attempt to fix join game out of synch (and added more logging to track further if needed)

This commit is contained in:
Mark Vejvoda 2013-06-02 05:57:51 +00:00
parent 9c4b469d09
commit ee271467d0
3 changed files with 20 additions and 19 deletions

View File

@ -5691,6 +5691,7 @@ void Game::setPaused(bool value,bool forceAllowPauseStateChange,bool clearCaches
}
bool localEcho = lang.isLanguageLocal(languageList[i]);
server->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
sleep(1);
haveClientConnectedButNoReady = true;
}

View File

@ -392,20 +392,19 @@ 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) {
// int updateProgressValue = unit->getUpdateProgress();
// int speed = unit->getCurrSkill()->getTotalSpeed(unit->getTotalUpgrade());
// int df = unit->getDiagonalFactor();
// int hf = unit->getHeightFactor();
// bool changedActiveCommand = unit->isChangedActiveCommand();
//
// char szBuf[8096]="";
// snprintf(szBuf,8096,"unit->needToUpdate() returned: %d updateProgressValue: %d speed: %d changedActiveCommand: %d df: %d hf: %d",update,updateProgressValue,speed,changedActiveCommand,df,hf);
// unit->logSynchDataThreaded(__FILE__,__LINE__,szBuf);
// }
//
// }
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
int updateProgressValue = unit->getUpdateProgress();
int speed = unit->getCurrSkill()->getTotalSpeed(unit->getTotalUpgrade());
int df = unit->getDiagonalFactor();
int hf = unit->getHeightFactor();
bool changedActiveCommand = unit->isChangedActiveCommand();
char szBuf[8096]="";
snprintf(szBuf,8096,"unit->needToUpdate() returned: %d updateProgressValue: %d speed: %d changedActiveCommand: %d df: %d hf: %d",update,updateProgressValue,speed,changedActiveCommand,df,hf);
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

@ -1965,7 +1965,8 @@ int Unit::getHeightFactor() {
throw megaglest_runtime_error("targetCell == NULL");
}
int heightDiff= ((unitCell->getHeight() * 100.f) - (targetCell->getHeight() * 100.f));
int heightDiff= (truncateDecimal<float>(unitCell->getHeight() * 100.f,2) -
truncateDecimal<float>(targetCell->getHeight() * 100.f,2));
heightFactor= clamp(100 + heightDiff / 500, 20, 500);
}
@ -4032,8 +4033,8 @@ std::string Unit::toString() const {
result += " deadCount = " + intToStr(this->deadCount);
result += " progress = " + intToStr(this->progress);
result += "\n";
result += " lastAnimProgress = " + floatToStr(this->lastAnimProgress,16);
result += " animProgress = " + floatToStr(this->animProgress,16);
result += " lastAnimProgress = " + intToStr(this->lastAnimProgress);
result += " animProgress = " + intToStr(this->animProgress);
result += " highlight = " + floatToStr(this->highlight,16);
result += " progress2 = " + intToStr(this->progress2);
result += " kills = " + intToStr(this->kills);
@ -4131,9 +4132,9 @@ void Unit::saveGame(XmlNode *rootNode) {
// float progress; //between 0 and 1
unitNode->addAttribute("progress",intToStr(progress), mapTagReplacements);
// float lastAnimProgress; //between 0 and 1
unitNode->addAttribute("lastAnimProgress",floatToStr(lastAnimProgress,16), mapTagReplacements);
unitNode->addAttribute("lastAnimProgress",intToStr(lastAnimProgress), mapTagReplacements);
// float animProgress; //between 0 and 1
unitNode->addAttribute("animProgress",floatToStr(animProgress,16), mapTagReplacements);
unitNode->addAttribute("animProgress",intToStr(animProgress), mapTagReplacements);
// float highlight;
unitNode->addAttribute("highlight",floatToStr(highlight,16), mapTagReplacements);
// int progress2;