attempt to see if this fixes out of synch

This commit is contained in:
Mark Vejvoda 2013-05-23 23:52:46 +00:00
parent 3746bf4f11
commit a94787654d
3 changed files with 26 additions and 3 deletions

View File

@ -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());

View File

@ -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<float>(diagonalFactor);
truncateDecimal<float>(heightFactor);
float speedDenominator = (speedDivider * updateFPS);
truncateDecimal<float>(speedDenominator);
float newProgress = currentProgress;
truncateDecimal<float>(newProgress);
newProgress += ((speed * diagonalFactor * heightFactor) / speedDenominator);
truncateDecimal<float>(newProgress);
return newProgress;

View File

@ -724,6 +724,7 @@ public:
std::string toString() const;
bool needToUpdate();
float getUpdateProgress();
bool isLastStuckFrameWithinCurrentFrameTolerance();
inline uint32 getLastStuckFrame() const { return lastStuckFrame; }