SAGA2: Fix more global constructors warnings

This commit is contained in:
a/ 2021-07-02 03:33:13 +09:00
parent d017c36880
commit f6c8326aa4
7 changed files with 36 additions and 11 deletions

View File

@ -42,13 +42,13 @@ namespace Saga2 {
struct auxAudioTheme {
bool active;
Location l;
StaticLocation l;
soundSegment loopID;
};
static auxAudioTheme aats[AUXTHEMES] = {
{ false, Nowhere, 0 },
{ false, Nowhere, 0 }
{false, {Nowhere, 0}, 0},
{false, {Nowhere, 0}, 0}
};
void addAuxTheme(Location loc, soundSegment lid);
@ -153,7 +153,7 @@ void initAudioEnvirons(void) {
void addAuxTheme(Location loc, soundSegment lid) {
for (int i = 0; i < AUXTHEMES; i++) {
if (!aats[i].active) {
aats[i].l = loc;
aats[i].l.set(loc, loc.context);
aats[i].loopID = lid;
aats[i].active = true;
return;
@ -239,7 +239,7 @@ void setAreaSound(const TilePoint &) {
if (aats[i].active) {
Location loc = getCenterActor()->notGetWorldLocation();
if (aats[i].l.context == Nothing || loc.context == aats[i].l.context) {
TilePoint tp = (aats[i].l >> kTileUVShift) - baseCoords;
TilePoint tp = (aats[i].l.tile >> kTileUVShift) - baseCoords;
if (tp.magnitude() < dist.magnitude()) {
dist = tp;
loopID = USEAUXTHEME;

View File

@ -94,6 +94,16 @@ bool isWorld(GameObject *);
Location: Describes location of object within world or container
* ===================================================================== */
struct StaticLocation {
StaticTilePoint tile;
ObjectID context;
void set(TilePoint t, ObjectID con) {
tile.set(t.u, t.v, t.z);
context = con;
}
};
class Location : public TilePoint {
public:
// context = the ObjectID of containing context
@ -134,6 +144,13 @@ public:
context = con;
}
Location(StaticLocation l) {
u = l.tile.u;
v = l.tile.v;
z = l.tile.z;
context = l.context;
}
};
/* ===================================================================== *

View File

@ -173,7 +173,7 @@ void PatrolRouteIterator::altDecrement(void) {
//-----------------------------------------------------------------------
// Return the coordinates of the current waypoint
const TilePoint &PatrolRouteIterator::operator*(void) const {
const TilePoint PatrolRouteIterator::operator*(void) const {
const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
return _vertexNo >= 0 && _vertexNo < route.vertices() ? route[_vertexNo] : Nowhere;

View File

@ -142,7 +142,7 @@ public:
}
// Return the coordinates of the current waypoint
const TilePoint &operator*(void) const;
const TilePoint operator*(void) const;
// Iterate
const PatrolRouteIterator &operator++(void);

View File

@ -45,7 +45,7 @@ extern PlatformHandle platformList; // platform resource hunk
* ===================================================================== */
static int16 prevMapNum;
static TilePoint prevCoords = Nowhere;
static StaticTilePoint prevCoords = Nowhere;
static MetaTilePtr prevMeta;
/* ===================================================================== *
@ -923,7 +923,7 @@ int16 tileNopeHeight(
// Look up the metatile on the map.
metaPtr = prevMeta = mapList[mapNum].lookupMeta(metaCoords);
prevMapNum = mapNum;
prevCoords = metaCoords;
prevCoords.set(metaCoords.u, metaCoords.v, metaCoords.z);
}
if (metaPtr == NULL) return 0L;

View File

@ -106,6 +106,14 @@ struct StaticTilePoint {
return p;
}
friend int operator==(StaticTilePoint a, StaticTilePoint b) {
return a.u == b.u && a.v == b.v && a.z == b.z;
}
friend int operator!=(StaticTilePoint a, StaticTilePoint b) {
return a.u != b.u || a.v != b.v || a.z != b.z;
}
void operator+=(StaticTilePoint a) {
u += a.u;
v += a.v;
@ -191,7 +199,7 @@ struct TilePoint {
* ============================================================================ */
// A TilePoint defining a NULL location
const extern TilePoint Nowhere;
const extern StaticTilePoint Nowhere;
/* ============================================================================ *
TileRegion: Specifies a rectangular region of tiles using min/max

View File

@ -79,7 +79,7 @@ const int slowScrollSpeed = 6,
fastThreshhold = 16,
snapThreshhold = 400;
const TilePoint Nowhere((int16)minint16, (int16)minint16, (int16)minint16);
const StaticTilePoint Nowhere = {(int16)minint16, (int16)minint16, (int16)minint16};
const MetaTileID NoMetaTile(nullID, nullID);
const ActiveItemID NoActiveItem(0, activeItemIndexNullID);