Use constants for maze construction

This commit is contained in:
Marijn van der Werf 2017-05-03 15:57:37 +02:00 committed by Michael Steenbeek
parent 927190103b
commit 31e8b510ec
3 changed files with 34 additions and 18 deletions

View File

@ -1811,7 +1811,7 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y,
mapElement = map_get_track_element_at_of_type_from_ride(x, y, baseHeight, TRACK_ELEM_MAZE, rideIndex);
if (mapElement == NULL) {
if (mode != 0) {
if (mode != GC_SET_MAZE_TRACK_BUILD) {
gGameCommandErrorText = 0;
return MONEY32_UNDEFINED;
}
@ -1880,8 +1880,9 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y,
}
if (mode == 0) {
// Build mode
switch (mode) {
case GC_SET_MAZE_TRACK_BUILD:
{
uint8 segmentOffset = maze_element_get_segment_bit(x, y);
mapElement->properties.track.maze_entry &= ~(1 << segmentOffset);
@ -1903,10 +1904,14 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y,
}
}
}
} else if (mode == 1) {
// Move mode
} else {
// Fill-in mode
break;
}
case GC_SET_MAZE_TRACK_MOVE:
break;
case GC_SET_MAZE_TRACK_FILL:
if (direction != 4) {
uint16 previousSegmentX = x - TileDirectionDelta[direction].x / 2;
uint16 previousSegmentY = y - TileDirectionDelta[direction].y / 2;
@ -1943,6 +1948,7 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y,
segmentBit--;
} while ((segmentBit & 0x3) != 0x3);
}
break;
}
map_invalidate_tile(floor2(x, 32), floor2(y, 32), mapElement->base_height * 8, mapElement->clearance_height * 8);

View File

@ -491,6 +491,12 @@ enum {
TRACK_ELEMENT_LOCATION_IS_UNDERGROUND = 2,
};
enum {
GC_SET_MAZE_TRACK_BUILD = 0,
GC_SET_MAZE_TRACK_MOVE = 1,
GC_SET_MAZE_TRACK_FILL = 2,
};
typedef struct track_circuit_iterator {
rct_xy_element last;
rct_xy_element current;

View File

@ -185,7 +185,7 @@ static void window_maze_construction_close(rct_window *w)
if (ride->overall_view == 0xFFFF) {
sint32 savedPausedState = gGamePaused;
gGamePaused = 0;
game_do_command(0, 9, 0, rideIndex, GAME_COMMAND_DEMOLISH_RIDE, 0, 0);
game_do_command(0, GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED, 0, rideIndex, GAME_COMMAND_DEMOLISH_RIDE, 0, 0);
gGamePaused = savedPausedState;
} else {
window_ride_main_open(rideIndex);
@ -205,8 +205,8 @@ static void window_maze_construction_entrance_mouseup(rct_window *w, sint32 widg
// ???
uint8 old_state = _rideConstructionState;
_rideConstructionState = 5;
if (old_state != 5)
_rideConstructionState = RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT;
if (old_state != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT)
_rideConstructionState = old_state;
window_maze_construction_update_pressed_widgets();
}
@ -369,7 +369,11 @@ static void window_maze_construction_entrance_tooldown(sint32 x, sint32 y, rct_w
uint8 rideIndex = gRideEntranceExitPlaceRideIndex;
uint8 entranceExitType = gRideEntranceExitPlaceType;
gGameCommandErrorTitle = entranceExitType ? STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION : STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION;
if (entranceExitType == ENTRANCE_TYPE_RIDE_ENTRANCE) {
gGameCommandErrorTitle = STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION;
} else {
gGameCommandErrorTitle = STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION;
}
money32 cost = game_do_command(
x,
@ -489,17 +493,17 @@ static void window_maze_construction_construct(sint32 direction)
z = _currentTrackBeginZ;
switch (_rideConstructionState) {
case RIDE_CONSTRUCTION_STATE_MAZE_BUILD:
mode = 0;
flags = 1;
mode = GC_SET_MAZE_TRACK_BUILD;
flags = GAME_COMMAND_FLAG_APPLY;
break;
case RIDE_CONSTRUCTION_STATE_MAZE_MOVE:
mode = 1;
flags = 1 | 8;
mode = GC_SET_MAZE_TRACK_MOVE;
flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED;
break;
default:
case RIDE_CONSTRUCTION_STATE_MAZE_FILL:
mode = 2;
flags = 1 | 8;
mode = GC_SET_MAZE_TRACK_FILL;
flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED;
break;
}
@ -519,7 +523,7 @@ static void window_maze_construction_construct(sint32 direction)
_currentTrackBeginX = x;
_currentTrackBeginY = y;
if (_rideConstructionState != 7) {
if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_MAZE_MOVE) {
audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z);
}
}