Merge pull request #649 from duncanspumpkin/ride_construct

Ride construct
This commit is contained in:
Ted John 2014-12-20 13:17:36 +00:00
commit d53085c7d6
4 changed files with 104 additions and 14 deletions

View File

@ -470,10 +470,15 @@ void window_close(rct_window* window)
if (window == NULL)
return;
// Make a copy of the window class and number incase
// the window order is changed by the close event.
rct_windowclass cls = window->classification;
rct_windownumber number = window->number;
// Call close event of window
RCT2_CALLPROC_X(window->event_handlers[WE_CLOSE], 0, 0, 0, 0, (int)window, 0, 0);
window = window_find_by_number(window->classification, window->number);
window = window_find_by_number(cls, number);
// Remove viewport
if (window->viewport != NULL) {

View File

@ -481,7 +481,7 @@ static rct_window *ride_create_or_find_construction_window(int rideIndex)
RCT2_GLOBAL(0x00F440A7, uint8) = rideIndex;
w = window_construction_open(rideIndex);
} else {
RCT2_CALLPROC_X(0x006C9627, 0, 0, 0, 0, 0, 0, 0);
sub_6C9627();
RCT2_GLOBAL(0x00F440A7, uint8) = rideIndex;
}
@ -702,9 +702,10 @@ static void ride_remove_peeps(int rideIndex)
ride->var_14D |= 4;
}
void sub_6C683D(int x, int y, int z, int direction, int type, int esi, int edi, int ebp)
int sub_6C683D(int* x, int* y, int z, int direction, int type, int esi, int edi, int ebp)
{
RCT2_CALLPROC_X(0x006C683D, x, (direction << 8) | type, y, z, esi, edi, ebp);
int ebx = (direction << 8) | type;
return RCT2_CALLFUNC_X(0x006C683D, x, &ebx, y, &z, &esi, &edi, &ebp)&0x100;
}
void sub_6C96C0()
@ -712,20 +713,23 @@ void sub_6C96C0()
RCT2_CALLPROC_X(0x006C96C0, 0, 0, 0, 0, 0, 0, 0);
}
static void sub_6C9627()
void sub_6C9627()
{
switch (RCT2_GLOBAL(0x00F440A6, uint8)) {
case 3:
{
int x = RCT2_GLOBAL(0x00F440A8, uint16), y = RCT2_GLOBAL(0x00F440AA, uint16);
sub_6C683D(
RCT2_GLOBAL(0x00F440A8, uint16),
RCT2_GLOBAL(0x00F440AA, uint16),
&x,
&y,
RCT2_GLOBAL(0x00F440AC, uint16),
RCT2_GLOBAL(0x00F440AE, uint8) & 3,
RCT2_GLOBAL(0x00F440AF, uint8),
0,
0,
1
);
);
}
break;
case 6:
case 7:
@ -893,7 +897,8 @@ int ride_modify(rct_map_element *mapElement, int x, int y)
z = mapElement->base_height * 8;
direction = mapElement->type & 3;
type = mapElement->properties.track.type;
sub_6C683D(x, y, z, direction, type, 0, 0, 0);
if (sub_6C683D(&x, &y, z, direction, type, 0, 0, 0)) return 0;
RCT2_GLOBAL(0x00F440A7, uint8) = rideIndex;
RCT2_GLOBAL(0x00F440A6, uint8) = 3;
@ -905,7 +910,7 @@ int ride_modify(rct_map_element *mapElement, int x, int y)
RCT2_GLOBAL(0x00F440B0, uint8) = 0;
RCT2_GLOBAL(0x00F440B1, uint8) = 0;
if (RCT2_GLOBAL(0x0097CF40 + (ride->type * 8), uint32) & 0x8000) {
if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint64)[ride->type] & 0x8000) {
sub_6C84CE();
return 1;
}

View File

@ -628,6 +628,8 @@ rct_ride_measurement *ride_get_measurement(int rideIndex, rct_string_id *message
void ride_breakdown_add_news_item(int rideIndex);
rct_peep *ride_find_closest_mechanic(rct_ride *ride, int forInspection);
int sub_6CC3FB(int rideIndex);
void sub_6C9627();
int sub_6C683D(int* x, int* y, int z, int direction, int type, int esi, int edi, int ebp);
void ride_set_map_tooltip(rct_map_element *mapElement);
int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint16 sampleRate, uint32 position, uint8 *tuneId);
void ride_music_update_final();

