1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Large changeset, first part of editing H3 objects via mods feature. Changes:

- loading of all objects (including H3 objects) will be directed by mod handlers
- common base for all handlers accessible from mod system (IHanderBase)
- json format changes: use struct with string ID's instead of vector

- fixed some gcc/clang errors and warnings
- fixed several cases of memory leaks and invalid memory access (mostly related to usage of bonus system and/or identifiers resolution)

Note that right now loading is much slower than before due to excessive json validation (or not fast enough validator)
This commit is contained in:
Ivan Savenko
2013-04-21 12:49:26 +00:00
parent 8a4f81b981
commit c6cc6e6301
85 changed files with 4714 additions and 4441 deletions

View File

@@ -1271,7 +1271,7 @@ void CGameHandler::newTurn()
{
if(t->hasBuilt(BuildingID::RESOURCE_SILO)) //there is resource silo
{
if(t->town->primaryRes == 127) //we'll give wood and ore
if(t->town->primaryRes == Res::WOOD_AND_ORE) //we'll give wood and ore
{
n.res[player][Res::WOOD] ++;
n.res[player][Res::ORE] ++;
@@ -4739,11 +4739,12 @@ bool CGameHandler::complain( const std::string &problem )
void CGameHandler::showGarrisonDialog( ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits, const boost::function<void()> &cb )
{
PlayerColor player = getOwner(hid);
//PlayerColor player = getOwner(hid);
auto upperArmy = dynamic_cast<const CArmedInstance*>(getObj(upobj));
auto lowerArmy = dynamic_cast<const CArmedInstance*>(getObj(hid));
assert(upperArmy, lowerArmy);
assert(lowerArmy);
assert(upperArmy);
auto garrisonQuery = make_shared<CGarrisonDialogQuery>(upperArmy, lowerArmy);
queries.addQuery(garrisonQuery);
@@ -4789,6 +4790,16 @@ bool CGameHandler::isAllowedExchange( ObjectInstanceID id1, ObjectInstanceID id2
return true;
}
if (o1->ID == Obj::HERO && o2->ID == Obj::HERO)
{
const CGHeroInstance *h1 = static_cast<const CGHeroInstance*>(o1);
const CGHeroInstance *h2 = static_cast<const CGHeroInstance*>(o2);
// two heroes in same town (garrisoned and visiting)
if (h1->visitedTown != nullptr && h2->visitedTown != nullptr && h1->visitedTown == h2->visitedTown)
return true;
}
//Ongoing garrison exchange
if(auto dialog = std::dynamic_pointer_cast<CGarrisonDialogQuery>(queries.topQuery(o1->tempOwner)))
{