mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
fix setting brakes speed on current track and implement game command
This commit is contained in:
@@ -934,7 +934,7 @@ static uint32 game_do_command_table[58] = {
|
||||
0x0068BC01,
|
||||
0,
|
||||
0,
|
||||
0x006C5AE9,
|
||||
0,
|
||||
0, // use new_game_command_table, original: 0x006BEFA1, 29
|
||||
0, // 30
|
||||
0,
|
||||
@@ -997,7 +997,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = {
|
||||
game_command_emptysub,
|
||||
game_command_raise_water,
|
||||
game_command_lower_water,
|
||||
game_command_emptysub,
|
||||
game_command_set_brakes_speed,
|
||||
game_command_hire_new_staff_member, //game_command_emptysub,
|
||||
game_command_set_staff_patrol, // 30
|
||||
game_command_fire_staff_member,
|
||||
|
||||
@@ -52,7 +52,7 @@ enum GAME_COMMAND {
|
||||
GAME_COMMAND_EDIT_LAND_SMOOTH,
|
||||
GAME_COMMAND_RAISE_WATER,
|
||||
GAME_COMMAND_LOWER_WATER,
|
||||
GAME_COMMAND_28,
|
||||
GAME_COMMAND_SET_BRAKES_SPEED,
|
||||
GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, // 29
|
||||
GAME_COMMAND_SET_STAFF_PATROL, //30
|
||||
GAME_COMMAND_FIRE_STAFF_MEMBER, // 31
|
||||
|
||||
@@ -3458,4 +3458,48 @@ void game_command_place_track(int *eax, int *ebx, int *ecx, int *edx, int *esi,
|
||||
void game_command_remove_track(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp)
|
||||
{
|
||||
RCT2_CALLFUNC_X(0x006C5B69, eax, ebx, ecx, edx, esi, edi, ebp);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006C5AE9
|
||||
*/
|
||||
void game_command_set_brakes_speed(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp)
|
||||
{
|
||||
rct_map_element *mapElement;
|
||||
int x, y, z, trackType, brakesSpeed;
|
||||
|
||||
x = (*eax & 0xFFFF);
|
||||
y = (*ecx & 0xFFFF);
|
||||
z = (*edi & 0xFFFF);
|
||||
trackType = (*edx & 0xFF);
|
||||
brakesSpeed = ((*ebx >> 8) & 0xFF);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 0;
|
||||
RCT2_GLOBAL(0x009DEA5E, uint8) = x + 16;
|
||||
RCT2_GLOBAL(0x009DEA60, uint8) = y + 16;
|
||||
RCT2_GLOBAL(0x009DEA62, uint8) = z;
|
||||
|
||||
if (*ebx & GAME_COMMAND_FLAG_APPLY) {
|
||||
*ebx = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
do {
|
||||
if (mapElement->base_height * 8 != z)
|
||||
continue;
|
||||
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK)
|
||||
continue;
|
||||
if (mapElement->properties.track.type != trackType)
|
||||
continue;
|
||||
|
||||
mapElement->properties.track.sequence =
|
||||
(mapElement->properties.track.sequence & 0x0F) |
|
||||
((brakesSpeed >> 1) << 4);
|
||||
|
||||
break;
|
||||
} while (!map_element_is_last_for_tile(mapElement++));
|
||||
|
||||
*ebx = 0;
|
||||
}
|
||||
@@ -496,5 +496,6 @@ const rct_preview_track *get_track_def_from_ride_index(int rideIndex, int trackT
|
||||
|
||||
void game_command_place_track(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
void game_command_remove_track(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
void game_command_set_brakes_speed(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -548,6 +548,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc
|
||||
memcpy((void*)0x009B5F2C, &newsItem->colour, 256);
|
||||
x = w->x + (middleOutsetWidget->left + middleOutsetWidget->right) / 2;
|
||||
y = w->y + middleOutsetWidget->top + 11;
|
||||
width = middleOutsetWidget->right - middleOutsetWidget->left - 62;
|
||||
sub_6C1F57(dpi, x, y, width, 14, stringId, NULL, newsItem->ticks);
|
||||
|
||||
x = w->x + window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].left;
|
||||
|
||||
@@ -471,7 +471,7 @@ money32 sub_6CA162(int rideIndex, int trackType, int trackDirection, int edxRS16
|
||||
static void window_ride_construction_show_special_track_dropdown(rct_window *w, rct_widget *widget);
|
||||
static void ride_selected_track_set_seat_rotation(int seatRotation);
|
||||
static void loc_6C7502(int al);
|
||||
static void loc_6C76E9();
|
||||
static void ride_construction_set_brakes_speed(int brakesSpeed);
|
||||
|
||||
static void ride_construction_toolupdate_construct(int screenX, int screenY);
|
||||
static void ride_construction_toolupdate_entrance_exit(int screenX, int screenY);
|
||||
@@ -1442,18 +1442,18 @@ static void window_ride_construction_mousedown(int widgetIndex, rct_window *w, r
|
||||
_currentTrackPrice = MONEY32_UNDEFINED;
|
||||
sub_6C84CE();
|
||||
} else {
|
||||
uint8 *ebp = (uint8*)0x00F440CD;
|
||||
uint8 bl = 30;
|
||||
uint8 *brakesSpeedPtr = (uint8*)0x00F440CD;
|
||||
uint8 maxBrakesSpeed = 30;
|
||||
if (RCT2_GLOBAL(0x00F440D3, uint8) != 1) {
|
||||
ebp = (uint8*)0x00F440CE;
|
||||
bl = RCT2_GLOBAL(0x0097CF40 + 6 + (ride->type * 8), uint8);
|
||||
brakesSpeedPtr = (uint8*)0x00F440CE;
|
||||
maxBrakesSpeed = RCT2_GLOBAL(0x0097CF40 + 6 + (ride->type * 8), uint8);
|
||||
}
|
||||
uint8 bh = *ebp + 2;
|
||||
if (bh <= bl) {
|
||||
uint8 brakesSpeed = *brakesSpeedPtr + 2;
|
||||
if (brakesSpeed <= maxBrakesSpeed) {
|
||||
if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_SELECTED) {
|
||||
loc_6C76E9();
|
||||
ride_construction_set_brakes_speed(brakesSpeed);
|
||||
} else {
|
||||
*ebp = bh;
|
||||
*brakesSpeedPtr = brakesSpeed;
|
||||
sub_6C84CE();
|
||||
}
|
||||
}
|
||||
@@ -1466,16 +1466,16 @@ static void window_ride_construction_mousedown(int widgetIndex, rct_window *w, r
|
||||
_currentTrackPrice = MONEY32_UNDEFINED;
|
||||
sub_6C84CE();
|
||||
} else {
|
||||
uint8 *ebp = (uint8*)0x00F440CD;
|
||||
uint8 *brakesSpeedPtr = (uint8*)0x00F440CD;
|
||||
if (RCT2_GLOBAL(0x00F440D3, uint8) != 1) {
|
||||
ebp = (uint8*)0x00F440CE;
|
||||
brakesSpeedPtr = (uint8*)0x00F440CE;
|
||||
}
|
||||
uint8 bh = *ebp - 2;
|
||||
if (bh >= 2) {
|
||||
uint8 brakesSpeed = *brakesSpeedPtr - 2;
|
||||
if (brakesSpeed >= 2) {
|
||||
if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_SELECTED) {
|
||||
loc_6C76E9();
|
||||
ride_construction_set_brakes_speed(brakesSpeed);
|
||||
} else {
|
||||
*ebp = bh;
|
||||
*brakesSpeedPtr = brakesSpeed;
|
||||
sub_6C84CE();
|
||||
}
|
||||
}
|
||||
@@ -3172,7 +3172,7 @@ static void loc_6C7502(int al)
|
||||
*
|
||||
* rct2: 0x006C76E9
|
||||
*/
|
||||
static void loc_6C76E9()
|
||||
static void ride_construction_set_brakes_speed(int brakesSpeed)
|
||||
{
|
||||
rct_map_element *mapElement;
|
||||
int x, y, z;
|
||||
@@ -3180,13 +3180,13 @@ static void loc_6C76E9()
|
||||
x = _currentTrackBeginX;
|
||||
y = _currentTrackBeginY;
|
||||
z = _currentTrackBeginZ;
|
||||
if (sub_6C683D(&x, &y, &z, _currentTrackPieceDirection & 3, _currentTrackPieceType, 0, &mapElement, 0)) {
|
||||
if (!sub_6C683D(&x, &y, &z, _currentTrackPieceDirection & 3, _currentTrackPieceType, 0, &mapElement, 0)) {
|
||||
game_do_command(
|
||||
_currentTrackBeginX,
|
||||
GAME_COMMAND_FLAG_APPLY | ((_currentTrackPieceDirection & 3) << 8),
|
||||
GAME_COMMAND_FLAG_APPLY | ((brakesSpeed) << 8),
|
||||
_currentTrackBeginY,
|
||||
mapElement->properties.track.type,
|
||||
GAME_COMMAND_28,
|
||||
GAME_COMMAND_SET_BRAKES_SPEED,
|
||||
_currentTrackBeginZ,
|
||||
0
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user