SAGA2: Fix warnings in objects.cpp

This commit is contained in:
Eugene Sandulenko 2021-06-21 14:57:54 +02:00
parent 1cc521808f
commit d295808363
No known key found for this signature in database
GPG key ID: 014D387312D34F08
4 changed files with 14 additions and 18 deletions

View file

@ -501,7 +501,7 @@ int16 RRandom(int16 c, int16 s, int16 id) {
/* ============================================================================ * /* ============================================================================ *
Main interpreter Main interpreter
* ============================================================================ */ * ============================================================================ */
void print_script_name(uint8 *codePtr, char *descr = NULL) { void print_script_name(uint8 *codePtr, const char *descr = NULL) {
char scriptName[32]; char scriptName[32];
uint8 *sym = codePtr - 1; uint8 *sym = codePtr - 1;
uint8 length = MIN<uint>(*sym, sizeof scriptName - 1); uint8 length = MIN<uint>(*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); 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]; //static nameBuf[64];
if (segNum >= 0) if (segNum >= 0)

View file

@ -436,8 +436,6 @@ void GameObject::append(ObjectID newParent) {
// one, so we need to get the right one. // one, so we need to get the right one.
headPtr = getHeadPtr(newParent, _data.location); headPtr = getHeadPtr(newParent, _data.location);
GameObject *parent = GameObject::objectAddress(newParent);
// Link us in to the parent's chain // Link us in to the parent's chain
_data.parentID = newParent; _data.parentID = newParent;
@ -1474,8 +1472,9 @@ void GameObject::updateState(void) {
Object Names Object Names
* ======================================================================= */ * ======================================================================= */
char *GameObject::nameText(uint16 index) { const char *GameObject::nameText(uint16 index) {
if (index < 0 || index >= nameListCount) return "Bad Name Index"; if (index < 0 || index >= nameListCount)
return "Bad Name Index";
return nameList[index]; return nameList[index];
} }
@ -1483,7 +1482,6 @@ char *GameObject::nameText(uint16 index) {
#define INTANGIBLE_MASK (ProtoObj::isEnchantment|ProtoObj::isSpell|ProtoObj::isSkill) #define INTANGIBLE_MASK (ProtoObj::isEnchantment|ProtoObj::isSpell|ProtoObj::isSkill)
TilePoint GameObject::getFirstEmptySlot(GameObject *obj) { TilePoint GameObject::getFirstEmptySlot(GameObject *obj) {
int16 slotCount = 0;
ObjectID objID; ObjectID objID;
GameObject *item; GameObject *item;
TilePoint newLoc, temp; TilePoint newLoc, temp;
@ -1795,8 +1793,7 @@ bool GameObject::addTimer(TimerID id) {
bool GameObject::addTimer(TimerID id, int16 frameInterval) { bool GameObject::addTimer(TimerID id, int16 frameInterval) {
TimerList *timerList; TimerList *timerList;
Timer *newTimer, Timer *newTimer;
*timerInList;
// Create the new timer // Create the new timer
if ((newTimer = new Timer(this, id, frameInterval)) == nullptr) if ((newTimer = new Timer(this, id, frameInterval)) == nullptr)
@ -1874,7 +1871,6 @@ void GameObject::removeAllTimers(void) {
bool GameObject::addSensor(Sensor *newSensor) { bool GameObject::addSensor(Sensor *newSensor) {
SensorList *sensorList; SensorList *sensorList;
Sensor *sensorInList;
// Fetch the existing sensor list for this object or allocate a // Fetch the existing sensor list for this object or allocate a
// new one // new one
@ -2078,11 +2074,11 @@ bool GameObject::canSenseSpecificActor(
SenseInfo &info, SenseInfo &info,
int16 range, int16 range,
Actor *a) { Actor *a) {
SpecificActorSensor sensor(this, 0, range, a); SpecificActorSensor sensor(this, 0, range, a);
if (isActor(this)) { if (isActor(this)) {
Actor *a = (Actor *) this; Actor *ac = (Actor *)this;
return sensor.check(info, a->enchantmentFlags); return sensor.check(info, ac->enchantmentFlags);
} }
return sensor.check(info, nonActorSenseFlags); return sensor.check(info, nonActorSenseFlags);
} }

View file

@ -173,7 +173,7 @@ public:
ObjectID thisID(void); // calculate our own ID value ObjectID thisID(void); // calculate our own ID value
static char *nameText(uint16 index); static const char *nameText(uint16 index);
protected: protected:
// get address of head-of-chain id. // get address of head-of-chain id.
@ -465,7 +465,7 @@ public:
Location notGetWorldLocation(void); Location notGetWorldLocation(void);
// Return the name of this object (proper noun if it has one) // Return the name of this object (proper noun if it has one)
char *objName(void) { const char *objName(void) {
return nameText((int16)( return nameText((int16)(
_data.nameIndex > 0 ? _data.nameIndex : prototype->nameIndex)); _data.nameIndex > 0 ? _data.nameIndex : prototype->nameIndex));
} }
@ -485,7 +485,7 @@ public:
} }
// Return the name of this type of object // Return the name of this type of object
char *protoName(void) { const char *protoName(void) {
return nameText(prototype->nameIndex); return nameText(prototype->nameIndex);
} }

View file

@ -114,8 +114,8 @@ int stringf(char *buffer, long maxlen, int formatStr, int16 *args) {
GameObject *obj = GameObject::objectAddress(*args++); GameObject *obj = GameObject::objectAddress(*args++);
// Obtain SAGA string, copy to buffer (if it fits) // Obtain SAGA string, copy to buffer (if it fits)
for (dptr = obj->objName(); *dptr && buffer < bufEnd;) { for (const char *dptr1 = obj->objName(); *dptr1 && buffer < bufEnd;) {
*buffer++ = *dptr++; *buffer++ = *dptr1++;
} }
} else { } else {
// Write the character after the '%' to the buffer // Write the character after the '%' to the buffer