1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-28 03:57:02 +02:00

Merge pull request #2750 from Nordsoft91/editor-improvements

This commit is contained in:
Nordsoft91 2023-09-05 12:28:41 +04:00 committed by GitHub
commit a0fead361b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

View File

@ -341,6 +341,9 @@ void CGObjectInstance::serializeJsonOptions(JsonSerializeFormat & handler)
void CGObjectInstance::serializeJsonOwner(JsonSerializeFormat & handler)
{
if(handler.saving && tempOwner == PlayerColor::NEUTRAL)
return;
ui8 temp = tempOwner.getNum();
handler.serializeEnum("owner", temp, PlayerColor::NEUTRAL.getNum(), GameConstants::PLAYER_COLOR_NAMES);

View File

@ -196,6 +196,8 @@ public:
GameResID producedResource;
ui32 producedQuantity;
std::set<GameResID> abandonedMineResources;
bool isAbandoned() const;
private:
void onHeroVisit(const CGHeroInstance * h) const override;
@ -209,7 +211,6 @@ private:
std::string getObjectName() const override;
std::string getHoverText(PlayerColor player) const override;
bool isAbandoned() const;
public:
template <typename Handler> void serialize(Handler &h, const int version)
{

View File

@ -118,7 +118,10 @@ void Initializer::initialize(CGHeroInstance * o)
o->tempOwner = defaultPlayer;
if(o->ID == Obj::PRISON)
{
o->subID = 0;
o->tempOwner = PlayerColor::NEUTRAL;
}
if(o->ID == Obj::HERO)
{
@ -184,8 +187,16 @@ void Initializer::initialize(CGMine * o)
if(!o) return;
o->tempOwner = defaultPlayer;
o->producedResource = GameResID(o->subID);
o->producedQuantity = o->defaultResProduction();
if(o->isAbandoned())
{
for(auto r = 0; r < GameConstants::RESOURCE_QUANTITY - 1; ++r)
o->abandonedMineResources.insert(GameResID(r));
}
else
{
o->producedResource = GameResID(o->subID);
o->producedQuantity = o->defaultResProduction();
}
}
void Initializer::initialize(CGResource * o)

View File

@ -141,6 +141,7 @@ void MapController::repairMap()
{
nih->typeName = "prison";
nih->subTypeName = "prison";
nih->subID = 0;
}
nih->type = type;