try to cleanup possible memory issue

This commit is contained in:
Mark Vejvoda 2013-09-23 22:25:38 +00:00
parent 3a6544a257
commit f66a0834c9
4 changed files with 16 additions and 11 deletions

View File

@ -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";
}

View File

@ -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;

View File

@ -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

View File

@ -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;
}