mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +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");
|
||||
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");
|
||||
return PlayerColor::CANNOT_DETERMINE;
|
||||
|
@ -341,12 +341,7 @@ void CGObjectInstance::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
|
||||
void CGObjectInstance::serializeJsonOwner(JsonSerializeFormat & handler)
|
||||
{
|
||||
ui8 temp = tempOwner.getNum();
|
||||
|
||||
handler.serializeEnum("owner", temp, PlayerColor::NEUTRAL.getNum(), GameConstants::PLAYER_COLOR_NAMES);
|
||||
|
||||
if(!handler.saving)
|
||||
tempOwner = PlayerColor(temp);
|
||||
handler.serializeId("owner", tempOwner, PlayerColor::NEUTRAL);
|
||||
}
|
||||
|
||||
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);
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
logGlobal->error("Invalid quest mission type");
|
||||
|
@ -31,9 +31,11 @@ CIdentifierStorage::CIdentifierStorage()
|
||||
registerObject(ModScope::scopeBuiltin(), "spellSchool", "any", SpellSchool(ESpellSchool::ANY));
|
||||
|
||||
for (int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++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)
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
//TODO: RE-ENABLE
|
||||
//assert(state != ELoadingState::LOADING);
|
||||
assert(state != ELoadingState::LOADING);
|
||||
|
||||
auto idList = getPossibleIdentifiers(ObjectCallback::fromNameAndType(scope, type, name, std::function<void(si32)>(), silent));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user