[Scummvm-cvs-logs] CVS: scummvm/sword2 debug.cpp,1.43,1.44 function.cpp,1.69,1.70 logic.cpp,1.46,1.47 protocol.cpp,1.27,1.28 router.cpp,1.42,1.43 sword2.cpp,1.119,1.120 sword2.h,1.67,1.68

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Tue Nov 16 01:16:03 CET 2004


Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4259

Modified Files:
	debug.cpp function.cpp logic.cpp protocol.cpp router.cpp 
	sword2.cpp sword2.h 
Log Message:
Cleanup


Index: debug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/debug.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- debug.cpp	14 Nov 2004 15:00:00 -0000	1.43
+++ debug.cpp	16 Nov 2004 09:15:24 -0000	1.44
@@ -104,12 +104,14 @@
 		makeDebugTextBlock(buf, 0, 105);
 	}
 
+#ifdef SWORD2_DEBUG
 	// speed-up indicator
 
-	if (_vm->_renderSkip) {		// see sword.cpp
+	if (_vm->_renderSkip) {		// see sword2.cpp
 		sprintf(buf, "SKIPPING FRAMES FOR SPEED-UP!");
 		makeDebugTextBlock(buf, 0, 120);
 	}
+#endif
 
 	// debug info at top of screen - enabled/disabled as one complete unit
 

Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- function.cpp	14 Nov 2004 15:00:00 -0000	1.69
+++ function.cpp	16 Nov 2004 09:15:25 -0000	1.70
@@ -211,7 +211,7 @@
 	return IR_CONT;
 }
 
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 #define BLACK	0
 #define WHITE	1
 #define RED	2
