SAGA2: Move currentMapNum to Saga2Engine

This commit is contained in:
a/
2021-08-24 02:43:15 +09:00
parent 00cdcbf1fa
commit ebba60f8eb
9 changed files with 40 additions and 49 deletions
+2 -4
View File
@@ -553,15 +553,13 @@ int16 openAutoMap() {
uint16 closeButtonResID = 0;
uint16 scrollButtonResID = 2;
extern int16 currentMapNum;
updateMapFeatures(currentMapNum);
updateMapFeatures(g_vm->_currentMapNum);
// init the resource context handle
decRes = resFile->newContext(MKTAG('A', 'M', 'A', 'P'), "Automap Resources");
// debug
_summaryData = LoadResource(decRes, MKTAG('S', 'U', 'M', currentMapNum), "summary data");
_summaryData = LoadResource(decRes, MKTAG('S', 'U', 'M', g_vm->_currentMapNum), "summary data");
// get the graphics associated with the buttons
closeBtnImage = loadButtonRes(decRes, closeButtonResID, numBtnImages);
+1 -2
View File
@@ -130,7 +130,6 @@ const static StaticTilePoint AudibilityVector = { 1, 1, 0 };
extern volatile int32 gameTime;
extern int16 currentMapNum; // which map is in use
extern uint16 rippedRoofID;
extern GameObject *getViewCenterObject(void);
@@ -266,7 +265,7 @@ void setAreaSound(const TilePoint &) {
TilePoint AudVec = TilePoint(AudibilityVector);
regn.max = baseCoords + ((AudVec * r) << kPlatShift) ; ///kTileUVSize;
regn.min = baseCoords - ((AudVec * r) << kPlatShift); ///kTileUVSize;
MetaTileIterator mIter(currentMapNum, regn);
MetaTileIterator mIter(g_vm->_currentMapNum, regn);
int i = 0;
int j = 0;
-3
View File
@@ -37,7 +37,6 @@ namespace Saga2 {
extern GameObject *objectList;
extern WorldMapData *mapList;
extern int16 currentMapNum;
Console::Console(Saga2Engine *vm) : GUI::Debugger() {
_vm = vm;
@@ -394,8 +393,6 @@ bool Console::cmdDumpMap(int argc, const char **argv) {
else {
gPixelMap drawMap;
drawMap.size = _vm->_tileDrawMap.size * atoi(argv[1]);
//drawMap.size.x = mapList[currentMapNum].mapHeight;
//drawMap.size.y = mapList[currentMapNum].mapHeight;
drawMap.data = new uint8[drawMap.bytes()]();
drawMetaTiles(drawMap);
+2 -3
View File
@@ -43,7 +43,6 @@ bool centerActorIndicatorEnabled;
Imports
* ===================================================================== */
extern int16 currentMapNum;
extern WorldMapData *mapList;
extern StaticPoint16 fineScroll;
@@ -382,8 +381,8 @@ void DisplayNode::drawObject(void) {
mCoords.z = 0;
// Do not display objects that are on a ripped roof
if ((mt = mapList[currentMapNum].lookupMeta(mCoords)) != NULL) {
if ((rt = mt->ripTable(currentMapNum)) != NULL) {
if ((mt = mapList[g_vm->_currentMapNum].lookupMeta(mCoords)) != NULL) {
if ((rt = mt->ripTable(g_vm->_currentMapNum)) != NULL) {
if (objCoords.z >= rt->zTable[tCoords.u][tCoords.v]) {
// Disable hit-test on the object's box
hitBox.width = -1;
+1
View File
@@ -90,6 +90,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
_indivControlsFlag = false;
_userControlsSetup = false;
_fadeDepth = 1;
_currentMapNum = 0;
SearchMan.addSubDirectoryMatching(gameDataDir, "res");
SearchMan.addSubDirectoryMatching(gameDataDir, "dos/drivers"); // For Miles Sound files
+1
View File
@@ -195,6 +195,7 @@ public:
bool _indivControlsFlag;
bool _userControlsSetup;
int _fadeDepth;
int _currentMapNum;
private:
+29 -30
View File
@@ -197,7 +197,6 @@ StaticTilePoint viewCenter = {0, 0, 0}; // coordinates of view on ma
// These two variables define which sectors overlap the view rect.
int16 currentMapNum; // which map is in use
int16 lastMapNum;
int32 lastUpdateTime; // time of last display update
@@ -1513,9 +1512,9 @@ void cleanupMaps(void) {
// Set a new current map
void setCurrentMap(int mapNum) {
currentMapNum = mapNum;
if (lastMapNum != currentMapNum) {
lastMapNum = currentMapNum;
g_vm->_currentMapNum = mapNum;
if (lastMapNum != g_vm->_currentMapNum) {
lastMapNum = g_vm->_currentMapNum;
freeAllTileBanks();
audioEnvironmentSetWorld(mapNum);
}
@@ -1681,7 +1680,7 @@ void initPlatformCache(void) {
* ===================================================================== */
TilePoint XYToUV(const Point32 &pt) {
int32 mapHeight = mapList[currentMapNum].mapHeight;
int32 mapHeight = mapList[g_vm->_currentMapNum].mapHeight;
TilePoint coords;
// coordinates of the view in U,V
@@ -1698,7 +1697,7 @@ TilePoint XYToUV(const Point32 &pt) {
* ===================================================================== */
void TileToScreenCoords(const TilePoint &tp, Point16 &p) {
int32 mapHeight = mapList[currentMapNum].mapHeight;
int32 mapHeight = mapList[g_vm->_currentMapNum].mapHeight;
// screen coords of the point
p.x = (((int32)tp.u - (int32)tp.v) << 1) - tileScroll.x + mapHeight;
@@ -1706,7 +1705,7 @@ void TileToScreenCoords(const TilePoint &tp, Point16 &p) {
}
void TileToScreenCoords(const TilePoint &tp, StaticPoint16 &p) {
int32 mapHeight = mapList[currentMapNum].mapHeight;
int32 mapHeight = mapList[g_vm->_currentMapNum].mapHeight;
// screen coords of the point
p.x = (((int32)tp.u - (int32)tp.v) << 1) - tileScroll.x + mapHeight;
@@ -2495,7 +2494,7 @@ TileInfo *TileIterator::next(TilePoint *loc, StandingTileInfo *stiResult) {
* ============================================================================ */
inline void drawMetaRow(gPixelMap &drawMap, TilePoint coords, Point16 pos) {
WorldMapData *curMap = &mapList[currentMapNum];
WorldMapData *curMap = &mapList[g_vm->_currentMapNum];
int16 uOrg = coords.u * kPlatformWidth,
vOrg = coords.v * kPlatformWidth;
@@ -2565,7 +2564,7 @@ inline void drawMetaRow(gPixelMap &drawMap, TilePoint coords, Point16 pos) {
for (int i = 0; i < layerLimit; i++) {
Platform *p;
p = metaPtr->fetchPlatform(currentMapNum, i);
p = metaPtr->fetchPlatform(g_vm->_currentMapNum, i);
if (!p)
continue;
@@ -2606,8 +2605,8 @@ void buildRipTable(
int32 *initPtr = (int32 *)ripTable->zTable;
// Initialize table
mt->ripTableID(currentMapNum) = ripTable->thisID();
ripTable->metaID = mt->thisID(currentMapNum);
mt->ripTableID(g_vm->_currentMapNum) = ripTable->thisID();
ripTable->metaID = mt->thisID(g_vm->_currentMapNum);
ripTable->ripID = ripID;
for (uint i = 0;
@@ -2625,12 +2624,12 @@ void buildRipTable(
for (uint i = 0; i < maxPlatforms; i++) {
Platform *p;
if ((p = mt->fetchPlatform(currentMapNum, i)) == nullptr) continue;
if ((p = mt->fetchPlatform(g_vm->_currentMapNum, i)) == nullptr) continue;
if (p->roofRipID() != ripID) continue;
for (; i < maxPlatforms && tilesToGo > 0; i++) {
if ((p = mt->fetchPlatform(currentMapNum, i)) == nullptr)
if ((p = mt->fetchPlatform(g_vm->_currentMapNum, i)) == nullptr)
continue;
uint16 platHeight = p->height << 3;
@@ -2683,7 +2682,7 @@ void buildRipTables(void) {
ripTableReg.max.v =
(actorCoords.v + regionRadius + kTileUVMask) >> kTileUVShift;
MetaTileIterator mIter(currentMapNum, ripTableReg);
MetaTileIterator mIter(g_vm->_currentMapNum, ripTableReg);
// Build meta tile pointer array
mt = mIter.first();
@@ -2703,7 +2702,7 @@ void buildRipTables(void) {
for (int i = 0; i < mtTableSize; i++) {
mt = mtTable[i];
RipTable *mtRipTable = mt->ripTable(currentMapNum);
RipTable *mtRipTable = mt->ripTable(g_vm->_currentMapNum);
// If meta tile aready has a valid object ripping table, simply
// recycle it
@@ -2779,9 +2778,9 @@ void drawMetaTiles(gPixelMap &drawMap) {
// coordinates of the view window on the map in X,Y (in 16 pixel units)
viewPos.x = (tileScroll.x >> kTileDXShift)
- (kPlatformWidth * mapList[currentMapNum].mapSize),
- (kPlatformWidth * mapList[g_vm->_currentMapNum].mapSize),
viewPos.y = (kPlatformWidth
* mapList[currentMapNum].mapSize
* mapList[g_vm->_currentMapNum].mapSize
* kTileDX)
- tileScroll.y;
@@ -3020,7 +3019,7 @@ void maskPlatform(
int16 trFlags;
ti = p.fetchTile(
currentMapNum,
g_vm->_currentMapNum,
pCoords,
origin,
&imageData,
@@ -3072,7 +3071,7 @@ void maskMetaRow(
TilePoint relLoc,
Point16 pos,
uint16 roofID) {
WorldMapData *curMap = &mapList[currentMapNum];
WorldMapData *curMap = &mapList[g_vm->_currentMapNum];
int16 uOrg = coords.u * kPlatformWidth,
vOrg = coords.v * kPlatformWidth;
@@ -3146,7 +3145,7 @@ void maskMetaRow(
for (int i = 0; i < layerLimit; i++) {
Platform *p;
if ((p = metaPtr->fetchPlatform(currentMapNum, i)) == nullptr)
if ((p = metaPtr->fetchPlatform(g_vm->_currentMapNum, i)) == nullptr)
continue;
if (p->roofRipID() == roofID && roofID > 0) break;
@@ -3191,9 +3190,9 @@ void drawTileMask(
// coordinates of the view window on the map in X,Y (in 16 pixel units)
viewPos.x = (aPos.x >> kTileDXShift)
- (kPlatformWidth * mapList[currentMapNum].mapSize),
- (kPlatformWidth * mapList[g_vm->_currentMapNum].mapSize),
viewPos.y = (kPlatformWidth
* mapList[currentMapNum].mapSize << kTileDXShift)
* mapList[g_vm->_currentMapNum].mapSize << kTileDXShift)
- aPos.y;
// coordinates of the view window upper left corner in U,V
@@ -3777,7 +3776,7 @@ bool pointOnHiddenSurface(
SurfaceType surfaceType) {
assert(surfaceType == surfaceVertU || surfaceType == surfaceVertV);
WorldMapData *curMap = &mapList[currentMapNum];
WorldMapData *curMap = &mapList[g_vm->_currentMapNum];
TilePoint testCoords,
mCoords,
@@ -3829,14 +3828,14 @@ bool pointOnHiddenSurface(
int16 h,
trFlags;
if ((p = mt->fetchPlatform(currentMapNum, i)) == nullptr)
if ((p = mt->fetchPlatform(g_vm->_currentMapNum, i)) == nullptr)
continue;
if (!(p->flags & plVisible) || platformRipped(p)) continue;
// Fetch the tile at this location
adjTile = p->fetchTile(
currentMapNum,
g_vm->_currentMapNum,
tCoords,
origin,
h,
@@ -3870,7 +3869,7 @@ StaticTilePoint pickTile(Point32 pos,
const TilePoint &protagPos,
StaticTilePoint *floorResult,
ActiveItemPtr *pickTAI) {
WorldMapData *curMap = &mapList[currentMapNum];
WorldMapData *curMap = &mapList[g_vm->_currentMapNum];
StaticTilePoint result = {0, 0, 0};
TilePoint pickCoords,
@@ -3963,7 +3962,7 @@ StaticTilePoint pickTile(Point32 pos,
Platform *p;
StandingTileInfo sti;
if ((p = mt->fetchPlatform(currentMapNum, i)) == nullptr)
if ((p = mt->fetchPlatform(g_vm->_currentMapNum, i)) == nullptr)
continue;
if (platformRipped(p)) break;
@@ -3972,7 +3971,7 @@ StaticTilePoint pickTile(Point32 pos,
// Fetch the tile at this location
ti = p->fetchTAGInstance(
currentMapNum,
g_vm->_currentMapNum,
tCoords,
origin,
&imageData,
@@ -4318,7 +4317,7 @@ void updateMainDisplay(void) {
setCurrentMap(currentWorld->mapNum);
}
WorldMapData *curMap = &mapList[currentMapNum];
WorldMapData *curMap = &mapList[g_vm->_currentMapNum];
StaticPoint32 scrollCenter,
scrollDelta;
@@ -4473,7 +4472,7 @@ const int mappingRadius = 2;
void markMetaAsVisited(const TilePoint &pt) {
// If (they have cartography)
{
WorldMapData *curMap = &mapList[currentMapNum];
WorldMapData *curMap = &mapList[g_vm->_currentMapNum];
uint16 *mapData = curMap->map->mapData;
TilePoint metaCoords = pt >> (kTileUVShift + kPlatShift);
+1 -2
View File
@@ -40,7 +40,6 @@ const uint16 tileBankCount = 64;
const uint32 tileImageID = MKTAG('T', 'I', 'L', 0);
extern int16 currentMapNum;
extern hResource *objResFile;
extern hResContext *tileRes; // tile resource handle
@@ -121,7 +120,7 @@ void drawPlatform(
uint8 *imageData;
int16 trFlags;
TileInfo *ti = p.fetchTile(currentMapNum, pCoords, origin, &imageData, h, trFlags);
TileInfo *ti = p.fetchTile(g_vm->_currentMapNum, pCoords, origin, &imageData, h, trFlags);
if (ti == NULL)
continue;
+3 -5
View File
@@ -35,8 +35,6 @@
namespace Saga2 {
extern int16 currentMapNum; // which map is in use
/* ===================================================================== *
Prototypes
* ===================================================================== */
@@ -78,7 +76,7 @@ void dayNightUpdate(void) {
lightLevel,
MAX_LIGHT);
if (currentMapNum == 0)
if (g_vm->_currentMapNum == 0)
g_vm->_pal->beginFade(&g_vm->_pal->_newPalette, 100);
}
@@ -86,7 +84,7 @@ void dayNightUpdate(void) {
gPalettePtr neededPalette;
gPalette currentPalette;
neededPalette = currentMapNum == 0 ? &g_vm->_pal->_newPalette : g_vm->_pal->_noonPalette;
neededPalette = g_vm->_currentMapNum == 0 ? &g_vm->_pal->_newPalette : g_vm->_pal->_noonPalette;
g_vm->_pal->getCurrentPalette(&currentPalette);
if (memcmp(&currentPalette, neededPalette, sizeof(gPalette)) != 0)
g_vm->_pal->setCurrentPalette(neededPalette);
@@ -129,7 +127,7 @@ void fadeUp(void) {
drawMainDisplay();
reDrawScreen();
enablePaletteChanges();
g_vm->_pal->beginFade(currentMapNum != 0 ? g_vm->_pal->_noonPalette : &g_vm->_pal->_newPalette, 20);
g_vm->_pal->beginFade(g_vm->_currentMapNum != 0 ? g_vm->_pal->_noonPalette : &g_vm->_pal->_newPalette, 20);
while (g_vm->_pal->updatePalette()) ;
}
}