[Scummvm-cvs-logs] SF.net SVN: scummvm: [23439] scummvm/trunk/engines/sword2

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Thu Jul 20 22:37:41 CEST 2006


Revision: 23439
          http://svn.sourceforge.net/scummvm/?rev=23439&view=rev
Author:   eriktorbjorn
Date:     2006-07-08 13:45:01 -0700 (Sat, 08 Jul 2006)

Log Message:
-----------
Cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sword2/console.cpp
    scummvm/trunk/engines/sword2/debug.cpp
    scummvm/trunk/engines/sword2/function.cpp
    scummvm/trunk/engines/sword2/layers.cpp
    scummvm/trunk/engines/sword2/mouse.cpp
    scummvm/trunk/engines/sword2/resman.h
    scummvm/trunk/engines/sword2/screen.cpp
    scummvm/trunk/engines/sword2/sound.cpp
    scummvm/trunk/engines/sword2/startup.cpp

Modified: scummvm/trunk/engines/sword2/console.cpp
===================================================================
--- scummvm/trunk/engines/sword2/console.cpp	2006-07-08 20:27:03 UTC (rev 23438)
+++ scummvm/trunk/engines/sword2/console.cpp	2006-07-08 20:45:01 UTC (rev 23439)
@@ -434,44 +434,41 @@
 	}
 
 	// Open up the resource and take a look inside!
-	uint8 type = _vm->_resman->fetchType(res);;
-	byte name[NAME_LEN];
+	uint8 type = _vm->_resman->fetchType(res);
 
