1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00

Do not send netpack inside netpack handler.

This commit is contained in:
AlexVinS 2016-10-09 19:38:13 +03:00
parent bb890098df
commit 7db7ece143
2 changed files with 19 additions and 4 deletions

View File

@ -440,10 +440,15 @@ void CRewardableObject::setPropertyDer(ui8 what, ui32 val)
}
}
void CRewardableObject::triggerRewardReset() const
{
cb->setObjProperty(id, ObjProperty::REWARD_RESET, 0);
}
void CRewardableObject::newTurn(CRandomGenerator & rand) const
{
if (resetDuration != 0 && cb->getDate(Date::DAY) > 1 && (cb->getDate(Date::DAY) % resetDuration) == 1)
cb->setObjProperty(id, ObjProperty::REWARD_RESET, 0);
triggerRewardReset();
}
CRewardableObject::CRewardableObject():
@ -1042,6 +1047,14 @@ CGVisitableOPW::CGVisitableOPW()
resetDuration = 7;
}
void CGVisitableOPW::triggerRewardReset() const
{
CRewardableObject::triggerRewardReset();
ChangeObjectVisitors cov(ChangeObjectVisitors::VISITOR_CLEAR, id);
cb->sendAndApply(&cov);
}
void CGVisitableOPW::initObj(CRandomGenerator & rand)
{
setRandomReward(rand);
@ -1084,9 +1097,6 @@ void CGVisitableOPW::setPropertyDer(ui8 what, ui32 val)
reward = 500;
}
}
ChangeObjectVisitors cov(ChangeObjectVisitors::VISITOR_CLEAR, id);
cb->sendAndApply(&cov); // that cause server hang
}
CRewardableObject::setPropertyDer(what, val);

View File

@ -191,6 +191,8 @@ protected:
virtual CVisitInfo getVisitInfo(int index, const CGHeroInstance *h) const;
virtual void triggerRewardReset() const;
/// Rewards that can be granted by an object
std::vector<CVisitInfo> info;
@ -315,6 +317,9 @@ public:
class DLL_LINKAGE CGVisitableOPW : public CRewardableObject //objects visitable once per week
{
protected:
void triggerRewardReset() const override;
public:
void initObj(CRandomGenerator & rand) override;