1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-01 23:12:49 +02:00

Large rewrite of adventure map objects:

- replaced CDefObjInfo with ObjectTemplate class
- ObjectTempate is a direct member of objects instead of pointer with
shared ownership across CMap, handler and game objects
- simplified handling of objects that can change appearance (e.g. towns)
- all object queries regarding object appearance/blockmaps use h3m pos
instead of relative positions
- removed need of modhandler::reload
- cleanup of some old code
This commit is contained in:
Ivan Savenko
2014-01-02 23:48:38 +00:00
parent 2b9e074d54
commit 2c4c964a45
27 changed files with 729 additions and 672 deletions

View File

@@ -11,6 +11,8 @@
#include "CArtHandler.h"
#include "CSpellHandler.h"
#include "filesystem/Filesystem.h"
#include "CDefObjInfoHandler.h"
#include "CObjectHandler.h"
/*
* CTownHandler.cpp, part of VCMI engine
@@ -709,6 +711,38 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
void CTownHandler::afterLoadFinalization()
{
initializeRequirements();
ObjectTemplate base = VLC->dobjinfo->pickCandidates(Obj::TOWN, 0).front();
for (CFaction * fact : factions)
{
if (fact->town)
{
base.animationFile = fact->town->clientInfo.advMapCastle;
base.subid = fact->index;
// replace existing (if any) and add new template.
// Necessary for objects added via mods that don't have any templates in H3
VLC->dobjinfo->eraseAll(Obj::TOWN, fact->index);
VLC->dobjinfo->registerTemplate(base);
assert(fact->town->dwellings.size() == fact->town->dwellingNames.size());
for (size_t i=0; i<fact->town->dwellings.size(); i++)
{
ObjectTemplate base = VLC->dobjinfo->pickCandidates(Obj::CREATURE_GENERATOR1, 0).front();
//both unupgraded and upgraded get same dwelling
for (auto cre : fact->town->creatures[i])
{
base.subid = 80 + cre;
base.animationFile = fact->town->dwellings[i];
if (VLC->objh->cregens.count(cre) == 0)
{
VLC->dobjinfo->registerTemplate(base);
VLC->objh->cregens[80 + cre] = cre; //map of dwelling -> creature id
}
}
}
}
}
}
void CTownHandler::initializeRequirements()