mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Do not send netpack inside netpack handler.
This commit is contained in:
		| @@ -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); | ||||
|   | ||||
| @@ -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; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user