Ticket #8693: TEST6.patch

File TEST6.patch, 24.5 KB (added by SF/h00ligan, 17 years ago)

Recorder patch

  • backends/events/default/default-events.cpp

     
    2727
    2828#include "common/stdafx.h"
    2929#include "common/system.h"
     30#include "common/config-manager.h"
    3031#include "backends/events/default/default-events.h"
    3132
     33#define RECORD_SIGNATURE 0x54455354
     34#define RECORD_VERSION 1
     35
     36void readRecord(Common::InSaveFile *inFile, uint32 &diff, Common::Event &event) {
     37        diff = inFile->readUint32LE();
     38
     39        event.type = (Common::EventType)inFile->readUint32LE();
     40
     41        switch(event.type) {
     42                case Common::EVENT_KEYDOWN:
     43                case Common::EVENT_KEYUP:
     44                        event.kbd.keycode = inFile->readSint32LE();
     45                        event.kbd.ascii = inFile->readUint16LE();
     46                        event.kbd.flags = inFile->readByte();
     47                        break;
     48                case Common::EVENT_MOUSEMOVE:
     49                case Common::EVENT_LBUTTONDOWN:
     50                case Common::EVENT_LBUTTONUP:
     51                case Common::EVENT_RBUTTONDOWN:
     52                case Common::EVENT_RBUTTONUP:
     53                case Common::EVENT_WHEELUP:
     54                case Common::EVENT_WHEELDOWN:
     55                        event.mouse.x = inFile->readSint16LE();
     56                        event.mouse.y = inFile->readSint16LE();
     57                        break;
     58        }       
     59}
     60
     61void writeRecord(Common::OutSaveFile *outFile, uint32 diff, Common::Event &event) {
     62        outFile->writeUint32LE(diff);
     63
     64        outFile->writeUint32LE((uint32)event.type);
     65
     66        switch(event.type) {
     67                case Common::EVENT_KEYDOWN:
     68                case Common::EVENT_KEYUP:
     69                        outFile->writeSint32LE(event.kbd.keycode);
     70                        outFile->writeUint16LE(event.kbd.ascii);
     71                        outFile->writeByte(event.kbd.flags);
     72                        break;
     73                case Common::EVENT_MOUSEMOVE:
     74                case Common::EVENT_LBUTTONDOWN:
     75                case Common::EVENT_LBUTTONUP:
     76                case Common::EVENT_RBUTTONDOWN:
     77                case Common::EVENT_RBUTTONUP:
     78                case Common::EVENT_WHEELUP:
     79                case Common::EVENT_WHEELDOWN:
     80                        outFile->writeSint16LE(event.mouse.x);
     81                        outFile->writeSint16LE(event.mouse.y);
     82                        break;
     83        }
     84}
     85
    3286DefaultEventManager::DefaultEventManager(OSystem *boss) :
    3387        _boss(boss),
    3488        _buttonState(0),
     
    3791
    3892        assert(_boss);
    3993
     94        _recordFile = NULL;
     95        _recordTimeFile = NULL;
     96        _playbackFile = NULL;
     97        _playbackTimeFile = NULL;
     98        _timeMutex = _boss->createMutex();
     99        _recorderMutex = _boss->createMutex();
     100
     101        _eventCount = 0;
     102        _lastEventCount = 0;
     103        _lastMillis = 0;
     104
     105        Common::String recordModeString = ConfMan.get("record_mode");
     106        if (recordModeString.compareToIgnoreCase("record") == 0) {
     107                _recordMode = kRecorderRecord;
     108        } else {
     109                if (recordModeString.compareToIgnoreCase("playback") == 0) {
     110                        _recordMode = kRecorderPlayback;
     111                } else {
     112                        _recordMode = kPassthrough;
     113                }
     114        }
     115
     116        _recordFileName = ConfMan.get("record_file_name");
     117        if (_recordFileName.empty()) {
     118                _recordFileName = "record.bin";
     119        }
     120        _recordTempFileName = ConfMan.get("record_temp_file_name");
     121        if (_recordTempFileName.empty()) {
     122                _recordTempFileName = "record.tmp";
     123        }
     124        _recordTimeFileName = ConfMan.get("record_time_file_name");
     125        if (_recordTimeFileName.empty()) {
     126                _recordTimeFileName = "record.time";
     127        }
     128
    40129        // Reset key repeat
    41130        _currentKeyDown.keycode = 0;
     131
     132        // recorder stuff
     133        if (_recordMode == kRecorderRecord) {
     134                _recordCount = 0;
     135                _recordTimeCount = 0;
     136                _recordFile = _boss->getSavefileManager()->openForSaving(_recordTempFileName.c_str());
     137                _recordTimeFile = _boss->getSavefileManager()->openForSaving(_recordTimeFileName.c_str());
     138                _recordSubtitles = ConfMan.getBool("subtitles");
     139        }
     140
     141        uint32 sign;
     142        uint32 version;
     143        uint32 randomSourceCount;
     144        if (_recordMode == kRecorderPlayback) {
     145                _playbackCount = 0;
     146                _playbackTimeCount = 0;
     147                _playbackFile = _boss->getSavefileManager()->openForLoading(_recordFileName.c_str());
     148                _playbackTimeFile = _boss->getSavefileManager()->openForLoading(_recordTimeFileName.c_str());
     149                sign = _playbackFile->readUint32LE();
     150                if (sign != RECORD_SIGNATURE) {
     151                        error("Unknown record file signature");
     152                }
     153                version = _playbackFile->readUint32LE();
     154
     155                // conf vars
     156                ConfMan.setBool("subtitles", _playbackFile->readByte() != 0);
     157               
     158                _recordCount = _playbackFile->readUint32LE();
     159                _recordTimeCount = _playbackFile->readUint32LE();
     160                randomSourceCount = _playbackFile->readUint32LE();
     161                for (uint i = 0; i < randomSourceCount; ++i) {
     162                        RandomSourceRecord rec;
     163                        rec.name = "";
     164                        uint32 sLen = _playbackFile->readUint32LE();
     165                        for (uint j = 0; j < sLen; ++j) {
     166                                char c = _playbackFile->readSByte();
     167                                rec.name += c;
     168                        }
     169                        rec.seed = _playbackFile->readUint32LE();
     170                        _randomSourceRecords.push_back(rec);
     171                }
     172
     173                _hasPlaybackEvent = false;
     174        }
    42175}
    43176
     177DefaultEventManager::~DefaultEventManager() {
     178        _boss->lockMutex(_timeMutex);
     179        _boss->lockMutex(_recorderMutex);
     180        _recordMode = kPassthrough;
     181        _boss->unlockMutex(_timeMutex);
     182        _boss->unlockMutex(_recorderMutex);
     183       
     184        if (_playbackFile != NULL) {
     185                delete _playbackFile;
     186        }
     187        if (_playbackTimeFile != NULL) {
     188                delete _playbackTimeFile;
     189        }
     190
     191        if (_recordFile != NULL) {
     192                _recordFile->finalize();
     193                delete _recordFile;
     194                _recordTimeFile->finalize();
     195                delete _recordTimeFile;
     196
     197                _playbackFile = _boss->getSavefileManager()->openForLoading(_recordTempFileName.c_str());
     198
     199                _recordFile = _boss->getSavefileManager()->openForSaving(_recordFileName.c_str());
     200                _recordFile->writeUint32LE(RECORD_SIGNATURE);
     201                _recordFile->writeUint32LE(RECORD_VERSION);
     202               
     203                // conf vars
     204                _recordFile->writeByte(_recordSubtitles ? 1 : 0);
     205               
     206                _recordFile->writeUint32LE(_recordCount);
     207                _recordFile->writeUint32LE(_recordTimeCount);
     208               
     209                _recordFile->writeUint32LE(_randomSourceRecords.size());
     210                for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
     211                        _recordFile->writeUint32LE(_randomSourceRecords[i].name.size());
     212                        _recordFile->writeString(_randomSourceRecords[i].name);
     213                        _recordFile->writeUint32LE(_randomSourceRecords[i].seed);
     214                }
     215
     216                for (uint i = 0; i < _recordCount; ++i) {
     217                        uint32 tempDiff;
     218                        Common::Event tempEvent;
     219                        readRecord(_playbackFile, tempDiff, tempEvent);
     220                        writeRecord(_recordFile, tempDiff, tempEvent);
     221                }
     222
     223                _recordFile->finalize();
     224                delete _recordFile;
     225                delete _playbackFile;
     226               
     227                //TODO: remove recordTempFileName'ed file
     228        }
     229        _boss->deleteMutex(_timeMutex);
     230        _boss->deleteMutex(_recorderMutex);
     231}
     232
     233bool DefaultEventManager::playback(Common::Event &event) {
     234       
     235        if (!_hasPlaybackEvent) {
     236                if (_recordCount > _playbackCount) {
     237                        readRecord(_playbackFile, (uint32&)_playbackDiff, _playbackEvent);
     238                        _playbackCount++;
     239                        _hasPlaybackEvent = true;
     240                }
     241        }
     242
     243        if (_hasPlaybackEvent) {
     244                if (_playbackDiff <= (_eventCount - _lastEventCount)) {
     245                        switch(_playbackEvent.type) {
     246                                case Common::EVENT_MOUSEMOVE:
     247                                case Common::EVENT_LBUTTONDOWN:
     248                                case Common::EVENT_LBUTTONUP:
     249                                case Common::EVENT_RBUTTONDOWN:
     250                                case Common::EVENT_RBUTTONUP:
     251                                case Common::EVENT_WHEELUP:
     252                                case Common::EVENT_WHEELDOWN:
     253                                        _boss->warpMouse(_playbackEvent.mouse.x, _playbackEvent.mouse.y);
     254                                        break;
     255                        }       
     256                        event = _playbackEvent;
     257                        _hasPlaybackEvent = false;
     258                        _lastEventCount = _eventCount;
     259                        return true;
     260                }
     261        }
     262               
     263        return false;
     264}
     265
     266void DefaultEventManager::record(Common::Event &event) {
     267        writeRecord(_recordFile, _eventCount - _lastEventCount, event);
     268       
     269        _recordCount++;
     270        _lastEventCount = _eventCount;
     271}
     272
     273void DefaultEventManager::registerRandomSource(Common::RandomSource &rnd, const char *name) {
     274       
     275        if (_recordMode == kRecorderRecord) {
     276                RandomSourceRecord rec;
     277                rec.name = name;
     278                rec.seed = rnd.getSeed();
     279                _randomSourceRecords.push_back(rec);
     280        }
     281
     282        if (_recordMode == kRecorderPlayback) {
     283                for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
     284                        if (_randomSourceRecords[i].name == name) {
     285                                rnd.setSeed(_randomSourceRecords[i].seed);
     286                                _randomSourceRecords.remove_at(i);
     287                                break;
     288                        }
     289                }
     290        }
     291}
     292
     293void DefaultEventManager::processMillis(uint32 &millis) {
     294        uint32 d;
     295        if (_recordMode == kPassthrough) {
     296                return;
     297        }
     298
     299        _boss->lockMutex(_timeMutex);
     300        if (_recordMode == kRecorderRecord) {
     301                //Simple RLE compression
     302                d = millis - _lastMillis;
     303                if (d >= 0xff) {
     304                        _recordTimeFile->writeByte(0xff);
     305                        _recordTimeFile->writeUint32LE(d);
     306                } else {
     307                        _recordTimeFile->writeByte(d);
     308                }
     309                _recordTimeCount++;
     310        }
     311
     312        if (_recordMode == kRecorderPlayback) {
     313                if (_recordTimeCount > _playbackTimeCount) {
     314                        d = _playbackTimeFile->readByte();
     315                        if (d == 0xff) {
     316                                d = _playbackTimeFile->readUint32LE();
     317                        }
     318                        millis = _lastMillis + d;
     319                        _playbackTimeCount++;
     320                }
     321        }
     322        _lastMillis = millis;
     323        _boss->unlockMutex(_timeMutex);
     324}
     325
    44326bool DefaultEventManager::pollEvent(Common::Event &event) {
    45327        uint32 time = _boss->getMillis();
    46328        bool result;
    47329       
     330
    48331        result = _boss->pollEvent(event);
    49        
     332
     333        if (_recordMode != kPassthrough)  {
     334
     335                _boss->lockMutex(_recorderMutex);
     336                _eventCount++;
     337
     338                if (_recordMode == kRecorderPlayback)  {
     339                        if (event.type != Common::EVENT_QUIT) {
     340                                result = playback(event);
     341                        }
     342                } else {               
     343                        if (_recordMode == kRecorderRecord) {
     344                                if (result) {
     345                                        record(event);
     346                                }
     347                        }
     348                }
     349                _boss->unlockMutex(_recorderMutex);
     350        }
     351               
    50352        if (result) {
    51353                event.synthetic = false;
    52354                switch (event.type) {
  • backends/events/default/default-events.h

     
    2828
    2929#include "common/stdafx.h"
    3030#include "common/events.h"
     31#include "common/savefile.h"
    3132
    3233/*
    3334At some point we will remove pollEvent from OSystem and change
     
    4849        int _buttonState;
    4950        int _modifierState;
    5051        bool _shouldQuit;
     52       
     53        class RandomSourceRecord {
     54        public:
     55                Common::String name;
     56                uint32 seed;
     57        };
     58        Common::Array<RandomSourceRecord> _randomSourceRecords;
    5159
     60        bool _recordSubtitles;
     61        volatile uint32 _recordCount;
     62        volatile uint32 _lastRecordEvent;
     63        volatile uint32 _recordTimeCount;
     64        Common::OutSaveFile *_recordFile;
     65        Common::OutSaveFile *_recordTimeFile;
     66        Common::MutexRef _timeMutex;
     67        Common::MutexRef _recorderMutex;
     68        volatile uint32 _lastMillis;
     69
     70        volatile uint32 _playbackCount;
     71        volatile uint32 _playbackDiff;
     72        volatile bool _hasPlaybackEvent;
     73        volatile uint32 _playbackTimeCount;
     74        Common::Event _playbackEvent;   
     75        Common::InSaveFile *_playbackFile;
     76        Common::InSaveFile *_playbackTimeFile;
     77
     78        volatile uint32 _eventCount;
     79        volatile uint32 _lastEventCount;
     80
     81        enum RecordMode {
     82                kPassthrough = 0,
     83                kRecorderRecord = 1,
     84                kRecorderPlayback = 2
     85        };
     86        volatile RecordMode _recordMode;
     87        Common::String _recordFileName;
     88        Common::String _recordTempFileName;
     89        Common::String _recordTimeFileName;
     90       
    5291        // for continuous events (keyDown)
    5392        enum {
    5493                kKeyRepeatInitialDelay = 400,
     
    62101        } _currentKeyDown;
    63102        uint32 _keyRepeatTime;
    64103
     104        void record(Common::Event &event);
     105        bool playback(Common::Event &event);
    65106public:
    66107        DefaultEventManager(OSystem *boss);
     108        ~DefaultEventManager();
    67109
    68110        virtual bool pollEvent(Common::Event &event);
     111        virtual void registerRandomSource(Common::RandomSource &rnd, const char *name);
     112        virtual void processMillis(uint32 &millis);
    69113
    70114        virtual Common::Point getMousePos() const { return _mousePos; }
    71115        virtual int getButtonState() const { return _buttonState; }
  • backends/platform/sdl/sdl.cpp

     
    3333#include "backends/plugins/sdl/sdl-provider.h"
    3434#include "common/config-manager.h"
    3535#include "common/util.h"
     36#include "common/events.h"
    3637#include "base/main.h"
    3738
    3839#include "backends/saves/default/default-saves.h"
     
    273274}
    274275
    275276uint32 OSystem_SDL::getMillis() {
    276         return SDL_GetTicks();
     277        uint32 millis = SDL_GetTicks();
     278        getEventManager()->processMillis(millis);
     279        return millis;
    277280}
    278281
    279282void OSystem_SDL::delayMillis(uint msecs) {
     
    354357        SDL_ShowCursor(SDL_ENABLE);
    355358        SDL_Quit();
    356359
     360        delete getEventManager();
    357361        exit(0);
    358362}
    359363
  • common/events.h

     
    167167         */
    168168        virtual bool pollEvent(Common::Event &event) = 0;
    169169
    170 
     170        /** Register random source so it can be serialized in game test purposes **/
     171        virtual void registerRandomSource(Common::RandomSource &rnd, const char *name) = 0;
     172       
     173        virtual void processMillis(uint32 &millis) = 0;
     174       
    171175        /** Return the current key state */
    172176        virtual Common::Point getMousePos() const = 0;
    173177       
  • common/util.h

     
    7272public:
    7373        RandomSource();
    7474        void setSeed(uint32 seed);
     75       
     76        uint32 getSeed() {
     77                return _randSeed;
     78        }
    7579
    7680        /**
    7781         * Generates a random unsigned integer in the interval [0, max].
  • engines/agi/agi.cpp

     
    546546                        _gameId = g->id;
    547547
    548548        _rnd = new Common::RandomSource();
     549        syst->getEventManager()->registerRandomSource(*_rnd, "agi");
    549550
    550551        Common::addSpecialDebugLevel(kDebugLevelMain, "Main", "Generic debug level");
    551552        Common::addSpecialDebugLevel(kDebugLevelResources, "Resources", "Resources debugging");
  • engines/agos/agos.cpp

     
    2828#include "common/config-manager.h"
    2929#include "common/file.h"
    3030#include "common/system.h"
     31#include "common/events.h"
    3132
    3233#include "agos/debugger.h"
    3334#include "agos/intern.h"
     
    534535        File::addDefaultDirectory(_gameDataPath + "SFX");
    535536        File::addDefaultDirectory(_gameDataPath + "speech");
    536537        File::addDefaultDirectory(_gameDataPath + "SPEECH");
     538       
     539        syst->getEventManager()->registerRandomSource(_rnd, "agos");
    537540}
    538541
    539542int AGOSEngine::init() {
  • engines/cine/main_loop.cpp

     
    125125                                }
    126126                                break;
    127127                        case 291: // F10
    128                                 if (!disableSystemMenu && !inMenu) {
     128                                disableSystemMenu = false;
     129                                //if (!disableSystemMenu && !inMenu) {
    129130                                        g_cine->makeSystemMenu();
    130                                 }
     131                                //}
    131132                                break;
    132133                        default:
    133134                                lastKeyStroke = event.kbd.keycode;
  • engines/gob/gob.cpp

     
    2525
    2626#include "common/stdafx.h"
    2727#include "common/endian.h"
     28#include "common/events.h"
    2829
    2930#include "base/plugins.h"
    3031#include "common/config-manager.h"
     
    8889        Common::addSpecialDebugLevel(kDebugFileIO, "FileIO", "File Input/Output debug level");
    8990        Common::addSpecialDebugLevel(kDebugGraphics, "Graphics", "Graphics debug level");
    9091        Common::addSpecialDebugLevel(kDebugCollisions, "Collisions", "Collisions debug level");
     92        syst->getEventManager()->registerRandomSource(_rnd, "gob");
    9193}
    9294
    9395GobEngine::~GobEngine() {
  • engines/kyra/kyra.cpp

     
    121121        Common::addSpecialDebugLevel(kDebugLevelGUI, "GUI", "GUI debug level");
    122122        Common::addSpecialDebugLevel(kDebugLevelSequence, "Sequence", "Sequence debug level");
    123123        Common::addSpecialDebugLevel(kDebugLevelMovie, "Movie", "Movie debug level");
     124        system->getEventManager()->registerRandomSource(_rnd, "kyra");
    124125}
    125126
    126127int KyraEngine::init() {
  • engines/kyra/sprites.cpp

     
    2828#include "common/stream.h"
    2929#include "common/util.h"
    3030#include "common/system.h"
     31#include "common/events.h"
    3132#include "kyra/screen.h"
    3233#include "kyra/kyra.h"
    3334#include "kyra/sprites.h"
     
    4748        _spriteDefStart = 0;
    4849        memset(_drawLayerTable, 0, sizeof(_drawLayerTable));
    4950        _sceneAnimatorBeaconFlag = 0;
     51        system->getEventManager()->registerRandomSource(_rnd, "kyraSprites");
    5052}
    5153
    5254Sprites::~Sprites() {
  • engines/lure/hotspots.cpp

     
    542542        Common::RandomSource rnd;
    543543        int16 xp, yp;
    544544
     545        g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
     546
    545547        if (_currentActions.isEmpty())
    546548                _currentActions.addFront(START_WALKING, roomNumber());
    547549        else
     
    28352837        Common::RandomSource rnd;
    28362838        RandomActionType actionType;
    28372839        uint16 scheduleId;
     2840        g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
     2841
    28382842        int actionIndex = rnd.getRandomNumber(set->numActions() - 1);
    28392843        set->getEntry(actionIndex, actionType, scheduleId);
    28402844
     
    30233027        ValueTableData &fields = Resources::getReference().fieldList();
    30243028        Common::RandomSource rnd;
    30253029
     3030        g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
     3031
    30263032        h.handleTalkDialog();
    30273033        if (h.frameCtr() > 0) {
    30283034                h.setFrameCtr(h.frameCtr() - 1);
     
    30633069        if (h.executeScript()) {
    30643070                // Script is done - set new script to one of two alternates randomly
    30653071                Common::RandomSource rnd;
     3072                g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
     3073
    30663074                h.setHotspotScript(rnd.getRandomNumber(100) >= 50 ? 0x54 : 0);
    30673075                h.setFrameCtr(20 + rnd.getRandomNumber(63));
    30683076        }
     
    33193327        Common::RandomSource rnd;
    33203328        static bool ewanXOffset = false;
    33213329
     3330        g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
     3331
    33223332        h.handleTalkDialog();
    33233333        if (h.delayCtr() > 0) {
    33243334                h.setDelayCtr(h.delayCtr() - 1);
  • engines/lure/res.cpp

     
    2828#include "lure/scripts.h"
    2929#include "lure/screen.h"
    3030#include "common/endian.h"
     31#include "common/events.h"
    3132
    3233namespace Lure {
    3334
     
    4041}
    4142
    4243Resources::Resources() {
     44        g_system->getEventManager()->registerRandomSource(_rnd, "lureResources");
    4345        int_resources = this;
    4446        reloadData();
    4547}
  • engines/lure/scripts.cpp

     
    566566
    567567void Script::randomToGeneral(uint16 maxVal, uint16 minVal, uint16 v3) {
    568568        Common::RandomSource rnd;
     569        g_system->getEventManager()->registerRandomSource(rnd, "lureScripts");
    569570        uint16 v = minVal + rnd.getRandomNumber(maxVal - minVal);
    570571        Resources::getReference().fieldList().setField(GENERAL, v);
    571572}
  • engines/queen/display.cpp

     
    2525
    2626#include "common/stdafx.h"
    2727#include "common/system.h"
     28#include "common/events.h"
    2829
    2930#include "graphics/cursorman.h"
    3031
     
    8182        memset(&_dynalum, 0, sizeof(_dynalum));
    8283
    8384        setupInkColors();
     85        system->getEventManager()->registerRandomSource(_rnd, "queenDisplay");
    8486}
    8587
    8688Display::~Display() {
  • engines/queen/music.cpp

     
    2424 */
    2525
    2626#include "common/stdafx.h"
     27#include "common/system.h"
     28#include "common/events.h"
    2729#include "queen/music.h"
    2830#include "queen/queen.h"
    2931#include "queen/resource.h"
     
    4850        this->open();
    4951
    5052        _tune = vm->resource()->isDemo() ? Sound::_tuneDemo : Sound::_tune;
     53        vm->_system->getEventManager()->registerRandomSource(_rnd, "queenMusic");
    5154}
    5255
    5356MidiMusic::~MidiMusic() {
  • engines/queen/queen.cpp

     
    3232#include "common/fs.h"
    3333#include "common/savefile.h"
    3434#include "common/system.h"
     35#include "common/events.h"
    3536
    3637#include "queen/queen.h"
    3738#include "queen/bankman.h"
     
    110111
    111112QueenEngine::QueenEngine(OSystem *syst)
    112113        : Engine(syst), _debugger(0) {
     114        syst->getEventManager()->registerRandomSource(randomizer, "queen");
    113115}
    114116
    115117QueenEngine::~QueenEngine() {
  • engines/saga/saga.cpp

     
    2828#include "common/file.h"
    2929#include "common/config-manager.h"
    3030#include "common/system.h"
     31#include "common/events.h"
    3132
    3233#include "sound/mixer.h"
    3334
     
    114115        }
    115116
    116117        _displayClip.left = _displayClip.top = 0;
     118        syst->getEventManager()->registerRandomSource(_rnd, "saga");
    117119}
    118120
    119121SagaEngine::~SagaEngine() {
  • engines/scumm/scumm.cpp

     
    532532        // Add debug levels     
    533533        for (int i = 0; i < ARRAYSIZE(debugChannels); ++i)
    534534                Common::addSpecialDebugLevel(debugChannels[i].flag,  debugChannels[i].channel, debugChannels[i].desc);
     535
     536        syst->getEventManager()->registerRandomSource(_rnd, "scumm");
    535537}
    536538
    537539
  • engines/sky/logic.cpp

     
    2626#include "common/stdafx.h"
    2727#include "common/endian.h"
    2828#include "common/rect.h"
     29#include "common/events.h"
    2930
    3031#include "sky/autoroute.h"
    3132#include "sky/compact.h"
     
    7172}
    7273
    7374Logic::Logic(SkyCompact *skyCompact, Screen *skyScreen, Disk *skyDisk, Text *skyText, MusicBase *skyMusic, Mouse *skyMouse, Sound *skySound) {
     75        g_system->getEventManager()->registerRandomSource(_rnd, "sky");
     76
    7477        _skyCompact = skyCompact;
    7578        _skyScreen = skyScreen;
    7679        _skyDisk = skyDisk;
  • engines/sword1/logic.cpp

     
    2626#include "common/stdafx.h"
    2727#include "common/endian.h"
    2828#include "common/util.h"
     29#include "common/system.h"
     30#include "common/events.h"
    2931
    3032#include "sword1/logic.h"
    3133#include "sword1/text.h"
     
    5456uint32 Logic::_scriptVars[NUM_SCRIPT_VARS];
    5557
    5658Logic::Logic(ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer) {
     59        g_system->getEventManager()->registerRandomSource(_rnd, "sword1");
     60
    5761        _objMan = pObjMan;
    5862        _resMan = resMan;
    5963        _screen = pScreen;
  • engines/sword1/sound.cpp

     
    2727#include "common/endian.h"
    2828
    2929#include "common/util.h"
     30#include "common/system.h"
     31#include "common/events.h"
    3032
    3133#include "sword1/sound.h"
    3234#include "sword1/resman.h"
     
    4345#define SPEECH_FLAGS (Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_LITTLE_ENDIAN)
    4446
    4547Sound::Sound(const char *searchPath, Audio::Mixer *mixer, ResMan *pResMan) {
     48        g_system->getEventManager()->registerRandomSource(_rnd, "sword1sound");
    4649        strcpy(_filePath, searchPath);
    4750        _mixer = mixer;
    4851        _resMan = pResMan;
  • engines/sword2/sword2.cpp

     
    209209        _gameSpeed = 1;
    210210
    211211        _quit = false;
     212        syst->getEventManager()->registerRandomSource(_rnd, "sword2");
    212213}
    213214
    214215Sword2Engine::~Sword2Engine() {
  • engines/touche/touche.cpp

     
    7373        Common::addSpecialDebugLevel(kDebugResource, "Resource", "Resource debug level");
    7474        Common::addSpecialDebugLevel(kDebugOpcodes,  "Opcodes",  "Opcodes debug level");
    7575        Common::addSpecialDebugLevel(kDebugUserIntf, "UserIntf", "UserInterface debug level");
     76        system->getEventManager()->registerRandomSource(_rnd, "touche");
    7677}
    7778
    7879ToucheEngine::~ToucheEngine() {