diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 205a54ad..92df770d 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -386,6 +386,15 @@ void FactionThread::execute() { if(minorDebugPerformance && (chrono.getMillis() - elapsed2) >= 1) printf("Faction [%d - %s] #2-unit threaded updates on frame: %d for [%d] unit # %d, unitCount = %d, took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName().c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),j,unitCount,(long long int)chrono.getMillis() - elapsed2); } + else { + if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) { + float updateProgressValue = unit->getUpdateProgress(); + char szBuf[8096]=""; + snprintf(szBuf,8096,"unit->needToUpdate() returned: %d updateProgressValue: %f",update,updateProgressValue); + unit->logSynchDataThreaded(__FILE__,__LINE__,szBuf); + } + + } } if(minorDebugPerformance && chrono.getMillis() >= 1) printf("Faction [%d - %s] threaded updates on frame: %d for [%d] units took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName().c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),(long long int)chrono.getMillis()); diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index c1935c17..2ef0f1ab 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -1860,7 +1860,7 @@ const CommandType *Unit::computeCommandType(const Vec2i &pos, const Unit *target } -bool Unit::needToUpdate() { +float Unit::getUpdateProgress() { //assert(progress <= 1.f); if(progress > 1.f) { char szBuf[8096]=""; @@ -1874,7 +1874,7 @@ bool Unit::needToUpdate() { throw megaglest_runtime_error(szBuf); } - bool return_value = false; + float newProgress = progress; if(currSkill->getClass() != scDie) { //speed int speed = currSkill->getTotalSpeed(&totalUpgrade); @@ -1920,9 +1920,17 @@ bool Unit::needToUpdate() { //float speedDenominator = (speedDivider * game->getWorld()->getUpdateFps(this->getFactionIndex())); //float newProgress = progress; //newProgress += (speed * diagonalFactor * heightFactor) / speedDenominator; - float newProgress = getUpdatedProgress(progress, game->getWorld()->getUpdateFps(this->getFactionIndex()), + newProgress = getUpdatedProgress(progress, game->getWorld()->getUpdateFps(this->getFactionIndex()), speed, diagonalFactor, heightFactor); + } + return newProgress; +} + +bool Unit::needToUpdate() { + bool return_value = false; + if(currSkill->getClass() != scDie) { + float newProgress = getUpdateProgress(); if(newProgress >= 1.f) { return_value = true; } @@ -1933,8 +1941,13 @@ bool Unit::needToUpdate() { float Unit::getUpdatedProgress(float currentProgress, int updateFPS, int speed, float diagonalFactor, float heightFactor) { + truncateDecimal(diagonalFactor); + truncateDecimal(heightFactor); + float speedDenominator = (speedDivider * updateFPS); + truncateDecimal(speedDenominator); float newProgress = currentProgress; + truncateDecimal(newProgress); newProgress += ((speed * diagonalFactor * heightFactor) / speedDenominator); truncateDecimal(newProgress); return newProgress; diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 8185f666..86efb65c 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -724,6 +724,7 @@ public: std::string toString() const; bool needToUpdate(); + float getUpdateProgress(); bool isLastStuckFrameWithinCurrentFrameTolerance(); inline uint32 getLastStuckFrame() const { return lastStuckFrame; }