mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Fixed serialization of PlayerColor in json
This commit is contained in:
parent
86a7f5f5cd
commit
12c4f8d18c
@ -238,7 +238,7 @@ PlayerColor InterfaceObjectConfigurable::readPlayerColor(const JsonNode & config
|
|||||||
{
|
{
|
||||||
logGlobal->debug("Reading PlayerColor");
|
logGlobal->debug("Reading PlayerColor");
|
||||||
if(!config.isNull() && config.isString())
|
if(!config.isNull() && config.isString())
|
||||||
return PlayerColor(vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, config.String()));
|
return PlayerColor::decode(config.String());
|
||||||
|
|
||||||
logGlobal->debug("Unknown PlayerColor attribute");
|
logGlobal->debug("Unknown PlayerColor attribute");
|
||||||
return PlayerColor::CANNOT_DETERMINE;
|
return PlayerColor::CANNOT_DETERMINE;
|
||||||
|
@ -341,12 +341,7 @@ void CGObjectInstance::serializeJsonOptions(JsonSerializeFormat & handler)
|
|||||||
|
|
||||||
void CGObjectInstance::serializeJsonOwner(JsonSerializeFormat & handler)
|
void CGObjectInstance::serializeJsonOwner(JsonSerializeFormat & handler)
|
||||||
{
|
{
|
||||||
ui8 temp = tempOwner.getNum();
|
handler.serializeId("owner", tempOwner, PlayerColor::NEUTRAL);
|
||||||
|
|
||||||
handler.serializeEnum("owner", temp, PlayerColor::NEUTRAL.getNum(), GameConstants::PLAYER_COLOR_NAMES);
|
|
||||||
|
|
||||||
if(!handler.saving)
|
|
||||||
tempOwner = PlayerColor(temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BattleField CGObjectInstance::getBattlefield() const
|
BattleField CGObjectInstance::getBattlefield() const
|
||||||
|
@ -534,7 +534,7 @@ void CQuest::serializeJson(JsonSerializeFormat & handler, const std::string & fi
|
|||||||
handler.serializeId<ui32, ui32, HeroTypeID>("hero", m13489val, 0);
|
handler.serializeId<ui32, ui32, HeroTypeID>("hero", m13489val, 0);
|
||||||
break;
|
break;
|
||||||
case MISSION_PLAYER:
|
case MISSION_PLAYER:
|
||||||
handler.serializeEnum("player", m13489val, PlayerColor::CANNOT_DETERMINE.getNum(), GameConstants::PLAYER_COLOR_NAMES);
|
handler.serializeId<ui32, ui32, PlayerColor>("player", m13489val, PlayerColor::NEUTRAL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->error("Invalid quest mission type");
|
logGlobal->error("Invalid quest mission type");
|
||||||
|
@ -31,9 +31,11 @@ CIdentifierStorage::CIdentifierStorage()
|
|||||||
registerObject(ModScope::scopeBuiltin(), "spellSchool", "any", SpellSchool(ESpellSchool::ANY));
|
registerObject(ModScope::scopeBuiltin(), "spellSchool", "any", SpellSchool(ESpellSchool::ANY));
|
||||||
|
|
||||||
for (int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i)
|
for (int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i)
|
||||||
{
|
|
||||||
registerObject(ModScope::scopeBuiltin(), "resource", GameConstants::RESOURCE_NAMES[i], i);
|
registerObject(ModScope::scopeBuiltin(), "resource", GameConstants::RESOURCE_NAMES[i], i);
|
||||||
}
|
|
||||||
|
for (int i = 0; i < std::size(GameConstants::PLAYER_COLOR_NAMES); ++i)
|
||||||
|
registerObject(ModScope::scopeBuiltin(), "playerColor", GameConstants::PLAYER_COLOR_NAMES[i], i);
|
||||||
|
|
||||||
|
|
||||||
for(int i=0; i<GameConstants::PRIMARY_SKILLS; ++i)
|
for(int i=0; i<GameConstants::PRIMARY_SKILLS; ++i)
|
||||||
{
|
{
|
||||||
@ -155,8 +157,7 @@ void CIdentifierStorage::tryRequestIdentifier(const std::string & type, const Js
|
|||||||
|
|
||||||
std::optional<si32> CIdentifierStorage::getIdentifier(const std::string & scope, const std::string & type, const std::string & name, bool silent) const
|
std::optional<si32> CIdentifierStorage::getIdentifier(const std::string & scope, const std::string & type, const std::string & name, bool silent) const
|
||||||
{
|
{
|
||||||
//TODO: RE-ENABLE
|
assert(state != ELoadingState::LOADING);
|
||||||
//assert(state != ELoadingState::LOADING);
|
|
||||||
|
|
||||||
auto idList = getPossibleIdentifiers(ObjectCallback::fromNameAndType(scope, type, name, std::function<void(si32)>(), silent));
|
auto idList = getPossibleIdentifiers(ObjectCallback::fromNameAndType(scope, type, name, std::function<void(si32)>(), silent));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user