mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Few more cleanup
This commit is contained in:
parent
f686edc1b8
commit
ff1c224a97
@ -19,22 +19,6 @@
|
|||||||
#include "CCreatureHandler.h"
|
#include "CCreatureHandler.h"
|
||||||
#include "CSpellHandler.h"
|
#include "CSpellHandler.h"
|
||||||
|
|
||||||
///Helpers
|
|
||||||
|
|
||||||
static inline void jsonSetString(const JsonNode& source, const std::string& name, std::string& dest)
|
|
||||||
{
|
|
||||||
dest = source[name].String();//null->empty string
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void jsonSetBool(const JsonNode& source, const std::string& name, bool& dest)
|
|
||||||
{
|
|
||||||
const JsonNode& val = source[name];
|
|
||||||
if(!val.isNull()) //do not rely on default value
|
|
||||||
{
|
|
||||||
dest = val.Bool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///MacroString
|
///MacroString
|
||||||
|
|
||||||
MacroString::MacroString(const std::string &format)
|
MacroString::MacroString(const std::string &format)
|
||||||
@ -47,8 +31,6 @@ MacroString::MacroString(const std::string &format)
|
|||||||
size_t end_pos = 0;
|
size_t end_pos = 0;
|
||||||
size_t start_pos = std::string::npos;
|
size_t start_pos = std::string::npos;
|
||||||
|
|
||||||
tlog5 << "Parsing format " << format << std::endl;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
start_pos = format.find(MACRO_START, end_pos);
|
start_pos = format.find(MACRO_START, end_pos);
|
||||||
@ -316,17 +298,15 @@ void CBonusTypeHandler::load(const JsonNode& config)
|
|||||||
|
|
||||||
void CBonusTypeHandler::loadItem(const JsonNode& source, CBonusType& dest)
|
void CBonusTypeHandler::loadItem(const JsonNode& source, CBonusType& dest)
|
||||||
{
|
{
|
||||||
dest.hidden = false;
|
dest.nameTemplate = source["name"].String();
|
||||||
jsonSetString(source,"name", dest.nameTemplate);
|
dest.descriptionTemplate = source["description"].String();
|
||||||
jsonSetString(source,"description", dest.descriptionTemplate);
|
dest.hidden = source["hidden"].Bool(); //Null -> false
|
||||||
|
|
||||||
jsonSetBool(source,"hidden", dest.hidden);
|
|
||||||
|
|
||||||
const JsonNode& graphics = source["graphics"];
|
const JsonNode& graphics = source["graphics"];
|
||||||
|
|
||||||
if(!graphics.isNull())
|
if(!graphics.isNull())
|
||||||
{
|
{
|
||||||
jsonSetString(graphics,"icon", dest.icon);
|
dest.icon = graphics["icon"].String();
|
||||||
}
|
}
|
||||||
dest.buildMacros();
|
dest.buildMacros();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user