mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Moved banks randomization to server-side with client netpack
This commit is contained in:
@@ -97,6 +97,8 @@ void CBank::setConfig(const BankConfig & config)
|
||||
|
||||
for(const auto & stack : config.guards)
|
||||
setCreature (SlotID(stacksCount()), stack.type->getId(), stack.count);
|
||||
|
||||
daycounter = 1; //yes, 1 since "today" daycounter won't be incremented
|
||||
}
|
||||
|
||||
void CBank::setPropertyDer (ObjProperty what, ObjPropertyID identifier)
|
||||
@@ -106,11 +108,6 @@ void CBank::setPropertyDer (ObjProperty what, ObjPropertyID identifier)
|
||||
case ObjProperty::BANK_DAYCOUNTER: //daycounter
|
||||
daycounter+= identifier.getNum();
|
||||
break;
|
||||
case ObjProperty::BANK_RESET:
|
||||
// FIXME: Object reset must be done by separate netpack from server
|
||||
initObj(cb->gameState()->getRandomGenerator());
|
||||
daycounter = 1; //yes, 1 since "today" daycounter won't be incremented
|
||||
break;
|
||||
case ObjProperty::BANK_CLEAR:
|
||||
bankConfig.reset();
|
||||
break;
|
||||
@@ -124,7 +121,11 @@ void CBank::newTurn(vstd::RNG & rand) const
|
||||
if (resetDuration != 0)
|
||||
{
|
||||
if (daycounter >= resetDuration)
|
||||
cb->setObjPropertyValue(id, ObjProperty::BANK_RESET); //daycounter 0
|
||||
{
|
||||
auto handler = std::dynamic_pointer_cast<CBankInstanceConstructor>(getObjectHandler());
|
||||
auto config = handler->generateConfiguration(cb, rand, ID);
|
||||
cb->setBankObjectConfiguration(id, config);
|
||||
}
|
||||
else
|
||||
cb->setObjPropertyValue(id, ObjProperty::BANK_DAYCOUNTER, 1); //daycounter++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user