[Scummvm-cvs-logs] SF.net SVN: scummvm:[52311] scummvm/trunk/engines/sci

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Mon Aug 23 22:29:13 CEST 2010


Revision: 52311
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52311&view=rev
Author:   m_kiewitz
Date:     2010-08-23 20:29:13 +0000 (Mon, 23 Aug 2010)

Log Message:
-----------
SCI: storing game super class address now inside SciEngine

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/features.cpp
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h

Modified: scummvm/trunk/engines/sci/engine/features.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/features.cpp	2010-08-23 20:28:04 UTC (rev 52310)
+++ scummvm/trunk/engines/sci/engine/features.cpp	2010-08-23 20:29:13 UTC (rev 52311)
@@ -275,15 +275,8 @@
 			return _lofsType;
 		}
 
-		// Find the "Game" object, super class of the actual game-object
-		const reg_t game = g_sci->getGameObject();
-		const Object *gameObject = _segMan->getObject(game);
-		reg_t gameSuperClass = NULL_REG;
-		if (gameObject) {
-			gameSuperClass = gameObject->getSuperClassSelector();
-		}
-
-		// Find a function of the game object which invokes lofsa/lofss
+		// Find a function of the "Game" object (which is the game super class) which invokes lofsa/lofss
+		reg_t gameSuperClass = g_sci->getGameSuperClassAddress();
 		bool found = false;
 		if (!gameSuperClass.isNull()) {
 			Common::String gameSuperClassName = _segMan->getObjectName(gameSuperClass);

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2010-08-23 20:28:04 UTC (rev 52310)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2010-08-23 20:29:13 UTC (rev 52311)
@@ -251,7 +251,7 @@
 	lang = K_LANG_ENGLISH;
 
 	if (SELECTOR(printLang) != -1) {
-		lang = (kLanguage)readSelectorValue(_gamestate->_segMan, _gameObj, SELECTOR(printLang));
+		lang = (kLanguage)readSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(printLang));
 
 		if ((getSciVersion() >= SCI_VERSION_1_1) || (lang == K_LANG_NONE)) {
 			// If language is set to none, we use the language from the game detector.
@@ -292,7 +292,7 @@
 
 void SciEngine::setSciLanguage(kLanguage lang) {
 	if (SELECTOR(printLang) != -1)
-		writeSelectorValue(_gamestate->_segMan, _gameObj, SELECTOR(printLang), lang);
+		writeSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(printLang), lang);
 }
 
 void SciEngine::setSciLanguage() {
@@ -304,7 +304,7 @@
 	kLanguage subLang = K_LANG_NONE;
 
 	if (SELECTOR(subtitleLang) != -1) {
-		subLang = (kLanguage)readSelectorValue(_gamestate->_segMan, _gameObj, SELECTOR(subtitleLang));
+		subLang = (kLanguage)readSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(subtitleLang));
 	}
 
 	kLanguage secondLang;
@@ -327,7 +327,7 @@
 void SciEngine::checkVocabularySwitch() {
 	uint16 parserLanguage = 1;
 	if (SELECTOR(parseLang) != -1)
-		parserLanguage = readSelectorValue(_gamestate->_segMan, _gameObj, SELECTOR(parseLang));
+		parserLanguage = readSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(parseLang));
 		
 	if (parserLanguage != _vocabularyLanguage) {
 		delete _vocabulary;

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2010-08-23 20:28:04 UTC (rev 52310)
+++ scummvm/trunk/engines/sci/sci.cpp	2010-08-23 20:29:13 UTC (rev 52311)
@@ -201,7 +201,8 @@
 
 	// Add the after market GM patches for the specified game, if they exist
 	_resMan->addNewGMPatch(_gameId);
-	_gameObj = _resMan->findGameObject();
+	_gameObjectAddress = _resMan->findGameObject();
+	_gameSuperClassAddress = NULL_REG;
 
 	SegManager *segMan = new SegManager(_resMan);
 
@@ -212,6 +213,7 @@
 	// Create debugger console. It requires GFX to be initialized
 	_console = new Console(this);
 	_kernel = new Kernel(_resMan, segMan);
+
 	_features = new GameFeatures(segMan, _kernel);
 	// Only SCI0, SCI01 and SCI1 EGA games used a parser
 	_vocabulary = (getSciVersion() <= SCI_VERSION_1_EGA) ? new Vocabulary(_resMan, false) : NULL;
@@ -231,6 +233,14 @@
 		return Common::kUnknownError;
 	}
 
+	// we try to find the super class address of the game object, we can't do that earlier
+	const Object *gameObject = segMan->getObject(_gameObjectAddress);
+	if (!gameObject) {
+		warning("Could not get game object, aborting...");
+		return Common::kUnknownError;
+	}
+	_gameSuperClassAddress = gameObject->getSuperClassSelector();
+
 	script_adjust_opcode_formats();
 
 	// Must be called after game_init(), as they use _features
@@ -250,9 +260,9 @@
 		if (selectedLanguage == Common::EN_ANY) {
 			// and english was selected as language
 			if (SELECTOR(printLang) != -1) // set text language to english
-				writeSelectorValue(segMan, _gameObj, SELECTOR(printLang), 1);
+				writeSelectorValue(segMan, _gameObjectAddress, SELECTOR(printLang), 1);
 			if (SELECTOR(parseLang) != -1) // and set parser language to english as well
-				writeSelectorValue(segMan, _gameObj, SELECTOR(parseLang), 1);
+				writeSelectorValue(segMan, _gameObjectAddress, SELECTOR(parseLang), 1);
 		}
 	}
 
@@ -444,8 +454,8 @@
 	_gamestate->stack_base[1] = NULL_REG;
 
 	// Register the first element on the execution stack
-	if (!send_selector(_gamestate, _gameObj, _gameObj, _gamestate->stack_base, 2, _gamestate->stack_base)) {
-		_console->printObject(_gameObj);
+	if (!send_selector(_gamestate, _gameObjectAddress, _gameObjectAddress, _gamestate->stack_base, 2, _gamestate->stack_base)) {
+		_console->printObject(_gameObjectAddress);
 		error("initStackBaseWithSelector: error while registering the first selector in the call stack");
 	}
 

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2010-08-23 20:28:04 UTC (rev 52310)
+++ scummvm/trunk/engines/sci/sci.h	2010-08-23 20:29:13 UTC (rev 52311)
@@ -233,7 +233,8 @@
 	inline EngineState *getEngineState() const { return _gamestate; }
 	inline Vocabulary *getVocabulary() const { return _vocabulary; }
 	inline EventManager *getEventManager() const { return _eventMan; }
-	inline reg_t getGameObject() const { return _gameObj; }
+	inline reg_t getGameObject() const { return _gameObjectAddress; }
+	inline reg_t getGameSuperClassAddress() const { return _gameSuperClassAddress; }
 
 	Common::RandomSource &getRNG() { return _rng; }
 
@@ -342,7 +343,8 @@
 	Vocabulary *_vocabulary;
 	int16 _vocabularyLanguage;
 	EventManager *_eventMan;
-	reg_t _gameObj; /**< Pointer to the game object */
+	reg_t _gameObjectAddress; /**< Pointer to the game object */
+	reg_t _gameSuperClassAddress; // Address of the super class of the game object
 	Console *_console;
 	Common::RandomSource _rng;
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list