1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Added stubs for some Map objects serialization

This commit is contained in:
AlexVinS 2015-11-16 16:30:40 +03:00
parent 6977fc3a14
commit b56b7017ba
4 changed files with 173 additions and 18 deletions

View File

@ -107,7 +107,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
undeadModifier = new Bonus(Bonus::PERMANENT, Bonus::MORALE, Bonus::ARMY, -1, UNDEAD_MODIFIER_ID, VLC->generaltexth->arraytxt[116]); undeadModifier = new Bonus(Bonus::PERMANENT, Bonus::MORALE, Bonus::ARMY, -1, UNDEAD_MODIFIER_ID, VLC->generaltexth->arraytxt[116]);
undeadModifier->description = undeadModifier->description.substr(0, undeadModifier->description.size()-2);//trim value undeadModifier->description = undeadModifier->description.substr(0, undeadModifier->description.size()-2);//trim value
addNewBonus(undeadModifier); addNewBonus(undeadModifier);
} }
} }
else if(undeadModifier) else if(undeadModifier)
removeBonus(undeadModifier); removeBonus(undeadModifier);
@ -131,3 +131,13 @@ CBonusSystemNode * CArmedInstance::whatShouldBeAttached()
{ {
return this; return this;
} }
void CArmedInstance::writeJsonOptions(JsonNode& json) const
{
}
void CArmedInstance::readJsonOptions(const JsonNode& json)
{
}

View File

@ -40,4 +40,7 @@ public:
h & static_cast<CBonusSystemNode&>(*this); h & static_cast<CBonusSystemNode&>(*this);
h & static_cast<CCreatureSet&>(*this); h & static_cast<CCreatureSet&>(*this);
} }
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };

View File

