[Scummvm-cvs-logs] SF.net SVN: scummvm:[54948] scummvm/trunk/engines/hugo

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Sat Dec 18 00:12:37 CET 2010


Revision: 54948
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54948&view=rev
Author:   strangerke
Date:     2010-12-17 23:12:36 +0000 (Fri, 17 Dec 2010)

Log Message:
-----------
HUGO: little code cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/game.h
    scummvm/trunk/engines/hugo/schedule.cpp
    scummvm/trunk/engines/hugo/schedule.h
    scummvm/trunk/engines/hugo/schedule_v1d.cpp
    scummvm/trunk/engines/hugo/schedule_v2d.cpp

Modified: scummvm/trunk/engines/hugo/game.h
===================================================================
--- scummvm/trunk/engines/hugo/game.h	2010-12-17 18:18:52 UTC (rev 54947)
+++ scummvm/trunk/engines/hugo/game.h	2010-12-17 23:12:36 UTC (rev 54948)
@@ -211,7 +211,7 @@
 	START_OBJ,                                      //  1 - Object number
 	INIT_OBJXY,                                     //  2 - Object number, x,y
 	PROMPT,                                         //  3 - index of prompt & response string, ptrs to action
-	// lists.  First if response matches, 2nd if not.
+	                                                //      lists.  First if response matches, 2nd if not.
 	BKGD_COLOR,                                     //  4 - new background color
 	INIT_OBJVXY,                                    //  5 - Object number, vx, vy
 	INIT_CARRY,                                     //  6 - Object number, carried status
@@ -520,7 +520,7 @@
 };
 
 struct act31 {                                      // Type 31 - Exit special maze processing
-	action_t actType;                                   // The type of action
+	action_t actType;                               // The type of action
 	int      timer;                                 // Time to set off the action
 };
 
@@ -638,17 +638,17 @@
 };
 
 struct act48 {                                      // Type 48 - Set curr_seq_p to frame n
-	action_t actType;                                   // The type of action
+	action_t actType;                               // The type of action
 	int      timer;                                 // Time to set off the action
 	int      objNumb;                               // The object number
 	int      seqIndex;                              // The index of seq array to set to
 	int      frameIndex;                            // The index of frame to set to
 };
 
-struct act49 {                                      // Added by Strangerke - Type 79 - Play a sound (DOS way)
-	action_t actType;                                   // The type of action
+struct act49 {                                      // Added by Strangerke - Type 79 - Play a song (DOS way)
+	action_t actType;                               // The type of action
 	int      timer;                                 // Time to set off the action
-	uint16   soundIndex;                            // Sound index in string array
+	uint16   songIndex;                             // Song index in string array
 };
 
 union act {

Modified: scummvm/trunk/engines/hugo/schedule.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule.cpp	2010-12-17 18:18:52 UTC (rev 54947)
+++ scummvm/trunk/engines/hugo/schedule.cpp	2010-12-17 23:12:36 UTC (rev 54948)
@@ -537,7 +537,7 @@
 						break;
 					case OLD_SONG:           //49
 						_actListArr[i][j].a49.timer = in.readSint16BE();
-						_actListArr[i][j].a49.soundIndex = in.readUint16BE();
+						_actListArr[i][j].a49.songIndex = in.readUint16BE();
 						break;
 					default:
 						error("Engine - Unknown action type encountered: %d", _actListArr[i][j].a0.actType);
@@ -948,4 +948,56 @@
 	}
 }
 
+/**
+* Insert the action pointed to by p into the timer event queue
+* The queue goes from head (earliest) to tail (latest) timewise
+*/
+void Scheduler::insertAction(act *action) {
+	debugC(1, kDebugSchedule, "insertAction() - Action type A%d", action->a0.actType);
+
+	// First, get and initialise the event structure
+	event_t *curEvent = getQueue();
+	curEvent->action = action;
+	switch (action->a0.actType) {                   // Assign whether local or global
+	case AGSCHEDULE:
+		curEvent->localActionFl = false;            // Lasts over a new screen
+		break;
+	default:
+		curEvent->localActionFl = true;             // Rest are for current screen only
+		break;
+	}
+
+	curEvent->time = action->a0.timer + getTicks(); // Convert rel to abs time
+
+	// Now find the place to insert the event
+	if (!_tailEvent) {                              // Empty queue
+		_tailEvent = _headEvent = curEvent;
+		curEvent->nextEvent = curEvent->prevEvent = 0;
+	} else {
+		event_t *wrkEvent = _tailEvent;             // Search from latest time back
+		bool found = false;
+
+		while (wrkEvent && !found) {
+			if (wrkEvent->time <= curEvent->time) { // Found if new event later
+				found = true;
+				if (wrkEvent == _tailEvent)         // New latest in list
+					_tailEvent = curEvent;
+				else
+					wrkEvent->nextEvent->prevEvent = curEvent;
+				curEvent->nextEvent = wrkEvent->nextEvent;
+				wrkEvent->nextEvent = curEvent;
+				curEvent->prevEvent = wrkEvent;
+			}
+			wrkEvent = wrkEvent->prevEvent;
+		}
+
+		if (!found) {                               // Must be earliest in list
+			_headEvent->prevEvent = curEvent;       // So insert as new head
+			curEvent->nextEvent = _headEvent;
+			curEvent->prevEvent = 0;
+			_headEvent = curEvent;
+		}
+	}
+}
+
 } // End of namespace Hugo

Modified: scummvm/trunk/engines/hugo/schedule.h
===================================================================
--- scummvm/trunk/engines/hugo/schedule.h	2010-12-17 18:18:52 UTC (rev 54947)
+++ scummvm/trunk/engines/hugo/schedule.h	2010-12-17 23:12:36 UTC (rev 54948)
@@ -87,13 +87,13 @@
 	virtual const char *getCypher() = 0;
 	virtual event_t *doAction(event_t *curEvent) = 0;
 	virtual void delQueue(event_t *curEvent) = 0;
-	virtual void insertAction(act *action) = 0;
 
 	event_t *getQueue();
 
 	uint32 getDosTicks(bool updateFl);
 	uint32 getWinTicks();
 
+	void insertAction(act *action);
 };
 
 class Scheduler_v1d : public Scheduler {
@@ -102,11 +102,9 @@
 	~Scheduler_v1d();
 
 	virtual const char *getCypher();
-
 	virtual uint32 getTicks();
-
-	virtual void insertAction(act *action);
 	virtual void runScheduler();
+
 protected:
 	virtual void delQueue(event_t *curEvent);
 	virtual event_t *doAction(event_t *curEvent);
@@ -118,7 +116,6 @@
 	virtual ~Scheduler_v2d();
 
 	virtual const char *getCypher();
-	void insertAction(act *action);
 protected:
 	void delQueue(event_t *curEvent);
 	event_t *doAction(event_t *curEvent);

Modified: scummvm/trunk/engines/hugo/schedule_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule_v1d.cpp	2010-12-17 18:18:52 UTC (rev 54947)
+++ scummvm/trunk/engines/hugo/schedule_v1d.cpp	2010-12-17 23:12:36 UTC (rev 54948)
@@ -247,12 +247,6 @@
 		else
 			insertActionList(action->a25.actFailIndex);
 		break;
-//	case SOUND:                                     // act26: Play a sound (or tune)
-//		if (action->a26.soundIndex < _vm->_tunesNbr)
-//			_vm->_sound->playMusic(action->a26.soundIndex);
-//		else
-//			_vm->_sound->playSound(action->a26.soundIndex, BOTH_CHANNELS, MED_PRI);
-//		break;
 	case ADD_SCORE:                                 // act27: Add object's value to score
 		_vm->adjustScore(_vm->_object->_objects[action->a27.objNumb].objValue);
 		break;
@@ -266,10 +260,10 @@
 			insertActionList(action->a29.actFailIndex);
 		break;
 	case OLD_SONG:
-		//TODO For Hugo 1 and Hugo2 DOS: The songs were not stored in a DAT file, but directly as
+		//TODO For DOS versions: The songs were not stored in a DAT file, but directly as
 		//strings. the current play_music should be modified to use a strings instead of reading
 		//the file, in those cases. This replaces, for those DOS versions, act26.
-		warning("STUB: doAction(act49)");
+		warning("STUB: doAction(act49) %s", _vm->_textData[action->a49.songIndex]);
 		break;
 	default:
 		error("An error has occurred: %s", "doAction");
@@ -286,52 +280,6 @@
 }
 
 /**
-* Insert the action pointed to by p into the timer event queue
-* The queue goes from head (earliest) to tail (latest) timewise
-*/
-void Scheduler_v1d::insertAction(act *action) {
-	debugC(1, kDebugSchedule, "insertAction() - Action type A%d", action->a0.actType);
-
-	// First, get and initialise the event structure
-	event_t *curEvent = getQueue();
-	curEvent->action = action;
-
-	curEvent->localActionFl = true;                 // Rest are for current screen only
-
-	curEvent->time = action->a0.timer + getTicks(); // Convert rel to abs time
-
-	// Now find the place to insert the event
-	if (!_tailEvent) {                              // Empty queue
-		_tailEvent = _headEvent = curEvent;
-		curEvent->nextEvent = curEvent->prevEvent = 0;
-	} else {
-		event_t *wrkEvent = _tailEvent;             // Search from latest time back
-		bool found = false;
-
-		while (wrkEvent && !found) {
-			if (wrkEvent->time <= curEvent->time) { // Found if new event later
-				found = true;
-				if (wrkEvent == _tailEvent)         // New latest in list
-					_tailEvent = curEvent;
-				else
-					wrkEvent->nextEvent->prevEvent = curEvent;
-				curEvent->nextEvent = wrkEvent->nextEvent;
-				wrkEvent->nextEvent = curEvent;
-				curEvent->prevEvent = wrkEvent;
-			}
-			wrkEvent = wrkEvent->prevEvent;
-		}
-
-		if (!found) {                               // Must be earliest in list
-			_headEvent->prevEvent = curEvent;       // So insert as new head
-			curEvent->nextEvent = _headEvent;
-			curEvent->prevEvent = 0;
-			_headEvent = curEvent;
-		}
-	}
-}
-
-/**
 * This is the scheduler which runs every tick.  It examines the event queue
 * for any events whose time has come.  It dequeues these events and performs
 * the action associated with the event, returning it to the free queue

Modified: scummvm/trunk/engines/hugo/schedule_v2d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule_v2d.cpp	2010-12-17 18:18:52 UTC (rev 54947)
+++ scummvm/trunk/engines/hugo/schedule_v2d.cpp	2010-12-17 23:12:36 UTC (rev 54948)
@@ -376,10 +376,10 @@
 			_vm->_object->_objects[action->a48.objNumb].currImagePtr = _vm->_object->_objects[action->a48.objNumb].currImagePtr->nextSeqPtr;
 		break;
 	case OLD_SONG:
-		//TODO For Hugo 1 and Hugo2 DOS: The songs were not stored in a DAT file, but directly as
+		//TODO For DOS versions: The songs were not stored in a DAT file, but directly as
 		//strings. the current play_music should be modified to use a strings instead of reading
 		//the file, in those cases. This replaces, for those DOS versions, act26.
-		warning("STUB: doAction(act49)");
+		warning("STUB: doAction(act49) %s", _vm->_textData[action->a49.songIndex]);
 		break;
 	default:
 		error("An error has occurred: %s", "doAction");
@@ -394,56 +394,4 @@
 		return wrkEvent;                            // Return next event ptr
 	}
 }
-
-/**
-* Insert the action pointed to by p into the timer event queue
-* The queue goes from head (earliest) to tail (latest) timewise
-*/
-void Scheduler_v2d::insertAction(act *action) {
-	debugC(1, kDebugSchedule, "insertAction() - Action type A%d", action->a0.actType);
-
-	// First, get and initialise the event structure
-	event_t *curEvent = getQueue();
-	curEvent->action = action;
-	switch (action->a0.actType) {                   // Assign whether local or global
-	case AGSCHEDULE:
-		curEvent->localActionFl = false;            // Lasts over a new screen
-		break;
-	default:
-		curEvent->localActionFl = true;             // Rest are for current screen only
-		break;
-	}
-
-	curEvent->time = action->a0.timer + getTicks(); // Convert rel to abs time
-
-	// Now find the place to insert the event
-	if (!_tailEvent) {                              // Empty queue
-		_tailEvent = _headEvent = curEvent;
-		curEvent->nextEvent = curEvent->prevEvent = 0;
-	} else {
-		event_t *wrkEvent = _tailEvent;             // Search from latest time back
-		bool found = false;
-
-		while (wrkEvent && !found) {
-			if (wrkEvent->time <= curEvent->time) { // Found if new event later
-				found = true;
-				if (wrkEvent == _tailEvent)         // New latest in list
-					_tailEvent = curEvent;
-				else
-					wrkEvent->nextEvent->prevEvent = curEvent;
-				curEvent->nextEvent = wrkEvent->nextEvent;
-				wrkEvent->nextEvent = curEvent;
-				curEvent->prevEvent = wrkEvent;
-			}
-			wrkEvent = wrkEvent->prevEvent;
-		}
-
-		if (!found) {                               // Must be earliest in list
-			_headEvent->prevEvent = curEvent;       // So insert as new head
-			curEvent->nextEvent = _headEvent;
-			curEvent->prevEvent = 0;
-			_headEvent = curEvent;
-		}
-	}
-}
 } // End of namespace Hugo


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