View File

@ -35,8 +35,18 @@ void sub_6b2fa9(rct_windownumber number){
}
}
enum {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_PAGE_BACKGROUND,
WIDX_DEMOLISH = 24
};
void window_construction_emptysub(){}
void window_construction_close();
void window_construction_mouseup();
void window_construction_maze_close();
@ -75,7 +85,7 @@ static void* window_construction_maze_events[] = {
//0x993EEC
static void* window_construction_events[] = {
window_construction_close,
(void*)0x6C6E14,
window_construction_mouseup,
(void*)0x6C7934,
(void*)0x6C6E6A,
(void*)0x6C78CD,
@ -193,7 +203,7 @@ void window_construction_close(){
window_get_register(w);
RCT2_CALLPROC_X(0x006C9627, 0, 0, 0, 0, 0, 0, 0);
sub_6C9627();
viewport_set_visibility(0);
map_invalidate_map_selection_tiles();
@ -224,7 +234,7 @@ void window_construction_maze_close(){
window_get_register(w);
RCT2_CALLPROC_X(0x006C9627, 0, 0, 0, 0, 0, 0, 0);
sub_6C9627();
viewport_set_visibility(0);
map_invalidate_map_selection_tiles();
@ -247,4 +257,72 @@ void window_construction_maze_close(){
}
window_ride_main_open(ride_id);
}
}
void window_construction_mouseup_demolish(rct_window* w);
/* rct2: 0x006C6E14 */
void window_construction_mouseup(){
short widgetIndex;
rct_window *w;
window_widget_get_registers(w, widgetIndex);
RCT2_CALLPROC_X(0x6C6A77, 0, 0, 0, 0, 0, 0, 0);
switch (widgetIndex){
case WIDX_CLOSE:
window_close(w);
break;
case 27:
RCT2_CALLPROC_X(0x6C9296, 0, 0, 0, widgetIndex, (int)w, 0, 0);
break;
case 26:
RCT2_CALLPROC_X(0x6C93B8, 0, 0, 0, widgetIndex, (int)w, 0, 0);
break;
case 23:
RCT2_CALLPROC_X(0x6C9F72, 0, 0, 0, widgetIndex, (int)w, 0, 0);
break;
case WIDX_DEMOLISH:
window_construction_mouseup_demolish(w);
break;
case 32:
RCT2_CALLPROC_X(0x6C78AA, 0, 0, 0, widgetIndex, (int)w, 0, 0);
break;
case 29:
RCT2_CALLPROC_X(0x6C7802, 0, 0, 0, widgetIndex, (int)w, 0, 0);
break;
case 30:
RCT2_CALLPROC_X(0x6C7866, 0, 0, 0, widgetIndex, (int)w, 0, 0);
break;
}
}
/* rct2: 0x006C9BA5 */
void window_construction_mouseup_demolish(rct_window* w){
RCT2_CALLPROC_X(0x6C9BA5, 0, 0, 0, 0, (int)w, 0, 0);
return;
RCT2_GLOBAL(0xF44070, uint32) = 0x80000000;
sub_6C9627();
RCT2_GLOBAL(0xF440B8, uint8) = 3;
if (RCT2_GLOBAL(0xF440A6, uint8) == 1){
//6C9C4F
}
if (RCT2_GLOBAL(0xF440A6, uint8) != 2){
//6c9cc4
int eax = RCT2_GLOBAL(0xF440A8, uint16),
ebx = RCT2_GLOBAL(0xF440AF, uint8) || (RCT2_GLOBAL(0xF440AE, uint8) << 8),
ecx = RCT2_GLOBAL(0xF440AA, uint16),
edx = RCT2_GLOBAL(0xF440AC, uint16);
sub_6C683D(&eax, &ecx, edx, RCT2_GLOBAL(0xF440AE, uint8), RCT2_GLOBAL(0xF440AF, uint8) & 0x3FF, 0, 0, 0);
}
int ride_id = RCT2_GLOBAL(0xF440A7, uint8);
RCT2_GLOBAL(0xF441D2, uint8) = ride_id;
//6c9BFE
}