1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Explicitly ban 'large' dwellings from random selection

Old code was relying on specific sorting order leading to easy to break
logic
This commit is contained in:
Ivan Savenko
2024-04-22 12:35:55 +03:00
parent 7d6b936a9d
commit ffec4b9154
4 changed files with 14 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ class DwellingInstanceConstructor : public CDefaultObjectTypeHandler<CGDwelling>
std::vector<std::vector<const CCreature *>> availableCreatures;
JsonNode guards;
bool bannedForRandomDwelling = false;
protected:
bool objectFilter(const CGObjectInstance * obj, std::shared_ptr<const ObjectTemplate> tmpl) const override;
@@ -34,6 +35,7 @@ public:
void initializeObject(CGDwelling * object) const override;
void randomizeObject(CGDwelling * object, CRandomGenerator & rng) const override;
bool isBannedForRandomDwelling() const;
bool producesCreature(const CCreature * crea) const;
std::vector<const CCreature *> getProducedCreatures() const;
};