1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fixed unitialized ptrs in CArtifacts.

Parsing for adventure map def for artifacts.
This commit is contained in:
DjWarmonger 2012-12-16 11:35:14 +00:00
parent c764ce6ebe
commit 99e7177d57
3 changed files with 23 additions and 3 deletions

View File

@ -171,6 +171,8 @@ CArtifact::CArtifact()
possibleSlots[ArtBearer::HERO]; //we want to generate map entry even if it will be empty
possibleSlots[ArtBearer::CREATURE]; //we want to generate map entry even if it will be empty
possibleSlots[ArtBearer::COMMANDER];
constituents = NULL; //default pointer to zero
constituentOf = NULL;
}
CArtifact::~CArtifact()
@ -333,7 +335,6 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
continue;
// Fill in information about combined artifacts. Should perhaps be moved to a config file?
nart.constituentOf = NULL;
switch (nart.id)
{
case 129: // Angelic Alliance
@ -399,7 +400,6 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
// TODO: WoG combinationals
default:
nart.constituents = NULL;
break;
}
@ -476,6 +476,7 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
value = &graphics["large"];
if (!value->isNull())
art->large = value->String();
art->advMapDef = graphics["map"].String();
art->price = node["value"].Float();

View File

@ -77,6 +77,7 @@ public:
std::string image;
std::string large; // big image for cutom artifacts, used in drag & drop
std::string advMapDef; //used for adventure map object
si32 iconIndex; //TODO: handle automatically
const std::string &Name() const; //getter
@ -103,7 +104,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CBonusSystemNode&>(*this);
h & name & description & eventText & image & large & iconIndex &
h & name & description & eventText & image & large & advMapDef & iconIndex &
price & possibleSlots & constituents & constituentOf & aClass & id;
}

View File

@ -165,6 +165,7 @@ void CModHandler::loadActiveMods()
void CModHandler::reload()
{
{
//recreate adventure map defs
assert(!VLC->dobjinfo->gobjs[Obj::MONSTER].empty()); //make sure that at least some def info was found
const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::MONSTER].begin()->second;
@ -181,6 +182,23 @@ void CModHandler::reload()
}
}
}
{
assert(!VLC->dobjinfo->gobjs[Obj::ARTIFACT].empty());
const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::ARTIFACT].begin()->second;
BOOST_FOREACH(auto & art, VLC->arth->artifacts)
{
if (!vstd::contains(VLC->dobjinfo->gobjs[Obj::ARTIFACT], art->id)) // no obj info for this type
{
CGDefInfo * info = new CGDefInfo(*baseInfo);
info->subid = art->id;
info->name = art->advMapDef;
VLC->dobjinfo->gobjs[Obj::ARTIFACT][art->id] = info;
}
}
}
{
assert(!VLC->dobjinfo->gobjs[Obj::TOWN].empty()); //make sure that at least some def info was found