-	_vm->_resman->fetchName(res, name);
-
 	switch (type) {
 	case ANIMATION_FILE:
-		DebugPrintf("<anim> %s\n", name);
+		DebugPrintf("<anim> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case SCREEN_FILE:
-		DebugPrintf("<layer> %s\n", name);
+		DebugPrintf("<layer> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case GAME_OBJECT:
-		DebugPrintf("<game object> %s\n", name);
+		DebugPrintf("<game object> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case WALK_GRID_FILE:
-		DebugPrintf("<walk grid> %s\n", name);
+		DebugPrintf("<walk grid> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case GLOBAL_VAR_FILE:
-		DebugPrintf("<global variables> %s\n", name);
+		DebugPrintf("<global variables> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case PARALLAX_FILE_null:
-		DebugPrintf("<parallax file NOT USED!> %s\n", name);
+		DebugPrintf("<parallax file NOT USED!> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case RUN_LIST:
-		DebugPrintf("<run list> %s\n", name);
+		DebugPrintf("<run list> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case TEXT_FILE:
-		DebugPrintf("<text file> %s\n", name);
+		DebugPrintf("<text file> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case SCREEN_MANAGER:
-		DebugPrintf("<screen manager> %s\n", name);
+		DebugPrintf("<screen manager> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case MOUSE_FILE:
-		DebugPrintf("<mouse pointer> %s\n", name);
+		DebugPrintf("<mouse pointer> %s\n", _vm->_resman->fetchName(res));
 		break;
 	case ICON_FILE:
-		DebugPrintf("<menu icon> %s\n", name);
+		DebugPrintf("<menu icon> %s\n", _vm->_resman->fetchName(res));
 		break;
 	default:
 		DebugPrintf("unrecognised fileType %d\n", type);
@@ -511,9 +508,7 @@
 			if (!res)
 				break;
 
-			byte name[NAME_LEN];
-
-			DebugPrintf("%d %s\n", res, _vm->_resman->fetchName(res, name));
+			DebugPrintf("%d %s\n", res, _vm->_resman->fetchName(res));
 		}
 
 		_vm->_resman->closeResource(runList);
@@ -786,12 +781,11 @@
 
 	for (uint32 i = 0; i < MAX_events; i++) {
 		if (eventList[i].id) {
-			byte buf[NAME_LEN];
 			uint32 target = eventList[i].id;
 			uint32 script = eventList[i].interact_id;
 
-			DebugPrintf("slot %2d: id = %s (%d)\n", i, _vm->_resman->fetchName(target, buf), target);
-			DebugPrintf("         script = %s (%d) pos %d\n", _vm->_resman->fetchName(script / 65536, buf), script / 65536, script % 65536);
+			DebugPrintf("slot %2d: id = %s (%d)\n", i, _vm->_resman->fetchName(target), target);
+			DebugPrintf("         script = %s (%d) pos %d\n", _vm->_resman->fetchName(script / 65536), script / 65536, script % 65536);
 		}
 	}
 

Modified: scummvm/trunk/engines/sword2/debug.cpp
===================================================================
--- scummvm/trunk/engines/sword2/debug.cpp	2006-07-08 20:27:03 UTC (rev 23438)
+++ scummvm/trunk/engines/sword2/debug.cpp	2006-07-08 20:45:01 UTC (rev 23439)
@@ -172,8 +172,6 @@
 	// general debug info
 
 	if (_displayDebugText) {
-		byte name[NAME_LEN];
-
 /*
 		// CD in use
 		sprintf(buf, "CD-%d", currentCD);
@@ -187,7 +185,7 @@
 				_vm->_logic->readVar(MOUSE_X),
 				_vm->_logic->readVar(MOUSE_Y),
 				_vm->_logic->readVar(CLICKED_ID),
-				_vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID), name));
+				_vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID)));
 		else
 			sprintf(buf, "last click at %d,%d (---)",
 				_vm->_logic->readVar(MOUSE_X),
@@ -206,7 +204,7 @@
 				mouseX + screenInfo->scroll_offset_x,
 				mouseY + screenInfo->scroll_offset_y,
 				mouseTouching,
-				_vm->_resman->fetchName(mouseTouching, name));
+				_vm->_resman->fetchName(mouseTouching));
 		else
 			sprintf(buf, "mouse %d,%d (not touching)",
 				mouseX + screenInfo->scroll_offset_x,
@@ -221,7 +219,7 @@
 			sprintf(buf, "player %d,%d %s (%d) #%d/%d",
 				screenInfo->player_feet_x,
 				screenInfo->player_feet_y,
-				_vm->_resman->fetchName(_graphAnimRes, name),
+				_vm->_resman->fetchName(_graphAnimRes),
 				_graphAnimRes,
 				_graphAnimPc,
 				_graphNoFrames);
@@ -287,7 +285,7 @@
 
 		if (_speechScriptWaiting) {
 			sprintf(buf, "script waiting for %s (%d)",
-				_vm->_resman->fetchName(_speechScriptWaiting, name),
+				_vm->_resman->fetchName(_speechScriptWaiting),
 				_speechScriptWaiting);
 			makeDebugTextBlock(buf, 0, 90);
 		}

Modified: scummvm/trunk/engines/sword2/function.cpp
===================================================================
--- scummvm/trunk/engines/sword2/function.cpp	2006-07-08 20:27:03 UTC (rev 23438)
+++ scummvm/trunk/engines/sword2/function.cpp	2006-07-08 20:45:01 UTC (rev 23439)
@@ -876,9 +876,7 @@
 		if (readVar(PLAYER_ID) != CUR_PLAYER_ID)
 			debug(5, "(%d) Nico: %s", _officialTextNumber, text + 2);
 		else {
-			byte buf[NAME_LEN];
-
-			debug(5, "(%d) %s: %s", _officialTextNumber, _vm->_resman->fetchName(readVar(ID), buf), text + 2);
+			debug(5, "(%d) %s: %s", _officialTextNumber, _vm->_resman->fetchName(readVar(ID)), text + 2);
 		}
 
 		// Set up the speech animation

Modified: scummvm/trunk/engines/sword2/layers.cpp
===================================================================
--- scummvm/trunk/engines/sword2/layers.cpp	2006-07-08 20:27:03 UTC (rev 23438)
+++ scummvm/trunk/engines/sword2/layers.cpp	2006-07-08 20:45:01 UTC (rev 23439)
@@ -48,7 +48,6 @@
  */
 
 void Screen::initBackground(int32 res, int32 new_palette) {
-	byte buf[NAME_LEN];
 	int i;
 
 	assert(res);
@@ -56,7 +55,7 @@
 	_vm->_sound->clearFxQueue();
 	waitForFade();
 
-	debug(1, "CHANGED TO LOCATION \"%s\"", _vm->_resman->fetchName(res, buf));
+	debug(1, "CHANGED TO LOCATION \"%s\"", _vm->_resman->fetchName(res));
 
 	// if last screen was using a shading mask (see below)
 	if (_thisScreen.mask_flag) {

Modified: scummvm/trunk/engines/sword2/mouse.cpp
===================================================================
--- scummvm/trunk/engines/sword2/mouse.cpp	2006-07-08 20:27:03 UTC (rev 23438)
+++ scummvm/trunk/engines/sword2/mouse.cpp	2006-07-08 20:45:01 UTC (rev 23439)
@@ -539,7 +539,6 @@
 }
 
 void Mouse::menuMouse() {
-	byte buf[NAME_LEN];
 	MouseEvent *me;
 	int hit;
 
@@ -587,7 +586,7 @@
 		hideMouse();
 
 		debug(2, "Right-click on \"%s\" icon",
-			_vm->_resman->fetchName(_vm->_logic->readVar(OBJECT_HELD), buf));
+			_vm->_resman->fetchName(_vm->_logic->readVar(OBJECT_HELD)));
 
 		return;
 	}
@@ -615,7 +614,7 @@
 		setLuggage(_masterMenuList[hit].luggage_resource);
 
 		debug(2, "Left-clicked on \"%s\" icon - switch to drag mode",
-			_vm->_resman->fetchName(_vm->_logic->readVar(OBJECT_HELD), buf));
+			_vm->_resman->fetchName(_vm->_logic->readVar(OBJECT_HELD)));
 	}
 }
 
@@ -817,10 +816,10 @@
 				_vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID), buf2));
 		else if (_vm->_logic->readVar(LEFT_BUTTON))
 			debug(2, "Left-clicked on \"%s\"",
-				_vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID), buf1));
+				_vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID)));
 		else	// RIGHT BUTTON
 			debug(2, "Right-clicked on \"%s\"",
-				_vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID), buf1));
+				_vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID)));
 	}
 }
 
