From 3a5c99bca54067bcdbb03f6627456ca1cfd799fa Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 18 Sep 2013 22:44:04 +0000 Subject: [PATCH] small code cleanup to see if this corrects any memory issues --- source/glest_game/ai/ai_rule.cpp | 14 +++++++------- source/glest_game/network/network_interface.cpp | 5 +++++ source/glest_game/type_instances/faction.cpp | 3 +-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/source/glest_game/ai/ai_rule.cpp b/source/glest_game/ai/ai_rule.cpp index 014e2e22..77aa76b3 100644 --- a/source/glest_game/ai/ai_rule.cpp +++ b/source/glest_game/ai/ai_rule.cpp @@ -568,7 +568,7 @@ AiRuleProduceResourceProducer::AiRuleProduceResourceProducer(Ai *ai): { interval= shortInterval; rt=NULL; - bool newResourceBehaviour=Config::getInstance().getBool("NewResourceBehaviour","false");; + newResourceBehaviour=Config::getInstance().getBool("NewResourceBehaviour","false");; } bool AiRuleProduceResourceProducer::test(){ @@ -886,7 +886,7 @@ void AiRuleProduce::produceGenericNew(const ProduceTask *pt) { if(producedUnit->isOfClass(pt->getUnitClass())){ if(aiInterface->reqsOk(ct) && aiInterface->reqsOk(producedUnit)){ - produceIt= true; + //produceIt= true; addUnitTypeToCandidates(producedUnit, ableUnits,ableUnitsGiveBack, false); } } @@ -949,12 +949,12 @@ void AiRuleProduce::produceGenericNew(const ProduceTask *pt) { for(unsigned int i = 0; i < ableUnits.size(); ++i) { const UnitType *ut = ableUnits[i]; - snprintf(szBuf,8096,"i: %d unit type [%s]",i,ut->getName(false).c_str()); + snprintf(szBuf,8096,"i: %u unit type [%s]",i,ut->getName(false).c_str()); aiInterface->printLog(4, szBuf); } for(unsigned int i = 0; i < newAbleUnits.size(); ++i) { const UnitType *ut = newAbleUnits[i]; - snprintf(szBuf,8096,"i: %d new unit type [%s]",i,ut->getName(false).c_str()); + snprintf(szBuf,8096,"i: %u new unit type [%s]",i,ut->getName(false).c_str()); aiInterface->printLog(4, szBuf); } } @@ -1665,7 +1665,7 @@ void AiRuleBuild::buildBestBuilding(const vector &buildings){ if(aiInterface->isLogLevelEnabled(4) == true) { char szBuf[8096]=""; - snprintf(szBuf,8096,"In buildBestBuilding warriorproducer building unit type: [%s] i = %d j = %d\n",building->getName().c_str(),i,j); + snprintf(szBuf,8096,"In buildBestBuilding warriorproducer building unit type: [%s] i = %d j = %u\n",building->getName().c_str(),i,j); aiInterface->printLog(4, szBuf); } @@ -1681,7 +1681,7 @@ void AiRuleBuild::buildBestBuilding(const vector &buildings){ if(aiInterface->isLogLevelEnabled(4) == true) { char szBuf[8096]=""; - snprintf(szBuf,8096,"In buildBestBuilding resourceproducer building unit type: [%s] i = %d j = %d\n",building->getName().c_str(),i,j); + snprintf(szBuf,8096,"In buildBestBuilding resourceproducer building unit type: [%s] i = %d j = %u\n",building->getName().c_str(),i,j); aiInterface->printLog(4, szBuf); } @@ -1698,7 +1698,7 @@ void AiRuleBuild::buildBestBuilding(const vector &buildings){ if(aiInterface->isLogLevelEnabled(4) == true) { char szBuf[8096]=""; - snprintf(szBuf,8096,"In buildBestBuilding ANY building unit type: [%s] i = %d j = %d\n",building->getName().c_str(),i,j); + snprintf(szBuf,8096,"In buildBestBuilding ANY building unit type: [%s] i = %d j = %u\n",building->getName().c_str(),i,j); aiInterface->printLog(4, szBuf); } diff --git a/source/glest_game/network/network_interface.cpp b/source/glest_game/network/network_interface.cpp index bccceb54..698af96e 100644 --- a/source/glest_game/network/network_interface.cpp +++ b/source/glest_game/network/network_interface.cpp @@ -63,6 +63,11 @@ void NetworkInterface::init() { receivedDataSynchCheck=false; gameSettings = GameSettings(); + + networkPlayerFactionCRCMutex = NULL; + for(unsigned int index = 0; index < GameConstants::maxPlayers; ++index) { + networkPlayerFactionCRC[index] = 0; + } } NetworkInterface::~NetworkInterface() { diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index b1209531..6c12ad76 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -2310,8 +2310,7 @@ void Faction::addCRC_DetailsForWorldFrame(int worldFrameCount,bool isNetworkServ if(crcWorldFrameDetails.size() > MAX_FRAME_CACHE) { //printf("===> Removing older world frame log entries: %lld\n",(long long int)crcWorldFrameDetails.size()); - for(std::map::iterator iterMap = crcWorldFrameDetails.begin(); - crcWorldFrameDetails.size() - MAX_FRAME_CACHE > 0;) { + for(;crcWorldFrameDetails.size() - MAX_FRAME_CACHE > 0;) { crcWorldFrameDetails.erase(crcWorldFrameDetails.begin()); } }