- changed debug world synch formatting so on xplatform we don't have issues with filename and other header tag items

This commit is contained in:
Mark Vejvoda 2010-12-01 23:38:03 +00:00
parent 42ebe42155
commit 8deec8d518
6 changed files with 72 additions and 61 deletions

View File

@ -87,9 +87,9 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [findPath] unit->getPos() [%s] finalPos [%s]",
__FILE__,__FUNCTION__,__LINE__,unit->getPos().getString().c_str(),finalPos.getString().c_str());
unit->logSynchData(szBuf);
sprintf(szBuf,"[findPath] unit->getPos() [%s] finalPos [%s]",
unit->getPos().getString().c_str(),finalPos.getString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
//route cache
@ -186,9 +186,9 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [attempting to BAIL OUT] finalPos [%s] ts [%d]",
__FILE__,__FUNCTION__,__LINE__,finalPos.getString().c_str(),ts);
unit->logSynchData(szBuf);
sprintf(szBuf,"[attempting to BAIL OUT] finalPos [%s] ts [%d]",
finalPos.getString().c_str(),ts);
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
if(wasStuck != NULL) {
@ -204,9 +204,9 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [attempting to BAIL OUT] finalPos [%s] newFinalPos [%s] ts [%d] canUnitMove [%d]",
__FILE__,__FUNCTION__,__LINE__,finalPos.getString().c_str(),newFinalPos.getString().c_str(),ts,canUnitMove);
unit->logSynchData(szBuf);
sprintf(szBuf,"[attempting to BAIL OUT] finalPos [%s] newFinalPos [%s] ts [%d] canUnitMove [%d]",
finalPos.getString().c_str(),newFinalPos.getString().c_str(),ts,canUnitMove);
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
if(canUnitMove) {
@ -385,9 +385,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [path for unit BLOCKED] openNodesList.size() [%ld] openPosList.size() [%ld] finalPos [%s] targetPos [%s] inBailout [%d] ts [%d]",
__FILE__,__FUNCTION__,__LINE__,openNodesList.size(),openPosList.size(),finalPos.getString().c_str(),targetPos.getString().c_str(),inBailout,ts);
unit->logSynchData(szBuf);
sprintf(szBuf,"[path for unit BLOCKED] openNodesList.size() [%ld] openPosList.size() [%ld] finalPos [%s] targetPos [%s] inBailout [%d] ts [%d]",
openNodesList.size(),openPosList.size(),finalPos.getString().c_str(),targetPos.getString().c_str(),inBailout,ts);
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
}
else {
@ -410,9 +410,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [Setting new path for unit] openNodesList.size() [%ld] openPosList.size() [%ld] finalPos [%s] targetPos [%s] inBailout [%d] ts [%d]",
__FILE__,__FUNCTION__,__LINE__,openNodesList.size(),openPosList.size(),finalPos.getString().c_str(),targetPos.getString().c_str(),inBailout,ts);
unit->logSynchData(szBuf);
sprintf(szBuf,"[Setting new path for unit] openNodesList.size() [%ld] openPosList.size() [%ld] finalPos [%s] targetPos [%s] inBailout [%d] ts [%d]",
openNodesList.size(),openPosList.size(),finalPos.getString().c_str(),targetPos.getString().c_str(),inBailout,ts);
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled == true) {

View File

@ -636,12 +636,13 @@ void Faction::addResourceTargetToCache(const Vec2i &pos,bool incrementUseCounter
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [addResourceTargetToCache] pos [%s]cacheResourceTargetList.size() [%ld]",
__FILE__,__FUNCTION__,__LINE__,pos.getString().c_str(),cacheResourceTargetList.size());
sprintf(szBuf,"[addResourceTargetToCache] pos [%s]cacheResourceTargetList.size() [%ld]",
pos.getString().c_str(),cacheResourceTargetList.size());
//unit->logSynchData(szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"----------------------------------- START [%d] ------------------------------------------------\n",getFrameCount());
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"[%s::%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s\n",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"------------------------------------ END [%d] -------------------------------------------------\n",getFrameCount());
}
}
@ -658,12 +659,13 @@ void Faction::removeResourceTargetFromCache(const Vec2i &pos) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [removeResourceTargetFromCache] pos [%s]cacheResourceTargetList.size() [%ld]",
__FILE__,__FUNCTION__,__LINE__,pos.getString().c_str(),cacheResourceTargetList.size());
sprintf(szBuf,"[removeResourceTargetFromCache] pos [%s]cacheResourceTargetList.size() [%ld]",
pos.getString().c_str(),cacheResourceTargetList.size());
//unit->logSynchData(szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"----------------------------------- START [%d] ------------------------------------------------\n",getFrameCount());
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"[%s::%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s\n",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"------------------------------------ END [%d] -------------------------------------------------\n",getFrameCount());
}
}
@ -770,10 +772,10 @@ Vec2i Faction::getClosestResourceTypeTargetFromCache(Unit *unit, const ResourceT
if(deleteList.size() > 0) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [cleaning old resource targets] deleteList.size() [%ld] cacheResourceTargetList.size() [%ld] result [%s]",
__FILE__,__FUNCTION__,__LINE__,deleteList.size(),cacheResourceTargetList.size(),result.getString().c_str());
sprintf(szBuf,"[cleaning old resource targets] deleteList.size() [%ld] cacheResourceTargetList.size() [%ld] result [%s]",
deleteList.size(),cacheResourceTargetList.size(),result.getString().c_str());
unit->logSynchData(szBuf);
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
cleanupResourceTypeTargetCache(&deleteList);
@ -903,11 +905,12 @@ void Faction::cleanupResourceTypeTargetCache(std::vector<Vec2i> *deleteListPtr)
if(deleteList.size() > 0) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [cleaning old resource targets] deleteList.size() [%ld] cacheResourceTargetList.size() [%ld], needToCleanup [%d]",
__FILE__,__FUNCTION__,__LINE__,deleteList.size(),cacheResourceTargetList.size(),needToCleanup);
sprintf(szBuf,"[cleaning old resource targets] deleteList.size() [%ld] cacheResourceTargetList.size() [%ld], needToCleanup [%d]",
deleteList.size(),cacheResourceTargetList.size(),needToCleanup);
//unit->logSynchData(szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"----------------------------------- START [%d] ------------------------------------------------\n",getFrameCount());
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"[%s::%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s\n",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"------------------------------------ END [%d] -------------------------------------------------\n",getFrameCount());
}

