/**
 *
 *  rct2: 0x006CD811
 */
static void window_maze_construction_close(rct_window *w)
{
    ride_construction_invalidate_current_track();
    viewport_set_visibility(0);

    map_invalidate_map_selection_tiles();
    gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;

    // In order to cancel the yellow arrow correctly the
    // selection tool should be cancelled.
    tool_cancel();

    hide_gridlines();

    uint8 rideIndex = _currentRideIndex;
    rct_ride* ride = get_ride(rideIndex);
    if (ride->overall_view.xy == RCT_XY8_UNDEFINED) {
        sint32 savedPausedState = gGamePaused;
        gGamePaused = 0;
        game_do_command(0, GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED, 0, rideIndex, GAME_COMMAND_DEMOLISH_RIDE, 0, 0);
        gGamePaused = savedPausedState;
    } else {
        window_ride_main_open(rideIndex);
    }
}
Beispiel #2
0
void window_construction_maze_close(){
	rct_window *w;

	window_get_register(w);

	sub_6C9627();
	viewport_set_visibility(0);

	map_invalidate_map_selection_tiles();
	RCT2_GLOBAL(0x9DE58A, uint16) &= 0xFFFD;

	hide_gridlines();
	
	uint8 ride_id = RCT2_GLOBAL(0xF440A7, uint8);

	rct_ride* ride = GET_RIDE(ride_id);

	if (ride->overall_view == 0xFFFF){
		int eax = RCT2_GLOBAL(0x009DEA6E, uint8);

		RCT2_GLOBAL(0x009DEA6E, uint8) = 0;
		game_do_command(0, 9, 0, ride_id, GAME_COMMAND_7, 0, 0);

		RCT2_GLOBAL(0x009DEA6E, uint8) = eax;
		return;
	}

	window_ride_main_open(ride_id);
}
Beispiel #3
0
void window_construction_close(){
	rct_window *w;

	window_get_register(w);

	sub_6C9627();
	viewport_set_visibility(0);

	map_invalidate_map_selection_tiles();
	RCT2_GLOBAL(0x9DE58A, uint16) &= 0xFFFD;

	hide_gridlines();

	int x, y;
	uint8 ride_id = RCT2_GLOBAL(0xF440A7, uint8);
	rct_map_element* map_element = sub_6CAF80(ride_id, &x, &y);

	if ((int)map_element == -1){
		int eax = RCT2_GLOBAL(0x009DEA6E, uint8);

		RCT2_GLOBAL(0x009DEA6E, uint8) = 0;
		game_do_command(0, 9, 0, ride_id, GAME_COMMAND_7, 0, 0);

		RCT2_GLOBAL(0x009DEA6E, uint8) = eax;
		return;
	}

	window_ride_main_open(ride_id);
}
/**
 *
 *  rct2: 0x006CFF2D
 */
static void window_track_place_toolupdate(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y)
{
    sint16 mapX, mapY, mapZ;

    map_invalidate_map_selection_tiles();
    gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
    gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
    gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;

    // Get the tool map position
    sub_68A15E(x, y, &mapX, &mapY, nullptr, nullptr);
    if (mapX == LOCATION_NULL) {
        window_track_place_clear_provisional();
        return;
    }

    // Check if tool map position has changed since last update
    if (mapX == _window_track_place_last_x && mapY == _window_track_place_last_y) {
        place_virtual_track(_trackDesign, PTD_OPERATION_DRAW_OUTLINES, true, 0, mapX, mapY, 0);
        return;
    }

    money32 cost = MONEY32_UNDEFINED;

    // Get base Z position
    mapZ = window_track_place_get_base_z(mapX, mapY);
    if (game_is_not_paused() || gCheatsBuildInPauseMode) {
        window_track_place_clear_provisional();

        // Try increasing Z until a feasible placement is found
        for (sint32 i = 0; i < 7; i++) {
            uint8 rideIndex;
            window_track_place_attempt_placement(_trackDesign, mapX, mapY, mapZ, 105, &cost, &rideIndex);
            if (cost != MONEY32_UNDEFINED) {
                _window_track_place_ride_index = rideIndex;
                _window_track_place_last_valid_x = mapX;
                _window_track_place_last_valid_y = mapY;
                _window_track_place_last_valid_z = mapZ;
                _window_track_place_last_was_valid = true;
                break;
            }
            mapZ += 8;
        }
    }

    _window_track_place_last_x = mapX;
    _window_track_place_last_y = mapY;
    if (cost != _window_track_place_last_cost) {
        _window_track_place_last_cost = cost;
        widget_invalidate(w, WIDX_PRICE);
    }

    place_virtual_track(_trackDesign, PTD_OPERATION_DRAW_OUTLINES, true, 0, mapX, mapY, mapZ);
}
/**
 *
 *  rct2: 0x006CFF34
 */
static void window_track_place_tooldown(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y)
{
    sint32 i;
    sint16 mapX, mapY, mapZ;
    money32 cost;
    uint8 rideIndex;

    window_track_place_clear_provisional();
    map_invalidate_map_selection_tiles();
    gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
    gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
    gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;

    sub_68A15E(x, y, &mapX, &mapY, nullptr, nullptr);
    if (mapX == LOCATION_NULL)
        return;

    // Try increasing Z until a feasible placement is found
    mapZ = window_track_place_get_base_z(mapX, mapY);
    for (i = 0; i < 7; i++) {
        gDisableErrorWindowSound = true;
        window_track_place_attempt_placement(_trackDesign, mapX, mapY, mapZ, 1, &cost, &rideIndex);
        gDisableErrorWindowSound = false;

        if (cost != MONEY32_UNDEFINED) {
            window_close_by_class(WC_ERROR);
            audio_play_sound_at_location(SOUND_PLACE_ITEM, mapX, mapY, mapZ);

            _currentRideIndex = rideIndex;
            if (track_design_are_entrance_and_exit_placed()) {
                auto intent = Intent(WC_RIDE);
                intent.putExtra(INTENT_EXTRA_RIDE_ID, rideIndex);
                context_open_intent(&intent);
                window_close(w);
            } else {
                ride_initialise_construction_window(rideIndex);
                w = window_find_by_class(WC_RIDE_CONSTRUCTION);
                window_event_mouse_up_call(w, WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE);
            }
            return;
        }

        // Check if player did not have enough funds
        if (gGameCommandErrorText == STR_NOT_ENOUGH_CASH_REQUIRES)
            break;

        mapZ += 8;
    }

    // Unable to build track
    audio_play_sound_at_location(SOUND_ERROR, mapX, mapY, mapZ);
}
/**
 *
 *  rct2: 0x006D0119
 */
static void window_track_place_close(rct_window *w)
{
    window_track_place_clear_provisional();
    viewport_set_visibility(0);
    map_invalidate_map_selection_tiles();
    gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
    gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
    hide_gridlines();
    _window_track_place_mini_preview.clear();
    _window_track_place_mini_preview.shrink_to_fit();
    track_design_dispose(_trackDesign);
    _trackDesign = nullptr;
}