mirror of
https://bitbucket.org/seefoe/src.git
synced 2026-07-30 00:15:46 -04:00
remove SOE deprecated code and files - leaving in the #if 0 blocks with TODO and other possible uses for later
This commit is contained in:
@@ -632,13 +632,6 @@ yyerrlab1: /* here on error raised explicitly by an action */
|
||||
|
||||
yyerrdefault: /* current state does not do anything special for the error token. */
|
||||
|
||||
#if 0
|
||||
/* This is wrong; only states that explicitly want error tokens
|
||||
should shift them. */
|
||||
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
|
||||
if (yyn) goto yydefault;
|
||||
#endif
|
||||
|
||||
yyerrpop: /* pop the current state because it cannot handle the error token */
|
||||
|
||||
if (yyssp == yyss) YYABORT;
|
||||
|
||||
@@ -380,201 +380,6 @@ static errorType evaluateArgs(void)
|
||||
return retVal;
|
||||
|
||||
return retVal;
|
||||
|
||||
#if 0
|
||||
|
||||
errorType retVal = ERR_NONE; // assume no error has been found
|
||||
bool outPathUsed = false; // flag to monitor if -o flag was used, if so, we can ignore -d, -p, -e, -f
|
||||
bool inFileEntered = false;
|
||||
int argc = CommandLine::getPlainCount();
|
||||
|
||||
// get default values from DOS
|
||||
char currentDir[maxStringSize];
|
||||
if (nullptr == getcwd(currentDir, maxStringSize)) // get current working directory
|
||||
{
|
||||
retVal = ERR_UNKNOWNDIR;
|
||||
return(retVal);
|
||||
}
|
||||
drive[0] = currentDir[0]; // drive letter
|
||||
drive[1] = 0; // and nullptr terminate it
|
||||
strcpy(extension, "IFF"); // default to uppercase .IFF
|
||||
strcpy(directory, ¤tDir[2]); // get everything after the Drive: including the first backslash
|
||||
filename[0] = 0;
|
||||
|
||||
// see specs.txt for requests
|
||||
// scan for any argv's that has '-' in the argv[n][0]'s character
|
||||
for (int index = 0; index < argc; index++) // note: if using argv[] rather then CommandLine::getPlainString() then start with 1 rather then 0
|
||||
{
|
||||
if ('-' == CommandLine::getPlainString(index)[0])
|
||||
{
|
||||
// we've found a parameter switch
|
||||
switch (tolower(CommandLine::getPlainString(index)[1])) // assume non case sensitive switches
|
||||
{
|
||||
case 'i': // install via #pragma
|
||||
{
|
||||
usePragma = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'c': // use CCCP instead of CPP
|
||||
useCCCP = true;
|
||||
break;
|
||||
|
||||
case 'v': // don't show any debug message
|
||||
verboseMode = true;
|
||||
break;
|
||||
|
||||
case '$':
|
||||
debugMode = true;
|
||||
break;
|
||||
|
||||
case 'o': // target output file name and path (complete path)
|
||||
{
|
||||
index++; // next param
|
||||
outPathUsed = true;
|
||||
strcpy(outFileName, CommandLine::getPlainString(index));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'd': // target drive letter (-p must be present)
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(drive, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the drive letter arg that SHOULD follow the -d option
|
||||
break;
|
||||
}
|
||||
|
||||
case 'p': // target pathname
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(directory, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the pathname arg that follows the -p option
|
||||
break;
|
||||
}
|
||||
|
||||
case 'f': // target filename
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(filename, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the filename arg that follows the -f
|
||||
break;
|
||||
}
|
||||
|
||||
case 'e': // target extension
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(extension, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the extension arg that follows the -e
|
||||
break;
|
||||
}
|
||||
|
||||
case 'h': // help!
|
||||
case '?':
|
||||
{
|
||||
help();
|
||||
index = argc; // force to exit
|
||||
retVal = ERR_HELPREQUEST;
|
||||
return(retVal); // special case, ONLY time I call return() in the middle of the function (because I check for argc < 2 at the end of the code)
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
sprintf(err_msg, "\nUnknown parameter %s, use -h to seek help...\n", CommandLine::getPlainString(index));
|
||||
MIFFMessage(err_msg, 1);
|
||||
index = argc; // force to exit
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we found an arg that doesn't start with '-' so let's assume it's a filename
|
||||
if (!inFileEntered)
|
||||
{
|
||||
strcpy(inFileName, CommandLine::getPlainString(index));
|
||||
inFileEntered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = ERR_MULTIPLEINFILE;
|
||||
index = argc;
|
||||
}
|
||||
|
||||
// now construct the DEFAULT filename for this file by scanning backwards to front and only extracting the filename (no extension, no path)
|
||||
if (ERR_NONE == retVal)
|
||||
{
|
||||
char sourceName[maxStringSize];
|
||||
strcpy(sourceName, inFileName); // make a duplicate for us to play with
|
||||
for (int strIndex = strlen(sourceName); strIndex > 0; strIndex--)
|
||||
{
|
||||
if ('.' == sourceName[strIndex])
|
||||
sourceName[strIndex] = 0; // put a stopper here... we are assuming that '.' indicates extension! I'm going to assume that the person is just testing me if s/he decides to use filename like "foo.bar.psych" which will truncate to "foo"
|
||||
if ('\\' == sourceName[strIndex])
|
||||
break; // get out, for we've reached the path name...
|
||||
}
|
||||
|
||||
// ok, by here, strIndex should point to either beginning of the string, or where the first '\' was found scanning backwards
|
||||
strcpy(filename, &sourceName[strIndex]); // ta-da-!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inFileEntered)
|
||||
{
|
||||
if (0 == preprocessSource(inFileName))
|
||||
{
|
||||
if (verboseMode)
|
||||
{
|
||||
// using err_msg as my temp buffer...
|
||||
sprintf(err_msg,"Now compiling %s\n", inFileName);
|
||||
MIFFMessage(err_msg, 0);
|
||||
}
|
||||
|
||||
if (ERR_NONE == retVal)
|
||||
retVal = loadInputToBuffer(sourceBuffer, bufferSize);
|
||||
}
|
||||
else // preprocessSource returned an error...
|
||||
{
|
||||
retVal = ERR_PREPROCESS;
|
||||
}
|
||||
}
|
||||
else // inFileEntered == false
|
||||
{
|
||||
MIFFMessage("Missing input filename in command line!", 1);
|
||||
}
|
||||
|
||||
// construct a outFileName[] based on drive[], directory[], filename[], and extension[]
|
||||
if (!outPathUsed && (ERR_NONE == retVal))
|
||||
{
|
||||
if (inFileName[0]) // make sure the user has entered a input filename
|
||||
sprintf(outFileName,"%s:%s\\%s.%s", drive, directory, filename, extension);
|
||||
}
|
||||
|
||||
if (argc < 1)
|
||||
retVal = ERR_ARGSTOOFEW; // we can do this because we know -h was not entered...
|
||||
|
||||
return(retVal);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -72,10 +72,6 @@ void TaskConnection::onConnectionOpened()
|
||||
void TaskConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
UNREF(message);
|
||||
#if 0
|
||||
Archive::ReadIterator r(message);
|
||||
GameNetworkMessage m(r);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -46,32 +46,8 @@ TaskManagerSysInfo & TaskManagerSysInfo::operator = (const TaskManagerSysInfo &
|
||||
|
||||
const float TaskManagerSysInfo::getScore() const
|
||||
{
|
||||
#if 0
|
||||
//Temporariy remove this since it's not giving us good results
|
||||
FILE * avg = popen("uptime", "r");
|
||||
float a = 0.0f;
|
||||
if(avg)
|
||||
{
|
||||
std::string output;
|
||||
while(!feof(avg))
|
||||
{
|
||||
char buf[1024] = {"\0"};
|
||||
|
||||
fread(buf, sizeof(buf), 1, avg);
|
||||
output += buf;
|
||||
}
|
||||
char formatted[1024] = {"\0"};
|
||||
std::string load = output.substr(output.find("load average:"));
|
||||
sscanf(load.c_str(), "load average: %f", &a);
|
||||
pclose(avg);
|
||||
}
|
||||
return a;
|
||||
#else
|
||||
|
||||
float ret = static_cast<float>(TaskManager::getNumGameConnections());
|
||||
return ret;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -77,10 +77,6 @@ void MetricsServerConnection::onProcessKilled(const ProcessKilled & k)
|
||||
|
||||
void MetricsServerConnection::receive(const Archive::ByteStream & )
|
||||
{
|
||||
#if 0
|
||||
Archive::ReadIterator r(message);
|
||||
GameNetworkMessage m(r);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -831,15 +831,6 @@ void TaskManager::update()
|
||||
lastTime = currentTime;
|
||||
}
|
||||
|
||||
#if 0
|
||||
instance().m_sysInfoSource->update();
|
||||
if (ms_doUpdate)
|
||||
{
|
||||
Locator::updateAllLoads();
|
||||
ms_doUpdate = false;
|
||||
}
|
||||
#endif//0
|
||||
|
||||
// get process status
|
||||
std::set<std::pair<std::string, unsigned long> >::iterator i;
|
||||
for(i = instance().m_localServers.begin(); i != instance().m_localServers.end();)
|
||||
|
||||
@@ -498,23 +498,6 @@ void DatabaseProcess::receiveMessage(const MessageDispatch::Emitter & source, co
|
||||
Loader::getInstance().checkVersionNumber(ConfigServerDatabase::getExpectedDBVersion(), ConfigServerDatabase::isCorrectDBVersionRequired());
|
||||
Loader::getInstance().loadClock();
|
||||
}
|
||||
else if(message.isType("LoadObjectMessage"))
|
||||
{
|
||||
#if 0
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
LoadObjectMessage lom(ri);
|
||||
connectToGameServer(lom.getAddress().c_str(),lom.getPort(),lom.getProcess());
|
||||
#endif
|
||||
}
|
||||
else if (message.isType("LoadUniverseMessage"))
|
||||
{
|
||||
#if 0
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
LoadUniverseMessage lom(ri);
|
||||
connectToGameServer(lom.getAddress().c_str(),lom.getPort(),lom.getProcess());
|
||||
#endif
|
||||
}
|
||||
|
||||
else if(message.isType("GameSetProcessId") || message.isType("GameGameServerConnect"))
|
||||
{
|
||||
GameServerConnection * g = const_cast<GameServerConnection *>(static_cast<const GameServerConnection *>(&source));
|
||||
|
||||
@@ -246,15 +246,6 @@ namespace CommoditiesMarketNamespace
|
||||
errorCode = ar_ITEM_EQUIPPED;
|
||||
}
|
||||
|
||||
#if 0
|
||||
const VolumeContainer *vol = ContainerInterface::getVolumeContainer(item);
|
||||
if (vol && vol->getCurrentVolume() > 0)
|
||||
{
|
||||
errorCode = ar_NOT_EMPTY;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if ((errorCode == ar_OK) && auctionContainer.isVendor() && !auctionContainer.isBazaarTerminal())
|
||||
{
|
||||
// check to make sure the vendor isn't restricted from accepting this item
|
||||
@@ -1772,67 +1763,9 @@ void CommoditiesMarket::auctionCreateImmediate(CreatureObject &owner, ServerObje
|
||||
|
||||
void CommoditiesMarket::auctionCreatePermanent(const std::string &, const ServerObject &, const ServerObject &, BidAmount , const Unicode::String &, bool )
|
||||
{
|
||||
if (!ConfigServerGame::getCommoditiesMarketEnabled())
|
||||
return;
|
||||
|
||||
DEBUG_WARNING(true, ("auctionCreatePermanent has been depricated and shouldn't be used. If you see this WARNING, add a line to catch cheaters in the command in CommandCppFuncs.cpp"));
|
||||
|
||||
return;
|
||||
|
||||
#if 0 //what the hell is this?
|
||||
|
||||
const NetworkId & itemId = item.getNetworkId();
|
||||
int flags = AUCTION_ALWAYS_PRESENT;
|
||||
if (premium)
|
||||
{
|
||||
flags |= AUCTION_PREMIUM_AUCTION;
|
||||
}
|
||||
const TangibleObject *tangibleObject = item.asTangibleObject();
|
||||
if (tangibleObject && tangibleObject->hasCondition(ServerTangibleObjectTemplate::C_magicItem))
|
||||
{
|
||||
flags |= AUCTION_MAGIC_ITEM;
|
||||
}
|
||||
|
||||
const Unicode::String objectName = Auction::getItemAuctionName(&item);
|
||||
|
||||
const AuctionToken & token = AuctionTokenServer::createTokenFor(item);
|
||||
Unicode::String oobData;
|
||||
OutOfBandPackager::pack(token, 0, oobData);
|
||||
|
||||
ServerObject::AttributeVector attributes;
|
||||
|
||||
//-- I don't know why this cast is necessary, but MSDEV is apparently confused otherwise
|
||||
static_cast<const ServerObject &>(item).getAttributes(NetworkId::cms_invalid, attributes);
|
||||
OutOfBandPackager::pack(attributes, 1, oobData);
|
||||
|
||||
OutOfBandPackager::pack(item.getTemplateName(), 2, oobData);
|
||||
|
||||
if (s_market)
|
||||
{
|
||||
s_market->AddImmediateAuction(
|
||||
-1,
|
||||
ownerName,
|
||||
price,
|
||||
1,
|
||||
itemId,
|
||||
objectName.size(), objectName.data(),
|
||||
item.getGameObjectType(),
|
||||
ConfigServerGame::getUnclaimedAuctionItemDestroyTimeSec(),
|
||||
auctionContainer.getNetworkId(),
|
||||
getLocationString(auctionContainer),
|
||||
flags,
|
||||
userDescription.size(), userDescription.data(),
|
||||
oobData.size(),
|
||||
oobData);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
DEBUG_WARNING(true, ("[Commodities API] : No commodities server connection to send AddImmediateAuction."));
|
||||
|
||||
getCommoditiesServerConnection(); //attempt to reconnect to commodities server
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -91,13 +91,6 @@ namespace PreloadManagerNameSpace
|
||||
if (tmp)
|
||||
line = tmp;
|
||||
|
||||
DataTable* dt = DataTableManager::getTable(line, true);
|
||||
#if 0
|
||||
if (dt)
|
||||
ms_dataTableList.push_back(dt);
|
||||
#else
|
||||
UNREF(dt);
|
||||
#endif
|
||||
DEBUG_REPORT_LOG(true, ("."));
|
||||
line = fgets(buf, 256, fp);
|
||||
}
|
||||
|
||||
@@ -549,16 +549,6 @@ void ServerBuildoutManagerNamespace::buildObjectsToSave(std::vector<ServerObject
|
||||
|
||||
bool ServerBuildoutManagerNamespace::isNotObjectForBuildout(ServerObject const *obj)
|
||||
{
|
||||
#if 0
|
||||
DEBUG_REPORT_LOG_PRINT( true, ( "isNotObjectForBuildout: %s [%d] ver=%d isPersisted=%d isPlayerController=%d includeInBuildout=%d\n" ,
|
||||
Unicode::wideToNarrow( obj->getObjectName() ).c_str(),
|
||||
(int)obj->getNetworkId().getValue(),
|
||||
obj->getCacheVersion(),
|
||||
obj->isPersisted(),
|
||||
obj->isPlayerControlled(),
|
||||
obj->getIncludeInBuildout() ) );
|
||||
#endif
|
||||
|
||||
const ServerObject * const containingObject = safe_cast<const ServerObject *>(ContainerInterface::getContainedByObject(*obj));
|
||||
|
||||
// make sure that cells that should be included in the buildout have all their
|
||||
@@ -750,12 +740,6 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo)
|
||||
|
||||
FATAL( isPob && ( cellIndex != 0 || containerId != 0 ), ( "tried to add a pob to a cell or other container. %s (objId=%d cellIndex=%d containerId=%d)",
|
||||
serverTemplateBase->getName(), objId, cellIndex,containerId ) );
|
||||
#if 0
|
||||
DEBUG_REPORT_LOG_PRINT( true, ( "SERVER --------- objId=%016I64x container=%016I64x\n",
|
||||
objId,
|
||||
containerId));
|
||||
|
||||
#endif
|
||||
|
||||
Quaternion const q(
|
||||
areaBuildoutTable.getFloatValue(qwColumn, buildoutRow),
|
||||
|
||||
@@ -2524,18 +2524,6 @@ void ServerWorld::remove()
|
||||
delete m_sceneId;
|
||||
m_sceneId = 0;
|
||||
|
||||
#if 0 //removed pending objects
|
||||
ObjectMap::iterator objIter;
|
||||
while (m_pendingObjects->size() > 0)
|
||||
{
|
||||
objIter = m_pendingObjects->begin();
|
||||
object = (*objIter).second;
|
||||
m_pendingObjects->erase(objIter);
|
||||
delete object;
|
||||
}
|
||||
delete m_pendingObjects;
|
||||
m_pendingObjects = 0;
|
||||
#endif
|
||||
delete g_objectSphereTree;
|
||||
g_objectSphereTree = 0;
|
||||
delete g_triggerSphereTree;
|
||||
|
||||
@@ -2821,12 +2821,6 @@ float CreatureObject::alter(float time)
|
||||
}
|
||||
|
||||
//check timer and migrate stats if necessary
|
||||
|
||||
//disable self stat migration
|
||||
#if 0
|
||||
migrateStats(time);
|
||||
#endif
|
||||
|
||||
if (isPlayerControlled())
|
||||
{
|
||||
PROFILER_AUTO_BLOCK_DEFINE("CreatureObject::alter auth player stuff");
|
||||
|
||||
@@ -112,36 +112,12 @@ void GroupWaypointBuilderNamespace::updateGroupWaypoints(PlayerObject &playerObj
|
||||
|
||||
void GroupWaypointBuilder::updateGroupWaypoints(GroupObject const &groupObject)
|
||||
{
|
||||
#if 0
|
||||
PlayerObject::WaypointMap groupWaypoints;
|
||||
buildGroupWaypoints(groupObject, groupWaypoints);
|
||||
GroupWaypointBuilderNamespace::updateGroupWaypoints(groupObject, groupWaypoints);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void GroupWaypointBuilder::updateGroupWaypoints(PlayerObject &playerObject, bool const updateGroup)
|
||||
{
|
||||
#if 0
|
||||
CreatureObject const * const creatureObject = playerObject.getCreatureObject();
|
||||
if (creatureObject)
|
||||
{
|
||||
GroupObject const * const groupObject = creatureObject->getGroup();
|
||||
if (groupObject && updateGroup)
|
||||
{
|
||||
PlayerObject::WaypointMap groupWaypoints;
|
||||
buildGroupWaypoints(*groupObject, groupWaypoints);
|
||||
GroupWaypointBuilderNamespace::updateGroupWaypoints(*groupObject, groupWaypoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerObject::WaypointMap groupWaypoints;
|
||||
buildGroupWaypoints(playerObject, groupWaypoints);
|
||||
GroupWaypointBuilderNamespace::updateGroupWaypoints(playerObject, groupWaypoints);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -2411,13 +2411,6 @@ int ServerObject::getVolume(void) const
|
||||
{
|
||||
const VolumeContainmentProperty* volumeProperty = ContainerInterface::getVolumeContainmentProperty(*this);
|
||||
return volumeProperty ? volumeProperty->getVolume() : 1;
|
||||
#if 0
|
||||
const VolumeContainer * container = ContainerInterface::getVolumeContainer(*this);
|
||||
if (container)
|
||||
return m_volume.get()+container->getCurrentVolume();
|
||||
else
|
||||
return m_volume.get();
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -268,20 +268,6 @@ void ShipClientUpdateTracker::update(float elapsedTime) // static
|
||||
|
||||
static Archive::ByteStream bs;
|
||||
|
||||
#if 0
|
||||
GameClientMessage gcm(
|
||||
(*k).second,
|
||||
false,
|
||||
ShipUpdateTransformMessage(
|
||||
ship->getNetworkId(),
|
||||
controller->getTransform(),
|
||||
controller->getVelocity(),
|
||||
controller->getYawRate(),
|
||||
controller->getPitchRate(),
|
||||
controller->getRollRate(),
|
||||
(*j).first->getSyncStampLong()));
|
||||
gcm.pack(bs);
|
||||
#else
|
||||
static ConstCharCrcString const s_gcmname("GameClientMessage");
|
||||
static ConstCharCrcString const s_sutmname("ShipUpdateTransformMessage");
|
||||
static unsigned int const s_sutmByteStreamLength =
|
||||
@@ -313,7 +299,6 @@ void ShipClientUpdateTracker::update(float elapsedTime) // static
|
||||
PackedRotationRate const packedRollRate(controller->getRollRate());
|
||||
Archive::put(bs, packedRollRate);
|
||||
Archive::put(bs, (*j).first->getSyncStampLong());
|
||||
#endif
|
||||
|
||||
(*j).first->Connection::send(bs, false);
|
||||
bs.clear();
|
||||
|
||||
@@ -733,63 +733,6 @@ void ServerSecureTrade::removeItem(const CreatureObject & trader, const ServerOb
|
||||
//-- CS requested that removing an item cancels the trade to prevent scamming
|
||||
UNREF (item);
|
||||
cancelTrade (trader);
|
||||
|
||||
#if 0
|
||||
if (m_tradeState != TS_Trading)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("Secure Trade: received an remove item in non-trade state\n"));
|
||||
beginTrading();
|
||||
}
|
||||
|
||||
if (&trader == m_initiator)
|
||||
{
|
||||
std::vector<ServerObject *>::iterator i = std::find(m_initiatorContents->begin(), m_initiatorContents->end(), &item);
|
||||
if (i != m_initiatorContents->end())
|
||||
{
|
||||
m_initiatorContents->erase(i);
|
||||
|
||||
Client * const recipientClient = m_recipient->getClient();
|
||||
if (recipientClient)
|
||||
{
|
||||
RemoveItemMessage const m(item.getNetworkId());
|
||||
recipientClient->send(m, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//@todo need an error message
|
||||
}
|
||||
|
||||
}
|
||||
else if (& trader == m_recipient)
|
||||
{
|
||||
std::vector<ServerObject *>::iterator i = std::find(m_recipientContents->begin(), m_recipientContents->end(), &item);
|
||||
if (i != m_recipientContents->end())
|
||||
{
|
||||
m_recipientContents->erase(i);
|
||||
|
||||
Client * const initiatorClient = m_initiator->getClient();
|
||||
if (initiatorClient)
|
||||
{
|
||||
RemoveItemMessage const m(item.getNetworkId());
|
||||
initiatorClient->send(m, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//@todo need an error message for not found.
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("Secure Trade: received a remove Item from non participant\n"));
|
||||
return;
|
||||
}
|
||||
unacceptOffer(*m_initiator);
|
||||
unacceptOffer(*m_recipient);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -42,23 +42,7 @@ KeyServer::~KeyServer()
|
||||
|
||||
bool KeyServer::update(void)
|
||||
{
|
||||
bool result = false;
|
||||
#if 0 // disable key rotation
|
||||
lastUpdateTime += Clock::frameTime();
|
||||
if(lastUpdateTime > updateRate)
|
||||
{
|
||||
lastUpdateTime = CONST_REAL(0.0);
|
||||
KeyShare::Key k;
|
||||
for(unsigned int j = 0; j < KeyShareConstants::keyLength; j ++)
|
||||
{
|
||||
k.value[j] = static_cast<unsigned char>(randomNumberGenerator->random(255));
|
||||
}
|
||||
pushKey(k);
|
||||
result = true;
|
||||
}
|
||||
#endif // disable key rotation
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -4705,20 +4705,6 @@ int JavaLibrary::runScript(const NetworkId & caller, const std::string& script,
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case 'S':
|
||||
{
|
||||
arg = globals.getNextStringId();
|
||||
if (arg == 0)
|
||||
{
|
||||
return SCRIPT_OVERRIDE;
|
||||
}
|
||||
// @todo: fix this when we get real string ids
|
||||
// int param = atoi(stringArg);
|
||||
// ms_env->SetIntField(arg, ms_fidStringIdData, static_cast<jint>(param));
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
DEBUG_REPORT_LOG(true, ("unknown parameter type %c(%#x)\n", argList[i],
|
||||
static_cast<unsigned>(argList[i]))); //lint !e571 suspicious cast
|
||||
|
||||
@@ -181,29 +181,6 @@ jstring JNICALL ScriptMethodsChatNamespace::chatPackOutOfBandToken(JNIEnv * env,
|
||||
|
||||
JavaString result("JavaLibrary::chatPackOutOfBandToken - FAILED Token archive not implemented");
|
||||
return result.getReturnValue();
|
||||
|
||||
#if 0
|
||||
JavaStringParam jt(target);
|
||||
Unicode::String t;
|
||||
if(! JavaLibrary::convert(jt, t))
|
||||
return 0;
|
||||
|
||||
if(! source)
|
||||
return 0;
|
||||
|
||||
Token * token = 0;
|
||||
if(!JavaLibrary::getObject(source, token))
|
||||
return 0;
|
||||
|
||||
Archive::ByteStream bs;
|
||||
Archive::put(bs, std::string(token->getObjectTemplateName()));
|
||||
Archive::put(bs, *token);
|
||||
|
||||
OutOfBandPackager::pack(bs, gs_Object, position, t);
|
||||
|
||||
JavaString result(t);
|
||||
return result.getReturnValue();
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -43,9 +43,6 @@ voidpf ZlibCompressorNamespace::allocateWrapper(voidpf opaque, uInt items, uInt
|
||||
UNREF(opaque);
|
||||
void *result = 0;
|
||||
|
||||
#if 0
|
||||
result = operator new(items * size);
|
||||
#else
|
||||
int totalSize = items * size;
|
||||
if (totalSize > cms_poolElementThreshold)
|
||||
{
|
||||
@@ -67,7 +64,6 @@ voidpf ZlibCompressorNamespace::allocateWrapper(voidpf opaque, uInt items, uInt
|
||||
|
||||
ms_mutex.leave();
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -78,9 +74,6 @@ void ZlibCompressorNamespace::freeWrapper(voidpf opaque, voidpf address)
|
||||
{
|
||||
UNREF(opaque);
|
||||
|
||||
#if 0
|
||||
operator delete(address);
|
||||
#else
|
||||
if (address < ms_memoryBottom || address >= ms_memoryTop)
|
||||
operator delete(address);
|
||||
else
|
||||
@@ -89,7 +82,6 @@ void ZlibCompressorNamespace::freeWrapper(voidpf opaque, voidpf address)
|
||||
ms_memoryPool.push_back(address);
|
||||
ms_mutex.leave();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -417,10 +417,6 @@ void DebugMonitor::flushOutput()
|
||||
const int input = wgetch(s_outputWindow);
|
||||
if (input != ERR)
|
||||
{
|
||||
#if 0
|
||||
DEBUG_REPORT_LOG(true, ("DebugMonitor: received key [index=%d].\n", input));
|
||||
#endif
|
||||
|
||||
//-- Handle input.
|
||||
switch (input)
|
||||
{
|
||||
|
||||
@@ -248,10 +248,6 @@ public:
|
||||
|
||||
void read_string(Unicode::String &str);
|
||||
Unicode::String read_unicodeString();
|
||||
|
||||
#if 0
|
||||
real *read_float (int count, real *array=nullptr);
|
||||
#endif
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -115,26 +115,14 @@ void FloatingPointUnit::update(void)
|
||||
|
||||
WORD FloatingPointUnit::getControlWord(void)
|
||||
{
|
||||
//TODO wtf is this asm statement?
|
||||
#if 0
|
||||
WORD controlWord = 0;
|
||||
__asm fnstcw controlWord;
|
||||
return controlWord;
|
||||
#else
|
||||
return status;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void FloatingPointUnit::setControlWord(WORD controlWord)
|
||||
{
|
||||
//TODO see above?
|
||||
|
||||
UNREF(controlWord);
|
||||
#if 0
|
||||
__asm fldcw controlWord;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -88,11 +88,6 @@ void Os::installCommon(void)
|
||||
|
||||
ExitChain::add(Os::remove, "Os::remove", 0, true);
|
||||
|
||||
#if 0 //TODO For now we won't screw with the priority of the process
|
||||
HANDLE threadHandle = GetCurrentThread();
|
||||
DEBUG_FATAL(!SetThreadPriority(threadHandle, THREAD_PRIORITY_ABOVE_NORMAL), ("Failed to set game thread priority"));
|
||||
#endif
|
||||
|
||||
numberOfUpdates = 0;
|
||||
mainThreadId = pthread_self();
|
||||
|
||||
@@ -299,19 +294,6 @@ bool Os::update(void)
|
||||
|
||||
++numberOfUpdates;
|
||||
|
||||
#if 0
|
||||
#ifdef _DEBUG
|
||||
|
||||
if (DEBUG_FLAG_PLATFORM(validateHeap))
|
||||
{
|
||||
PROFILER_START("validate heap");
|
||||
MemoryManager::validate();
|
||||
PROFILER_STOP("validate heap");
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Clock::update();
|
||||
|
||||
wasPaused = false;
|
||||
|
||||
@@ -179,13 +179,6 @@ DWORD GetFileSize(FILE* hFile, DWORD* lpHighSize)
|
||||
endPos = ftell(hFile);
|
||||
fseek(hFile, curPos, SEEK_SET);
|
||||
return endPos;
|
||||
|
||||
#if 0
|
||||
//This is what I want to do, but I have no file des number
|
||||
struct stat buf;
|
||||
fstat(hFile, &buf);
|
||||
return buf->st_size;
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOL FileExists(const char* filename)
|
||||
|
||||
@@ -44,12 +44,6 @@ void SetupSharedFoundation::install(const Data &data)
|
||||
if (data.argc)
|
||||
CommandLine::absorbStrings(const_cast<const char**>(data.argv+1), data.argc-1);
|
||||
|
||||
#if 0
|
||||
//currently there's a problem that we cannot override the defaults here.
|
||||
if (data.configFile)
|
||||
IGNORE_RETURN(ConfigFile::loadFile(data.configFile));
|
||||
#endif
|
||||
|
||||
// get the post command-line text for the ConfigFile (key-value pairs)
|
||||
const char *configString = CommandLine::getPostCommandLineString();
|
||||
if (configString)
|
||||
|
||||
@@ -254,24 +254,6 @@ void Clock::update(void)
|
||||
ms_lastFrameRate = RECIP(ms_lastFrameTime);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// -qq- debugging W2K QueryPerformanceCounter
|
||||
static DWORD lastTick;
|
||||
DWORD newTick = GetTickCount();
|
||||
|
||||
DEBUG_REPORT_LOG_PRINT(true, ("Clock::update %I64d %I64d %6I64d %10d %10d %3d %6.2f=fps %6.4f=time\n", ms_lastPoll, newPoll, newPoll - ms_lastPoll, lastTick, newTick, newTick - lastTick, ms_lastFrameRate, ms_lastFrameTime));
|
||||
|
||||
static int bad = 0;
|
||||
|
||||
if (bad && ++bad > 64)
|
||||
__asm int 3;
|
||||
|
||||
if (ms_lastFrameTime > 3.0)
|
||||
bad = 1;
|
||||
|
||||
lastTick = newTick;
|
||||
#endif
|
||||
|
||||
ms_lastPoll = newPoll;
|
||||
|
||||
|
||||
|
||||
@@ -78,25 +78,6 @@ uint32 Crc::calculate(const char *string)
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
uint32 Crc::calculateWithToLower(const char *string)
|
||||
{
|
||||
uint32 crc;
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
for (crc = CRC_INIT; *string; ++string)
|
||||
crc = crctable[((crc>>24) ^ static_cast<uint32>(tolower(*string))) & 0xFF] ^ (crc << 8);
|
||||
|
||||
return (crc ^ CRC_INIT);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
uint32 Crc::calculate(const void *data, int length, uint32 initCrc)
|
||||
{
|
||||
DEBUG_FATAL(!data, ("nullptr data arg"));
|
||||
|
||||
@@ -321,16 +321,6 @@ WearableAppearanceMap::MapResult::MapResult(MapResult const &rhs) :
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
WearableAppearanceMap::MapResult &WearableAppearanceMap::MapResult::operator =(MapResult const &rhs)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool WearableAppearanceMap::MapResult::hasMapping() const
|
||||
{
|
||||
return m_hasMapping;
|
||||
|
||||
@@ -485,15 +485,6 @@ int Quest::getMoneyRewardCredits() const
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
std::vector<QuestTask *> const & Quest::getTasks() const
|
||||
{
|
||||
return *m_tasks;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Conversts a comma-delimited list of strings into a vector or the CRCs
|
||||
* of those strings.
|
||||
|
||||
@@ -367,13 +367,6 @@ void ImageManipulation::install(const InstallData &installData)
|
||||
|
||||
//-- make sure we've got valid function pointers for all
|
||||
NOT_NULL(ms_nextMipmapFunction);
|
||||
#if 0
|
||||
NOT_NULL(ms_convertFormatFunction);
|
||||
NOT_NULL(ms_copyIgnoreAlphaFunction);
|
||||
NOT_NULL(ms_copyRespectAlphaFunction);
|
||||
NOT_NULL(ms_blendFunction);
|
||||
NOT_NULL(ms_blendTwoFunction);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -55,20 +55,7 @@ public:
|
||||
|
||||
static void install(const InstallData &installData);
|
||||
|
||||
static void generateNextSmallerMipmap(const Image &sourceImage, Image &destImage);
|
||||
|
||||
#if 0
|
||||
static void convertFormatSameSize(const Image &sourceImage, Image &destImage);
|
||||
|
||||
// these functions require same pixel format. they do not stretch or compress pixels.
|
||||
static void copyIgnoreAlpha(const Image &sourceImage, int sourceX, int sourceY, int width, int height, Image &destImage, int destX, int destY);
|
||||
static void copyRespectAlpha(const Image &sourceImage, int sourceX, int sourceY, int width, int height, Image &destImage, int destX, int destY);
|
||||
|
||||
// these two always respect alpha
|
||||
static void blend(float sourceBlendFactor, const Image &sourceImage, int sourceX, int sourceY, int width, int height, Image &destImage, int destX, int destY);
|
||||
static void blendTwo(float firstSourceBlendFactor, float resultToDestBlendFactor, const Image &sourceImage1, const Image &sourceImage2, int sourceX, int sourceY, int width, int height, Image &destImage, int destX, int destY);
|
||||
#endif
|
||||
|
||||
static void generateNextSmallerMipmap(const Image &sourceImage, Image &destImage);
|
||||
private:
|
||||
|
||||
static void remove();
|
||||
|
||||
@@ -146,7 +146,7 @@ void PaletteArgb::release() const
|
||||
--m_referenceCount;
|
||||
|
||||
//-- We are going to let the PaletteArgbList keep references to the palettes and clean them up at the end.
|
||||
#if 0
|
||||
#if 0 //TODO: should we use the below or nuke it?
|
||||
if (m_referenceCount == 0)
|
||||
{
|
||||
PaletteArgbList::stopTracking(*this);
|
||||
|
||||
-5
@@ -41,11 +41,6 @@ public:
|
||||
virtual void deleteLinksTo(const CustomizationData &customizationData) = 0;
|
||||
|
||||
virtual bool isLocalDirectory() const = 0;
|
||||
#if 0
|
||||
virtual std::string writeLocalDirectoryToString() const = 0;
|
||||
|
||||
virtual void loadLocalDirectoryFromString(int version, const std::string &string, int startIndex) = 0;
|
||||
#endif
|
||||
CustomizationData &getOwner();
|
||||
const CustomizationData &getOwner() const;
|
||||
|
||||
|
||||
-227
@@ -395,231 +395,4 @@ bool CustomizationData::LocalDirectory::isLocalDirectory() const
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
std::string CustomizationData::LocalDirectory::writeLocalDirectoryToString() const
|
||||
{
|
||||
char scratchBuffer[1024];
|
||||
std::string data;
|
||||
|
||||
//-- count # persistable variables
|
||||
int variableCount = 0;
|
||||
|
||||
{
|
||||
const CustomizationVariableMap::const_iterator endIt = m_variables.end();
|
||||
for (CustomizationVariableMap::const_iterator it = m_variables.begin(); it != endIt; ++it)
|
||||
{
|
||||
//-- verify it's a non-nullptr variable
|
||||
const CustomizationVariable *const variable = it->second;
|
||||
if (variable && variable->doesVariablePersist())
|
||||
{
|
||||
// we will write this variable
|
||||
++variableCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-- write # variables
|
||||
sprintf(scratchBuffer, "%x%c", variableCount, cms_stringFieldSeparator);
|
||||
data += scratchBuffer;
|
||||
|
||||
//-- write each variable
|
||||
{
|
||||
const CustomizationVariableMap::const_iterator endIt = m_variables.end();
|
||||
for (CustomizationVariableMap::const_iterator it = m_variables.begin(); it != endIt; ++it)
|
||||
{
|
||||
//-- verify it's a non-nullptr variable
|
||||
const CustomizationVariable *const variable = it->second;
|
||||
if (!variable)
|
||||
{
|
||||
WARNING(true, ("writeLocalDirectoryToString: nullptr variable for [%s], skipping variable writing."));
|
||||
continue;
|
||||
}
|
||||
|
||||
//-- skip variables that should not be written. typically this will be constant data
|
||||
// that doesn't need to be customized or transmitted/persisted.
|
||||
if (!variable->doesVariablePersist())
|
||||
continue;
|
||||
|
||||
//-- write variable name
|
||||
data += it->first.getString();
|
||||
data += cms_stringFieldSeparator;
|
||||
|
||||
//-- write variable data
|
||||
// get variable content data
|
||||
const std::string variableContents = variable->writeToString();
|
||||
|
||||
// write content length (we do this so we can skip a variable if its not supported at load time)
|
||||
sprintf(scratchBuffer, "%x%c", variableContents.size(), cms_stringFieldSeparator);
|
||||
data += scratchBuffer;
|
||||
|
||||
// write variable content
|
||||
data += variableContents;
|
||||
}
|
||||
}
|
||||
|
||||
//-- get # local directories to write
|
||||
int directoryCount = 0;
|
||||
{
|
||||
const DirectoryMap::const_iterator endIt = m_directories.end();
|
||||
for (DirectoryMap::const_iterator it = m_directories.begin(); it != endIt; ++it)
|
||||
{
|
||||
if (it->second && it->second->isLocalDirectory())
|
||||
++directoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
//-- write # directories
|
||||
sprintf(scratchBuffer, "%x%c", directoryCount, cms_stringFieldSeparator);
|
||||
data += scratchBuffer;
|
||||
|
||||
//-- write directory contents
|
||||
{
|
||||
const DirectoryMap::const_iterator endIt = m_directories.end();
|
||||
for (DirectoryMap::const_iterator it = m_directories.begin(); it != endIt; ++it)
|
||||
{
|
||||
if (it->second && it->second->isLocalDirectory())
|
||||
{
|
||||
// write directory name
|
||||
data += it->first.getString();
|
||||
data += cms_stringFieldSeparator;
|
||||
|
||||
// get directory data contents
|
||||
const std::string subdirData = it->second->writeLocalDirectoryToString();
|
||||
|
||||
// write directory data size (we do this so we can skip a directory if its not supported at load time)
|
||||
sprintf(scratchBuffer, "%x%c", subdirData.size(), cms_stringFieldSeparator);
|
||||
data += scratchBuffer;
|
||||
|
||||
// write directory contents
|
||||
data += subdirData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
void CustomizationData::LocalDirectory::loadLocalDirectoryFromString(int version, const std::string &string, int startIndex)
|
||||
{
|
||||
if (version == 2)
|
||||
loadLocalDirectoryFromString_0002(string, startIndex);
|
||||
else
|
||||
WARNING(true, ("loadLocalDirectoryFromString(): unsupported version [%d]", version));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#if 0
|
||||
|
||||
void CustomizationData::LocalDirectory::loadLocalDirectoryFromString_0002(const std::string &data, int startIndex)
|
||||
{
|
||||
int currentPosition = startIndex;
|
||||
|
||||
//-- get # variables
|
||||
const int variableCount = parseSeparatedHexInt(data, currentPosition, currentPosition);
|
||||
if (currentPosition == static_cast<int>(std::string::npos))
|
||||
{
|
||||
WARNING(true, ("loadLocalDirectoryFromString_0002(): failed to load variable count, aborting load."));
|
||||
return;
|
||||
}
|
||||
|
||||
//-- load each variable
|
||||
{
|
||||
for (int i = 0; i < variableCount; ++i)
|
||||
{
|
||||
//-- load the variable name
|
||||
const std::string variableName = parseSeparatedString(data, currentPosition, currentPosition);
|
||||
if (currentPosition == static_cast<int>(std::string::npos))
|
||||
{
|
||||
WARNING(true, ("loadLocalDirectoryFromString_0002(): failed to load variable name, aborting load."));
|
||||
return;
|
||||
}
|
||||
|
||||
//-- load the # characters in the value data
|
||||
const int valueCharacterCount = parseSeparatedHexInt(data, currentPosition, currentPosition);
|
||||
if (currentPosition == static_cast<int>(std::string::npos))
|
||||
{
|
||||
WARNING(true, ("loadLocalDirectoryFromString_0002(): failed to load variable data size, aborting load."));
|
||||
return;
|
||||
}
|
||||
|
||||
//-- find the customization variable
|
||||
CustomizationVariable *const variable = findVariable(variableName, 0);
|
||||
if (!variable)
|
||||
{
|
||||
WARNING(true, ("loadLocalDirectoryFromString_0002(): variable [%s] does not exist to be restored.", variableName.c_str()));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//-- load the data
|
||||
if (!variable->loadFromString(2, std::string(data, static_cast<std::string::size_type>(currentPosition), static_cast<std::string::size_type>(valueCharacterCount))))
|
||||
WARNING(true, ("loadLocalDirectoryFromString_0002(): variable [%s] failed to load.", variableName.c_str()));
|
||||
}
|
||||
|
||||
//-- pass the variable data
|
||||
currentPosition += valueCharacterCount;
|
||||
}
|
||||
}
|
||||
|
||||
//-- get # subdirectories
|
||||
const int directoryCount = parseSeparatedHexInt(data, currentPosition, currentPosition);
|
||||
if (currentPosition == static_cast<int>(std::string::npos))
|
||||
{
|
||||
WARNING(true, ("loadLocalDirectoryFromString_0002(): failed to load directory count, aborting load."));
|
||||
return;
|
||||
}
|
||||
|
||||
//-- load each subdirectory
|
||||
{
|
||||
for (int i = 0; i < directoryCount; ++i)
|
||||
{
|
||||
//-- load the directory name
|
||||
const std::string directoryName = parseSeparatedString(data, currentPosition, currentPosition);
|
||||
if (currentPosition == static_cast<int>(std::string::npos))
|
||||
{
|
||||
WARNING(true, ("loadLocalDirectoryFromString_0002(): failed to load directory name, aborting load."));
|
||||
return;
|
||||
}
|
||||
|
||||
//-- load the # characters in the value data
|
||||
const int directoryCharacterCount = parseSeparatedHexInt(data, currentPosition, currentPosition);
|
||||
if (currentPosition == static_cast<int>(std::string::npos))
|
||||
{
|
||||
WARNING(true, ("loadLocalDirectoryFromString_0002(): failed to load directory data size, aborting load."));
|
||||
return;
|
||||
}
|
||||
|
||||
//-- find the customization variable
|
||||
Directory *const directory = findDirectory(directoryName, 0);
|
||||
if (!directory)
|
||||
{
|
||||
WARNING(true, ("loadLocalDirectoryFromString_0002(): object id=[%s], directory [%s] does not exist to be restored.", getOwner().getOwnerObject().getNetworkId().getValueString().c_str(), directoryName.c_str()));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//-- load the data
|
||||
directory->loadLocalDirectoryFromString(2, data, currentPosition);
|
||||
}
|
||||
|
||||
//-- pass the variable data
|
||||
currentPosition += directoryCharacterCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ======================================================================
|
||||
|
||||
-10
@@ -49,11 +49,6 @@ public:
|
||||
virtual void deleteLinksTo(const CustomizationData &customizationData);
|
||||
|
||||
virtual bool isLocalDirectory() const;
|
||||
#if 0
|
||||
virtual std::string writeLocalDirectoryToString() const;
|
||||
|
||||
virtual void loadLocalDirectoryFromString(int version, const std::string &string, int startIndex);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@@ -61,11 +56,6 @@ private:
|
||||
typedef stdmap<const CrcLowerString, CustomizationVariable*>::fwd CustomizationVariableMap;
|
||||
|
||||
private:
|
||||
|
||||
#if 0
|
||||
void loadLocalDirectoryFromString_0002(const std::string &string, int startIndex);
|
||||
#endif
|
||||
|
||||
// Disabled.
|
||||
LocalDirectory();
|
||||
LocalDirectory(const LocalDirectory&);
|
||||
|
||||
-27
@@ -164,31 +164,4 @@ bool CustomizationData::RemoteDirectory::isLocalDirectory() const
|
||||
return false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
std::string CustomizationData::RemoteDirectory::writeLocalDirectoryToString() const
|
||||
{
|
||||
WARNING(true, ("writeLocalDirectoryToString(): operation makes no sense on RemoteDirectory instances.\n"));
|
||||
return "";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
void CustomizationData::RemoteDirectory::loadLocalDirectoryFromString(int version, const std::string &string, int startIndex)
|
||||
{
|
||||
UNREF(version);
|
||||
UNREF(string);
|
||||
UNREF(startIndex);
|
||||
|
||||
WARNING(true, ("loadLocalDirectoryFromString(): operation makes no sense on RemoteDirectory instances."));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ======================================================================
|
||||
|
||||
-5
@@ -47,11 +47,6 @@ public:
|
||||
virtual void deleteLinksTo(const CustomizationData &customizationData);
|
||||
|
||||
virtual bool isLocalDirectory() const;
|
||||
#if 0
|
||||
virtual std::string writeLocalDirectoryToString() const;
|
||||
|
||||
virtual void loadLocalDirectoryFromString(int version, const std::string &string, int startIndex);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
|
||||
-53
@@ -52,36 +52,6 @@ int RangedIntCustomizationVariable::getPersistedDataByteCount() const
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
std::string RangedIntCustomizationVariable::writeToString() const
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf(buffer, "%x", getValue());
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
bool RangedIntCustomizationVariable::loadFromString(int version, const std::string &data)
|
||||
{
|
||||
if (version == 2)
|
||||
return loadFromString_0002(data);
|
||||
else
|
||||
{
|
||||
WARNING(true, ("loadFromString(): version %d unsupported.\n", version));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void RangedIntCustomizationVariable::saveToByteVector(ByteVector &data) const
|
||||
{
|
||||
int const byteCount = getPersistedDataByteCount();
|
||||
@@ -179,29 +149,6 @@ RangedIntCustomizationVariable::RangedIntCustomizationVariable()
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#if 0
|
||||
|
||||
bool RangedIntCustomizationVariable::loadFromString_0002(const std::string &data)
|
||||
{
|
||||
int newValue;
|
||||
|
||||
const int scanfResult = sscanf(data.c_str(), "%x", &newValue);
|
||||
if (scanfResult != 1)
|
||||
{
|
||||
// failed
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(newValue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This function computes the normalized value.
|
||||
* @return a number in [0.0,1.0]
|
||||
|
||||
-4
@@ -46,10 +46,6 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
#if 0
|
||||
bool loadFromString_0002(const std::string &data);
|
||||
#endif
|
||||
|
||||
// disabled
|
||||
RangedIntCustomizationVariable(const RangedIntCustomizationVariable&);
|
||||
RangedIntCustomizationVariable &operator =(const RangedIntCustomizationVariable&);
|
||||
|
||||
@@ -1390,10 +1390,6 @@ void Object::setParentCell(CellProperty *cellProperty)
|
||||
if (getParentCell() == cellProperty)
|
||||
return;
|
||||
|
||||
#if 0
|
||||
DEBUG_FATAL(isChildObject(), ("Object::setParentCell called on child object [id=%s template=%s] with parent object [id=%s template=%s]", getNetworkId().getValueString().c_str(), getObjectTemplateName(), m_attachedToObject->getNetworkId().getValueString().c_str(), m_attachedToObject->getObjectTemplateName()));
|
||||
#endif
|
||||
|
||||
// if we were in another cell, detach us. This will leave out object in world space.
|
||||
if (!isInWorldCell())
|
||||
detachFromObject(DF_world);
|
||||
|
||||
@@ -722,14 +722,6 @@ CellProperty *CellProperty::getDestinationCell(const Vector &startPosition, cons
|
||||
CellProperty *cellProperty = 0;
|
||||
closestPortalT = FLT_MAX;
|
||||
|
||||
#if 0
|
||||
if ((startPosition - endPosition).magnitude() > 2.0f)
|
||||
{
|
||||
static volatile int debug = 0;
|
||||
++debug;
|
||||
}
|
||||
#endif
|
||||
|
||||
const PortalObjectList::const_iterator iEnd = m_portalObjectList->end();
|
||||
for (PortalObjectList::const_iterator i = m_portalObjectList->begin(); i != iEnd; ++i)
|
||||
{
|
||||
|
||||
@@ -229,7 +229,7 @@ bool PortalProperty::serverEndBaselines(int serverObjectCrc, std::vector<Object*
|
||||
//-- fixupObject() causes the fixedup object to get added to the world before its parent has been
|
||||
//-- for now, we won't queue anything for fixup
|
||||
|
||||
#if 0
|
||||
#if 0 //TODO: see above
|
||||
// go through the cells and remove objects
|
||||
for (size_t cell=1 ; cell< numberOfCells; ++cell)
|
||||
{
|
||||
|
||||
-124
@@ -374,130 +374,6 @@ bool SamplerProceduralTerrainAppearance::SamplerChunk::getHeightAt (const Vector
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
#if 0
|
||||
bool SamplerProceduralTerrainAppearance::SamplerChunk::getHeightAt2(const Vector& pos, float* const height, Vector* const normal) const
|
||||
{
|
||||
// ------------------------------------------------
|
||||
// make sure we're in the chunk
|
||||
const Vector vmin = m_boxExtent.getMin ();
|
||||
const Vector vmax = m_boxExtent.getMax ();
|
||||
if (pos.x < vmin.x || pos.x > vmax.x || pos.z < vmin.z || pos.z > vmax.z)
|
||||
{
|
||||
DEBUG_WARNING (true, ("called getHeightAt for position not within chunk"));
|
||||
return false;
|
||||
}
|
||||
// ------------------------------------------------
|
||||
|
||||
// ------------------------------------------------
|
||||
// get height pole and tile coordinate.
|
||||
const Vector localPos = pos - vmin;
|
||||
|
||||
const ProceduralTerrainAppearanceTemplate *proceduralTerrainAppearanceTemplate = getAppearanceTemplate();
|
||||
const float distanceBetweenPoles = proceduralTerrainAppearanceTemplate->getTileWidthInMeters() / 2.0f;
|
||||
const int numberOfPolesPerChunk = proceduralTerrainAppearanceTemplate->getNumberOfTilesPerChunk() * 2;
|
||||
|
||||
int poleX = int(floor(localPos.x / distanceBetweenPoles));
|
||||
if (poleX>=numberOfPolesPerChunk)
|
||||
{
|
||||
poleX=numberOfPolesPerChunk-1;
|
||||
}
|
||||
|
||||
int poleZ = int(floor(localPos.z / distanceBetweenPoles));
|
||||
if (poleZ>=numberOfPolesPerChunk)
|
||||
{
|
||||
poleZ=numberOfPolesPerChunk-1;
|
||||
}
|
||||
|
||||
const int tileX = poleX>>1;
|
||||
const int tileZ = poleZ>>1;
|
||||
// ------------------------------------------------
|
||||
|
||||
// ------------------------------------------------
|
||||
// if the tile at x,z is excluded, return failure.
|
||||
|
||||
// DEBUG
|
||||
{
|
||||
int dbgTileX, dbgTileZ;
|
||||
_findTileXz(pos, dbgTileX, dbgTileZ);
|
||||
DEBUG_FATAL(dbgTileX!=tileX, (""));
|
||||
DEBUG_FATAL(dbgTileZ!=tileZ, (""));
|
||||
}
|
||||
|
||||
if (isExcluded(tileX, tileZ))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// ------------------------------------------------
|
||||
|
||||
|
||||
// ------------------------------------------------
|
||||
// construct vertical vector at x,z that goes
|
||||
// from the highest point in the chunk to the
|
||||
// lowest point in the chunk.
|
||||
const Vector start(pos.x, vmax.y + 0.1f, pos.z);
|
||||
const Vector end(pos.x, vmin.y - 0.1f, pos.z);
|
||||
const Vector dir = end - start;
|
||||
// ------------------------------------------------
|
||||
|
||||
//-- collide with the 8 polygons in the tile
|
||||
bool found = false;
|
||||
|
||||
CollisionInfo result;
|
||||
result.setPoint (end);
|
||||
|
||||
Vector intersection;
|
||||
|
||||
const int numberOfTilesPerChunk = m_proceduralTerrainAppearance.getNumberOfTilesPerChunk();
|
||||
const int tileIndex = tileZ * numberOfTilesPerChunk + tileX;
|
||||
const int triangleOffset = tileIndex * 8;
|
||||
for (int tri = triangleOffset; tri < triangleOffset + 8; ++tri)
|
||||
{
|
||||
const Plane& plane = (*m_planeList) [tri];
|
||||
const Vector& normal = plane.getNormal ();
|
||||
|
||||
if ( dir.dot(normal)<0.f // if triangle is facing upward
|
||||
&& plane.findIntersection(start, end, intersection)
|
||||
)
|
||||
{
|
||||
const int i0 = (*ms_indexList)[tri*3 + 0];
|
||||
const int i1 = (*ms_indexList)[tri*3 + 1];
|
||||
const int i2 = (*ms_indexList)[tri*3 + 2];
|
||||
|
||||
const Vector& v0 = (*m_vertexList)[i0];
|
||||
const Vector& v1 = (*m_vertexList)[i1];
|
||||
const Vector& v2 = (*m_vertexList)[i2];
|
||||
|
||||
DenormalizedLine2d const line01 (Vector2d (v0.x, v0.z), Vector2d (v1.x, v1.z));
|
||||
DenormalizedLine2d const line12 (Vector2d (v1.x, v1.z), Vector2d (v2.x, v2.z));
|
||||
DenormalizedLine2d const line20 (Vector2d (v2.x, v2.z), Vector2d (v0.x, v0.z));
|
||||
|
||||
if (line01.computeDistanceTo (Vector2d (start.x, start.z)) <= 0 &&
|
||||
line12.computeDistanceTo (Vector2d (start.x, start.z)) <= 0 &&
|
||||
line20.computeDistanceTo (Vector2d (start.x, start.z)) <= 0)
|
||||
{
|
||||
found = true;
|
||||
|
||||
result.setPoint (intersection);
|
||||
result.setNormal (normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
if (height)
|
||||
*height = result.getPoint ().y;
|
||||
|
||||
if (normal)
|
||||
*normal = result.getNormal ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#define ALLOW_BACKFACING_COLLISION 0
|
||||
|
||||
@@ -209,25 +209,4 @@ float CoordinateHash::makeFloat(unsigned long hash)
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
#if 0
|
||||
long CoordinateHash::hashTuple(float x, float z)
|
||||
{
|
||||
const unsigned long ix = (*(unsigned long *)&x)^0x5a5a5a5a;
|
||||
const unsigned long iz = (*(unsigned long *)&z)^0xa5a5a5a5;
|
||||
const unsigned long hx = _hash1((ix>>8) | (ix<<24));
|
||||
const unsigned long hz = _hash1((iz>>16) | (iz<<16));
|
||||
const unsigned long hmix1 = hx^hz;
|
||||
const unsigned long h = hmix1;
|
||||
|
||||
/*
|
||||
FastRandomGenerator rngx(hx);
|
||||
FastRandomGenerator rngz(hz);
|
||||
const long rnx = rngx.random();
|
||||
const long rnz = rngz.random();
|
||||
return rnx^rnz;
|
||||
*/
|
||||
|
||||
return h;
|
||||
}
|
||||
#endif
|
||||
//===================================================================
|
||||
|
||||
@@ -142,18 +142,3 @@ void Thread::setPriority(ePriority priority)
|
||||
pthread_setschedparam(thread, policies[priority], &p);
|
||||
}
|
||||
|
||||
// Make sure the header-only files compile :)
|
||||
|
||||
#if 0
|
||||
|
||||
#include "sharedSynchronization/CountingSemaphore.h"
|
||||
#include "sharedSynchronization/BlockingPointer.h"
|
||||
#include "sharedSynchronization/BlockingQueue.h"
|
||||
#include "sharedSynchronization/WriteOnce.h"
|
||||
|
||||
Mutex t;
|
||||
BlockingQueue<int> bqint(t, 0, 0);
|
||||
BlockingPointer<int> bpint(t, 0, 0);
|
||||
WriteOnce<int> woint;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,26 +19,3 @@ FuncPtrThreadZero::Handle runNamedThread(const std::string &name, void (* func)(
|
||||
{
|
||||
return TypedThreadHandle<FuncPtrThreadZero> (new FuncPtrThreadZero(name, func));
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Testing stuff
|
||||
|
||||
class testclass
|
||||
{
|
||||
public:
|
||||
void zeroArg() {}
|
||||
void oneArg(testclass *) {}
|
||||
void twoArg(testclass *, int) {}
|
||||
};
|
||||
|
||||
testclass m;
|
||||
|
||||
typedef MemberFunctionThreadZero<testclass>::Handle AsyncTestMemberFunctionZero;
|
||||
AsyncTestMemberFunctionZero temp = runThread(m, testclass::zeroArg);
|
||||
|
||||
typedef MemberFunctionThreadOne<testclass, testclass *>::Handle AsyncTestMemberFunctionOne;
|
||||
AsyncTestMemberFunctionOne temp2 = runThread(m, testclass::oneArg, &m);
|
||||
|
||||
typedef MemberFunctionThreadTwo<testclass, testclass *, int>::Handle AsyncTestMemberFunctionTwo;
|
||||
AsyncTestMemberFunctionTwo temp3 = runThread(m, testclass::twoArg, &m, 4);
|
||||
#endif
|
||||
|
||||
@@ -278,12 +278,3 @@ void FileName::stripSpecificPathAndExt (Path path, char* nameBuffer, int nameBuf
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("%s\n", FileName (FileName::P_none, "test")));
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("%s\n", FileName (FileName::P_none, "test", "iff")));
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("%s\n", FileName (FileName::P_sound, "test")));
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("%s\n", FileName (FileName::P_sound, "test", "iff")));
|
||||
|
||||
#endif
|
||||
|
||||
-4
@@ -87,14 +87,10 @@ add_library(VChatAPI
|
||||
../../../utils2.0/utils/TcpLibrary/TcpConnection.cpp
|
||||
../../../utils2.0/utils/TcpLibrary/TcpConnection.h
|
||||
../../../utils2.0/utils/TcpLibrary/TcpHandlers.h
|
||||
../../../utils2.0/utils/TcpLibrary/TcpListener.cpp
|
||||
../../../utils2.0/utils/TcpLibrary/TcpListener.h
|
||||
../../../utils2.0/utils/TcpLibrary/TcpManager.cpp
|
||||
../../../utils2.0/utils/TcpLibrary/TcpManager.h
|
||||
|
||||
../../../utils2.0/utils/UdpLibrary/UdpHandler.hpp
|
||||
../../../utils2.0/utils/UdpLibrary/UdpLibrary.cpp
|
||||
../../../utils2.0/utils/UdpLibrary/UdpLibrary.hpp
|
||||
../../../utils2.0/utils/UdpLibrary/UdpListener.cpp
|
||||
../../../utils2.0/utils/UdpLibrary/UdpListener.h
|
||||
)
|
||||
|
||||
@@ -9,23 +9,8 @@
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
# pragma warning (disable: 4251)
|
||||
|
||||
# ifndef DECLSPEC
|
||||
# if defined (IMPORT_DLL)
|
||||
# define DECLSPEC __declspec(dllimport)
|
||||
# elif defined (EXPORT_DLL)
|
||||
# define DECLSPEC __declspec(dllexport)
|
||||
# else
|
||||
# define DECLSPEC
|
||||
# endif
|
||||
# endif
|
||||
# define DECLIMPORT __declspec(dllimport)
|
||||
#else
|
||||
# define DECLSPEC
|
||||
# define DECLIMPORT extern
|
||||
#endif
|
||||
#define DECLSPEC
|
||||
#define DECLIMPORT extern
|
||||
|
||||
#ifdef WIN32
|
||||
# define FILENAME (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
|
||||
-435
@@ -1,435 +0,0 @@
|
||||
|
||||
//This code is not used by anything intentionally
|
||||
//The Connection class was getting mistakenly linked in
|
||||
//instead of the SWG Connection class that is used for
|
||||
//all of our connections. Removing the whole thing
|
||||
//to prevent the issue from coming up again.
|
||||
#if 0
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning (disable: 4786)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "TcpConnection.h"
|
||||
#include "TcpListener.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
{
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Listener::QueueNode::QueueNode() :
|
||||
connection(0),
|
||||
request(0)
|
||||
{
|
||||
}
|
||||
|
||||
Listener::QueueNode::QueueNode(Connection * con, RequestBase * req) :
|
||||
connection(con),
|
||||
request(req)
|
||||
{
|
||||
}
|
||||
|
||||
Listener::Listener() :
|
||||
mParams(),
|
||||
mTcpManager(0),
|
||||
mConnections(),
|
||||
mConnectionCount(0),
|
||||
mClosedConnections(),
|
||||
mQueuedRequests(),
|
||||
mActiveRequests(),
|
||||
mActiveCount(0),
|
||||
mActiveMax(0),
|
||||
mAcceptingNewConnections(true)
|
||||
{
|
||||
//printf("ctor 0x%x Listener\n",this);
|
||||
}
|
||||
|
||||
Listener::~Listener()
|
||||
{
|
||||
std::set<Connection *>::iterator iterator;
|
||||
for (iterator = mConnections.begin(); iterator != mConnections.end(); iterator++)
|
||||
{
|
||||
Connection * connection = *iterator;
|
||||
delete connection;
|
||||
}
|
||||
mConnections.clear();
|
||||
|
||||
if (mTcpManager != 0)
|
||||
{
|
||||
mTcpManager->Release();
|
||||
mTcpManager = 0;
|
||||
}
|
||||
|
||||
//printf("dtor 0x%x Listener\n",this);
|
||||
}
|
||||
|
||||
void Listener::RequestSleep(RequestBase * request)
|
||||
{
|
||||
mSleepingRequests.insert(request);
|
||||
}
|
||||
|
||||
void Listener::RequestWake(RequestBase * request)
|
||||
{
|
||||
if (mSleepingRequests.erase(request))
|
||||
{
|
||||
QueueNode node(request->mConnection, request);
|
||||
mActiveRequests.push_front(node);
|
||||
}
|
||||
}
|
||||
|
||||
void Listener::OnConnectRequest(TcpConnection * connection)
|
||||
{
|
||||
if (IsAcceptingNewConnections())
|
||||
{
|
||||
Connection * connectionObject = new Connection(*this, connection);
|
||||
|
||||
mConnections.insert(connectionObject);
|
||||
mConnectionCount++;
|
||||
|
||||
OnConnectionOpened(connectionObject);
|
||||
}
|
||||
}
|
||||
|
||||
void Listener::QueueRequest(Connection * connection, RequestBase * request)
|
||||
{
|
||||
if (connection)
|
||||
{
|
||||
// normal request, internal requests have no connection
|
||||
connection->NotifyQueuedRequest(request);
|
||||
}
|
||||
mQueuedRequests.push_back(QueueNode(connection,request));
|
||||
}
|
||||
|
||||
bool Listener::IsIdle() const
|
||||
{
|
||||
return (!IsActive() && !mTcpManager && mQueuedRequests.empty() && !mActiveCount);
|
||||
}
|
||||
|
||||
bool Listener::IsAcceptingNewConnections() const
|
||||
{
|
||||
return (IsActive() && mAcceptingNewConnections);
|
||||
}
|
||||
|
||||
unsigned Listener::Process()
|
||||
{
|
||||
//Profile profile("Listener::Process");
|
||||
////////////////////////////////////////
|
||||
// handle inactive state (with UdpManager)
|
||||
if (!IsActive() && mTcpManager)
|
||||
{
|
||||
// check all connections to see if they are idle
|
||||
std::set<Connection *>::iterator iterator;
|
||||
for (iterator = mConnections.begin(); iterator != mConnections.end(); iterator++)
|
||||
{
|
||||
Connection * connection = *iterator;
|
||||
if (connection->IsConnected())
|
||||
connection->Disconnect();
|
||||
}
|
||||
// close the UdpManager if all the connections are closed
|
||||
if (!mConnectionCount)
|
||||
{
|
||||
mTcpManager->Release();
|
||||
mTcpManager = 0;
|
||||
OnShutdown();
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////
|
||||
// handle active state (without UdpManager)
|
||||
else if (IsActive() && !mTcpManager)
|
||||
{
|
||||
mParams = GetConnectionParams();
|
||||
mActiveMax = GetActiveRequestMax();
|
||||
mTcpManager = new TcpManager(mParams);
|
||||
mTcpManager->SetHandler(this);
|
||||
if (mTcpManager->BindAsServer()){
|
||||
OnStartup();
|
||||
}else{
|
||||
OnFailedStartup();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// process the TcpManager
|
||||
if (mTcpManager)
|
||||
{
|
||||
//Profile subProfile("TcpManager::GiveTime()");
|
||||
mTcpManager->GiveTime();
|
||||
}
|
||||
|
||||
// check all closed connections to see if they are idle
|
||||
std::list<Connection *>::iterator closedIterator = mClosedConnections.begin();
|
||||
while (closedIterator != mClosedConnections.end())
|
||||
{
|
||||
//Profile profile("Listener::Process (cleanup connection)");
|
||||
std::list<Connection *>::iterator current = closedIterator++;
|
||||
Connection * connection = *current;
|
||||
if (!connection->GetActiveRequests() &&
|
||||
!connection->GetQueuedRequests())
|
||||
{
|
||||
mClosedConnections.erase(current);
|
||||
mConnections.erase(connection);
|
||||
mConnectionCount--;
|
||||
OnConnectionDestroyed(connection);
|
||||
delete connection;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// process request queue
|
||||
while (!mQueuedRequests.empty() && (!mActiveMax || mActiveCount < mActiveMax))
|
||||
{
|
||||
//Profile profile("Listener::Process (activate queued request)");
|
||||
QueueNode & node = mQueuedRequests.front();
|
||||
if (!IsActive())
|
||||
{
|
||||
// If not active, discard queued request
|
||||
if (node.connection)
|
||||
{
|
||||
// normal request, internal requests have no connection
|
||||
node.connection->NotifyDiscardRequest(node.request);
|
||||
}
|
||||
DestroyRequest(node.request);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Move request to active list
|
||||
if (node.connection)
|
||||
{
|
||||
// normal request, internal requests have no connection
|
||||
node.connection->NotifyBeginRequest(node.request);
|
||||
}
|
||||
mActiveRequests.push_back(node);
|
||||
mActiveCount++;
|
||||
}
|
||||
mQueuedRequests.pop_front();
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// Process active requests
|
||||
unsigned requestsProcessed = 0;
|
||||
std::list<QueueNode>::iterator iterator = mActiveRequests.begin();
|
||||
while (iterator != mActiveRequests.end())
|
||||
{
|
||||
//Profile profile("Listener::Process (process request)");
|
||||
std::list<QueueNode>::iterator current = iterator++;
|
||||
RequestBase * request = current->request;
|
||||
Connection * connection = current->connection;
|
||||
|
||||
if (request->Process())
|
||||
{
|
||||
if (connection)
|
||||
{
|
||||
// normal request, internal requests have no connection
|
||||
connection->NotifyEndRequest(request);
|
||||
}
|
||||
DestroyRequest(request);
|
||||
mActiveRequests.erase(current);
|
||||
mActiveCount--;
|
||||
}
|
||||
else if (mSleepingRequests.find(request) != mSleepingRequests.end())
|
||||
{
|
||||
mActiveRequests.erase(current);
|
||||
}
|
||||
requestsProcessed++;
|
||||
}
|
||||
return requestsProcessed;
|
||||
}
|
||||
|
||||
/*
|
||||
void Listener::GetStats(UdpManagerStatistics & statsStruct)
|
||||
{
|
||||
if (mTcpManager)
|
||||
mTcpManager->GetStats(&statsStruct);
|
||||
}
|
||||
|
||||
void Listener::ResetStats()
|
||||
{
|
||||
if (mTcpManager)
|
||||
mTcpManager->ResetStats();
|
||||
}
|
||||
*/
|
||||
|
||||
void Listener::OnStartup()
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnShutdown()
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnFailedStartup()
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnConnectionOpened(Connection * connection)
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnConnectionClosed(Connection * connection, const char * reason)
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnConnectionDestroyed(Connection * connection)
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnCrcReject(Connection *connection, const unsigned char * buffer, unsigned size)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
void Listener::OnPacketCorrupt(Connection *con, const unsigned char *data, int dataLen, UdpCorruptionReason reason)
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Connection::Connection(Listener & listener, TcpConnection * connection) :
|
||||
mListener(listener),
|
||||
mConnection(connection),
|
||||
mHost(),
|
||||
mHostIp(0),
|
||||
mDisconnectReason(0),
|
||||
mQueuedRequests(0),
|
||||
mActiveRequests(0)
|
||||
{
|
||||
mConnection->AddRef();
|
||||
mConnection->SetHandler(this);
|
||||
|
||||
char buffer[256];
|
||||
char addr[32];
|
||||
mHostIp = mConnection->GetDestinationIp().GetAddress();
|
||||
mConnection->GetDestinationIp().GetAddress(addr);
|
||||
snprintf(buffer, sizeof(buffer), "%s:%u", addr, mConnection->GetDestinationPort());
|
||||
mHost = buffer;
|
||||
|
||||
//printf("ctor 0x%x connection\n",this);
|
||||
}
|
||||
|
||||
Connection::~Connection()
|
||||
{
|
||||
Disconnect();
|
||||
|
||||
//printf("dtor 0x%x connection\n",this);
|
||||
}
|
||||
|
||||
unsigned Connection::Send(const unsigned char * data, unsigned dataLen)
|
||||
{
|
||||
if (mConnection)
|
||||
{
|
||||
mConnection->Send((const char*)data, dataLen);
|
||||
return dataLen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Connection::Disconnect()
|
||||
{
|
||||
if (mConnection)
|
||||
OnTerminated(mConnection);
|
||||
}
|
||||
|
||||
bool Connection::IsConnected() const
|
||||
{
|
||||
return mConnection != 0;
|
||||
}
|
||||
|
||||
const std::string & Connection::GetHost() const
|
||||
{
|
||||
return mHost;
|
||||
}
|
||||
|
||||
const unsigned Connection::GetHostIP() const
|
||||
{
|
||||
return mHostIp;
|
||||
}
|
||||
|
||||
unsigned Connection::GetQueuedRequests() const
|
||||
{
|
||||
return mQueuedRequests;
|
||||
}
|
||||
|
||||
unsigned Connection::GetActiveRequests() const
|
||||
{
|
||||
return mActiveRequests;
|
||||
}
|
||||
|
||||
void Connection::OnTerminated(TcpConnection *con)
|
||||
{
|
||||
mConnection->SetHandler(0);
|
||||
mConnection->Disconnect();
|
||||
//TcpConnection::DisconnectReason disconnectReason = mConnection->GetDisconnectReason();
|
||||
mConnection->Release();
|
||||
mConnection = 0;
|
||||
mListener.mClosedConnections.push_back(this);
|
||||
mListener.OnConnectionClosed(this, "Test"/*TcpConnection::DisconnectReasonText(disconnectReason)*/);
|
||||
}
|
||||
|
||||
void Connection::OnRoutePacket(TcpConnection *, const unsigned char * data, int dataLen)
|
||||
{
|
||||
mListener.OnReceive(this, data, dataLen);
|
||||
}
|
||||
|
||||
void Connection::OnCrcReject(TcpConnection *, const unsigned char * data, int dataLen)
|
||||
{
|
||||
mListener.OnCrcReject(this, data, dataLen);
|
||||
}
|
||||
|
||||
/*
|
||||
void Connection::OnPacketCorrupt(TcpConnection *, const uchar *data, int dataLen, UdpCorruptionReason reason)
|
||||
{
|
||||
mListener.OnPacketCorrupt(this, data, dataLen, reason);
|
||||
}
|
||||
*/
|
||||
|
||||
void Connection::NotifyQueuedRequest(RequestBase * request)
|
||||
{
|
||||
mQueuedRequests++;
|
||||
}
|
||||
|
||||
void Connection::NotifyDiscardRequest(RequestBase * request)
|
||||
{
|
||||
mQueuedRequests--;
|
||||
}
|
||||
|
||||
void Connection::NotifyBeginRequest(RequestBase * request)
|
||||
{
|
||||
mQueuedRequests--;
|
||||
mActiveRequests++;
|
||||
}
|
||||
|
||||
void Connection::NotifyEndRequest(RequestBase * request)
|
||||
{
|
||||
mActiveRequests--;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
RequestBase::RequestBase(Connection * connection, bool isInternal) :
|
||||
mConnection(connection),
|
||||
mProcessState(0),
|
||||
mIsInternal(isInternal)
|
||||
{
|
||||
}
|
||||
|
||||
RequestBase::~RequestBase()
|
||||
{
|
||||
}
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
-160
@@ -1,160 +0,0 @@
|
||||
|
||||
//This code is not used by anything intentionally
|
||||
//The Connection class was getting mistakenly linked in
|
||||
//instead of the SWG Connection class that is used for
|
||||
//all of our connections. Removing the whole thing
|
||||
//to prevent the issue from coming up again.
|
||||
#if 0
|
||||
|
||||
|
||||
#ifndef TCP_LISTENER_H
|
||||
#define TCP_LISTENER_H
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <set>
|
||||
|
||||
#include "TcpManager.h"
|
||||
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
namespace NAMESPACE
|
||||
{
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RequestBase;
|
||||
class Connection;
|
||||
class Listener : public TcpManagerHandler
|
||||
{
|
||||
friend class Connection;
|
||||
struct QueueNode
|
||||
{
|
||||
QueueNode();
|
||||
QueueNode(Connection * connection, RequestBase * request);
|
||||
bool operator<(const QueueNode & rhs) { return request < rhs.request; }
|
||||
|
||||
Connection * connection;
|
||||
RequestBase * request;
|
||||
};
|
||||
|
||||
public:
|
||||
Listener();
|
||||
virtual ~Listener();
|
||||
|
||||
void QueueRequest(Connection * connection, RequestBase * request);
|
||||
bool IsIdle() const;
|
||||
bool IsAcceptingNewConnections() const;
|
||||
unsigned Process();
|
||||
void SetAcceptingNewConnections(bool value) { mAcceptingNewConnections = value; }
|
||||
//void GetStats(TcpManagerStatistics & statsStruct);
|
||||
//void ResetStats();
|
||||
|
||||
unsigned GetNumberQueuedRequests() { return (unsigned)mQueuedRequests.size(); }
|
||||
|
||||
void RequestSleep(RequestBase * request);
|
||||
void RequestWake(RequestBase * request);
|
||||
|
||||
virtual bool IsActive() const = 0;
|
||||
virtual unsigned GetActiveRequestMax() = 0;
|
||||
virtual TcpManager::TcpParams GetConnectionParams() = 0;
|
||||
|
||||
virtual void OnStartup();
|
||||
virtual void OnShutdown();
|
||||
virtual void OnFailedStartup();
|
||||
virtual void OnConnectionOpened(Connection * connection);
|
||||
virtual void OnConnectionClosed(Connection * connection, const char * reason);
|
||||
virtual void OnConnectionDestroyed(Connection * connection);
|
||||
virtual void OnReceive(Connection * connection, const unsigned char * data, unsigned dataLen) = 0;
|
||||
virtual void OnCrcReject(Connection *connection, const unsigned char * data, unsigned dataLen);
|
||||
//virtual void OnPacketCorrupt(Connection *con, const unsigned char *data, int dataLen, TcpCorruptionReason reason);
|
||||
virtual void DestroyRequest(RequestBase * request) = 0;
|
||||
|
||||
virtual void OnConnectRequest(TcpConnection *con);
|
||||
|
||||
protected:
|
||||
TcpManager::TcpParams mParams;
|
||||
TcpManager * mTcpManager;
|
||||
|
||||
std::set<Connection *> mConnections;
|
||||
unsigned mConnectionCount;
|
||||
std::list<Connection *> mClosedConnections;
|
||||
|
||||
std::list<QueueNode> mQueuedRequests;
|
||||
std::list<QueueNode> mActiveRequests;
|
||||
std::set<RequestBase *> mSleepingRequests;
|
||||
unsigned mActiveCount;
|
||||
unsigned mActiveMax;
|
||||
bool mAcceptingNewConnections;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Connection : public TcpConnectionHandler
|
||||
{
|
||||
friend class Listener;
|
||||
public:
|
||||
Connection(Listener & listener, TcpConnection * connection);
|
||||
virtual ~Connection();
|
||||
|
||||
unsigned Send(const unsigned char * data, unsigned dataLen);
|
||||
void Disconnect();
|
||||
bool IsConnected() const;
|
||||
|
||||
const std::string & GetHost() const;
|
||||
const unsigned GetHostIP() const;
|
||||
unsigned GetQueuedRequests() const;
|
||||
unsigned GetActiveRequests() const;
|
||||
|
||||
virtual void OnTerminated(TcpConnection *con);
|
||||
virtual void OnConnectRequest(TcpConnection *con) {};
|
||||
virtual void OnRoutePacket(TcpConnection *con, const unsigned char *data, int dataLen);
|
||||
virtual void OnCrcReject(TcpConnection *con, const unsigned char *data, int dataLen);
|
||||
//virtual void OnPacketCorrupt(TcpConnection *con, const unsigned char *data, int dataLen, TcpCorruptionReason reason);
|
||||
|
||||
protected:
|
||||
void NotifyQueuedRequest(RequestBase * request);
|
||||
void NotifyDiscardRequest(RequestBase * request);
|
||||
void NotifyBeginRequest(RequestBase * request);
|
||||
void NotifyEndRequest(RequestBase * request);
|
||||
|
||||
protected:
|
||||
Listener & mListener;
|
||||
TcpConnection * mConnection;
|
||||
std::string mHost;
|
||||
unsigned mHostIp;
|
||||
const char * mDisconnectReason;
|
||||
unsigned mQueuedRequests;
|
||||
unsigned mActiveRequests;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RequestBase
|
||||
{
|
||||
friend class Listener;
|
||||
public:
|
||||
RequestBase(Connection * connection, bool isInternal=false);
|
||||
virtual ~RequestBase();
|
||||
|
||||
virtual bool Process() = 0;
|
||||
|
||||
Connection * GetConnection() const { return mConnection; }
|
||||
unsigned GetState() const { return mProcessState; }
|
||||
|
||||
protected:
|
||||
Connection * mConnection;
|
||||
unsigned mProcessState;
|
||||
bool mIsInternal;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef EXTERNAL_DISTRO
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
-394
@@ -1,394 +0,0 @@
|
||||
//This code is not used by anything intentionally
|
||||
//The Connection class was getting mistakenly linked in
|
||||
//instead of the SWG Connection class that is used for
|
||||
//all of our connections. Removing the whole thing
|
||||
//to prevent the issue from coming up again.
|
||||
#if 0
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning (disable: 4786)
|
||||
#endif
|
||||
|
||||
#include "Base/timer.h"
|
||||
#include "UdpListener.h"
|
||||
#include "Base/profile.h"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
namespace UdpLibrary
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Listener::QueueNode::QueueNode() :
|
||||
connection(0),
|
||||
request(0)
|
||||
{
|
||||
}
|
||||
|
||||
Listener::QueueNode::QueueNode(Connection * con, RequestBase * req) :
|
||||
connection(con),
|
||||
request(req)
|
||||
{
|
||||
}
|
||||
|
||||
Listener::Listener() :
|
||||
mParams(),
|
||||
mUdpManager(0),
|
||||
mConnections(),
|
||||
mConnectionCount(0),
|
||||
mClosedConnections(),
|
||||
mQueuedRequests(),
|
||||
mActiveRequests(),
|
||||
mActiveCount(0),
|
||||
mActiveMax(0)
|
||||
{
|
||||
//printf("ctor 0x%x Listener\n",this);
|
||||
}
|
||||
|
||||
Listener::~Listener()
|
||||
{
|
||||
std::set<Connection *>::iterator iterator;
|
||||
for (iterator = mConnections.begin(); iterator != mConnections.end(); iterator++)
|
||||
{
|
||||
Connection * connection = *iterator;
|
||||
delete connection;
|
||||
}
|
||||
mConnections.clear();
|
||||
|
||||
if (mUdpManager != 0)
|
||||
{
|
||||
mUdpManager->Release();
|
||||
mUdpManager = 0;
|
||||
}
|
||||
|
||||
//printf("dtor 0x%x Listener\n",this);
|
||||
}
|
||||
|
||||
void Listener::RequestSleep(RequestBase * request)
|
||||
{
|
||||
mSleepingRequests.insert(request);
|
||||
}
|
||||
|
||||
void Listener::RequestWake(RequestBase * request)
|
||||
{
|
||||
if (mSleepingRequests.erase(request))
|
||||
{
|
||||
QueueNode node(request->mConnection, request);
|
||||
mActiveRequests.push_front(node);
|
||||
}
|
||||
}
|
||||
|
||||
void Listener::OnConnectRequest(UdpConnection * connection)
|
||||
{
|
||||
if (IsActive())
|
||||
{
|
||||
Connection * connectionObject = new Connection(*this, connection);
|
||||
|
||||
mConnections.insert(connectionObject);
|
||||
mConnectionCount++;
|
||||
|
||||
OnConnectionOpened(connectionObject);
|
||||
}
|
||||
}
|
||||
|
||||
void Listener::QueueRequest(Connection * connection, RequestBase * request)
|
||||
{
|
||||
connection->NotifyQueuedRequest(request);
|
||||
mQueuedRequests.push_back(QueueNode(connection,request));
|
||||
}
|
||||
|
||||
bool Listener::IsIdle() const
|
||||
{
|
||||
return (!IsActive() && !mUdpManager && mQueuedRequests.empty() && !mActiveCount);
|
||||
}
|
||||
|
||||
unsigned Listener::Process()
|
||||
{
|
||||
Profile profile("Listener::Process");
|
||||
////////////////////////////////////////
|
||||
// handle inactive state (with UdpManager)
|
||||
if (!IsActive() && mUdpManager)
|
||||
{
|
||||
// check all connections to see if they are idle
|
||||
std::set<Connection *>::iterator iterator;
|
||||
for (iterator = mConnections.begin(); iterator != mConnections.end(); iterator++)
|
||||
{
|
||||
Connection * connection = *iterator;
|
||||
if (connection->IsConnected())
|
||||
connection->Disconnect();
|
||||
}
|
||||
// close the UdpManager if all the connections are closed
|
||||
if (!mConnectionCount)
|
||||
{
|
||||
mUdpManager->Release();
|
||||
mUdpManager = 0;
|
||||
OnShutdown();
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////
|
||||
// handle active state (without UdpManager)
|
||||
else if (IsActive() && !mUdpManager)
|
||||
{
|
||||
mParams = GetConnectionParams();
|
||||
mParams.handler = this;
|
||||
mActiveMax = GetActiveRequestMax();
|
||||
mUdpManager = new UdpManager(&mParams);
|
||||
OnStartup();
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// process the UdpManager
|
||||
if (mUdpManager)
|
||||
{
|
||||
Profile subProfile("UdpManager::GiveTime()");
|
||||
mUdpManager->GiveTime();
|
||||
}
|
||||
|
||||
// check all closed connections to see if they are idle
|
||||
std::list<Connection *>::iterator closedIterator = mClosedConnections.begin();
|
||||
while (closedIterator != mClosedConnections.end())
|
||||
{
|
||||
Profile profile("Listener::Process (cleanup connection)");
|
||||
std::list<Connection *>::iterator current = closedIterator++;
|
||||
Connection * connection = *current;
|
||||
if (!connection->GetActiveRequests() &&
|
||||
!connection->GetQueuedRequests())
|
||||
{
|
||||
mClosedConnections.erase(current);
|
||||
mConnections.erase(connection);
|
||||
mConnectionCount--;
|
||||
OnConnectionDestroyed(connection);
|
||||
delete connection;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// process request queue
|
||||
while (!mQueuedRequests.empty() && (!mActiveMax || mActiveCount < mActiveMax))
|
||||
{
|
||||
Profile profile("Listener::Process (activate queued request)");
|
||||
QueueNode & node = mQueuedRequests.front();
|
||||
if (!IsActive())
|
||||
{
|
||||
// If not active, discard queued request
|
||||
node.connection->NotifyDiscardRequest(node.request);
|
||||
DestroyRequest(node.request);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Move request to active list
|
||||
node.connection->NotifyBeginRequest(node.request);
|
||||
mActiveRequests.push_back(node);
|
||||
mActiveCount++;
|
||||
}
|
||||
mQueuedRequests.pop_front();
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// Process active requests
|
||||
unsigned requestsProcessed = 0;
|
||||
std::list<QueueNode>::iterator iterator = mActiveRequests.begin();
|
||||
while (iterator != mActiveRequests.end())
|
||||
{
|
||||
Profile profile("Listener::Process (process request)");
|
||||
std::list<QueueNode>::iterator current = iterator++;
|
||||
RequestBase * request = current->request;
|
||||
Connection * connection = current->connection;
|
||||
|
||||
if (request->Process())
|
||||
{
|
||||
connection->NotifyEndRequest(request);
|
||||
DestroyRequest(request);
|
||||
mActiveRequests.erase(current);
|
||||
mActiveCount--;
|
||||
}
|
||||
else if (mSleepingRequests.find(request) != mSleepingRequests.end())
|
||||
{
|
||||
mActiveRequests.erase(current);
|
||||
}
|
||||
requestsProcessed++;
|
||||
}
|
||||
return requestsProcessed;
|
||||
}
|
||||
|
||||
void Listener::GetStats(UdpManagerStatistics & statsStruct)
|
||||
{
|
||||
if (mUdpManager)
|
||||
mUdpManager->GetStats(&statsStruct);
|
||||
}
|
||||
|
||||
void Listener::ResetStats()
|
||||
{
|
||||
if (mUdpManager)
|
||||
mUdpManager->ResetStats();
|
||||
}
|
||||
|
||||
void Listener::OnStartup()
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnShutdown()
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnConnectionOpened(Connection * connection)
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnConnectionClosed(Connection * connection, const char * reason)
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnConnectionDestroyed(Connection * connection)
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnCrcReject(Connection *connection, const unsigned char * buffer, unsigned size)
|
||||
{
|
||||
}
|
||||
|
||||
void Listener::OnPacketCorrupt(Connection *con, const unsigned char *data, int dataLen, UdpCorruptionReason reason)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Connection::Connection(Listener & listener, UdpConnection * connection) :
|
||||
mListener(listener),
|
||||
mConnection(connection),
|
||||
mHost(),
|
||||
mHostIp(0),
|
||||
mDisconnectReason(0),
|
||||
mQueuedRequests(0),
|
||||
mActiveRequests(0)
|
||||
{
|
||||
mConnection->AddRef();
|
||||
mConnection->SetHandler(this);
|
||||
|
||||
char buffer[256];
|
||||
char addr[32];
|
||||
mHostIp = mConnection->GetDestinationIp().GetAddress();
|
||||
mConnection->GetDestinationIp().GetAddress(addr);
|
||||
snprintf(buffer, sizeof(buffer), "%s:%u", addr, mConnection->GetDestinationPort());
|
||||
mHost = buffer;
|
||||
|
||||
//printf("ctor 0x%x connection\n",this);
|
||||
}
|
||||
|
||||
Connection::~Connection()
|
||||
{
|
||||
Disconnect();
|
||||
|
||||
//printf("dtor 0x%x connection\n",this);
|
||||
}
|
||||
|
||||
unsigned Connection::Send(const unsigned char * data, unsigned dataLen)
|
||||
{
|
||||
if (mConnection)
|
||||
{
|
||||
mConnection->Send(cUdpChannelReliable1, data, dataLen);
|
||||
return dataLen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Connection::Disconnect()
|
||||
{
|
||||
if (mConnection)
|
||||
OnTerminated(mConnection);
|
||||
}
|
||||
|
||||
bool Connection::IsConnected() const
|
||||
{
|
||||
return mConnection != 0;
|
||||
}
|
||||
|
||||
const std::string & Connection::GetHost() const
|
||||
{
|
||||
return mHost;
|
||||
}
|
||||
|
||||
const unsigned Connection::GetHostIP() const
|
||||
{
|
||||
return mHostIp;
|
||||
}
|
||||
|
||||
unsigned Connection::GetQueuedRequests() const
|
||||
{
|
||||
return mQueuedRequests;
|
||||
}
|
||||
|
||||
unsigned Connection::GetActiveRequests() const
|
||||
{
|
||||
return mActiveRequests;
|
||||
}
|
||||
|
||||
void Connection::OnTerminated(UdpConnection *con)
|
||||
{
|
||||
mConnection->SetHandler(0);
|
||||
mConnection->Disconnect();
|
||||
UdpConnection::DisconnectReason disconnectReason = mConnection->GetDisconnectReason();
|
||||
mConnection->Release();
|
||||
mConnection = 0;
|
||||
mListener.mClosedConnections.push_back(this);
|
||||
mListener.OnConnectionClosed(this, UdpConnection::DisconnectReasonText(disconnectReason));
|
||||
}
|
||||
|
||||
void Connection::OnRoutePacket(UdpConnection *, const unsigned char * data, int dataLen)
|
||||
{
|
||||
mListener.OnReceive(this, data, dataLen);
|
||||
}
|
||||
|
||||
void Connection::OnCrcReject(UdpConnection *, const unsigned char * data, int dataLen)
|
||||
{
|
||||
mListener.OnCrcReject(this, data, dataLen);
|
||||
}
|
||||
|
||||
void Connection::OnPacketCorrupt(UdpConnection *, const uchar *data, int dataLen, UdpCorruptionReason reason)
|
||||
{
|
||||
mListener.OnPacketCorrupt(this, data, dataLen, reason);
|
||||
}
|
||||
|
||||
void Connection::NotifyQueuedRequest(RequestBase * request)
|
||||
{
|
||||
mQueuedRequests++;
|
||||
}
|
||||
|
||||
void Connection::NotifyDiscardRequest(RequestBase * request)
|
||||
{
|
||||
mQueuedRequests--;
|
||||
}
|
||||
|
||||
void Connection::NotifyBeginRequest(RequestBase * request)
|
||||
{
|
||||
mQueuedRequests--;
|
||||
mActiveRequests++;
|
||||
}
|
||||
|
||||
void Connection::NotifyEndRequest(RequestBase * request)
|
||||
{
|
||||
mActiveRequests--;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
RequestBase::RequestBase(Connection * connection) :
|
||||
mConnection(connection),
|
||||
mProcessState(0)
|
||||
{
|
||||
}
|
||||
|
||||
RequestBase::~RequestBase()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
-145
@@ -1,145 +0,0 @@
|
||||
//This code is not used by anything intentionally
|
||||
//The Connection class was getting mistakenly linked in
|
||||
//instead of the SWG Connection class that is used for
|
||||
//all of our connections. Removing the whole thing
|
||||
//to prevent the issue from coming up again.
|
||||
#if 0
|
||||
|
||||
#ifndef COMMON_SERVER__LISTENER_H
|
||||
#define COMMON_SERVER__LISTENER_H
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include "UdpLibrary.hpp"
|
||||
|
||||
namespace UdpLibrary
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RequestBase;
|
||||
class Connection;
|
||||
class Listener : public UdpManagerHandler
|
||||
{
|
||||
friend class Connection;
|
||||
struct QueueNode
|
||||
{
|
||||
QueueNode();
|
||||
QueueNode(Connection * connection, RequestBase * request);
|
||||
bool operator<(const QueueNode & rhs) { return request < rhs.request; }
|
||||
|
||||
Connection * connection;
|
||||
RequestBase * request;
|
||||
};
|
||||
|
||||
public:
|
||||
Listener();
|
||||
virtual ~Listener();
|
||||
|
||||
void QueueRequest(Connection * connection, RequestBase * request);
|
||||
bool IsIdle() const;
|
||||
unsigned Process();
|
||||
void GetStats(UdpManagerStatistics & statsStruct);
|
||||
void ResetStats();
|
||||
|
||||
void RequestSleep(RequestBase * request);
|
||||
void RequestWake(RequestBase * request);
|
||||
|
||||
virtual bool IsActive() const = 0;
|
||||
virtual unsigned GetActiveRequestMax() = 0;
|
||||
virtual UdpManager::Params GetConnectionParams() = 0;
|
||||
|
||||
virtual void OnStartup();
|
||||
virtual void OnShutdown();
|
||||
virtual void OnConnectionOpened(Connection * connection);
|
||||
virtual void OnConnectionClosed(Connection * connection, const char * reason);
|
||||
virtual void OnConnectionDestroyed(Connection * connection);
|
||||
virtual void OnReceive(Connection * connection, const unsigned char * data, unsigned dataLen) = 0;
|
||||
virtual void OnCrcReject(Connection *connection, const unsigned char * data, unsigned dataLen);
|
||||
virtual void OnPacketCorrupt(Connection *con, const unsigned char *data, int dataLen, UdpCorruptionReason reason);
|
||||
virtual void DestroyRequest(RequestBase * request) = 0;
|
||||
|
||||
virtual void OnConnectRequest(UdpConnection *con);
|
||||
|
||||
protected:
|
||||
UdpManager::Params mParams;
|
||||
UdpManager * mUdpManager;
|
||||
|
||||
std::set<Connection *> mConnections;
|
||||
unsigned mConnectionCount;
|
||||
std::list<Connection *> mClosedConnections;
|
||||
|
||||
std::list<QueueNode> mQueuedRequests;
|
||||
std::list<QueueNode> mActiveRequests;
|
||||
std::set<RequestBase *> mSleepingRequests;
|
||||
unsigned mActiveCount;
|
||||
unsigned mActiveMax;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class Connection : public UdpConnectionHandler
|
||||
{
|
||||
friend class Listener;
|
||||
public:
|
||||
Connection(Listener & listener, UdpConnection * connection);
|
||||
virtual ~Connection();
|
||||
|
||||
unsigned Send(const uchar * data, unsigned dataLen);
|
||||
void Disconnect();
|
||||
bool IsConnected() const;
|
||||
|
||||
const std::string & GetHost() const;
|
||||
const unsigned GetHostIP() const;
|
||||
unsigned GetQueuedRequests() const;
|
||||
unsigned GetActiveRequests() const;
|
||||
|
||||
virtual void OnTerminated(UdpConnection *con);
|
||||
virtual void OnRoutePacket(UdpConnection *con, const uchar *data, int dataLen);
|
||||
virtual void OnCrcReject(UdpConnection *con, const uchar *data, int dataLen);
|
||||
virtual void OnPacketCorrupt(UdpConnection *con, const uchar *data, int dataLen, UdpCorruptionReason reason);
|
||||
|
||||
protected:
|
||||
void NotifyQueuedRequest(RequestBase * request);
|
||||
void NotifyDiscardRequest(RequestBase * request);
|
||||
void NotifyBeginRequest(RequestBase * request);
|
||||
void NotifyEndRequest(RequestBase * request);
|
||||
|
||||
protected:
|
||||
Listener & mListener;
|
||||
UdpConnection * mConnection;
|
||||
std::string mHost;
|
||||
unsigned mHostIp;
|
||||
const char * mDisconnectReason;
|
||||
unsigned mQueuedRequests;
|
||||
unsigned mActiveRequests;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class RequestBase
|
||||
{
|
||||
friend class Listener;
|
||||
public:
|
||||
RequestBase(Connection * connection);
|
||||
virtual ~RequestBase();
|
||||
|
||||
virtual bool Process() = 0;
|
||||
|
||||
protected:
|
||||
Connection * mConnection;
|
||||
unsigned mProcessState;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1
-60
@@ -72,15 +72,6 @@ int main(int argc, char **argv)
|
||||
params.pooledPacketMax = 50;
|
||||
params.pooledPacketSize = 512;
|
||||
|
||||
#if 0
|
||||
params.simulateIncomingByteRate = 0;
|
||||
params.simulateIncomingLossPercent = 10;
|
||||
params.simulateOutgoingByteRate = 0;
|
||||
params.simulateOutgoingLossPercent = 10;
|
||||
params.simulateDestinationOverloadLevel = 0;
|
||||
params.simulateOutgoingOverloadLevel = 0;
|
||||
#endif
|
||||
|
||||
params.reliable[0].maxInstandingPackets = 500;
|
||||
params.reliable[0].maxOutstandingBytes = 200000;
|
||||
params.reliable[0].maxOutstandingPackets = 500;
|
||||
@@ -156,9 +147,7 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#if 1
|
||||
// randomly send a medium sized packet on a random channel
|
||||
// randomly send a medium sized packet on a random channel
|
||||
if (rand() % 200 == 0)
|
||||
{
|
||||
char buf[8000];
|
||||
@@ -176,54 +165,6 @@ int main(int argc, char **argv)
|
||||
myConnection->Send(cUdpChannelReliable1, buf, len);
|
||||
}
|
||||
}
|
||||
#elif 0
|
||||
// send a very large packet one after the other (don't send next packet til the previous one has made it)
|
||||
if (myConnection->TotalPendingBytes() == 0)
|
||||
{
|
||||
// send another packet
|
||||
SimpleLogicalPacket *lp = new SimpleLogicalPacket(nullptr, 30000000);
|
||||
int dlen = lp->GetDataLen();
|
||||
char *ptr = (char *)lp->GetDataPtr();
|
||||
|
||||
ptr[0] = (char)(rand() % 50);
|
||||
for (int i = 1; i < dlen; i++)
|
||||
{
|
||||
ptr[i] = (char)(i % 100);
|
||||
}
|
||||
|
||||
printf("OUT LEN=%d \n", dlen);
|
||||
myConnection->Send(cUdpChannelReliable1, lp);
|
||||
lp->Release();
|
||||
}
|
||||
#else
|
||||
// prepare a random sized group of medium packets and then send the group, don't prepare next group until previous one has made it
|
||||
UdpConnection::ChannelStatus cs;
|
||||
myConnection->GetChannelStatus(cUdpChannelReliable1, &cs);
|
||||
if (cs.queuedBytes == 0)
|
||||
{
|
||||
int count = 0;
|
||||
GroupLogicalPacket *glp = new GroupLogicalPacket();
|
||||
int di = rand() % 20 + 1;
|
||||
for (int i = 0; i < di; i++)
|
||||
{
|
||||
GroupLogicalPacket *sub = new GroupLogicalPacket();
|
||||
for (int j = 0; j < di; j++)
|
||||
{
|
||||
char buf[8000];
|
||||
*(ushort *)buf = count;
|
||||
int len = (rand() % 1000) + 10;
|
||||
*(ushort *)(buf + len - 2) = count;
|
||||
sub->AddPacket(buf, len);
|
||||
count++;
|
||||
}
|
||||
glp->AddPacket(sub);
|
||||
sub->Release();
|
||||
}
|
||||
myConnection->Send(cUdpChannelReliable1, glp);
|
||||
glp->Release();
|
||||
printf("Group of %d packets sent\n", count);
|
||||
}
|
||||
#endif
|
||||
|
||||
myUdpManager->GiveTime();
|
||||
Sleep(10);
|
||||
|
||||
-13
@@ -97,14 +97,6 @@ int main(int argc, char **argv)
|
||||
params.pooledPacketMax = 5000;
|
||||
params.pooledPacketSize = 512;
|
||||
|
||||
#if 0
|
||||
params.simulateIncomingByteRate = 2000;
|
||||
params.simulateIncomingLossPercent = 0;
|
||||
params.simulateOutgoingByteRate = 2000;
|
||||
params.simulateOutgoingLossPercent = 0;
|
||||
params.simulateDestinationOverloadLevel = 8000;
|
||||
params.simulateOutgoingOverloadLevel = 8000;
|
||||
#endif
|
||||
params.reliable[0].maxInstandingPackets = 500;
|
||||
params.reliable[0].maxOutstandingBytes = 200000;
|
||||
params.reliable[0].maxOutstandingPackets = 500;
|
||||
@@ -197,11 +189,6 @@ void Player::OnRoutePacket(UdpConnection * /*con*/, const uchar *data, int dataL
|
||||
|
||||
char hold[256];
|
||||
printf("FROM=%s,%d LEN=%d \n", mConnection->GetDestinationIp().GetAddress(hold), mConnection->GetDestinationPort(), dataLen);
|
||||
|
||||
#if 0
|
||||
// reflect exact packet back to client
|
||||
mConnection->Send(cUdpChannelReliable1, data, dataLen);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ set(SHARED_SOURCES
|
||||
shared/buffers/ExperienceBuffer.h
|
||||
shared/buffers/IndexedNetworkTableBuffer.cpp
|
||||
shared/buffers/IndexedNetworkTableBuffer.h
|
||||
shared/buffers/IndexedTableBuffer.h
|
||||
shared/buffers/LocationBuffer.cpp
|
||||
shared/buffers/LocationBuffer.h
|
||||
shared/buffers/ManufactureSchematicAttributeBuffer.cpp
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#if 0 //@todo code reorg
|
||||
// ======================================================================
|
||||
//
|
||||
// IndexedNetworkTableBuffer.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_IndexedNetworkTableBuffer_H
|
||||
#define INCLUDED_IndexedNetworkTableBuffer_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include <unordered_map>
|
||||
#include "serverDatabase/TableBuffer.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* Adds to NetworkTableBuffer the ability to retrieve rows based on an
|
||||
* integer index.
|
||||
* @todo Remove "Network" from the name because it no longer has anything to
|
||||
* do with the network.
|
||||
* @todo If we have time someday :) Play with the idea of making this be a
|
||||
* class that's attached to a TableBuffer, much the same way a real DB index
|
||||
* is attached to a table. The TableBuffer could have a list of pointers
|
||||
* to indexes, and it would invoke addRow, etc., as needed.
|
||||
*/
|
||||
|
||||
class IndexedNetworkTableBuffer : public TableBuffer
|
||||
{
|
||||
public:
|
||||
void addRowToIndex(int indexValue, DB::Row *row);
|
||||
DB::Row *findRowByIndex(int indexValue);
|
||||
|
||||
protected:
|
||||
IndexedNetworkTableBuffer(TableBufferMode mode, DB::ModeQuery *query);
|
||||
|
||||
private:
|
||||
typedef std::unordered_map<int, DB::Row*> IndexType;
|
||||
/**
|
||||
* Index to locate rows.
|
||||
*
|
||||
* Note that the rows are owned by the TableBuffer base class. This
|
||||
* is just an index to find a specific row quickly. Therefore, this
|
||||
* class does not create or delete the rows.
|
||||
*/
|
||||
IndexType m_index;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user