@@ -993,9 +992,7 @@
 				setLuggage(_currentLuggageResource);
 			}
 		} else {
-			byte buf[NAME_LEN];
-
-			error("ERROR: mouse.pointer==0 for object %d (%s) - update logic script!", _mouseTouching, _vm->_resman->fetchName(_mouseTouching, buf));
+			error("ERROR: mouse.pointer==0 for object %d (%s) - update logic script!", _mouseTouching, _vm->_resman->fetchName(_mouseTouching));
 		}
 	} else if (_oldMouseTouching && !_mouseTouching) {
 		// the cursor has moved off something - reset cursor to

Modified: scummvm/trunk/engines/sword2/resman.h
===================================================================
--- scummvm/trunk/engines/sword2/resman.h	2006-07-08 20:27:03 UTC (rev 23438)
+++ scummvm/trunk/engines/sword2/resman.h	2006-07-08 20:45:01 UTC (rev 23439)
@@ -98,7 +98,12 @@
 		return ptr[0];
 	}
 
-	byte *fetchName(uint32 res, byte *buf) {
+	byte *fetchName(uint32 res, byte *buf = NULL) {
+		static byte tempbuf[NAME_LEN];
+
+		if (!buf)
+			buf = tempbuf;
+
 		byte *ptr = openResource(res);
 		memcpy(buf, ptr + 10, NAME_LEN);
 		closeResource(res);

Modified: scummvm/trunk/engines/sword2/screen.cpp
===================================================================
--- scummvm/trunk/engines/sword2/screen.cpp	2006-07-08 20:27:03 UTC (rev 23438)
+++ scummvm/trunk/engines/sword2/screen.cpp	2006-07-08 20:45:01 UTC (rev 23439)
@@ -491,12 +491,10 @@
 	uint32 current_layer_area = layer_head.width * layer_head.height;
 
 	if (current_layer_area > _largestLayerArea) {
-		byte buf[NAME_LEN];
-
 		_largestLayerArea = current_layer_area;
 		sprintf(_largestLayerInfo,
 			"largest layer:  %s layer(%d) is %dx%d",
-			_vm->_resman->fetchName(_thisScreen.background_layer_id, buf),
+			_vm->_resman->fetchName(_thisScreen.background_layer_id),
 			layer_number, layer_head.width, layer_head.height);
 	}
 
@@ -583,12 +581,10 @@
 	uint32 current_sprite_area = frame_head.width * frame_head.height;
 
 	if (current_sprite_area > _largestSpriteArea) {
-		byte buf[NAME_LEN];
-
 		_largestSpriteArea = current_sprite_area;
 		sprintf(_largestSpriteInfo,
 			"largest sprite: %s frame(%d) is %dx%d",
-			_vm->_resman->fetchName(build_unit->anim_resource, buf),
+			_vm->_resman->fetchName(build_unit->anim_resource),
 			build_unit->anim_pc,
 			frame_head.width,
 			frame_head.height);
@@ -618,11 +614,9 @@
 
 	uint32 rv = drawSprite(&spriteInfo);
 	if (rv) {
-		byte buf[NAME_LEN];
-
 		error("Driver Error %.8x with sprite %s (%d) in processImage",
 			rv,
-			_vm->_resman->fetchName(build_unit->anim_resource, buf),
+			_vm->_resman->fetchName(build_unit->anim_resource),
 			build_unit->anim_resource);
 	}
 

Modified: scummvm/trunk/engines/sword2/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sound.cpp	2006-07-08 20:27:03 UTC (rev 23438)
+++ scummvm/trunk/engines/sword2/sound.cpp	2006-07-08 20:45:01 UTC (rev 23439)
@@ -202,9 +202,7 @@
 			break;
 		}
 
-		byte buf[NAME_LEN];
-
-		debug(0, "SFX (sample=\"%s\", vol=%d, pan=%d, delay=%d, type=%s)", _vm->_resman->fetchName(res, buf), volume, pan, delay, typeStr);
+		debug(0, "SFX (sample=\"%s\", vol=%d, pan=%d, delay=%d, type=%s)", _vm->_resman->fetchName(res), volume, pan, delay, typeStr);
 	}
 
 	for (int i = 0; i < FXQ_LENGTH; i++) {

Modified: scummvm/trunk/engines/sword2/startup.cpp
===================================================================
--- scummvm/trunk/engines/sword2/startup.cpp	2006-07-08 20:27:03 UTC (rev 23438)
+++ scummvm/trunk/engines/sword2/startup.cpp	2006-07-08 20:45:01 UTC (rev 23439)
@@ -80,9 +80,7 @@
 		}
 
 		if (_resman->fetchType(id) != SCREEN_MANAGER) {
-			byte name[NAME_LEN];
-
-			warning("startup.inf:%d: '%s' (%d) is not a screen manager", lineno, _resman->fetchName(id, name), id);
+			warning("startup.inf:%d: '%s' (%d) is not a screen manager", lineno, _resman->fetchName(id), id);
 			continue;
 		}
 






More information about the Scummvm-git-logs mailing list