try to see if this makes disabled network crc checking more performance freindly

This commit is contained in:
Mark Vejvoda
2013-10-20 20:06:19 +00:00
parent 260f770171
commit a17068165f
4 changed files with 58 additions and 26 deletions

View File

@@ -454,6 +454,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
//RandomGen random; //RandomGen random;
random.init(id); random.init(id);
random.setDisableLastCallerTracking(isNetworkCRCEnabled() == false);
pathFindRefreshCellCount = random.randRange(10,20,intToStr(__LINE__)); pathFindRefreshCellCount = random.randRange(10,20,intToStr(__LINE__));
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) { if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
@@ -646,8 +647,41 @@ void Unit::dumpMemoryList() {
} }
#endif #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) { void Unit::logParticleInfo(string info) {
networkCRCParticleInfoList.push_back(info); if(isNetworkCRCEnabled() == true) {
networkCRCParticleInfoList.push_back(info);
}
} }
string Unit::getParticleInfo() const { string Unit::getParticleInfo() const {
string result = ""; string result = "";
@@ -4286,7 +4320,6 @@ std::string Unit::toString(bool crcMode) const {
if(networkCRCParticleLogInfo != "") { if(networkCRCParticleLogInfo != "") {
result += "networkCRCParticleLogInfo = " + networkCRCParticleLogInfo + "\n"; result += "networkCRCParticleLogInfo = " + networkCRCParticleLogInfo + "\n";
} }
result += "networkCRCParticleObserverLogInfo = " + networkCRCParticleObserverLogInfo + "\n";
if(networkCRCDecHpList.empty() == false) { if(networkCRCDecHpList.empty() == false) {
result += "getNetworkCRCDecHpList() = " + getNetworkCRCDecHpList() + "\n"; result += "getNetworkCRCDecHpList() = " + getNetworkCRCDecHpList() + "\n";
} }

View File

@@ -482,12 +482,8 @@ private:
Vec2i lastHarvestedResourcePos; Vec2i lastHarvestedResourcePos;
string networkCRCLogInfo; string networkCRCLogInfo;
string networkCRCParticleLogInfo; string networkCRCParticleLogInfo;
string networkCRCParticleObserverLogInfo;
vector<string> networkCRCDecHpList; vector<string> networkCRCDecHpList;
vector<string> networkCRCParticleInfoList; vector<string> networkCRCParticleInfoList;
public: public:
@@ -787,25 +783,20 @@ public:
void addAttackParticleSystem(ParticleSystem *ps); 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(); Checksum getCRC();
virtual void end(ParticleSystem *particleSystem); virtual void end(ParticleSystem *particleSystem);
virtual void logParticleInfo(string info); virtual void logParticleInfo(string info);
void clearParticleInfo() { networkCRCParticleInfoList.clear(); } void setNetworkCRCParticleLogInfo(string networkCRCParticleLogInfo) { this->networkCRCParticleLogInfo = networkCRCParticleLogInfo; }
string getParticleInfo() const; void clearParticleInfo();
void addNetworkCRCDecHp(string info);
void addNetworkCRCDecHp(string info) { networkCRCDecHpList.push_back(info); } void clearNetworkCRCDecHpList();
private: private:
//void addNetworkCRCDecHp(string info) { } bool isNetworkCRCEnabled();
string getNetworkCRCDecHpList() const; string getNetworkCRCDecHpList() const;
string getParticleInfo() const;
float computeHeight(const Vec2i &pos) const; float computeHeight(const Vec2i &pos) const;
void calculateXZRotation(); void calculateXZRotation();

View File

@@ -32,6 +32,7 @@ private:
private: private:
int lastNumber; int lastNumber;
std::vector<std::string> lastCaller; std::vector<std::string> lastCaller;
bool disableLastCallerTracking;
int rand(std::string lastCaller); int rand(std::string lastCaller);
@@ -46,9 +47,9 @@ public:
void setLastNumber(int value) { lastNumber = value; } void setLastNumber(int value) { lastNumber = value; }
std::string getLastCaller() const; std::string getLastCaller() const;
void clearLastCaller() { lastCaller.clear(); } void clearLastCaller();
//void clearLastCaller() { } void addLastCaller(std::string text);
void addLastCaller(std::string text) { lastCaller.push_back(text); } void setDisableLastCallerTracking(bool value) { disableLastCallerTracking = value; }
}; };
}}//end namespace }}//end namespace

View File

@@ -33,6 +33,7 @@ const int RandomGen::b= 150889;
RandomGen::RandomGen(){ RandomGen::RandomGen(){
lastNumber= 0; lastNumber= 0;
disableLastCallerTracking = false;
} }
void RandomGen::init(int seed){ void RandomGen::init(int seed){
@@ -56,6 +57,18 @@ std::string RandomGen::getLastCaller() const {
} }
return result; 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) { int RandomGen::randRange(int min, int max,string lastCaller) {
if(min > max) { if(min > max) {
char szBuf[8096]=""; 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); 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); 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; 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); 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); 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; return res;
} }