mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
Switched LURE to use a single central RandomSource instance, instead of (sometimes) creating a new RandomSource every function call.
svn-id: r43715
This commit is contained in:
parent
e98c791106
commit
ac5a6552ca
@ -40,7 +40,7 @@ const FighterRecord initialFighterList[3] = {
|
||||
|
||||
FightsManager *int_fights = NULL;
|
||||
|
||||
FightsManager::FightsManager() {
|
||||
FightsManager::FightsManager() : _rnd(LureEngine::getReference().rnd()) {
|
||||
int_fights = this;
|
||||
_fightData = NULL;
|
||||
_mouseFlags = 0;
|
||||
|
@ -66,7 +66,7 @@ enum KeyStatus {KS_UP, KS_KEYDOWN_1, KS_KEYDOWN_2};
|
||||
class FightsManager {
|
||||
private:
|
||||
MemoryBlock *_fightData;
|
||||
Common::RandomSource _rnd;
|
||||
Common::RandomSource &_rnd;
|
||||
uint8 _mouseFlags;
|
||||
KeyStatus _keyDown;
|
||||
FighterRecord _fighterList[3];
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "lure/sound.h"
|
||||
#include "lure/lure.h"
|
||||
#include "common/endian.h"
|
||||
#include "common/EventRecorder.h"
|
||||
|
||||
namespace Lure {
|
||||
|
||||
@ -598,11 +597,9 @@ void Hotspot::setRandomDest() {
|
||||
Resources &res = Resources::getReference();
|
||||
RoomData *roomData = res.getRoom(roomNumber());
|
||||
Common::Rect &rect = roomData->walkBounds;
|
||||
Common::RandomSource rnd;
|
||||
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
||||
int16 xp, yp;
|
||||
|
||||
g_eventRec.registerRandomSource(rnd, "lureHotspots");
|
||||
|
||||
if (currentActions().isEmpty())
|
||||
currentActions().addFront(START_WALKING, roomNumber());
|
||||
else
|
||||
@ -3145,10 +3142,9 @@ void HotspotTickHandlers::followerAnimHandler(Hotspot &h) {
|
||||
return;
|
||||
}
|
||||
|
||||
Common::RandomSource rnd;
|
||||
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
||||
RandomActionType actionType;
|
||||
uint16 scheduleId;
|
||||
g_eventRec.registerRandomSource(rnd, "lureHotspots");
|
||||
|
||||
int actionIndex = rnd.getRandomNumber(set->numActions() - 1);
|
||||
set->getEntry(actionIndex, actionType, scheduleId);
|
||||
@ -3336,9 +3332,7 @@ void HotspotTickHandlers::goewinCaptiveAnimHandler(Hotspot &h) {
|
||||
|
||||
void HotspotTickHandlers::prisonerAnimHandler(Hotspot &h) {
|
||||
ValueTableData &fields = Resources::getReference().fieldList();
|
||||
Common::RandomSource rnd;
|
||||
|
||||
g_eventRec.registerRandomSource(rnd, "lureHotspots");
|
||||
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
||||
|
||||
h.handleTalkDialog();
|
||||
if (h.frameCtr() > 0) {
|
||||
@ -3380,8 +3374,7 @@ void HotspotTickHandlers::morkusAnimHandler(Hotspot &h) {
|
||||
|
||||
if (h.executeScript()) {
|
||||
// Script is done - set new script to one of two alternates randomly
|
||||
Common::RandomSource rnd;
|
||||
g_eventRec.registerRandomSource(rnd, "lureHotspots");
|
||||
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
||||
|
||||
h.setHotspotScript(rnd.getRandomNumber(100) >= 50 ? 0x54 : 0);
|
||||
h.setFrameCtr(20 + rnd.getRandomNumber(63));
|
||||
@ -3678,11 +3671,9 @@ void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
|
||||
Resources &res = Resources::getReference();
|
||||
Room &room = Room::getReference();
|
||||
BarEntry &barEntry = res.barmanLists().getDetails(h.roomNumber());
|
||||
Common::RandomSource rnd;
|
||||
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
||||
static bool ewanXOffset = false;
|
||||
|
||||
g_eventRec.registerRandomSource(rnd, "lureHotspots");
|
||||
|
||||
h.handleTalkDialog();
|
||||
if (h.delayCtr() > 0) {
|
||||
h.setDelayCtr(h.delayCtr() - 1);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "common/config-manager.h"
|
||||
#include "common/system.h"
|
||||
#include "common/savefile.h"
|
||||
#include "common/EventRecorder.h"
|
||||
|
||||
#include "lure/luredefs.h"
|
||||
#include "lure/surface.h"
|
||||
@ -39,6 +40,7 @@ namespace Lure {
|
||||
static LureEngine *int_engine = NULL;
|
||||
|
||||
LureEngine::LureEngine(OSystem *system, const LureGameDescription *gameDesc): Engine(system), _gameDescription(gameDesc) {
|
||||
g_eventRec.registerRandomSource(_rnd, "lure");
|
||||
|
||||
Common::addDebugChannel(kLureDebugScripts, "scripts", "Scripts debugging");
|
||||
Common::addDebugChannel(kLureDebugAnimations, "animations", "Animations debugging");
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "sound/mixer.h"
|
||||
#include "common/file.h"
|
||||
#include "common/savefile.h"
|
||||
#include "common/util.h"
|
||||
|
||||
#include "lure/disk.h"
|
||||
#include "lure/res.h"
|
||||
@ -43,6 +44,8 @@
|
||||
|
||||
namespace Lure {
|
||||
|
||||
#define RandomNumberGen LureEngine::getReference().rnd()
|
||||
|
||||
struct LureGameDescription;
|
||||
|
||||
class LureEngine : public Engine {
|
||||
@ -59,6 +62,7 @@ private:
|
||||
StringData *_strings;
|
||||
Room *_room;
|
||||
FightsManager *_fights;
|
||||
Common::RandomSource _rnd;
|
||||
|
||||
const char *generateSaveName(int slotNumber);
|
||||
|
||||
@ -86,6 +90,7 @@ public:
|
||||
|
||||
Disk &disk() { return *_disk; }
|
||||
|
||||
Common::RandomSource &rnd() { return _rnd; }
|
||||
int gameToLoad() { return _gameToLoad; }
|
||||
bool loadGame(uint8 slotNumber);
|
||||
bool saveGame(uint8 slotNumber, Common::String &caption);
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "lure/lure.h"
|
||||
#include "common/endian.h"
|
||||
#include "common/events.h"
|
||||
#include "common/EventRecorder.h"
|
||||
|
||||
namespace Lure {
|
||||
|
||||
@ -42,8 +41,7 @@ Resources &Resources::getReference() {
|
||||
return *int_resources;
|
||||
}
|
||||
|
||||
Resources::Resources() {
|
||||
g_eventRec.registerRandomSource(_rnd, "lureResources");
|
||||
Resources::Resources() : _rnd(LureEngine::getReference().rnd()) {
|
||||
int_resources = this;
|
||||
reloadData();
|
||||
|
||||
|
@ -51,7 +51,7 @@ struct TalkDialogDetails {
|
||||
|
||||
class Resources {
|
||||
private:
|
||||
Common::RandomSource _rnd;
|
||||
Common::RandomSource &_rnd;
|
||||
Palette *_paletteSubset;
|
||||
MemoryBlock *_cursors;
|
||||
RoomDataList _roomData;
|
||||
|
@ -739,9 +739,7 @@ void Script::addActions(uint16 hotspotId, uint16 actions, uint16 v3) {
|
||||
// Generates a random number and stores it in the general field
|
||||
|
||||
void Script::randomToGeneral(uint16 maxVal, uint16 minVal, uint16 v3) {
|
||||
Common::RandomSource rnd;
|
||||
g_eventRec.registerRandomSource(rnd, "lureScripts");
|
||||
uint16 v = minVal + rnd.getRandomNumber(maxVal - minVal);
|
||||
uint16 v = minVal + LureEngine::getReference().rnd().getRandomNumber(maxVal - minVal);
|
||||
Resources::getReference().fieldList().setField(GENERAL, v);
|
||||
}
|
||||
|
||||
|
@ -1299,7 +1299,6 @@ CopyProtectionDialog::CopyProtectionDialog() {
|
||||
bool CopyProtectionDialog::show() {
|
||||
Screen &screen = Screen::getReference();
|
||||
Events &events = Events::getReference();
|
||||
Common::RandomSource rnd;
|
||||
LureEngine &engine = LureEngine::getReference();
|
||||
|
||||
screen.setPaletteEmpty();
|
||||
@ -1403,8 +1402,9 @@ bool CopyProtectionDialog::show() {
|
||||
|
||||
void CopyProtectionDialog::chooseCharacters() {
|
||||
Screen &screen = Screen::getReference();
|
||||
int char1 = _rnd.getRandomNumber(19);
|
||||
int char2 = _rnd.getRandomNumber(19);
|
||||
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
||||
int char1 = rnd.getRandomNumber(19);
|
||||
int char2 = rnd.getRandomNumber(19);
|
||||
|
||||
HotspotsList::iterator curHotspot = _hotspots.begin();
|
||||
(curHotspot->get())->setFrameNumber(char1);
|
||||
|
@ -140,7 +140,6 @@ public:
|
||||
|
||||
class CopyProtectionDialog {
|
||||
private:
|
||||
Common::RandomSource _rnd;
|
||||
typedef Common::List<Common::SharedPtr<Hotspot> > HotspotsList;
|
||||
HotspotsList _hotspots;
|
||||
int _charIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user