mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- compile fix
- fixed crash if json defines only one creature horde
This commit is contained in:
parent
74a1d09871
commit
27a30b5ff9
@ -844,4 +844,10 @@ bool AbstractGoal::invalid() const
|
||||
void AbstractGoal::accept (VCAI * ai)
|
||||
{
|
||||
ai->tryRealize(*this);
|
||||
};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CGoal<T>::accept (VCAI * ai)
|
||||
{
|
||||
ai->tryRealize(static_cast<T&>(*this)); //casting enforces template instantiation
|
||||
}
|
||||
|
@ -144,10 +144,7 @@ public:
|
||||
OSETTER(CGTownInstance *, town)
|
||||
OSETTER(int, bid)
|
||||
|
||||
void accept (VCAI * ai) override
|
||||
{
|
||||
ai->tryRealize(static_cast<T&>(*this)); //casting enforces template instantiation
|
||||
}
|
||||
void accept (VCAI * ai) override;
|
||||
|
||||
CGoal<T> * clone() const override
|
||||
{
|
||||
|
@ -610,6 +610,7 @@ SDLImage::SDLImage(std::string filename, bool compressed):
|
||||
if (surf == nullptr)
|
||||
{
|
||||
logGlobal->errorStream() << "Error: failed to load image "<<filename;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -480,9 +480,12 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
|
||||
|
||||
// Horde building creature level
|
||||
for(const JsonNode &node : source["horde"].Vector())
|
||||
{
|
||||
town.hordeLvl[town.hordeLvl.size()] = node.Float();
|
||||
}
|
||||
|
||||
// town needs to have exactly 2 horde entries. Validation will take care of 2+ entries
|
||||
// but anything below 2 must be handled here
|
||||
for (size_t i=source["horde"].Vector().size(); i<2; i++)
|
||||
town.hordeLvl[i] = -1;
|
||||
|
||||
const JsonVector & creatures = source["creatures"].Vector();
|
||||
|
||||
|
@ -744,14 +744,19 @@ public:
|
||||
{
|
||||
FIRST_AVAILABLE = -2,
|
||||
PRE_FIRST = -1, //sometimes used as error, sometimes as first free in backpack
|
||||
HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, RIGHT_RING, LEFT_RING, FEET, MISC1, MISC2, MISC3, MISC4,
|
||||
MACH1, MACH2, MACH3, MACH4, SPELLBOOK, MISC5,
|
||||
HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, //5
|
||||
RIGHT_RING, LEFT_RING, FEET, //8
|
||||
MISC1, MISC2, MISC3, MISC4, //12
|
||||
MACH1, MACH2, MACH3, MACH4, //16
|
||||
SPELLBOOK, MISC5, //18
|
||||
AFTER_LAST,
|
||||
//cres
|
||||
CREATURE_SLOT = 0,
|
||||
COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6, COMMANDER_AFTER_LAST
|
||||
};
|
||||
|
||||
static_assert (AFTER_LAST == 19, "incorrect number of artifact slots");
|
||||
|
||||
ArtifactPosition(EArtifactPosition _num = PRE_FIRST) : num(_num)
|
||||
{}
|
||||
|
||||
|
@ -133,8 +133,8 @@ void CPrivilagedInfoCallback::getAllTiles (std::unordered_set<int3, ShashInt3> &
|
||||
{
|
||||
for (int yd = 0; yd < gs->map->height; yd++)
|
||||
{
|
||||
if ((getTile (int3 (xd,yd,zd))->terType == 8 && water)
|
||||
|| (getTile (int3 (xd,yd,zd))->terType != 8 && land))
|
||||
if ((getTile (int3 (xd,yd,zd))->terType == ETerrainType::WATER && water)
|
||||
|| (getTile (int3 (xd,yd,zd))->terType != ETerrainType::WATER && land))
|
||||
tiles.insert(int3(xd,yd,zd));
|
||||
}
|
||||
}
|
||||
@ -157,7 +157,7 @@ void CPrivilagedInfoCallback::getFreeTiles (std::vector<int3> &tiles) const
|
||||
for (int yd = 0; yd < gs->map->height; yd++)
|
||||
{
|
||||
tinfo = getTile(int3 (xd,yd,zd));
|
||||
if (tinfo->terType != 8 && !tinfo->blocked) //land and free
|
||||
if (tinfo->terType != ETerrainType::WATER && !tinfo->blocked) //land and free
|
||||
tiles.push_back (int3 (xd,yd,zd));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user