From f66a0834c9f0a9eaa2a90b0734bbacbd040b1708 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 23 Sep 2013 22:25:38 +0000 Subject: [PATCH] try to cleanup possible memory issue --- source/glest_game/type_instances/unit.cpp | 10 +++++----- source/glest_game/type_instances/unit.h | 6 ++++-- source/shared_lib/include/util/randomgen.h | 3 ++- source/shared_lib/sources/util/randomgen.cpp | 8 +++++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 67a69463..9de9b618 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -2979,9 +2979,9 @@ bool Unit::repair(){ //decrements HP and returns if dead bool Unit::decHp(int decrementValue) { - char szBuf[8096]=""; - snprintf(szBuf,8095,"this->hp = %d, decrementValue = %d",this->hp,decrementValue); - addNetworkCRCDecHp(szBuf); +// char szBuf[8096]=""; +// snprintf(szBuf,8095,"this->hp = %d, decrementValue = %d",this->hp,decrementValue); +// addNetworkCRCDecHp(szBuf); if(this->hp == 0) { return false; @@ -4251,14 +4251,14 @@ std::string Unit::toString(bool crcMode) const { result += "lastStuckFrame = " + uIntToStr(lastStuckFrame) + "\n"; result += "lastStuckPos = " + lastStuckPos.getString() + "\n"; - if(attackParticleSystems.size() > 0) { + if(attackParticleSystems.empty() == false) { result += "attackParticleSystems count = " + intToStr(attackParticleSystems.size()) + "\n"; } if(networkCRCParticleLogInfo != "") { result += "networkCRCParticleLogInfo = " + networkCRCParticleLogInfo + "\n"; } result += "networkCRCParticleObserverLogInfo = " + networkCRCParticleObserverLogInfo + "\n"; - if(networkCRCDecHpList.size() > 0) { + if(networkCRCDecHpList.empty() == false) { result += "getNetworkCRCDecHpList() = " + getNetworkCRCDecHpList() + "\n"; } diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index c14ab6ad..4345cfb6 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -782,14 +782,16 @@ public: void setNetworkCRCParticleLogInfo(string networkCRCParticleLogInfo) { this->networkCRCParticleLogInfo = networkCRCParticleLogInfo; } void setNetworkCRCParticleObserverLogInfo(string networkCRCParticleObserverLogInfo) { this->networkCRCParticleObserverLogInfo = networkCRCParticleObserverLogInfo; } - void clearNetworkCRCDecHpList() { networkCRCDecHpList.clear(); } + //void clearNetworkCRCDecHpList() { networkCRCDecHpList.clear(); } + void clearNetworkCRCDecHpList() { } Checksum getCRC(); virtual void end(ParticleSystem *particleSystem); private: - void addNetworkCRCDecHp(string info) { networkCRCDecHpList.push_back(info); } + //void addNetworkCRCDecHp(string info) { networkCRCDecHpList.push_back(info); } + void addNetworkCRCDecHp(string info) { } string getNetworkCRCDecHpList() const; float computeHeight(const Vec2i &pos) const; diff --git a/source/shared_lib/include/util/randomgen.h b/source/shared_lib/include/util/randomgen.h index 87422c99..92720be5 100644 --- a/source/shared_lib/include/util/randomgen.h +++ b/source/shared_lib/include/util/randomgen.h @@ -49,7 +49,8 @@ public: void setLastNumber(int value) { lastNumber = value; } std::string getLastCaller() const; - void clearLastCaller() { lastCaller.clear(); } + //void clearLastCaller() { lastCaller.clear(); } + void clearLastCaller() { } }; }}//end namespace diff --git a/source/shared_lib/sources/util/randomgen.cpp b/source/shared_lib/sources/util/randomgen.cpp index e1fff917..76a0d78c 100644 --- a/source/shared_lib/sources/util/randomgen.cpp +++ b/source/shared_lib/sources/util/randomgen.cpp @@ -56,7 +56,7 @@ int RandomGen::rand(string lastCaller) { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,lastNumber); this->lastNumber = (a*lastNumber + b) % m; - this->lastCaller.push_back(lastCaller); + //this->lastCaller.push_back(lastCaller); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,lastNumber); @@ -65,8 +65,10 @@ int RandomGen::rand(string lastCaller) { std::string RandomGen::getLastCaller() const { std::string result = ""; - for(unsigned int index = 0; index < lastCaller.size(); ++index) { - result += lastCaller[index] + " "; + if(lastCaller.empty() == false) { + for(unsigned int index = 0; index < lastCaller.size(); ++index) { + result += lastCaller[index] + " "; + } } return result; }