some more static analyzer suggestions

This commit is contained in:
DarthArgus
2016-07-25 22:11:10 -07:00
parent 88888e4091
commit 814cf4f731
16 changed files with 3350 additions and 3456 deletions
File diff suppressed because it is too large Load Diff
@@ -50,7 +50,7 @@ public:
typedef unsigned int SpawnDelaySeconds;
struct CentralObject
{
CentralObject();
CentralObject();
CentralObject(const SceneId & sceneId, uint32 authProcess);
SceneId m_sceneId;
@@ -148,12 +148,12 @@ public:
static void run(void);
static void done();
static void remove();
ConnectionServerConnection * getAnyConnectionServer();
GameServerConnection * getGameServer (const uint32 processId) const;
GameServerConnection * getGameServer (const SceneId &scene) const;
const ServersList getGameServers (const SceneId &scene) const;
GameServerConnection * getGameServer(const uint32 processId) const;
GameServerConnection * getGameServer(const SceneId &scene) const;
const ServersList getGameServers(const SceneId &scene) const;
std::vector<const GameServerConnection *> getGameServers() const;
time_t getLastTimeSystemTimeMismatchNotification() const;
@@ -172,24 +172,23 @@ public:
void removeFromAccountConnectionMap(StationId suid);
private:
void handleRequestGameServerForLoginMessage (const RequestGameServerForLoginMessage & msg);
void handleRequestSceneTransfer (const RequestSceneTransfer & msg);
void handleGameServerForLoginMessage (const GameServerForLoginMessage & msg);
void handleRequestGameServerForLoginMessage(const RequestGameServerForLoginMessage & msg);
void handleRequestSceneTransfer(const RequestSceneTransfer & msg);
void handleGameServerForLoginMessage(const GameServerForLoginMessage & msg);
void handleExchangeListCreditsMessage(const ExchangeListCreditsMessage& msg);
void handleExchangeListCreditsMessage (const ExchangeListCreditsMessage& msg);
size_t getGameServerCount (void) const;
size_t getGameServerCount(void) const;
void update();
void sendPopulationUpdateToLoginServer();
void sendMetricsToWebAPI(std::string updateURL);
void sendMetricsToWebAPI(const std::string &updateURL);
ConnectionServerConnection * getConnectionServerForAccount(StationId suid);
void addToAccountConnectionMap(StationId suid, ConnectionServerConnection * cconn, uint32 subscriptionBits);
void removeFromAccountConnectionMap(int connectionServerConnectionId);
void doServerPings();
void excommunicateServer(const ExcommunicateGameServerMessage &);
protected:
protected:
friend class Singleton<CentralServer>;
CentralServer();
@@ -205,11 +204,11 @@ private:
SceneGameMap m_gameServers;
ConnectionServerSUIDMap m_accountConnectionMap;
// Network::Address clientService;
/**
The dbProcessServerProcessId is set by the DBProcess. The central server
refers to this process if there are no matching objects in any of its maps.
*/
// Network::Address clientService;
/**
The dbProcessServerProcessId is set by the DBProcess. The central server
refers to this process if there are no matching objects in any of its maps.
*/
uint32 m_dbProcessServerProcessId;
bool m_done;
Service * m_gameService;
@@ -330,7 +329,7 @@ inline int CentralServer::getNumConnectionServers() const
inline int CentralServer::getNumDatabaseServers() const
{
GameServerConnection * g = getGameServer(getDbProcessServerProcessId());
if(g)
if (g)
{
return 1;
}
@@ -116,7 +116,7 @@ static const CommandParser::CmdInfo cmds[] =
{ms_testStructurePlacement, 1, "<template name>", "Put the client into structure placement mode"},
{"setDebugFlag", 3, "<section> <name> <0 | 1>", "Toggle a debugFlag on the server"},
{"validateWorld", 0, "", "Run a sanity check on the world"},
{"setUniverseProcess", 1, "<int>", "Change universe authority to that process id"},
{"setUniverseProcess", 1, "<int>", "Change universe authority to that process id"},
{"getRegionsAt", 2, "<x> <z>", "List the regions at the given point"},
{"enableNewJedi", 1, "<true | false>", "Enable/disable tracking of players to see if they can become Jedi"},
{"setMessageToTimeLimit", 1, "<time limit in ms>", "Sets the time limit we will process messageTos in a frame. <= 0 means process all messages"},
@@ -203,59 +203,59 @@ static const CommandParser::CmdInfo cmds[] =
//-----------------------------------------------------------------
ConsoleCommandParserServer::ConsoleCommandParserServer (void) :
CommandParser ("server", 0, "...", "Server related commands.", 0)
ConsoleCommandParserServer::ConsoleCommandParserServer(void) :
CommandParser("server", 0, "...", "Server related commands.", 0)
{
createDelegateCommands (cmds);
createDelegateCommands(cmds);
}
//-----------------------------------------------------------------
bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const StringVector_t & argv, const String_t & originalCommand, String_t & result, const CommandParser * node)
bool ConsoleCommandParserServer::performParsing(const NetworkId & userId, const StringVector_t & argv, const String_t & originalCommand, String_t & result, const CommandParser * node)
{
NOT_NULL (node);
NOT_NULL(node);
UNREF(originalCommand);
ServerObject * user = safe_cast<ServerObject *>(NetworkIdManager::getObjectById (userId));
ServerObject * user = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(userId));
//-----------------------------------------------------------------
if (isAbbrev (argv [0], ms_testStructurePlacement))
if (isAbbrev(argv[0], ms_testStructurePlacement))
{
//-- make sure the user is valid
if (!user)
{
result += Unicode::narrowToWide ("invalid user");
result += Unicode::narrowToWide("invalid user");
return true;
}
if (!user->getClient ())
if (!user->getClient())
{
result += Unicode::narrowToWide ("invalid client");
result += Unicode::narrowToWide("invalid client");
return true;
}
if (!user->getClient ()->isGod ())
if (!user->getClient()->isGod())
{
result += Unicode::narrowToWide ("user does not have admin privileges");
result += Unicode::narrowToWide("user does not have admin privileges");
return true;
}
const std::string serverObjectTemplateName = Unicode::wideToNarrow(argv [1]);
const std::string serverObjectTemplateName = Unicode::wideToNarrow(argv[1]);
//-- make sure the name is not empty
if (serverObjectTemplateName.empty ())
if (serverObjectTemplateName.empty())
{
result += Unicode::narrowToWide ("serverObjectTemplateName is empty");
result += Unicode::narrowToWide("serverObjectTemplateName is empty");
return true;
}
//-- fetch the object template
const ObjectTemplate* const objectTemplate = ObjectTemplateList::fetch (serverObjectTemplateName);
const ObjectTemplate* const objectTemplate = ObjectTemplateList::fetch(serverObjectTemplateName);
if (!objectTemplate)
{
result += Unicode::narrowToWide ("serverObjectTemplate does not exist");
result += Unicode::narrowToWide("serverObjectTemplate does not exist");
return true;
}
@@ -263,18 +263,18 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
const ServerObjectTemplate* const serverObjectTemplate = dynamic_cast<const ServerObjectTemplate*> (objectTemplate);
if (!serverObjectTemplate)
{
objectTemplate->releaseReference ();
objectTemplate->releaseReference();
result += Unicode::narrowToWide ("serverObjectTemplate is not a server object template");
result += Unicode::narrowToWide("serverObjectTemplate is not a server object template");
return true;
}
//-- fetch the shared object template
const std::string sharedObjectTemplateName = serverObjectTemplate->getSharedTemplate ();
serverObjectTemplate->releaseReference ();
if (sharedObjectTemplateName.empty ())
const std::string sharedObjectTemplateName = serverObjectTemplate->getSharedTemplate();
serverObjectTemplate->releaseReference();
if (sharedObjectTemplateName.empty())
{
result += Unicode::narrowToWide ("serverObjectTemplate specifies no sharedObjectTemplateName");
result += Unicode::narrowToWide("serverObjectTemplate specifies no sharedObjectTemplateName");
return true;
}
@@ -287,31 +287,31 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
//-- make sure the user is valid
if (!user)
{
result += Unicode::narrowToWide ("invalid user");
result += Unicode::narrowToWide("invalid user");
return true;
}
if (!user->getClient ())
if (!user->getClient())
{
result += Unicode::narrowToWide ("invalid client");
result += Unicode::narrowToWide("invalid client");
return true;
}
if (!user->getClient ()->isGod ())
if (!user->getClient()->isGod())
{
result += Unicode::narrowToWide ("user does not have admin privileges");
result += Unicode::narrowToWide("user does not have admin privileges");
return true;
}
unsigned long val = strtoul(Unicode::wideToNarrow(argv[1]).c_str(), nullptr, 10);
const bool isPublic = (val != 0);
SetConnectionServerPublic const p(isPublic);
GameServer::getInstance().sendToCentralServer(p);
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
else if( isAbbrev( argv[0], "abortShutdown"))
{
else if (isAbbrev(argv[0], "abortShutdown"))
{
if (!user)
{
result += getErrorMessage(argv[0], ERR_INVALID_USER);
@@ -330,10 +330,10 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
}
AbortShutdown const msg;
GameServer::getInstance().sendToCentralServer(msg);
result += getErrorMessage (argv[0], ERR_SUCCESS);
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
else if( isAbbrev( argv[0], "shutdown"))
{
else if (isAbbrev(argv[0], "shutdown"))
{
if (!user)
{
result += getErrorMessage(argv[0], ERR_INVALID_USER);
@@ -350,26 +350,26 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
result += Unicode::narrowToWide("User is not a god");
return true;
}
if( argv.size() < 4 )
if (argv.size() < 4)
{
result += Unicode::narrowToWide("Not enough parameters. usage is \"shutdown [secsToWait] [maxSecs] [systemMessage]\"");
return true;
}
unsigned long secsToWait = strtoul(Unicode::wideToNarrow(argv[1]).c_str(), nullptr, 10);
unsigned long maxSecs = strtoul(Unicode::wideToNarrow(argv[2]).c_str(), nullptr, 10);
Unicode::String systemMessage;
for( size_t i=3; i< argv.size(); ++i)
for (size_t i = 3; i < argv.size(); ++i)
{
systemMessage += argv[i] + Unicode::narrowToWide(" ");
}
ShutdownCluster const msg(secsToWait, maxSecs, systemMessage);
GameServer::getInstance().sendToCentralServer(msg);
result += getErrorMessage (argv[0], ERR_SUCCESS);
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
//-----------------------------------------------------------------
else if (isAbbrev( argv [0], "kill"))
else if (isAbbrev(argv[0], "kill"))
{
if (!user)
{
@@ -387,39 +387,39 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
result += Unicode::narrowToWide("User is not a god");
return true;
}
unsigned long val = strtoul(Unicode::wideToNarrow(argv[1]).c_str (), nullptr, 10);
unsigned long val = strtoul(Unicode::wideToNarrow(argv[1]).c_str(), nullptr, 10);
switch (val)
{
case 1:
{
ExcommunicateGameServerMessage exmsg(GameServer::getInstance().getProcessId(), 0, "");
GameServer::getInstance().sendToCentralServer(exmsg);
result += getErrorMessage (argv[0], ERR_SUCCESS);
break;
}
case 2:
{
GenericValueTypeMessage<int> const msg("ShutdownMessage", 0);
GameServer::getInstance().sendToPlanetServer(msg);
result += getErrorMessage (argv[0], ERR_SUCCESS);
break;
}
case 3:
{
GenericValueTypeMessage<int> const msg("RequestClusterShutdown", 0);
GameServer::getInstance().sendToCentralServer(msg);
result += getErrorMessage (argv[0], ERR_SUCCESS);
break;
}
default:
result += getErrorMessage (argv[0], ERR_SUCCESS);
case 1:
{
ExcommunicateGameServerMessage exmsg(GameServer::getInstance().getProcessId(), 0, "");
GameServer::getInstance().sendToCentralServer(exmsg);
result += getErrorMessage(argv[0], ERR_SUCCESS);
break;
}
case 2:
{
GenericValueTypeMessage<int> const msg("ShutdownMessage", 0);
GameServer::getInstance().sendToPlanetServer(msg);
result += getErrorMessage(argv[0], ERR_SUCCESS);
break;
}
case 3:
{
GenericValueTypeMessage<int> const msg("RequestClusterShutdown", 0);
GameServer::getInstance().sendToCentralServer(msg);
result += getErrorMessage(argv[0], ERR_SUCCESS);
break;
}
default:
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
}
//-----------------------------------------------------------------
else if (isAbbrev( argv[0], "error"))
else if (isAbbrev(argv[0], "error"))
{
if (user && user->getClient ())
if (user && user->getClient())
{
ErrorMessage const em("GameServer Console", Unicode::wideToNarrow(argv[1]).c_str());
user->getClient()->send(em, true);
@@ -428,31 +428,31 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
//-----------------------------------------------------------------------
else if(isAbbrev(argv[0], "getPlanetId"))
else if (isAbbrev(argv[0], "getPlanetId"))
{
PlanetObject * p = ServerUniverse::getInstance().getCurrentPlanet();
if (argv.size() > 1)
p = ServerUniverse::getInstance().getPlanetByName(Unicode::wideToNarrow(argv[1]));
NetworkId pid;
if(p)
if (p)
{
pid = p->getNetworkId();
}
result += Unicode::narrowToWide(pid.getValueString());
}
//-----------------------------------------------------------------
else if (isAbbrev( argv[0], "clock"))
else if (isAbbrev(argv[0], "clock"))
{
char text[128];
sprintf(text, "FPS: %f FrameTime: %f\n", Clock::framesPerSecond(), Clock::frameTime());
result += Unicode::narrowToWide(text);
result += getErrorMessage (argv[0], ERR_SUCCESS);
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
//-----------------------------------------------------------------
else if (isAbbrev( argv[0], "releaseAuth"))
else if (isAbbrev(argv[0], "releaseAuth"))
{
NetworkId oid(Unicode::wideToNarrow(argv[1]));
ServerObject* object = ServerWorld::findObjectByNetworkId(oid);
@@ -470,7 +470,7 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
GameServer::getInstance().sendToCentralServer(msg);
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
else if(isAbbrev( argv[0], "showObjectSpheres"))
else if (isAbbrev(argv[0], "showObjectSpheres"))
{
std::vector<std::pair<ServerObject *, Sphere> > results;
ServerWorld::dumpObjectSphereTree(results);
@@ -481,31 +481,31 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
result += Unicode::narrowToWide(" object sphere tree nodes to client\n");
std::vector<std::pair<ServerObject *, Sphere> >::iterator i;
for(i = results.begin(); i != results.end(); ++i)
for (i = results.begin(); i != results.end(); ++i)
{
std::string name = "SPHERE NODE";
NetworkId id(NetworkId::cms_invalid);
if((*i).first)
if ((*i).first)
{
name = Unicode::wideToNarrow((*i).first->getObjectName());
id = (*i).first->getNetworkId();
}
sprintf(
count,
"Sphere id=[%lu] origin=[%f, %f, %f] radius=[%f] OID=[%s] %s\n",
std::distance(results.begin(), i),//reinterpret_cast<unsigned long>(i),
(*i).second.getCenter().x,
(*i).second.getCenter().y,
(*i).second.getCenter().z,
count,
"Sphere id=[%lu] origin=[%f, %f, %f] radius=[%f] OID=[%s] %s\n",
std::distance(results.begin(), i),//reinterpret_cast<unsigned long>(i),
(*i).second.getCenter().x,
(*i).second.getCenter().y,
(*i).second.getCenter().z,
(*i).second.getRadius(),
id.getValueString().c_str(),
name.c_str()
);
);
result += Unicode::narrowToWide(count);
}
}
else if(isAbbrev( argv[0], "showTriggerSpheres"))
else if (isAbbrev(argv[0], "showTriggerSpheres"))
{
std::vector<std::pair<TriggerVolume *, Sphere> > results;
ServerWorld::dumpTriggerSphereTree(results);
@@ -515,38 +515,37 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
result += Unicode::narrowToWide(count);
result += Unicode::narrowToWide(" trigger sphere tree nodes to client\n");
std::vector<std::pair<TriggerVolume *, Sphere> >::iterator i;
for(i = results.begin(); i != results.end(); ++i)
for (i = results.begin(); i != results.end(); ++i)
{
std::string name = "SPHERE NODE";
NetworkId id(NetworkId::cms_invalid);
if((*i).first)
if ((*i).first)
{
name = Unicode::wideToNarrow((*i).first->getOwner().getObjectName());
id = (*i).first->getOwner().getNetworkId();
}
sprintf(
count,
"Sphere id=[%lu] origin=[%f, %f, %f] radius=[%f] OID=[%s] %s\n",
count,
"Sphere id=[%lu] origin=[%f, %f, %f] radius=[%f] OID=[%s] %s\n",
std::distance(results.begin(), i),
(*i).second.getCenter().x,
(*i).second.getCenter().y,
(*i).second.getCenter().z,
(*i).second.getCenter().x,
(*i).second.getCenter().y,
(*i).second.getCenter().z,
(*i).second.getRadius(),
id.getValueString().c_str(),
name.c_str()
);
);
result += Unicode::narrowToWide(count);
}
}
else if (isAbbrev (argv[0], "snapAllObjectsToTerrain"))
else if (isAbbrev(argv[0], "snapAllObjectsToTerrain"))
{
ServerWorld::snapAllObjectsToTerrain ();
result += getErrorMessage (argv[0], ERR_SUCCESS);
ServerWorld::snapAllObjectsToTerrain();
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
else if (isAbbrev (argv[0], "getSceneId"))
else if (isAbbrev(argv[0], "getSceneId"))
{
if (user == nullptr)
{
@@ -555,9 +554,9 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
}
result += Unicode::narrowToWide(user->getSceneId());
result += Unicode::narrowToWide("\n");
result += getErrorMessage (argv[0], ERR_SUCCESS);
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
else if (isAbbrev (argv[0], "setGodMode"))
else if (isAbbrev(argv[0], "setGodMode"))
{
if (!user)
{
@@ -570,17 +569,16 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
return true;
}
unsigned long val = strtoul(Unicode::wideToNarrow(argv[1]).c_str (), nullptr, 10);
unsigned long val = strtoul(Unicode::wideToNarrow(argv[1]).c_str(), nullptr, 10);
if (user->getClient()->setGodMode(val != 0))
result += getErrorMessage (argv[0], ERR_SUCCESS);
result += getErrorMessage(argv[0], ERR_SUCCESS);
else
result += Unicode::narrowToWide("Cannot set god mode on unvalidated client\n");
}
else if (isAbbrev(argv[0], "reloadCommandTable"))
{
result += getErrorMessage(argv[0], ERR_SUCCESS);
ServerCommandTable::load();
// send a message to other servers to reload the table
@@ -629,12 +627,12 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
{
std::string tableName;
tableName = Unicode::wideToNarrow(argv[1]);
int col = atoi(Unicode::wideToNarrow(argv[2]).c_str ());
int row = atoi(Unicode::wideToNarrow(argv[3]).c_str ());
int col = atoi(Unicode::wideToNarrow(argv[2]).c_str());
int row = atoi(Unicode::wideToNarrow(argv[3]).c_str());
DataTable * dt = DataTableManager::getTable(tableName);
if (dt)
{
result += Unicode::narrowToWide(dt->getStringValue(col, row));
result += Unicode::narrowToWide(dt->getStringValue(col, row));
}
else
result += Unicode::narrowToWide("No such table");
@@ -644,12 +642,12 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
GameServer::getInstance().loadTerrain();
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
else if(isAbbrev(argv[0], "messageCount"))
else if (isAbbrev(argv[0], "messageCount"))
{
std::vector<std::pair<std::string, int> > messages = GameNetworkMessage::getMessageCount();
std::vector<std::pair<std::string, int> >::iterator i;
char buf[128] = {"\0"};
for(i = messages.begin(); i != messages.end(); ++i)
char buf[128] = { "\0" };
for (i = messages.begin(); i != messages.end(); ++i)
{
IGNORE_RETURN(snprintf(buf, sizeof(buf), "[%9d] - \"%s\"\n", (*i).second, (*i).first.c_str()));
result += Unicode::narrowToWide(buf);
@@ -659,7 +657,7 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
else if (isAbbrev(argv[0], "listRegions"))
{
Client * client = user->getClient();
if(client)
if (client)
{
//get all the regions, and build messages, and sender to client (should be priveledged client, i.e. godclient user)
std::string planetName;
@@ -679,7 +677,7 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
std::vector<const Region *> regions;
RegionMaster::getRegionsForPlanet(planetName, regions);
for (std::vector<const Region *>::const_iterator i = regions.begin(); i != regions.end(); ++i)
for (std::vector<const Region *>::const_iterator i = regions.begin(); i != regions.end(); ++i)
{
const RegionRectangle * ro = dynamic_cast<const RegionRectangle*>(*i);
if (ro != nullptr)
@@ -749,7 +747,7 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
}
else if (isAbbrev(argv[0], "setFrameRateLimit"))
{
if(argv.size() > 1)
if (argv.size() > 1)
{
float newLimit = static_cast<float>(atof(Unicode::wideToNarrow(argv[1]).c_str()));
@@ -764,22 +762,22 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
}
else if (isAbbrev(argv[0], "setDebugFlag"))
{
if (!user->getClient ()->isGod ())
if (!user->getClient()->isGod())
{
result += Unicode::narrowToWide ("user does not have admin privileges");
result += Unicode::narrowToWide("user does not have admin privileges");
}
else if(argv.size() > 3)
else if (argv.size() > 3)
{
const std::string section = Unicode::wideToNarrow(argv[1]);
const std::string name = Unicode::wideToNarrow(argv[2]);
const bool value = argv[3][0] != '0';
bool * const flag = DebugFlags::findFlag(section.c_str(), name.c_str());
if(flag)
if (flag)
{
*flag = value;
result += Unicode::narrowToWide("set flag " + section + "/" + name + " to ");
if(value)
if (value)
{
result += Unicode::narrowToWide("true");
}
@@ -787,7 +785,6 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
{
result += Unicode::narrowToWide("false");
}
}
else
{
@@ -799,7 +796,7 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
result += getErrorMessage(argv[0], ERR_FAIL);
}
}
else if(isAbbrev(argv[0], "validateWorld"))
else if (isAbbrev(argv[0], "validateWorld"))
{
World::validate();
@@ -823,9 +820,9 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
size_t resultCount = results.size();
if(resultCount)
if (resultCount)
{
for(size_t i = 0; i < resultCount; i++)
for (size_t i = 0; i < resultCount; i++)
{
result += results[i]->getName();
result += Unicode::narrowToWide("\n");
@@ -834,7 +831,7 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
else
{
result += Unicode::narrowToWide("No regions at the given point\n");
}
}
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
@@ -860,7 +857,7 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
}
else if (isAbbrev(argv[0], "startSave"))
{
GenericValueTypeMessage<NetworkId> const msg("StartSaveMessage", userId);
GenericValueTypeMessage<NetworkId> const msg("StartSaveMessage", userId);
GameServer::getInstance().sendToDatabaseServer(msg);
result += Unicode::narrowToWide("Request sent. Please wait for reply");
@@ -924,7 +921,7 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
ServerMessageForwarding::beginBroadcast();
GenericValueTypeMessage<bool> const enablePlayerSanityCheckerMessage("EnablePlayerSanityCheckerMessage",enableFlag);
GenericValueTypeMessage<bool> const enablePlayerSanityCheckerMessage("EnablePlayerSanityCheckerMessage", enableFlag);
ServerMessageForwarding::send(enablePlayerSanityCheckerMessage);
ServerMessageForwarding::end();
@@ -998,11 +995,11 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const StringVector_t & argv, const String_t & originalCommand, String_t & result, const CommandParser * node)
{
NOT_NULL (node);
NOT_NULL(node);
UNREF(originalCommand);
ServerObject * user = safe_cast<ServerObject *>(NetworkIdManager::getObjectById (userId));
ServerObject * user = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(userId));
if (isAbbrev(argv[0], "destroyPersistedBuildoutAreaDuplicates"))
{
@@ -1023,7 +1020,7 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
{
ExcommunicateGameServerMessage exmsg(serverId, 0, "");
GameServer::getInstance().sendToCentralServer(exmsg);
result += getErrorMessage (argv[0], ERR_SUCCESS);
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
else
result += Unicode::narrowToWide("Invalid server number");
@@ -1048,7 +1045,7 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
std::string const &scene = Unicode::wideToNarrow(argv[1]);
int x = static_cast<int>(strtod(Unicode::wideToNarrow(argv[2]).c_str(), nullptr));
int z = static_cast<int>(strtod(Unicode::wideToNarrow(argv[3]).c_str(), nullptr));
RestartServerMessage msg(scene, x, z);
if (scene == ConfigServerGame::getSceneID())
GameServer::getInstance().sendToPlanetServer(msg);
@@ -1064,22 +1061,22 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
{
std::string const &scene = Unicode::wideToNarrow(argv[1]);
GenericValueTypeMessage<std::string> msg("RestartPlanetMessage",scene);
GenericValueTypeMessage<std::string> msg("RestartPlanetMessage", scene);
if (scene == ConfigServerGame::getSceneID())
{
GenericValueTypeMessage<int> const msg("ShutdownMessage", 0);
GenericValueTypeMessage<int> const msg("ShutdownMessage", 0);
GameServer::getInstance().sendToPlanetServer(msg);
}
else
GameServer::getInstance().sendToCentralServer(msg);
result += getErrorMessage(argv[0], ERR_SUCCESS);
}
else
result += Unicode::narrowToWide("Syntax: remote server restartPlanet <sceneId>");
}
else if (isAbbrev(argv [0], "dumpCreatures"))
else if (isAbbrev(argv[0], "dumpCreatures"))
{
// This is potentially an expensive command, so make sure that this can only be done in god mode
if (!user)
@@ -1245,15 +1242,15 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
char buffer[128];
std::vector<int> moveListSize;
snprintf(buffer, sizeof(buffer)-1, "%d move object lists\n", ServerWorld::getNumMoveLists(moveListSize));
buffer[sizeof(buffer)-1] = '\0';
snprintf(buffer, sizeof(buffer) - 1, "%d move object lists\n", ServerWorld::getNumMoveLists(moveListSize));
buffer[sizeof(buffer) - 1] = '\0';
result += Unicode::narrowToWide(buffer);
int moveListIndex = 1;
for (std::vector<int>::const_iterator i = moveListSize.begin(); i != moveListSize.end(); ++i)
{
snprintf(buffer, sizeof(buffer)-1, "list #%d size: %d\n", moveListIndex++, *i);
buffer[sizeof(buffer)-1] = '\0';
snprintf(buffer, sizeof(buffer) - 1, "list #%d size: %d\n", moveListIndex++, *i);
buffer[sizeof(buffer) - 1] = '\0';
result += Unicode::narrowToWide(buffer);
}
@@ -1266,8 +1263,8 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
ServerWorld::setNumMoveLists(numMoveLists);
char buffer[128];
snprintf(buffer, sizeof(buffer)-1, "setting the number of move object lists to %d\n", numMoveLists);
buffer[sizeof(buffer)-1] = '\0';
snprintf(buffer, sizeof(buffer) - 1, "setting the number of move object lists to %d\n", numMoveLists);
buffer[sizeof(buffer) - 1] = '\0';
result += Unicode::narrowToWide(buffer);
result += getErrorMessage(argv[0], ERR_SUCCESS);
@@ -1517,7 +1514,7 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
if (!padding.empty())
result += Unicode::narrowToWide(padding);
result += Unicode::narrowToWide(FormattedString<512>().sprintf(": %4d\n", iterStatistics->second));
result += Unicode::narrowToWide(FormattedString<512>().sprintf(": %4d\n", iterStatistics->second));
}
}
}
@@ -1563,7 +1560,6 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
++groupMemberIndex;
IGNORE_RETURN(orderedMemberList.insert(std::make_pair(std::make_pair(Unicode::toUpper(iter->second), iter->first), groupMemberName)));
}
for (std::multimap<std::pair<std::string, NetworkId>, std::string>::const_iterator iter2 = orderedMemberList.begin(); iter2 != orderedMemberList.end(); ++iter2)
@@ -1641,41 +1637,26 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
{
if (iter->second->getType() & TravelPoint::TPT_NPC_Starport)
{
if (tpType.empty())
tpType += ", ";
tpType = "TPT_NPC_Starport";
}
if (iter->second->getType() & TravelPoint::TPT_NPC_Shuttleport)
{
if (tpType.empty())
tpType += ", ";
tpType = "TPT_NPC_Shuttleport";
}
if (iter->second->getType() & TravelPoint::TPT_NPC_StaticBaseBeacon)
{
if (tpType.empty())
tpType += ", ";
tpType = "TPT_NPC_StaticBaseBeacon";
}
if (iter->second->getType() & TravelPoint::TPT_PC_Shuttleport)
{
if (tpType.empty())
tpType += ", ";
tpType = "TPT_PC_Shuttleport";
}
if (iter->second->getType() & TravelPoint::TPT_PC_CampShuttleBeacon)
{
if (tpType.empty())
tpType += ", ";
tpType = "TPT_PC_CampShuttleBeacon";
}
}
@@ -2971,7 +2952,7 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
if (!user)
{
parseSuccess = false;
result += Unicode::narrowToWide ("invalid user\n");
result += Unicode::narrowToWide("invalid user\n");
}
if (parseSuccess)
@@ -2979,7 +2960,7 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
if (!user->getClient())
{
parseSuccess = false;
result += Unicode::narrowToWide ("invalid client\n");
result += Unicode::narrowToWide("invalid client\n");
}
}
@@ -2989,7 +2970,7 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
if (!playerObject)
{
parseSuccess = false;
result += Unicode::narrowToWide ("invalid player object\n");
result += Unicode::narrowToWide("invalid player object\n");
}
else
{
@@ -3027,14 +3008,14 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
if (s_tenOriginalGroundPlanets.count(ServerWorld::getSceneId()) <= 0)
{
parseSuccess = false;
result += Unicode::narrowToWide ("you must be on one of the 10 original ground planets for character transfer\n");
result += Unicode::narrowToWide("you must be on one of the 10 original ground planets for character transfer\n");
}
}
if (parseSuccess)
{
result += Unicode::narrowToWide(FormattedString<1024>().sprintf("requesting transfer of this character [%u, %s, %s (%s)] to [%u, %s, %s]\n", sourceStationId, GameServer::getInstance().getClusterName().c_str(), Unicode::wideToNarrow(user->getAssignedObjectName()).c_str(), user->getNetworkId().getValueString().c_str(), destStationId, destGalaxy.c_str(), destCharacterName.c_str()));
result += Unicode::narrowToWide ("you will be disconnected once the transfer is validated and the transfer process begins.\n");
result += Unicode::narrowToWide("you will be disconnected once the transfer is validated and the transfer process begins.\n");
TransferRequestMoveValidation const trmv(TransferRequestMoveValidation::TRS_console_god_command, GameServer::getInstance().getProcessId(), sourceStationId, destStationId, GameServer::getInstance().getClusterName(), destGalaxy, Unicode::wideToNarrow(user->getAssignedObjectName()), user->getNetworkId(), user->getTemplateCrc(), destCharacterName, std::string("en"));
GameServer::getInstance().sendToCentralServer(trmv);
@@ -3089,7 +3070,7 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
result += Unicode::narrowToWide(FormattedString<1024>().sprintf("(%s) is not a valid GCW score category.\n", category.c_str()));
result += Unicode::narrowToWide("\nThe GCW score categories are as follows:\n");
std::map<std::string, Pvp::GcwScoreCategory const *> const & allGcwScoreCategory = Pvp::getAllGcwScoreCategory();
std::map<std::string, Pvp::GcwScoreCategory const *> const & allGcwScoreCategory = Pvp::getAllGcwScoreCategory();
for (std::map<std::string, Pvp::GcwScoreCategory const *>::const_iterator iter = allGcwScoreCategory.begin(); iter != allGcwScoreCategory.end(); ++iter)
{
result += Unicode::narrowToWide(iter->first);
@@ -3112,7 +3093,7 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
result += Unicode::narrowToWide(FormattedString<1024>().sprintf("(%s) is not a valid GCW score category.\n", category.c_str()));
result += Unicode::narrowToWide("\nThe GCW score categories are as follows:\n");
std::map<std::string, Pvp::GcwScoreCategory const *> const & allGcwScoreCategory = Pvp::getAllGcwScoreCategory();
std::map<std::string, Pvp::GcwScoreCategory const *> const & allGcwScoreCategory = Pvp::getAllGcwScoreCategory();
for (std::map<std::string, Pvp::GcwScoreCategory const *>::const_iterator iter = allGcwScoreCategory.begin(); iter != allGcwScoreCategory.end(); ++iter)
{
result += Unicode::narrowToWide(iter->first);
@@ -3134,7 +3115,7 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
result += Unicode::narrowToWide(FormattedString<1024>().sprintf("(%s) is not a valid GCW score category.\n", category.c_str()));
result += Unicode::narrowToWide("\nThe GCW score categories are as follows:\n");
std::map<std::string, Pvp::GcwScoreCategory const *> const & allGcwScoreCategory = Pvp::getAllGcwScoreCategory();
std::map<std::string, Pvp::GcwScoreCategory const *> const & allGcwScoreCategory = Pvp::getAllGcwScoreCategory();
for (std::map<std::string, Pvp::GcwScoreCategory const *>::const_iterator iter = allGcwScoreCategory.begin(); iter != allGcwScoreCategory.end(); ++iter)
{
result += Unicode::narrowToWide(iter->first);
@@ -3453,80 +3434,79 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
GameServer::setExtraDelayPerFrameMs(ms);
}
else if (isAbbrev(argv[0], "serverinfo"))
{
char numBuf[64] = {"\0"};
static const Unicode::String unl(Unicode::narrowToWide(std::string("\n")));
{
char numBuf[64] = { "\0" };
static const Unicode::String unl(Unicode::narrowToWide(std::string("\n")));
result += Unicode::narrowToWide("PID: ");
snprintf(numBuf, sizeof(numBuf), "%lu", GameServer::getInstance().getProcessId());
result += Unicode::narrowToWide(std::string(numBuf)) + unl;
result += Unicode::narrowToWide("PID: ");
snprintf(numBuf, sizeof(numBuf), "%lu", GameServer::getInstance().getProcessId());
result += Unicode::narrowToWide(std::string(numBuf)) + unl;
result += Unicode::narrowToWide("Scene: ") + Unicode::narrowToWide(ConfigServerGame::getSceneID()) + unl;
result += Unicode::narrowToWide("Scene: ") + Unicode::narrowToWide(ConfigServerGame::getSceneID()) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumObjects());
result += Unicode::narrowToWide(std::string("Number of Objects: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumObjects());
result += Unicode::narrowToWide(std::string("Number of Objects: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumAI());
result += Unicode::narrowToWide(std::string("Number of AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumAI());
result += Unicode::narrowToWide(std::string("Number of AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumBuildings());
result += Unicode::narrowToWide(std::string("Number of Buildings: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumBuildings());
result += Unicode::narrowToWide(std::string("Number of Buildings: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumInstallations());
result += Unicode::narrowToWide(std::string("Number of Installations: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumInstallations());
result += Unicode::narrowToWide(std::string("Number of Installations: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumCreatures());
result += Unicode::narrowToWide(std::string("Number of Creatures: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumCreatures());
result += Unicode::narrowToWide(std::string("Number of Creatures: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumPlayers());
result += Unicode::narrowToWide(std::string("Number of Players: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumPlayers());
result += Unicode::narrowToWide(std::string("Number of Players: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumTangibles());
result += Unicode::narrowToWide(std::string("Number of Tangibles: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumTangibles());
result += Unicode::narrowToWide(std::string("Number of Tangibles: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumUniverseObjects());
result += Unicode::narrowToWide(std::string("Number of UniverseObjects: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumUniverseObjects());
result += Unicode::narrowToWide(std::string("Number of UniverseObjects: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumDynamicAI());
result += Unicode::narrowToWide(std::string("Number of Dynamic AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumDynamicAI());
result += Unicode::narrowToWide(std::string("Number of Dynamic AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumStaticAI());
result += Unicode::narrowToWide(std::string("Number of Static AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumCombatAI());
result += Unicode::narrowToWide(std::string("Number of Combat AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumHibernatingAI());
result += Unicode::narrowToWide(std::string("Number of Hibernating AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumStaticAI());
result += Unicode::narrowToWide(std::string("Number of Static AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumDelayedHibernatingAI());
result += Unicode::narrowToWide(std::string("Number of Delayed Hibernating AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumIntangibles());
result += Unicode::narrowToWide(std::string("Number of Intangibles: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumCombatAI());
result += Unicode::narrowToWide(std::string("Number of Combat AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumMissionDatas());
result += Unicode::narrowToWide(std::string("Number of MissionDatas: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumHibernatingAI());
result += Unicode::narrowToWide(std::string("Number of Hibernating AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumMissionObjects());
result += Unicode::narrowToWide(std::string("Number of MissionObjects: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumDelayedHibernatingAI());
result += Unicode::narrowToWide(std::string("Number of Delayed Hibernating AI: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumRunTimeRules());
result += Unicode::narrowToWide(std::string("Number of Runtime Rules: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumIntangibles());
result += Unicode::narrowToWide(std::string("Number of Intangibles: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumGroupObjects());
result += Unicode::narrowToWide(std::string("Number of GroupObjects: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumMissionDatas());
result += Unicode::narrowToWide(std::string("Number of MissionDatas: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumMissionListEntries());
result += Unicode::narrowToWide(std::string("Number of MissionListEntries: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumMissionObjects());
result += Unicode::narrowToWide(std::string("Number of MissionObjects: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumWaypoints());
result += Unicode::narrowToWide(std::string("Number of Waypoints: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumRunTimeRules());
result += Unicode::narrowToWide(std::string("Number of Runtime Rules: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumPlayerQuestObjects());
result += Unicode::narrowToWide(std::string("Number of PlayerQuestObjects: ") + std::string(numBuf)) + unl;
}
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumGroupObjects());
result += Unicode::narrowToWide(std::string("Number of GroupObjects: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumMissionListEntries());
result += Unicode::narrowToWide(std::string("Number of MissionListEntries: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumWaypoints());
result += Unicode::narrowToWide(std::string("Number of Waypoints: ") + std::string(numBuf)) + unl;
snprintf(numBuf, sizeof(numBuf), "%d", ObjectTracker::getNumPlayerQuestObjects());
result += Unicode::narrowToWide(std::string("Number of PlayerQuestObjects: ") + std::string(numBuf)) + unl;
}
#endif
else
{
@@ -3534,6 +3514,6 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
}
return true;
}
}
// ======================================================================
// ======================================================================
@@ -86,13 +86,13 @@ void AuthTransferTracker::beginAuthTransfer(NetworkId const &networkId, uint32 n
if ((*i) != GameServer::getInstance().getProcessId())
authTransferInfo.unconfirmedProcessIds.push_back(*i);
s_authTransfersOrdered->push(networkId);
if (ConfigServerGame::getLogAuthTransfer())
{
char logBuffer[1024];
logBuffer[0] = '\0';
for (std::vector<uint32>::const_iterator i = authTransferInfo.unconfirmedProcessIds.begin(); i != authTransferInfo.unconfirmedProcessIds.end(); ++i)
sprintf(logBuffer+strlen(logBuffer), "%lu ", *i);
snprintf(logBuffer + strlen(logBuffer), sizeof(logBuffer), "%lu ", *i);
LOG("AuthTransfer", ("Begin auth transfer confirm for %s ( %s)", networkId.getValueString().c_str(), logBuffer));
}
}
@@ -103,9 +103,9 @@ void AuthTransferTracker::beginAuthTransfer(NetworkId const &networkId, uint32 n
void AuthTransferTracker::sendConfirmAuthTransfer(NetworkId const &networkId, uint32 fromServer)
{
// only send if the old server was set, wasn't this server, and wasn't the db.
if ( fromServer
&& fromServer != GameServer::getInstance().getProcessId()
&& fromServer != GameServer::getInstance().getDatabaseProcessId())
if (fromServer
&& fromServer != GameServer::getInstance().getProcessId()
&& fromServer != GameServer::getInstance().getDatabaseProcessId())
{
// also only send if we have a connection, since it may be an auth transfer due to a server crash
if (GameServer::getInstance().isGameServerConnected(fromServer))
@@ -196,7 +196,7 @@ void AuthTransferTracker::update()
std::map<NetworkId, AuthTransferInfo>::iterator i = s_authTransferMap->find(networkId);
if (i != s_authTransferMap->end())
{
if (Clock::timeMs()-(*i).second.startTime < AUTH_TRACK_TIME_MS)
if (Clock::timeMs() - (*i).second.startTime < AUTH_TRACK_TIME_MS)
return;
s_authTransferMap->erase(i);
}
@@ -204,5 +204,4 @@ void AuthTransferTracker::update()
}
}
// ======================================================================
// ======================================================================
@@ -553,7 +553,7 @@ bool ServerBuildoutManagerNamespace::isNotObjectForBuildout(ServerObject const *
tmpObj->setIncludeInBuildout(true);
}
if (!obj || !obj->isInWorld() || (!obj->isPersisted() && !obj->getIncludeInBuildout()) || obj->isPlayerControlled())
if (!obj->isInWorld() || (!obj->isPersisted() && !obj->getIncludeInBuildout()) || obj->isPlayerControlled())
{
return true;
}
@@ -2916,9 +2916,9 @@ void ServerWorld::update(real time)
std::string buffer;
getWeather().debugPrint(buffer);
DEBUG_REPORT_LOG(true, ("Weather data is %s\n", buffer.c_str()));
}
}
#endif
}
}
updatePlanetServer();
@@ -53,7 +53,6 @@ SharedObjectTemplate const *GroupObject::m_defaultSharedTemplate = 0;
namespace GroupObjectNamespace
{
// ----------------------------------------------------------------------
unsigned int const cs_maximumNumberInGroup = 8;
@@ -78,29 +77,27 @@ namespace GroupObjectNamespace
}
// ----------------------------------------------------------------------
}
using namespace GroupObjectNamespace;
// ======================================================================
GroupObject::GroupObject(ServerGroupObjectTemplate const *newTemplate)
: UniverseObject(newTemplate),
m_groupName(),
m_groupMembers(),
m_groupShipFormationMembers(),
m_groupPOBShipAndOwners(),
m_groupLevel(),
m_groupMemberLevels(),
m_groupMemberProfessions(),
m_formationNameCrc(Crc::crcNull),
m_allMembers(),
m_nonPCMembers(),
m_lootMaster(),
m_lootRule(0),
m_groupPickupTimer(std::make_pair(0, 0)),
m_groupPickupLocation(std::make_pair("", Vector()))
: UniverseObject(newTemplate),
m_groupName(),
m_groupMembers(),
m_groupShipFormationMembers(),
m_groupPOBShipAndOwners(),
m_groupLevel(),
m_groupMemberLevels(),
m_groupMemberProfessions(),
m_formationNameCrc(Crc::crcNull),
m_allMembers(),
m_nonPCMembers(),
m_lootMaster(),
m_lootRule(0),
m_groupPickupTimer(std::make_pair(0, 0)),
m_groupPickupLocation(std::make_pair("", Vector()))
{
m_groupMembers.setSourceObject(this);
m_groupShipFormationMembers.setSourceObject(this);
@@ -175,7 +172,7 @@ void GroupObject::removeDefaultTemplate()
if (!m_defaultSharedTemplate)
{
m_defaultSharedTemplate->releaseReference();
m_defaultSharedTemplate = 0;
m_defaultSharedTemplate = nullptr;
}
}
@@ -448,7 +445,7 @@ void GroupObject::addGroupMember(GroupMemberParam const & member)
GroupUpdateObserver updater(this, Archive::ADOO_generic);
m_groupMembers.push_back(std::make_pair(member.m_memberId, member.m_memberName));
m_allMembers.insert(member.m_memberId);
if (!member.m_memberIsPC)
m_nonPCMembers.insert(member.m_memberId);
@@ -467,7 +464,7 @@ void GroupObject::addGroupMember(GroupMemberParam const & member)
POBShipIsAdded = true;
}
}
if (!POBShipIsAdded)
{
m_groupPOBShipAndOwners.push_back(std::make_pair(member.m_memberShipId, member.m_memberId));
@@ -546,7 +543,7 @@ void GroupObject::removeGroupMember(NetworkId const &memberId)
break;
}
}
break;
}
}
@@ -655,7 +652,7 @@ void GroupObject::createGroupChatRoom() const
LOG("GroupChat", ("Creating group chat room %s (group id %s)", getChatRoomPath().c_str(), getNetworkId().getValueString().c_str()));
Chat::createRoom("System", false, getChatRoomPath(), getNetworkId().getValueString());
//TODO: temporary separation of voice and text
Chat::requestGetChannel(getChatRoomPath(), getVoiceChatDisplayName());
}
@@ -787,7 +784,7 @@ void GroupObject::onChatRoomCreate(std::string const &path) // static
if (!path.compare(0, prefix.length(), prefix))
{
// it's a group channel, so extract the networkId
NetworkId id(path.substr(prefix.length(), path.length()-prefix.length()-getChatRoomSuffix().length()));
NetworkId id(path.substr(prefix.length(), path.length() - prefix.length() - getChatRoomSuffix().length()));
Object *obj = NetworkIdManager::getObjectById(id);
if (obj)
{
@@ -1342,7 +1339,7 @@ void GroupObject::makeLootMaster(NetworkId const & newLootMasterId)
{
return;
}
if (!isAuthoritative())
{
Controller *controller = getController();
@@ -1360,7 +1357,7 @@ void GroupObject::makeLootMaster(NetworkId const & newLootMasterId)
else
{
GroupUpdateObserver updater(this, Archive::ADOO_generic);
int const numberOfGroupMembers = m_groupMembers.size();
for (int i = 0; i < numberOfGroupMembers; ++i)
@@ -1486,4 +1483,4 @@ void GroupObject::reenterGroupChatRoom(CreatureObject const &who) const
Chat::enterRoom(firstName, groupChatRoomPath, false, false);
}
// ======================================================================
// ======================================================================
@@ -34,7 +34,7 @@ bool PvpRuleSetNormal::canAttack(TangibleObject const &actor, TangibleObject con
bool const actorIsPlayer = PvpInternal::isPlayer(actor);
bool const targetIsPlayer = PvpInternal::isPlayer(target);
Pvp::FactionId targetFaction = PvpInternal::getAlignedFaction(target);
Pvp::FactionId actorFaction = PvpInternal::getAlignedFaction(actor);
Pvp::FactionId actorFaction = PvpInternal::getAlignedFaction(actor);
Pvp::PvpType actorPvpType = actor.getPvpType();
Pvp::PvpType targetPvpType = target.getPvpType();
@@ -92,7 +92,7 @@ bool PvpRuleSetNormal::canAttack(TangibleObject const &actor, TangibleObject con
return false;
}
if (actorFaction != targetFaction)
{
// special forces player can attack opposing special forces NPC
@@ -104,30 +104,29 @@ bool PvpRuleSetNormal::canAttack(TangibleObject const &actor, TangibleObject con
}
// anyone may attack someone they are mutually dueling with
if ( PvpInternal::hasDuelEnemyFlag(target, actor.getNetworkId())
&& PvpInternal::hasDuelEnemyFlag(actor, target.getNetworkId()))
if (PvpInternal::hasDuelEnemyFlag(target, actor.getNetworkId())
&& PvpInternal::hasDuelEnemyFlag(actor, target.getNetworkId()))
return true;
// a bounty hunter can attack their target
if (actorIsPlayer && targetIsPlayer && creatureActor && creatureTarget && creatureActor->hasBounty(*creatureTarget) && creatureActor->hasBountyMissionForTarget(creatureTarget->getNetworkId()))
return true;
if(targetIsPlayer && actorIsPlayer)
if (targetIsPlayer && actorIsPlayer)
{
// noone may attack someone in their own group
if (PvpInternal::inSameGroup(actor, target))
return false;
if(actorFaction!=targetFaction)
if (actorFaction != targetFaction)
{
//IF I'M DECLARED AND THEY ARE AS WELL, WE CAN ATTACK.
if ((actorPvpType == PvpType_Declared) && (targetPvpType == PvpType_Declared))
{
return true;
}
}
}
}
}
// anyone may attack someone with a PEF against them (unless they are unattackable)
if (PvpInternal::hasPersonalEnemyFlag(target, actor.getNetworkId()))
@@ -158,22 +157,22 @@ bool PvpRuleSetNormal::canAttack(TangibleObject const &actor, TangibleObject con
NetworkId bhId;
if (target.getObjVars().getItem("objHunter", bhId) && (bhId == actor.getNetworkId()))
{
/*
static int sentinel = 0;
/*
static int sentinel = 0;
// PvpInternal::setPermanentPersonalEnemyFlag() can cause PvpRuleSetNormal::canAttack()
// to get called again; to prevent infinite recursion, don't call
// PvpInternal::setPermanentPersonalEnemyFlag() again
if (sentinel == 0)
{
sentinel = 1;
// PvpInternal::setPermanentPersonalEnemyFlag() can cause PvpRuleSetNormal::canAttack()
// to get called again; to prevent infinite recursion, don't call
// PvpInternal::setPermanentPersonalEnemyFlag() again
if (sentinel == 0)
{
sentinel = 1;
// need to const cast because of updating target to set the PEF
PvpInternal::setPermanentPersonalEnemyFlag(const_cast<TangibleObject &>(target), actor.getNetworkId());
// need to const cast because of updating target to set the PEF
PvpInternal::setPermanentPersonalEnemyFlag(const_cast<TangibleObject &>(target), actor.getNetworkId());
sentinel = 0;
}
*/
sentinel = 0;
}
*/
return true;
}
@@ -187,27 +186,26 @@ bool PvpRuleSetNormal::canAttack(TangibleObject const &actor, TangibleObject con
{
// guild members may attack members of other guilds which have declared war on their guild,
// but only if neither guild members is in a guild war "cool down" period
if ( GuildInterface::hasDeclaredWarAgainst(creatureTarget->getGuildId(), creatureActor->getGuildId())
&& GuildInterface::hasDeclaredWarAgainst(creatureActor->getGuildId(), creatureTarget->getGuildId())
if (GuildInterface::hasDeclaredWarAgainst(creatureTarget->getGuildId(), creatureActor->getGuildId())
&& GuildInterface::hasDeclaredWarAgainst(creatureActor->getGuildId(), creatureTarget->getGuildId())
&& creatureActor->getGuildWarEnabled()
&& creatureTarget->getGuildWarEnabled()
&& !PvpInternal::hasAnyGuildWarCoolDownPeriodEnemyFlag(*creatureActor)
&& !PvpInternal::hasAnyGuildWarCoolDownPeriodEnemyFlag(*creatureTarget))
&& !PvpInternal::hasAnyGuildWarCoolDownPeriodEnemyFlag(*creatureActor)
&& !PvpInternal::hasAnyGuildWarCoolDownPeriodEnemyFlag(*creatureTarget))
return true;
}
if ( (actorIsPlayer) && (!targetIsPlayer) )
if ((actorIsPlayer) && (!targetIsPlayer))
{
// PC attacker rules
// anyone may attack npc targets with no faction opponents
if (!targetIsPlayer && PvpFactions::getOpposingFactions(targetFaction).empty())
if (PvpFactions::getOpposingFactions(targetFaction).empty())
return true;
if (targetFaction != 0)
{
// so they're factional
if (actorFaction!=targetFaction)
if (actorFaction != targetFaction)
{
//they have a differnent faction than me
//am I neutral?
@@ -222,16 +220,16 @@ bool PvpRuleSetNormal::canAttack(TangibleObject const &actor, TangibleObject con
else
{
return true;
}
}
}
if (!actorIsPlayer)
if (!actorIsPlayer)
{
// NPC attacker rules
if (!actorFaction)
{
// A neutral NPC can attack anything
// A neutral NPC can attack anything
return true;
}
else if ((!targetFaction) && (targetIsPlayer))
@@ -278,7 +276,7 @@ bool PvpRuleSetNormal::canHelp(TangibleObject const &actor, TangibleObject const
bool const actorIsPlayer = PvpInternal::isPlayer(actor);
bool const targetIsPlayer = PvpInternal::isPlayer(target);
Pvp::FactionId targetFaction = PvpInternal::getAlignedFaction(target);
Pvp::FactionId actorFaction = PvpInternal::getAlignedFaction(actor);
Pvp::FactionId actorFaction = PvpInternal::getAlignedFaction(actor);
Pvp::PvpType actorPvpType = actor.getPvpType();
Pvp::PvpType targetPvpType = target.getPvpType();
@@ -299,7 +297,7 @@ bool PvpRuleSetNormal::canHelp(TangibleObject const &actor, TangibleObject const
// npcs are allowed to help anyone
if (!actorIsPlayer)
return true;
// help target not player and not pet
if (!targetIsPlayer && !PvpInternal::isPet(target))
return false;
@@ -354,8 +352,8 @@ void PvpRuleSetNormal::getAttackRepercussions(TangibleObject const &actor, Tangi
// attacks between dueling characters only refresh duel flags
// attacks between dueling characters have no repercussions
if ( PvpInternal::hasDuelEnemyFlag(target, actor.getNetworkId())
&& PvpInternal::hasDuelEnemyFlag(actor, target.getNetworkId()))
if (PvpInternal::hasDuelEnemyFlag(target, actor.getNetworkId())
&& PvpInternal::hasDuelEnemyFlag(actor, target.getNetworkId()))
return;
bool const actorIsPlayer = PvpInternal::isPlayer(actor);
@@ -378,17 +376,17 @@ void PvpRuleSetNormal::getAttackRepercussions(TangibleObject const &actor, Tangi
// attacks between guild war members have no repercussions, but only if
// both the guild war members are not in the guild war "cool down" period
if ( GuildInterface::hasDeclaredWarAgainst(creatureActor->getGuildId(), creatureTarget->getGuildId())
&& GuildInterface::hasDeclaredWarAgainst(creatureTarget->getGuildId(), creatureActor->getGuildId())
if (GuildInterface::hasDeclaredWarAgainst(creatureActor->getGuildId(), creatureTarget->getGuildId())
&& GuildInterface::hasDeclaredWarAgainst(creatureTarget->getGuildId(), creatureActor->getGuildId())
&& creatureActor->getGuildWarEnabled()
&& creatureTarget->getGuildWarEnabled()
&& !PvpInternal::hasAnyGuildWarCoolDownPeriodEnemyFlag(*creatureActor)
&& !PvpInternal::hasAnyGuildWarCoolDownPeriodEnemyFlag(*creatureTarget))
&& !PvpInternal::hasAnyGuildWarCoolDownPeriodEnemyFlag(*creatureActor)
&& !PvpInternal::hasAnyGuildWarCoolDownPeriodEnemyFlag(*creatureTarget))
return;
}
Pvp::FactionId targetFaction = PvpInternal::getAlignedFaction(target);
Pvp::FactionId actorFaction = PvpInternal::getAlignedFaction(actor);
Pvp::FactionId actorFaction = PvpInternal::getAlignedFaction(actor);
Pvp::PvpType actorPvpType = actor.getPvpType();
Pvp::PvpType targetPvpType = target.getPvpType();
@@ -417,13 +415,13 @@ void PvpRuleSetNormal::getAttackRepercussions(TangibleObject const &actor, Tangi
targetFaction = 0;
}
if( PvpFactions::isBubbleFaction(actorFaction) || PvpFactions::isBubbleFaction(targetFaction))
if (PvpFactions::isBubbleFaction(actorFaction) || PvpFactions::isBubbleFaction(targetFaction))
{
if(actorIsPlayer)
if (actorIsPlayer)
actorRepercussions.push_back(PvpEnemy(target.getNetworkId(), PvpFactions::getBubbleCombatFactionId(), -1));
else if (targetIsPlayer)
targetRepercussions.push_back(PvpEnemy(actor.getNetworkId(), PvpFactions::getBubbleCombatFactionId(), -1));
return;
}
@@ -462,7 +460,7 @@ void PvpRuleSetNormal::getAttackRepercussions(TangibleObject const &actor, Tangi
void PvpRuleSetNormal::getHelpRepercussions(TangibleObject const &actor, TangibleObject const &target, std::vector<PvpEnemy> &actorRepercussions, std::vector<PvpEnemy> &targetRepercussions) const
{
actorRepercussions.clear();
actorRepercussions.clear();
targetRepercussions.clear();
}
@@ -483,7 +481,7 @@ bool PvpRuleSetNormal::isEnemy(TangibleObject const &actor, TangibleObject const
return true;
Pvp::FactionId targetFaction = PvpInternal::getAlignedFaction(target);
Pvp::FactionId actorFaction = PvpInternal::getAlignedFaction(actor);
Pvp::FactionId actorFaction = PvpInternal::getAlignedFaction(actor);
Pvp::PvpType actorPvpType = actor.getPvpType();
Pvp::PvpType targetPvpType = target.getPvpType();
@@ -547,7 +545,7 @@ bool PvpRuleSetNormal::isEnemy(TangibleObject const &actor, TangibleObject const
// do duel and guild war checks before attackable player faction checks
// this is so covert opposite faction players who duel or guild war can still death blow correctly
if ( PvpInternal::hasDuelEnemyFlag(target, actor.getNetworkId())
if (PvpInternal::hasDuelEnemyFlag(target, actor.getNetworkId())
&& PvpInternal::hasDuelEnemyFlag(actor, target.getNetworkId()))
return true;
@@ -557,7 +555,7 @@ bool PvpRuleSetNormal::isEnemy(TangibleObject const &actor, TangibleObject const
// guild members are enemies of other guilds which have declared war on their guild,
// but only if neither guild members is in a guild war "cool down" period
// being an enemy sets the client's "default action" to death blow for incapacitated players in a guild war
if ( GuildInterface::hasDeclaredWarAgainst(creatureTarget->getGuildId(), creatureActor->getGuildId())
if (GuildInterface::hasDeclaredWarAgainst(creatureTarget->getGuildId(), creatureActor->getGuildId())
&& GuildInterface::hasDeclaredWarAgainst(creatureActor->getGuildId(), creatureTarget->getGuildId())
&& creatureActor->getGuildWarEnabled()
&& creatureTarget->getGuildWarEnabled()
@@ -566,7 +564,7 @@ bool PvpRuleSetNormal::isEnemy(TangibleObject const &actor, TangibleObject const
return true;
}
if ( actorFaction )
if (actorFaction)
{
//i'm not neutral
if (targetFaction)
@@ -608,8 +606,8 @@ bool PvpRuleSetNormal::isDuelingAllowed(TangibleObject const &actor, TangibleObj
CreatureObject const * actorCreature = actor.asCreatureObject();
CreatureObject const * targetCreature = target.asCreatureObject();
return ( actorCreature && actorIsPlayer && actorCreature->isInWorld() && !actorCreature->isInTutorial()
&& targetCreature && targetIsPlayer && targetCreature->isInWorld() && !targetCreature->isInTutorial() );
return (actorCreature && actorIsPlayer && actorCreature->isInWorld() && !actorCreature->isInTutorial()
&& targetCreature && targetIsPlayer && targetCreature->isInWorld() && !targetCreature->isInTutorial());
}
// ======================================================================
// ======================================================================
@@ -30,7 +30,7 @@ namespace DataLintNamespace
typedef stdvector<std::string>::fwd StringList;
typedef std::pair<std::string, std::pair<DataLint::AssetType, StringList> > WarningPair;
typedef stdvector<WarningPair>::fwd WarningList;
typedef bool (*AssetFunction)(char const *);
typedef bool(*AssetFunction)(char const *);
bool ms_installed = false;
DataLint::AssetType m_currentAssetType = DataLint::AT_invalid;
@@ -80,7 +80,7 @@ void DataLint::install()
m_warningList = new WarningList();
m_warningList->reserve(4096);
m_assetStack = new StringList ();
m_assetStack = new StringList();
m_assetList = new StringPairList();
m_assetList->reserve(4096);
@@ -116,10 +116,10 @@ void DataLint::report()
// Server/client
FILE *assetErrorFileAll = fopen(dataLintErrorsAll.c_str(), "wt");
FILE *assetErrorFileAllFatal = fopen(dataLintErrorsAllFatal.c_str(), "wt");
FILE *assetErrorFileAllWarning = fopen(dataLintErrorsAllWarning.c_str(), "wt");
FILE *assetErrorFileObjectTemplate = fopen(dataLintErrorsAllObjectTemplate.c_str(), "wt");
FILE *assetErrorFileAll = fopen(dataLintErrorsAll.c_str(), "wt");
FILE *assetErrorFileAllFatal = fopen(dataLintErrorsAllFatal.c_str(), "wt");
FILE *assetErrorFileAllWarning = fopen(dataLintErrorsAllWarning.c_str(), "wt");
FILE *assetErrorFileObjectTemplate = fopen(dataLintErrorsAllObjectTemplate.c_str(), "wt");
// Client only
@@ -137,17 +137,17 @@ void DataLint::report()
if (m_mode == M_client)
{
assetErrorFileAppearance = fopen("DataLint_Errors_Appearance.txt", "wt");
assetErrorFileAppearance = fopen("DataLint_Errors_Appearance.txt", "wt");
assetErrorFileArrangementDescriptor = fopen("DataLint_Errors_ArrangementDescriptor.txt", "wt");
assetErrorFileLocalizedStringTable = fopen("DataLint_Errors_LocalizedStringTable.txt", "wt");
assetErrorFilePortalProperty = fopen("DataLint_Errors_PortalProperty.txt", "wt");
assetErrorFileShaderTemplate = fopen("DataLint_Errors_ShaderTemplate.txt", "wt");
assetErrorFileSkyBox = fopen("DataLint_Errors_SkyBox.txt", "wt");
assetErrorFileSlotDescriptor = fopen("DataLint_Errors_SlotDescriptor.txt", "wt");
assetErrorFileSoundTemplate = fopen("DataLint_Errors_SoundTemplate.txt", "wt");
assetErrorFileTerrain = fopen("DataLint_Errors_Terrain.txt", "wt");
assetErrorFileTexture = fopen("DataLint_Errors_Texture.txt", "wt");
assetErrorFileTextureRenderer = fopen("DataLint_Errors_TextureRenderer.txt", "wt");
assetErrorFileLocalizedStringTable = fopen("DataLint_Errors_LocalizedStringTable.txt", "wt");
assetErrorFilePortalProperty = fopen("DataLint_Errors_PortalProperty.txt", "wt");
assetErrorFileShaderTemplate = fopen("DataLint_Errors_ShaderTemplate.txt", "wt");
assetErrorFileSkyBox = fopen("DataLint_Errors_SkyBox.txt", "wt");
assetErrorFileSlotDescriptor = fopen("DataLint_Errors_SlotDescriptor.txt", "wt");
assetErrorFileSoundTemplate = fopen("DataLint_Errors_SoundTemplate.txt", "wt");
assetErrorFileTerrain = fopen("DataLint_Errors_Terrain.txt", "wt");
assetErrorFileTexture = fopen("DataLint_Errors_Texture.txt", "wt");
assetErrorFileTextureRenderer = fopen("DataLint_Errors_TextureRenderer.txt", "wt");
}
// Might want to think of a better way to keep track of the number of errors for each specific asset type.
@@ -205,104 +205,104 @@ void DataLint::report()
switch (warningListIter->second.first)
{
case AT_appearance:
{
if (m_mode == M_client)
{
writeError(assetErrorFileAppearance, *warningListIter, totalErrorCountAppearance);
}
}
break;
case AT_arrangementDescriptor:
{
if (m_mode == M_client)
{
writeError(assetErrorFileArrangementDescriptor, *warningListIter, totalErrorCountArrangementDescriptor);
}
}
break;
case AT_localizedStringTable:
{
if (m_mode == M_client)
{
writeError(assetErrorFileLocalizedStringTable, *warningListIter, totalErrorCountLocalizedStringTable);
}
}
break;
case AT_objectTemplate:
{
writeError(assetErrorFileObjectTemplate, *warningListIter, totalErrorCountObjectTemplate);
}
break;
case AT_portalProperty:
{
if (m_mode == M_client)
{
writeError(assetErrorFilePortalProperty, *warningListIter, totalErrorCountPortalProperty);
}
}
break;
case AT_shaderTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileShaderTemplate, *warningListIter, totalErrorCountShaderTemplate);
}
}
break;
case AT_skyBox:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSkyBox, *warningListIter, totalErrorCountSkyBox);
}
}
break;
case AT_slotDescriptor:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSlotDescriptor, *warningListIter, totalErrorCountSlotDescriptor);
}
}
break;
case AT_soundTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSoundTemplate, *warningListIter, totalErrorCountSoundTemplate);
}
}
break;
case AT_terrain:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTerrain, *warningListIter, totalErrorCountTerrain);
}
}
break;
case AT_texture:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTexture, *warningListIter, totalErrorCountTexture);
}
}
break;
case AT_textureRendererTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTextureRenderer, *warningListIter, totalErrorCountTextureRenderer);
}
}
break;
default:
{
DEBUG_REPORT_LOG_PRINT(true, ("DataLint::remove() - Unsupported asset type: %s", warningListIter->first.c_str()));
}
break;
case AT_appearance:
{
if (m_mode == M_client)
{
writeError(assetErrorFileAppearance, *warningListIter, totalErrorCountAppearance);
}
}
break;
case AT_arrangementDescriptor:
{
if (m_mode == M_client)
{
writeError(assetErrorFileArrangementDescriptor, *warningListIter, totalErrorCountArrangementDescriptor);
}
}
break;
case AT_localizedStringTable:
{
if (m_mode == M_client)
{
writeError(assetErrorFileLocalizedStringTable, *warningListIter, totalErrorCountLocalizedStringTable);
}
}
break;
case AT_objectTemplate:
{
writeError(assetErrorFileObjectTemplate, *warningListIter, totalErrorCountObjectTemplate);
}
break;
case AT_portalProperty:
{
if (m_mode == M_client)
{
writeError(assetErrorFilePortalProperty, *warningListIter, totalErrorCountPortalProperty);
}
}
break;
case AT_shaderTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileShaderTemplate, *warningListIter, totalErrorCountShaderTemplate);
}
}
break;
case AT_skyBox:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSkyBox, *warningListIter, totalErrorCountSkyBox);
}
}
break;
case AT_slotDescriptor:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSlotDescriptor, *warningListIter, totalErrorCountSlotDescriptor);
}
}
break;
case AT_soundTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSoundTemplate, *warningListIter, totalErrorCountSoundTemplate);
}
}
break;
case AT_terrain:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTerrain, *warningListIter, totalErrorCountTerrain);
}
}
break;
case AT_texture:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTexture, *warningListIter, totalErrorCountTexture);
}
}
break;
case AT_textureRendererTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTextureRenderer, *warningListIter, totalErrorCountTextureRenderer);
}
}
break;
default:
{
DEBUG_REPORT_LOG_PRINT(true, ("DataLint::remove() - Unsupported asset type: %s", warningListIter->first.c_str()));
}
break;
}
// Write the error to the master error file
@@ -483,13 +483,13 @@ std::string DataLintNamespace::formatErrorMessage(WarningPair &warningPair, int
}
}
sprintf(formatedError, "%3d Error: %s\n", currentErrorCount, assetError);
snprintf(formatedError, 4096, "%3d Error: %s\n", currentErrorCount, assetError);
result += formatedError;
}
if (lineOfCode)
{
sprintf(formatedError, " Line of Code: %s\n", lineOfCode);
snprintf(formatedError, 4096, " Line of Code: %s\n", lineOfCode);
result += formatedError;
}
@@ -499,10 +499,10 @@ std::string DataLintNamespace::formatErrorMessage(WarningPair &warningPair, int
{
std::string stackString(*stringListIter);
sprintf(text, " Loaded From: %s\n", stackString.c_str());
snprintf(text, 4096, " Loaded From: %s\n", stackString.c_str());
fixUpSlashes(text);
sprintf(formatedError, "%s", text);
snprintf(formatedError, 4096, "%s", text);
result += formatedError;
}
@@ -731,17 +731,17 @@ bool DataLintNamespace::isAnUnSupportedAsset(char const *text)
bool const textureRendererTemplateAsset = isATextureRendererTemplateAsset(text);
bool const result = !(appearanceAsset ||
arrangementDescriptorAsset ||
localizedStringAsset ||
objectTemplateAsset ||
portalPropertyAsset ||
shaderTemplateAsset ||
skyBoxAsset ||
slotDescriptorAsset ||
soundAsset ||
terrainAsset ||
textureAsset ||
textureRendererTemplateAsset);
arrangementDescriptorAsset ||
localizedStringAsset ||
objectTemplateAsset ||
portalPropertyAsset ||
shaderTemplateAsset ||
skyBoxAsset ||
slotDescriptorAsset ||
soundAsset ||
terrainAsset ||
textureAsset ||
textureRendererTemplateAsset);
return result;
}
@@ -777,75 +777,75 @@ DataLint::StringPairList DataLint::getList(AssetType const assetType)
{
switch (assetType)
{
case AT_appearance:
{
return DataLintNamespace::getList(8192, isAnAppearanceAsset);
}
break;
case AT_arrangementDescriptor:
{
return DataLintNamespace::getList(1024, isAnArrangementDescriptorAsset);
}
break;
case AT_localizedStringTable:
{
return DataLintNamespace::getList(1024, isALocalizedStringAsset);
}
break;
case AT_objectTemplate:
{
return DataLintNamespace::getList(8192, isAnObjectTemplateAsset);
}
break;
case AT_portalProperty:
{
return DataLintNamespace::getList(512, isAPortalProprtyAsset);
}
break;
case AT_shaderTemplate:
{
return DataLintNamespace::getList(4096, isAShaderTemplateAsset);
}
break;
case AT_skyBox:
{
return DataLintNamespace::getList(256, isASkyBoxAsset);
}
break;
case AT_slotDescriptor:
{
return DataLintNamespace::getList(1024, isASlotDescriptorAsset);
}
break;
case AT_soundTemplate:
{
return DataLintNamespace::getList(4096, isASoundAsset);
}
break;
case AT_terrain:
{
return DataLintNamespace::getList(32, isATerrainAsset);
}
break;
case AT_texture:
{
return DataLintNamespace::getList(8192, isATextureAsset);
}
break;
case AT_textureRendererTemplate:
{
return DataLintNamespace::getList(512, isATextureRendererTemplateAsset);
}
break;
case AT_unSupported:
{
return DataLintNamespace::getList(4096, isAnUnSupportedAsset);
}
break;
default:
{
DEBUG_FATAL(true, ("DataLint::getList() - Unknown list type."));
}
case AT_appearance:
{
return DataLintNamespace::getList(8192, isAnAppearanceAsset);
}
break;
case AT_arrangementDescriptor:
{
return DataLintNamespace::getList(1024, isAnArrangementDescriptorAsset);
}
break;
case AT_localizedStringTable:
{
return DataLintNamespace::getList(1024, isALocalizedStringAsset);
}
break;
case AT_objectTemplate:
{
return DataLintNamespace::getList(8192, isAnObjectTemplateAsset);
}
break;
case AT_portalProperty:
{
return DataLintNamespace::getList(512, isAPortalProprtyAsset);
}
break;
case AT_shaderTemplate:
{
return DataLintNamespace::getList(4096, isAShaderTemplateAsset);
}
break;
case AT_skyBox:
{
return DataLintNamespace::getList(256, isASkyBoxAsset);
}
break;
case AT_slotDescriptor:
{
return DataLintNamespace::getList(1024, isASlotDescriptorAsset);
}
break;
case AT_soundTemplate:
{
return DataLintNamespace::getList(4096, isASoundAsset);
}
break;
case AT_terrain:
{
return DataLintNamespace::getList(32, isATerrainAsset);
}
break;
case AT_texture:
{
return DataLintNamespace::getList(8192, isATextureAsset);
}
break;
case AT_textureRendererTemplate:
{
return DataLintNamespace::getList(512, isATextureRendererTemplateAsset);
}
break;
case AT_unSupported:
{
return DataLintNamespace::getList(4096, isAnUnSupportedAsset);
}
break;
default:
{
DEBUG_FATAL(true, ("DataLint::getList() - Unknown list type."));
}
}
return StringPairList();
@@ -904,4 +904,4 @@ void DataLint::setServerMode()
m_mode = M_server;
}
// ============================================================================
// ============================================================================
@@ -29,9 +29,9 @@ uint32 RemoteDebugServer::ms_inputTarget;
// ======================================================================
RemoteDebug::Channel::Channel(const std::string& name, Channel *parent)
: m_name(nullptr),
m_parent(parent)
RemoteDebug::Channel::Channel(const std::string& name, Channel *parent)
: m_name(nullptr),
m_parent(parent)
{
m_name = new std::string(name);
m_children = new NodeList;
@@ -42,7 +42,7 @@ RemoteDebug::Channel::Channel(const std::string& name, Channel *parent)
RemoteDebug::Channel::~Channel()
{
m_parent = nullptr;
if(m_name)
if (m_name)
{
delete m_name;
m_name = nullptr;
@@ -71,33 +71,32 @@ const std::string& RemoteDebug::Channel::name()
// ======================================================================
RemoteDebug::Variable::Variable(const std::string& name, void *memLoc, VARIABLE_TYPES type)
: m_memLoc(memLoc),
m_name(nullptr),
m_type(type)
: m_memLoc(memLoc),
m_name(nullptr),
m_type(type)
{
m_name = new std::string(name);
int32 i = 0;
float f = 0.0;
char s = '\0';
int32 b = 0;
switch(m_type)
switch (m_type)
{
case INT:
m_value.intValue = i;
break;
case INT:
m_value.intValue = i;
break;
case FLOAT:
m_value.floatValue = f;
break;
case FLOAT:
m_value.floatValue = f;
break;
case CSTRING:
m_value.stringValue = &s;
break;
case CSTRING:
m_value.stringValue = nullptr;
break;
case BOOL:
m_value.boolValue = b;
break;
case BOOL:
m_value.boolValue = b;
break;
}
}
@@ -105,10 +104,10 @@ RemoteDebug::Variable::Variable(const std::string& name, void *memLoc, VARIABLE_
RemoteDebug::Variable::~Variable()
{
if(m_type == CSTRING)
if (m_type == CSTRING)
delete m_value.stringValue;
if(m_name)
if (m_name)
{
delete m_name;
m_name = nullptr;
@@ -119,23 +118,23 @@ RemoteDebug::Variable::~Variable()
void RemoteDebug::Variable::setValue(VARIABLEVALUE v)
{
switch(m_type)
switch (m_type)
{
case INT:
m_value.intValue = v.intValue;
break;
case INT:
m_value.intValue = v.intValue;
break;
case FLOAT:
m_value.floatValue = v.floatValue;
break;
case FLOAT:
m_value.floatValue = v.floatValue;
break;
case CSTRING:
m_value.stringValue = v.stringValue;
break;
case CSTRING:
m_value.stringValue = v.stringValue;
break;
case BOOL:
m_value.boolValue = v.boolValue;
break;
case BOOL:
m_value.boolValue = v.boolValue;
break;
}
}
@@ -143,27 +142,27 @@ void RemoteDebug::Variable::setValue(VARIABLEVALUE v)
void RemoteDebug::Variable::setValue(void *memLoc)
{
if(memLoc)
if (memLoc)
{
switch(m_type)
switch (m_type)
{
case INT:
memcpy(&m_value.intValue, memLoc, sizeof(int32));
break;
case INT:
memcpy(&m_value.intValue, memLoc, sizeof(int32));
break;
case FLOAT:
memcpy(&m_value.floatValue, memLoc, sizeof(float));
break;
case FLOAT:
memcpy(&m_value.floatValue, memLoc, sizeof(float));
break;
case CSTRING:
delete[] m_value.stringValue;
m_value.stringValue = new char[strlen(static_cast<char *>(memLoc))];
strcpy(m_value.stringValue, const_cast<const char *>(static_cast<char *>(memLoc)));
break;
case CSTRING:
delete[] m_value.stringValue;
m_value.stringValue = new char[strlen(static_cast<char *>(memLoc))];
strcpy(m_value.stringValue, const_cast<const char *>(static_cast<char *>(memLoc)));
break;
case BOOL:
memcpy(&m_value.boolValue, memLoc, sizeof(int32));
break;
case BOOL:
memcpy(&m_value.boolValue, memLoc, sizeof(int32));
break;
}
}
}
@@ -193,8 +192,8 @@ void RemoteDebug::Variable::setType(VARIABLE_TYPES type)
void RemoteDebug::Variable::pushValue()
{
if (m_memLoc)
switch (m_type)
{
switch (m_type)
{
case BOOL:
case INT:
memcpy(m_memLoc, &m_value, sizeof(int32));
@@ -207,7 +206,7 @@ void RemoteDebug::Variable::pushValue()
case FLOAT:
memcpy(m_memLoc, &m_value, sizeof(float));
break;
}
}
}
// ----------------------------------------------------------------------
@@ -219,24 +218,24 @@ RemoteDebug::VARIABLE_TYPES RemoteDebug::Variable::type()
// ======================================================================
void RemoteDebugClient::install(RemoveFunction rf, OpenFunction of,
CloseFunction cf, SendFunction sf,
IsReadyFunction irf, NewStreamFunction ncf,
StreamMessageFunction cmf, NewVariableFunction nvf,
VariableValueFunction vvf, VariableTypeFunction vtf,
BeginFrameFunction bff, EndFrameFunction eff,
NewStaticViewFunction nsvf, LineFunction lf)
void RemoteDebugClient::install(RemoveFunction rf, OpenFunction of,
CloseFunction cf, SendFunction sf,
IsReadyFunction irf, NewStreamFunction ncf,
StreamMessageFunction cmf, NewVariableFunction nvf,
VariableValueFunction vvf, VariableTypeFunction vtf,
BeginFrameFunction bff, EndFrameFunction eff,
NewStaticViewFunction nsvf, LineFunction lf)
{
RemoteDebug::install(rf, of, cf, sf, irf);
ms_newStreamFunction = ncf;
ms_streamMessageFunction = cmf;
ms_newVariableFunction = nvf;
ms_variableValueFunction = vvf;
ms_variableTypeFunction = vtf;
ms_beginFrameFunction = bff;
ms_endFrameFunction = eff;
ms_newStaticViewFunction = nsvf;
ms_lineFunction = lf;
ms_newStreamFunction = ncf;
ms_streamMessageFunction = cmf;
ms_newVariableFunction = nvf;
ms_variableValueFunction = vvf;
ms_variableTypeFunction = vtf;
ms_beginFrameFunction = bff;
ms_endFrameFunction = eff;
ms_newStaticViewFunction = nsvf;
ms_lineFunction = lf;
}
// ----------------------------------------------------------------------
@@ -256,7 +255,7 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
//convert to a const char[] for conveinence
const char * const charMessage = reinterpret_cast<const char * const>(message);
//these values are known based on the packet protocol (see RemoteDebug.h for more info
const int sizeOfMessageType = 1;
const int sizeOfMessageType = 1;
const int sizeOfChannelNumber = 4;
const int sizeOfSizeofPayload = 4;
//this value is filled in from the packet
@@ -264,7 +263,7 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
//this value if filled in from the packet
uint32 sizeOfPayload = 0;
//get the message type
//get the message type
RemoteDebug::MESSAGE_TYPE type = static_cast<RemoteDebug::MESSAGE_TYPE>(charMessage[0]);
//grab the channelNumber
@@ -272,12 +271,12 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
//build the payload if needed
if (type == RemoteDebug::STREAM ||
type == RemoteDebug::STATIC_LINE ||
type == RemoteDebug::NEW_STATIC ||
type == RemoteDebug::NEW_STREAM ||
type == RemoteDebug::VARIABLE_TYPE ||
type == RemoteDebug::VARIABLE_VALUE ||
type == RemoteDebug::NEW_VARIABLE)
type == RemoteDebug::STATIC_LINE ||
type == RemoteDebug::NEW_STATIC ||
type == RemoteDebug::NEW_STREAM ||
type == RemoteDebug::VARIABLE_TYPE ||
type == RemoteDebug::VARIABLE_VALUE ||
type == RemoteDebug::NEW_VARIABLE)
{
memcpy(&sizeOfPayload, charMessage + sizeOfMessageType + sizeOfChannelNumber, sizeOfSizeofPayload);
memcpy(ms_buffer, charMessage + sizeOfMessageType + sizeOfChannelNumber + sizeOfSizeofPayload, sizeOfPayload);
@@ -287,81 +286,81 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
int32 t;
VARIABLE_TYPES varType;
switch(type)
switch (type)
{
case RemoteDebug::STREAM:
//see if we're redefining an already existing stream
if(ms_streamMessageFunction)
ms_streamMessageFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::STREAM:
//see if we're redefining an already existing stream
if (ms_streamMessageFunction)
ms_streamMessageFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_STREAM:
if (channelNumber < ms_nextStream)
return;
registerStream(ms_buffer);
if (ms_newStreamFunction)
ms_newStreamFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_STREAM:
if (channelNumber < ms_nextStream)
return;
registerStream(ms_buffer);
if (ms_newStreamFunction)
ms_newStreamFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_VARIABLE:
if (channelNumber < ms_nextVariable)
return;
//do not send value back to server (hence the "false")
registerVariable(ms_buffer, nullptr, BOOL, false);
if (ms_newVariableFunction)
ms_newVariableFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_VARIABLE:
if (channelNumber < ms_nextVariable)
return;
//do not send value back to server (hence the "false")
registerVariable(ms_buffer, nullptr, BOOL, false);
if (ms_newVariableFunction)
ms_newVariableFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::VARIABLE_TYPE:
t = atoi(ms_buffer);
varType = static_cast<VARIABLE_TYPES>(t);
(*ms_variableValues)[channelNumber]->setType(varType);
if(ms_variableTypeFunction)
ms_variableTypeFunction(channelNumber, varType);
break;
case RemoteDebug::VARIABLE_VALUE:
(*ms_variableValues)[channelNumber]->setValue(ms_buffer);
if(ms_variableValueFunction)
ms_variableValueFunction(channelNumber, ms_buffer);
break;
case RemoteDebug::VARIABLE_TYPE:
t = atoi(ms_buffer);
varType = static_cast<VARIABLE_TYPES>(t);
(*ms_variableValues)[channelNumber]->setType(varType);
if (ms_variableTypeFunction)
ms_variableTypeFunction(channelNumber, varType);
break;
case RemoteDebug::NEW_STATIC:
if (channelNumber < ms_nextStaticView)
return;
registerStaticView(ms_buffer);
if (ms_newStaticViewFunction)
ms_newStaticViewFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::VARIABLE_VALUE:
(*ms_variableValues)[channelNumber]->setValue(ms_buffer);
if (ms_variableValueFunction)
ms_variableValueFunction(channelNumber, ms_buffer);
break;
case RemoteDebug::STATIC_LINE:
if (ms_lineFunction)
ms_lineFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_STATIC:
if (channelNumber < ms_nextStaticView)
return;
registerStaticView(ms_buffer);
if (ms_newStaticViewFunction)
ms_newStaticViewFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::STATIC_BEGIN_FRAME:
if (ms_beginFrameFunction)
ms_beginFrameFunction(channelNumber);
break;
case RemoteDebug::STATIC_LINE:
if (ms_lineFunction)
ms_lineFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::STATIC_END_FRAME:
if (ms_endFrameFunction)
ms_endFrameFunction(channelNumber);
break;
case RemoteDebug::STATIC_BEGIN_FRAME:
if (ms_beginFrameFunction)
ms_beginFrameFunction(channelNumber);
break;
case RemoteDebug::STREAM_SQUELCH:
case RemoteDebug::STREAM_UNSQUELCH:
case RemoteDebug::STATIC_SQUELCH:
case RemoteDebug::STATIC_UNSQUELCH:
case RemoteDebug::STATIC_INPUT_TARGET:
case RemoteDebug::STATIC_UP:
case RemoteDebug::STATIC_DOWN:
case RemoteDebug::STATIC_LEFT:
case RemoteDebug::STATIC_RIGHT:
case RemoteDebug::STATIC_ENTER:
case RemoteDebug::REQUEST_ALL_CHANNELS:
default:
break;
case RemoteDebug::STATIC_END_FRAME:
if (ms_endFrameFunction)
ms_endFrameFunction(channelNumber);
break;
case RemoteDebug::STREAM_SQUELCH:
case RemoteDebug::STREAM_UNSQUELCH:
case RemoteDebug::STATIC_SQUELCH:
case RemoteDebug::STATIC_UNSQUELCH:
case RemoteDebug::STATIC_INPUT_TARGET:
case RemoteDebug::STATIC_UP:
case RemoteDebug::STATIC_DOWN:
case RemoteDebug::STATIC_LEFT:
case RemoteDebug::STATIC_RIGHT:
case RemoteDebug::STATIC_ENTER:
case RemoteDebug::REQUEST_ALL_CHANNELS:
default:
break;
}
}
@@ -373,9 +372,9 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
void RemoteDebugClient::close()
{
DEBUG_FATAL(!ms_installed, ("remoteDebug not installed"));
//don't need to do anything if we're already closed
if(!ms_opened)
if (!ms_opened)
return;
if (ms_closeFunction)
@@ -402,9 +401,9 @@ void RemoteDebugClient::close()
ms_squelchedStream->clear();
ms_squelchedStatic->clear();
ms_nextStream = 0;
ms_nextStream = 0;
ms_nextStaticView = 0;
ms_nextVariable = 0;
ms_nextVariable = 0;
}
// ----------------------------------------------------------------------
@@ -419,9 +418,9 @@ void RemoteDebugClient::isReady()
// ======================================================================
void RemoteDebugServer::install(RemoveFunction rmf, OpenFunction of ,
CloseFunction cf , SendFunction sf,
IsReadyFunction irf)
void RemoteDebugServer::install(RemoveFunction rmf, OpenFunction of,
CloseFunction cf, SendFunction sf,
IsReadyFunction irf)
{
RemoteDebug::install(rmf, of, cf, sf, irf);
ms_inputTarget = 0;
@@ -452,7 +451,7 @@ void RemoteDebugServer::receive(const unsigned char * const message, const uint3
//convert to a const char[] for conveinence
const char * const charMessage = reinterpret_cast<const char * const>(message);
//these values are known based on the packet protocol (see RemoteDebug.h for more info
const int sizeOfMessageType = 1;
const int sizeOfMessageType = 1;
const int sizeOfChannelNumber = 4;
const int sizeOfSizeofPayload = 4;
//this value is filled in from the packet
@@ -460,7 +459,7 @@ void RemoteDebugServer::receive(const unsigned char * const message, const uint3
//this value if filled in from the packet
uint32 sizeOfPayload = 0;
//get the message type
//get the message type
RemoteDebug::MESSAGE_TYPE type = static_cast<RemoteDebug::MESSAGE_TYPE>(charMessage[0]);
//grab the channelNumber
@@ -468,92 +467,92 @@ void RemoteDebugServer::receive(const unsigned char * const message, const uint3
//build the payload if needed
if (type == RemoteDebug::STREAM ||
type == RemoteDebug::NEW_STREAM ||
type == RemoteDebug::VARIABLE_TYPE ||
type == RemoteDebug::VARIABLE_VALUE ||
type == RemoteDebug::NEW_VARIABLE)
type == RemoteDebug::NEW_STREAM ||
type == RemoteDebug::VARIABLE_TYPE ||
type == RemoteDebug::VARIABLE_VALUE ||
type == RemoteDebug::NEW_VARIABLE)
{
memcpy(&sizeOfPayload, charMessage + sizeOfMessageType + sizeOfChannelNumber, sizeOfSizeofPayload);
memcpy(ms_buffer, charMessage + sizeOfMessageType + sizeOfChannelNumber + sizeOfSizeofPayload, sizeOfPayload);
}
Variable* v = nullptr;
switch(type)
switch (type)
{
case STREAM:
case NEW_STREAM:
case VARIABLE_TYPE:
case NEW_VARIABLE:
break;
case STREAM:
case NEW_STREAM:
case VARIABLE_TYPE:
case NEW_VARIABLE:
break;
case STREAM_SQUELCH:
(*ms_squelchedStream)[channelNumber] = true;
break;
case STREAM_SQUELCH:
(*ms_squelchedStream)[channelNumber] = true;
break;
case STREAM_UNSQUELCH:
(*ms_squelchedStream)[channelNumber] = false;
break;
case STREAM_UNSQUELCH:
(*ms_squelchedStream)[channelNumber] = false;
break;
case VARIABLE_VALUE:
//set the new value into the variable on the server side
v = (*ms_variableValues)[channelNumber];
if(!v)
{
DEBUG_FATAL(true, ("message on undefined variable"));
return; //lint !e527 unreachable code
}
v->setValue(ms_buffer);
//put that new value back into the game object
v->pushValue();
break;
case VARIABLE_VALUE:
//set the new value into the variable on the server side
v = (*ms_variableValues)[channelNumber];
if (!v)
{
DEBUG_FATAL(true, ("message on undefined variable"));
return; //lint !e527 unreachable code
}
v->setValue(ms_buffer);
//put that new value back into the game object
v->pushValue();
break;
case STATIC_SQUELCH:
(*ms_squelchedStatic)[channelNumber] = true;
break;
case STATIC_SQUELCH:
(*ms_squelchedStatic)[channelNumber] = true;
break;
case STATIC_UNSQUELCH:
(*ms_squelchedStatic)[channelNumber] = false;
break;
case STATIC_UNSQUELCH:
(*ms_squelchedStatic)[channelNumber] = false;
break;
case REQUEST_ALL_CHANNELS:
sendAllChannels();
break;
case REQUEST_ALL_CHANNELS:
sendAllChannels();
break;
case STATIC_INPUT_TARGET:
ms_inputTarget = channelNumber;
break;
case STATIC_INPUT_TARGET:
ms_inputTarget = channelNumber;
break;
case STATIC_UP:
if ((*ms_upFunctionMap)[ms_inputTarget] != nullptr)
(*ms_upFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_UP:
if ((*ms_upFunctionMap)[ms_inputTarget] != nullptr)
(*ms_upFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_DOWN:
if ((*ms_downFunctionMap)[ms_inputTarget] != nullptr)
(*ms_downFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_DOWN:
if ((*ms_downFunctionMap)[ms_inputTarget] != nullptr)
(*ms_downFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_LEFT:
if ((*ms_leftFunctionMap)[ms_inputTarget] != nullptr)
(*ms_leftFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_LEFT:
if ((*ms_leftFunctionMap)[ms_inputTarget] != nullptr)
(*ms_leftFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_RIGHT:
if ((*ms_rightFunctionMap)[ms_inputTarget] != nullptr)
(*ms_rightFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_RIGHT:
if ((*ms_rightFunctionMap)[ms_inputTarget] != nullptr)
(*ms_rightFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_ENTER:
if ((*ms_enterFunctionMap)[ms_inputTarget] != nullptr)
(*ms_enterFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_ENTER:
if ((*ms_enterFunctionMap)[ms_inputTarget] != nullptr)
(*ms_enterFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case NEW_STATIC:
case STATIC_BEGIN_FRAME:
case STATIC_END_FRAME:
case STATIC_LINE:
default:
break;
case NEW_STATIC:
case STATIC_BEGIN_FRAME:
case STATIC_END_FRAME:
case STATIC_LINE:
default:
break;
}
}
@@ -565,7 +564,7 @@ void RemoteDebugServer::receive(const unsigned char * const message, const uint3
void RemoteDebugServer::close()
{
DEBUG_FATAL(!ms_installed, ("remoteDebug not installed"));
if (ms_closeFunction)
ms_closeFunction();
ms_opened = false;
@@ -575,16 +574,16 @@ void RemoteDebugServer::close()
void RemoteDebugServer::sendAllChannels()
{
for(StreamMap::iterator it = ms_streams->begin(); it != ms_streams->end(); ++it)
for (StreamMap::iterator it = ms_streams->begin(); it != ms_streams->end(); ++it)
send(NEW_STREAM, it->second->name().c_str());
for(VariableMap::iterator itr = ms_variables->begin(); itr != ms_variables->end(); ++itr)
for (VariableMap::iterator itr = ms_variables->begin(); itr != ms_variables->end(); ++itr)
{
send(NEW_VARIABLE, itr->second->name().c_str());
send(VARIABLE_TYPE, itr->second->name().c_str());
send(VARIABLE_VALUE, itr->second->name().c_str());
}
for(StaticViewMap::iterator iter = ms_staticViews->begin(); iter != ms_staticViews->end(); ++iter)
for (StaticViewMap::iterator iter = ms_staticViews->begin(); iter != ms_staticViews->end(); ++iter)
send(NEW_STATIC, iter->second->name().c_str());
}
// ======================================================================
// ======================================================================
@@ -111,7 +111,7 @@ namespace AssetCustomizationManagerNamespace
void getIntRangeFromIntRangeId(int intRangeId, IntRange &intRange);
void getRangeTypeInfoFromRangeId(int rangeId, bool &isPalette, int &idForRealType);
VariableUsage const *getVariableUsageFromId(int variableUsageId);
UsageIndexEntry const *lookupVariableUsageIndexEntry(int assetId);
LinkIndexEntry const *lookupAssetLinkIndexEntry(int assetId);
int lookupAssetId(CrcString const &assetName);
@@ -123,19 +123,19 @@ namespace AssetCustomizationManagerNamespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Tag const TAG_ACST = TAG(A,C,S,T);
Tag const TAG_CIDX = TAG(C,I,D,X);
Tag const TAG_DEFV = TAG(D,E,F,V);
Tag const TAG_IRNG = TAG(I,R,N,G);
Tag const TAG_LIDX = TAG(L,I,D,X);
Tag const TAG_LLST = TAG(L,L,S,T);
Tag const TAG_NAME = TAG(N,A,M,E);
Tag const TAG_PNOF = TAG(P,N,O,F);
Tag const TAG_RTYP = TAG(R,T,Y,P);
Tag const TAG_UCMP = TAG(U,C,M,P);
Tag const TAG_UIDX = TAG(U,I,D,X);
Tag const TAG_ULST = TAG(U,L,S,T);
Tag const TAG_VNOF = TAG(V,N,O,F);
Tag const TAG_ACST = TAG(A, C, S, T);
Tag const TAG_CIDX = TAG(C, I, D, X);
Tag const TAG_DEFV = TAG(D, E, F, V);
Tag const TAG_IRNG = TAG(I, R, N, G);
Tag const TAG_LIDX = TAG(L, I, D, X);
Tag const TAG_LLST = TAG(L, L, S, T);
Tag const TAG_NAME = TAG(N, A, M, E);
Tag const TAG_PNOF = TAG(P, N, O, F);
Tag const TAG_RTYP = TAG(R, T, Y, P);
Tag const TAG_UCMP = TAG(U, C, M, P);
Tag const TAG_UIDX = TAG(U, I, D, X);
Tag const TAG_ULST = TAG(U, L, S, T);
Tag const TAG_VNOF = TAG(V, N, O, F);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -191,52 +191,52 @@ void AssetCustomizationManagerNamespace::remove()
DEBUG_FATAL(!s_installed, ("AssetCustomizationManager not installed."));
s_installed = false;
delete [] s_nameDataBlock;
s_nameDataBlock = nullptr;
delete[] s_nameDataBlock;
s_nameDataBlock = nullptr;
s_nameDataBlockSize = 0;
delete [] s_paletteIdNameOffsetMap;
delete[] s_paletteIdNameOffsetMap;
s_paletteIdNameOffsetMap = nullptr;
s_maxValidPaletteId = 0;
s_maxValidPaletteId = 0;
delete [] s_variableIdNameOffsetMap;
delete[] s_variableIdNameOffsetMap;
s_variableIdNameOffsetMap = nullptr;
s_maxValidVariableId = 0;
s_maxValidVariableId = 0;
delete [] s_defaultValueMap;
s_defaultValueMap = nullptr;
delete[] s_defaultValueMap;
s_defaultValueMap = nullptr;
s_maxValidDefaultId = 0;
delete [] s_intRangeMap;
s_intRangeMap = nullptr;
delete[] s_intRangeMap;
s_intRangeMap = nullptr;
s_maxValidIntRangeId = 0;
delete [] s_rangeTypeMap;
s_rangeTypeMap = nullptr;
delete[] s_rangeTypeMap;
s_rangeTypeMap = nullptr;
s_maxValidRangeId = 0;
delete [] s_variableUsageMap;
s_variableUsageMap = nullptr;
delete[] s_variableUsageMap;
s_variableUsageMap = nullptr;
s_maxValidVariableUsageId = 0;
delete [] s_variableUsageList;
s_variableUsageList = 0;
delete[] s_variableUsageList;
s_variableUsageList = 0;
s_variableUsageListEntryCount = 0;
delete [] s_usageIndex;
s_usageIndex = nullptr;
delete[] s_usageIndex;
s_usageIndex = nullptr;
s_usageIndexEntryCount = 0;
delete [] s_linkList;
s_linkList = nullptr;
delete[] s_linkList;
s_linkList = nullptr;
s_linkListEntryCount = 0;
delete [] s_linkIndex;
s_linkIndex = nullptr;
delete[] s_linkIndex;
s_linkIndex = nullptr;
s_linkIndexEntryCount = 0;
delete [] s_crcLookupTable;
s_crcLookupTable = nullptr;
delete[] s_crcLookupTable;
s_crcLookupTable = nullptr;
s_crcLookupEntryCount = 0;
}
@@ -245,21 +245,21 @@ void AssetCustomizationManagerNamespace::remove()
void AssetCustomizationManagerNamespace::load(Iff &iff)
{
iff.enterForm(TAG_ACST);
Tag const version = iff.getCurrentName();
switch (version)
{
case TAG_0000:
load_0000(iff);
break;
default:
{
char buffer[5];
ConvertTagToString(version, buffer);
FATAL(true, ("unsupported AssetCustomizationManager file version [%s].", buffer));
}
}
Tag const version = iff.getCurrentName();
switch (version)
{
case TAG_0000:
load_0000(iff);
break;
default:
{
char buffer[5];
ConvertTagToString(version, buffer);
FATAL(true, ("unsupported AssetCustomizationManager file version [%s].", buffer));
}
}
iff.exitForm(TAG_ACST);
}
@@ -270,113 +270,113 @@ void AssetCustomizationManagerNamespace::load_0000(Iff &iff)
{
iff.enterForm(TAG_0000);
//-- Read name data as one big block.
iff.enterChunk(TAG_NAME);
//-- Read name data as one big block.
iff.enterChunk(TAG_NAME);
s_nameDataBlockSize = iff.getChunkLengthLeft();
s_nameDataBlock = new char[static_cast<size_t>(s_nameDataBlockSize)];
iff.read_char(s_nameDataBlockSize, s_nameDataBlock);
s_nameDataBlockSize = iff.getChunkLengthLeft();
s_nameDataBlock = new char[static_cast<size_t>(s_nameDataBlockSize)];
iff.read_char(s_nameDataBlockSize, s_nameDataBlock);
iff.exitChunk(TAG_NAME);
iff.exitChunk(TAG_NAME);
//-- Read palette id to palette name offset block. Palette IDs start at 1.
iff.enterChunk(TAG_PNOF);
s_maxValidPaletteId = iff.getChunkLengthLeft(sizeof(uint16));
s_paletteIdNameOffsetMap = new uint16[static_cast<size_t>(s_maxValidPaletteId)];
iff.read_uint16(s_maxValidPaletteId, s_paletteIdNameOffsetMap);
//-- Read palette id to palette name offset block. Palette IDs start at 1.
iff.enterChunk(TAG_PNOF);
iff.exitChunk(TAG_PNOF);
s_maxValidPaletteId = iff.getChunkLengthLeft(sizeof(uint16));
s_paletteIdNameOffsetMap = new uint16[static_cast<size_t>(s_maxValidPaletteId)];
iff.read_uint16(s_maxValidPaletteId, s_paletteIdNameOffsetMap);
//-- Read variable id to variable name offset block. Variable IDs start at 1.
iff.enterChunk(TAG_VNOF);
s_maxValidVariableId = iff.getChunkLengthLeft(sizeof(uint16));
s_variableIdNameOffsetMap = new uint16[static_cast<size_t>(s_maxValidVariableId)];
iff.read_uint16(s_maxValidVariableId, s_variableIdNameOffsetMap);
iff.exitChunk(TAG_PNOF);
iff.exitChunk(TAG_VNOF);
//-- Read variable id to variable name offset block. Variable IDs start at 1.
iff.enterChunk(TAG_VNOF);
//-- Read default value id.
iff.enterChunk(TAG_DEFV);
s_maxValidVariableId = iff.getChunkLengthLeft(sizeof(uint16));
s_variableIdNameOffsetMap = new uint16[static_cast<size_t>(s_maxValidVariableId)];
iff.read_uint16(s_maxValidVariableId, s_variableIdNameOffsetMap);
s_maxValidDefaultId = iff.getChunkLengthLeft(sizeof(int32));
s_defaultValueMap = new int32[static_cast<size_t>(s_maxValidDefaultId)];
iff.read_int32(s_maxValidDefaultId, s_defaultValueMap);
iff.exitChunk(TAG_VNOF);
iff.exitChunk(TAG_DEFV);
//-- Read default value id.
iff.enterChunk(TAG_DEFV);
//-- Read the integer range table.
iff.enterChunk(TAG_IRNG);
s_maxValidIntRangeId = iff.getChunkLengthLeft(sizeof(IntRange));
s_intRangeMap = new IntRange[static_cast<size_t>(s_maxValidIntRangeId)];
iff.read_int32(2 * s_maxValidIntRangeId, reinterpret_cast<int32*>(s_intRangeMap)); //lint !e740 // unusual pointer cast. // Yes; its fine and is worth the bug savings over handling directly as array of int32.
s_maxValidDefaultId = iff.getChunkLengthLeft(sizeof(int32));
s_defaultValueMap = new int32[static_cast<size_t>(s_maxValidDefaultId)];
iff.read_int32(s_maxValidDefaultId, s_defaultValueMap);
iff.exitChunk(TAG_IRNG);
iff.exitChunk(TAG_DEFV);
//-- Read the range type table.
iff.enterChunk(TAG_RTYP);
//-- Read the integer range table.
iff.enterChunk(TAG_IRNG);
s_maxValidRangeId = iff.getChunkLengthLeft(sizeof(uint16));
s_rangeTypeMap = new uint16[static_cast<size_t>(s_maxValidRangeId)];
iff.read_uint16(s_maxValidRangeId, s_rangeTypeMap);
s_maxValidIntRangeId = iff.getChunkLengthLeft(sizeof(IntRange));
s_intRangeMap = new IntRange[static_cast<size_t>(s_maxValidIntRangeId)];
iff.read_int32(2 * s_maxValidIntRangeId, reinterpret_cast<int32*>(s_intRangeMap)); //lint !e740 // unusual pointer cast. // Yes; its fine and is worth the bug savings over handling directly as array of int32.
iff.exitChunk(TAG_RTYP);
iff.exitChunk(TAG_IRNG);
//-- Read the variable usage composition table.
iff.enterChunk(TAG_UCMP);
//-- Read the range type table.
iff.enterChunk(TAG_RTYP);
s_maxValidVariableUsageId = iff.getChunkLengthLeft(sizeof(VariableUsage));
s_variableUsageMap = new VariableUsage[static_cast<size_t>(s_maxValidVariableUsageId)];
iff.read_uint16(3 * s_maxValidVariableUsageId, reinterpret_cast<uint16*>(s_variableUsageMap));
s_maxValidRangeId = iff.getChunkLengthLeft(sizeof(uint16));
s_rangeTypeMap = new uint16[static_cast<size_t>(s_maxValidRangeId)];
iff.read_uint16(s_maxValidRangeId, s_rangeTypeMap);
iff.exitChunk(TAG_UCMP);
iff.exitChunk(TAG_RTYP);
//-- Read variable usage list.
iff.enterChunk(TAG_ULST);
s_variableUsageListEntryCount = iff.getChunkLengthLeft(sizeof(uint16));
s_variableUsageList = new uint16[static_cast<size_t>(s_variableUsageListEntryCount)];
iff.read_uint16(s_variableUsageListEntryCount, s_variableUsageList);
//-- Read the variable usage composition table.
iff.enterChunk(TAG_UCMP);
iff.exitChunk(TAG_ULST);
s_maxValidVariableUsageId = iff.getChunkLengthLeft(sizeof(VariableUsage));
s_variableUsageMap = new VariableUsage[static_cast<size_t>(s_maxValidVariableUsageId)];
iff.read_uint16(3 * s_maxValidVariableUsageId, reinterpret_cast<uint16*>(s_variableUsageMap));
//-- Read variable usage index.
iff.enterChunk(TAG_UIDX);
iff.exitChunk(TAG_UCMP);
s_usageIndexEntryCount = iff.getChunkLengthLeft(sizeof(UsageIndexEntry));
s_usageIndex = new UsageIndexEntry[static_cast<size_t>(s_usageIndexEntryCount)];
iff.read_uint8(isizeof(UsageIndexEntry) * s_usageIndexEntryCount, reinterpret_cast<uint8*>(s_usageIndex));
//-- Read variable usage list.
iff.enterChunk(TAG_ULST);
iff.exitChunk(TAG_UIDX);
s_variableUsageListEntryCount = iff.getChunkLengthLeft(sizeof(uint16));
s_variableUsageList = new uint16[static_cast<size_t>(s_variableUsageListEntryCount)];
iff.read_uint16(s_variableUsageListEntryCount, s_variableUsageList);
//-- Read asset linkage list.
iff.enterChunk(TAG_LLST);
s_linkListEntryCount = iff.getChunkLengthLeft(sizeof(uint16));
s_linkList = new uint16[static_cast<size_t>(s_linkListEntryCount)];
iff.read_uint16(s_linkListEntryCount, s_linkList);
iff.exitChunk(TAG_ULST);
iff.exitChunk(TAG_LLST);
//-- Read variable usage index.
iff.enterChunk(TAG_UIDX);
//-- Read asset linkage index.
iff.enterChunk(TAG_LIDX);
s_usageIndexEntryCount = iff.getChunkLengthLeft(sizeof(UsageIndexEntry));
s_usageIndex = new UsageIndexEntry[static_cast<size_t>(s_usageIndexEntryCount)];
iff.read_uint8(isizeof(UsageIndexEntry) * s_usageIndexEntryCount, reinterpret_cast<uint8*>(s_usageIndex));
s_linkIndexEntryCount = iff.getChunkLengthLeft(sizeof(LinkIndexEntry));
s_linkIndex = new LinkIndexEntry[static_cast<size_t>(s_linkIndexEntryCount)];
iff.read_uint8(isizeof(LinkIndexEntry) * s_linkIndexEntryCount, reinterpret_cast<uint8*>(s_linkIndex));
iff.exitChunk(TAG_UIDX);
iff.exitChunk(TAG_LIDX);
//-- Read asset linkage list.
iff.enterChunk(TAG_LLST);
//-- Read crc name -> asset id lookup table.
iff.enterChunk(TAG_CIDX);
s_linkListEntryCount = iff.getChunkLengthLeft(sizeof(uint16));
s_linkList = new uint16[static_cast<size_t>(s_linkListEntryCount)];
iff.read_uint16(s_linkListEntryCount, s_linkList);
s_crcLookupEntryCount = iff.getChunkLengthLeft(sizeof(CrcLookupEntry));
s_crcLookupTable = new CrcLookupEntry[static_cast<size_t>(s_crcLookupEntryCount)];
iff.read_uint8(isizeof(CrcLookupEntry) * s_crcLookupEntryCount, reinterpret_cast<uint8*>(s_crcLookupTable));
iff.exitChunk(TAG_LLST);
iff.exitChunk(TAG_CIDX);
//-- Read asset linkage index.
iff.enterChunk(TAG_LIDX);
s_linkIndexEntryCount = iff.getChunkLengthLeft(sizeof(LinkIndexEntry));
s_linkIndex = new LinkIndexEntry[static_cast<size_t>(s_linkIndexEntryCount)];
iff.read_uint8(isizeof(LinkIndexEntry) * s_linkIndexEntryCount, reinterpret_cast<uint8*>(s_linkIndex));
iff.exitChunk(TAG_LIDX);
//-- Read crc name -> asset id lookup table.
iff.enterChunk(TAG_CIDX);
s_crcLookupEntryCount = iff.getChunkLengthLeft(sizeof(CrcLookupEntry));
s_crcLookupTable = new CrcLookupEntry[static_cast<size_t>(s_crcLookupEntryCount)];
iff.read_uint8(isizeof(CrcLookupEntry) * s_crcLookupEntryCount, reinterpret_cast<uint8*>(s_crcLookupTable));
iff.exitChunk(TAG_CIDX);
iff.exitForm(TAG_0000);
}
@@ -444,7 +444,7 @@ void AssetCustomizationManagerNamespace::getRangeTypeInfoFromRangeId(int rangeId
//-- Get range type from range id. Range ids start at 1 and need to be shifted down one
// index to lookup int range type info.
uint16 const rangeType = s_rangeTypeMap[rangeId - 1];
isPalette = ((rangeType & 0x8000) != 0);
isPalette = ((rangeType & 0x8000) != 0);
idForRealType = (rangeType & 0x7fff);
}
@@ -485,7 +485,7 @@ AssetCustomizationManagerNamespace::LinkIndexEntry const *AssetCustomizationMana
int AssetCustomizationManagerNamespace::lookupAssetId(CrcString const &assetName)
{
uint32 const key = assetName.getCrc();
uint32 const key = assetName.getCrc();
CrcLookupEntry const *entry = static_cast<CrcLookupEntry*>(bsearch(&key, s_crcLookupTable, static_cast<size_t>(s_crcLookupEntryCount), sizeof(CrcLookupEntry), compare_uint32));
return (entry != nullptr) ? entry->assetId : 0;
@@ -579,7 +579,7 @@ void AssetCustomizationManagerNamespace::addVariablesForAssetAndLinks(int assetI
int const defaultValue = getDefaultValueFromDefaultId(variableUsage->defaultId);
//-- Get variable type.
bool isPalette = false;
bool isPalette = false;
int idForRealType = 0;
getRangeTypeInfoFromRangeId(variableUsage->rangeId, isPalette, idForRealType);
@@ -589,7 +589,7 @@ void AssetCustomizationManagerNamespace::addVariablesForAssetAndLinks(int assetI
{
//-- Get palette.
char const *const paletteName = getPaletteNameFromPaletteId(idForRealType);
PaletteArgb const *const palette = PaletteArgbList::fetch(TemporaryCrcString(paletteName, true));
PaletteArgb const *const palette = PaletteArgbList::fetch(TemporaryCrcString(paletteName, true));
if (!palette)
{
DEBUG_WARNING(true, ("failed to load palette [%s], skipping variable [%s]", paletteName, variablePathName));
@@ -605,18 +605,16 @@ void AssetCustomizationManagerNamespace::addVariablesForAssetAndLinks(int assetI
{
IntRange intRange;
getIntRangeFromIntRangeId(idForRealType, intRange);
variable = new BasicRangedIntCustomizationVariable(intRange.minRangeInclusive, defaultValue, intRange.maxRangeExclusive);
}
//-- Add the variable to the CustomizationData.
NOT_NULL(variable);
customizationData.addVariableTakeOwnership(variablePathName2, variable);
++addedVariableCount;
}
}
//-- Recursively call on assets that this asset is dependent upon. These assets
// could be providing additional variables.
@@ -687,4 +685,4 @@ int AssetCustomizationManager::addCustomizationVariablesForAsset(CrcString const
return addedVariableCount;
}
// ======================================================================
// ======================================================================
@@ -99,7 +99,7 @@ void TemplateDefinitionFile::setWriteForCompiler(bool flag)
*/
const std::string & TemplateDefinitionFile::getTemplateNameFilter(void) const
{
static const std::string wildcard = "*";
static const std::string wildcard = "*";
if (!m_templateNameFilter.empty())
return m_templateNameFilter;
@@ -127,7 +127,7 @@ bool TemplateDefinitionFile::isValidTemplateName(const Filename & name) const
return true;
}
int const maxCaptureCount = 10;
int const maxCaptureCount = 10;
int const matchDataElementCount = maxCaptureCount * 3;
int matchData[matchDataElementCount];
@@ -188,11 +188,11 @@ void TemplateDefinitionFile::writeClassHeaderBegin(File &fp) const
baseNamePath = "sharedObject/";
baseName = ROOT_TEMPLATE_NAME;
}
else if(_stricmp(baseName, "tpfTemplate") == 0)
else if (_stricmp(baseName, "tpfTemplate") == 0)
{
baseNamePath = "sharedTemplateDefinition/";
}
fp.print("//========================================================================\n");
fp.print("//\n");
fp.print("// %s.h\n", name);
@@ -366,10 +366,10 @@ void TemplateDefinitionFile::writeClassSourceBegin(File &fp, const TemplateData
fp.print(" * Class constructor.\n");
fp.print(" */\n");
fp.print("%s::%s(const std::string & filename)\n", name, name);
// if (sourceTemplate.hasList())
// if (sourceTemplate.hasList())
sourceTemplate.writeSourceLoadedFlagInit(fp);
fp.print("{\n");
// fp.print("\tsetId(%s);\n", getTemplateId().tagString.c_str());
// fp.print("\tsetId(%s);\n", getTemplateId().tagString.c_str());
fp.print("} // %s::%s\n", name, name);
fp.print("\n");
fp.print("/**\n");
@@ -445,11 +445,11 @@ void TemplateDefinitionFile::writeClassSourceBegin(File &fp, const TemplateData
*/
int TemplateDefinitionFile::parse(File &fp)
{
static const int BUFFER_SIZE = 1024;
int lineLen;
char buffer[BUFFER_SIZE];
char token[BUFFER_SIZE];
TemplateData *currentTemplate = nullptr;
static const int BUFFER_SIZE = 1024;
int lineLen;
char buffer[BUFFER_SIZE];
char token[BUFFER_SIZE];
TemplateData *currentTemplate = nullptr;
cleanup();
@@ -490,8 +490,8 @@ TemplateData *currentTemplate = nullptr;
fp.printError("no compiler path defined");
return -1;
}
// if (m_baseName.size() == 0 && m_templateName != ROOT_TEMPLATE_NAME)
// m_baseName = ROOT_TEMPLATE_NAME;
// if (m_baseName.size() == 0 && m_templateName != ROOT_TEMPLATE_NAME)
// m_baseName = ROOT_TEMPLATE_NAME;
line = getNextWhitespaceToken(line, token);
int version = atoi(token);
if (version < 0 || version > 9999)
@@ -506,7 +506,7 @@ TemplateData *currentTemplate = nullptr;
}
if (version > m_highestVersion)
m_highestVersion = version;
currentTemplate = new TemplateData(version, *this);
m_templateMap[version] = currentTemplate;
}
@@ -530,7 +530,7 @@ TemplateData *currentTemplate = nullptr;
}
line = getNextWhitespaceToken(line, token);
setBaseFilename(token);
// load and parse the base template
Filename baseFileName = fp.getFilename();
baseFileName.setName(token);
@@ -585,8 +585,8 @@ TemplateData *currentTemplate = nullptr;
WARNING(m_filterCompiledRegex == nullptr, ("TemplateDefinitionFile::parse(): pcre_compile() failed, error=[%s], errorOffset=[%d], regex text=[%s].", errorString, errorOffset, m_templateNameFilter.c_str()));
}
else if (strcmp(token, "clientpath") == 0 ||
strcmp(token, "serverpath") == 0 ||
strcmp(token, "sharedpath") == 0)
strcmp(token, "serverpath") == 0 ||
strcmp(token, "sharedpath") == 0)
{
if (m_path.getPath().size() != 0)
{
@@ -595,14 +595,14 @@ TemplateData *currentTemplate = nullptr;
}
if (strcmp(token, "clientpath") == 0)
m_templateLocation = LOC_CLIENT;
else if (strcmp(token, "serverpath") == 0)
else if (strcmp(token, "serverpath") == 0)
m_templateLocation = LOC_SERVER;
else
else
m_templateLocation = LOC_SHARED;
line = getNextWhitespaceToken(line, token);
m_path.setPath(token);
m_path.prependPath(fp.getFilename());
// reset the template name to add the corrent prefix to the template
// reset the template name to add the corrent prefix to the template
// name
setTemplateFilename(m_templateFilename);
if (!m_baseFilename.empty())
@@ -622,11 +622,11 @@ TemplateData *currentTemplate = nullptr;
else
{
char errbuf[2048];
sprintf(errbuf, "I don't know how to handle this line!: <%s>. "
snprintf(errbuf, 2048, "I don't know how to handle this line!: <%s>. "
"Barfed on token <%s>.", buffer, token);
fp.printError(errbuf);
return -1;
}
}
return 0;
} // TemplateDefinitionFile::parse
} // TemplateDefinitionFile::parse
+300 -307
View File
@@ -16,335 +16,328 @@
#endif
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
namespace NAMESPACE
{
#endif
namespace Base
{
// set default values for global masks
CAutoLog::eLogLevel CAutoLog::nLogMask = eLOG_NORMAL; // what is logged in log files
CAutoLog::eLogLevel CAutoLog::nPrintMask = eLOG_ERROR; // what is printed on the screen
CAutoLog::eLogLevel CAutoLog::nFlushMask = eLOG_ERROR; // when is file flushed on every entry?
// class info
//-------------------------------------
bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
if( nullptr == filename)
return false;
if (pFilename)
return false;
#ifdef WIN32
pFilename = _strdup(filename);
#else
pFilename = strdup(filename);
#endif
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename,WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
char strPath[1024];
strcpy(strPath,pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != nullptr)
{
*ptr = 0;
#ifdef WIN32
char curdir[128];
// remember current directory
if( _getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
if (_chdir(strPath))
{
// failed to find the directory, so we must create it
if (_mkdir(strPath))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
_chdir(curdir);
}
#else
struct stat SS;
// see if directory exists
if (stat(strPath,&SS))
{
// create directory
if (mkdir(strPath,0777))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
#endif
}
pFile = fopen(pFilename,"a+");
if( pFile == nullptr || pFile == (FILE *)-1)
namespace Base
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
return false;
}
// set default values for global masks
CAutoLog::eLogLevel CAutoLog::nLogMask = eLOG_NORMAL; // what is logged in log files
CAutoLog::eLogLevel CAutoLog::nPrintMask = eLOG_ERROR; // what is printed on the screen
CAutoLog::eLogLevel CAutoLog::nFlushMask = eLOG_ERROR; // when is file flushed on every entry?
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
nTodaysDayOfYear = ptm->tm_yday;
// class info
//printf("Open log file: %s\n",pFilename);
return true;
}
//-------------------------------------
bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
if (nullptr == filename)
return false;
//-------------------------------------
void CAutoLog::Close(void)
//-------------------------------------
{
if( pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
pFile = (FILE *)-1;
free(pFilename);
pFilename = nullptr;
}
//-------------------------------------
void CAutoLog::LogError(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_ERROR, strInput);
}
//-------------------------------------
void CAutoLog::LogAlert(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_ALERT, strInput);
}
//-------------------------------------
void CAutoLog::Log(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_NORMAL, strInput);
}
//-------------------------------------
void CAutoLog::LogDebug(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_DEBUG, strInput);
}
//-------------------------------------
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
}
if (nLogMask == eLOG_NONE || nLogMask < severity)
{
if (nPrintMask == eLOG_NONE || nPrintMask < severity)
{ // no point in parsing, we're doing nothing.
return;
}
}
char strTime[128];
char strInput[1024];
char strOutput[1024+128];
time_t t;
// parse format and input arguments
va_list varg;
va_start(varg, fmt);
vsprintf(strInput, fmt, varg);
va_end(varg);
// make timestamp
time(&t);
strftime(strTime, sizeof(strTime), "[%m/%d/%Y %H:%M:%S]", localtime(&t) );
// construct output string
sprintf(strOutput, "%s %s\n", strTime, strInput);
// check to see if current file needs to be archived
Archive();
// log to file
if (!(nLogMask == eLOG_NONE || nLogMask < severity))
{
fwrite(strOutput,strlen(strOutput),1,pFile);
}
// print as standard output
if (!(nPrintMask == eLOG_NONE || nPrintMask < severity))
{
printf("%s", strOutput);
}
// flush file buffer if error is high severity
if (severity <= nFlushMask)
fflush(pFile);
}
//-------------------------------------
void CAutoLog::Archive(void)
//-------------------------------------
{
if( pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
}
// check to see if it's time to archive
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
if (ptm->tm_yday == nTodaysDayOfYear)
{
return; // nope, not time to archive
}
nTodaysDayOfYear = ptm->tm_yday;
char strPath[1024];
char strCurrent[1024];
char strTime[128];
char * pCurrent;
if (pFilename)
return false;
#ifdef WIN32
char curdir[128];
pFilename = _strdup(filename);
#else
struct stat SS;
pFilename = strdup(filename);
#endif
strftime(strTime, sizeof(strTime), "%m%d%Y", localtime(&t) ); // numerical time e.g. 041698
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename, WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
strcpy(strCurrent,pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent,".");
sprintf(strPath,"%s" SLASHCHAR "%s", strCurrent, strTime); // logs/041698
char strPath[1024];
strcpy(strPath, pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != nullptr)
{
*ptr = 0;
#ifdef WIN32
// remember current directory
if( _getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
}
char curdir[128];
if (_chdir(strPath))
{
// failed to find the directory, so we must create it
if (_mkdir(strPath))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
_chdir(curdir);
}
// remember current directory
if (_getcwd(curdir, sizeof(curdir)) == nullptr)
{
fprintf(stderr, "CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
if (_chdir(strPath))
{
// failed to find the directory, so we must create it
if (_mkdir(strPath))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
_chdir(curdir);
}
#else
// see if directory exists
if (stat(strPath,&SS))
{
// create directory
if (mkdir(strPath,0777))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
struct stat SS;
// see if directory exists
if (stat(strPath, &SS))
{
// create directory
if (mkdir(strPath, 0777))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
#endif
}
pFile = fopen(pFilename, "a+");
if (pFile == nullptr || pFile == (FILE *)-1)
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
return false;
}
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
nTodaysDayOfYear = ptm->tm_yday;
//printf("Open log file: %s\n",pFilename);
return true;
}
//-------------------------------------
void CAutoLog::Close(void)
//-------------------------------------
{
if (pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
pFile = (FILE *)-1;
free(pFilename);
pFilename = nullptr;
}
//-------------------------------------
void CAutoLog::LogError(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_ERROR, strInput);
}
//-------------------------------------
void CAutoLog::LogAlert(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_ALERT, strInput);
}
//-------------------------------------
void CAutoLog::Log(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_NORMAL, strInput);
}
//-------------------------------------
void CAutoLog::LogDebug(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_DEBUG, strInput);
}
//-------------------------------------
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
}
if (nLogMask == eLOG_NONE || nLogMask < severity)
{
if (nPrintMask == eLOG_NONE || nPrintMask < severity)
{ // no point in parsing, we're doing nothing.
return;
}
}
char strTime[128];
char strInput[1024];
char strOutput[1024 + 128];
time_t t;
// parse format and input arguments
va_list varg;
va_start(varg, fmt);
vsprintf(strInput, fmt, varg);
va_end(varg);
// make timestamp
time(&t);
strftime(strTime, sizeof(strTime), "[%m/%d/%Y %H:%M:%S]", localtime(&t));
// construct output string
snprintf(strOutput, 1152, "%s %s\n", strTime, strInput);
// check to see if current file needs to be archived
Archive();
// log to file
if (!(nLogMask == eLOG_NONE || nLogMask < severity))
{
fwrite(strOutput, strlen(strOutput), 1, pFile);
}
// print as standard output
if (!(nPrintMask == eLOG_NONE || nPrintMask < severity))
{
printf("%s", strOutput);
}
// flush file buffer if error is high severity
if (severity <= nFlushMask)
fflush(pFile);
}
//-------------------------------------
void CAutoLog::Archive(void)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
}
// check to see if it's time to archive
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
if (ptm->tm_yday == nTodaysDayOfYear)
{
return; // nope, not time to archive
}
nTodaysDayOfYear = ptm->tm_yday;
char strPath[1024];
char strCurrent[1024];
char strTime[128];
char * pCurrent;
#ifdef WIN32
char curdir[128];
#else
struct stat SS;
#endif
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
strftime(strTime, sizeof(strTime), "%m%d%Y", localtime(&t)); // numerical time e.g. 041698
sprintf(strCurrent,"%s" SLASHCHAR "%s",strPath,pCurrent);
strcpy(strCurrent, pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent, ".");
fflush(pFile);
fclose(pFile);
snprintf(strPath, 1024, "%s" SLASHCHAR "%s", strCurrent, strTime); // logs/041698
rename(pFilename,strCurrent);
#ifdef WIN32
// remember current directory
if (_getcwd(curdir, sizeof(curdir)) == nullptr)
{
fprintf(stderr, "CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
}
pFile = fopen(pFilename,"w+");
}
if (_chdir(strPath))
{
// failed to find the directory, so we must create it
if (_mkdir(strPath))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
_chdir(curdir);
}
#else
// see if directory exists
if (stat(strPath, &SS))
{
// create directory
if (mkdir(strPath, 0777))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
#endif
};
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
sprintf(strCurrent, "%s" SLASHCHAR "%s", strPath, pCurrent);
fflush(pFile);
fclose(pFile);
rename(pFilename, strCurrent);
pFile = fopen(pFilename, "w+");
}
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif
File diff suppressed because it is too large Load Diff
+257 -265
View File
@@ -7,13 +7,11 @@
#include <stdarg.h>
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
namespace NAMESPACE
{
#endif
namespace Base
{
namespace Base
{
#ifdef WIN32
#include <direct.h> // for NT directory commands
#define SLASHCHAR "\\"
@@ -23,325 +21,319 @@ namespace Base
#define WRONGSLASH '\\'
#endif
// set default values for global masks
CAutoLog::eLogLevel CAutoLog::nLogMask = eLOG_NORMAL; // what is logged in log files
CAutoLog::eLogLevel CAutoLog::nPrintMask = eLOG_ERROR; // what is printed on the screen
CAutoLog::eLogLevel CAutoLog::nFlushMask = eLOG_ERROR; // when is file flushed on every entry?
// set default values for global masks
CAutoLog::eLogLevel CAutoLog::nLogMask = eLOG_NORMAL; // what is logged in log files
CAutoLog::eLogLevel CAutoLog::nPrintMask = eLOG_ERROR; // what is printed on the screen
CAutoLog::eLogLevel CAutoLog::nFlushMask = eLOG_ERROR; // when is file flushed on every entry?
// class info
// class info
//-------------------------------------
bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
//-------------------------------------
bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
if (nullptr == filename)
return false;
if( nullptr == filename)
return false;
if (pFilename)
return false;
if (pFilename)
return false;
pFilename = strdup(filename);
pFilename = strdup(filename);
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename, WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename,WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
char strPath[1024];
strcpy(strPath,pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != nullptr)
{
*ptr = 0;
char strPath[1024];
strcpy(strPath, pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != nullptr)
{
*ptr = 0;
#ifdef WIN32
char curdir[128];
char curdir[128];
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
// remember current directory
if (getcwd(curdir, sizeof(curdir)) == nullptr)
{
fprintf(stderr, "CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
if (_chdir(strPath))
{
// failed to find the directory, so we must create it
if (mkdir(strPath))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
_chdir(curdir);
}
if (_chdir(strPath))
{
// failed to find the directory, so we must create it
if (mkdir(strPath))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
_chdir(curdir);
}
#else
struct stat SS;
struct stat SS;
// see if directory exists
if (stat(strPath,&SS))
{
// create directory
if (mkdir(strPath,0777))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
// see if directory exists
if (stat(strPath, &SS))
{
// create directory
if (mkdir(strPath, 0777))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
#endif
}
}
pFile = fopen(pFilename, "a+");
if (pFile == nullptr || pFile == (FILE *)-1)
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
return false;
}
pFile = fopen(pFilename,"a+");
if( pFile == nullptr || pFile == (FILE *)-1)
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
return false;
}
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
nTodaysDayOfYear = ptm->tm_yday;
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
nTodaysDayOfYear = ptm->tm_yday;
//printf("Open log file: %s\n",pFilename);
return true;
}
//printf("Open log file: %s\n",pFilename);
return true;
}
//-------------------------------------
void CAutoLog::Close(void)
//-------------------------------------
{
if (pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
pFile = (FILE *)-1;
//-------------------------------------
void CAutoLog::Close(void)
//-------------------------------------
{
if( pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
pFile = (FILE *)-1;
free(pFilename);
pFilename = nullptr;
}
//-------------------------------------
void CAutoLog::LogError(char * format, ...)
{
char strInput[1024];
free(pFilename);
pFilename = nullptr;
}
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
//-------------------------------------
void CAutoLog::LogError(char * format, ...)
{
char strInput[1024];
Log(eLOG_ERROR, strInput);
}
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
//-------------------------------------
void CAutoLog::LogAlert(char * format, ...)
{
char strInput[1024];
Log(eLOG_ERROR, strInput);
}
//-------------------------------------
void CAutoLog::LogAlert(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_ALERT, strInput);
}
Log(eLOG_ALERT, strInput);
}
//-------------------------------------
void CAutoLog::Log(char * format, ...)
{
char strInput[1024];
//-------------------------------------
void CAutoLog::Log(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_NORMAL, strInput);
}
Log(eLOG_NORMAL, strInput);
}
//-------------------------------------
void CAutoLog::LogDebug(char * format, ...)
{
char strInput[1024];
//-------------------------------------
void CAutoLog::LogDebug(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_DEBUG, strInput);
}
Log(eLOG_DEBUG, strInput);
}
//-------------------------------------
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
}
//-------------------------------------
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
}
if (nLogMask == eLOG_NONE || nLogMask < severity)
{
if (nPrintMask == eLOG_NONE || nPrintMask < severity)
{ // no point in parsing, we're doing nothing.
return;
}
}
if (nLogMask == eLOG_NONE || nLogMask < severity)
{
if (nPrintMask == eLOG_NONE || nPrintMask < severity)
{ // no point in parsing, we're doing nothing.
return;
}
}
char strTime[128];
char strInput[1024];
char strOutput[1024 + 128];
time_t t;
char strTime[128];
char strInput[1024];
char strOutput[1024+128];
time_t t;
// parse format and input arguments
va_list varg;
va_start(varg, fmt);
vsprintf(strInput, fmt, varg);
va_end(varg);
// parse format and input arguments
va_list varg;
va_start(varg, fmt);
vsprintf(strInput, fmt, varg);
va_end(varg);
// make timestamp
time(&t);
strftime(strTime, sizeof(strTime), "[%m/%d/%Y %H:%M:%S]", localtime(&t));
// make timestamp
time(&t);
strftime(strTime, sizeof(strTime), "[%m/%d/%Y %H:%M:%S]", localtime(&t) );
// construct output string
snprintf(strOutput, 1152, "%s %s\n", strTime, strInput);
// construct output string
sprintf(strOutput, "%s %s\n", strTime, strInput);
// check to see if current file needs to be archived
Archive();
// check to see if current file needs to be archived
Archive();
// log to file
if (!(nLogMask == eLOG_NONE || nLogMask < severity))
{
fwrite(strOutput, strlen(strOutput), 1, pFile);
}
// log to file
if (!(nLogMask == eLOG_NONE || nLogMask < severity))
{
fwrite(strOutput,strlen(strOutput),1,pFile);
}
// print as standard output
if (!(nPrintMask == eLOG_NONE || nPrintMask < severity))
{
printf("%s", strOutput);
}
// print as standard output
if (!(nPrintMask == eLOG_NONE || nPrintMask < severity))
{
printf("%s", strOutput);
}
// flush file buffer if error is high severity
if (severity <= nFlushMask)
fflush(pFile);
}
// flush file buffer if error is high severity
if (severity <= nFlushMask)
fflush(pFile);
}
//-------------------------------------
void CAutoLog::Archive(void)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
}
//-------------------------------------
void CAutoLog::Archive(void)
//-------------------------------------
{
if( pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
}
// check to see if it's time to archive
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
if (ptm->tm_yday == nTodaysDayOfYear)
{
return; // nope, not time to archive
}
nTodaysDayOfYear = ptm->tm_yday;
// check to see if it's time to archive
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
if (ptm->tm_yday == nTodaysDayOfYear)
{
return; // nope, not time to archive
}
nTodaysDayOfYear = ptm->tm_yday;
char strPath[1024];
char strCurrent[1024];
char strTime[128];
char * pCurrent;
char strPath[1024];
char strCurrent[1024];
char strTime[128];
char * pCurrent;
#ifdef WIN32
char curdir[128];
char curdir[128];
#else
struct stat SS;
struct stat SS;
#endif
strftime(strTime, sizeof(strTime), "%m%d%Y", localtime(&t) ); // numerical time e.g. 041698
strftime(strTime, sizeof(strTime), "%m%d%Y", localtime(&t)); // numerical time e.g. 041698
strcpy(strCurrent,pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent,".");
strcpy(strCurrent, pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent, ".");
sprintf(strPath,"%s" SLASHCHAR "%s", strCurrent, strTime); // logs/041698
snprintf(strPath, 1024, "%s" SLASHCHAR "%s", strCurrent, strTime); // logs/041698
#ifdef WIN32
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
}
// remember current directory
if (getcwd(curdir, sizeof(curdir)) == nullptr)
{
fprintf(stderr, "CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
}
if (_chdir(strPath))
{
// failed to find the directory, so we must create it
if (mkdir(strPath))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
_chdir(curdir);
}
if (_chdir(strPath))
{
// failed to find the directory, so we must create it
if (mkdir(strPath))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
_chdir(curdir);
}
#else
// see if directory exists
if (stat(strPath,&SS))
{
// create directory
if (mkdir(strPath,0777))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
// see if directory exists
if (stat(strPath, &SS))
{
// create directory
if (mkdir(strPath, 0777))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
#endif
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
sprintf(strCurrent,"%s" SLASHCHAR "%s",strPath,pCurrent);
sprintf(strCurrent, "%s" SLASHCHAR "%s", strPath, pCurrent);
fflush(pFile);
fclose(pFile);
fflush(pFile);
fclose(pFile);
rename(pFilename,strCurrent);
rename(pFilename, strCurrent);
pFile = fopen(pFilename,"w+");
}
};
pFile = fopen(pFilename, "w+");
}
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif
+257 -265
View File
@@ -7,13 +7,11 @@
#include <stdarg.h>
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
namespace NAMESPACE
{
#endif
namespace Base
{
namespace Base
{
#ifdef WIN32
#include <direct.h> // for NT directory commands
#define SLASHCHAR "\\"
@@ -23,325 +21,319 @@ namespace Base
#define WRONGSLASH '\\'
#endif
// set default values for global masks
CAutoLog::eLogLevel CAutoLog::nLogMask = eLOG_NORMAL; // what is logged in log files
CAutoLog::eLogLevel CAutoLog::nPrintMask = eLOG_ERROR; // what is printed on the screen
CAutoLog::eLogLevel CAutoLog::nFlushMask = eLOG_ERROR; // when is file flushed on every entry?
// set default values for global masks
CAutoLog::eLogLevel CAutoLog::nLogMask = eLOG_NORMAL; // what is logged in log files
CAutoLog::eLogLevel CAutoLog::nPrintMask = eLOG_ERROR; // what is printed on the screen
CAutoLog::eLogLevel CAutoLog::nFlushMask = eLOG_ERROR; // when is file flushed on every entry?
// class info
// class info
//-------------------------------------
bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
//-------------------------------------
bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
if (nullptr == filename)
return false;
if( nullptr == filename)
return false;
if (pFilename)
return false;
if (pFilename)
return false;
pFilename = strdup(filename);
pFilename = strdup(filename);
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename, WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename,WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
char strPath[1024];
strcpy(strPath,pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != nullptr)
{
*ptr = 0;
char strPath[1024];
strcpy(strPath, pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != nullptr)
{
*ptr = 0;
#ifdef WIN32
char curdir[128];
char curdir[128];
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
// remember current directory
if (getcwd(curdir, sizeof(curdir)) == nullptr)
{
fprintf(stderr, "CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
if (chdir(strPath))
{
// failed to find the directory, so we must create it
if (mkdir(strPath))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
chdir(curdir);
}
if (chdir(strPath))
{
// failed to find the directory, so we must create it
if (mkdir(strPath))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
chdir(curdir);
}
#else
struct stat SS;
struct stat SS;
// see if directory exists
if (stat(strPath,&SS))
{
// create directory
if (mkdir(strPath,0777))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
// see if directory exists
if (stat(strPath, &SS))
{
// create directory
if (mkdir(strPath, 0777))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = nullptr;
return false; // error, can't proceed
}
}
#endif
}
}
pFile = fopen(pFilename, "a+");
if (pFile == nullptr || pFile == (FILE *)-1)
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
return false;
}
pFile = fopen(pFilename,"a+");
if( pFile == nullptr || pFile == (FILE *)-1)
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
return false;
}
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
nTodaysDayOfYear = ptm->tm_yday;
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
nTodaysDayOfYear = ptm->tm_yday;
//printf("Open log file: %s\n",pFilename);
return true;
}
//printf("Open log file: %s\n",pFilename);
return true;
}
//-------------------------------------
void CAutoLog::Close(void)
//-------------------------------------
{
if (pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
pFile = (FILE *)-1;
//-------------------------------------
void CAutoLog::Close(void)
//-------------------------------------
{
if( pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
pFile = (FILE *)-1;
free(pFilename);
pFilename = nullptr;
}
//-------------------------------------
void CAutoLog::LogError(char * format, ...)
{
char strInput[1024];
free(pFilename);
pFilename = nullptr;
}
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
//-------------------------------------
void CAutoLog::LogError(char * format, ...)
{
char strInput[1024];
Log(eLOG_ERROR, strInput);
}
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
//-------------------------------------
void CAutoLog::LogAlert(char * format, ...)
{
char strInput[1024];
Log(eLOG_ERROR, strInput);
}
//-------------------------------------
void CAutoLog::LogAlert(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_ALERT, strInput);
}
Log(eLOG_ALERT, strInput);
}
//-------------------------------------
void CAutoLog::Log(char * format, ...)
{
char strInput[1024];
//-------------------------------------
void CAutoLog::Log(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_NORMAL, strInput);
}
Log(eLOG_NORMAL, strInput);
}
//-------------------------------------
void CAutoLog::LogDebug(char * format, ...)
{
char strInput[1024];
//-------------------------------------
void CAutoLog::LogDebug(char * format, ...)
{
char strInput[1024];
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
// parse format and input arguments
va_list varg;
va_start(varg, format);
vsprintf(strInput, format, varg);
va_end(varg);
Log(eLOG_DEBUG, strInput);
}
Log(eLOG_DEBUG, strInput);
}
//-------------------------------------
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
}
//-------------------------------------
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
}
if (nLogMask == eLOG_NONE || nLogMask < severity)
{
if (nPrintMask == eLOG_NONE || nPrintMask < severity)
{ // no point in parsing, we're doing nothing.
return;
}
}
if (nLogMask == eLOG_NONE || nLogMask < severity)
{
if (nPrintMask == eLOG_NONE || nPrintMask < severity)
{ // no point in parsing, we're doing nothing.
return;
}
}
char strTime[128];
char strInput[1024];
char strOutput[1024 + 128];
time_t t;
char strTime[128];
char strInput[1024];
char strOutput[1024+128];
time_t t;
// parse format and input arguments
va_list varg;
va_start(varg, fmt);
vsprintf(strInput, fmt, varg);
va_end(varg);
// parse format and input arguments
va_list varg;
va_start(varg, fmt);
vsprintf(strInput, fmt, varg);
va_end(varg);
// make timestamp
time(&t);
strftime(strTime, sizeof(strTime), "[%m/%d/%Y %H:%M:%S]", localtime(&t));
// make timestamp
time(&t);
strftime(strTime, sizeof(strTime), "[%m/%d/%Y %H:%M:%S]", localtime(&t) );
// construct output string
snprintf(strOutput, 1152, "%s %s\n", strTime, strInput);
// construct output string
sprintf(strOutput, "%s %s\n", strTime, strInput);
// check to see if current file needs to be archived
Archive();
// check to see if current file needs to be archived
Archive();
// log to file
if (!(nLogMask == eLOG_NONE || nLogMask < severity))
{
fwrite(strOutput, strlen(strOutput), 1, pFile);
}
// log to file
if (!(nLogMask == eLOG_NONE || nLogMask < severity))
{
fwrite(strOutput,strlen(strOutput),1,pFile);
}
// print as standard output
if (!(nPrintMask == eLOG_NONE || nPrintMask < severity))
{
printf("%s", strOutput);
}
// print as standard output
if (!(nPrintMask == eLOG_NONE || nPrintMask < severity))
{
printf("%s", strOutput);
}
// flush file buffer if error is high severity
if (severity <= nFlushMask)
fflush(pFile);
}
// flush file buffer if error is high severity
if (severity <= nFlushMask)
fflush(pFile);
}
//-------------------------------------
void CAutoLog::Archive(void)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
}
//-------------------------------------
void CAutoLog::Archive(void)
//-------------------------------------
{
if( pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
}
// check to see if it's time to archive
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
if (ptm->tm_yday == nTodaysDayOfYear)
{
return; // nope, not time to archive
}
nTodaysDayOfYear = ptm->tm_yday;
// check to see if it's time to archive
time_t t;
time(&t);
struct tm *ptm = localtime(&t);
if (ptm->tm_yday == nTodaysDayOfYear)
{
return; // nope, not time to archive
}
nTodaysDayOfYear = ptm->tm_yday;
char strPath[1024];
char strCurrent[1024];
char strTime[128];
char * pCurrent;
char strPath[1024];
char strCurrent[1024];
char strTime[128];
char * pCurrent;
#ifdef WIN32
char curdir[128];
char curdir[128];
#else
struct stat SS;
struct stat SS;
#endif
strftime(strTime, sizeof(strTime), "%m%d%Y", localtime(&t) ); // numerical time e.g. 041698
strftime(strTime, sizeof(strTime), "%m%d%Y", localtime(&t)); // numerical time e.g. 041698
strcpy(strCurrent,pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent,".");
strcpy(strCurrent, pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent, ".");
sprintf(strPath,"%s" SLASHCHAR "%s", strCurrent, strTime); // logs/041698
snprintf(strPath, 1024, "%s" SLASHCHAR "%s", strCurrent, strTime); // logs/041698
#ifdef WIN32
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
}
// remember current directory
if (getcwd(curdir, sizeof(curdir)) == nullptr)
{
fprintf(stderr, "CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
}
if (chdir(strPath))
{
// failed to find the directory, so we must create it
if (mkdir(strPath))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
chdir(curdir);
}
if (chdir(strPath))
{
// failed to find the directory, so we must create it
if (mkdir(strPath))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
else
{
// found the directory, but we don't want to be there, so go back
chdir(curdir);
}
#else
// see if directory exists
if (stat(strPath,&SS))
{
// create directory
if (mkdir(strPath,0777))
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
// see if directory exists
if (stat(strPath, &SS))
{
// create directory
if (mkdir(strPath, 0777))
{
fprintf(stderr, "CAutoLog::Archive failed to make directory: %s\n", strPath);
return; // error, can't proceed
}
}
#endif
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
sprintf(strCurrent,"%s" SLASHCHAR "%s",strPath,pCurrent);
sprintf(strCurrent, "%s" SLASHCHAR "%s", strPath, pCurrent);
fflush(pFile);
fclose(pFile);
fflush(pFile);
fclose(pFile);
rename(pFilename,strCurrent);
rename(pFilename, strCurrent);
pFile = fopen(pFilename,"w+");
}
};
pFile = fopen(pFilename, "w+");
}
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif