mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 21:51:17 +02:00
try to see if this makes disabled network crc checking more performance freindly
This commit is contained in:
@@ -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) {
|
||||
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";
|
||||
}
|
||||
|
@@ -482,12 +482,8 @@ private:
|
||||
Vec2i lastHarvestedResourcePos;
|
||||
|
||||
string networkCRCLogInfo;
|
||||
|
||||
string networkCRCParticleLogInfo;
|
||||
|
||||
string networkCRCParticleObserverLogInfo;
|
||||
vector<string> networkCRCDecHpList;
|
||||
|
||||
vector<string> 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();
|
||||
|
@@ -32,6 +32,7 @@ private:
|
||||
private:
|
||||
int lastNumber;
|
||||
std::vector<std::string> 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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user