mirror of https://github.com/OpenRCT2/OpenRCT2.git
Apply cpp style
This commit is contained in:
parent
652cf510e5
commit
b2bab06235
|
@ -1102,7 +1102,7 @@ bool track_block_get_previous_from_zero(sint16 x, sint16 y, sint16 z, uint8 ride
|
|||
|
||||
void sub_6C84CE();
|
||||
void sub_6C96C0();
|
||||
money32 ride_get_entrance_or_exit_price(sint32 rideIndex, sint32 x, sint32 y, sint32 direction, sint32 dh, sint32 di);
|
||||
money32 ride_get_entrance_or_exit_price(sint32 rideIndex, sint32 x, sint32 y, sint32 direction, sint32 placeType, sint32 stationNum);
|
||||
void ride_get_entrance_or_exit_position_from_screen_position(sint32 x, sint32 y, sint32 *outX, sint32 *outY, sint32 *outDirection);
|
||||
|
||||
bool ride_select_backwards_from_front();
|
||||
|
|
|
@ -228,7 +228,14 @@ static money32 ParkEntranceRemove(sint16 x, sint16 y, uint8 z, uint8 flags)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static money32 place_ride_entrance_or_exit(sint16 x, sint16 y, sint16 z, uint8 direction, uint8 flags, uint8 rideIndex, uint8 station_num, uint8 is_exit)
|
||||
static money32 place_ride_entrance_or_exit(sint16 x,
|
||||
sint16 y,
|
||||
sint16 z,
|
||||
uint8 direction,
|
||||
uint8 flags,
|
||||
uint8 rideIndex,
|
||||
uint8 stationNum,
|
||||
bool isExit)
|
||||
{
|
||||
// Remember when in Unknown station num mode rideIndex is unknown and z is set
|
||||
// When in known station num mode rideIndex is known and z is unknown
|
||||
|
@ -237,57 +244,73 @@ static money32 place_ride_entrance_or_exit(sint16 x, sint16 y, sint16 z, uint8 d
|
|||
gCommandPosition.x = x;
|
||||
gCommandPosition.y = y;
|
||||
|
||||
if (!map_check_free_elements_and_reorganise(1)) {
|
||||
if (!map_check_free_elements_and_reorganise(1))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode){
|
||||
if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode)
|
||||
{
|
||||
gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (station_num == 0xFF) {
|
||||
if (stationNum == 0xFF)
|
||||
{
|
||||
z *= 16;
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
return MONEY32_UNDEFINED;
|
||||
|
||||
if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) {
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
sint16 clear_z = z / 8 + (is_exit ? 5 : 7);
|
||||
|
||||
if (!gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) {
|
||||
if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) {
|
||||
sint16 clear_z = z / 8 + (isExit ? 5 : 7);
|
||||
|
||||
if (!gCheatsDisableClearanceChecks &&
|
||||
!map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (gMapGroundFlags & ELEMENT_IS_UNDERWATER)
|
||||
{
|
||||
gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (z > 1952) {
|
||||
if (z > 1952)
|
||||
{
|
||||
gGameCommandErrorText = STR_TOO_HIGH;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rideIndex >= MAX_RIDES)
|
||||
{
|
||||
log_warning("Invalid game command for ride %u", rideIndex);
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
rct_ride* ride = get_ride(rideIndex);
|
||||
if (ride->type == RIDE_TYPE_NULL)
|
||||
{
|
||||
log_warning("Invalid game command for ride %u", rideIndex);
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
if (ride->status != RIDE_STATUS_CLOSED) {
|
||||
|
||||
if (ride->status != RIDE_STATUS_CLOSED)
|
||||
{
|
||||
gGameCommandErrorText = STR_MUST_BE_CLOSED_FIRST;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) {
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK)
|
||||
{
|
||||
gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
@ -295,81 +318,93 @@ static money32 place_ride_entrance_or_exit(sint16 x, sint16 y, sint16 z, uint8 d
|
|||
ride_clear_for_construction(rideIndex);
|
||||
ride_remove_peeps(rideIndex);
|
||||
|
||||
uint8 requires_remove = 0;
|
||||
sint16 remove_x = 0;
|
||||
sint16 remove_y = 0;
|
||||
bool requiresRemove = false;
|
||||
rct_xy16 removeCoord = { 0, 0 };
|
||||
|
||||
if (is_exit) {
|
||||
if (ride->exits[station_num] != 0xFFFF) {
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST) {
|
||||
if (isExit)
|
||||
{
|
||||
if (ride->exits[stationNum] != 0xFFFF)
|
||||
{
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
gGameCommandErrorText = 0;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
remove_x = (ride->exits[station_num] & 0xFF) * 32;
|
||||
remove_y = ((ride->exits[station_num] >> 8) & 0xFF) * 32;
|
||||
requires_remove = 1;
|
||||
removeCoord.x = (ride->exits[stationNum] & 0xFF) * 32;
|
||||
removeCoord.y = ((ride->exits[stationNum] >> 8) & 0xFF) * 32;
|
||||
requiresRemove = true;
|
||||
}
|
||||
} else if (ride->entrances[station_num] != 0xFFFF) {
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST) {
|
||||
}
|
||||
else if (ride->entrances[stationNum] != 0xFFFF)
|
||||
{
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
gGameCommandErrorText = 0;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
remove_x = (ride->entrances[station_num] & 0xFF) * 32;
|
||||
remove_y = ((ride->entrances[station_num] >> 8) & 0xFF) * 32;
|
||||
requires_remove = 1;
|
||||
removeCoord.x = (ride->entrances[stationNum] & 0xFF) * 32;
|
||||
removeCoord.y = ((ride->entrances[stationNum] >> 8) & 0xFF) * 32;
|
||||
requiresRemove = true;
|
||||
}
|
||||
|
||||
if (requires_remove) {
|
||||
if (requiresRemove)
|
||||
{
|
||||
money32 success = game_do_command(
|
||||
remove_x,
|
||||
removeCoord.x,
|
||||
flags,
|
||||
remove_y,
|
||||
removeCoord.y,
|
||||
rideIndex,
|
||||
GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT,
|
||||
station_num,
|
||||
stationNum,
|
||||
0
|
||||
);
|
||||
|
||||
if (success == MONEY32_UNDEFINED) {
|
||||
if (success == MONEY32_UNDEFINED)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
z = ride->station_heights[station_num] * 8;
|
||||
z = ride->station_heights[stationNum] * 8;
|
||||
gCommandPosition.z = z;
|
||||
|
||||
if (
|
||||
(flags & GAME_COMMAND_FLAG_APPLY) &&
|
||||
if ((flags & GAME_COMMAND_FLAG_APPLY) &&
|
||||
!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) &&
|
||||
!(flags & GAME_COMMAND_FLAG_GHOST)
|
||||
) {
|
||||
!(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
footpath_remove_litter(x, y, z);
|
||||
wall_remove_at_z(x, y, z);
|
||||
}
|
||||
|
||||
if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) {
|
||||
if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
sint8 clear_z = (z / 8) + (is_exit ? 5 : 7);
|
||||
sint8 clear_z = (z / 8) + (isExit ? 5 : 7);
|
||||
|
||||
if (!gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) {
|
||||
if (!gCheatsDisableClearanceChecks &&
|
||||
!map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) {
|
||||
if (gMapGroundFlags & ELEMENT_IS_UNDERWATER)
|
||||
{
|
||||
gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (z / 8 > 244){
|
||||
if (z / 8 > 244)
|
||||
{
|
||||
gGameCommandErrorText = STR_TOO_HIGH;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
rct_xyz16 coord;
|
||||
coord.x = x + 16;
|
||||
coord.y = y + 16;
|
||||
|
@ -379,29 +414,36 @@ static money32 place_ride_entrance_or_exit(sint16 x, sint16 y, sint16 z, uint8 d
|
|||
rct_map_element* mapElement = map_element_insert(x / 32, y / 32, z / 8, 0xF);
|
||||
assert(mapElement != NULL);
|
||||
mapElement->clearance_height = clear_z;
|
||||
mapElement->properties.entrance.type = is_exit;
|
||||
mapElement->properties.entrance.index = station_num << 4;
|
||||
mapElement->properties.entrance.type = isExit;
|
||||
mapElement->properties.entrance.index = stationNum << 4;
|
||||
mapElement->properties.entrance.ride_index = rideIndex;
|
||||
mapElement->type = MAP_ELEMENT_TYPE_ENTRANCE | direction;
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST) {
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
mapElement->flags |= MAP_ELEMENT_FLAG_GHOST;
|
||||
}
|
||||
|
||||
if (is_exit) {
|
||||
ride->exits[station_num] = (x / 32) | (y / 32 << 8);
|
||||
} else {
|
||||
ride->entrances[station_num] = (x / 32) | (y / 32 << 8);
|
||||
ride->last_peep_in_queue[station_num] = SPRITE_INDEX_NULL;
|
||||
ride->queue_length[station_num] = 0;
|
||||
if (isExit)
|
||||
{
|
||||
ride->exits[stationNum] = (x / 32) | (y / 32 << 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
ride->entrances[stationNum] = (x / 32) | (y / 32 << 8);
|
||||
ride->last_peep_in_queue[stationNum] = SPRITE_INDEX_NULL;
|
||||
ride->queue_length[stationNum] = 0;
|
||||
|
||||
map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, x, y, z / 8);
|
||||
}
|
||||
|
||||
footpath_queue_chain_reset();
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST)) {
|
||||
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
maze_entrance_hedge_removal(x, y, mapElement);
|
||||
}
|
||||
|
||||
footpath_connect_edges(x, y, mapElement, flags);
|
||||
sub_6A759F();
|
||||
|
||||
|
@ -413,12 +455,14 @@ static money32 place_ride_entrance_or_exit(sint16 x, sint16 y, sint16 z, uint8 d
|
|||
return cost;
|
||||
}
|
||||
|
||||
static money32 remove_ride_entrance_or_exit(sint16 x, sint16 y, uint8 rideIndex, uint8 station_num, uint8 flags){
|
||||
static money32 remove_ride_entrance_or_exit(sint16 x, sint16 y, uint8 rideIndex, uint8 stationNum, uint8 flags)
|
||||
{
|
||||
if (rideIndex >= MAX_RIDES)
|
||||
{
|
||||
log_warning("Invalid game command for ride %u", rideIndex);
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
rct_ride* ride = get_ride(rideIndex);
|
||||
if (ride->type == RIDE_TYPE_NULL)
|
||||
{
|
||||
|
@ -426,50 +470,61 @@ static money32 remove_ride_entrance_or_exit(sint16 x, sint16 y, uint8 rideIndex,
|
|||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST)){
|
||||
if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode){
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) &&
|
||||
game_is_paused() &&
|
||||
!gCheatsBuildInPauseMode)
|
||||
{
|
||||
gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
if (ride->status != RIDE_STATUS_CLOSED){
|
||||
if (ride->status != RIDE_STATUS_CLOSED)
|
||||
{
|
||||
gGameCommandErrorText = STR_MUST_BE_CLOSED_FIRST;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) {
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK)
|
||||
{
|
||||
gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY){
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
ride_clear_for_construction(rideIndex);
|
||||
ride_remove_peeps(rideIndex);
|
||||
invalidate_test_results(rideIndex);
|
||||
|
||||
uint8 found = 0;
|
||||
bool found = false;
|
||||
rct_map_element* mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||
if (mapElement == NULL)
|
||||
{
|
||||
log_warning("Invalid coordinates for entrance/exit removal x = %d, y = %d", x, y);
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
do{
|
||||
|
||||
do
|
||||
{
|
||||
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (mapElement->base_height != ride->station_heights[station_num])
|
||||
if (mapElement->base_height != ride->station_heights[stationNum])
|
||||
continue;
|
||||
|
||||
if (flags & (1 << 5) && !(mapElement->flags & MAP_ELEMENT_FLAG_GHOST))
|
||||
continue;
|
||||
|
||||
found = 1;
|
||||
found = true;
|
||||
break;
|
||||
} while (!map_element_is_last_for_tile(mapElement++));
|
||||
}
|
||||
while (!map_element_is_last_for_tile(mapElement++));
|
||||
|
||||
if (!found){
|
||||
if (!found)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
|
@ -483,15 +538,17 @@ static money32 remove_ride_entrance_or_exit(sint16 x, sint16 y, uint8 rideIndex,
|
|||
maze_entrance_hedge_replacement(x, y, mapElement);
|
||||
footpath_remove_edges_at(x, y, mapElement);
|
||||
|
||||
uint8 is_exit = mapElement->properties.entrance.type;
|
||||
bool isExit = mapElement->properties.entrance.type == ENTRANCE_TYPE_RIDE_EXIT;
|
||||
|
||||
map_element_remove(mapElement);
|
||||
|
||||
if (is_exit){
|
||||
ride->exits[station_num] = 0xFFFF;
|
||||
if (isExit)
|
||||
{
|
||||
ride->exits[stationNum] = 0xFFFF;
|
||||
}
|
||||
else{
|
||||
ride->entrances[station_num] = 0xFFFF;
|
||||
else
|
||||
{
|
||||
ride->entrances[stationNum] = 0xFFFF;
|
||||
}
|
||||
|
||||
sub_6A759F();
|
||||
|
@ -507,7 +564,11 @@ money32 ride_entrance_exit_place_ghost(uint8 rideIndex, sint16 x, sint16 y, uint
|
|||
{
|
||||
return game_do_command(
|
||||
x,
|
||||
(GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST) | (direction << 8),
|
||||
(GAME_COMMAND_FLAG_APPLY |
|
||||
GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED |
|
||||
GAME_COMMAND_FLAG_5 |
|
||||
GAME_COMMAND_FLAG_GHOST) |
|
||||
(direction << 8),
|
||||
y,
|
||||
rideIndex | (placeType << 8),
|
||||
GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT,
|
||||
|
@ -671,25 +732,39 @@ extern "C"
|
|||
*
|
||||
* rct2: 0x006CA28C
|
||||
*/
|
||||
money32 ride_get_entrance_or_exit_price(sint32 rideIndex, sint32 x, sint32 y, sint32 direction, sint32 dh, sint32 di)
|
||||
money32 ride_get_entrance_or_exit_price(sint32 rideIndex,
|
||||
sint32 x,
|
||||
sint32 y,
|
||||
sint32 direction,
|
||||
sint32 placeType,
|
||||
sint32 stationNum)
|
||||
{
|
||||
sub_6C96C0();
|
||||
money32 result = ride_entrance_exit_place_ghost(rideIndex, x, y, direction, dh, di);
|
||||
if (result != MONEY32_UNDEFINED) {
|
||||
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT;
|
||||
gRideEntranceExitGhostPosition.x = x;
|
||||
gRideEntranceExitGhostPosition.y = y;
|
||||
gRideEntranceExitGhostPosition.direction = direction;
|
||||
gRideEntranceExitGhostStationIndex = di & 0xFF;
|
||||
}
|
||||
return result;
|
||||
sub_6C96C0();
|
||||
money32 result = ride_entrance_exit_place_ghost(rideIndex, x, y, direction, placeType, stationNum);
|
||||
|
||||
if (result != MONEY32_UNDEFINED)
|
||||
{
|
||||
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT;
|
||||
gRideEntranceExitGhostPosition.x = x;
|
||||
gRideEntranceExitGhostPosition.y = y;
|
||||
gRideEntranceExitGhostPosition.direction = direction;
|
||||
gRideEntranceExitGhostStationIndex = stationNum & 0xFF;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006660A8
|
||||
*/
|
||||
void game_command_place_ride_entrance_or_exit(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp){
|
||||
void game_command_place_ride_entrance_or_exit(sint32 *eax,
|
||||
sint32 *ebx,
|
||||
sint32 *ecx,
|
||||
sint32 *edx,
|
||||
sint32 *esi,
|
||||
sint32 *edi,
|
||||
sint32 *ebp)
|
||||
{
|
||||
*ebx = place_ride_entrance_or_exit(
|
||||
*eax & 0xFFFF,
|
||||
*ecx & 0xFFFF,
|
||||
|
@ -706,14 +781,21 @@ extern "C"
|
|||
*
|
||||
* rct2: 0x0066640B
|
||||
*/
|
||||
void game_command_remove_ride_entrance_or_exit(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp){
|
||||
void game_command_remove_ride_entrance_or_exit(sint32 *eax,
|
||||
sint32 *ebx,
|
||||
sint32 *ecx,
|
||||
sint32 *edx,
|
||||
sint32 *esi,
|
||||
sint32 *edi,
|
||||
sint32 *ebp)
|
||||
{
|
||||
*ebx = remove_ride_entrance_or_exit(
|
||||
*eax & 0xFFFF,
|
||||
*ecx & 0xFFFF,
|
||||
*edx & 0xFF,
|
||||
*edi & 0xFF,
|
||||
*ebx & 0xFF
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue