implement ride_crash with hook

This commit is contained in:
IntelOrca 2015-07-10 20:29:50 +01:00
parent 8c4b82cade
commit 25cad9d9f1
4 changed files with 33 additions and 16 deletions

View File

@ -842,6 +842,7 @@ enum {
STR_CONTINUE_SAVED_GAME_TIP = 1922,
STR_SHOW_TUTORIAL_TIP = 1923,
STR_EXIT = 1924,
STR_RIDE_HAS_CRASHED = 1928,
STR_SHOW_SUBJECT_TIP = 1937,

View File

@ -32,6 +32,7 @@
#include "network/http.h"
#include "openrct2.h"
#include "platform/platform.h"
#include "ride/ride.h"
#include "util/sawyercoding.h"
#include "world/mapgen.h"
#include "title.h"
@ -189,6 +190,7 @@ bool openrct2_initialise()
// Hooks to allow RCT2 to call OpenRCT2 functions instead
addhook(0x006E732D, (int)gfx_set_dirty_blocks, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0); // remove after all drawing is decompiled
addhook(0x006E7499, (int)gfx_redraw_screen_rect, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0); // remove when 0x6E7FF3 is decompiled
addhook(0x006B752C, (int)ride_crash, 0, (int[]){ EDX, EBX, END }, 0); // remove when callers are decompiled
if (!rct2_init())
return false;

View File

@ -1707,17 +1707,6 @@ static void ride_update(int rideIndex)
ride_inspection_update(ride);
// Used to bring up the "real" ride window after a crash. Can be removed once vehicle_update is decompiled
if (ride->lifecycle_flags & RIDE_LIFECYCLE_CRASHED) {
if ((ride->lifecycle_flags & RIDE_LIFECYCLE_CRASHED_WINDOW_OPENED) == 0) {
ride->lifecycle_flags |= RIDE_LIFECYCLE_CRASHED_WINDOW_OPENED;
window_ride_main_open(rideIndex);
}
}
else if (ride->lifecycle_flags & RIDE_LIFECYCLE_CRASHED_WINDOW_OPENED) {
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_CRASHED_WINDOW_OPENED;
}
if (ride->status == RIDE_STATUS_TESTING && gConfigGeneral.no_test_crashes) {
for (int i = 0; i < ride->num_vehicles; i++) {
rct_vehicle *vehicle = &(g_sprite_list[ride->vehicles[i]].vehicle);
@ -6003,4 +5992,31 @@ void game_command_remove_ride_entrance_or_exit(int *eax, int *ebx, int *ecx, int
*edi & 0xFF,
*ebx & 0xFF
);
}
}
/**
*
* rct2: 0x006B752C
*/
void ride_crash(int rideIndex, int vehicleIndex)
{
rct_ride *ride;
rct_vehicle *vehicle;
rct_window *w;
// TODO Remove these when hook is no longer used
rideIndex &= 0xFF;
vehicleIndex &= 0xFF;
ride = GET_RIDE(rideIndex);
vehicle = &(g_sprite_list[ride->vehicles[vehicleIndex]]).vehicle;
w = window_ride_open_vehicle(vehicle);
if (w->viewport != NULL) {
w->viewport->flags |= VIEWPORT_FLAG_SOUND_ON;
}
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, rct_string_id) = ride->name;
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = ride->name_arguments;
news_item_add_to_queue(NEWS_ITEM_RIDE, STR_RIDE_HAS_CRASHED, rideIndex);
}

View File

@ -387,10 +387,7 @@ enum {
RIDE_LIFECYCLE_16 = 1 << 16,
RIDE_LIFECYCLE_CABLE_LIFT = 1 << 17,
RIDE_LIFECYCLE_18 = 1 << 18,
RIDE_LIFECYCLE_SIX_FLAGS = 1 << 19,
// Used to bring up the "real" ride window after a crash. Can be removed once vehicle_update is decompiled
RIDE_LIFECYCLE_CRASHED_WINDOW_OPENED = 1 << 20
RIDE_LIFECYCLE_SIX_FLAGS = 1 << 19
};
// Constants used by the ride_type->flags property at 0x008
@ -960,5 +957,6 @@ void game_command_place_ride_entrance_or_exit(int *eax, int *ebx, int *ecx, int
void game_command_remove_ride_entrance_or_exit(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
void sub_6CB945(int rideIndex);
void ride_crash(int rideIndex, int vehicleIndex);
#endif