Review tileSetCenter flags

This commit is contained in:
Alexander Batalov 2022-10-29 18:52:22 +03:00
parent 0851354c8a
commit 4821cab724
6 changed files with 36 additions and 34 deletions

View File

@ -693,7 +693,7 @@ int gameHandleKey(int eventCode, bool isInCombatMode)
} }
if (gIsMapper) { if (gIsMapper) {
tileSetCenter(gDude->tile, TILE_SET_CENTER_FLAG_0x01); tileSetCenter(gDude->tile, TILE_SET_CENTER_REFRESH_WINDOW);
} else { } else {
_tile_scroll_to(gDude->tile, 2); _tile_scroll_to(gDude->tile, 2);
} }

View File

@ -545,7 +545,7 @@ static void opSetMapStart(Program* program)
} }
int tile = 200 * y + x; 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); scriptError("\nScript Error: %s: op_set_map_start: tile_set_center failed", program->name);
return; 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(); tileWindowRefresh();
} }
@ -866,7 +866,7 @@ static void opMoveTo(Program* program)
Rect rect; Rect rect;
newTile = objectSetLocation(object, tile, elevation, &rect); newTile = objectSetLocation(object, tile, elevation, &rect);
if (newTile != -1) { if (newTile != -1) {
tileSetCenter(object->tile, TILE_SET_CENTER_FLAG_0x01); tileSetCenter(object->tile, TILE_SET_CENTER_REFRESH_WINDOW);
} }
if (tileLimitingEnabled) { if (tileLimitingEnabled) {
@ -2061,7 +2061,7 @@ static void opMetarule3(Program* program)
} }
break; break;
case METARULE3_TILE_SET_CENTER: 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; break;
case METARULE3_109: case METARULE3_109:
result.integerValue = aiGetChemUse(static_cast<Object*>(param1.pointerValue)); result.integerValue = aiGetChemUse(static_cast<Object*>(param1.pointerValue));
@ -3158,7 +3158,7 @@ static void opFloatMessage(Program* program)
color = _colorTable[31744]; color = _colorTable[31744];
a5 = _colorTable[0]; a5 = _colorTable[0];
font = 103; font = 103;
tileSetCenter(gDude->tile, TILE_SET_CENTER_FLAG_0x01); tileSetCenter(gDude->tile, TILE_SET_CENTER_REFRESH_WINDOW);
break; break;
case FLOATING_MESSAGE_TYPE_NORMAL: case FLOATING_MESSAGE_TYPE_NORMAL:
case FLOATING_MESSAGE_TYPE_YELLOW: case FLOATING_MESSAGE_TYPE_YELLOW:

View File

@ -707,7 +707,7 @@ int mapSetEnteringLocation(int elevation, int tile_num, int orientation)
void mapNewMap() void mapNewMap()
{ {
mapSetElevation(0); mapSetElevation(0);
tileSetCenter(20100, TILE_SET_CENTER_FLAG_0x02); tileSetCenter(20100, TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS);
memset(&gMapTransition, 0, sizeof(gMapTransition)); memset(&gMapTransition, 0, sizeof(gMapTransition));
gMapHeader.enteringElevation = 0; gMapHeader.enteringElevation = 0;
gMapHeader.enteringRotation = 0; gMapHeader.enteringRotation = 0;
@ -894,7 +894,7 @@ static int mapLoad(File* stream)
} }
error = "Error setting tile center"; 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; goto err;
} }
@ -1240,7 +1240,7 @@ int mapHandleTransition()
objectSetRotation(gDude, gMapTransition.rotation, NULL); 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!"); debugPrint("\nError: map: attempt to center out-of-bounds!");
} }

View File

@ -1530,7 +1530,7 @@ int objectSetLocation(Object* obj, int tile, int elevation, Rect* rect)
if (elevation != oldElevation) { if (elevation != oldElevation) {
mapSetElevation(elevation); 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()) { if (isInCombat()) {
_game_user_wants_to_quit = 1; _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; goto err;
} }
} }
@ -3753,7 +3753,7 @@ int _obj_load_dude(File* stream)
return -1; 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; return rc;
} }

View File

@ -433,7 +433,7 @@ int tileInit(TileData** a1, int squareGridWidth, int squareGridHeight, int hexGr
gTileWindowWidth = ORIGINAL_ISO_WINDOW_WIDTH; gTileWindowWidth = ORIGINAL_ISO_WINDOW_WIDTH;
gTileWindowHeight = ORIGINAL_ISO_WINDOW_HEIGHT; 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); tileSetBorder(windowWidth, windowHeight, hexGridWidth, hexGridHeight);
// Restore actual window size and set center one more time to calculate // 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; gTileWindowWidth = windowWidth;
gTileWindowHeight = windowHeight; 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) { if (compat_stricmp(settings.system.executable.c_str(), "mapper") == 0) {
gTileWindowRefreshElevationProc = tileRefreshMapper; gTileWindowRefreshElevationProc = tileRefreshMapper;
@ -533,7 +533,8 @@ int tileSetCenter(int tile, int flags)
return -1; return -1;
} }
if ((gTileScrollLimitingEnabled & ((flags & TILE_SET_CENTER_FLAG_0x02) == 0)) != 0) { if ((flags & TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS) == 0) {
if (gTileScrollLimitingEnabled) {
int tileScreenX; int tileScreenX;
int tileScreenY; int tileScreenY;
tileToScreenXY(tile, &tileScreenX, &tileScreenY, gElevation); tileToScreenXY(tile, &tileScreenX, &tileScreenY, gElevation);
@ -553,11 +554,12 @@ int tileSetCenter(int tile, int flags)
} }
} }
if ((gTileScrollBlockingEnabled & ((flags & TILE_SET_CENTER_FLAG_0x02) == 0)) != 0) { if (gTileScrollBlockingEnabled) {
if (_obj_scroll_blocking_at(tile, gElevation) == 0) { if (_obj_scroll_blocking_at(tile, gElevation) == 0) {
return -1; return -1;
} }
} }
}
int tile_x = gHexGridWidth - 1 - tile % gHexGridWidth; int tile_x = gHexGridWidth - 1 - tile % gHexGridWidth;
int tile_y = tile / gHexGridWidth; int tile_y = tile / gHexGridWidth;
@ -590,7 +592,7 @@ int tileSetCenter(int tile, int flags)
gCenterTile = tile; gCenterTile = tile;
if (flags & TILE_SET_CENTER_FLAG_0x01) { if ((flags & TILE_SET_CENTER_REFRESH_WINDOW) != 0) {
// NOTE: Uninline. // NOTE: Uninline.
tileWindowRefresh(); tileWindowRefresh();
} }

View File

@ -6,8 +6,8 @@
namespace fallout { namespace fallout {
#define TILE_SET_CENTER_FLAG_0x01 0x01 #define TILE_SET_CENTER_REFRESH_WINDOW 0x01
#define TILE_SET_CENTER_FLAG_0x02 0x02 #define TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS 0x02
typedef void(TileWindowRefreshProc)(Rect* rect); typedef void(TileWindowRefreshProc)(Rect* rect);
typedef void(TileWindowRefreshElevationProc)(Rect* rect, int elevation); typedef void(TileWindowRefreshElevationProc)(Rect* rect, int elevation);