mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
CGLighthouse: workaround crash on map initialization. Fix issue 3020
Dirty hack here since proper fix would require to break saves
This commit is contained in:
@ -2161,7 +2161,8 @@ void CGLighthouse::initObj(CRandomGenerator & rand)
|
|||||||
{
|
{
|
||||||
if(tempOwner < PlayerColor::PLAYER_LIMIT)
|
if(tempOwner < PlayerColor::PLAYER_LIMIT)
|
||||||
{
|
{
|
||||||
giveBonusTo(tempOwner);
|
// FIXME: This is dirty hack
|
||||||
|
giveBonusTo(tempOwner, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2171,7 +2172,7 @@ std::string CGLighthouse::getHoverText(PlayerColor player) const
|
|||||||
return getObjectName();
|
return getObjectName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLighthouse::giveBonusTo( PlayerColor player ) const
|
void CGLighthouse::giveBonusTo(PlayerColor player, bool onInit) const
|
||||||
{
|
{
|
||||||
GiveBonus gb(GiveBonus::PLAYER);
|
GiveBonus gb(GiveBonus::PLAYER);
|
||||||
gb.bonus.type = Bonus::SEA_MOVEMENT;
|
gb.bonus.type = Bonus::SEA_MOVEMENT;
|
||||||
@ -2180,7 +2181,14 @@ void CGLighthouse::giveBonusTo( PlayerColor player ) const
|
|||||||
gb.bonus.duration = Bonus::PERMANENT;
|
gb.bonus.duration = Bonus::PERMANENT;
|
||||||
gb.bonus.source = Bonus::OBJECT;
|
gb.bonus.source = Bonus::OBJECT;
|
||||||
gb.bonus.sid = id.getNum();
|
gb.bonus.sid = id.getNum();
|
||||||
cb->sendAndApply(&gb);
|
|
||||||
|
// FIXME: This is really dirty hack
|
||||||
|
// Proper fix would be to make CGLighthouse into bonus system node
|
||||||
|
// Unfortunately this will cause saves breakage
|
||||||
|
if(onInit)
|
||||||
|
gb.applyGs(cb->gameState());
|
||||||
|
else
|
||||||
|
cb->sendAndApply(&gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLighthouse::serializeJsonOptions(JsonSerializeFormat& handler)
|
void CGLighthouse::serializeJsonOptions(JsonSerializeFormat& handler)
|
||||||
|
@ -523,7 +523,7 @@ public:
|
|||||||
{
|
{
|
||||||
h & static_cast<CGObjectInstance&>(*this);
|
h & static_cast<CGObjectInstance&>(*this);
|
||||||
}
|
}
|
||||||
void giveBonusTo( PlayerColor player ) const;
|
void giveBonusTo(PlayerColor player, bool onInit = false) const;
|
||||||
protected:
|
protected:
|
||||||
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user