1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +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

@ -46,8 +46,10 @@ void CGDefInfo::fetchInfoFromMSK()
}
}
void CDefObjInfoHandler::load()
CDefObjInfoHandler::CDefObjInfoHandler()
{
VLC->dobjinfo = this;
auto textFile = CResourceHandler::get()->loadData(ResourceID("DATA/ZOBJCTS.TXT"));
std::istringstream inp(std::string((char*)textFile.first.get(), textFile.second));
@ -132,8 +134,17 @@ void CDefObjInfoHandler::load()
//coverageMap calculating
nobj->fetchInfoFromMSK();
auto dest = nobj->id.toDefObjInfo();
if (dest.find(nobj->subid) != dest.end() && dest[nobj->subid] != nullptr)
{
// there is just too many of these. Note that this data is almost unused
// exceptions are: town(village-capitol) and creation of new objects (holes, creatures, heroes, etc)
//logGlobal->warnStream() << "Warning: overwriting def info for " << dest[nobj->subid]->name << " with " << nobj->name;
dest[nobj->subid].dellNull(); // do not leak
}
nobj->id.toDefObjInfo()[nobj->subid] = nobj;
}
for (int i = 0; i < 8 ; i++)