mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-24 03:47:18 +02:00
Workaround for hero & town issue. Game still crashes elsewhere, though.
This commit is contained in:
parent
dc98f14884
commit
bae9f2083f
@ -1899,6 +1899,13 @@ void CGameState::initVisitingAndGarrisonedHeroes()
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto hero : map->heroesOnMap)
|
||||
{
|
||||
if (hero->visitedTown)
|
||||
{
|
||||
assert (hero->visitedTown->visitingHero == hero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BFieldType CGameState::battleGetBattlefieldType(int3 tile)
|
||||
|
@ -523,7 +523,14 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
|
||||
|
||||
void CGTownInstance::onHeroLeave(const CGHeroInstance * h) const
|
||||
{
|
||||
cb->stopHeroVisitCastle(this, h);
|
||||
//FIXME: find out why this issue appears on random maps
|
||||
if (visitingHero == h)
|
||||
{
|
||||
cb->stopHeroVisitCastle(this, h);
|
||||
logGlobal->warnStream() << h->name << " correctly left town " << name;
|
||||
}
|
||||
else
|
||||
logGlobal->warnStream() << "Warning, " << h->name << " tries to leave the town " << name << " but hero is not inside.";
|
||||
}
|
||||
|
||||
std::string CGTownInstance::getObjectName() const
|
||||
|
@ -23,8 +23,8 @@ void CMapGenerator::foreach_neighbour(const int3 &pos, std::function<void(int3&
|
||||
}
|
||||
|
||||
|
||||
CMapGenerator::CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int randomSeed /*= std::time(nullptr)*/) :
|
||||
mapGenOptions(mapGenOptions), randomSeed(randomSeed), monolithIndex(0)
|
||||
CMapGenerator::CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int RandomSeed /*= std::time(nullptr)*/) :
|
||||
mapGenOptions(mapGenOptions), randomSeed(RandomSeed), monolithIndex(0)
|
||||
{
|
||||
rand.setSeed(randomSeed);
|
||||
}
|
||||
@ -50,12 +50,13 @@ void CMapGenerator::initTiles()
|
||||
|
||||
CMapGenerator::~CMapGenerator()
|
||||
{
|
||||
//FIXME: what if map is not present anymore?
|
||||
if (tiles && map)
|
||||
if (tiles)
|
||||
{
|
||||
for (int i=0; i < map->width; i++)
|
||||
int width = mapGenOptions->getWidth();
|
||||
int height = mapGenOptions->getHeight();
|
||||
for (int i=0; i < width; i++)
|
||||
{
|
||||
for(int j=0; j < map->height; j++)
|
||||
for(int j=0; j < height; j++)
|
||||
{
|
||||
delete [] tiles[i][j];
|
||||
}
|
||||
@ -80,6 +81,7 @@ std::unique_ptr<CMap> CMapGenerator::generate()
|
||||
genZones();
|
||||
map->calculateGuardingGreaturePositions(); //clear map so that all tiles are unguarded
|
||||
fillZones();
|
||||
//updated fuarded tiles will be calculated in CGameState::initMapObjects()
|
||||
}
|
||||
catch (rmgException &e)
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
class DLL_LINKAGE CMapGenerator
|
||||
{
|
||||
public:
|
||||
explicit CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int randomSeed = std::time(nullptr));
|
||||
explicit CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int RandomSeed = std::time(nullptr));
|
||||
~CMapGenerator(); // required due to unique_ptr
|
||||
|
||||
std::unique_ptr<CMap> generate();
|
||||
|
Loading…
x
Reference in New Issue
Block a user