diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/teenagent/actor.cpp | 7 | ||||
-rw-r--r-- | engines/teenagent/actor.h | 6 | ||||
-rw-r--r-- | engines/teenagent/callbacks.cpp | 4 | ||||
-rw-r--r-- | engines/teenagent/scene.cpp | 2 | ||||
-rw-r--r-- | engines/teenagent/teenagent.cpp | 8 | ||||
-rw-r--r-- | engines/teenagent/teenagent.h | 4 |
6 files changed, 18 insertions, 13 deletions
diff --git a/engines/teenagent/actor.cpp b/engines/teenagent/actor.cpp index 870410b2c2..717c022c38 100644 --- a/engines/teenagent/actor.cpp +++ b/engines/teenagent/actor.cpp @@ -31,10 +31,9 @@ namespace TeenAgent { Actor::Actor() : head_index(0), idle_type(0) {} //idle animation lists at dseg: 0x6540 -Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, uint zoom) { - static Common::RandomSource random; +Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, uint zoom, Common::RandomSource &rnd) { if (index == 0) { - idle_type = random.getRandomNumber(2); + idle_type = rnd.getRandomNumber(2); debug(0, "switched to idle animation %u", idle_type); } @@ -44,7 +43,7 @@ Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point & frames_idle = res->dseg.ptr(res->dseg.get_word(0x6540 + idle_type * 2)) + index; index += delta_frame; if (*frames_idle == 0) { - idle_type = random.getRandomNumber(2); + idle_type = rnd.getRandomNumber(2); debug(0, "switched to idle animation %u[loop]", idle_type); index = 3; //put 4th frame (base 1) if idle animation loops } diff --git a/engines/teenagent/actor.h b/engines/teenagent/actor.h index 5e13af10ea..9a7d395547 100644 --- a/engines/teenagent/actor.h +++ b/engines/teenagent/actor.h @@ -22,6 +22,10 @@ #include "teenagent/animation.h" #include "common/rect.h" +namespace Common { +class RandomSource; +} + namespace TeenAgent { class Actor : public Animation { @@ -30,7 +34,7 @@ class Actor : public Animation { public: Actor(); Common::Rect render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, bool head, uint zoom); - Common::Rect renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, uint zoom); + Common::Rect renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, uint zoom, Common::RandomSource &rnd); }; } // End of namespace TeenAgent diff --git a/engines/teenagent/callbacks.cpp b/engines/teenagent/callbacks.cpp index 8c8519e51b..ae498478a4 100644 --- a/engines/teenagent/callbacks.cpp +++ b/engines/teenagent/callbacks.cpp @@ -36,7 +36,7 @@ namespace TeenAgent { void TeenAgentEngine::rejectMessage() { Resources * res = Resources::instance(); //random reject message: - uint i = random.getRandomNumber(3); + uint i = _rnd.getRandomNumber(3); //debug(0, "reject message: %s", (const char *)res->dseg.ptr(res->dseg.get_word(0x339e + 2 * i))); displayMessage(res->dseg.get_word(0x339e + 2 * i)); } @@ -3004,7 +3004,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) { moveTo(153, 163, 4); playActorAnimation(973); if (CHECK_FLAG(0xDBC1, 0)) { - SET_FLAG(0xDBC1, random.getRandomNumber(5) + 1); + SET_FLAG(0xDBC1, _rnd.getRandomNumber(5) + 1); } loadScene(30, 18, 159, 2); return true; diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp index 54c3ce928d..ef18b95f5a 100644 --- a/engines/teenagent/scene.cpp +++ b/engines/teenagent/scene.cpp @@ -804,7 +804,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) { if (_idle_timer < 50) actor_animation_position = teenagent.render(surface, position, orientation, 0, actor_talking, zoom); else - actor_animation_position = teenagent_idle.renderIdle(surface, position, orientation, mark_delta, zoom); + actor_animation_position = teenagent_idle.renderIdle(surface, position, orientation, mark_delta, zoom, _engine->_rnd); } } diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp index d8cbae9fac..f076dbc0a1 100644 --- a/engines/teenagent/teenagent.cpp +++ b/engines/teenagent/teenagent.cpp @@ -47,7 +47,9 @@ namespace TeenAgent { -TeenAgentEngine::TeenAgentEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), action(kActionNone), _gameDescription(gd) { +TeenAgentEngine::TeenAgentEngine(OSystem *system, const ADGameDescription *gd) + : Engine(system), action(kActionNone), _gameDescription(gd), + _rnd("teenagent") { music = new MusicPlayer(); console = 0; @@ -396,8 +398,8 @@ bool TeenAgentEngine::showMetropolis() { //generate colors matrix memmove(colors + 320, colors + 480, 8480); for(uint c = 0; c < 17; ++c) { - byte x = (random.getRandomNumber(184) + 5) & 0xff; - uint offset = 8800 + random.getRandomNumber(158); + byte x = (_rnd.getRandomNumber(184) + 5) & 0xff; + uint offset = 8800 + _rnd.getRandomNumber(158); colors[offset++] = x; colors[offset++] = x; } diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h index a376b379ba..bc802da8bc 100644 --- a/engines/teenagent/teenagent.h +++ b/engines/teenagent/teenagent.h @@ -47,7 +47,7 @@ class Scene; class MusicPlayer; class Console; -class TeenAgentEngine: public Engine { +class TeenAgentEngine : public Engine { public: enum Action { kActionNone, kActionExamine, kActionUse }; @@ -117,7 +117,7 @@ public: void fadeOut(); void wait(uint16 frames); - Common::RandomSource random; + Common::RandomSource _rnd; Scene *scene; Inventory *inventory; |