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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Jun 10 13:18:11 CEST 2010


Revision: 49568
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49568&view=rev
Author:   thebluegr
Date:     2010-06-10 11:18:10 +0000 (Thu, 10 Jun 2010)

Log Message:
-----------
Resolved a FIXME with getSciLanguage(), by creating a separate setter. Also, some camelCase changes

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/detection.cpp
    scummvm/trunk/engines/sci/engine/ksound.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/engine/state.h
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/console.cpp	2010-06-10 11:18:10 UTC (rev 49568)
@@ -75,7 +75,7 @@
 
 	// Variables
 	DVar_Register("sleeptime_factor",	&g_debug_sleeptime_factor, DVAR_INT, 0);
-	DVar_Register("gc_interval",		&engine->_gamestate->script_gc_interval, DVAR_INT, 0);
+	DVar_Register("gc_interval",		&engine->_gamestate->scriptGCInterval, DVAR_INT, 0);
 	DVar_Register("simulated_key",		&g_debug_simulated_key, DVAR_INT, 0);
 	DVar_Register("track_mouse_clicks",	&g_debug_track_mouse_clicks, DVAR_BOOL, 0);
 	DVar_Register("script_abort_flag",	&_engine->_gamestate->abortScriptProcessing, DVAR_INT, 0);
@@ -2086,7 +2086,7 @@
 }
 
 bool Console::cmdScriptSteps(int argc, const char **argv) {
-	DebugPrintf("Number of executed SCI operations: %d\n", _engine->_gamestate->script_step_counter);
+	DebugPrintf("Number of executed SCI operations: %d\n", _engine->_gamestate->scriptStepCounter);
 	return true;
 }
 
@@ -2114,7 +2114,7 @@
 bool Console::cmdBacktrace(int argc, const char **argv) {
 	DebugPrintf("Dumping the send/self/super/call/calle/callb stack:\n");
 
-	DebugPrintf("Call stack (current base: 0x%x):\n", _engine->_gamestate->execution_stack_base);
+	DebugPrintf("Call stack (current base: 0x%x):\n", _engine->_gamestate->executionStackBase);
 	Common::List<ExecStack>::iterator iter;
 	uint i = 0;
 

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/detection.cpp	2010-06-10 11:18:10 UTC (rev 49568)
@@ -673,11 +673,11 @@
 }
 
 bool SciEngine::canLoadGameStateCurrently() {
-	return !_gamestate->execution_stack_base;
+	return !_gamestate->executionStackBase;
 }
 
 bool SciEngine::canSaveGameStateCurrently() {
-	return !_gamestate->execution_stack_base;
+	return !_gamestate->executionStackBase;
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp	2010-06-10 11:18:10 UTC (rev 49568)
@@ -151,7 +151,10 @@
 			if (language != -1)
 				g_sci->getResMan()->setAudioLanguage(language);
 
-			return make_reg(0, g_sci->getSciLanguage());
+			kLanguage kLang = g_sci->getSciLanguage();
+			g_sci->setSciLanguage(kLang);
+
+			return make_reg(0, kLang);
 		}
 		break;
 	case kSciAudioCD:

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2010-06-10 11:18:10 UTC (rev 49568)
@@ -722,7 +722,7 @@
 	meta.savegame_date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
 	meta.savegame_time = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF);
 
