diff --git a/src/game.cc b/src/game.cc index 5ea3043..3d8c859 100644 --- a/src/game.cc +++ b/src/game.cc @@ -693,7 +693,7 @@ int gameHandleKey(int eventCode, bool isInCombatMode) } if (gIsMapper) { - tileSetCenter(gDude->tile, TILE_SET_CENTER_FLAG_0x01); + tileSetCenter(gDude->tile, TILE_SET_CENTER_REFRESH_WINDOW); } else { _tile_scroll_to(gDude->tile, 2); } diff --git a/src/interpreter_extra.cc b/src/interpreter_extra.cc index 9626648..312ca56 100644 --- a/src/interpreter_extra.cc +++ b/src/interpreter_extra.cc @@ -545,7 +545,7 @@ static void opSetMapStart(Program* program) } int tile = 200 * y + x; - if (tileSetCenter(tile, TILE_SET_CENTER_FLAG_0x01 | TILE_SET_CENTER_FLAG_0x02) != 0) { + if (tileSetCenter(tile, TILE_SET_CENTER_REFRESH_WINDOW | TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS) != 0) { scriptError("\nScript Error: %s: op_set_map_start: tile_set_center failed", program->name); return; } @@ -584,7 +584,7 @@ static void opOverrideMapStart(Program* program) } } - tileSetCenter(tile, TILE_SET_CENTER_FLAG_0x01); + tileSetCenter(tile, TILE_SET_CENTER_REFRESH_WINDOW); tileWindowRefresh(); } @@ -866,7 +866,7 @@ static void opMoveTo(Program* program) Rect rect; newTile = objectSetLocation(object, tile, elevation, &rect); if (newTile != -1) { - tileSetCenter(object->tile, TILE_SET_CENTER_FLAG_0x01); + tileSetCenter(object->tile, TILE_SET_CENTER_REFRESH_WINDOW); } if (tileLimitingEnabled) { @@ -2061,7 +2061,7 @@ static void opMetarule3(Program* program) } break; case METARULE3_TILE_SET_CENTER: - result.integerValue = tileSetCenter(param1.integerValue, TILE_SET_CENTER_FLAG_0x01); + result.integerValue = tileSetCenter(param1.integerValue, TILE_SET_CENTER_REFRESH_WINDOW); break; case METARULE3_109: result.integerValue = aiGetChemUse(static_cast(param1.pointerValue)); @@ -3158,7 +3158,7 @@ static void opFloatMessage(Program* program) color = _colorTable[31744]; a5 = _colorTable[0]; font = 103; - tileSetCenter(gDude->tile, TILE_SET_CENTER_FLAG_0x01); + tileSetCenter(gDude->tile, TILE_SET_CENTER_REFRESH_WINDOW); break; case FLOATING_MESSAGE_TYPE_NORMAL: case FLOATING_MESSAGE_TYPE_YELLOW: diff --git a/src/map.cc b/src/map.cc index 369e6fb..87990e1 100644 --- a/src/map.cc +++ b/src/map.cc @@ -707,7 +707,7 @@ int mapSetEnteringLocation(int elevation, int tile_num, int orientation) void mapNewMap() { mapSetElevation(0); - tileSetCenter(20100, TILE_SET_CENTER_FLAG_0x02); + tileSetCenter(20100, TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS); memset(&gMapTransition, 0, sizeof(gMapTransition)); gMapHeader.enteringElevation = 0; gMapHeader.enteringRotation = 0; @@ -894,7 +894,7 @@ static int mapLoad(File* stream) } error = "Error setting tile center"; - if (tileSetCenter(gEnteringTile, TILE_SET_CENTER_FLAG_0x02) != 0) { + if (tileSetCenter(gEnteringTile, TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS) != 0) { goto err; } @@ -1240,7 +1240,7 @@ int mapHandleTransition() objectSetRotation(gDude, gMapTransition.rotation, NULL); } - if (tileSetCenter(gDude->tile, TILE_SET_CENTER_FLAG_0x01) == -1) { + if (tileSetCenter(gDude->tile, TILE_SET_CENTER_REFRESH_WINDOW) == -1) { debugPrint("\nError: map: attempt to center out-of-bounds!"); } diff --git a/src/object.cc b/src/object.cc index 44e50f9..9cbf55a 100644 --- a/src/object.cc +++ b/src/object.cc @@ -1530,7 +1530,7 @@ int objectSetLocation(Object* obj, int tile, int elevation, Rect* rect) if (elevation != oldElevation) { mapSetElevation(elevation); - tileSetCenter(tile, TILE_SET_CENTER_FLAG_0x01 | TILE_SET_CENTER_FLAG_0x02); + tileSetCenter(tile, TILE_SET_CENTER_REFRESH_WINDOW | TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS); if (isInCombat()) { _game_user_wants_to_quit = 1; } @@ -3335,7 +3335,7 @@ static int _obj_offset_table_init() } } - if (tileSetCenter(gCenterTile + 1, 2) == -1) { + if (tileSetCenter(gCenterTile + 1, TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS) == -1) { goto err; } } @@ -3753,7 +3753,7 @@ int _obj_load_dude(File* stream) return -1; } - tileSetCenter(tile, TILE_SET_CENTER_FLAG_0x01 | TILE_SET_CENTER_FLAG_0x02); + tileSetCenter(tile, TILE_SET_CENTER_REFRESH_WINDOW | TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS); return rc; } diff --git a/src/tile.cc b/src/tile.cc index 1ce2e77..2354bc5 100644 --- a/src/tile.cc +++ b/src/tile.cc @@ -433,7 +433,7 @@ int tileInit(TileData** a1, int squareGridWidth, int squareGridHeight, int hexGr gTileWindowWidth = ORIGINAL_ISO_WINDOW_WIDTH; gTileWindowHeight = ORIGINAL_ISO_WINDOW_HEIGHT; - tileSetCenter(hexGridWidth * (hexGridHeight / 2) + hexGridWidth / 2, 2); + tileSetCenter(hexGridWidth * (hexGridHeight / 2) + hexGridWidth / 2, TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS); tileSetBorder(windowWidth, windowHeight, hexGridWidth, hexGridHeight); // Restore actual window size and set center one more time to calculate @@ -442,7 +442,7 @@ int tileInit(TileData** a1, int squareGridWidth, int squareGridHeight, int hexGr gTileWindowWidth = windowWidth; gTileWindowHeight = windowHeight; - tileSetCenter(hexGridWidth * (hexGridHeight / 2) + hexGridWidth / 2, 2); + tileSetCenter(hexGridWidth * (hexGridHeight / 2) + hexGridWidth / 2, TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS); if (compat_stricmp(settings.system.executable.c_str(), "mapper") == 0) { gTileWindowRefreshElevationProc = tileRefreshMapper; @@ -533,29 +533,31 @@ int tileSetCenter(int tile, int flags) return -1; } - if ((gTileScrollLimitingEnabled & ((flags & TILE_SET_CENTER_FLAG_0x02) == 0)) != 0) { - int tileScreenX; - int tileScreenY; - tileToScreenXY(tile, &tileScreenX, &tileScreenY, gElevation); + if ((flags & TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS) == 0) { + if (gTileScrollLimitingEnabled) { + int tileScreenX; + int tileScreenY; + tileToScreenXY(tile, &tileScreenX, &tileScreenY, gElevation); - int dudeScreenX; - int dudeScreenY; - tileToScreenXY(gDude->tile, &dudeScreenX, &dudeScreenY, gElevation); + int dudeScreenX; + int dudeScreenY; + tileToScreenXY(gDude->tile, &dudeScreenX, &dudeScreenY, gElevation); - int dx = abs(dudeScreenX - tileScreenX); - int dy = abs(dudeScreenY - tileScreenY); + int dx = abs(dudeScreenX - tileScreenX); + int dy = abs(dudeScreenY - tileScreenY); - if (dx > abs(dudeScreenX - _tile_offx) - || dy > abs(dudeScreenY - _tile_offy)) { - if (dx >= 480 || dy >= 400) { - return -1; + if (dx > abs(dudeScreenX - _tile_offx) + || dy > abs(dudeScreenY - _tile_offy)) { + if (dx >= 480 || dy >= 400) { + return -1; + } } } - } - if ((gTileScrollBlockingEnabled & ((flags & TILE_SET_CENTER_FLAG_0x02) == 0)) != 0) { - if (_obj_scroll_blocking_at(tile, gElevation) == 0) { - return -1; + if (gTileScrollBlockingEnabled) { + if (_obj_scroll_blocking_at(tile, gElevation) == 0) { + return -1; + } } } @@ -590,7 +592,7 @@ int tileSetCenter(int tile, int flags) gCenterTile = tile; - if (flags & TILE_SET_CENTER_FLAG_0x01) { + if ((flags & TILE_SET_CENTER_REFRESH_WINDOW) != 0) { // NOTE: Uninline. tileWindowRefresh(); } diff --git a/src/tile.h b/src/tile.h index 83f2070..54f20a0 100644 --- a/src/tile.h +++ b/src/tile.h @@ -6,8 +6,8 @@ namespace fallout { -#define TILE_SET_CENTER_FLAG_0x01 0x01 -#define TILE_SET_CENTER_FLAG_0x02 0x02 +#define TILE_SET_CENTER_REFRESH_WINDOW 0x01 +#define TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS 0x02 typedef void(TileWindowRefreshProc)(Rect* rect); typedef void(TileWindowRefreshElevationProc)(Rect* rect, int elevation);