SAGA2: Fix rest of the non-global-constructor warnings

This commit is contained in:
Eugene Sandulenko 2021-06-23 14:16:08 +02:00
parent e90a71d2fd
commit 44c4ad38e9
No known key found for this signature in database
GPG key ID: 014D387312D34F08
12 changed files with 43 additions and 106 deletions

View file

@ -284,12 +284,12 @@ void gPort::drawStringChars(
gPixelMap &dest,
int xpos, // x position to draw it
int ypos) { // y position to draw it
uint8 *s, // pointer to string
drawchar; // char to draw
const char *s; // pointer to string
uint8 drawchar; // char to draw
int16 x; // current x position
uint8 *buffer, // buffer to render to
*uBuffer; // underline buffer
uint16 rowMod = dest.size.x; // row modulus of dest
uint16 drowMod = dest.size.x; // row modulus of dest
int16 i; // loop index
uint8 underbar = (textStyles & textStyleBar) != 0;
bool underscore;
@ -299,35 +299,35 @@ void gPort::drawStringChars(
underPos = font->baseLine + 2;
if (underPos > font->height) underPos = font->height;
buffer = dest.data + (ypos * rowMod);
uBuffer = buffer + (underPos * rowMod);
buffer = dest.data + (ypos * drowMod);
uBuffer = buffer + (underPos * drowMod);
// draw drop-shadow, if any
if (textStyles & textStyleShadow) {
x = xpos - 1;
s = (uint8 *)str;
s = str;
if (textStyles & textStyleOutline) { // if outlining
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick drop shadow
x += font->charKern[drawchar];
DrawChar3x3Outline(font, drawchar, x, buffer, shPen, rowMod);
DrawChar3x3Outline(font, drawchar, x, buffer, shPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
} else if (textStyles & textStyleThickOutline) { // if outlining
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick drop shadow
x += font->charKern[drawchar];
DrawChar5x5Outline(font, drawchar, x, buffer, shPen, rowMod);
DrawChar5x5Outline(font, drawchar, x, buffer, shPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
} else {
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick drop shadow
x += font->charKern[drawchar];
DrawChar(font, drawchar, x, buffer + rowMod,
shPen, rowMod);
DrawChar(font, drawchar, x, buffer + drowMod,
shPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
}
@ -337,24 +337,24 @@ void gPort::drawStringChars(
if (textStyles & textStyleOutline) { // if outlining
x = xpos;
s = (uint8 *)str;
s = str;
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick text
x += font->charKern[drawchar];
DrawChar3x3Outline(font, drawchar, x, buffer - rowMod,
olPen, rowMod);
DrawChar3x3Outline(font, drawchar, x, buffer - drowMod,
olPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
} else if (textStyles & textStyleThickOutline) { // if thick outlining
x = xpos;
s = (uint8 *)str;
s = str;
for (i = 0; i < len; i++) {
drawchar = *s++; // draw extra thick text
x += font->charKern[drawchar];
DrawChar5x5Outline(font, drawchar, x, buffer - rowMod * 2,
olPen, rowMod);
DrawChar5x5Outline(font, drawchar, x, buffer - drowMod * 2,
olPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
}
@ -362,7 +362,7 @@ void gPort::drawStringChars(
// draw inner part
x = xpos;
s = (uint8 *)str;
s = str;
underscore = textStyles & textStyleUnderScore ? true : false;
for (i = 0; i < len; i++) {
@ -377,7 +377,7 @@ void gPort::drawStringChars(
if (textStyles & textStyleHiLiteBar) color = bgPen;
}
x += font->charKern[drawchar];
DrawChar(font, drawchar, x, buffer, color, rowMod);
DrawChar(font, drawchar, x, buffer, color, drowMod);
x += font->charSpace[drawchar] + textSpacing;
if (underscore) { // draw underscore
@ -453,8 +453,8 @@ int16 gPort::drawClippedString(
// Handle special case of negative kern value of 1st character
if (font->charKern[s[0]] < 0) {
int16 kern = - font->charKern[s[0]];
if (font->charKern[(byte)s[0]] < 0) {
int16 kern = - font->charKern[(byte)s[0]];
clipWidth += kern; // increase size of map to render
xoff += kern; // offset text into map right

View file

@ -568,7 +568,6 @@ bool gTextBox::pointerHit(gPanelMessage &msg) {
if (Rect16(0, 0, extent.width, extent.height).ptInside(pos)) {
Rect16 textBoxExtent = editRect;
int8 newIndex;
// get the position of the line
newIndex = clamp(0, pos.y / fontOffset, linesPerPage - 1);
@ -646,7 +645,6 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
// Process the various keystrokes...
if (editing && cursorPos > anchorPos) {
int16 t = cursorPos;
cursorPos = anchorPos;
anchorPos = cursorPos;
}
@ -905,13 +903,13 @@ void gTextBox::drawContents(void) {
// Allocate a temporary pixel map and render into it.
if (NewTempPort(tPort, editRect.width, editRect.height)) {
int16 cursorX,
anchorX,
anchorX = 0,
hiliteX,
hiliteWidth,
textHeight;
textHeight_;
textHeight = fontHeight;
textHeight_ = fontHeight;
if (hilit || editing) {
@ -978,7 +976,7 @@ void gTextBox::drawContents(void) {
tPort.setFont(textFont);
tPort.setColor(fontColorHilite);
tPort.moveTo(-scrollPixels, (editRect.height - textHeight + 1) / 2);
tPort.moveTo(-scrollPixels, (editRect.height - textHeight_ + 1) / 2);
tPort.drawText(fieldStrings[index], currentLen[index]);
// Blit the pixelmap to the main screen

View file

@ -26,6 +26,7 @@
#ifndef SAGA2_GTEXTBOX_H
#define SAGA2_GTEXTBOX_H
namespace Saga2 {
enum textBoxFlags {
@ -65,7 +66,6 @@ class gTextBox : public gControl {
private:
char **fieldStrings;
void *bufRef;
char *undoBuffer; // undo buffer for editing
bool internalBuffer;

View file

@ -95,7 +95,7 @@ hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
_base = (hResEntry *)((uint8*)_res->_table + entry->offset - _res->_firstGroupOffset);
debugC(3, kDebugResources, "- _numEntries = %d, _base = %p, entry->offset = %d",
_numEntries, _base, entry->offset);
_numEntries, (void *)_base, entry->offset);
_valid = true;
}

View file

@ -73,7 +73,7 @@ int16 lastExport;
extern hResource *scriptResFile; // script resources
hResContext *scriptRes; // script resource handle
void script_error(char *msg) {
void script_error(const char *msg) {
thisThread->flags |= Thread::aborted;
WriteStatusF(0, msg);
}
@ -302,7 +302,7 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
return segmentAddress(seg, index) + offset;
}
error("byteAddress: Invalid addressing mode: %d.\n", *pcPtr);
error("byteAddress: Invalid addressing mode: %d.\n", **pcPtr);
}
// Returns the address of an object given an addressing mode
@ -376,7 +376,7 @@ uint8 *objectAddress(
break;
default:
error("objectAddress: Invalid addressing mode: %d.\n", *pcPtr);
error("objectAddress: Invalid addressing mode: %d.\n", **pcPtr);
}
offs = index;
@ -443,7 +443,7 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
error("Addressing relative to 'this' not supported just yet.\n");
}
error("bitAddress: Invalid addressing mode: %d.\n", *pcPtr);
error("bitAddress: Invalid addressing mode: %d.\n", **pcPtr);
}
// Returns the address of a string
@ -577,7 +577,8 @@ bool Thread::interpret(void) {
switch (op = *pc++) {
case op_dup:
D_OP(op_dup);
*--stack = stack[0]; // duplicate value on stack
--stack;
*stack = stack[1]; // duplicate value on stack
break;
case op_drop: // drop word on stack
@ -1582,7 +1583,6 @@ void Thread::dispatch(void) {
numWaitSemi = 0,
numWaitOther = 0;
#if DEBUG
for (th = threadList.first(); th; th = threadList.next(th)) {
if (th->flags & waiting) {
switch (th->waitType) {
@ -1604,8 +1604,7 @@ void Thread::dispatch(void) {
numThreads++;
}
WriteStatusF(17, "Threads:%d X:%d D:%d F:%d T:%d O:%d", numThreads, numExecute, numWaitDelay, numWaitFrames, numWaitSemi, numWaitOther);
#endif
debugC(2, kDebugScripts, "Threads:%d X:%d D:%d F:%d T:%d O:%d", numThreads, numExecute, numWaitDelay, numWaitFrames, numWaitSemi, numWaitOther);
for (th = threadList.first(); th; th = nextThread) {
nextThread = threadList.next(th);
@ -1638,6 +1637,8 @@ void Thread::dispatch(void) {
((ActiveItem *)th->waitParam)->setExclusive(true);
}
break;
default:
break;
}
}

View file

@ -690,7 +690,7 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
// status line class
CStatusLine::CStatusLine(gPanelList &list,
const Rect16 &box,
char *msg,
const char *msg,
gFont *font,
int16 textPos,
textPallete &pal,
@ -896,8 +896,6 @@ void CMassWeightIndicator::recalculate(void) {
** weight/bulk control ( so it refreshes )
**/
void CMassWeightIndicator::update(void) {
CMassWeightIndicator *indNode = nullptr;
if (bRedraw == true) {
for (Common::List<CMassWeightIndicator *>::iterator it = indList.begin(); it != indList.end(); ++it) {
(*it)->recalculate();

View file

@ -238,7 +238,7 @@ private:
}
public:
CStatusLine(gPanelList &, const Rect16 &, char *, gFont *,
CStatusLine(gPanelList &, const Rect16 &, const char *, gFont *,
int16, textPallete &, int32, int16, AppFunc *cmd = NULL);
~CStatusLine(void);

View file

@ -36,13 +36,8 @@
#define TEST1 1 // enable test code
#define TEST2 1
#define TEST3 1 // loading/saving
#define CHEATMOVE 1 // For moving with keypad in 8 directions
#if TEST3
#include "saga2/loadsave.h"
#endif
#ifdef ALEXS
#include "saga2/automap.h"
#include "saga2/uidialog.h"
@ -114,7 +109,6 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
Actor *a = getCenterActor();
Location l(a->getLocation(), a->IDParent());
GameObject *object = (GameObject *)getCenterActor();
#ifdef FTA
static int Object = 2;
#endif
@ -186,26 +180,6 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
#endif
#if TEST3
case '5':
saveGameState(0, "game 1");
break;
case '6':
saveGameState(1, "game 2");
break;
case '%':
cleanupGameState();
loadSavedGameState(0);
break;
case '^':
cleanupGameState();
loadSavedGameState(1);
break;
#endif
#ifdef FTA
case 'a':
if (++Object < 8) {

View file

@ -2313,8 +2313,7 @@ uint16 GameObject::totalContainedBulk(void) {
GameWorld::GameWorld(int16 map) {
Common::SeekableReadStream *stream;
if (stream = loadResourceToStream(tileRes, MKTAG('M', 'A', 'P', (char)map),
"game map")) {
if ((stream = loadResourceToStream(tileRes, MKTAG('M', 'A', 'P', (char)map), "game map"))) {
int16 mapSize; // Size of map in MetaTiles
mapSize = stream->readUint16LE();

View file

@ -418,15 +418,6 @@ bool ProtoObj::dropOn(
assert(target != NULL);
assert(isWorld(loc.context));
int16 scriptResult;
/*
// Handle object script in a standard fashion
if ( ( scriptResult = stdActionScript(
Method_GameObject_onDropOnTAG,
dObj, enactor, target ) )
!= actionResultNotDone )
return scriptResult == actionResultSuccess;
*/
return dropOnAction(dObj, enactor, target, loc, num);
}
@ -627,19 +618,12 @@ bool ProtoObj::acceptHealing(
int8 perDieMod) {
int8 pdm = perDieMod;
int16 damage = 0;
int16 scriptResult;
assert(dObj != Nothing);
damage = absDamage;
if (dice)
for (int d = 0; d < abs(dice); d++)
damage += (g_vm->_rnd->getRandomNumber(sides - 1) + pdm + 1) * (dice > 0 ? 1 : -1);
#if 0
if ((scriptResult = stdActionScript(
Method_GameObject_onAcceptDamage,
dObj, enactor, Nothing))
!= actionResultNotDone)
return scriptResult == actionResultSuccess;
#endif
return acceptHealingAction(dObj, enactor, damage);
}
@ -1091,7 +1075,6 @@ bool InventoryProto::dropAction(
ProtoObj *enactorProto = enactorPtr->proto();
TilePoint enactorLoc(enactorPtr->getLocation());
TilePoint vector = loc - enactorLoc;
StandingTileInfo sti;
GameObject *extractedObj = NULL;
// Split the merged object if needed.
@ -1468,13 +1451,9 @@ bool KeyProto::setUseCursor(ObjectID dObj) {
// Send acceptLockToggle message to container
bool KeyProto::useOnAction(ObjectID dObj, ObjectID enactor, ObjectID withObj) {
GameObject *container = GameObject::objectAddress(withObj),
*thisKey = GameObject::objectAddress(dObj);
int16 keyID = thisKey->_data.massCount > 0 ? thisKey->_data.massCount : lockType;
GameObject *container = GameObject::objectAddress(withObj);
if (!container->acceptLockToggle(enactor, lockType)) {
// WriteStatusF( 3, "%s doesn't work", thisKey->objName() );
return false;
}
@ -1580,7 +1559,6 @@ bool MeleeWeaponProto::useAction(ObjectID dObj, ObjectID enactor) {
a->holdInRightHand(Nothing);
else {
GameObject *leftHandObjectPtr;
ProtoObj *leftHandProto;
leftHandObjectPtr = a->leftHandObject != Nothing
? GameObject::objectAddress(a->leftHandObject)
@ -2257,7 +2235,6 @@ bool ArmorProto::useSlotAvailable(GameObject *obj, Actor *a) {
bool ArmorProto::useAction(ObjectID dObj, ObjectID enactor) {
assert(isObject(dObj));
assert(isActor(enactor));
PlayerActorID pID;
Actor *a = (Actor *)GameObject::objectAddress(enactor);
GameObject *obj = GameObject::objectAddress(dObj);
@ -2663,9 +2640,6 @@ uint16 SkillProto::containmentSet(void) {
}
bool SkillProto::useAction(ObjectID dObj, ObjectID enactor) {
//GameObject *spellPtr = GameObject::objectAddress( dObj );
SpellStuff &sp = spellBook[getSpellID()];
if (nonUsable(this))
return false;
@ -3024,18 +2998,15 @@ bool IntangibleContainerProto::canOpen(ObjectID dObj, ObjectID) {
// Open a intangible container
bool IntangibleContainerProto::openAction(ObjectID dObj, ObjectID enactor) {
ContainerNode *cn;
GameObject *dObjPtr = GameObject::objectAddress(dObj);
// Perform appropriate opening tasks
cn = CreateContainerNode(enactor, false);
cn->markForShow();
// dObjPtr->_data.objectFlags |= GameObject::objectOpen; // Set open bit;
return true;
}
bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
ContainerNode *cn = globalContainerList.find(dObj, ContainerNode::mentalType);
assert(cn);
@ -3043,9 +3014,6 @@ bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
// Mark container for lazy deletion
cn->markForDelete();
// Clear open bit
// dObjPtr->_data.objectFlags &= ~GameObject::objectOpen;
return true;
}

View file

@ -37,8 +37,7 @@
namespace Saga2 {
const uint32 imageGroupID = MKTAG('I', 'M', 'A', 'G'),
borderID = MKTAG('B', 'R', 'D', 0);
const uint32 imageGroupID = MKTAG('I', 'M', 'A', 'G');
const int defaultStatusWait = 15;

View file

@ -2364,7 +2364,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
debugC(3, kDebugLoading, "- plIndex: %d", plIndex);
// Now, load the actual metatile data...
if (stream = loadResourceToStream(tileRes, platformID + mapNum, "platform")) {
if ((stream = loadResourceToStream(tileRes, platformID + mapNum, "platform"))) {
if (stream->skip(plIndex * sizeof(Platform))) {
pce->pl.load(stream);
return &pce->pl;
@ -4394,7 +4394,7 @@ void initTileCyclingStates(void) {
if (cycleList == nullptr)
error("Unable to load tile cycling data");
if (stream = loadResourceToStream(tileRes, cycleID, "cycle list")) {
if ((stream = loadResourceToStream(tileRes, cycleID, "cycle list"))) {
for (int i = 0; i < cycleCount; ++i)
cycleList[i].load(stream);