SAGA2: Clean some global constructor warnings

This commit is contained in:
a/ 2021-07-04 14:38:32 +09:00
parent 573521056f
commit c6c0475e41
3 changed files with 42 additions and 43 deletions

View File

@ -67,6 +67,10 @@ typedef int16 PlayerActorID;
MetaTileID struct
* ===================================================================== */
struct StaticMetaTileID {
int16 map, index;
};
struct MetaTileID {
int16 map; // map number
int16 index; // index into metatile array
@ -80,6 +84,11 @@ struct MetaTileID {
// Constructor
MetaTileID(int16 m, int16 i) : map(m), index(i) {}
MetaTileID(StaticMetaTileID mt) {
map = mt.map;
index = mt.index;
}
MetaTileID operator = (const MetaTileID &id) {
map = id.map;
index = id.index;
@ -96,7 +105,7 @@ struct MetaTileID {
};
// ID of NULL meta tile
extern const MetaTileID NoMetaTile;
extern const StaticMetaTileID NoMetaTile;
/* ===================================================================== *
ActiveItemID struct
@ -108,6 +117,10 @@ const int activeItemMapShift = 13;
const int16 activeItemIndexNullID = 0x1FFF;
struct StaticActiveItemID {
int16 val;
};
#include "common/pack-start.h"
struct ActiveItemID {
int16 val; // ID value --
@ -125,13 +138,13 @@ struct ActiveItemID {
ActiveItemID(int16 idVal) : val(idVal) {}
// Constructor
#if DEBUG
ActiveItemID(int16 m, int16 i);
#else
ActiveItemID(int16 m, int16 i) :
val((m << activeItemMapShift) | (i & activeItemIndexMask)) {
}
#endif
ActiveItemID(StaticActiveItemID a) {
val = a.val;
}
ActiveItemID operator = (const ActiveItemID &id) {
val = id.val;
@ -143,6 +156,10 @@ struct ActiveItemID {
return *this;
}
static int16 getVal(int16 m, int16 i) {
return (m << activeItemMapShift) | (i & activeItemIndexMask);
}
bool operator == (const ActiveItemID &id) const {
return val == id.val;
}
@ -155,27 +172,19 @@ struct ActiveItemID {
return val;
}
#if DEBUG
void setMapNum(int16 m);
#else
void setMapNum(int16 m) {
val &= ~activeItemMapMask;
val |= (m << activeItemMapShift);
}
#endif
int16 getMapNum(void) {
return (uint16)val >> activeItemMapShift;
}
#if DEBUG
void setIndexNum(int16 i);
#else
void setIndexNum(int16 i) {
val &= ~activeItemIndexMask;
val |= i & activeItemIndexMask;
}
#endif
int16 getIndexNum(void) {
return val & activeItemIndexMask;
@ -184,7 +193,7 @@ struct ActiveItemID {
#include "common/pack-end.h"
// ID of NULL active item
extern const ActiveItemID NoActiveItem;
extern const StaticActiveItemID NoActiveItem;
/* ===================================================================== *
Task's and TaskStacks

View File

@ -81,8 +81,8 @@ const int slowScrollSpeed = 6,
const StaticTilePoint Nowhere = {(int16)minint16, (int16)minint16, (int16)minint16};
const MetaTileID NoMetaTile(nullID, nullID);
const ActiveItemID NoActiveItem(0, activeItemIndexNullID);
const StaticMetaTileID NoMetaTile = {nullID, nullID};
const StaticActiveItemID NoActiveItem = {ActiveItemID::getVal(0, activeItemIndexNullID)};
enum SurfaceType {
surfaceHoriz, // Level surface
@ -184,7 +184,7 @@ uint16 rippedRoofID;
static StaticTilePoint ripTableCoords = Nowhere;
static RipTable ripTableList[25];
static RipTable *ripTableList;
WorldMapData *mapList; // master map data array
@ -235,30 +235,6 @@ BankBits LoadedBanks; // what banks are loaded?
ActiveItemID member functions
* ===================================================================== */
#if DEBUG
ActiveItemID::ActiveItemID(int16 m, int16 i) :
val((m << activeItemMapShift) | (i & activeItemIndexMask)) {
assert(m < 0x8);
assert((uint16)i <= activeItemIndexNullID);
}
void ActiveItemID::setMapNum(int16 m) {
assert(m < 0x8);
val &= ~activeItemMapMask;
val |= (m << activeItemMapShift);
}
void ActiveItemID::setIndexNum(int16 i) {
assert((uint16)i <= activeItemIndexNullID);
val &= ~activeItemIndexMask;
val |= i & activeItemIndexMask;
}
#endif
/* ===================================================================== *
Finds the address of a tile associated with a TileID
* ===================================================================== */
//-----------------------------------------------------------------------
// Return the address of a tile's TileInfo structure given that tile's ID
@ -1591,6 +1567,13 @@ void initMaps(void) {
mapData->buildInstanceHash();
}
ripTableList = new RipTable[RipTable::kRipTableSize];
for (int k = 0; k < RipTable::kRipTableSize; ++k) {
ripTableList[k].metaID = NoMetaTile;
ripTableList[k].ripID = 0;
memset(ripTableList[k].zTable, 0, sizeof(ripTableList[k].zTable));
}
initPlatformCache();
initMapFeatures();
}
@ -1602,6 +1585,9 @@ void cleanupMaps(void) {
int16 i;
termMapFeatures();
delete[] ripTableList;
// Iterate through each map, dumping the data
for (i = 0; i < worldCount; i++) {
WorldMapData *mapData = &mapList[i];
@ -2818,7 +2804,7 @@ void buildRipTables(void) {
int16 tableIndex;
// bit array of available rip tables
uint8 tableAvail[(ARRAYSIZE(ripTableList) + 7) >> 3];
uint8 tableAvail[(RipTable::kRipTableSize + 7) >> 3];
memset(tableAvail, 0xFF, sizeof(tableAvail));
@ -2852,7 +2838,7 @@ void buildRipTables(void) {
uint j;
// Find available table
for (j = 0; j < ARRAYSIZE(ripTableList); j++) {
for (j = 0; j < RipTable::kRipTableSize; j++) {
if (tableAvail[j >> 3] & (1 << (j & 0x7)))
break;
}

View File

@ -766,6 +766,10 @@ struct RipTable {
uint16 ripID;
int16 zTable[kPlatformWidth][kPlatformWidth];
enum {
kRipTableSize = 25
};
// Constructor
RipTable(void) : metaID(NoMetaTile) {}