-	if (s->execution_stack_base) {
+	if (s->executionStackBase) {
 		warning("Cannot save from below kernel function");
 		return 1;
 	}
@@ -875,7 +875,7 @@
 	s->gc_countdown = GC_INTERVAL - 1;
 
 	// Time state:
-	s->last_wait_time = g_system->getMillis();
+	s->lastWaitTime = g_system->getMillis();
 	s->game_start_time = g_system->getMillis();
 
 #ifdef USE_OLD_MUSIC_FUNCTIONS

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2010-06-10 11:18:10 UTC (rev 49568)
@@ -284,7 +284,7 @@
 
 #if 0
 	if (sci_debug_flags & _DEBUG_FLAG_LOGGING) {
-		printf("%d: acc=%04x:%04x  ", script_step_counter, PRINT_REG(s->r_acc));
+		printf("%d: acc=%04x:%04x  ", scriptStepCounter, PRINT_REG(s->r_acc));
 		disassemble(s, s->xs->addr.pc, 0, 1);
 		if (s->seeking == kDebugSeekGlobal)
 			printf("Global %d (0x%x) = %04x:%04x\n", s->seekSpecial,
@@ -351,7 +351,7 @@
 		}
 	}
 
-	printf("Step #%d\n", s->script_step_counter);
+	printf("Step #%d\n", s->scriptStepCounter);
 	disassemble(s, s->xs->addr.pc, 0, 1);
 
 	if (g_debugState.runningStep) {

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2010-06-10 11:18:10 UTC (rev 49568)
@@ -95,7 +95,7 @@
 		abortScriptProcessing = kAbortNone;
 	}
 
-	execution_stack_base = 0;
+	executionStackBase = 0;
 	_executionStackPosChanged = false;
 
 	restAdjust = 0;
@@ -103,7 +103,7 @@
 	r_acc = NULL_REG;
 	r_prev = NULL_REG;
 
-	last_wait_time = 0;
+	lastWaitTime = 0;
 
 	gc_countdown = 0;
 
@@ -111,14 +111,14 @@
 	_throttleLastTime = 0;
 	_throttleTrigger = false;
 
-	script_step_counter = 0;
-	script_gc_interval = GC_INTERVAL;
+	scriptStepCounter = 0;
+	scriptGCInterval = GC_INTERVAL;
 }
 
 void EngineState::wait(int16 ticks) {
 	uint32 time = g_system->getMillis();
-	r_acc = make_reg(0, ((long)time - (long)last_wait_time) * 60 / 1000);
-	last_wait_time = time;
+	r_acc = make_reg(0, ((long)time - (long)lastWaitTime) * 60 / 1000);
+	lastWaitTime = time;
 
 	ticks *= g_debug_sleeptime_factor;
 	g_sci->getEventManager()->sleep(ticks * 1000 / 60);
@@ -144,7 +144,7 @@
 }
 
 void EngineState::shrinkStackToBase() {
-	uint size = execution_stack_base + 1;
+	uint size = executionStackBase + 1;
 	assert(_executionStack.size() >= size);
 	Common::List<ExecStack>::iterator iter = _executionStack.begin();
 	for (uint i = 0; i < size; ++i)
@@ -268,15 +268,20 @@
 			default:
 				lang = K_LANG_ENGLISH;
 			}
-
-			// Store language in printLang selector
-			writeSelectorValue(_gamestate->_segMan, _gameObj, SELECTOR(printLang), lang);
 		}
 	}
 
 	return lang;
 }
 
+void SciEngine::setSciLanguage(kLanguage lang) {
+	writeSelectorValue(_gamestate->_segMan, _gameObj, SELECTOR(printLang), lang);
+}
+
+void SciEngine::setSciLanguage() {
+	setSciLanguage(getSciLanguage());
+}
+
 Common::String SciEngine::strSplit(const char *str, const char *sep) {
 	kLanguage lang = getSciLanguage();
 	kLanguage subLang = K_LANG_NONE;

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/engine/state.h	2010-06-10 11:18:10 UTC (rev 49568)
@@ -112,7 +112,7 @@
 	SoundCommandParser *_soundCmd;
 
 	uint32 game_start_time; /**< The time at which the interpreter was started */
-	uint32 last_wait_time; /**< The last time the game invoked Wait() */
+	uint32 lastWaitTime; /**< The last time the game invoked Wait() */
 
 	void wait(int16 ticks);
 
@@ -134,7 +134,7 @@
 	 * When called from kernel functions, the vm is re-started recursively on
 	 * the same stack. This variable contains the stack base for the current vm.
 	 */
-	int execution_stack_base;
+	int executionStackBase;
 	bool _executionStackPosChanged;   /**< Set to true if the execution stack position should be re-evaluated by the vm */
 
 	reg_t r_acc; /**< Accumulator */
@@ -156,8 +156,8 @@
 	AbortGameState abortScriptProcessing;
 	bool gameWasRestarted;
 
-	int script_step_counter; // Counts the number of steps executed
-	int script_gc_interval; // Number of steps in between gcs
+	int scriptStepCounter; // Counts the number of steps executed
+	int scriptGCInterval; // Number of steps in between gcs
 
 	uint16 currentRoomNumber() const;
 	void setRoomNumber(uint16 roomNumber);
@@ -169,7 +169,7 @@
 
 	/**
 	 * Shrink execution stack to size.
-	 * Contains an assert it is not already smaller.
+	 * Contains an assert if it is not already smaller.
 	 */
 	void shrinkStackToBase();
 

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-10 11:18:10 UTC (rev 49568)
@@ -631,7 +631,7 @@
 
 static void gc_countdown(EngineState *s) {
 	if (s->gc_countdown-- <= 0) {
-		s->gc_countdown = s->script_gc_interval;
+		s->gc_countdown = s->scriptGCInterval;
 		run_gc(s);
 	}
 }
@@ -726,7 +726,7 @@
 	ExecStack *xs_new = NULL;
 	Object *obj = s->_segMan->getObject(s->xs->objp);
 	Script *local_script = s->_segMan->getScriptIfLoaded(s->xs->local_segment);
-	int old_execution_stack_base = s->execution_stack_base;
+	int old_executionStackBase = s->executionStackBase;
 	// Used to detect the stack bottom, for "physical" returns
 	const byte *code_buf = NULL; // (Avoid spurious warning)
 
@@ -735,7 +735,7 @@
 	}
 
 	if (!restoring)
-		s->execution_stack_base = s->_executionStack.size() - 1;
+		s->executionStackBase = s->_executionStack.size() - 1;
 
 	s->variables_seg[VAR_TEMP] = s->variables_seg[VAR_PARAM] = s->_segMan->findSegmentByType(SEG_TYPE_STACK);
 	s->variables_base[VAR_TEMP] = s->variables_base[VAR_PARAM] = s->stack_base;
@@ -1179,8 +1179,8 @@
 				StackPtr old_fp = s->xs->fp;
 				ExecStack *old_xs = &(s->_executionStack.back());
 
-				if ((int)s->_executionStack.size() - 1 == s->execution_stack_base) { // Have we reached the base?
-					s->execution_stack_base = old_execution_stack_base; // Restore stack base
+				if ((int)s->_executionStack.size() - 1 == s->executionStackBase) { // Have we reached the base?
+					s->executionStackBase = old_executionStackBase; // Restore stack base
 
 					s->_executionStack.pop_back();
 
@@ -1661,7 +1661,7 @@
 					opcode);
 		}
 //#endif
-		++s->script_step_counter;
+		++s->scriptStepCounter;
 	}
 }
 

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/sci.cpp	2010-06-10 11:18:10 UTC (rev 49568)
@@ -304,7 +304,7 @@
 	_gamestate->r_acc = _gamestate->r_prev = NULL_REG;
 
 	_gamestate->_executionStack.clear();    // Start without any execution stack
-	_gamestate->execution_stack_base = -1; // No vm is running yet
+	_gamestate->executionStackBase = -1; // No vm is running yet
 	_gamestate->_executionStackPosChanged = false;
 
 	_gamestate->abortScriptProcessing = kAbortNone;
@@ -325,7 +325,7 @@
 		_vocabulary->parser_base = make_reg(_gamestate->_segMan->getSysStringsSegment(), SYS_STRING_PARSER_BASE);
 	}
 
-	_gamestate->game_start_time = _gamestate->last_wait_time = g_system->getMillis();
+	_gamestate->game_start_time = _gamestate->lastWaitTime = g_system->getMillis();
 
 	srand(g_system->getMillis()); // Initialize random number generator
 
@@ -335,9 +335,7 @@
 #endif
 
 	// Load game language into printLang property of game object
-	// FIXME: It's evil to achieve this as a side effect of a getter.
-	// Much better to have an explicit init method for this.
-	getSciLanguage();
+	setSciLanguage();
 
 	return true;
 }

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2010-06-10 10:27:13 UTC (rev 49567)
+++ scummvm/trunk/engines/sci/sci.h	2010-06-10 11:18:10 UTC (rev 49568)
@@ -187,6 +187,8 @@
 	Common::String strSplit(const char *str, const char *sep = "\r----------\r");
 
 	kLanguage getSciLanguage();
+	void setSciLanguage(kLanguage lang);
+	void setSciLanguage();
 
 	Common::String getSciLanguageString(const char *str, kLanguage lang, kLanguage *lang2 = NULL) const;
 


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