aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-07 11:45:27 -0400
committerPaul Gilbert2016-08-07 11:45:27 -0400
commitda0669b82bcc29fd6b926d27c63812aa17164f10 (patch)
treeb14218cdfc0d1405e0998b818dba3736d520457a /engines/titanic
parentef2dda7e2ef945c0a8b49af3e24381d3f66e22d1 (diff)
downloadscummvm-rg350-da0669b82bcc29fd6b926d27c63812aa17164f10.tar.gz
scummvm-rg350-da0669b82bcc29fd6b926d27c63812aa17164f10.tar.bz2
scummvm-rg350-da0669b82bcc29fd6b926d27c63812aa17164f10.zip
TITANIC: Add getNewRandomNumber to CGameObject
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/core/game_object.cpp10
-rw-r--r--engines/titanic/core/game_object.h5
2 files changed, 15 insertions, 0 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 73e3511319..89e3ded248 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -1392,6 +1392,16 @@ void CGameObject::resetMail() {
mailMan->resetValue();
}
+int CGameObject::getNewRandomNumber(int max, int *oldVal) {
+ if (oldVal) {
+ int startingVal = *oldVal;
+ while (*oldVal == startingVal && max > 0)
+ *oldVal = g_vm->getRandomNumber(max);
+ } else {
+ return g_vm->getRandomNumber(max);
+ }
+}
+
/*------------------------------------------------------------------------*/
CRoomItem *CGameObject::getRoom() const {
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index fdbbcd6959..665fc6cf37 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -513,6 +513,11 @@ protected:
* Scroll text down
*/
void scrollTextDown();
+
+ /**
+ * Gets a new random number
+ */
+ int getNewRandomNumber(int max, int *oldVal = nullptr);
public:
bool _isMail;
int _id;