svn-id: r23439
This commit is contained in:
Torbjörn Andersson 2006-07-08 20:45:01 +00:00
parent 8edc7ce1f7
commit 7bfaa0db78
9 changed files with 37 additions and 56 deletions

View file

@ -434,44 +434,41 @@ bool Debugger::Cmd_ResLook(int argc, const char **argv) {
} }
// Open up the resource and take a look inside! // Open up the resource and take a look inside!
uint8 type = _vm->_resman->fetchType(res);; uint8 type = _vm->_resman->fetchType(res);
byte name[NAME_LEN];
_vm->_resman->fetchName(res, name);
switch (type) { switch (type) {
case ANIMATION_FILE: case ANIMATION_FILE:
DebugPrintf("<anim> %s\n", name); DebugPrintf("<anim> %s\n", _vm->_resman->fetchName(res));
break; break;
case SCREEN_FILE: case SCREEN_FILE:
DebugPrintf("<layer> %s\n", name); DebugPrintf("<layer> %s\n", _vm->_resman->fetchName(res));
break; break;
case GAME_OBJECT: case GAME_OBJECT:
DebugPrintf("<game object> %s\n", name); DebugPrintf("<game object> %s\n", _vm->_resman->fetchName(res));
break; break;
case WALK_GRID_FILE: case WALK_GRID_FILE:
DebugPrintf("<walk grid> %s\n", name); DebugPrintf("<walk grid> %s\n", _vm->_resman->fetchName(res));
break; break;
case GLOBAL_VAR_FILE: case GLOBAL_VAR_FILE:
DebugPrintf("<global variables> %s\n", name); DebugPrintf("<global variables> %s\n", _vm->_resman->fetchName(res));
break; break;
case PARALLAX_FILE_null: case PARALLAX_FILE_null:
DebugPrintf("<parallax file NOT USED!> %s\n", name); DebugPrintf("<parallax file NOT USED!> %s\n", _vm->_resman->fetchName(res));
break; break;
case RUN_LIST: case RUN_LIST:
DebugPrintf("<run list> %s\n", name); DebugPrintf("<run list> %s\n", _vm->_resman->fetchName(res));
break; break;
case TEXT_FILE: case TEXT_FILE:
DebugPrintf("<text file> %s\n", name); DebugPrintf("<text file> %s\n", _vm->_resman->fetchName(res));
break; break;
case SCREEN_MANAGER: case SCREEN_MANAGER:
DebugPrintf("<screen manager> %s\n", name); DebugPrintf("<screen manager> %s\n", _vm->_resman->fetchName(res));
break; break;
case MOUSE_FILE: case MOUSE_FILE:
DebugPrintf("<mouse pointer> %s\n", name); DebugPrintf("<mouse pointer> %s\n", _vm->_resman->fetchName(res));
break; break;
case ICON_FILE: case ICON_FILE:
DebugPrintf("<menu icon> %s\n", name); DebugPrintf("<menu icon> %s\n", _vm->_resman->fetchName(res));
break; break;
default: default:
DebugPrintf("unrecognised fileType %d\n", type); DebugPrintf("unrecognised fileType %d\n", type);
@ -511,9 +508,7 @@ bool Debugger::Cmd_RunList(int argc, const char **argv) {
if (!res) if (!res)
break; break;
byte name[NAME_LEN]; DebugPrintf("%d %s\n", res, _vm->_resman->fetchName(res));
DebugPrintf("%d %s\n", res, _vm->_resman->fetchName(res, name));
} }
_vm->_resman->closeResource(runList); _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++) { for (uint32 i = 0; i < MAX_events; i++) {
if (eventList[i].id) { if (eventList[i].id) {
byte buf[NAME_LEN];
uint32 target = eventList[i].id; uint32 target = eventList[i].id;
uint32 script = eventList[i].interact_id; uint32 script = eventList[i].interact_id;
DebugPrintf("slot %2d: id = %s (%d)\n", i, _vm->_resman->fetchName(target, buf), target); 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, buf), script / 65536, script % 65536); DebugPrintf(" script = %s (%d) pos %d\n", _vm->_resman->fetchName(script / 65536), script / 65536, script % 65536);
} }
} }

View file

