From 46ef60e1b93603dc6fc6e7543959ca9efdfd3f2a Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 10 Apr 2006 06:40:15 +0000 Subject: Merged o_chance() into o1_chance(). svn-id: r21743 --- engines/simon/items.cpp | 61 ++++++++++++++++++++++++------------------------- engines/simon/simon.h | 2 -- 2 files changed, 30 insertions(+), 33 deletions(-) (limited to 'engines/simon') diff --git a/engines/simon/items.cpp b/engines/simon/items.cpp index b2d7218945..c3d668a3bb 100644 --- a/engines/simon/items.cpp +++ b/engines/simon/items.cpp @@ -447,7 +447,36 @@ void SimonEngine::o1_gtf() { void SimonEngine::o1_chance() { // 23 - setScriptCondition(o_chance(getVarOrWord())); + uint a = getVarOrWord(); + + if (a == 0) { + setScriptCondition(false); + return; + } + + if (a == 100) { + setScriptCondition(true); + return; + } + + a += _scriptUnk1; + + if (a <= 0) { + _scriptUnk1 = 0; + setScriptCondition(false); + } else if ((uint)_rnd.getRandomNumber(99) < a) { + if (_scriptUnk1 <= 0) + _scriptUnk1 -= 5; + else + _scriptUnk1 = 0; + setScriptCondition(true); + } else { + if (_scriptUnk1 >= 0) + _scriptUnk1 += 5; + else + _scriptUnk1 = 0; + setScriptCondition(false); + } } void SimonEngine::o1_isRoom() { @@ -1717,36 +1746,6 @@ void SimonEngine::o_waitForMark(uint i) { } } - -bool SimonEngine::o_chance(uint a) { - if (a == 0) - return 0; - - if (a == 100) - return 1; - - a += _scriptUnk1; - if (a <= 0) { - _scriptUnk1 = 0; - return 0; - } - - if ((uint)_rnd.getRandomNumber(99) < a) { - if (_scriptUnk1 <= 0) - _scriptUnk1 -= 5; - else - _scriptUnk1 = 0; - return 1; - } - - if (_scriptUnk1 >= 0) - _scriptUnk1 += 5; - else - _scriptUnk1 = 0; - - return 0; -} - void SimonEngine::o_inventory_descriptions() { uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); diff --git a/engines/simon/simon.h b/engines/simon/simon.h index 423b03887e..74c73c873e 100644 --- a/engines/simon/simon.h +++ b/engines/simon/simon.h @@ -554,8 +554,6 @@ protected: void unlinkItem(Item *item); void linkItem(Item *item, Item *parent); - bool o_chance(uint a); - void o_kill_sprite_simon1(uint a); void o_kill_sprite_simon2(uint a, uint b); -- cgit v1.2.3