From d2958083637f0dd3e8f9e5cbffe6a8fd8e7cbdf5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 21 Jun 2021 14:57:54 +0200 Subject: [PATCH] SAGA2: Fix warnings in objects.cpp --- engines/saga2/interp.cpp | 4 ++-- engines/saga2/objects.cpp | 18 +++++++----------- engines/saga2/objects.h | 6 +++--- engines/saga2/sagafunc.cpp | 4 ++-- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp index ee4fd48ef93..eb572cbac89 100644 --- a/engines/saga2/interp.cpp +++ b/engines/saga2/interp.cpp @@ -501,7 +501,7 @@ int16 RRandom(int16 c, int16 s, int16 id) { /* ============================================================================ * Main interpreter * ============================================================================ */ -void print_script_name(uint8 *codePtr, char *descr = NULL) { +void print_script_name(uint8 *codePtr, const char *descr = NULL) { char scriptName[32]; uint8 *sym = codePtr - 1; uint8 length = MIN(*sym, sizeof scriptName - 1); @@ -515,7 +515,7 @@ void print_script_name(uint8 *codePtr, char *descr = NULL) { debugC(1, kDebugScripts, "Scripts: %d op_enter: ::%s ", lastExport, scriptName); } -char *objectName(int16 segNum, uint16 segOff) { +const char *objectName(int16 segNum, uint16 segOff) { //static nameBuf[64]; if (segNum >= 0) diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp index 2a92794fd8d..9678554d7e8 100644 --- a/engines/saga2/objects.cpp +++ b/engines/saga2/objects.cpp @@ -436,8 +436,6 @@ void GameObject::append(ObjectID newParent) { // one, so we need to get the right one. headPtr = getHeadPtr(newParent, _data.location); - GameObject *parent = GameObject::objectAddress(newParent); - // Link us in to the parent's chain _data.parentID = newParent; @@ -1474,8 +1472,9 @@ void GameObject::updateState(void) { Object Names * ======================================================================= */ -char *GameObject::nameText(uint16 index) { - if (index < 0 || index >= nameListCount) return "Bad Name Index"; +const char *GameObject::nameText(uint16 index) { + if (index < 0 || index >= nameListCount) + return "Bad Name Index"; return nameList[index]; } @@ -1483,7 +1482,6 @@ char *GameObject::nameText(uint16 index) { #define INTANGIBLE_MASK (ProtoObj::isEnchantment|ProtoObj::isSpell|ProtoObj::isSkill) TilePoint GameObject::getFirstEmptySlot(GameObject *obj) { - int16 slotCount = 0; ObjectID objID; GameObject *item; TilePoint newLoc, temp; @@ -1795,8 +1793,7 @@ bool GameObject::addTimer(TimerID id) { bool GameObject::addTimer(TimerID id, int16 frameInterval) { TimerList *timerList; - Timer *newTimer, - *timerInList; + Timer *newTimer; // Create the new timer if ((newTimer = new Timer(this, id, frameInterval)) == nullptr) @@ -1874,7 +1871,6 @@ void GameObject::removeAllTimers(void) { bool GameObject::addSensor(Sensor *newSensor) { SensorList *sensorList; - Sensor *sensorInList; // Fetch the existing sensor list for this object or allocate a // new one @@ -2078,11 +2074,11 @@ bool GameObject::canSenseSpecificActor( SenseInfo &info, int16 range, Actor *a) { - SpecificActorSensor sensor(this, 0, range, a); + SpecificActorSensor sensor(this, 0, range, a); if (isActor(this)) { - Actor *a = (Actor *) this; - return sensor.check(info, a->enchantmentFlags); + Actor *ac = (Actor *)this; + return sensor.check(info, ac->enchantmentFlags); } return sensor.check(info, nonActorSenseFlags); } diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h index 62b2d8e65c0..e6763e4ea67 100644 --- a/engines/saga2/objects.h +++ b/engines/saga2/objects.h @@ -173,7 +173,7 @@ public: ObjectID thisID(void); // calculate our own ID value - static char *nameText(uint16 index); + static const char *nameText(uint16 index); protected: // get address of head-of-chain id. @@ -465,7 +465,7 @@ public: Location notGetWorldLocation(void); // Return the name of this object (proper noun if it has one) - char *objName(void) { + const char *objName(void) { return nameText((int16)( _data.nameIndex > 0 ? _data.nameIndex : prototype->nameIndex)); } @@ -485,7 +485,7 @@ public: } // Return the name of this type of object - char *protoName(void) { + const char *protoName(void) { return nameText(prototype->nameIndex); } diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp index c064e63e614..97b6c0f5cf9 100644 --- a/engines/saga2/sagafunc.cpp +++ b/engines/saga2/sagafunc.cpp @@ -114,8 +114,8 @@ int stringf(char *buffer, long maxlen, int formatStr, int16 *args) { GameObject *obj = GameObject::objectAddress(*args++); // Obtain SAGA string, copy to buffer (if it fits) - for (dptr = obj->objName(); *dptr && buffer < bufEnd;) { - *buffer++ = *dptr++; + for (const char *dptr1 = obj->objName(); *dptr1 && buffer < bufEnd;) { + *buffer++ = *dptr1++; } } else { // Write the character after the '%' to the buffer