mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fixed Artifact parser. Check http://forum.vcmi.eu/viewtopic.php?p=7889#7889 for example mod.
This commit is contained in:
parent
a8175c13bd
commit
afe3f77a59
@ -24,7 +24,7 @@ using namespace boost::assign;
|
|||||||
|
|
||||||
extern boost::rand48 ran;
|
extern boost::rand48 ran;
|
||||||
|
|
||||||
const std::map<std::string, int> artRarityMap = boost::assign::map_list_of
|
const std::map<std::string, CArtifact::EartClass> artifactClassMap = boost::assign::map_list_of
|
||||||
("TREASURE", CArtifact::ART_TREASURE)
|
("TREASURE", CArtifact::ART_TREASURE)
|
||||||
("MINOR", CArtifact::ART_MINOR)
|
("MINOR", CArtifact::ART_MINOR)
|
||||||
("MAJOR", CArtifact::ART_MAJOR)
|
("MAJOR", CArtifact::ART_MAJOR)
|
||||||
@ -168,6 +168,9 @@ bool CArtifact::isBig () const
|
|||||||
CArtifact::CArtifact()
|
CArtifact::CArtifact()
|
||||||
{
|
{
|
||||||
setNodeType(ARTIFACT);
|
setNodeType(ARTIFACT);
|
||||||
|
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
CArtifact::~CArtifact()
|
CArtifact::~CArtifact()
|
||||||
@ -313,10 +316,6 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
|
|||||||
|
|
||||||
nart.price= parser.readNumber();
|
nart.price= parser.readNumber();
|
||||||
|
|
||||||
nart.possibleSlots[ArtBearer::HERO]; //we want to generate map entry even if it will be empty
|
|
||||||
nart.possibleSlots[ArtBearer::CREATURE]; //we want to generate map entry even if it will be empty
|
|
||||||
nart.possibleSlots[ArtBearer::COMMANDER];
|
|
||||||
|
|
||||||
for(int j=0;j<slots.size();j++)
|
for(int j=0;j<slots.size();j++)
|
||||||
{
|
{
|
||||||
if(parser.readString() == "x")
|
if(parser.readString() == "x")
|
||||||
@ -468,7 +467,7 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
|
|||||||
const JsonNode & text = node["text"];
|
const JsonNode & text = node["text"];
|
||||||
art->setName (text["name"].String());
|
art->setName (text["name"].String());
|
||||||
art->setDescription (text["description"].String());
|
art->setDescription (text["description"].String());
|
||||||
art->setName (text["event"].String());
|
art->setEventText (text["event"].String());
|
||||||
|
|
||||||
const JsonNode & graphics = node["graphics"];
|
const JsonNode & graphics = node["graphics"];
|
||||||
art->iconIndex = graphics["iconIndex"].Float();
|
art->iconIndex = graphics["iconIndex"].Float();
|
||||||
@ -479,11 +478,24 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
|
|||||||
|
|
||||||
art->price = node["value"].Float();
|
art->price = node["value"].Float();
|
||||||
|
|
||||||
|
{
|
||||||
|
auto it = artifactClassMap.find (node["class"].String());
|
||||||
|
if (it != artifactClassMap.end())
|
||||||
|
{
|
||||||
|
art->aClass = it->second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tlog2 << "Warning! Artifact rarity " << value->String() << " not recognized!";
|
||||||
|
art->aClass = CArtifact::ART_SPECIAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int bearerType = -1;
|
int bearerType = -1;
|
||||||
|
|
||||||
// FIXME FIXME FIXME: value is unitialized = crash!
|
{
|
||||||
auto it = artifactBearerMap.find (value->String());
|
auto it = artifactBearerMap.find (node["type"].String());
|
||||||
if (it != artifactPositionMap.end())
|
if (it != artifactBearerMap.end())
|
||||||
{
|
{
|
||||||
bearerType = it->second;
|
bearerType = it->second;
|
||||||
switch (bearerType)
|
switch (bearerType)
|
||||||
@ -500,11 +512,25 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
tlog2 << "Warning! Artifact type " << value->String() << " not recognized!";
|
tlog2 << "Warning! Artifact type " << value->String() << " not recognized!";
|
||||||
|
}
|
||||||
|
|
||||||
value = &node["slot"];
|
value = &node["slot"];
|
||||||
if (!value->isNull() && bearerType == ArtBearer::HERO) //we assume non-hero slots are irrelevant?
|
if (!value->isNull() && bearerType == ArtBearer::HERO) //we assume non-hero slots are irrelevant?
|
||||||
{
|
{
|
||||||
auto it = artifactPositionMap.find (value->String());
|
std::string slotName = value->String();
|
||||||
|
if (slotName == "MISC")
|
||||||
|
{
|
||||||
|
//unfortunatelly slot ids aare not continuous
|
||||||
|
art->possibleSlots[ArtBearer::HERO] += ArtifactPosition::MISC1, ArtifactPosition::MISC2, ArtifactPosition::MISC3, ArtifactPosition::MISC4, ArtifactPosition::MISC5;
|
||||||
|
}
|
||||||
|
else if (slotName == "RING")
|
||||||
|
{
|
||||||
|
art->possibleSlots[ArtBearer::HERO] += ArtifactPosition::LEFT_RING, ArtifactPosition::RIGHT_RING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
auto it = artifactPositionMap.find (slotName);
|
||||||
if (it != artifactPositionMap.end())
|
if (it != artifactPositionMap.end())
|
||||||
{
|
{
|
||||||
auto slot = it->second;
|
auto slot = it->second;
|
||||||
@ -513,6 +539,7 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
|
|||||||
else
|
else
|
||||||
tlog2 << "Warning! Artifact slot " << value->String() << " not recognized!";
|
tlog2 << "Warning! Artifact slot " << value->String() << " not recognized!";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_FOREACH (const JsonNode &bonus, node["bonuses"].Vector())
|
BOOST_FOREACH (const JsonNode &bonus, node["bonuses"].Vector())
|
||||||
{
|
{
|
||||||
@ -771,6 +798,10 @@ void CArtHandler::initAllowedArtifactsList(const std::vector<ui8> &allowed)
|
|||||||
allowedArtifacts.push_back(artifacts[i]);
|
allowedArtifacts.push_back(artifacts[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = GameConstants::ARTIFACTS_QUANTITY; i < artifacts.size(); ++i) //allow all new artifacts by default
|
||||||
|
{
|
||||||
|
allowedArtifacts.push_back(artifacts[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CArtifactInstance::CArtifactInstance()
|
CArtifactInstance::CArtifactInstance()
|
||||||
|
@ -531,8 +531,8 @@ void CMapLoaderH3M::readDisposedHeroes()
|
|||||||
|
|
||||||
void CMapLoaderH3M::readAllowedArtifacts()
|
void CMapLoaderH3M::readAllowedArtifacts()
|
||||||
{
|
{
|
||||||
map->allowedArtifact.resize(GameConstants::ARTIFACTS_QUANTITY);
|
map->allowedArtifact.resize (VLC->arth->artifacts.size()); //handle new artifacts, make them allowed by default
|
||||||
for(ui32 x = 0; x < map->allowedArtifact.size(); x++)
|
for (ui32 x = 0; x < map->allowedArtifact.size(); ++x)
|
||||||
{
|
{
|
||||||
map->allowedArtifact[x] = true;
|
map->allowedArtifact[x] = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user