diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index aee5f9b1d..e7f3e6419 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -454,6 +454,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, //RandomGen random; random.init(id); + random.setDisableLastCallerTracking(isNetworkCRCEnabled() == false); pathFindRefreshCellCount = random.randRange(10,20,intToStr(__LINE__)); if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) { @@ -646,8 +647,41 @@ void Unit::dumpMemoryList() { } #endif +bool Unit::isNetworkCRCEnabled() { + bool isNetworkCRCEnabled = false; + + if(game != NULL && game->getGameSettings() != NULL) { + if(isFlagType1BitEnabled(game->getGameSettings()->getFlagTypes1(),ft1_network_synch_checks_verbose) == true) { + isNetworkCRCEnabled = true; + } + else if(isFlagType1BitEnabled(game->getGameSettings()->getFlagTypes1(),ft1_network_synch_checks) == true) { + isNetworkCRCEnabled = true; + } + } + return isNetworkCRCEnabled; +} + +void Unit::clearNetworkCRCDecHpList() { + if(networkCRCDecHpList.empty() == false) { + networkCRCDecHpList.clear(); + } +} +void Unit::clearParticleInfo() { + if(networkCRCParticleInfoList.empty() == false) { + networkCRCParticleInfoList.clear(); + } +} + +void Unit::addNetworkCRCDecHp(string info) { + if(isNetworkCRCEnabled() == true) { + networkCRCDecHpList.push_back(info); + } +} + void Unit::logParticleInfo(string info) { - networkCRCParticleInfoList.push_back(info); + if(isNetworkCRCEnabled() == true) { + networkCRCParticleInfoList.push_back(info); + } } string Unit::getParticleInfo() const { string result = ""; @@ -4286,7 +4320,6 @@ std::string Unit::toString(bool crcMode) const { if(networkCRCParticleLogInfo != "") { result += "networkCRCParticleLogInfo = " + networkCRCParticleLogInfo + "\n"; } - result += "networkCRCParticleObserverLogInfo = " + networkCRCParticleObserverLogInfo + "\n"; 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 b7582f1e9..1a3f3c6ea 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -482,12 +482,8 @@ private: Vec2i lastHarvestedResourcePos; string networkCRCLogInfo; - string networkCRCParticleLogInfo; - - string networkCRCParticleObserverLogInfo; vector networkCRCDecHpList; - vector networkCRCParticleInfoList; public: @@ -787,25 +783,20 @@ public: void addAttackParticleSystem(ParticleSystem *ps); - void setNetworkCRCParticleLogInfo(string networkCRCParticleLogInfo) { this->networkCRCParticleLogInfo = networkCRCParticleLogInfo; } - void setNetworkCRCParticleObserverLogInfo(string networkCRCParticleObserverLogInfo) { this->networkCRCParticleObserverLogInfo = networkCRCParticleObserverLogInfo; } - - void clearNetworkCRCDecHpList() { networkCRCDecHpList.clear(); } - //void clearNetworkCRCDecHpList() { } - Checksum getCRC(); virtual void end(ParticleSystem *particleSystem); virtual void logParticleInfo(string info); - void clearParticleInfo() { networkCRCParticleInfoList.clear(); } - string getParticleInfo() const; - - void addNetworkCRCDecHp(string info) { networkCRCDecHpList.push_back(info); } + void setNetworkCRCParticleLogInfo(string networkCRCParticleLogInfo) { this->networkCRCParticleLogInfo = networkCRCParticleLogInfo; } + void clearParticleInfo(); + void addNetworkCRCDecHp(string info); + void clearNetworkCRCDecHpList(); private: - //void addNetworkCRCDecHp(string info) { } + bool isNetworkCRCEnabled(); string getNetworkCRCDecHpList() const; + string getParticleInfo() const; float computeHeight(const Vec2i &pos) const; void calculateXZRotation(); diff --git a/source/shared_lib/include/util/randomgen.h b/source/shared_lib/include/util/randomgen.h index 406d61573..00f225899 100644 --- a/source/shared_lib/include/util/randomgen.h +++ b/source/shared_lib/include/util/randomgen.h @@ -32,6 +32,7 @@ private: private: int lastNumber; std::vector lastCaller; + bool disableLastCallerTracking; int rand(std::string lastCaller); @@ -46,9 +47,9 @@ public: void setLastNumber(int value) { lastNumber = value; } std::string getLastCaller() const; - void clearLastCaller() { lastCaller.clear(); } - //void clearLastCaller() { } - void addLastCaller(std::string text) { lastCaller.push_back(text); } + void clearLastCaller(); + void addLastCaller(std::string text); + void setDisableLastCallerTracking(bool value) { disableLastCallerTracking = value; } }; }}//end namespace diff --git a/source/shared_lib/sources/util/randomgen.cpp b/source/shared_lib/sources/util/randomgen.cpp index 88f885137..731b310f3 100644 --- a/source/shared_lib/sources/util/randomgen.cpp +++ b/source/shared_lib/sources/util/randomgen.cpp @@ -33,6 +33,7 @@ const int RandomGen::b= 150889; RandomGen::RandomGen(){ lastNumber= 0; + disableLastCallerTracking = false; } void RandomGen::init(int seed){ @@ -56,6 +57,18 @@ std::string RandomGen::getLastCaller() const { } return result; } + +void RandomGen::clearLastCaller() { + if(lastCaller.empty() == false) { + lastCaller.clear(); + } +} +void RandomGen::addLastCaller(std::string text) { + if(disableLastCallerTracking == false) { + lastCaller.push_back(text); + } +} + int RandomGen::randRange(int min, int max,string lastCaller) { if(min > max) { char szBuf[8096]=""; @@ -71,9 +84,6 @@ int RandomGen::randRange(int min, int max,string lastCaller) { snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %d, max = %d, res = %d",__FILE__,__FUNCTION__,__LINE__,min,max,res); throw megaglest_runtime_error(szBuf); } - - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] min = %d, max = %d, res = %d\n",__FILE__,__FUNCTION__,__LINE__,min,max,res); - return res; } @@ -93,9 +103,6 @@ float RandomGen::randRange(float min, float max,string lastCaller) { snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %f, max = %f, res = %f",__FILE__,__FUNCTION__,__LINE__,min,max,res); throw megaglest_runtime_error(szBuf); } - - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] min = %f, max = %f, res = %f\n",__FILE__,__FUNCTION__,__LINE__,min,max,res); - return res; }