- bugfix for restoring explorations on loading a saved game
This commit is contained in:
parent
560ed46cc0
commit
aec3ff1f63
|
@ -5496,6 +5496,7 @@ void Game::setPaused(bool value,bool forceAllowPauseStateChange,bool clearCaches
|
|||
Faction *faction = world.getFaction(i);
|
||||
faction->clearCaches();
|
||||
}
|
||||
world.refreshAllUnitExplorations();
|
||||
}
|
||||
setupPopupMenus(false);
|
||||
|
||||
|
@ -5521,6 +5522,7 @@ void Game::setPaused(bool value,bool forceAllowPauseStateChange,bool clearCaches
|
|||
Faction *faction = world.getFaction(i);
|
||||
faction->clearCaches();
|
||||
}
|
||||
world.refreshAllUnitExplorations();
|
||||
}
|
||||
pauseRequestSent=false;
|
||||
}
|
||||
|
|
|
@ -1116,51 +1116,23 @@ void Unit::setPos(const Vec2i &pos, bool clearPathFinder) {
|
|||
this->lastPos= this->pos;
|
||||
this->pos= pos;
|
||||
|
||||
// // This code is initial code to make the camera 'follow' a unit
|
||||
// //if(this->getId() == 5) {
|
||||
// if(cameraFollowUnit == true) {
|
||||
// //printf("A fov [%f] [H [%f] [V [%f]\n",game->getGameCameraPtr()->getFov(),game->getGameCameraPtr()->getHAng(),game->getGameCameraPtr()->getVAng());
|
||||
//
|
||||
// //game->getGameCameraPtr()->setClampDisabled(true);
|
||||
//
|
||||
// //game->getGameCameraPtr()->setFov(45);
|
||||
// if(oldLastPos.x > pos.x) {
|
||||
// game->getGameCameraPtr()->setHAng(270);
|
||||
// game->getGameCameraPtr()->setVAng(-7.6);
|
||||
// }
|
||||
// else if(oldLastPos.x < pos.x) {
|
||||
// game->getGameCameraPtr()->setHAng(90);
|
||||
// game->getGameCameraPtr()->setVAng(1.4);
|
||||
// }
|
||||
// else if(oldLastPos.y > pos.y) {
|
||||
// game->getGameCameraPtr()->setHAng(180);
|
||||
// game->getGameCameraPtr()->setVAng(4.2);
|
||||
// }
|
||||
// else {
|
||||
// game->getGameCameraPtr()->setHAng(-2.4);
|
||||
// game->getGameCameraPtr()->setVAng(-1.4);
|
||||
// }
|
||||
//
|
||||
// game->getGameCameraPtr()->setPos(getCurrVector());
|
||||
// game->getGameCameraPtr()->stop();
|
||||
//
|
||||
// //printf("B fov [%f] [H [%f] [V [%f]\n",game->getGameCameraPtr()->getFov(),game->getGameCameraPtr()->getHAng(),game->getGameCameraPtr()->getVAng());
|
||||
// }
|
||||
|
||||
map->clampPos(this->pos);
|
||||
this->meetingPos= pos - Vec2i(1);
|
||||
map->clampPos(this->meetingPos);
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
// Attempt to improve performance
|
||||
this->exploreCells();
|
||||
|
||||
calculateFogOfWarRadius();
|
||||
refreshPos();
|
||||
|
||||
logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
|
||||
}
|
||||
|
||||
void Unit::refreshPos() {
|
||||
// Attempt to improve performance
|
||||
this->exploreCells();
|
||||
calculateFogOfWarRadius();
|
||||
}
|
||||
|
||||
FowAlphaCellsLookupItem Unit::getFogOfWarRadius(bool useCache) const {
|
||||
if(useCache == true && Config::getInstance().getBool("EnableFowCache","true") == true) {
|
||||
return cachedFow;
|
||||
|
@ -4539,8 +4511,8 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction *
|
|||
result->pathFindRefreshCellCount = unitNode->getAttribute("pathFindRefreshCellCount")->getIntValue();
|
||||
}
|
||||
|
||||
result->exploreCells();
|
||||
result->calculateFogOfWarRadius();
|
||||
//result->exploreCells();
|
||||
//result->calculateFogOfWarRadius();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -592,6 +592,7 @@ public:
|
|||
inline void setLoadType(const ResourceType *loadType) {this->loadType= loadType;}
|
||||
inline void setProgress2(int progress2) {this->progress2= progress2;}
|
||||
void setPos(const Vec2i &pos,bool clearPathFinder=false);
|
||||
void refreshPos();
|
||||
void setTargetPos(const Vec2i &targetPos);
|
||||
void setTarget(const Unit *unit);
|
||||
void setTargetVec(const Vec3f &targetVec);
|
||||
|
|
|
@ -2073,6 +2073,10 @@ void World::initUnits() {
|
|||
f->limitResourcesToStore();
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Load game setting unit pos\n");
|
||||
refreshAllUnitExplorations();
|
||||
}
|
||||
}
|
||||
catch(const megaglest_runtime_error &ex) {
|
||||
gotError = true;
|
||||
|
@ -2104,6 +2108,17 @@ void World::initUnits() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void World::refreshAllUnitExplorations() {
|
||||
for(unsigned int i = 0; i < getFactionCount(); ++i) {
|
||||
Faction *faction = factions[i];
|
||||
|
||||
for(unsigned int j = 0; j < faction->getUnitCount(); ++j) {
|
||||
Unit *unit = faction->getUnit(j);
|
||||
unit->refreshPos();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void World::initMap() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
map.init(&tileset);
|
||||
|
|
|
@ -319,6 +319,7 @@ public:
|
|||
void loadGame(const XmlNode *rootNode);
|
||||
|
||||
void clearCaches();
|
||||
void refreshAllUnitExplorations();
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in New Issue