From 73c6cf8bc9601347ec364e6549fa1794925748e5 Mon Sep 17 00:00:00 2001 From: James Brown Date: Fri, 23 May 2003 06:35:47 +0000 Subject: [PATCH] Patch #742132: o2_setobjectname script overwrite fix svn-id: r7854 --- scumm/script_v2.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index 4d3c1f78c05..16631148a40 100644 --- a/scumm/script_v2.cpp +++ b/scumm/script_v2.cpp @@ -1292,7 +1292,7 @@ void Scumm_v2::o2_pickupObject() { void Scumm_v2::o2_setObjectName() { int obj = getVarOrDirectWord(0x80); - int size; + int size = 0; int a; int i = 0; byte *name = NULL; @@ -1303,7 +1303,6 @@ void Scumm_v2::o2_setObjectName() { a = fetchScriptByte(); work[i++] = a; } while (a); - work[i] = 0; if (obj < _numActors) error("Can't set actor %d name with new-name-of", obj); @@ -1312,19 +1311,21 @@ void Scumm_v2::o2_setObjectName() { if (name == NULL) return; // Silently abort - byte *objptr; - byte offset = 0; + while(name[size++]) + ; - objptr = getOBCDFromObject(obj); - offset = *(objptr + 14); - size = READ_LE_UINT16(objptr) - offset; - - if (i >= size) { + if (i > size) { warning("New name of object %d too long (old *%s* new *%s*)", obj, name, work); - i = size - 1; + i = size; } - memcpy(name, work, i + 1); + while (i < size) { + work[i-1] = '@'; + i++; + } + work[i-1] = 0; + + memcpy(name, work, i); redrawV2Inventory(); }