diff --git a/src/platform/osinterface.h b/src/platform/osinterface.h index 22053526f5..557a16fb1c 100644 --- a/src/platform/osinterface.h +++ b/src/platform/osinterface.h @@ -94,6 +94,7 @@ HANDLE osinterface_file_open(const char* filename); int osinterface_file_read(HANDLE handle, void* data, int size); int osinterface_file_close(HANDLE handle); int osinterface_file_move(const char* srcfilename, const char* dstfilename); +int osinterface_file_delete(const char* filename); int osinterface_open_common_file_dialog(int type, char *title, char *filename, char *filterPattern, char *filterName); void osinterface_show_messagebox(char* message); diff --git a/src/ride/track.c b/src/ride/track.c index 57cf6f949d..7652f02836 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -1104,5 +1104,25 @@ int track_rename(const char *text) */ int track_delete() { - return (RCT2_CALLPROC_X(0x006D3761, 0, 0, 0, 0, 0, 0, 0) & 0x100) == 0; + rct_window* w = window_find_by_class(WC_TRACK_DESIGN_LIST); + + char path[MAX_PATH]; + subsitute_path(path, RCT2_ADDRESS(RCT2_ADDRESS_TRACKS_PATH, char), &RCT2_ADDRESS(RCT2_ADDRESS_TRACK_LIST, char)[128 * w->track_list.var_482]); + + if (osinterface_file_delete(path)){ + RCT2_GLOBAL(0x141E9AC, uint16) = 3355; + return 0; + } + + ride_list_item item = { 0xFC, 0 }; + track_load_list(item); + + item.type = RCT2_GLOBAL(0xF44158, uint8); + item.entry_index = RCT2_GLOBAL(0xF44159, uint8); + track_load_list(item); + + reset_track_list_cache(); + + window_invalidate(w); + return 1; }