@ -103,16 +103,16 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const
{ {
std::string hoverName; std::string hoverName;
if(hero->hasVisions(this, 0)) if(hero->hasVisions(this, 0))
{ {
MetaString ms; MetaString ms;
ms << stacks.begin()->second->count; ms << stacks.begin()->second->count;
ms << " " ; ms << " " ;
ms.addTxt(MetaString::CRE_PL_NAMES,subID); ms.addTxt(MetaString::CRE_PL_NAMES,subID);
ms << "\n"; ms << "\n";
int decision = takenAction(hero, true); int decision = takenAction(hero, true);
switch (decision) switch (decision)
{ {
case FIGHT: case FIGHT:
@ -123,19 +123,19 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const
break; break;
case JOIN_FOR_FREE: case JOIN_FOR_FREE:
ms.addTxt(MetaString::GENERAL_TXT,243); ms.addTxt(MetaString::GENERAL_TXT,243);
break; break;
default: //decision = cost in gold default: //decision = cost in gold
VLC->generaltexth->allTexts[244]; VLC->generaltexth->allTexts[244];
ms << boost::to_string(boost::format(VLC->generaltexth->allTexts[244]) % decision); ms << boost::to_string(boost::format(VLC->generaltexth->allTexts[244]) % decision);
break; break;
} }
ms.toString(hoverName); ms.toString(hoverName);
} }
else else
{ {
hoverName = getHoverText(hero->tempOwner); hoverName = getHoverText(hero->tempOwner);
} }
const JsonNode & texts = VLC->generaltexth->localizedTexts["adventureMap"]["monsterThreat"]; const JsonNode & texts = VLC->generaltexth->localizedTexts["adventureMap"]["monsterThreat"];
@ -557,6 +557,17 @@ int CGCreature::getNumberOfStacks(const CGHeroInstance *hero) const
return split; return split;
} }
void CGCreature::writeJsonOptions(JsonNode& json) const
{
}
void CGCreature::readJsonOptions(const JsonNode& json)
{
}
//CGMine
void CGMine::onHeroVisit( const CGHeroInstance * h ) const void CGMine::onHeroVisit( const CGHeroInstance * h ) const
{ {
int relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); int relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner);
@ -693,6 +704,17 @@ void CGMine::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) con
cb->startBattleI(hero, this); cb->startBattleI(hero, this);
} }
void CGMine::writeJsonOptions(JsonNode& json) const
{
}
void CGMine::readJsonOptions(const JsonNode& json)
{
}
std::string CGResource::getHoverText(PlayerColor player) const std::string CGResource::getHoverText(PlayerColor player) const
{ {
return VLC->generaltexth->restypes[subID]; return VLC->generaltexth->restypes[subID];
@ -777,6 +799,17 @@ void CGResource::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer)
cb->startBattleI(hero, this); cb->startBattleI(hero, this);
} }
void CGResource::writeJsonOptions(JsonNode& json) const
{
}
void CGResource::readJsonOptions(const JsonNode& json)
{
}
CGTeleport::CGTeleport() : CGTeleport::CGTeleport() :
type(UNKNOWN), channel(TeleportChannelID()) type(UNKNOWN), channel(TeleportChannelID())
{ {
@ -1223,6 +1256,16 @@ void CGArtifact::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer)
cb->startBattleI(hero, this); cb->startBattleI(hero, this);
} }
void CGArtifact::writeJsonOptions(JsonNode& json) const
{
}
void CGArtifact::readJsonOptions(const JsonNode& json)
{
}
void CGWitchHut::initObj() void CGWitchHut::initObj()
{ {
if (allowedAbilities.empty()) //this can happen for RMG. regular maps load abilities from map file if (allowedAbilities.empty()) //this can happen for RMG. regular maps load abilities from map file
@ -1280,6 +1323,17 @@ std::string CGWitchHut::getHoverText(const CGHeroInstance * hero) const
return hoverName; return hoverName;
} }
void CGWitchHut::writeJsonOptions(JsonNode& json) const
{
}
void CGWitchHut::readJsonOptions(const JsonNode& json)
{
}
void CGMagicWell::onHeroVisit( const CGHeroInstance * h ) const void CGMagicWell::onHeroVisit( const CGHeroInstance * h ) const
{ {
int message; int message;
@ -1419,6 +1473,17 @@ std::string CGShrine::getHoverText(const CGHeroInstance * hero) const
return hoverName; return hoverName;
} }
void CGShrine::writeJsonOptions(JsonNode& json) const
{
}
void CGShrine::readJsonOptions(const JsonNode& json)
{
}
void CGSignBottle::initObj() void CGSignBottle::initObj()
{ {
//if no text is set than we pick random from the predefined ones //if no text is set than we pick random from the predefined ones
@ -1445,11 +1510,15 @@ void CGSignBottle::onHeroVisit( const CGHeroInstance * h ) const
cb->removeObject(this); cb->removeObject(this);
} }
//TODO: remove void CGSignBottle::writeJsonOptions(JsonNode& json) const
//void CGScholar::giveAnyBonus( const CGHeroInstance * h ) const {
//{
// }
//}
void CGSignBottle::readJsonOptions(const JsonNode& json)
{
}
void CGScholar::onHeroVisit( const CGHeroInstance * h ) const void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
{ {
@ -1524,6 +1593,16 @@ void CGScholar::initObj()
} }
} }
void CGScholar::writeJsonOptions(JsonNode& json) const
{
}
void CGScholar::readJsonOptions(const JsonNode& json)
{
}
void CGGarrison::onHeroVisit (const CGHeroInstance *h) const void CGGarrison::onHeroVisit (const CGHeroInstance *h) const
{ {
int ally = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); int ally = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner);
@ -1560,6 +1639,16 @@ void CGGarrison::battleFinished(const CGHeroInstance *hero, const BattleResult &
onHeroVisit(hero); onHeroVisit(hero);
} }
void CGGarrison::writeJsonOptions(JsonNode& json) const
{
}
void CGGarrison::readJsonOptions(const JsonNode& json)
{
}
void CGMagi::initObj() void CGMagi::initObj()
{ {
if (ID == Obj::EYE_OF_MAGI) if (ID == Obj::EYE_OF_MAGI)
@ -1674,7 +1763,7 @@ void CGShipyard::getOutOffsets( std::vector<int3> &offsets ) const
int3(-3,0,0), int3(1,0,0), //AB int3(-3,0,0), int3(1,0,0), //AB
int3(-3,1,0), int3(1,1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0), //CDEFG int3(-3,1,0), int3(1,1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0), //CDEFG
int3(-3,-1,0), int3(1,-1,0), int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0) //HIJKL int3(-3,-1,0), int3(1,-1,0), int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0) //HIJKL
}; };
} }
void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const
@ -1696,6 +1785,17 @@ void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const
} }
} }
void CGShipyard::writeJsonOptions(JsonNode& json) const
{
}
void CGShipyard::readJsonOptions(const JsonNode& json)
{
}
void CCartographer::onHeroVisit( const CGHeroInstance * h ) const void CCartographer::onHeroVisit( const CGHeroInstance * h ) const
{ {
//if player has not bought map of this subtype yet and underground exist for stalagmite cartographer //if player has not bought map of this subtype yet and underground exist for stalagmite cartographer
@ -1860,3 +1960,13 @@ void CGLighthouse::giveBonusTo( PlayerColor player ) const
gb.bonus.sid = id.getNum(); gb.bonus.sid = id.getNum();
cb->sendAndApply(&gb); cb->sendAndApply(&gb);
} }
void CGLighthouse::writeJsonOptions(JsonNode& json) const
{
}
void CGLighthouse::readJsonOptions(const JsonNode& json)
{
}

