From 0276ec835ef3c77a4dbf772ea54cc6d5292452f2 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 30 May 2010 15:17:29 +0000 Subject: Fixed findGameObject() for SCI11 games svn-id: r49326 --- engines/sci/engine/game.cpp | 8 +------- engines/sci/resource.cpp | 6 +++++- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 241df94316..232e0eca55 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -127,13 +127,7 @@ int game_init(EngineState *s) { srand(g_system->getMillis()); // Initialize random number generator - // TODO: This is sometimes off by 1... find out why - //s->_gameObj = g_sci->getResMan()->findGameObject(); - // Replaced by the code below for now - Script *scr000 = s->_segMan->getScript(1); - s->_gameObj = make_reg(1, scr000->validateExportFunc(0)); - if (getSciVersion() >= SCI_VERSION_1_1) - s->_gameObj.offset += scr000->_scriptSize; + s->_gameObj = g_sci->getResMan()->findGameObject(); #ifdef USE_OLD_MUSIC_FUNCTIONS if (s->sfx_init_flags & SFX_STATE_FLAG_NOSOUND) diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 56ff24389e..ba5689dcf0 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -1923,9 +1923,13 @@ reg_t ResourceManager::findGameObject(bool addSci11ScriptOffset) { // In SCI1.1 and newer, the heap is appended at the end of the script, // so adjust the offset accordingly - if (getSciVersion() >= SCI_VERSION_1_1 && addSci11ScriptOffset) + if (getSciVersion() >= SCI_VERSION_1_1 && addSci11ScriptOffset) { offset += script->size; + if (script->size & 2) + offset++; + } + return make_reg(1, offset); } -- cgit v1.2.3