mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
- better logging of some config files errors
- restored lvl 10 for some dragons
This commit is contained in:
@@ -68,7 +68,7 @@
|
|||||||
{
|
{
|
||||||
"special" : true,
|
"special" : true,
|
||||||
"id": 133,
|
"id": 133,
|
||||||
"level": 9,
|
"level": 10,
|
||||||
"faction": "neutral",
|
"faction": "neutral",
|
||||||
"abilities": [ [ "DRAGON_NATURE", 0, 0, 0 ] ], //crystal dragon is a dragon
|
"abilities": [ [ "DRAGON_NATURE", 0, 0, 0 ] ], //crystal dragon is a dragon
|
||||||
"ability_remove": [ "FLYING" ], //Crystal Dragons do not fly
|
"ability_remove": [ "FLYING" ], //Crystal Dragons do not fly
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
"level": 8,
|
"level": 8,
|
||||||
"faction": "neutral",
|
"faction": "neutral",
|
||||||
"abilities": [ [ "DRAGON_NATURE", 0, 0, 0 ], //faerie dragon is a dragon
|
"abilities": [ [ "DRAGON_NATURE", 0, 0, 0 ], //faerie dragon is a dragon
|
||||||
[ "MAGIC_MIRROR", 30, 0, 0 ]
|
[ "MAGIC_MIRROR", 30, 0, 0 ],
|
||||||
[ "CASTS", 5, 0, 0 ],
|
[ "CASTS", 5, 0, 0 ],
|
||||||
[ "CREATURE_SPELL_POWER", 500, 0, 0], //5 spell power per dragon
|
[ "CREATURE_SPELL_POWER", 500, 0, 0], //5 spell power per dragon
|
||||||
[ "SPELLCASTER", 2, "spell.magicArrow", 10 ],
|
[ "SPELLCASTER", 2, "spell.magicArrow", 10 ],
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
{
|
{
|
||||||
"special" : true,
|
"special" : true,
|
||||||
"id": 135,
|
"id": 135,
|
||||||
"level": 9,
|
"level": 10,
|
||||||
"faction": "neutral",
|
"faction": "neutral",
|
||||||
"abilities": [ [ "SPELL_AFTER_ATTACK", 100, 80, 0 ], //always reduce defense
|
"abilities": [ [ "SPELL_AFTER_ATTACK", 100, 80, 0 ], //always reduce defense
|
||||||
[ "ACID_BREATH", 25, 0, 20 ], //20% chance to do 25 damage
|
[ "ACID_BREATH", 25, 0, 20 ], //20% chance to do 25 damage
|
||||||
|
|||||||
@@ -84,10 +84,18 @@ void CIdentifierStorage::finalize() const
|
|||||||
{
|
{
|
||||||
// print list of missing objects and crash
|
// print list of missing objects and crash
|
||||||
// in future should try to do some cleanup (like returning all id's as 0)
|
// in future should try to do some cleanup (like returning all id's as 0)
|
||||||
|
if (!missingObjects.empty())
|
||||||
|
{
|
||||||
BOOST_FOREACH(auto object, missingObjects)
|
BOOST_FOREACH(auto object, missingObjects)
|
||||||
{
|
{
|
||||||
tlog1 << "Error: object " << object.first << " was not found!\n";
|
tlog1 << "Error: object " << object.first << " was not found!\n";
|
||||||
}
|
}
|
||||||
|
BOOST_FOREACH(auto object, registeredObjects)
|
||||||
|
{
|
||||||
|
tlog5 << object.first << " -> " << object.second << "\n";
|
||||||
|
}
|
||||||
|
tlog1 << "All known identifiers were dumped into log file\n";
|
||||||
|
}
|
||||||
assert(missingObjects.empty());
|
assert(missingObjects.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,33 +32,21 @@ JsonNode::JsonNode(JsonType Type):
|
|||||||
JsonNode::JsonNode(const char *data, size_t datasize):
|
JsonNode::JsonNode(const char *data, size_t datasize):
|
||||||
type(DATA_NULL)
|
type(DATA_NULL)
|
||||||
{
|
{
|
||||||
JsonParser parser(data, datasize, *this);
|
JsonParser parser(data, datasize);
|
||||||
|
*this = parser.parse("<unknown>");
|
||||||
|
|
||||||
JsonValidator validator(*this);
|
JsonValidator validator(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode::JsonNode(ResourceID && fileURI):
|
JsonNode::JsonNode(ResourceID && fileURI):
|
||||||
type(DATA_NULL)
|
type(DATA_NULL)
|
||||||
{
|
{
|
||||||
std::string filename = CResourceHandler::get()->getResourceName(fileURI);
|
auto file = CResourceHandler::get()->loadData(fileURI);
|
||||||
FILE * file = fopen(filename.c_str(), "rb");
|
|
||||||
if (!file)
|
|
||||||
{
|
|
||||||
tlog1 << "Failed to open file " << filename << "\n";
|
|
||||||
perror("Last system error was ");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
JsonParser parser(reinterpret_cast<char*>(file.first.get()), file.second);
|
||||||
size_t datasize = ftell(file);
|
*this = parser.parse(fileURI.getName());
|
||||||
fseek(file, 0, SEEK_SET);
|
|
||||||
|
|
||||||
char *input = new char[datasize];
|
|
||||||
datasize = fread((void*)input, 1, datasize, file);
|
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
JsonParser parser(input, datasize, *this);
|
|
||||||
JsonValidator validator(*this);
|
JsonValidator validator(*this);
|
||||||
delete [] input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode::JsonNode(const JsonNode ©):
|
JsonNode::JsonNode(const JsonNode ©):
|
||||||
@@ -345,12 +333,18 @@ std::ostream & operator<<(std::ostream &out, const JsonNode &node)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
JsonParser::JsonParser(const char * inputString, size_t stringSize, JsonNode &root):
|
JsonParser::JsonParser(const char * inputString, size_t stringSize):
|
||||||
input(inputString, stringSize),
|
input(inputString, stringSize),
|
||||||
lineCount(1),
|
lineCount(1),
|
||||||
lineStart(0),
|
lineStart(0),
|
||||||
pos(0)
|
pos(0)
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonNode JsonParser::parse(std::string fileName)
|
||||||
|
{
|
||||||
|
JsonNode root;
|
||||||
|
|
||||||
extractValue(root);
|
extractValue(root);
|
||||||
extractWhitespace(false);
|
extractWhitespace(false);
|
||||||
|
|
||||||
@@ -358,9 +352,13 @@ JsonParser::JsonParser(const char * inputString, size_t stringSize, JsonNode &ro
|
|||||||
if (pos < input.size())
|
if (pos < input.size())
|
||||||
error("Not all file was parsed!", true);
|
error("Not all file was parsed!", true);
|
||||||
|
|
||||||
//TODO: better way to show errors (like printing file name as well)
|
if (!errors.empty())
|
||||||
|
{
|
||||||
|
tlog3<<"File " << fileName << " is not a valid JSON file!\n";
|
||||||
tlog3<<errors;
|
tlog3<<errors;
|
||||||
}
|
}
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
bool JsonParser::extractSeparator()
|
bool JsonParser::extractSeparator()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -339,7 +339,10 @@ namespace JsonDetail
|
|||||||
bool error(const std::string &message, bool warning=false);
|
bool error(const std::string &message, bool warning=false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JsonParser(const char * inputString, size_t stringSize, JsonNode &root);
|
JsonParser(const char * inputString, size_t stringSize);
|
||||||
|
|
||||||
|
/// do actual parsing. filename is name of file that will printed to console if any errors were found
|
||||||
|
JsonNode parse(std::string fileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
//Internal class for Json validation, used automaticaly in JsonNode constructor. Behaviour:
|
//Internal class for Json validation, used automaticaly in JsonNode constructor. Behaviour:
|
||||||
|
|||||||
Reference in New Issue
Block a user