View File

@ -82,6 +82,9 @@ public:
} }
protected: protected:
void setPropertyDer(ui8 what, ui32 val) override; void setPropertyDer(ui8 what, ui32 val) override;
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
private: private:
void fight(const CGHeroInstance *h) const; void fight(const CGHeroInstance *h) const;
@ -107,6 +110,9 @@ public:
h & static_cast<CGObjectInstance&>(*this); h & static_cast<CGObjectInstance&>(*this);
h & message; h & message;
} }
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };
class DLL_LINKAGE CGWitchHut : public CPlayersVisited class DLL_LINKAGE CGWitchHut : public CPlayersVisited
@ -124,6 +130,9 @@ public:
h & static_cast<CPlayersVisited&>(*this); h & static_cast<CPlayersVisited&>(*this);
h & allowedAbilities & ability; h & allowedAbilities & ability;
} }
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };
class DLL_LINKAGE CGScholar : public CGObjectInstance class DLL_LINKAGE CGScholar : public CGObjectInstance
@ -133,7 +142,6 @@ public:
EBonusType bonusType; EBonusType bonusType;
ui16 bonusID; //ID of skill/spell ui16 bonusID; //ID of skill/spell
// void giveAnyBonus(const CGHeroInstance * h) const; //TODO: remove
CGScholar() : bonusType(EBonusType::RANDOM){}; CGScholar() : bonusType(EBonusType::RANDOM){};
void onHeroVisit(const CGHeroInstance * h) const override; void onHeroVisit(const CGHeroInstance * h) const override;
void initObj() override; void initObj() override;
@ -142,6 +150,9 @@ public:
h & static_cast<CGObjectInstance&>(*this); h & static_cast<CGObjectInstance&>(*this);
h & bonusType & bonusID; h & bonusType & bonusID;
} }
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };
class DLL_LINKAGE CGGarrison : public CArmedInstance class DLL_LINKAGE CGGarrison : public CArmedInstance
@ -158,6 +169,9 @@ public:
h & static_cast<CArmedInstance&>(*this); h & static_cast<CArmedInstance&>(*this);
h & removableUnits; h & removableUnits;
} }
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };
class DLL_LINKAGE CGArtifact : public CArmedInstance class DLL_LINKAGE CGArtifact : public CArmedInstance
@ -182,6 +196,9 @@ public:
h & static_cast<CArmedInstance&>(*this); h & static_cast<CArmedInstance&>(*this);
h & message & storedArtifact; h & message & storedArtifact;
} }
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };
class DLL_LINKAGE CGResource : public CArmedInstance class DLL_LINKAGE CGResource : public CArmedInstance
@ -204,6 +221,9 @@ public:
h & static_cast<CArmedInstance&>(*this); h & static_cast<CArmedInstance&>(*this);
h & amount & message; h & amount & message;
} }
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };
class DLL_LINKAGE CGShrine : public CPlayersVisited class DLL_LINKAGE CGShrine : public CPlayersVisited
@ -220,6 +240,9 @@ public:
h & static_cast<CPlayersVisited&>(*this);; h & static_cast<CPlayersVisited&>(*this);;
h & spell; h & spell;
} }
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };
class DLL_LINKAGE CGMine : public CArmedInstance class DLL_LINKAGE CGMine : public CArmedInstance
@ -247,6 +270,9 @@ public:
h & producedResource & producedQuantity; h & producedResource & producedQuantity;
} }
ui32 defaultResProduction(); ui32 defaultResProduction();
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };
struct DLL_LINKAGE TeleportChannel struct DLL_LINKAGE TeleportChannel
@ -411,6 +437,9 @@ public:
h & static_cast<CGObjectInstance&>(*this); h & static_cast<CGObjectInstance&>(*this);
h & static_cast<IShipyard&>(*this); h & static_cast<IShipyard&>(*this);
} }
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };
class DLL_LINKAGE CGMagi : public CGObjectInstance class DLL_LINKAGE CGMagi : public CGObjectInstance
@ -477,4 +506,7 @@ public:
h & static_cast<CGObjectInstance&>(*this); h & static_cast<CGObjectInstance&>(*this);
} }
void giveBonusTo( PlayerColor player ) const; void giveBonusTo( PlayerColor player ) const;
protected:
void writeJsonOptions(JsonNode & json) const override;
void readJsonOptions(const JsonNode & json) override;
}; };