diff --git a/mk/linux/analyzeWorldSynch.sh b/mk/linux/analyzeWorldSynch.sh index 705e6744..252cadab 100755 --- a/mk/linux/analyzeWorldSynch.sh +++ b/mk/linux/analyzeWorldSynch.sh @@ -2,7 +2,7 @@ MAX_SPLIT_SIZE_BYTES=75000000 -echo 'Max split file size = $MAX_SPLIT_SIZE_BYTES' +echo 'Max split file size = '"$MAX_SPLIT_SIZE_BYTES" echo 'Setting up temp folders...' diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index 6c7a456d..78e37a49 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -262,6 +262,9 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu //route a unit using A* algorithm TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout) { + Chrono chrono; + chrono.start(); + if(map == NULL) { throw runtime_error("map == NULL"); } @@ -273,6 +276,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout const Vec2i finalPos= computeNearestFreePos(unit, targetPos); + if(chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //path find algorithm //a) push starting pos into openNodes @@ -297,6 +302,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout Node *node = NULL; int64 lastPerfTick = 0; + if(chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + int whileLoopCount = 0; while(nodeLimitReached == false) { whileLoopCount++; @@ -349,6 +356,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout } } //while + if(chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + Node *lastNode= node; //if consumed all nodes find best node (to avoid strange behaviour) @@ -361,6 +370,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout } } + if(chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //check results of path finding TravelState ts = tsImpossible; UnitPathInterface *path= unit->getPath(); @@ -389,6 +400,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout openNodesList.size(),openPosList.size(),finalPos.getString().c_str(),targetPos.getString().c_str(),inBailout,ts); unit->logSynchData(__FILE__,__LINE__,szBuf); } + + if(chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } else { //on the way @@ -400,6 +413,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout currNode->prev->next= currNode; currNode= currNode->prev; } + + if(chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //store path path->clear(); @@ -408,6 +424,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout path->add(currNode->next->pos); } + if(chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) { char szBuf[4096]=""; sprintf(szBuf,"[Setting new path for unit] openNodesList.size() [%ld] openPosList.size() [%ld] finalPos [%s] targetPos [%s] inBailout [%d] ts [%d]", @@ -426,12 +444,16 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout sprintf(szBuf,"State: moving, cmd [%s] pos: %s dest pos: %s, Queue= %d",commandDesc.c_str(),unit->getPos().getString().c_str(), targetPos.getString().c_str(),path->getQueueCount()); unit->setCurrentUnitTitle(szBuf); } + + if(chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } openNodesList.clear(); openPosList.clear(); closedNodesList.clear(); + if(chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + return ts; } diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 565d4194..ae558d3f 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -780,6 +780,8 @@ int glestMain(int argc, char** argv) { std::pair(cfgMainKeys,cfgUserKeys), std::pair("glestkeys.ini","glestuserkeys.ini"), std::pair(true,false)); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(config.getBool("No2DMouseRendering","false") == false) { showCursor(false); @@ -794,12 +796,18 @@ int glestMain(int argc, char** argv) { if(config.getBool("noTeamColors","false") == true) { MeshCallbackTeamColor::noTeamColors = true; } - + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); // Over-ride default network command framecount //GameConstants::networkFramePeriod = config.getInt("NetworkFramePeriod",intToStr(GameConstants::networkFramePeriod).c_str()); //float pingTime = Socket::getAveragePingMS("soft-haus.com"); //printf("Ping time = %f\n",pingTime); + + Lang &lang= Lang::getInstance(); + lang.loadStrings(config.getString("Lang")); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); program= new Program(); @@ -1125,7 +1133,22 @@ __try { } __except(stackdumper(0, GetExceptionInformation()), EXCEPTION_CONTINUE_SEARCH) { return 0; } #endif } - + }}//end namespace -MAIN_FUNCTION(Glest::Game::glestMainWrapper) +MAIN_FUNCTION(Glest::Game::glestMainWrapper) + +/* +int main(int argc, char *argv[]) +{ + if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { + std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; + return 1; + } + atexit(SDL_Quit); + SDL_EnableUNICODE(1); + int result = Glest::Game::glestMainWrapper(argc, argv); + return result; +} +*/ + diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index a84e3e75..f4c91b90 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -382,7 +382,7 @@ void Program::setState(ProgramState *programState, bool cleanupOldState) programState->setStartXY(X,Y); SDL_PumpEvents(); - + showCursor(true); SDL_PumpEvents(); sleep(0); @@ -505,7 +505,7 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){ //lang Lang &lang= Lang::getInstance(); - lang.loadStrings(config.getString("Lang")); + //lang.loadStrings(config.getString("Lang")); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 59da6a3b..5f0e16e9 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -175,11 +175,16 @@ void UnitUpdater::updateUnit(Unit *unit) { //VERY IMPORTANT: compute next state depending on the first order of the list void UnitUpdater::updateUnitCommand(Unit *unit) { + Chrono chrono; + chrono.start(); + //if unit has command process it if(unit->anyCommand()) { unit->getCurrCommand()->getCommandType()->update(this, unit); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //if no commands stop and add stop command if(unit->anyCommand() == false && unit->isOperative()) { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -190,17 +195,24 @@ void UnitUpdater::updateUnitCommand(Unit *unit) { unit->giveCommand(new Command(unit->getType()->getFirstCtOfClass(ccStop))); } } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== updateStop ==================== void UnitUpdater::updateStop(Unit *unit) { - Command *command= unit->getCurrCommand(); + Chrono chrono; + chrono.start(); + + Command *command= unit->getCurrCommand(); const StopCommandType *sct = static_cast(command->getCommandType()); Unit *sighted; unit->setCurrSkill(sct->getStopSkillType()); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //we can attack any unit => attack it if(unit->getType()->hasSkillClass(scAttack)) { int cmdTypeCount = unit->getType()->getCommandTypeCount(); @@ -228,21 +240,34 @@ void UnitUpdater::updateStop(Unit *unit) { } } } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } //see any unit and cant attack it => run else if(unit->getType()->hasCommandClass(ccMove)) { + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(attackerOnSight(unit, &sighted)) { + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + Vec2i escapePos= unit->getPos()*2-sighted->getPos(); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); unit->giveCommand(new Command(unit->getType()->getFirstCtOfClass(ccMove), escapePos)); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== updateMove ==================== void UnitUpdater::updateMove(Unit *unit) { + Chrono chrono; + chrono.start(); + Command *command= unit->getCurrCommand(); const MoveCommandType *mct= static_cast(command->getCommandType()); @@ -254,6 +279,8 @@ void UnitUpdater::updateMove(Unit *unit) { unit->logSynchData(__FILE__,__LINE__,szBuf); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + TravelState tsValue = tsImpossible; switch(this->game->getGameSettings()->getPathFinderType()) { case pfBasic: @@ -266,6 +293,8 @@ void UnitUpdater::updateMove(Unit *unit) { throw runtime_error("detected unsupported pathfinder type!"); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + switch (tsValue) { case tsMoving: unit->setCurrSkill(mct->getMoveSkillType()); @@ -281,16 +310,23 @@ void UnitUpdater::updateMove(Unit *unit) { default: unit->finishCommand(); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== updateAttack ==================== void UnitUpdater::updateAttack(Unit *unit) { + Chrono chrono; + chrono.start(); + Command *command= unit->getCurrCommand(); const AttackCommandType *act= static_cast(command->getCommandType()); Unit *target= NULL; + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //if found if(attackableOnRange(unit, &target, act->getAttackSkillType())) { if(unit->getEp()>=act->getAttackSkillType()->getEpCost()) { @@ -300,6 +336,8 @@ void UnitUpdater::updateAttack(Unit *unit) { else { unit->setCurrSkill(scStop); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } else { //compute target pos @@ -321,6 +359,8 @@ void UnitUpdater::updateAttack(Unit *unit) { unit->logSynchData(__FILE__,__LINE__,szBuf); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + TravelState tsValue = tsImpossible; switch(this->game->getGameSettings()->getPathFinderType()) { case pfBasic: @@ -333,6 +373,8 @@ void UnitUpdater::updateAttack(Unit *unit) { throw runtime_error("detected unsupported pathfinder type!"); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //if unit arrives destPos order has ended switch (tsValue){ case tsMoving: @@ -346,14 +388,21 @@ void UnitUpdater::updateAttack(Unit *unit) { default: unit->finishCommand(); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== updateAttackStopped ==================== -void UnitUpdater::updateAttackStopped(Unit *unit){ - Command *command= unit->getCurrCommand(); +void UnitUpdater::updateAttackStopped(Unit *unit) { + Chrono chrono; + chrono.start(); + + Command *command= unit->getCurrCommand(); const AttackStoppedCommandType *asct= static_cast(command->getCommandType()); Unit *enemy; @@ -361,15 +410,20 @@ void UnitUpdater::updateAttackStopped(Unit *unit){ unit->setCurrSkill(asct->getAttackSkillType()); unit->setTarget(enemy); } - else{ + else { unit->setCurrSkill(asct->getStopSkillType()); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== updateBuild ==================== void UnitUpdater::updateBuild(Unit *unit) { + Chrono chrono; + chrono.start(); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); Command *command= unit->getCurrCommand(); @@ -384,6 +438,8 @@ void UnitUpdater::updateBuild(Unit *unit) { //if not building const UnitType *ut= command->getUnitType(); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + TravelState tsValue = tsImpossible; switch(this->game->getGameSettings()->getPathFinderType()) { case pfBasic: @@ -530,6 +586,8 @@ void UnitUpdater::updateBuild(Unit *unit) { } break; } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } else { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] tsArrived unit = %s\n",__FILE__,__FUNCTION__,__LINE__,unit->toString().c_str()); @@ -572,13 +630,20 @@ void UnitUpdater::updateBuild(Unit *unit) { gameCamera->getPos()); } } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== updateHarvest ==================== void UnitUpdater::updateHarvest(Unit *unit) { + Chrono chrono; + chrono.start(); + Command *command= unit->getCurrCommand(); const HarvestCommandType *hct= static_cast(command->getCommandType()); Vec2i targetPos(-1); @@ -586,6 +651,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { TravelState tsValue = tsImpossible; UnitPathInterface *path= unit->getPath(); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(unit->getCurrSkill()->getClass() != scHarvest) { //if not working if(unit->getLoadCount() == 0) { @@ -595,6 +662,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { //if can harvest dest. pos bool canHarvestDestPos = false; + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + switch(this->game->getGameSettings()->getPathFinderType()) { case pfBasic: { @@ -613,6 +682,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { throw runtime_error("detected unsupported pathfinder type!"); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if (canHarvestDestPos == true) { unit->setLastHarvestResourceTarget(NULL); @@ -635,11 +706,15 @@ void UnitUpdater::updateHarvest(Unit *unit) { default: throw runtime_error("detected unsupported pathfinder type!"); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } } if(canHarvestDestPos == false) { unit->setLastHarvestResourceTarget(&targetPos); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) { char szBuf[4096]=""; sprintf(szBuf,"[updateHarvest] unit->getPos() [%s] command->getPos() [%s]", @@ -667,6 +742,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { throw runtime_error("detected unsupported pathfinder type!"); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + // If the unit is blocked or Even worse 'stuck' then try to // find the same resource type elsewhere, but close by if((wasStuck == true || tsValue == tsBlocked) && unit->isAlive() == true) { @@ -711,6 +788,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { throw runtime_error("detected unsupported pathfinder type!"); } } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } if(canHarvestDestPos == false) { @@ -748,6 +827,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { } } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(wasStuck == true) { //if can't harvest, search for another resource unit->setCurrSkill(scStop); @@ -765,9 +846,16 @@ void UnitUpdater::updateHarvest(Unit *unit) { if(searchForResource(unit, hct) == false) { unit->finishCommand(); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } else { + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //if loaded, return to store Unit *store= world->nearestStore(unit->getPos(), unit->getFaction()->getIndex(), unit->getLoadType()); if(store!=NULL) { @@ -791,6 +879,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { throw runtime_error("detected unsupported pathfinder type!"); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + switch(tsValue) { case tsMoving: unit->setCurrSkill(hct->getMoveLoadedSkillType()); @@ -818,6 +908,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { unit->setCurrSkill(scStop); unit->setLoadCount(0); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } else { unit->finishCommand(); @@ -828,6 +920,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { //if working //unit->setLastHarvestResourceTarget(NULL); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + const Vec2i unitTargetPos = unit->getTargetPos(); SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unitTargetPos)); Resource *r= sc->getResource(); @@ -837,6 +931,8 @@ void UnitUpdater::updateHarvest(Unit *unit) { // hct has changed to a different harvest command. unit->setCurrSkill(hct->getStopLoadedSkillType()); // this is actually the wrong animation unit->getPath()->clear(); + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } else { @@ -873,14 +969,17 @@ void UnitUpdater::updateHarvest(Unit *unit) { unit->getPath()->clear(); } } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } } else { //if there is no resource, just stop unit->setCurrSkill(hct->getStopLoadedSkillType()); } - } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } void UnitUpdater::SwapActiveCommand(Unit *unitSrc, Unit *unitDest) { @@ -978,6 +1077,8 @@ Unit * UnitUpdater::findPeerUnitBuilder(Unit *unit) { // ==================== updateRepair ==================== void UnitUpdater::updateRepair(Unit *unit) { + Chrono chrono; + chrono.start(); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] unit = %p\n",__FILE__,__FUNCTION__,__LINE__,unit); @@ -999,6 +1100,8 @@ void UnitUpdater::updateRepair(Unit *unit) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] unit to repair [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,repaired->getFullName().c_str(),repaired->getId()); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + // Check if the 'repaired' unit is actually the peer unit in a multi-build? Unit *peerUnitBuilder = findPeerUnitBuilder(unit); @@ -1006,6 +1109,8 @@ void UnitUpdater::updateRepair(Unit *unit) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] unit peer [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,peerUnitBuilder->getFullName().c_str(),peerUnitBuilder->getId()); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + // Esnure we have the right unit to repair if(peerUnitBuilder != NULL) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] peerUnitBuilder = %p\n",__FILE__,__FUNCTION__,__LINE__,peerUnitBuilder); @@ -1019,6 +1124,8 @@ void UnitUpdater::updateRepair(Unit *unit) { bool nextToRepaired = repaired != NULL && map->isNextTo(unit->getPos(), repaired); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + peerUnitBuilder = NULL; if(repaired == NULL) { peerUnitBuilder = findPeerUnitBuilder(unit); @@ -1059,6 +1166,8 @@ void UnitUpdater::updateRepair(Unit *unit) { return; } } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } } else { @@ -1106,6 +1215,8 @@ void UnitUpdater::updateRepair(Unit *unit) { unit->logSynchData(__FILE__,__LINE__,szBuf); } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + TravelState ts; switch(this->game->getGameSettings()->getPathFinderType()) { case pfBasic: @@ -1129,6 +1240,8 @@ void UnitUpdater::updateRepair(Unit *unit) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ts = %d\n",__FILE__,__FUNCTION__,__LINE__,ts); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + switch(ts) { case tsMoving: SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] tsMoving\n",__FILE__,__FUNCTION__,__LINE__); @@ -1162,6 +1275,8 @@ void UnitUpdater::updateRepair(Unit *unit) { unit->setCurrSkill(scStop); unit->finishCommand(); + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } } else { @@ -1192,14 +1307,20 @@ void UnitUpdater::updateRepair(Unit *unit) { repaired->born(); scriptManager->onUnitCreated(repaired); } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== updateProduce ==================== -void UnitUpdater::updateProduce(Unit *unit){ +void UnitUpdater::updateProduce(Unit *unit) { + Chrono chrono; + chrono.start(); + Command *command= unit->getCurrCommand(); const ProduceCommandType *pct= static_cast(command->getCommandType()); Unit *produced; @@ -1208,8 +1329,11 @@ void UnitUpdater::updateProduce(Unit *unit){ //if not producing unit->setCurrSkill(pct->getProduceSkillType()); } - else{ + else { unit->update2(); + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(unit->getProgress2()>pct->getProduced()->getProductionTime()){ unit->finishCommand(); unit->setCurrSkill(scStop); @@ -1230,6 +1354,8 @@ void UnitUpdater::updateProduce(Unit *unit){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to place unit for unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,produced->toString().c_str()); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //place unit creates the unit if(!world->placeUnit(unit->getCenteredPos(), 10, produced)) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] COULD NOT PLACE UNIT for unitID [%d]\n",__FILE__,__FUNCTION__,__LINE__,produced->getId()); @@ -1246,15 +1372,23 @@ void UnitUpdater::updateProduce(Unit *unit){ produced->giveCommand(new Command(ct, unit->getMeetingPos())); } scriptManager->onUnitCreated(produced); + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } } } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== updateUpgrade ==================== -void UnitUpdater::updateUpgrade(Unit *unit){ +void UnitUpdater::updateUpgrade(Unit *unit) { + Chrono chrono; + chrono.start(); + + Command *command= unit->getCurrCommand(); const UpgradeCommandType *uct= static_cast(command->getCommandType()); @@ -1271,12 +1405,17 @@ void UnitUpdater::updateUpgrade(Unit *unit){ unit->getFaction()->finishUpgrade(uct->getProducedUpgrade()); } } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== updateMorph ==================== void UnitUpdater::updateMorph(Unit *unit){ - Command *command= unit->getCurrCommand(); + Chrono chrono; + chrono.start(); + + Command *command= unit->getCurrCommand(); const MorphCommandType *mct= static_cast(command->getCommandType()); if(unit->getCurrSkill()->getClass()!=scMorph){ @@ -1339,6 +1478,8 @@ void UnitUpdater::updateMorph(Unit *unit){ } } + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } // ==================== PRIVATE ==================== diff --git a/source/shared_lib/include/platform/posix/socket.h b/source/shared_lib/include/platform/posix/socket.h index 5daa1a91..e83fc687 100644 --- a/source/shared_lib/include/platform/posix/socket.h +++ b/source/shared_lib/include/platform/posix/socket.h @@ -25,7 +25,7 @@ using std::string; #ifdef WIN32 - #include + #include typedef SOCKET PLATFORM_SOCKET; #else #include diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index f3546fa9..d5856532 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -47,13 +47,14 @@ LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){ 0); //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - + MINIDUMP_EXCEPTION_INFORMATION lExceptionInformation; lExceptionInformation.ThreadId= GetCurrentThreadId(); lExceptionInformation.ExceptionPointers= pointers; lExceptionInformation.ClientPointers= false; - + +#if defined(__WIN32__) && !defined(__GNUC__) MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), @@ -66,7 +67,7 @@ LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){ //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); thisPointer->handle(); - +#endif //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); return EXCEPTION_EXECUTE_HANDLER;