@ -172,8 +172,6 @@ void Debugger::buildDebugText() {
// general debug info // general debug info
if (_displayDebugText) { if (_displayDebugText) {
byte name[NAME_LEN];
/* /*
// CD in use // CD in use
sprintf(buf, "CD-%d", currentCD); sprintf(buf, "CD-%d", currentCD);
@ -187,7 +185,7 @@ void Debugger::buildDebugText() {
_vm->_logic->readVar(MOUSE_X), _vm->_logic->readVar(MOUSE_X),
_vm->_logic->readVar(MOUSE_Y), _vm->_logic->readVar(MOUSE_Y),
_vm->_logic->readVar(CLICKED_ID), _vm->_logic->readVar(CLICKED_ID),
_vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID), name)); _vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID)));
else else
sprintf(buf, "last click at %d,%d (---)", sprintf(buf, "last click at %d,%d (---)",
_vm->_logic->readVar(MOUSE_X), _vm->_logic->readVar(MOUSE_X),
@ -206,7 +204,7 @@ void Debugger::buildDebugText() {
mouseX + screenInfo->scroll_offset_x, mouseX + screenInfo->scroll_offset_x,
mouseY + screenInfo->scroll_offset_y, mouseY + screenInfo->scroll_offset_y,
mouseTouching, mouseTouching,
_vm->_resman->fetchName(mouseTouching, name)); _vm->_resman->fetchName(mouseTouching));
else else
sprintf(buf, "mouse %d,%d (not touching)", sprintf(buf, "mouse %d,%d (not touching)",
mouseX + screenInfo->scroll_offset_x, mouseX + screenInfo->scroll_offset_x,
@ -221,7 +219,7 @@ void Debugger::buildDebugText() {
sprintf(buf, "player %d,%d %s (%d) #%d/%d", sprintf(buf, "player %d,%d %s (%d) #%d/%d",
screenInfo->player_feet_x, screenInfo->player_feet_x,
screenInfo->player_feet_y, screenInfo->player_feet_y,
_vm->_resman->fetchName(_graphAnimRes, name), _vm->_resman->fetchName(_graphAnimRes),
_graphAnimRes, _graphAnimRes,
_graphAnimPc, _graphAnimPc,
_graphNoFrames); _graphNoFrames);
@ -287,7 +285,7 @@ void Debugger::buildDebugText() {
if (_speechScriptWaiting) { if (_speechScriptWaiting) {
sprintf(buf, "script waiting for %s (%d)", sprintf(buf, "script waiting for %s (%d)",
_vm->_resman->fetchName(_speechScriptWaiting, name), _vm->_resman->fetchName(_speechScriptWaiting),
_speechScriptWaiting); _speechScriptWaiting);
makeDebugTextBlock(buf, 0, 90); makeDebugTextBlock(buf, 0, 90);
} }

View file

@ -876,9 +876,7 @@ int32 Logic::fnISpeak(int32 *params) {
if (readVar(PLAYER_ID) != CUR_PLAYER_ID) if (readVar(PLAYER_ID) != CUR_PLAYER_ID)
debug(5, "(%d) Nico: %s", _officialTextNumber, text + 2); debug(5, "(%d) Nico: %s", _officialTextNumber, text + 2);
else { else {
byte buf[NAME_LEN]; debug(5, "(%d) %s: %s", _officialTextNumber, _vm->_resman->fetchName(readVar(ID)), text + 2);
debug(5, "(%d) %s: %s", _officialTextNumber, _vm->_resman->fetchName(readVar(ID), buf), text + 2);
} }
// Set up the speech animation // Set up the speech animation

View file

@ -48,7 +48,6 @@ namespace Sword2 {
*/ */
void Screen::initBackground(int32 res, int32 new_palette) { void Screen::initBackground(int32 res, int32 new_palette) {
byte buf[NAME_LEN];
int i; int i;
assert(res); assert(res);
@ -56,7 +55,7 @@ void Screen::initBackground(int32 res, int32 new_palette) {
_vm->_sound->clearFxQueue(); _vm->_sound->clearFxQueue();
waitForFade(); 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 last screen was using a shading mask (see below)
if (_thisScreen.mask_flag) { if (_thisScreen.mask_flag) {

View file

@ -539,7 +539,6 @@ void Mouse::dragMouse() {
} }
void Mouse::menuMouse() { void Mouse::menuMouse() {
byte buf[NAME_LEN];
MouseEvent *me; MouseEvent *me;
int hit; int hit;
@ -587,7 +586,7 @@ void Mouse::menuMouse() {
hideMouse(); hideMouse();
debug(2, "Right-click on \"%s\" icon", 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; return;
} }
@ -615,7 +614,7 @@ void Mouse::menuMouse() {
setLuggage(_masterMenuList[hit].luggage_resource); setLuggage(_masterMenuList[hit].luggage_resource);
debug(2, "Left-clicked on \"%s\" icon - switch to drag mode", 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)); _vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID), buf2));
else if (_vm->_logic->readVar(LEFT_BUTTON)) else if (_vm->_logic->readVar(LEFT_BUTTON))
debug(2, "Left-clicked on \"%s\"", 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 else // RIGHT BUTTON
debug(2, "Right-clicked on \"%s\"", 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); setLuggage(_currentLuggageResource);
} }
} else { } else {
byte buf[NAME_LEN]; error("ERROR: mouse.pointer==0 for object %d (%s) - update logic script!", _mouseTouching, _vm->_resman->fetchName(_mouseTouching));
error("ERROR: mouse.pointer==0 for object %d (%s) - update logic script!", _mouseTouching, _vm->_resman->fetchName(_mouseTouching, buf));
} }
} else if (_oldMouseTouching && !_mouseTouching) { } else if (_oldMouseTouching && !_mouseTouching) {
// the cursor has moved off something - reset cursor to // the cursor has moved off something - reset cursor to

View file

@ -98,7 +98,12 @@ public:
return ptr[0]; 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); byte *ptr = openResource(res);
memcpy(buf, ptr + 10, NAME_LEN); memcpy(buf, ptr + 10, NAME_LEN);
closeResource(res); closeResource(res);

View file

@ -491,12 +491,10 @@ void Screen::processLayer(byte *file, uint32 layer_number) {
uint32 current_layer_area = layer_head.width * layer_head.height; uint32 current_layer_area = layer_head.width * layer_head.height;
if (current_layer_area > _largestLayerArea) { if (current_layer_area > _largestLayerArea) {
byte buf[NAME_LEN];
_largestLayerArea = current_layer_area; _largestLayerArea = current_layer_area;
sprintf(_largestLayerInfo, sprintf(_largestLayerInfo,
"largest layer: %s layer(%d) is %dx%d", "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); 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; uint32 current_sprite_area = frame_head.width * frame_head.height;
if (current_sprite_area > _largestSpriteArea) { if (current_sprite_area > _largestSpriteArea) {
byte buf[NAME_LEN];
_largestSpriteArea = current_sprite_area; _largestSpriteArea = current_sprite_area;
sprintf(_largestSpriteInfo, sprintf(_largestSpriteInfo,
"largest sprite: %s frame(%d) is %dx%d", "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, build_unit->anim_pc,
frame_head.width, frame_head.width,
frame_head.height); frame_head.height);
@ -618,11 +614,9 @@ void Screen::processImage(BuildUnit *build_unit) {
uint32 rv = drawSprite(&spriteInfo); uint32 rv = drawSprite(&spriteInfo);
if (rv) { if (rv) {
byte buf[NAME_LEN];
error("Driver Error %.8x with sprite %s (%d) in processImage", error("Driver Error %.8x with sprite %s (%d) in processImage",
rv, rv,
_vm->_resman->fetchName(build_unit->anim_resource, buf), _vm->_resman->fetchName(build_unit->anim_resource),
build_unit->anim_resource); build_unit->anim_resource);
} }

View file

@ -202,9 +202,7 @@ void Sound::queueFx(int32 res, int32 type, int32 delay, int32 volume, int32 pan)
break; break;
} }
byte buf[NAME_LEN]; debug(0, "SFX (sample=\"%s\", vol=%d, pan=%d, delay=%d, type=%s)", _vm->_resman->fetchName(res), volume, pan, delay, typeStr);
debug(0, "SFX (sample=\"%s\", vol=%d, pan=%d, delay=%d, type=%s)", _vm->_resman->fetchName(res, buf), volume, pan, delay, typeStr);
} }
for (int i = 0; i < FXQ_LENGTH; i++) { for (int i = 0; i < FXQ_LENGTH; i++) {

View file

@ -80,9 +80,7 @@ bool Sword2Engine::initStartMenu() {
} }
if (_resman->fetchType(id) != SCREEN_MANAGER) { 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), id);
warning("startup.inf:%d: '%s' (%d) is not a screen manager", lineno, _resman->fetchName(id, name), id);
continue; continue;
} }