1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-19 00:17:56 +02:00

Refactoring: only use RNGs explicitly to avoid bug prone code in future

Now server-side code should always use CRandomGenerator::getDefault which is serialized in GH.
CGameState::getRandomGenerator should be only used from GS code and CPackForClient-based applyGs.
This commit is contained in:
Arseniy Shestakov
2016-09-09 20:30:36 +03:00
parent 70abae9b51
commit c8faca8f39
28 changed files with 225 additions and 219 deletions

View File

@ -624,7 +624,7 @@ DLL_LINKAGE void HeroRecruited::applyGs( CGameState *gs )
h->attachTo(p);
if(fresh)
{
h->initObj();
h->initObj(gs->getRandomGenerator());
}
gs->map->addBlockVisTiles(h);
@ -689,7 +689,7 @@ DLL_LINKAGE void NewObject::applyGs( CGameState *gs )
gs->map->objects.push_back(o);
gs->map->addBlockVisTiles(o);
o->initObj();
o->initObj(gs->getRandomGenerator());
gs->map->calculateGuardingGreaturePositions();
logGlobal->debugStream() << "added object id=" << id << "; address=" << (intptr_t)o << "; name=" << o->getObjectName();