- added more crc capture data to track down oos

This commit is contained in:
Mark Vejvoda 2013-10-17 06:36:28 +00:00
parent 23963e537d
commit 83055456d2
5 changed files with 55 additions and 13 deletions

View File

@ -155,9 +155,13 @@ Vec2i UnitPathBasic::pop(bool removeFrontPos) {
return p;
}
std::string UnitPathBasic::toString() const {
std::string result = "unit path blockCount = " + intToStr(blockCount) + " pathQueue size = " + intToStr(pathQueue.size());
std::string result = "unit path blockCount = " + intToStr(blockCount) + "\npathQueue size = " + intToStr(pathQueue.size());
for(int idx = 0; idx < pathQueue.size(); ++idx) {
result += " index = " + intToStr(idx) + " " + pathQueue[idx].getString();
result += " index = " + intToStr(idx) + " value = " + pathQueue[idx].getString();
}
result += "\nlastPathCacheQueue size = " + intToStr(lastPathCacheQueue.size());
for(int idx = 0; idx < lastPathCacheQueue.size(); ++idx) {
result += " index = " + intToStr(idx) + " value = " + lastPathCacheQueue[idx].getString();
}
return result;
@ -209,6 +213,16 @@ void UnitPathBasic::loadGame(const XmlNode *rootNode) {
}
}
Checksum UnitPathBasic::getCRC() {
Checksum crcForPath;
crcForPath.addInt(blockCount);
crcForPath.addInt(pathQueue.size());
crcForPath.addInt(lastPathCacheQueue.size());
return crcForPath;
}
// =====================================================
// class UnitPath
// =====================================================
@ -3858,11 +3872,14 @@ bool Unit::isMeetingPointSettable() const {
return (type != NULL ? type->getMeetingPoint() : false);
}
int Unit::getFrameCount() const {
int frameCount = 0;
const Game *game = Renderer::getInstance().getGame();
uint32 Unit::getFrameCount() const {
uint32 frameCount = 0;
//const Game *game = Renderer::getInstance().getGame();
if(game != NULL && game->getWorld() != NULL) {
frameCount = game->getWorld()->getFrameCount();
int frameCountAsInt = game->getWorld()->getFrameCount();
if(frameCountAsInt >= 0) {
frameCount = frameCountAsInt;
}
}
return frameCount;
@ -4522,7 +4539,7 @@ void Unit::saveGame(XmlNode *rootNode) {
// bool ignoreCheckCommand;
unitNode->addAttribute("ignoreCheckCommand",intToStr(ignoreCheckCommand), mapTagReplacements);
// uint32 lastStuckFrame;
unitNode->addAttribute("lastStuckFrame",intToStr(lastStuckFrame), mapTagReplacements);
unitNode->addAttribute("lastStuckFrame",uIntToStr(lastStuckFrame), mapTagReplacements);
// Vec2i lastStuckPos;
unitNode->addAttribute("lastStuckPos",lastStuckPos.getString(), mapTagReplacements);
// uint32 lastPathfindFailedFrame;
@ -5136,6 +5153,10 @@ Checksum Unit::getCRC() {
//Map *map;
//UnitPathInterface *unitPath;
if(unitPath != NULL) {
uint32 crc = unitPath->getCRC().getSum();
crcForUnit.addBytes(&crc,sizeof(uint32));
}
//WaypointPath waypointPath;
if(consoleDebug) printf("#11 Unit: %d CRC: %u commands.size(): %ld\n",id,crcForUnit.getSum(),commands.size());
@ -5196,7 +5217,7 @@ Checksum Unit::getCRC() {
//bool ignoreCheckCommand;
//uint32 lastStuckFrame;
crcForUnit.addInt(lastStuckFrame);
crcForUnit.addUInt(lastStuckFrame);
//Vec2i lastStuckPos;
crcForUnit.addInt(lastStuckPos.x);
crcForUnit.addInt(lastStuckPos.y);

View File

@ -164,6 +164,8 @@ public:
virtual void loadGame(const XmlNode *rootNode) = 0;
virtual void clearCaches() = 0;
virtual Checksum getCRC() = 0;
};
class UnitPathBasic : public UnitPathInterface {
@ -214,6 +216,8 @@ public:
virtual void saveGame(XmlNode *rootNode);
virtual void loadGame(const XmlNode *rootNode);
virtual void clearCaches();
virtual Checksum getCRC();
};
// =====================================================
@ -275,6 +279,8 @@ public:
virtual void saveGame(XmlNode *rootNode) {};
virtual void loadGame(const XmlNode *rootNode) {};
virtual void clearCaches() {};
virtual Checksum getCRC() { return Checksum(); };
};
class WaypointPath : public list<Vec2i> {
@ -751,7 +757,7 @@ public:
bool isLastStuckFrameWithinCurrentFrameTolerance(bool evalMode);
inline uint32 getLastStuckFrame() const { return lastStuckFrame; }
inline void setLastStuckFrame(uint32 value) { lastStuckFrame = value; }
//inline void setLastStuckFrame(uint32 value) { lastStuckFrame = value; }
void setLastStuckFrameToCurrentFrame();
inline Vec2i getLastStuckPos() const { return lastStuckPos; }
@ -805,7 +811,7 @@ private:
void stopDamageParticles(bool force);
void startDamageParticles();
int getFrameCount() const;
uint32 getFrameCount() const;
void checkCustomizedParticleTriggers(bool force);
bool checkModelStateInfoForNewHpValue();
void checkUnitLevel();

View File

@ -701,8 +701,8 @@ void World::updateAllFactionUnits() {
int unitBlockCount = unit->getPath()->getBlockCount();
bool isStuck = unit->getPath()->isStuck();
bool isStuckWithinTolerance = unit->isLastStuckFrameWithinCurrentFrameTolerance(false);
uint32 lastStuckFrame = unit->getLastStuckFrame();
//bool isStuckWithinTolerance = unit->isLastStuckFrameWithinCurrentFrameTolerance(false);
//uint32 lastStuckFrame = unit->getLastStuckFrame();
if(unitUpdater.updateUnit(unit) == true) {
unitCountUpdated++;
@ -716,7 +716,8 @@ void World::updateAllFactionUnits() {
totalUnitsChecked++;
if(showPerfStats && chronoPerfUnit.getMillis() >= 10) {
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER " stuck: %d [%d] for unit:\n%sBEFORE unitBlockCount = %d, AFTER = %d, BEFORE lastStuckFrame = %u, AFTER: %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerfUnit.getMillis(),isStuck,isStuckWithinTolerance,unit->toString().c_str(),unitBlockCount,unit->getPath()->getBlockCount(),lastStuckFrame,unit->getLastStuckFrame());
//sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER " stuck: %d [%d] for unit:\n%sBEFORE unitBlockCount = %d, AFTER = %d, BEFORE lastStuckFrame = %u, AFTER: %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerfUnit.getMillis(),isStuck,isStuckWithinTolerance,unit->toString().c_str(),unitBlockCount,unit->getPath()->getBlockCount(),lastStuckFrame,unit->getLastStuckFrame());
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER " stuck: %d for unit:\n%sBEFORE unitBlockCount = %d, AFTER = %d, BEFORE , AFTER: %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerfUnit.getMillis(),isStuck,unit->toString().c_str(),unitBlockCount,unit->getPath()->getBlockCount(),unit->getLastStuckFrame());
perfList.push_back(perfBuf);
}

View File

@ -53,6 +53,7 @@ public:
uint32 addBytes(const void *_data, size_t _size);
void addString(const string &value);
uint32 addInt(const int32 &value);
uint32 addUInt(const uint32 &value);
uint32 addInt64(const int64 &value);
void addFile(const string &path);

View File

@ -128,6 +128,19 @@ uint32 Checksum::addInt(const int32 &value) {
return sum;
}
uint32 Checksum::addUInt(const uint32 &value) {
int8 byte = (value >> 0) & 0xFF;
addByte(byte);
byte = (value >> 8) & 0xFF;
addByte(byte);
byte = (value >> 16) & 0xFF;
addByte(byte);
byte = (value >> 24) & 0xFF;
addByte(byte);
return sum;
}
uint32 Checksum::addInt64(const int64 &value) {
int8 byte = (value >> 0) & 0xFF;
addByte(byte);