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
* ============================================================================ */
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<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);
}
char *objectName(int16 segNum, uint16 segOff) {
const char *objectName(int16 segNum, uint16 segOff) {
//static nameBuf[64];
if (segNum >= 0)

View file

@ -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
@ -2081,8 +2077,8 @@ bool GameObject::canSenseSpecificActor(
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);
}

View file

@ -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);
}

View file

@ -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