1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 13:03:11 +01:00

partially fix #2181

create common function
This commit is contained in:
Flukiestemperor
2015-11-03 14:38:42 -06:00
parent 025f36ec28
commit c8701ef01e
4 changed files with 54 additions and 8 deletions

View File

@@ -67,6 +67,7 @@ GAME_COMMAND_CALLBACK_POINTER* game_command_callback_table[] = {
game_command_callback_ride_construct_new,
game_command_callback_ride_construct_placed_front,
game_command_callback_ride_construct_placed_back,
game_command_callback_ride_remove_track_piece,
};
int game_command_callback_get_index(GAME_COMMAND_CALLBACK_POINTER* callback)

View File

@@ -128,6 +128,7 @@ static const int RideInspectionInterval[] = {
rct_ride_type **gRideTypeList = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_type*);
rct_ride* g_ride_list = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride);
bool gGotoStartPlacementMode = false;
// Static function declarations
rct_peep *find_closest_mechanic(int x, int y, int forInspection);
@@ -5536,6 +5537,28 @@ void game_command_callback_ride_construct_placed_front(int eax, int ebx, int ecx
sub_6C84CE();
}
/**
*
* Network client callback when removing ride pieces
* Client does execute placing the piece on the same tick as mouse_up - waits for server command
* Re-executes function from ride_construction - window_ride_construction_mouseup_demolish()
* Only uses part that deals with construction state
*/
void game_command_callback_ride_remove_track_piece(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp)
{
int x, y, z, direction, type;
rct_xy_element outputElement;
x = _currentTrackBeginX;
y = _currentTrackBeginY;
z = _currentTrackBeginZ;
direction = _currentTrackPieceDirection;
type = _currentTrackPieceType;
window_ride_construction_mouseup_demolish_next_piece(x, y, z, direction, type, outputElement);
}
/**
*
* rct2: 0x006B49D9
@@ -6287,6 +6310,10 @@ bool ride_select_forwards_from_back()
money32 ride_remove_track_piece(int x, int y, int z, int direction, int type)
{
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS;
if (network_get_mode() == NETWORK_MODE_CLIENT)
{
game_command_callback = game_command_callback_ride_remove_track_piece;
}
return game_do_command(x, (GAME_COMMAND_FLAG_APPLY) | ((direction & 3) << 8), y, type, GAME_COMMAND_REMOVE_TRACK, z, 0);
}

View File

@@ -876,6 +876,8 @@ extern const uint8 gRideClassifications[255];
#define _currentSeatRotationAngle RCT2_GLOBAL(0x00F440CF, uint8)
extern bool gGotoStartPlacementMode;
int ride_get_count();
int ride_get_total_queue_length(rct_ride *ride);
int ride_get_max_queue_time(rct_ride *ride);
@@ -929,6 +931,7 @@ void game_command_create_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi,
void game_command_callback_ride_construct_new(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
void game_command_callback_ride_construct_placed_front(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
void game_command_callback_ride_construct_placed_back(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
void game_command_callback_ride_remove_track_piece(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
void game_command_demolish_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
void game_command_set_ride_appearance(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
void game_command_set_ride_price(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
@@ -1009,4 +1012,6 @@ bool shop_item_is_souvenir(int shopItem);
void ride_reset_all_names();
const uint8* ride_seek_available_modes(rct_ride *ride);
void window_ride_construction_mouseup_demolish_next_piece(int x, int y, int z, int direction, int type, rct_xy_element outputElement);
#endif

View File

@@ -1670,11 +1670,11 @@ static void window_ride_construction_construct(rct_window *w)
*/
static void window_ride_construction_mouseup_demolish(rct_window* w)
{
int x, y, z, direction, type, slope, slopeEnd, b2, bankEnd, bankStart, b5, b4;
int x, y, z, direction, type;
rct_map_element *mapElement;
rct_xy_element inputElement, outputElement;
track_begin_end trackBeginEnd;
bool gotoStartPlacementMode;
//bool gotoStartPlacementMode;
_currentTrackPrice = MONEY32_UNDEFINED;
sub_6C9627();
@@ -1716,14 +1716,14 @@ static void window_ride_construction_mouseup_demolish(rct_window* w)
z = trackBeginEnd.begin_z;
direction = trackBeginEnd.begin_direction;
type = trackBeginEnd.begin_element->properties.track.type;
gotoStartPlacementMode = false;
gGotoStartPlacementMode = false;
}
else if (track_block_get_next(&inputElement, &outputElement, &z, &direction)) {
x = outputElement.x;
y = outputElement.y;
direction = outputElement.element->type & MAP_ELEMENT_DIRECTION_MASK;
type = outputElement.element->properties.track.type;
gotoStartPlacementMode = false;
gGotoStartPlacementMode = false;
} else {
x = _currentTrackBeginX;
y = _currentTrackBeginY;
@@ -1738,7 +1738,7 @@ static void window_ride_construction_mouseup_demolish(rct_window* w)
const rct_preview_track *trackBlock = get_track_def_from_ride_index(_currentRideIndex, mapElement->properties.track.type);
z = (mapElement->base_height * 8) - trackBlock->z;
gotoStartPlacementMode = true;
gGotoStartPlacementMode = true;
}
money32 cost = ride_remove_track_piece(
@@ -1753,7 +1753,13 @@ static void window_ride_construction_mouseup_demolish(rct_window* w)
return;
}
if (gotoStartPlacementMode) {
window_ride_construction_mouseup_demolish_next_piece(x, y, z, direction, type, outputElement);
}
void window_ride_construction_mouseup_demolish_next_piece(int x, int y, int z, int direction, int type, rct_xy_element outputElement)
{
int slope, slopeEnd, b2, bankEnd, bankStart, b5, b4;
if (gGotoStartPlacementMode) {
z &= 0xFFF0;
_currentTrackBeginZ = z;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_FRONT;
@@ -1783,7 +1789,8 @@ static void window_ride_construction_mouseup_demolish(rct_window* w)
sub_6C84CE();
}
}
} else {
}
else {
if (RCT2_GLOBAL(0x00F440B8, uint8) == 3 || RCT2_GLOBAL(0x00F440B8, uint8) == 1) {
if (type == TRACK_ELEM_MIDDLE_STATION || type == TRACK_ELEM_BEGIN_STATION) {
type = TRACK_ELEM_END_STATION;
@@ -1794,6 +1801,11 @@ static void window_ride_construction_mouseup_demolish(rct_window* w)
type = TRACK_ELEM_BEGIN_STATION;
}
}
if (network_get_mode() == NETWORK_MODE_CLIENT)
{
// rideConstructionState needs to be set again to the proper value, this only affects the client
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
}
_currentTrackBeginX = x;
_currentTrackBeginY = y;
_currentTrackBeginZ = z;
@@ -1803,7 +1815,8 @@ static void window_ride_construction_mouseup_demolish(rct_window* w)
_rideConstructionArrowPulseTime = 0;
if (RCT2_GLOBAL(0x00F440B8, uint8) == 1) {
ride_select_next_section();
} else if (RCT2_GLOBAL(0x00F440B8, uint8) == 2) {
}
else if (RCT2_GLOBAL(0x00F440B8, uint8) == 2) {
ride_select_previous_section();
}
sub_6C84CE();