@@ -232,7 +232,7 @@
 
 	// params:	0 colour to flash
 
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 	// what colour?
 	switch (params[0]) {
 	case WHITE:
@@ -268,7 +268,7 @@
 
 	// params	0: colour (see defines above)
 
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 	// what colour?
 	switch (params[0]) {
 	case BLACK:

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/logic.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- logic.cpp	14 Nov 2004 15:00:00 -0000	1.46
+++ logic.cpp	16 Nov 2004 09:15:25 -0000	1.47
@@ -335,7 +335,7 @@
 	// params:	none
 
 	// DON'T EVER KILL GEORGE!
-	if (_scriptVars[ID] == 8)
+	if (_scriptVars[ID] == CUR_PLAYER_ID)
 		return IR_CONT;
 
 	// Scan the list to see if it's already included

Index: protocol.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/protocol.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- protocol.cpp	24 Apr 2004 12:29:35 -0000	1.27
+++ protocol.cpp	16 Nov 2004 09:15:25 -0000	1.28
@@ -75,7 +75,7 @@
  */
 
 LayerHeader *Sword2Engine::fetchLayerHeader(byte *screenFile, uint16 layerNo) {
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 	ScreenHeader *screenHead = fetchScreenHeader(screenFile);
 
 	if (layerNo > screenHead->noLayers - 1)
@@ -118,7 +118,7 @@
 CdtEntry *Sword2Engine::fetchCdtEntry(byte *animFile, uint16 frameNo) {
 	AnimHeader *animHead = fetchAnimHeader(animFile);
 
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 	if (frameNo > animHead->noAnimFrames - 1)
 		error("fetchCdtEntry(animFile,%d) - anim only %d frames", frameNo, animHead->noAnimFrames);
 #endif
@@ -144,7 +144,7 @@
 Parallax *Sword2Engine::fetchBackgroundParallaxLayer(byte *screenFile, int layer) {
 	MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader));
 
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 	if (mscreenHeader->bg_parallax[layer] == 0)
 		error("fetchBackgroundParallaxLayer(%d) - No parallax layer exists", layer);
 #endif
@@ -155,7 +155,7 @@
 Parallax *Sword2Engine::fetchBackgroundLayer(byte *screenFile) {
 	MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader));
 
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 	if (mscreenHeader->screen == 0)
 		error("fetchBackgroundLayer (%d) - No background layer exists");
 #endif
@@ -166,7 +166,7 @@
 Parallax *Sword2Engine::fetchForegroundParallaxLayer(byte *screenFile, int layer) {
 	MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader));
 
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 	if (mscreenHeader->fg_parallax[layer] == 0)
 		error("fetchForegroundParallaxLayer(%d) - No parallax layer exists", layer);
 #endif

Index: router.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/router.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- router.cpp	23 Apr 2004 07:02:04 -0000	1.42
+++ router.cpp	16 Nov 2004 09:15:25 -0000	1.43
@@ -1150,7 +1150,7 @@
 		}
 	} while (_modularPath[p].dir < NO_DIRECTIONS);
 
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 	if (lastRealDir == 99)
 		error("slidyWalkAnimatorlast direction error");
 #endif

Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- sword2.cpp	15 Nov 2004 08:22:16 -0000	1.119
+++ sword2.cpp	16 Nov 2004 09:15:25 -0000	1.120
@@ -100,8 +100,6 @@
 
 namespace Sword2 {
 
-Sword2Engine *g_sword2 = NULL;
-
 Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst) : Engine(syst) {
 	// Add default file directories
 	File::addDefaultDirectory(_gameDataPath + "CLUSTERS/");
@@ -111,20 +109,24 @@
 	File::addDefaultDirectory(_gameDataPath + "sword2/");
 	File::addDefaultDirectory(_gameDataPath + "video/");
 
-	g_sword2 = this;
-	_debugger = NULL;
-	_sound = NULL;
-	_graphics = NULL;
 	_features = detector->_game.features;
 	_targetName = detector->_targetName;
+
 	_bootParam = ConfMan.getInt("boot_param");
 	_saveSlot = ConfMan.getInt("save_slot");
 
+	_debugger = NULL;
+	_graphics = NULL;
+	_sound = NULL;
+	_gui = NULL;
+	_fontRenderer = NULL;
+	_logic = NULL;
+	_resman = NULL;
+	_memory = NULL;
+
 	_keyboardEvent.pending = false;
 	_mouseEvent.pending = false;
 
-	_mouseX = _mouseY = 0;
-
 	_lastPaletteRes = 0;
 
 	_largestLayerArea = 0;
@@ -149,6 +151,7 @@
 	memset(&_thisScreen, 0, sizeof(_thisScreen));
 	memset(_mouseList, 0, sizeof(_mouseList));
 
+	_mouseX = _mouseY = 0;
 	_mouseTouching = 0;
 	_oldMouseTouching = 0;
 	_menuSelectedPos = 0;
@@ -164,26 +167,24 @@
 	_playerActivityDelay = 0;
 	_realLuggageItem = 0;
 
-	// used to be a define, but now it's flexible
 	_scrollFraction = 16;
 
-	_gamePaused = false;
+#ifdef SWORD2_DEBUG
 	_stepOneCycle = false;
+	_renderSkip = false;
+#endif
+
+	_gamePaused = false;
 	_graphicsLevelFudged = false;
 
-	_debugger = NULL;
-	_graphics = NULL;
-	_sound = NULL;
-	_gui = NULL;
-	_fontRenderer = NULL;
-	_logic = NULL;
-	_resman = NULL;
-	_memory = NULL;
+	_gameCycle = 0;
 
 	_quit = false;
 }
 
 Sword2Engine::~Sword2Engine() {
+	killMusic();
+
 	delete _debugger;
 	delete _graphics;
 	delete _sound;
@@ -223,7 +224,7 @@
 }
     
 void Sword2Engine::mainInit() {
-	// get some falling RAM and put it in your pocket, never let it slip
+	// Get some falling RAM and put it in your pocket, never let it slip
 	// away
 
 	_graphics = new Graphics(this, 640, 480);
@@ -255,26 +256,15 @@
 	// nor the scroll wheel.
 	setEventFilter(RD_LEFTBUTTONUP | RD_RIGHTBUTTONUP | RD_WHEELUP | RD_WHEELDOWN);
 
-	// Initialise global script variables and player object
 	setupPersistentResources();
-
-	// Set up font resource variables for this language version
-
-	debug(5, "CALLING: initialiseFontResourceFlags");
 	initialiseFontResourceFlags();
-
-	// initialise the sound fx queue
-
-	debug(5, "CALLING: Init_fx_queue");
 	initFxQueue();
 
-	// all demos (not just web)
 	if (_features & GF_DEMO)
 		Logic::_scriptVars[DEMO] = 1;
 	else
 		Logic::_scriptVars[DEMO] = 0;
 
-	debug(5, "CALLING: readOptionSettings");
 	_gui->readOptionSettings();
 
 	if (_saveSlot != -1) {
@@ -305,13 +295,7 @@
 	} else
 		startGame();
 
-	debug(5, "CALLING: initialiseRenderCycle");
 	_graphics->initialiseRenderCycle();
-
-	_renderSkip = false;		// Toggled on 'S' key, to render only
-					// 1 in 4 frames, to speed up game
-
-	_gameCycle = 0;
 }
 
 void Sword2Engine::mainRun() {
@@ -319,13 +303,7 @@
 		if (_debugger->isAttached())
 			_debugger->onFrame();
 
-		// the screen is build. Mostly because of first scroll
-		// cycle stuff
-
-#ifdef _SWORD2_DEBUG
-		// if we've just stepped forward one cycle while the
-		// game was paused
-
+#ifdef SWORD2_DEBUG
 		if (_stepOneCycle) {
 			pauseGame();
 			_stepOneCycle = false;
@@ -349,7 +327,7 @@
 					if (!Logic::_scriptVars[DEMO] && !_logic->_choosing)
 						_logic->fnPlayCredits(NULL);
 					break;
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 				case ' ':
 					if (_gamePaused) {
 						_stepOneCycle = true;
@@ -372,7 +350,7 @@
 			gameCycle();
 		}
 
-		// We can't use this as termination condition for the looop,
+		// We can't use this as termination condition for the loop,
 		// because we want the break to happen before updating the
 		// screen again.
 
@@ -382,14 +360,13 @@
 		// creates the debug text blocks
 		_debugger->buildDebugText();
 
-#ifdef _SWORD2_DEBUG
+#ifdef SWORD2_DEBUG
 		// if not in console & '_renderSkip' is set, only render
 		// display once every 4 game-cycles
 
-		if (console_status || !_renderSkip || (_gameCycle % 4) == 0)
-			buildDisplay();	// create and flip the screen
+		if (!_renderSkip || (_gameCycle % 4) == 0)
+			buildDisplay();
 #else
-		// create and flip the screen
 		buildDisplay();
 #endif
 	}
@@ -398,9 +375,6 @@
 void Sword2Engine::go() {
 	mainInit();
 	mainRun();
-
-	// Stop music instantly!
-	killMusic();
 }
 
 void Sword2Engine::closeGame() {
@@ -503,29 +477,28 @@
 }
 
 void Sword2Engine::gameCycle() {
-	// do one game cycle
+	// Do one game cycle, that is run the logic session until a full loop
+	// has been performed.
 
-	// got a screen to run?
 	if (_logic->getRunList()) {
-		// run the logic session UNTIL a full loop has been performed
 		do {
-			// reset the graphic 'BuildUnit' list before a new
-			// logic list (see fnRegisterFrame)
-			resetRenderLists();
+			// Reset the 'BuildUnit' and mouse hot-spot lists
+			// before each new logic list. The service scripts
+			// will fill thrm through fnRegisterFrame() and
+			// fnRegisterMouse().
 
-			// reset the mouse hot-spot list (see fnRegisterMouse
-			// and fnRegisterFrame)
+			resetRenderLists();
 			resetMouseList();
 
-			// keep going as long as new lists keep getting put in
-			// - i.e. screen changes
+			// Keep going as long as new lists keep getting put in
+			// - i.e. screen changes.
 		} while (_logic->processSession());
 	} else {
-		// start the console and print the start options perhaps?
+		// Start the console and print the start options perhaps?
 		_debugger->attach("AWAITING START COMMAND: (Enter 's 1' then 'q' to start from beginning)");
 	}
 
-	// if this screen is wide, recompute the scroll offsets every cycle
+	// If this screen is wide, recompute the scroll offsets every cycle
 	if (_thisScreen.scroll_flag)
 		setScrolling();
 
@@ -534,48 +507,36 @@
 }
 
 void Sword2Engine::startGame() {
-	// boot the game straight into a start script
+	// Boot the game straight into a start script. It's always George's
+	// script #1, but with different ScreenManager objects depending on
+	// if it's the demo or the full game, or if we're using a boot param.
 
 	int screen_manager_id;
 
 	debug(5, "startGame() STARTING:");
 
-	// all demos not just web
-	if (Logic::_scriptVars[DEMO])
-		screen_manager_id = 19;		// DOCKS SECTION START
-	else
-		screen_manager_id = 949;	// INTRO & PARIS START
-
-	// FIXME this could be validated against startup.inf for valid numbers
-	// to stop people shooting themselves in the foot
-
-	if (_bootParam != 0)
-		screen_manager_id = _bootParam;
-	
-	char *raw_script;
-	char *raw_data_ad;
+	if (!_bootParam) {
+		if (Logic::_scriptVars[DEMO])
+			screen_manager_id = 19;		// DOCKS SECTION START
+		else
+			screen_manager_id = 949;	// INTRO & PARIS START
+	} else {
+		// FIXME this could be validated against startup.inf for valid
+		// numbers to stop people shooting themselves in the foot
 
-	// the required start-scripts are both script #1 in the respective
-	// ScreenManager objects
+		if (_bootParam != 0)
+			screen_manager_id = _bootParam;
+	}
 
 	uint32 null_pc = 1;
 
-	// open george object, ready for start script to reference
-	raw_data_ad = (char *) _resman->openResource(CUR_PLAYER_ID);
-
-	// open the ScreenManager object
-	raw_script = (char *) _resman->openResource(screen_manager_id);
+	char *raw_data_ad = (char *) _resman->openResource(CUR_PLAYER_ID);
+	char *raw_script = (char *) _resman->openResource(screen_manager_id);
 
-	// run the start script now (because no console)
 	_logic->runScript(raw_script, raw_data_ad, &null_pc);
 
-	// close the ScreenManager object
 	_resman->closeResource(screen_manager_id);
-
-	// close george
 	_resman->closeResource(CUR_PLAYER_ID);
-
-	debug(5, "startGame() DONE.");
 }
 
 // FIXME: Move this to some better place?
@@ -591,25 +552,21 @@
 }
 
 void Sword2Engine::pauseGame() {
-	// don't allow Pause while screen fading or while black
+	// Don't allow Pause while screen fading or while black
 	if (_graphics->getFadeStatus() != RDFADE_NONE)
 		return;
 	
 	pauseAllSound();
 
-	// make a normal mouse
-	clearPointerText();
+	// Make the mouse cursor normal. This is the only place where we are
+	// allowed to clear the luggage this way.
 
-	// this is the only place allowed to do it this way
+	clearPointerText();
 	_graphics->setLuggageAnim(NULL, 0);
-
-	// blank cursor
 	setMouse(0);
-
-	// forces engine to choose a cursor
 	_mouseTouching = 1;
 
-	// if level at max, turn down because palette-matching won't work
+	// If level at max, turn down because palette-matching won't work
 	// when dimmed
 
 	if (_gui->_currentGraphicsLevel == 3) {
@@ -617,11 +574,15 @@
 		_graphicsLevelFudged = true;
 	}
 
-	// don't dim it if we're single-stepping through frames
+#ifdef SWORD2_DEBUG
+	// Don't dim it if we're single-stepping through frames
 	// dim the palette during the pause
 
 	if (!_stepOneCycle)
 		_graphics->dimPalette();
+#else
+	_graphics->dimPalette();
+#endif
 
 	_gamePaused = true;
 }
@@ -632,7 +593,7 @@
 
 	unpauseAllSound();
 
-	// put back game screen palette; see build_display.cpp
+	// Put back game screen palette; see build_display.cpp
 	setFullPalette(-1);
 
 	// If graphics level at max, turn up again
@@ -643,7 +604,7 @@
 
 	_gamePaused = false;
 
-	// if mouse is about or we're in a chooser menu
+	// If mouse is about or we're in a chooser menu
 	if (!_mouseStatus || _logic->_choosing)
 		setMouse(NORMAL_MOUSE_ID);
 }

Index: sword2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- sword2.h	15 Nov 2004 08:22:16 -0000	1.67
+++ sword2.h	16 Nov 2004 09:15:25 -0000	1.68
@@ -241,7 +241,11 @@
 	bool _wantSfxDebug;
 
 	int32 _gameCycle;
+
+#ifdef SWORD2_DEBUG
 	bool _renderSkip;
+	bool _stepOneCycle;
+#endif
 
 	int32 initBackground(int32 res, int32 new_palette);
 
@@ -392,7 +396,6 @@
 
 	bool _gamePaused;
 	bool _graphicsLevelFudged;
-	bool _stepOneCycle;		// for use while game paused
 
 	void startGame();
 	void gameCycle();
@@ -405,8 +408,6 @@
 	void initialiseFontResourceFlags(uint8 language);
 };
 
-extern Sword2Engine *g_sword2;
-
 } // End of namespace Sword2
 
 #endif





More information about the Scummvm-git-logs mailing list