From 75cea9206ddcd4020022005140b68c8dbbc2debd Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Fri, 23 May 2014 19:45:17 +0200 Subject: [PATCH] - Fixed uninitialized guarding creature positions - Fix for guard placement --- lib/CGameState.cpp | 2 ++ lib/rmg/CMapGenerator.cpp | 2 -- lib/rmg/CRmgTemplateZone.cpp | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index be4398eb6..137852662 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -1909,6 +1909,8 @@ void CGameState::initMapObjects() } } CGTeleport::postInit(); //pairing subterranean gates + + map->calculateGuardingGreaturePositions(); //calculate once again when all the guards are placed and initialized } void CGameState::initVisitingAndGarrisonedHeroes() diff --git a/lib/rmg/CMapGenerator.cpp b/lib/rmg/CMapGenerator.cpp index d08c72652..7a3330c7b 100644 --- a/lib/rmg/CMapGenerator.cpp +++ b/lib/rmg/CMapGenerator.cpp @@ -43,8 +43,6 @@ std::unique_ptr CMapGenerator::generate() { logGlobal->errorStream() << "Random map generation received exception: " << e.what(); } - - map->calculateGuardingGreaturePositions(); //calculate once again when all the guards are placed return std::move(map); } diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index 1fd0e00b1..2dc12550d 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -544,11 +544,14 @@ bool CRmgTemplateZone::guardObject(CMapGenerator* gen, CGObjectInstance* object, auto it = tileinfo.find(visitable + int3(i, j, 0)); if (it != tileinfo.end()) { - logGlobal->infoStream() << boost::format("Block at %d %d") % it->first.x % it->first.y; - if ( ! it->second.isOccupied() && ! it->second.isObstacle()) + if (it->first != visitable) { - tiles.push_back(it->first); - it->second.setObstacle(true); + logGlobal->infoStream() << boost::format("Block at %d %d") % it->first.x % it->first.y; + if (!it->second.isOccupied() && !it->second.isObstacle()) + { + tiles.push_back(it->first); + it->second.setObstacle(true); + } } } }