From 7bfaa0db78b79c555fc1137de4a5964beca9d16e Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 8 Jul 2006 20:45:01 +0000 Subject: Cleanup svn-id: r23439 --- engines/sword2/console.cpp | 36 +++++++++++++++--------------------- engines/sword2/debug.cpp | 10 ++++------ engines/sword2/function.cpp | 4 +--- engines/sword2/layers.cpp | 3 +-- engines/sword2/mouse.cpp | 13 +++++-------- engines/sword2/resman.h | 7 ++++++- engines/sword2/screen.cpp | 12 +++--------- engines/sword2/sound.cpp | 4 +--- engines/sword2/startup.cpp | 4 +--- 9 files changed, 37 insertions(+), 56 deletions(-) diff --git a/engines/sword2/console.cpp b/engines/sword2/console.cpp index b95c50653a..02f85418ad 100644 --- a/engines/sword2/console.cpp +++ b/engines/sword2/console.cpp @@ -434,44 +434,41 @@ bool Debugger::Cmd_ResLook(int argc, const char **argv) { } // Open up the resource and take a look inside! - uint8 type = _vm->_resman->fetchType(res);; - byte name[NAME_LEN]; - - _vm->_resman->fetchName(res, name); + uint8 type = _vm->_resman->fetchType(res); switch (type) { case ANIMATION_FILE: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case SCREEN_FILE: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case GAME_OBJECT: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case WALK_GRID_FILE: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case GLOBAL_VAR_FILE: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case PARALLAX_FILE_null: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case RUN_LIST: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case TEXT_FILE: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case SCREEN_MANAGER: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case MOUSE_FILE: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; case ICON_FILE: - DebugPrintf(" %s\n", name); + DebugPrintf(" %s\n", _vm->_resman->fetchName(res)); break; default: DebugPrintf("unrecognised fileType %d\n", type); @@ -511,9 +508,7 @@ bool Debugger::Cmd_RunList(int argc, const char **argv) { 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 @@ bool Debugger::Cmd_Events(int argc, const char **argv) { 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); } } diff --git a/engines/sword2/debug.cpp b/engines/sword2/debug.cpp index 42183c06d7..a7d4e709cc 100644 --- a/engines/sword2/debug.cpp +++ b/engines/sword2/debug.cpp @@ -172,8 +172,6 @@ void Debugger::buildDebugText() { // general debug info if (_displayDebugText) { - byte name[NAME_LEN]; - /* // CD in use sprintf(buf, "CD-%d", currentCD); @@ -187,7 +185,7 @@ void Debugger::buildDebugText() { _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 @@ void Debugger::buildDebugText() { 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 @@ void Debugger::buildDebugText() { 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 @@ void Debugger::buildDebugText() { if (_speechScriptWaiting) { sprintf(buf, "script waiting for %s (%d)", - _vm->_resman->fetchName(_speechScriptWaiting, name), + _vm->_resman->fetchName(_speechScriptWaiting), _speechScriptWaiting); makeDebugTextBlock(buf, 0, 90); } diff --git a/engines/sword2/function.cpp b/engines/sword2/function.cpp index a186fb9266..ec74d5c684 100644 --- a/engines/sword2/function.cpp +++ b/engines/sword2/function.cpp @@ -876,9 +876,7 @@ int32 Logic::fnISpeak(int32 *params) { 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 diff --git a/engines/sword2/layers.cpp b/engines/sword2/layers.cpp index e6e997c584..b64ae1de83 100644 --- a/engines/sword2/layers.cpp +++ b/engines/sword2/layers.cpp @@ -48,7 +48,6 @@ namespace Sword2 { */ void Screen::initBackground(int32 res, int32 new_palette) { - byte buf[NAME_LEN]; int i; assert(res); @@ -56,7 +55,7 @@ void Screen::initBackground(int32 res, int32 new_palette) { _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) { diff --git a/engines/sword2/mouse.cpp b/engines/sword2/mouse.cpp index d17b98624e..066a785a64 100644 --- a/engines/sword2/mouse.cpp +++ b/engines/sword2/mouse.cpp @@ -539,7 +539,6 @@ void Mouse::dragMouse() { } void Mouse::menuMouse() { - byte buf[NAME_LEN]; MouseEvent *me; int hit; @@ -587,7 +586,7 @@ void Mouse::menuMouse() { 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 @@ void Mouse::menuMouse() { 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 @@ void Mouse::normalMouse() { _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 @@ void Mouse::mouseOnOff() { 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 diff --git a/engines/sword2/resman.h b/engines/sword2/resman.h index 58875f1a74..756611ea31 100644 --- a/engines/sword2/resman.h +++ b/engines/sword2/resman.h @@ -98,7 +98,12 @@ public: 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); diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp index 8ed583d242..9c1d7cdf87 100644 --- a/engines/sword2/screen.cpp +++ b/engines/sword2/screen.cpp @@ -491,12 +491,10 @@ void Screen::processLayer(byte *file, uint32 layer_number) { 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 @@ void Screen::processImage(BuildUnit *build_unit) { 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 @@ void Screen::processImage(BuildUnit *build_unit) { 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); } diff --git a/engines/sword2/sound.cpp b/engines/sword2/sound.cpp index 575cd7b849..e62fac5e0a 100644 --- a/engines/sword2/sound.cpp +++ b/engines/sword2/sound.cpp @@ -202,9 +202,7 @@ void Sound::queueFx(int32 res, int32 type, int32 delay, int32 volume, int32 pan) 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++) { diff --git a/engines/sword2/startup.cpp b/engines/sword2/startup.cpp index 7ac089e04e..b8b0587ac7 100644 --- a/engines/sword2/startup.cpp +++ b/engines/sword2/startup.cpp @@ -80,9 +80,7 @@ bool Sword2Engine::initStartMenu() { } 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; } -- cgit v1.2.3