View File

@ -241,7 +241,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, const UnitType
livingUnits.insert(id);
livingUnitsp.insert(this);
logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
logSynchData(__FILE__,__LINE__);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -597,7 +597,7 @@ void Unit::setPos(const Vec2i &pos){
// Attempt to improve performance
this->exploreCells();
logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
logSynchData(__FILE__,__LINE__);
}
void Unit::setTargetPos(const Vec2i &targetPos){
@ -617,7 +617,7 @@ void Unit::setTargetPos(const Vec2i &targetPos){
this->targetPos= targetPos;
logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
logSynchData(__FILE__,__LINE__);
}
void Unit::setVisible(const bool visible) {
@ -1667,12 +1667,12 @@ void Unit::startDamageParticles(){
void Unit::setTargetVec(const Vec3f &targetVec) {
this->targetVec= targetVec;
logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
logSynchData(__FILE__,__LINE__);
}
void Unit::setMeetingPos(const Vec2i &meetingPos) {
this->meetingPos= meetingPos;
logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
logSynchData(__FILE__,__LINE__);
}
bool Unit::isMeetingPointSettable() const {
@ -1706,12 +1706,11 @@ void Unit::exploreCells() {
}
}
void Unit::logSynchData(string source) {
void Unit::logSynchData(string file,int line,string source) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[1024]="";
sprintf(szBuf,
//"Unit = %d [%s] [%s] pos = %s, lastPos = %s, targetPos = %s, targetVec = %s, meetingPos = %s, lastRotation [%f], targetRotation [%f], rotation [%f], progress [%f], progress2 [%f]\n",
"FrameCount [%d] Unit = %d [%s][%s] pos = %s, lastPos = %s, targetPos = %s, targetVec = %s, meetingPos = %s, lastRotation [%f], targetRotation [%f], rotation [%f], progress [%f], progress2 [%d]\nUnit Path [%s]\n",
getFrameCount(),
id,
@ -1730,12 +1729,20 @@ void Unit::logSynchData(string source) {
progress2,
(unitPath != NULL ? unitPath->toString().c_str() : "NULL"));
if(lastSynchDataString != string(szBuf) || lastSource != source) {
if( lastSynchDataString != string(szBuf) ||
lastFile != file ||
lastLine != line ||
lastSource != source) {
lastSynchDataString = string(szBuf);
lastFile = file;
lastSource = source;
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"----------------------------------- START [%d] ------------------------------------------------\n",getFrameCount());
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s %s",source.c_str(),szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"[%s::%d]\n",extractFileFromDirectoryPath(file).c_str(),line);
if(source != "") {
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s ",source.c_str());
}
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s\n",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"------------------------------------ END [%d] -------------------------------------------------\n",getFrameCount());
}
}
@ -1799,9 +1806,8 @@ void Unit::cleanupOldBadHarvestPos() {
if(purgeList.size() > 0) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [cleaning old bad harvest targets] purgeList.size() [%ld]",
__FILE__,__FUNCTION__,__LINE__,purgeList.size());
logSynchData(szBuf);
sprintf(szBuf,"[cleaning old bad harvest targets] purgeList.size() [%ld]",purgeList.size());
logSynchData(__FILE__,__LINE__,szBuf);
for(int i = 0; i < purgeList.size(); ++i) {
const Vec2i &item = purgeList[i];

View File

@ -286,6 +286,8 @@ private:
CardinalDir modelFacing;
std::string lastSynchDataString;
std::string lastFile;
int lastLine;
std::string lastSource;
int lastRenderFrame;
bool visible;
@ -465,7 +467,7 @@ public:
std::pair<Vec2i,std::vector<Vec2i> > getCurrentTargetPathTaken() const { return currentTargetPathTaken; }
void addCurrentTargetPathTakenCell(const Vec2i &target,const Vec2i &cell);
void logSynchData(string source="");
void logSynchData(string file,int line,string source="");
std::string toString() const;
private:

View File

@ -327,9 +327,9 @@ bool Map::isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resour
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [found peer harvest pos] pos [%s] resourcePos [%s] unit->getFaction()->getCacheResourceTargetListSize() [%d]",
__FILE__,__FUNCTION__,__LINE__,pos.getString().c_str(),resourcePos.getString().c_str(),unit->getFaction()->getCacheResourceTargetListSize());
unit->logSynchData(szBuf);
sprintf(szBuf,"[found peer harvest pos] pos [%s] resourcePos [%s] unit->getFaction()->getCacheResourceTargetListSize() [%d]",
pos.getString().c_str(),resourcePos.getString().c_str(),unit->getFaction()->getCacheResourceTargetListSize());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
if(unit->getPos().dist(resourcePos) <= size) {

View File

@ -250,8 +250,8 @@ void UnitUpdater::updateMove(Unit *unit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [updateMove] pos [%s] cmd [%s]",__FILE__,__FUNCTION__,__LINE__,pos.getString().c_str(),command->toString().c_str());
unit->logSynchData(szBuf);
sprintf(szBuf,"[updateMove] pos [%s] cmd [%s]",pos.getString().c_str(),command->toString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
TravelState tsValue = tsImpossible;
@ -316,9 +316,9 @@ void UnitUpdater::updateAttack(Unit *unit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [updateAttack] pos [%s] unit->getPos() [%s]",__FILE__,__FUNCTION__,__LINE__,
sprintf(szBuf,"[updateAttack] pos [%s] unit->getPos() [%s]",
pos.getString().c_str(),unit->getPos().getString().c_str());
unit->logSynchData(szBuf);
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
TravelState tsValue = tsImpossible;
@ -394,9 +394,9 @@ void UnitUpdater::updateBuild(Unit *unit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [updateBuild] unit->getPos() [%s] command->getPos() [%s] buildPos [%s]",
__FILE__,__FUNCTION__,__LINE__,unit->getPos().getString().c_str(),command->getPos().getString().c_str(),buildPos.getString().c_str());
unit->logSynchData(szBuf);
sprintf(szBuf,"[updateBuild] unit->getPos() [%s] command->getPos() [%s] buildPos [%s]",
unit->getPos().getString().c_str(),command->getPos().getString().c_str(),buildPos.getString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
tsValue = pathFinder->findPath(unit, buildPos);
@ -642,9 +642,9 @@ void UnitUpdater::updateHarvest(Unit *unit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [updateHarvest] unit->getPos() [%s] command->getPos() [%s]",
__FILE__,__FUNCTION__,__LINE__,unit->getPos().getString().c_str(),command->getPos().getString().c_str());
unit->logSynchData(szBuf);
sprintf(szBuf,"[updateHarvest] unit->getPos() [%s] command->getPos() [%s]",
unit->getPos().getString().c_str(),command->getPos().getString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
//if not continue walking
@ -721,9 +721,9 @@ void UnitUpdater::updateHarvest(Unit *unit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [updateHarvest #2] unit->getPos() [%s] command->getPos() [%s] targetPos [%s]",
__FILE__,__FUNCTION__,__LINE__,unit->getPos().getString().c_str(),command->getPos().getString().c_str(),targetPos.getString().c_str());
unit->logSynchData(szBuf);
sprintf(szBuf,"[updateHarvest #2] unit->getPos() [%s] command->getPos() [%s] targetPos [%s]",
unit->getPos().getString().c_str(),command->getPos().getString().c_str(),targetPos.getString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
wasStuck = false;
@ -774,9 +774,9 @@ void UnitUpdater::updateHarvest(Unit *unit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [updateHarvest #3] unit->getPos() [%s] store->getCenteredPos() [%s]",
__FILE__,__FUNCTION__,__LINE__,unit->getPos().getString().c_str(),store->getCenteredPos().getString().c_str());
unit->logSynchData(szBuf);
sprintf(szBuf,"[updateHarvest #3] unit->getPos() [%s] store->getCenteredPos() [%s]",
unit->getPos().getString().c_str(),store->getCenteredPos().getString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
TravelState tsValue = tsImpossible;
@ -1102,8 +1102,8 @@ void UnitUpdater::updateRepair(Unit *unit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[%s::%s Line: %d] [updateRepair] unit->getPos() [%s] command->getPos()() [%s] repairPos [%s]",__FILE__,__FUNCTION__,__LINE__,unit->getPos().getString().c_str(),command->getPos().getString().c_str(),repairPos.getString().c_str());
unit->logSynchData(szBuf);
sprintf(szBuf,"[updateRepair] unit->getPos() [%s] command->getPos()() [%s] repairPos [%s]",unit->getPos().getString().c_str(),command->getPos().getString().c_str(),repairPos.getString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
TravelState ts;