and fix a ton more minor performance issues

This commit is contained in:
DarthArgus
2014-10-27 22:39:57 -07:00
parent 14eaf713d0
commit c9c39d5713
97 changed files with 266 additions and 376 deletions
@@ -62,8 +62,7 @@ InputFileHandler::InputFileHandler(const char *infilename)
//
InputFileHandler::~InputFileHandler(void)
{
if(file)
delete file;
delete file;
}
@@ -27,8 +27,7 @@ OutputFileHandler::OutputFileHandler(const char *filename)
void OutputFileHandler::setCurrentFilename(const char *filename)
{
if (outFilename)
delete [] outFilename;
delete [] outFilename;
outFilename = new char[strlen(filename)+1];
strcpy(outFilename, filename);
@@ -84,8 +84,7 @@ AuctionTransferAPI::AuctionTransferAPI(const char *hostNames, const char *identi
//////////////////////////////////////////////////////////////////////////////////////
AuctionTransferAPI::~AuctionTransferAPI()
{
if( m_apiCore)
delete m_apiCore;
delete m_apiCore;
}
//////////////////////////////////////////////////////////////////////////////////////
@@ -33,10 +33,7 @@ void put(Base::ByteStream &msg, const Blob &source);
//////////////////////////////////////////////////////////////////////////////////////
Blob::~Blob()
{
if (m_data)
{
delete [] m_data;
}
delete [] m_data;
}
//////////////////////////////////////////////////////////////////////////////////////
@@ -301,10 +301,7 @@ int TcpConnection::finishConnect()
TcpConnection::~TcpConnection()
{
if (m_recvBuff != NULL)
{
delete [] m_recvBuff;
}
delete [] m_recvBuff;
while(m_head != NULL)
{
@@ -543,8 +540,7 @@ int TcpConnection::processIncoming()
}
else if (m_params.maxRecvMessageSize == 0)
{
if (m_recvBuff!=NULL)
delete [] m_recvBuff;
delete [] m_recvBuff;
m_recvBuff = new char[m_bytesNeeded-4];
}
else if (m_params.maxRecvMessageSize != 0 && (m_bytesNeeded-4) > m_params.maxRecvMessageSize)
@@ -78,7 +78,7 @@ class CA2GZIPT
}
~CA2GZIPT()
{
if(pgzip!=m_buffer) TRYFREE(pgzip);
free(pgzip);
}
void Init(char *lpsz,int len=-1)
{
@@ -191,7 +191,7 @@ class CA2GZIPT
err = deflateEnd(&(m_zstream));
}
if (m_z_err < 0) err = m_z_err;
TRYFREE(m_outbuf);
free(m_outbuf);
return err;
}
@@ -219,7 +219,7 @@ class CGZIP2AT
}
~CGZIP2AT()
{
if(psz!=m_buffer) TRYFREE(psz);
if(psz!=m_buffer) free(psz);
}
void Init()
{
@@ -463,7 +463,7 @@ class CGZIP2AT
err = inflateEnd(&(m_zstream));
}
if (m_z_err < 0) err = m_z_err;
TRYFREE(m_inbuf);
free(m_inbuf);
return err;
}
@@ -60,7 +60,7 @@ int main(int argc, char ** argv)
ConfigCentralServer::install();
cmdLine = "";
cmdLine.clear();
// now, the real command line
for(i = 0; i < argc; ++i)
{
@@ -167,9 +167,9 @@ void GameServerConnection::onReceive(const Archive::ByteStream & message)
//printf("GameServerConnection -- ChatInviteAvatarToRoom\n");
ChatInviteAvatarToRoom chat(ri);
ChatAvatarId characterName = chat.getAvatarId();
if(characterName.gameCode == "")
if(characterName.gameCode.empty())
characterName.gameCode = "SWG";
if(characterName.cluster == "")
if(characterName.cluster.empty())
characterName.cluster = ConfigChatServer::getClusterName();
ChatServer::invite(NetworkId::cms_invalid, characterName, chat.getRoomName());
}
@@ -186,9 +186,9 @@ void GameServerConnection::onReceive(const Archive::ByteStream & message)
//printf("GameServerConnection -- ChatUninviteAvatarFromRoom\n");
ChatUninviteFromRoom chat(ri);
ChatAvatarId characterName = chat.getAvatar();
if(characterName.gameCode == "")
if(characterName.gameCode.empty())
characterName.gameCode = "SWG";
if(characterName.cluster == "")
if(characterName.cluster.empty())
characterName.cluster = ConfigChatServer::getClusterName();
ChatServer::uninvite(ChatServer::getNetworkIdByAvatarId(characterName), chat.getSequence(), characterName, chat.getRoomName());
}
@@ -690,7 +690,7 @@ void VChatInterface::OnGetChannelInfo(unsigned track, unsigned result, const std
{
VChatSystem::Channel data;
data.m_channelName = channelName;
data.m_channelPassword = ""; // none of the channels have passwords at this point so this is a safe assumption
data.m_channelPassword.clear(); // none of the channels have passwords at this point so this is a safe assumption
data.m_channelURI = channelURI;
data.m_channelID = channelID;
setChannelData(data);
@@ -116,7 +116,7 @@ m_auctionsIndexedByTemplate(),
m_auctionsResourceContainer(),
m_vendorOffers()
{
assert(location != "");
assert(location.empty());
assert(GetStatus() >= AuctionMarket::ACTIVE && GetStatus() <= AuctionMarket::REMOVED);
AuctionMarket::getPlanetAndRegionFromLocationString(m_location, m_locationPlanet, m_locationRegion);
@@ -657,13 +657,11 @@ AuctionMarket::~AuctionMarket()
//We need to delete the auction and auction location objects
for (std::map<NetworkId, Auction *>::iterator i = m_auctions.begin(); i != m_auctions.end(); ++i)
{
if ((*i).second)
delete (*i).second;
delete (*i).second;
}
for (std::map<NetworkId, AuctionLocation *>::iterator i = m_locationIdMap.begin(); i != m_locationIdMap.end(); ++i)
{
if ((*i).second)
delete (*i).second;
delete (*i).second;
}
}
@@ -34,8 +34,8 @@ MetricsGatheringConnection::MetricsGatheringConnection(UdpConnectionMT * u, TcpC
m_processLabel(),
m_metricsChannels()
{
m_label = "";
m_processLabel = "";
m_label.clear();
m_processLabel.clear();
}
//-----------------------------------------------------------------------
@@ -116,8 +116,7 @@ void MetricsGatheringConnection::initialize(const std::string & process, const s
{
const std::string dot = ".";
m_label = process;
if (planet != "")
m_label = m_label + dot + planet;
m_label = m_label + dot + planet;
m_processLabel = m_label;
if (numberedProcess)
@@ -258,7 +258,7 @@ void AiMovementPathFollow::popNodeBack ( void )
AiPath::iterator it = m_path->end();
it--;
--it;
m_path->erase(it);
}
@@ -293,7 +293,7 @@ void AiMovementPathFollow::swapPath ( AiPath * newPath )
AiPath::iterator it;
#ifdef _DEBUG
for(it = m_path->begin(); it != m_path->end(); it++)
for(it = m_path->begin(); it != m_path->end(); ++it)
{
sendEraseWaypoint(*it);
}
@@ -303,7 +303,7 @@ void AiMovementPathFollow::swapPath ( AiPath * newPath )
m_path->swap(*newPath);
for(it = m_path->begin(); it != m_path->end(); it++)
for(it = m_path->begin(); it != m_path->end(); ++it)
{
(*it).detach();
@@ -323,7 +323,7 @@ void AiMovementPathFollow::clearPath ( void )
{
AiPath::iterator it;
for(it = m_path->begin(); it != m_path->end(); it++)
for(it = m_path->begin(); it != m_path->end(); ++it)
{
sendEraseWaypoint(*it);
}
@@ -1136,8 +1136,7 @@ void CommoditiesMarket::remove()
for(std::map<NetworkId, SalesTaxInfo*>::iterator i = s_pendingSalesTax.begin(); i != s_pendingSalesTax.end(); ++i)
{
if (i->second)
delete i->second;
delete i->second;
}
s_pendingSalesTax.clear();
}
@@ -472,8 +472,7 @@ Client::~Client()
for (std::vector<Watcher<ServerSynchronizedUi> >::iterator i = m_syncUIs.begin(); i != m_syncUIs.end(); ++i)
{
ServerSynchronizedUi* syncUI = i->getPointer();
if (syncUI)
delete syncUI;
delete syncUI;
}
ObjectTracker::removePlayer();
@@ -177,7 +177,7 @@ Object const *getContainingPobForObjectInWorld(Object const &object)
void compare_results_int( std::set<TriggerVolume *> &results, std::set<TriggerVolume *> results2, ServerObject* object )
void compare_results_int( std::set<TriggerVolume *> &results, const std::set<TriggerVolume *> &results2, ServerObject* object )
{
if ( results.empty() && results2.empty() ) // nothing to say........
return;
@@ -224,7 +224,7 @@ void compare_results_int( std::set<TriggerVolume *> &results, std::set<TriggerVo
void compare_results( Capsule const &test, std::vector<TriggerVolume *> &results_in, std::set<TriggerVolume *> results2, ServerObject* object )
void compare_results( Capsule const &test, std::vector<TriggerVolume *> &results_in, const std::set<TriggerVolume *> &results2, ServerObject* object )
{
size_t i;
std::set<TriggerVolume*> results;
@@ -244,7 +244,7 @@ void compare_results( Capsule const &test, std::vector<TriggerVolume *> &results
}
void compare_results( Vector const &center_w, float radius, std::vector<TriggerVolume *> &results_in, std::set<TriggerVolume *> results2, ServerObject* object )
void compare_results( Vector const &center_w, float radius, std::vector<TriggerVolume *> &results_in, const std::set<TriggerVolume *> &results2, ServerObject* object )
{
size_t i;
std::set<TriggerVolume*> results;
@@ -11719,10 +11719,8 @@ void CreatureObject::addPackedWearable(std::string const &appearanceData, int ar
// we own the weaponSharedBaselines and weaponSharedBaselines pointers, so if
// we are not going to add them to the wearables list, we must delete them
if (weaponSharedBaselines)
delete weaponSharedBaselines;
if (weaponSharedNpBaselines)
delete weaponSharedNpBaselines;
delete weaponSharedBaselines;
delete weaponSharedNpBaselines;
return;
}
@@ -980,7 +980,6 @@ ServerObject::~ServerObject()
{
PROFILER_AUTO_BLOCK_DEFINE("ServerObject::~ServerObject delete script object");
if (m_scriptObject != NULL)
delete m_scriptObject;
}
m_scriptObject = NULL;
@@ -374,11 +374,11 @@ void ServerResourceClassObject::checkAttributeLimits()
camm.minValue = iClassAttribs->second.first;
camm.minClassName = safe_cast<ServerResourceClassObject*>((*i))->getResourceClassName();
camm.nextMinValue = std::numeric_limits<int>::max();
camm.nextMinClassName = "";
camm.nextMinClassName.clear();
camm.maxValue = iClassAttribs->second.second;
camm.maxClassName = camm.minClassName;
camm.nextMaxValue = std::numeric_limits<int>::min();
camm.nextMaxClassName = "";
camm.nextMaxClassName.clear();
childrenClassAttributeRanges[iClassAttribs->first] = camm;
}
@@ -6163,7 +6163,7 @@ void TangibleObject::forceHateTarget(NetworkId const & target)
}
bool TangibleObject::isUserOnAccessList(NetworkId const user) const
bool TangibleObject::isUserOnAccessList(NetworkId const& user) const
{
return (std::find(m_accessList.begin(), m_accessList.end(), user) != m_accessList.end());
}
@@ -6173,7 +6173,7 @@ bool TangibleObject::isGuildOnAccessList(int guildId) const
return (std::find(m_guildAccessList.begin(), m_guildAccessList.end(), guildId) != m_guildAccessList.end());
}
void TangibleObject::addUserToAccessList(const NetworkId user)
void TangibleObject::addUserToAccessList(const NetworkId &user)
{
if(isAuthoritative())
{
@@ -6214,7 +6214,7 @@ void TangibleObject::addGuildToAccessList(int guildId)
}
void TangibleObject::removeUserFromAccessList(const NetworkId user)
void TangibleObject::removeUserFromAccessList(const NetworkId &user)
{
if(isAuthoritative())
{
@@ -139,44 +139,44 @@ void ServerObjectTemplate::registerMe(void)
ExitChain::add(exit, "ServerObjectTemplate");
// @todo: fill in the rest of this map
(*XpMap)[XP_rangedCombat] = "";
(*XpMap)[XP_meleeCombat] = "";
(*XpMap)[XP_tamingNoTime] = "";
(*XpMap)[XP_tamingShortTime] = "";
(*XpMap)[XP_tamingMediumTime] = "";
(*XpMap)[XP_tamingLargeTime] = "";
(*XpMap)[XP_architect] = "";
(*XpMap)[XP_botany] = "";
(*XpMap)[XP_bountyHunter] = "";
(*XpMap)[XP_chemist] = "";
(*XpMap)[XP_dancing] = "";
(*XpMap)[XP_facilityManagementSavings] = "";
(*XpMap)[XP_facilityManagementWearAndTear] = "";
(*XpMap)[XP_squadLeaderNoTime] = "";
(*XpMap)[XP_squadLeaderSmallTime] = "";
(*XpMap)[XP_squadLeaderMediumTime] = "";
(*XpMap)[XP_squadLeaderLargeTime] = "";
(*XpMap)[XP_hairdressing] = "";
(*XpMap)[XP_holonetSlicingPopularity] = "";
(*XpMap)[XP_holonetSlicingQuantity] = "";
(*XpMap)[XP_investigation] = "";
(*XpMap)[XP_medic] = "";
(*XpMap)[XP_military] = "";
(*XpMap)[XP_mining] = "";
(*XpMap)[XP_miningSavings] = "";
(*XpMap)[XP_rangedCombat].clear();
(*XpMap)[XP_meleeCombat].clear();
(*XpMap)[XP_tamingNoTime].clear();
(*XpMap)[XP_tamingShortTime].clear();
(*XpMap)[XP_tamingMediumTime].clear();
(*XpMap)[XP_tamingLargeTime].clear();
(*XpMap)[XP_architect].clear();
(*XpMap)[XP_botany].clear();
(*XpMap)[XP_bountyHunter].clear();
(*XpMap)[XP_chemist].clear();
(*XpMap)[XP_dancing].clear();
(*XpMap)[XP_facilityManagementSavings].clear();
(*XpMap)[XP_facilityManagementWearAndTear].clear();
(*XpMap)[XP_squadLeaderNoTime].clear();
(*XpMap)[XP_squadLeaderSmallTime].clear();
(*XpMap)[XP_squadLeaderMediumTime].clear();
(*XpMap)[XP_squadLeaderLargeTime].clear();
(*XpMap)[XP_hairdressing].clear();
(*XpMap)[XP_holonetSlicingPopularity].clear();
(*XpMap)[XP_holonetSlicingQuantity].clear();
(*XpMap)[XP_investigation].clear();
(*XpMap)[XP_medic].clear();
(*XpMap)[XP_military].clear();
(*XpMap)[XP_mining].clear();
(*XpMap)[XP_miningSavings].clear();
(*XpMap)[XP_musician] = "music";
(*XpMap)[XP_musicanPopularity] = "";
(*XpMap)[XP_politics] = "";
(*XpMap)[XP_slicing] = "";
(*XpMap)[XP_smuggling] = "";
(*XpMap)[XP_surveyingNoMinimum] = "";
(*XpMap)[XP_surveyingLowMinimum] = "";
(*XpMap)[XP_surveyingMediumMinimum] = "";
(*XpMap)[XP_surveyingHighMinimum] = "";
(*XpMap)[XP_survivalHealing] = "";
(*XpMap)[XP_survivalTracking] = "";
(*XpMap)[XP_vehicularControl] = "";
(*XpMap)[XP_vehicularWearAndTear] = "";
(*XpMap)[XP_musicanPopularity].clear();
(*XpMap)[XP_politics].clear();
(*XpMap)[XP_slicing].clear();
(*XpMap)[XP_smuggling].clear();
(*XpMap)[XP_surveyingNoMinimum].clear();
(*XpMap)[XP_surveyingLowMinimum].clear();
(*XpMap)[XP_surveyingMediumMinimum].clear();
(*XpMap)[XP_surveyingHighMinimum].clear();
(*XpMap)[XP_survivalHealing].clear();
(*XpMap)[XP_survivalTracking].clear();
(*XpMap)[XP_vehicularControl].clear();
(*XpMap)[XP_vehicularWearAndTear].clear();
(*XpMap)[XP_resourceHarvestingOrganic] = "resource_harvesting_organic";
(*XpMap)[XP_resourceHarvestingInorganic] = "resource_harvesting_inorganic";
(*XpMap)[XP_crafting] = "crafting_general";
@@ -9,7 +9,7 @@
//-----------------------------------------------------------------------
EnumerateServers::EnumerateServers(const bool a, const std::string addr, const unsigned short p, const int t) :
EnumerateServers::EnumerateServers(const bool a, const std::string &addr, const unsigned short p, const int t) :
GameNetworkMessage("EnumerateServers"),
add(a),
address(addr),
@@ -21,7 +21,7 @@ public:
PLANET_SERVER
};
EnumerateServers(const bool add, const std::string address, const unsigned short port, const int serverType);
EnumerateServers(const bool add, const std::string &address, const unsigned short port, const int serverType);
explicit EnumerateServers(Archive::ReadIterator & source);
~EnumerateServers();
@@ -95,7 +95,7 @@ CentralGameServerSetProcessId::~CentralGameServerSetProcessId()
//-----------------------------------------------------------------------
CentralGameServerProxyObject::CentralGameServerProxyObject(const NetworkId newObjectId,
CentralGameServerProxyObject::CentralGameServerProxyObject(const NetworkId &newObjectId,
const char * const newTemplateName,
const uint32 newGameServerProcessId,
const std::string & newGameServerAddress,
@@ -386,7 +386,7 @@ DatabaseSaveStart::~DatabaseSaveStart()
//----------------------------------------------------------------------
DatabaseCreateCharacterSuccess::DatabaseCreateCharacterSuccess(const NetworkId objectId, StationId stationId, const Unicode::String &characterName, int templateId, bool jedi) :
DatabaseCreateCharacterSuccess::DatabaseCreateCharacterSuccess(const NetworkId &objectId, StationId stationId, const Unicode::String &characterName, int templateId, bool jedi) :
GameNetworkMessage("DatabaseCreateCharacterSuccess"),
m_objectId(objectId),
m_stationId(stationId),
@@ -495,7 +495,7 @@ ConnectionServerAddress ::~ConnectionServerAddress ()
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
ShutdownCluster::ShutdownCluster(const uint32 timeToShutdown, const uint32 maxTime, const Unicode::String systemMessage):
ShutdownCluster::ShutdownCluster(const uint32 timeToShutdown, const uint32 maxTime, const Unicode::String &systemMessage):
GameNetworkMessage("ShutdownCluster"),
m_timeToShutdown(timeToShutdown),
m_maxTime(maxTime),
@@ -144,7 +144,7 @@ inline const uint32 CentralGameServerSetProcessId::getProcessId(void) const
class CentralGameServerProxyObject : public GameNetworkMessage
{
public:
CentralGameServerProxyObject(const NetworkId newObjectId,
CentralGameServerProxyObject(const NetworkId &newObjectId,
const char * const newTemplateName,
const uint32 newGameServerProcessId,
const std::string & newGameServerAddress,
@@ -587,7 +587,7 @@ public:
class DatabaseCreateCharacterSuccess : public GameNetworkMessage
{
public:
DatabaseCreateCharacterSuccess(const NetworkId objectId, StationId stationId, const Unicode::String &characterName, int templateId, bool jedi);
DatabaseCreateCharacterSuccess(const NetworkId &objectId, StationId stationId, const Unicode::String &characterName, int templateId, bool jedi);
DatabaseCreateCharacterSuccess(Archive::ReadIterator & source);
~DatabaseCreateCharacterSuccess();
@@ -739,7 +739,7 @@ inline const uint16 ConnectionServerAddress::getGameServicePort (void) const
class ShutdownCluster : public GameNetworkMessage
{
public:
ShutdownCluster( const uint32 timeToShutdown, const uint32 maxTime, const Unicode::String systemMessage);
ShutdownCluster( const uint32 timeToShutdown, const uint32 maxTime, const Unicode::String &systemMessage);
ShutdownCluster(Archive::ReadIterator &source);
virtual ~ShutdownCluster();
@@ -85,7 +85,7 @@ TransferControlMessage::~TransferControlMessage()
//-----------------------------------------------------------------------
ControlAssumed::ControlAssumed(NetworkId oid, const std::string & newSceneName, const bool skipLoadScreen,
const Vector startPos, const float startYaw, const std::string & templateName,
const Vector &startPos, const float startYaw, const std::string & templateName,
const int64 t) :
GameNetworkMessage("ControlAssumed"),
m_oid(oid),
@@ -117,7 +117,7 @@ class ControlAssumed : public GameNetworkMessage
{
public:
explicit ControlAssumed(NetworkId oid, const std::string & newSceneName, const bool skipLoadScreen,
const Vector startPos, const float startYaw, const std::string & templateName,
const Vector &startPos, const float startYaw, const std::string & templateName,
const int64 timeSeconds);
ControlAssumed(Archive::ReadIterator & source);
virtual ~ControlAssumed();
@@ -45,7 +45,7 @@ void updateQueue ( BuildQueue * queue, PerformanceTimer const & timer, float tim
currentBuilder->update();
BuildQueue::iterator old = it;
it++;
++it;
if(currentBuilder->buildDone())
{
@@ -821,8 +821,7 @@ void getStringArray(const LocalObjectArrayRefParam & array, std::vector<const Un
std::vector<const Unicode::String *>::iterator stringsIter = strings.begin();
for (jsize i = 0; i < count; ++i, ++stringsIter)
{
if (*stringsIter != 0)
delete *stringsIter;
delete *stringsIter;
stringElement = static_cast<jstring>(env->GetObjectArrayElement(arrayRef, i));
if (stringElement != 0)
@@ -1265,7 +1265,7 @@ void JavaLibrary::initializeJavaThread()
const char * jdwpString = "-Xrunjdwp:transport=dt_socket,server=y,suspend=n";
jdwpBuffer = new char[strlen(jdwpString) + 32];
strcpy(jdwpBuffer, jdwpString);
if (strlen(ConfigServerGame::getJavaDebugPort()) > 0)
if (ConfigServerGame::getJavaDebugPort()[0] == '\0')
{
strcat(jdwpBuffer, ",address=");
strcat(jdwpBuffer, ConfigServerGame::getJavaDebugPort());
@@ -5945,7 +5945,7 @@ const bool convert(const jobject & source, Vector & targetLoc, std::string & tar
JavaStringPtr sceneId = getStringField(LocalRefParam(source), JavaLibrary::ms_fidLocationArea);
if (sceneId == JavaString::cms_nullPtr)
{
targetSceneId = "";
targetSceneId.clear();
return false;
}
JavaLibrary::convert(*sceneId, targetSceneId);
@@ -5989,7 +5989,7 @@ const bool convertWorld(const jobject & source, Vector & targetLoc, std::string
JavaStringPtr sceneId = getStringField(LocalRefParam(source), JavaLibrary::ms_fidLocationArea);
if (sceneId == JavaString::cms_nullPtr)
{
targetSceneId = "";
targetSceneId.clear();
return false;
}
JavaLibrary::convert(*sceneId, targetSceneId);
@@ -467,8 +467,7 @@ void Scripting::InitScriptFuncHashMap(void)
*/
void Scripting::RemoveScriptFuncHashMap(void)
{
if (Scripting::ScriptFuncHashMap)
delete Scripting::ScriptFuncHashMap;
delete Scripting::ScriptFuncHashMap;
Scripting::ScriptFuncHashMap = NULL;
}
@@ -221,7 +221,7 @@ jboolean JNICALL ScriptMethodsBeastMasterNamespace::setBeastMasterPetCommands(JN
if (item != JavaString::cms_nullPtr)
JavaLibrary::convert(*item, commands[i]);
else
commands[i] = "";
commands[i].clear();
}
po->setPetCommandList(commands);
return JNI_TRUE;
@@ -261,7 +261,7 @@ jboolean JNICALL ScriptMethodsBeastMasterNamespace::setBeastMasterToggledPetComm
if (item != JavaString::cms_nullPtr)
JavaLibrary::convert(*item, commands[i]);
else
commands[i] = "";
commands[i]clear();
}
po->setPetToggledCommands(commands);
return JNI_TRUE;
@@ -109,7 +109,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::playClientEventObj(JNIEnv *
//get the event
std::string event;
JavaLibrary::convert(localEventType, event);
if (event == "")
if (event.empty())
return JNI_FALSE;
//get the hardpoint
@@ -167,7 +167,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::playClientEventObjLimited(J
//get the event
std::string event;
JavaLibrary::convert(localEventType, event);
if (event == "")
if (event.empty())
return JNI_FALSE;
//get the hardpoint
@@ -219,11 +219,11 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::playClientEventLoc(JNIEnv *
//get the events
std::string eventSource;
JavaLibrary::convert(localEventSourceType, eventSource);
if(eventSource == "")
if(eventSource.empty())
return JNI_FALSE;
std::string eventDest;
JavaLibrary::convert(localEventDestType, eventDest);
if(eventDest == "")
if(eventDest.empty())
return JNI_FALSE;
//get the location
@@ -254,11 +254,11 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::playClientEventLocLimited(J
//get the events
std::string eventSource;
JavaLibrary::convert(localEventSourceType, eventSource);
if(eventSource == "")
if(eventSource.empty())
return JNI_FALSE;
std::string eventDest;
JavaLibrary::convert(localEventDestType, eventDest);
if(eventDest == "")
if(eventDest.empty())
return JNI_FALSE;
//get the location
@@ -302,7 +302,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::playClientEffectObj(JNIEnv
//get the effect
std::string effect;
JavaLibrary::convert(localEffectName, effect);
if(effect == "")
if(effect.empty())
return JNI_FALSE;
//get the hardpoint
@@ -369,7 +369,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::playClientEffectObjLimited(
//get the effect
std::string effect;
JavaLibrary::convert(localEffectName, effect);
if(effect == "")
if(effect.empty())
return JNI_FALSE;
//get the hardpoint
@@ -432,7 +432,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::playClientEffectLoc(JNIEnv
//get the effect
std::string effect;
JavaLibrary::convert(localEffectName, effect);
if(effect == "")
if(effect.empty())
return JNI_FALSE;
//get the location
@@ -470,7 +470,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::playClientEffectLocLimited(
//get the effect
std::string effect;
JavaLibrary::convert(localEffectName, effect);
if(effect == "")
if(effect.empty())
return JNI_FALSE;
//get the location
@@ -554,7 +554,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::stopClientEffectObjByLabel(
//get the effect
std::string strLabelName;
JavaLibrary::convert(localLabel, strLabelName);
if(strLabelName == "")
if(strLabelName.empty())
return JNI_FALSE;
const NetworkId nid(objectEffectIsOn);
@@ -587,7 +587,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::stopClientEffectObjByLabelL
//get the effect
std::string strLabelName;
JavaLibrary::convert(localLabel, strLabelName);
if(strLabelName == "")
if(strLabelName.empty())
return JNI_FALSE;
const NetworkId nid(objectEffectIsOn);
@@ -613,7 +613,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::play2dNonLoopingMusic(JNIEn
std::string music;
JavaLibrary::convert(localMusicName, music);
if (music == "")
if (music.empty())
return JNI_FALSE;
PlayMusicMessage const msg(music, NetworkId::cms_invalid, 0, false);
@@ -637,7 +637,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::play2dNonLoopingSound(JNIEn
std::string music;
JavaLibrary::convert(localMusicName, music);
if (music == "")
if (music.empty())
return JNI_FALSE;
PlayMusicMessage const msg(music, NetworkId::cms_invalid, 1, false);
@@ -661,7 +661,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::playMusicWithParms(JNIEnv *
std::string music;
JavaLibrary::convert(localMusicName, music);
if (music == "")
if (music.empty())
return JNI_FALSE;
PlayMusicMessage const msg(music, NetworkId(source), playType, loop);
@@ -688,7 +688,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::createClientProjectile(JNIE
// get the weapon object template name string
std::string weaponObjectTemplateNameString;
JavaLibrary::convert(localWeaponObjectTemplateName, weaponObjectTemplateNameString);
if (weaponObjectTemplateNameString == "")
if (weaponObjectTemplateNameString.empty())
return JNI_FALSE;
// get the start location
@@ -730,7 +730,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::createClientProjectileObjec
// get the weapon object template name string
std::string weaponObjectTemplateNameString;
JavaLibrary::convert(localWeaponObjectTemplateName, weaponObjectTemplateNameString);
if (weaponObjectTemplateNameString == "")
if (weaponObjectTemplateNameString.empty())
return JNI_FALSE;
// Get our source object
@@ -788,7 +788,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::createClientProjectileObje
// get the weapon object template name string
std::string weaponObjectTemplateNameString;
JavaLibrary::convert(localWeaponObjectTemplateName, weaponObjectTemplateNameString);
if (weaponObjectTemplateNameString == "")
if (weaponObjectTemplateNameString.empty())
return JNI_FALSE;
// Get our source object
@@ -841,7 +841,7 @@ jboolean JNICALL ScriptMethodsClientEffectNamespace::createClientProjectileLocat
// get the weapon object template name string
std::string weaponObjectTemplateNameString;
JavaLibrary::convert(localWeaponObjectTemplateName, weaponObjectTemplateNameString);
if (weaponObjectTemplateNameString == "")
if (weaponObjectTemplateNameString.empty())
return JNI_FALSE;
// Get our target object
@@ -85,7 +85,7 @@ bool DB::OCIQueryImpl::prepare()
OCIStmtPrepare(m_stmthp,
m_session->errhp,
reinterpret_cast<OraText*>(const_cast<char*>(m_sql.c_str())),
strlen(m_sql.c_str()),
m_sql.length(),
(ub4) OCI_NTV_SYNTAX,
(ub4) OCI_DEFAULT)))
return false;
@@ -674,7 +674,7 @@ void RemoteDebug::send(MESSAGE_TYPE type, const char* theName)
if (explicitMessageLength != 0)
messageLength = explicitMessageLength;
else if (strlen(ms_varArgs_buffer) > 0)
else if (ms_varArgs_buffer[0] == '\0')
{
//only grab buffer sizes if needed
messageLength = strlen(ms_varArgs_buffer)+1;
@@ -688,7 +688,7 @@ void RemoteDebug::send(MESSAGE_TYPE type, const char* theName)
uint32 packetLength = static_cast<uint32>(messageTypeLength + channelNumberLength + messageLengthLength + static_cast<int>(messageLength));
if (strlen(ms_varArgs_buffer) > 0)
if (ms_varArgs_buffer[0] == '\0')
{
//copy data into the packet
memcpy(ms_buffer, &messageType, static_cast<uint32>(messageTypeLength));
@@ -106,8 +106,7 @@ RemoteDebug::Variable::Variable(const std::string& name, void *memLoc, VARIABLE_
RemoteDebug::Variable::~Variable()
{
if(m_type == CSTRING)
if (m_value.stringValue != NULL)
delete m_value.stringValue;
delete m_value.stringValue;
if(m_name)
{
@@ -157,8 +156,7 @@ void RemoteDebug::Variable::setValue(void *memLoc)
break;
case CSTRING:
if (m_value.stringValue)
delete[] m_value.stringValue;
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;
@@ -339,7 +339,7 @@ void FileManifest::setSceneId(const char *newScene)
if (s_currentSceneId.compare(newScene) == 0)
return;
if (strlen(newScene) == 0)
if (newScene[0] == '\0')
s_currentSceneId = "unknown";
else
s_currentSceneId = newScene;
@@ -146,8 +146,7 @@ inline void ArrayList<T>::copy (const ArrayList<T>& rhs)
// only delete and re-new the list if we don't have enough elements to hold the contents of rhs
if (m_numberOfElements < rhs.m_numberOfElements)
{
if (m_data)
delete [] m_data;
delete [] m_data;
m_size = rhs.m_size;
m_data = new T [m_size];
@@ -1541,8 +1541,7 @@ CommandLine::MatchCode CommandLine::parseOptions(const OptionSpec *optionTree, i
MatchCode mc;
// create the option information table
if (optionTable)
delete optionTable;
delete optionTable;
optionTable = new OptionTable;
// build the option tree corresponding to the option spec,
@@ -893,7 +893,7 @@ bool Os::handleDebugMenu()
// create the menu
HMENU menu = CreatePopupMenu();
const char *lastSection = "";
const char *lastSection.clear();
HMENU lastSubmenu = NULL;
int index = 1;
DebugFlags::FlagVector::const_iterator end = DebugFlags::ms_flagsSortedByName.end();
@@ -1508,7 +1508,7 @@ void Os::buildRelativePath(const char *baseDirectory, const char *targetPathname
}
//-- for each directory in base directory not matched, insert a "backup directory" string
relativePath = "";
relativePath.clear();
{
for (size_t i = matchCount; i < workingBaseDirectoryLength; ++i)
if (workingBaseDirectory[i] == directorySeparator)
@@ -39,8 +39,8 @@ draftSlotIndex(-1)
Crafting::IngredientSlot::IngredientSlot(enum IngredientType _ingredientType,
const StringId & _name,
const std::vector<NetworkId> slotIngredients,
const std::vector<int> slotIngredientsCount,
const std::vector<NetworkId> &slotIngredients,
const std::vector<int> &slotIngredientsCount,
float _complexity,
int _draftSlotOption,
int _draftSlotIndex) :
@@ -228,8 +228,8 @@ namespace Crafting
IngredientSlot(enum IngredientType _ingredientType,
const StringId & _name,
const stdvector<NetworkId>::fwd slotIngredients,
const stdvector<int>::fwd slotIngredientsCount,
const stdvector<NetworkId>::fwd &slotIngredients,
const stdvector<int>::fwd &slotIngredientsCount,
float _complexity,
int _draftSlotOption,
int _draftSlotIndex);
@@ -125,11 +125,11 @@ void HyperspaceManager::install()
HyperspaceLocation hyperspaceLoc;
hyperspaceLoc.name = cms_hyperspaceHomeLocationHyperspacePointName;
hyperspaceLoc.sceneName = "";
hyperspaceLoc.sceneName.clear();
hyperspaceLoc.location.x = 0;
hyperspaceLoc.location.y = 0;
hyperspaceLoc.location.z = 0;
hyperspaceLoc.requiredCommand = "";
hyperspaceLoc.requiredCommand.clear();
ms_hyperspaceLocationNameToHyperspaceLocations[hyperspaceLoc.name] = hyperspaceLoc;
}
@@ -113,9 +113,9 @@ Buff::PackedBuff Buff::getPackedBuffValue()
return result;
}
void Buff::set(uint32 buffNameCrc, Buff::PackedBuff buffValues)
void Buff::set(uint32 buffNameCrc, const Buff::PackedBuff &buffValues)
{
m_name = "";
m_name.clear();
m_nameCrc = buffNameCrc;
m_timestamp = buffValues.endtime;
m_value = buffValues.value;
@@ -41,7 +41,7 @@ public:
PackedBuff getPackedBuffValue();
static PackedBuff makePackedBuff(uint64 oldSchoolPackedBuff);
void set(uint32 buffNameCrc, PackedBuff buffValues);
void set(uint32 buffNameCrc, const PackedBuff &buffValues);
std::string m_name;
uint32 m_nameCrc;
@@ -175,7 +175,7 @@ void NebulaManager::clear()
}
}
s_currentSceneId = "";
s_currentSceneId.clear();
if (s_clearFunction != NULL)
s_clearFunction();
@@ -151,7 +151,7 @@ const std::string & PlayClientEffectObjectTransformMessage::getLabel() const
// ======================================================================
PlayClientEffectLocMessage::PlayClientEffectLocMessage(const std::string& effectName, const Vector& location, const std::string planet, const NetworkId & cell, float terrainDelta, const std::string& label)
PlayClientEffectLocMessage::PlayClientEffectLocMessage(const std::string& effectName, const Vector& location, const std::string &planet, const NetworkId & cell, float terrainDelta, const std::string& label)
: GameNetworkMessage(MESSAGE_TYPE),
m_effectName(effectName),
m_planet(planet),
@@ -342,7 +342,7 @@ Transform const & PlayClientEventObjectTransformMessage::getTransform() const
//----------------------------------------------------------------------
// ======================================================================
PlayClientEventLocMessage::PlayClientEventLocMessage(const std::string& eventSource, const std::string& eventDest, const Vector& location, const std::string planet, const NetworkId & cell, float terrainDelta)
PlayClientEventLocMessage::PlayClientEventLocMessage(const std::string& eventSource, const std::string& eventDest, const Vector& location, const std::string &planet, const NetworkId & cell, float terrainDelta)
: GameNetworkMessage(MESSAGE_TYPE),
m_eventSourceName(eventSource),
m_eventDestName(eventDest),
@@ -96,7 +96,7 @@ class PlayClientEffectLocMessage : public GameNetworkMessage
public:
PlayClientEffectLocMessage(const std::string& effectName,
const Vector& location,
const std::string planet,
const std::string &planet,
const NetworkId & cell,
float terrainDelta,
const std::string& label);
@@ -191,7 +191,7 @@ public:
PlayClientEventLocMessage(const std::string& eventSource,
const std::string& eventDest,
const Vector& position,
const std::string planet,
const std::string &planet,
const NetworkId & cell,
float terrainDelta);
explicit PlayClientEventLocMessage(Archive::ReadIterator& source);
@@ -85,7 +85,7 @@ package()
//-----------------------------------------------------------------------
BaselinesMessage::BaselinesMessage(const NetworkId id,
BaselinesMessage::BaselinesMessage(const NetworkId &id,
const Tag objectType,
const unsigned char newPackageId,
const Archive::ByteStream & newPackage) :
@@ -24,7 +24,7 @@ public: //ctor/dtor
const Archive::AutoByteStream & sourcePackage,
const unsigned char packageId);
BaselinesMessage (const NetworkId id,
BaselinesMessage (const NetworkId &id,
const Tag objectType,
const unsigned char newPackageId,
const Archive::ByteStream & newPackage);
@@ -880,10 +880,8 @@ Object::~Object(void)
deletePropertyList(m_propertyList);
if(m_defaultAppearance)
delete m_defaultAppearance;
if(m_alternateAppearance)
delete m_alternateAppearance;
delete m_defaultAppearance;
delete m_alternateAppearance;
m_appearance = 0;
m_defaultAppearance = 0;
@@ -42,8 +42,7 @@ LayerProperty::~LayerProperty()
void LayerProperty::setLayer(TerrainGenerator::Layer* layer)
{
if (m_layer != NULL)
delete m_layer;
delete m_layer;
m_layer = layer;
}
@@ -40,7 +40,7 @@ const char PATH_SEPARATOR = LINUX_PATH_SEPARATOR;
void Filename::setPath(const char *path)
{
if (path == NULL || *path == '\0')
m_path = "";
m_path.clear();
else
{
#ifdef WIN32
@@ -70,7 +70,7 @@ void Filename::setPath(const char *path)
void Filename::setName(const char *name)
{
if (name == NULL || *name == '\0')
m_name = "";
m_name.clear();
else
{
#ifdef WIN32
@@ -130,7 +130,7 @@ void Filename::setName(const char *name)
void Filename::setExtension(const char *extension)
{
if (extension == NULL || *extension == '\0')
m_extension = "";
m_extension.clear();
else
{
if (*extension == '.')
@@ -256,7 +256,7 @@ void Filename::setDrive(const char *drive)
if (drive != NULL && isalpha(*drive))
m_drive = std::string(drive, 1) + ":";
else
m_drive = "";
m_drive.clear();
makeFullPath();
} // Filename::setDrive
@@ -74,11 +74,11 @@ inline Filename::operator const char *(void) const
inline void Filename::clear(void)
{
m_path = "";
m_name = "";
m_extension = "";
m_fullFilename = "";
m_drive = "";
m_path.clear();
m_name.clear();
m_extension.clear();
m_fullFilename.clear();
m_drive.clear();
} // Filename::clear
inline const std::string & Filename::getPath(void) const
@@ -251,7 +251,7 @@ TemplateData::TemplateData(int version, const TemplateDefinitionFile &parent) :
* @param parent the template data this structure belongs to
* @param name the structure's name
*/
TemplateData::TemplateData(const TemplateData *parent, const std::string name) :
TemplateData::TemplateData(const TemplateData *parent, const std::string &name) :
m_fileParent(NULL),
m_templateParent(parent),
m_hasTemplateParam(false),
@@ -91,7 +91,7 @@ public:
public:
explicit TemplateData(int version, const TemplateDefinitionFile &parent);
explicit TemplateData(const TemplateData *parent, const std::string name);
explicit TemplateData(const TemplateData *parent, const std::string &name);
~TemplateData();
const std::string getName(void) const;
@@ -86,7 +86,7 @@ void TemplateDefinitionFile::setWriteForCompiler(bool flag)
}
else if (!flag && m_baseName == COMPILER_ROOT_TEMPLATE_NAME)
{
m_baseName = "";
m_baseName.clear();
}
std::map<int, TemplateData *>::iterator iter;
@@ -237,7 +237,7 @@ int TpfFile::loadTemplate(const Filename & filename)
}
else
{
m_iffPath = "";
m_iffPath.clear();
m_fp.printError("can't find \"dsrc\" in template path");
result = -1;
}
@@ -1769,7 +1769,7 @@ const char * TpfFile::parseDynamicVariableParameter(DynamicVariableParam & param
m_fp.printError("objvar parser given non-empty param");
return CHAR_ERROR;
}
data.m_name = "";
data.m_name.clear();
data.m_type = DynamicVariableParamData::LIST;
data.m_data.lparam = new std::vector<DynamicVariableParamData *>;
@@ -200,8 +200,7 @@ TerrainQuadTree::Node::Node (const int x, const int z, const int size, const flo
TerrainQuadTree::Node::~Node ()
{
if (m_chunk)
delete m_chunk;
delete m_chunk;
m_chunk = 0;
}
@@ -253,8 +253,7 @@ void AffectorColorRampHeight::setImage (const std::string& newImageName)
{
*imageName = newImageName;
if (image)
delete image;
delete image;
image = ImageFormatList::loadImage (imageName->c_str ());
if (image)
@@ -452,8 +451,7 @@ void AffectorColorRampFractal::setImage (const std::string& newImageName)
{
*imageName = newImageName;
if (image)
delete image;
delete image;
image = ImageFormatList::loadImage (imageName->c_str ());
if (image)
@@ -45,7 +45,7 @@ void DataTableManager::remove()
{
FATAL(!m_installed, ("DataTableManager::remove: not installed."));
m_cachedTable = 0;
m_cachedTableName = "";
m_cachedTableName.clear();
std::map<std::string, DataTable *>::iterator i;
for (i=m_tables.begin(); i != m_tables.end(); ++i)
@@ -103,7 +103,7 @@ void DataTableManager::close(const std::string& table)
if (m_cachedTable == i->second)
{
DEBUG_WARNING(m_cachedTableName != table, ("Cached name got out of sync"));
m_cachedTableName = "";
m_cachedTableName.clear();
m_cachedTable = 0;
}
@@ -589,7 +589,7 @@ void DataTableWriter::_loadFromSpreadsheetTab(const char * filename)
bool DataTableWriter::save(const char * outputFileName, bool optional) const
{
if (!outputFileName || strlen(outputFileName) == 0)
if (!outputFileName || outputFileName[0] != '\0')
{
DEBUG_FATAL(true, ("OutputFileName is NULL or empty."));
return false;
@@ -1038,7 +1038,7 @@ bool DataTableWriter::saveTable( const char* tableName, const char* fileName, bo
if (i != m_tables.end())
{
if (!fileName || strlen(fileName) == 0)
if (!fileName || fileName[0] != '\0')
{
std::string outputFile;
getTableOutputFileName((*i)->getName().c_str(), outputFile);
@@ -240,7 +240,7 @@ void FileName::stripSpecificPathAndExt (Path path, char* nameBuffer, int nameBuf
//correct path, now check extension.
//first make sure this path has an extension
if (strlen(pathTable[path].ext) > 0)
if (pathTable[path].ext[0] != '\0')
{
end = strrchr(nameBuffer, '.');
//make sure to compare strings starting just after the dot
@@ -202,8 +202,7 @@ void LocationManager::setPlanetName (char const * const planetName)
char fileName [256];
sprintf (fileName, "terrain/%s.trn", planetName);
if (ms_bakedTerrain)
delete ms_bakedTerrain;
delete ms_bakedTerrain;
ms_bakedTerrain = BakedTerrainReader::create (fileName);
}
@@ -138,7 +138,7 @@ RotaryCache::getNext()
{
void* retVal = (*mIterList).value;
mIterList++;
++mIterList;
return retVal;
}
@@ -47,8 +47,7 @@ MonitorObject::MonitorObject(UdpConnection *con,CMonitorData *_gamedata, char *p
MonitorObject::~MonitorObject()
{
if( mMark )
delete [] mMark;
delete [] mMark;
if( mConnection )
{
@@ -280,8 +279,7 @@ int x;
while( allowedAddressList[x])
free(allowedAddressList[x++]);
if( passString )
free( passString );
free( passString );
for (int i =0; i < mObjectCount; i++ )
delete mObject[i];
@@ -353,8 +351,7 @@ char buffer[1024];
return false;
}
if( passString )
free(passString);
free(passString);
for(x=0;x<AUTHADDRESS_MAX;x++)
@@ -437,16 +434,13 @@ CMonitorAPI::CMonitorAPI( const char *configFile, unsigned short Port, bool _bpr
CMonitorAPI::~CMonitorAPI()
{
if( mAddress )
free(mAddress);
free(mAddress);
if( mObjectManager )
delete mObjectManager;
delete mObjectManager;
mManager->Release();
if( mMonitorData )
delete mMonitorData;
delete mMonitorData;
}
@@ -530,8 +524,7 @@ monMessage(command, sequence, size)
//----------------------------------------------------------------
stringMessage::~stringMessage()
{
if(data)
delete [] data;
delete [] data;
data = 0;
}
@@ -76,25 +76,20 @@ int x;
for(x=0;x<m_count;x++)
{
if( m_data[x].discription )
delete [] m_data[x].discription;
delete [] m_data[x].discription;
if( m_data[x].label )
delete [] m_data[x].label;
delete [] m_data[x].label;
}
if(m_buffer)
delete m_buffer;
delete m_buffer;
if( m_data )
delete [] m_data;
delete [] m_data;
}
void CMonitorData::setMax(int _max)
{
if( m_data )
delete [] m_data;
delete [] m_data;
m_max = _max;
m_data = new MON_ELEMENT[m_max];
@@ -411,14 +406,12 @@ int x;
m_data[x].id = id;
//******* Label ***********
if( m_data[x].label )
delete [] m_data[x].label;
delete [] m_data[x].label;
m_data[x].label = new char [strlen(label)+1];
strcpy(m_data[x].label,label);
//******* Discription ******
if( m_data[x].discription != NULL )
delete [] m_data[x].discription;
delete [] m_data[x].discription;
m_data[x].discription = NULL;
if( des )
{
@@ -444,14 +437,12 @@ int x;
m_data[m_count].ping = pingValue( ping );
m_data[m_count].value = 0;
m_data[m_count].id = id;
if(m_data[m_count].label)
delete [] m_data[m_count].label;
delete [] m_data[m_count].label;
m_data[m_count].label = new char [strlen(label)+1];
strcpy(m_data[m_count].label,label);
if( des )
{
if( m_data[x].discription )
delete [] m_data[x].discription;
delete [] m_data[x].discription;
m_data[x].discription = new char [strlen(des)+1];
strcpy(m_data[x].discription,des);
}
@@ -470,8 +461,7 @@ int x;
{
if( Description == NULL )
{
if( m_data[x].discription )
delete [] m_data[x].discription;
delete [] m_data[x].discription;
m_data[x].discription = NULL;
mode = 0;
return x;
@@ -479,8 +469,7 @@ int x;
if( m_data[x].discription && !strcmp( m_data[x].discription, Description ) )
return -1;
if( m_data[x].discription )
delete [] m_data[x].discription;
delete [] m_data[x].discription;
m_data[x].discription = new char [ strlen(Description) +1 ];
strcpy(m_data[x].discription,Description);
mode = 1;
@@ -533,11 +522,9 @@ int x;
if( m_count == 1 )
{
if( m_data[0].label )
delete [] m_data[0].label;
delete [] m_data[0].label;
if( m_data[0].discription )
delete [] m_data[0].discription;
delete [] m_data[0].discription;
m_data[0].label = 0;
@@ -552,11 +539,9 @@ int x;
{
if( Id == m_data[x].id )
{
if( m_data[x].label )
delete [] m_data[x].label;
delete [] m_data[x].label;
if( m_data[x].discription )
delete [] m_data[x].discription;
delete [] m_data[x].discription;
m_data[x].label = 0;
if( x < m_count-1 )
@@ -101,7 +101,7 @@ namespace LoginAPI
}
else
{
value = "";
value.clear();
}
return value;
}
+1 -4
View File
@@ -133,10 +133,7 @@ void CAutoLog::Close(void)
}
pFile = (FILE *)-1;
if (pFilename)
{
free(pFilename);
}
free(pFilename);
pFilename = NULL;
}
+1 -2
View File
@@ -72,8 +72,7 @@ bool CConfig::LoadFile(char * file)
void CConfig::UnloadFile(void)
//-----------------------------------
{
if (pConfig)
delete[] pConfig;
delete[] pConfig;
pConfig = NULL;
}
@@ -129,10 +129,8 @@ void CAutoLog::Close(void)
}
pFile = (FILE *)-1;
if (pFilename)
{
free(pFilename);
}
free(pFilename);
pFilename = NULL;
}
@@ -71,8 +71,7 @@ bool CConfig::LoadFile(char * file)
void CConfig::UnloadFile(void)
//-----------------------------------
{
if (pConfig)
delete[] pConfig;
delete[] pConfig;
pConfig = NULL;
}
@@ -298,10 +298,7 @@ int TcpConnection::finishConnect()
TcpConnection::~TcpConnection()
{
if (m_recvBuff != NULL)
{
delete [] m_recvBuff;
}
delete [] m_recvBuff;
while(m_head != NULL)
{
@@ -540,8 +537,7 @@ int TcpConnection::processIncoming()
}
else if (m_params.maxRecvMessageSize == 0)
{
if (m_recvBuff!=NULL)
delete [] m_recvBuff;
delete [] m_recvBuff;
m_recvBuff = new char[m_bytesNeeded-4];
}
else if (m_params.maxRecvMessageSize != 0 && (m_bytesNeeded-4) > m_params.maxRecvMessageSize)
@@ -139,8 +139,7 @@ void Mapping::initSingleton ()
void Mapping::explicitDestroy ()
{
if (ms_singleton)
delete ms_singleton;
delete ms_singleton;
ms_singleton = 0;
}
@@ -69,8 +69,7 @@ void CharDataMap::initSingleton ()
void CharDataMap::explicitDestroy ()
{
if (ms_singleton)
delete ms_singleton;
delete ms_singleton;
ms_singleton = 0;
}
@@ -248,8 +247,7 @@ CharDataMap::ErrorCode CharDataMap::generateMapFromBuffer (const Blocks::Mapping
//-- pack all the char data into a contiguous block of memory
//--
if (m_contiguousData)
delete[] m_contiguousData;
delete[] m_contiguousData;
m_contiguousData = new CharData [validChars];
@@ -298,10 +298,7 @@ int TcpConnection::finishConnect()
TcpConnection::~TcpConnection()
{
if (m_recvBuff != NULL)
{
delete [] m_recvBuff;
}
delete [] m_recvBuff;
while(m_head != NULL)
{
@@ -540,8 +537,7 @@ int TcpConnection::processIncoming()
}
else if (m_params.maxRecvMessageSize == 0)
{
if (m_recvBuff!=NULL)
delete [] m_recvBuff;
delete [] m_recvBuff;
m_recvBuff = new char[m_bytesNeeded-4];
}
else if (m_params.maxRecvMessageSize != 0 && (m_bytesNeeded-4) > m_params.maxRecvMessageSize)
@@ -139,8 +139,7 @@ void Mapping::initSingleton ()
void Mapping::explicitDestroy ()
{
if (ms_singleton)
delete ms_singleton;
delete ms_singleton;
ms_singleton = 0;
}
@@ -69,8 +69,7 @@ void CharDataMap::initSingleton ()
void CharDataMap::explicitDestroy ()
{
if (ms_singleton)
delete ms_singleton;
delete ms_singleton;
ms_singleton = 0;
}
@@ -248,8 +247,7 @@ CharDataMap::ErrorCode CharDataMap::generateMapFromBuffer (const Blocks::Mapping
//-- pack all the char data into a contiguous block of memory
//--
if (m_contiguousData)
delete[] m_contiguousData;
delete[] m_contiguousData;
m_contiguousData = new CharData [validChars];
@@ -2126,7 +2126,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
}
ChatAvatarCore *removedAvatar = destRoomCore->removeAvatar(destAvatar->getAvatarID());
if (removedAvatar) delete removedAvatar;
delete removedAvatar;
m_api->OnReceiveAddBanRoom(srcAvatar, destAvatar, destRoom);
@@ -129,10 +129,8 @@ void CAutoLog::Close(void)
}
pFile = (FILE *)-1;
if (pFilename)
{
free(pFilename);
}
free(pFilename);
pFilename = NULL;
}
@@ -70,8 +70,7 @@ bool CConfig::LoadFile(char * file)
void CConfig::UnloadFile(void)
//-----------------------------------
{
if (pConfig)
delete[] pConfig;
delete[] pConfig;
pConfig = NULL;
}
@@ -139,8 +139,7 @@ void Mapping::initSingleton ()
void Mapping::explicitDestroy ()
{
if (ms_singleton)
delete ms_singleton;
delete ms_singleton;
ms_singleton = 0;
}
@@ -69,8 +69,7 @@ void CharDataMap::initSingleton ()
void CharDataMap::explicitDestroy ()
{
if (ms_singleton)
delete ms_singleton;
delete ms_singleton;
ms_singleton = 0;
}
@@ -248,8 +247,7 @@ CharDataMap::ErrorCode CharDataMap::generateMapFromBuffer (const Blocks::Mapping
//-- pack all the char data into a contiguous block of memory
//--
if (m_contiguousData)
delete[] m_contiguousData;
delete[] m_contiguousData;
m_contiguousData = new CharData [validChars];
@@ -171,7 +171,7 @@ void Logger::LoggerInit(const char *programName)
Logger::~Logger()
{
map<unsigned, LogInfo *>::iterator iter;
for(iter = m_logTable.begin(); iter != m_logTable.end(); iter++)
for(iter = m_logTable.begin(); iter != m_logTable.end(); ++iter)
{
logWithSys((*iter).first, LOG_INFO, LOG_FILEONLY, "---=== Log Stopped ===---");
fflush((*iter).second->file);
@@ -215,7 +215,7 @@ void Logger::flushAll()
{
map<unsigned, LogInfo *>::iterator iter;
for(iter = m_logTable.begin(); iter != m_logTable.end(); iter++)
for(iter = m_logTable.begin(); iter != m_logTable.end(); ++iter)
{
LogInfo *info = (*iter).second;
fflush(info->file);
@@ -660,7 +660,7 @@ void Logger::rollDate(time_t t)
m_logPrefix = buf;
map<unsigned, LogInfo *>::iterator iter;
for(iter = m_logTable.begin(); iter != m_logTable.end(); iter++)
for(iter = m_logTable.begin(); iter != m_logTable.end(); ++iter)
{
(*iter).second->filename = m_logPrefix + file_sep + (*iter).second->name.c_str() + ".log";
fflush((*iter).second->file);
@@ -44,8 +44,7 @@ MonitorObject::MonitorObject(UdpConnection *con,CMonitorData *_gamedata, char *p
MonitorObject::~MonitorObject()
{
if( mMark )
delete [] mMark;
delete [] mMark;
if( mConnection )
{
@@ -277,8 +276,7 @@ int x;
while( allowedAddressList[x])
free(allowedAddressList[x++]);
if( passString )
free( passString );
free( passString );
for (int i =0; i < mObjectCount; i++ )
delete mObject[i];
@@ -350,8 +348,7 @@ char buffer[1024];
return false;
}
if( passString )
free(passString);
free(passString);
for(x=0;x<AUTHADDRESS_MAX;x++)
@@ -436,16 +433,13 @@ CMonitorAPI::CMonitorAPI( char *configFile, unsigned short Port, bool _bprint ,
CMonitorAPI::~CMonitorAPI()
{
if( mAddress )
free(mAddress);
free(mAddress);
if( mObjectManager )
delete mObjectManager;
delete mObjectManager;
mManager->Release();
if( mMonitorData )
delete mMonitorData;
delete mMonitorData;
}
@@ -527,8 +521,7 @@ monMessage(command, sequence, size)
//----------------------------------------------------------------
stringMessage::~stringMessage()
{
if(data)
delete [] data;
delete [] data;
data = 0;
}
@@ -73,18 +73,12 @@ int x;
for(x=0;x<m_count;x++)
{
if( m_data[x].discription )
delete m_data[x].discription;
if( m_data[x].label )
delete m_data[x].label;
delete m_data[x].discription;
delete m_data[x].label;
}
if(m_buffer)
delete m_buffer;
if( m_data )
delete [] m_data;
delete m_buffer;
delete [] m_data;
}
void CMonitorData::resize_buffer(int new_size)
@@ -338,14 +332,12 @@ int x;
m_data[x].id = id;
//******* Label ***********
if( m_data[x].label )
delete m_data[x].label;
delete m_data[x].label;
m_data[x].label = new char [strlen(label)+1];
strcpy(m_data[x].label,label);
//******* Discription ******
if( m_data[x].discription != NULL )
delete [] m_data[x].discription;
delete [] m_data[x].discription;
m_data[x].discription = NULL;
if( des )
@@ -376,8 +368,7 @@ int x;
strcpy(m_data[m_count].label,label);
if( des )
{
if( m_data[x].discription )
delete [] m_data[x].discription;
delete [] m_data[x].discription;
m_data[x].discription = new char [strlen(des)+1];
strcpy(m_data[x].discription,des);
}
@@ -394,26 +385,23 @@ int x;
for(x=0;x<m_count;x++)
{
if( Id == m_data[x].id )
{
if( Description == NULL )
{
if( m_data[x].discription )
delete [] m_data[x].discription;
m_data[x].discription = NULL;
mode = 0;
return x;
}
if( m_data[x].discription && !strcmp( m_data[x].discription, Description ) )
return -1;
if( m_data[x].discription )
delete [] m_data[x].discription;
m_data[x].discription = new char [ sDescP1 ];
strcpy(m_data[x].discription,Description);
mode = 1;
if( Description == NULL )
{
delete [] m_data[x].discription;
m_data[x].discription = NULL;
mode = 0;
return x;
}
if( m_data[x].discription && !strcmp( m_data[x].discription, Description ) )
return -1;
if( m_data[x].discription )
delete [] m_data[x].discription;
m_data[x].discription = new char [ sDescP1 ];
strcpy(m_data[x].discription,Description);
mode = 1;
return x;
}
return -1;
}
@@ -453,8 +441,7 @@ int x;
if( m_count == 1 )
{
if( m_data[0].label )
delete [] m_data[0].label;
delete [] m_data[0].label;
m_data[0].label = 0;
m_data[0].id = 0;
@@ -469,8 +456,7 @@ int x;
{
if( Id == m_data[x].id )
{
if( m_data[x].label )
delete [] m_data[x].label;
delete [] m_data[x].label;
m_data[x].label = 0;
if( x < m_count -1 )
{
@@ -57,7 +57,7 @@ void Profiler::AddNode(Node & lhs, const Node & rhs)
lhs.mData.mMinLatency = rhs.mData.mMinLatency;
NodeMap_t::const_iterator iter;
for (iter = rhs.mNodeMap.begin(); iter != rhs.mNodeMap.end(); iter++)
for (iter = rhs.mNodeMap.begin(); iter != rhs.mNodeMap.end(); ++iter)
{
Node & node = lhs.mNodeMap[iter->first];
AddNode(node, iter->second);
@@ -69,7 +69,7 @@ void Profiler::AddData(const Profiler & rhs, bool hierarchy)
if (hierarchy)
{
NodeMap_t::const_iterator nodeIter;
for (nodeIter = rhs.mNodeMap.begin(); nodeIter != rhs.mNodeMap.end(); nodeIter++)
for (nodeIter = rhs.mNodeMap.begin(); nodeIter != rhs.mNodeMap.end(); ++nodeIter)
{
Node & node = mNodeMap[nodeIter->first];
AddNode(node, nodeIter->second);
@@ -77,7 +77,7 @@ void Profiler::AddData(const Profiler & rhs, bool hierarchy)
}
DataMap_t::const_iterator iter;
for (iter = rhs.mDataMap.begin(); iter != rhs.mDataMap.end(); iter++)
for (iter = rhs.mDataMap.begin(); iter != rhs.mDataMap.end(); ++iter)
{
NodeData & lhs = mDataMap[iter->first];
const NodeData & rhs = iter->second;
@@ -195,7 +195,7 @@ void Profiler::GetOutput(std::string & output, bool hierarchy)
// print data map (linear call profile)
DataMap_t::const_iterator iter;
for (iter = mDataMap.begin(); iter != mDataMap.end(); iter++)
for (iter = mDataMap.begin(); iter != mDataMap.end(); ++iter)
{
const NodeData & data = iter->second;
double trueLatency = data.mTotalLatency-data.mTotalChildLatency;
@@ -254,7 +254,7 @@ void Profiler::GetXmlOutput(std::string & output, bool hierarchy)
// print data map (linear call profile)
int i = 1;
DataMap_t::const_iterator iter;
for (iter = mDataMap.begin(); iter != mDataMap.end(); iter++)
for (iter = mDataMap.begin(); iter != mDataMap.end(); ++iter)
{
const NodeData & data = iter->second;
double trueLatency = data.mTotalLatency-data.mTotalChildLatency;
@@ -332,7 +332,7 @@ void Profiler::GetNodeOutput(std::string & output, const NodeMap_t & nodeMap, do
// recursively print node map
NodeMap_t::const_iterator iter;
for (iter = nodeMap.begin(); iter != nodeMap.end(); iter++)
for (iter = nodeMap.begin(); iter != nodeMap.end(); ++iter)
{
// output node description
const Node & node = iter->second;
@@ -361,7 +361,7 @@ void Profiler::GetXmlNodeOutput(std::string & output, const NodeMap_t & nodeMap,
// recursively print node map
int i = 1;
NodeMap_t::const_iterator iter;
for (iter = nodeMap.begin(); iter != nodeMap.end(); iter++)
for (iter = nodeMap.begin(); iter != nodeMap.end(); ++iter)
{
snprintf(buffer, sizeof(buffer), "<Node%d>", i);
output += buffer;
@@ -53,7 +53,7 @@ namespace soe
SerializeStringList(stringList_t vStrings)
: mMaxStringLength(DEFAULT_MAX_LENGTH_STRING), mMaxListLength(DEFAULT_MAX_NUMBER_ELEMENTS)
{
for(stringList_t::iterator i = vStrings.begin(); i != vStrings.end(); i++)
for(stringList_t::iterator i = vStrings.begin(); i != vStrings.end(); ++i)
{
push_back(*i);
}
@@ -103,7 +103,7 @@ namespace soe
#endif
return 0;
}
for (stringList_t::const_iterator iter = begin(); iter != end(); iter++, index++)
for (stringList_t::const_iterator iter = begin(); iter != end(); ++iter, ++index)
{
elementBytes = soe::Write(stream+bytes, size-bytes, *iter);
if (!elementBytes) {
@@ -156,7 +156,7 @@ namespace soe
SerializeStringVector(stringVector_t vStrings)
: mMaxStringLength(DEFAULT_MAX_LENGTH_STRING), mMaxVectorLength(DEFAULT_MAX_NUMBER_ELEMENTS)
{
for(stringVector_t::iterator i = vStrings.begin(); i != vStrings.end(); i++)
for(stringVector_t::iterator i = vStrings.begin(); i != vStrings.end(); ++i)
{
push_back(*i);
}
@@ -206,7 +206,7 @@ namespace soe
#endif
return 0;
}
for (stringVector_t::const_iterator iter = begin(); iter != end(); iter++, index++)
for (stringVector_t::const_iterator iter = begin(); iter != end(); ++iter, ++index)
{
elementBytes = soe::Write(stream+bytes, size-bytes, *iter);
if (!elementBytes) {
@@ -301,10 +301,7 @@ int TcpConnection::finishConnect()
TcpConnection::~TcpConnection()
{
if (m_recvBuff != NULL)
{
delete [] m_recvBuff;
}
delete [] m_recvBuff;
while(m_head != NULL)
{
@@ -547,8 +544,7 @@ int TcpConnection::processIncoming()
}
else if (m_params.maxRecvMessageSize == 0)
{
if (m_recvBuff!=NULL)
delete [] m_recvBuff;
delete [] m_recvBuff;
m_recvBuff = new char[m_bytesNeeded-4];
}
else if (m_params.maxRecvMessageSize != 0 && (m_bytesNeeded-4) > m_params.maxRecvMessageSize)
@@ -66,7 +66,7 @@ bool HashModule::Verify(const byte *digestIn)
BufferedTransformation::Err::Err(ErrorType errorType, const std::string &s)
: Exception(s), m_errorType(errorType)
{
if (GetWhat() == "")
if (GetWhat().empty())
{
switch (errorType)
{
@@ -137,7 +137,7 @@ AbstractFile* StdioFileFactory::createFile(const char *fileName, const char *ope
{
if(!fileName || !openType)
return NULL;
else if(strlen(fileName) == 0 || strlen(openType) == 0)
else if (fileName[0] == '\0' || openType[0] == '\0')
return NULL;
else
return new StdioFile(fileName, openType);
@@ -217,7 +217,7 @@ LocalizationManager & LocalizationManager::getManager ()
/**
* Get the locale specified by locale ("en" == English, "ja" == Japanese). Undefined results if called without first calling install ()
*/
LocalizationManager & LocalizationManager::getManager (Unicode::NarrowString locale)
LocalizationManager & LocalizationManager::getManager (const Unicode::NarrowString &locale)
{
LocalizationManagerHashMap::iterator f = LocalizationManager::ms_singletonHashMap->find(locale);
if(f != LocalizationManager::ms_singletonHashMap->end())
@@ -52,7 +52,7 @@ public:
LocalizationManager (AbstractFileFactory * fileFactory, const Unicode::NarrowString & localeName, DebugBadStringsFunc debugBadStringsFunc = 0, bool displayBadStringIds = true);
static LocalizationManager & getManager ();
static LocalizationManager & getManager (Unicode::NarrowString locale);
static LocalizationManager & getManager (const Unicode::NarrowString &locale);
~LocalizationManager ();
+1 -2
View File
@@ -136,8 +136,7 @@ void Mapping::initSingleton ()
void Mapping::explicitDestroy ()
{
if (ms_singleton)
delete ms_singleton;
delete ms_singleton;
ms_singleton = 0;
}
@@ -62,8 +62,7 @@ void CharDataMap::initSingleton ()
void CharDataMap::explicitDestroy ()
{
if (ms_singleton)
delete ms_singleton;
delete ms_singleton;
ms_singleton = 0;
}
@@ -241,8 +240,7 @@ CharDataMap::ErrorCode CharDataMap::generateMapFromBuffer (const Unicode::Blocks
//-- pack all the char data into a contiguous block of memory
//--
if (m_contiguousData)
delete[] m_contiguousData;
delete[] m_contiguousData;
m_contiguousData = new CharData [validChars];
@@ -532,8 +532,7 @@ void CSHandler::install()
void CSHandler::remove()
{
if( sm_instance )
delete sm_instance;
delete sm_instance;
}
CSHandler & CSHandler::getInstance()
@@ -161,7 +161,7 @@ int main(int argc, char ** argv)
SharedRemoteDebugServer::install();
//-- setup game server
cmdLine = "";
cmdLine.clear();
// now, the real command line
for(i = 0; i < argc; ++i)
{
@@ -350,8 +350,7 @@ static void lintType(char const *filePath, DataLint::AssetType const assetType,
if (strstr(filePath, "/base/") == NULL)
{
Object* const object = objectTemplate->createObject ();
if (object != NULL)
delete object;
delete object;
}
objectTemplate->releaseReference();