void window_player_overview_paint(rct_window *w, rct_drawpixelinfo *dpi) { window_draw_widgets(w, dpi); window_player_draw_tab_images(dpi, w); sint32 player = network_get_player_index((uint8)w->number); if (player == -1) { return; } // Draw current group sint32 groupindex = network_get_group_index(network_get_player_group(player)); if (groupindex != -1) { rct_widget* widget = &window_player_overview_widgets[WIDX_GROUP]; char buffer[300]; char* lineCh; lineCh = buffer; lineCh = utf8_write_codepoint(lineCh, FORMAT_WINDOW_COLOUR_2); safe_strcpy(lineCh, network_get_group_name(groupindex), sizeof(buffer) - (lineCh - buffer)); set_format_arg(0, const char *, buffer); gfx_draw_string_centred_clipped( dpi, STR_STRING, gCommonFormatArgs, COLOUR_BLACK, w->x + (widget->left + widget->right - 11) / 2, w->y + widget->top, widget->right - widget->left - 8 ); }
static void window_player_overview_show_group_dropdown(rct_window *w, rct_widget *widget) { rct_widget *dropdownWidget; sint32 numItems, i; sint32 player = network_get_player_index((uint8)w->number); if (player == -1) { return; } dropdownWidget = widget - 1; numItems = network_get_num_groups(); window_dropdown_show_text_custom_width( w->x + dropdownWidget->left, w->y + dropdownWidget->top, dropdownWidget->bottom - dropdownWidget->top + 1, w->colours[1], 0, 0, numItems, widget->right - dropdownWidget->left ); for (i = 0; i < network_get_num_groups(); i++) { gDropdownItemsFormat[i] = STR_OPTIONS_DROPDOWN_ITEM; gDropdownItemsArgs[i] = (uintptr_t)network_get_group_name(i); } dropdown_set_checked(network_get_group_index(network_get_player_group(player)), true); }
void window_player_overview_mouse_up(rct_window *w, rct_widgetindex widgetIndex) { switch(widgetIndex){ case WIDX_CLOSE: window_close(w); break; case WIDX_TAB_1: case WIDX_TAB_2: window_player_set_page(w, widgetIndex - WIDX_TAB_1); break; case WIDX_LOCATE:{ rct_window* mainWindow = window_get_main(); if (mainWindow != nullptr) { sint32 player = network_get_player_index((uint8)w->number); if (player == -1) { return; } LocationXYZ16 coord = network_get_player_last_action_coord(player); if (coord.x || coord.y || coord.z) { window_scroll_to_location(mainWindow, coord.x, coord.y, coord.z); } } }break; case WIDX_KICK: game_do_command(w->number, GAME_COMMAND_FLAG_APPLY, 0, 0, GAME_COMMAND_KICK_PLAYER, 0, 0); break; } }
void window_player_overview_show_group_dropdown(rct_window *w, rct_widget *widget) { rct_widget *dropdownWidget; int numItems, i; int player = network_get_player_index((uint8)w->number); if (player == -1) { return; } dropdownWidget = widget - 1; numItems = network_get_num_groups(); window_dropdown_show_text_custom_width( w->x + dropdownWidget->left, w->y + dropdownWidget->top, dropdownWidget->bottom - dropdownWidget->top + 1, w->colours[1], 0, numItems, widget->right - dropdownWidget->left ); for (i = 0; i < network_get_num_groups(); i++) { gDropdownItemsFormat[i] = 1142; gDropdownItemsArgs[i] = network_get_group_name_string_id(i); } dropdown_set_checked(network_get_group_index(network_get_player_group(player)), true); }
static money32 BannerRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 flags) { sint32 z = baseHeight * 8; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; gCommandPosition.x = x + 16; gCommandPosition.y = y + 16; gCommandPosition.z = z; if (!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode) { gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } if (!map_can_build_at(x, y, z - 16)) { return MONEY32_UNDEFINED; } // Slight modification to the code so that it now checks height as well // This was causing a bug with banners on two paths stacked. rct_tile_element* tileElement = map_get_banner_element_at(x / 32, y / 32, baseHeight, direction); if (tileElement == nullptr) { return MONEY32_UNDEFINED; } rct_banner *banner = &gBanners[tileElement->properties.banner.index]; rct_scenery_entry *bannerEntry = get_banner_entry(banner->type); money32 refund = 0; if (bannerEntry != nullptr) { refund = -((bannerEntry->banner.price * 3) / 4); } if (flags & GAME_COMMAND_FLAG_APPLY) { if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { LocationXYZ16 coord; coord.x = x + 16; coord.y = y + 16; coord.z = tile_element_height(coord.x, coord.y); network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); } tile_element_remove_banner_entry(tileElement); map_invalidate_tile_zoom1(x, y, z, z + 32); tile_element_remove(tileElement); } if (gParkFlags & PARK_FLAGS_NO_MONEY) { refund = 0; } return refund; }
void window_player_statistics_update(rct_window* w) { w->frame_no++; widget_invalidate(w, WIDX_TAB_1 + w->page); if (network_get_player_index((uint8)w->number) == -1) { window_close(w); } }
void window_player_overview_paint(rct_window *w, rct_drawpixelinfo *dpi) { window_draw_widgets(w, dpi); window_player_draw_tab_images(dpi, w); int player = network_get_player_index((uint8)w->number); if (player == -1) { return; } // Draw current group int groupindex = network_get_group_index(network_get_player_group(player)); if (groupindex != -1) { rct_widget* widget = &window_player_overview_widgets[WIDX_GROUP]; RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = network_get_group_name_string_id(groupindex); gfx_draw_string_centred_clipped( dpi, 1193, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, w->x + (widget->left + widget->right - 11) / 2, w->y + widget->top, widget->right - widget->left - 8 ); } // Draw ping int x = w->x + 90; int y = w->y + 24; RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = STR_PING; gfx_draw_string_left(dpi, STR_WINDOW_COLOUR_2_STRING, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, x, y); char ping[64]; sprintf(ping, "%d ms", network_get_player_ping(player)); gfx_draw_string(dpi, ping, w->colours[2], x + 30, y); // Draw last action x = w->x + (w->width / 2); y = w->y + w->height - 13; int width = w->width - 8; int lastaction = network_get_player_last_action(player, 0); RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = STR_ACTION_NA; if (lastaction != -999) { RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = network_get_action_name_string_id(lastaction); } gfx_draw_string_centred_clipped(dpi, STR_LAST_ACTION_RAN, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, x, y, width); if (w->viewport != NULL && w->var_492 != -1) { window_draw_viewport(dpi, w); } }
void window_player_overview_dropdown(rct_window *w, rct_widgetindex widgetIndex, sint32 dropdownIndex) { sint32 player = network_get_player_index((uint8)w->number); if (player == -1) { return; } if (dropdownIndex == -1) { return; } sint32 group = network_get_group_id(dropdownIndex); game_do_command(0, GAME_COMMAND_FLAG_APPLY, w->number, group, GAME_COMMAND_SET_PLAYER_GROUP, 0, 0); window_invalidate(w); }
void window_player_overview_update(rct_window* w) { w->frame_no++; widget_invalidate(w, WIDX_TAB_1 + w->page); if (network_get_player_index((uint8)w->number) == -1) { window_close(w); return; } // Update viewport bool scroll = true; // Use this spare window field for rotation check if (w->var_4AE != get_current_rotation()) { w->var_4AE = get_current_rotation(); scroll = false; } window_player_update_viewport(w, scroll); }
void window_player_statistics_paint(rct_window *w, rct_drawpixelinfo *dpi) { window_draw_widgets(w, dpi); window_player_draw_tab_images(dpi, w); int player = network_get_player_index((uint8)w->number); if (player == -1) { return; } int x = w->x + window_player_overview_widgets[WIDX_PAGE_BACKGROUND].left + 4; int y = w->y + window_player_overview_widgets[WIDX_PAGE_BACKGROUND].top + 4; RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint32) = network_get_player_commands_ran(player); gfx_draw_string_left(dpi, STR_COMMANDS_RAN, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0,x, y); y += 10; RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint32) = network_get_player_money_spent(player); gfx_draw_string_left(dpi, STR_MONEY_SPENT, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0,x, y); }
static void window_player_update_viewport(rct_window *w, bool scroll) { int playerIndex = network_get_player_index((uint8)w->number); if (playerIndex == -1) { return; } rct_viewport *viewport = w->viewport; if (viewport != NULL) { rct_xyz16 coord = network_get_player_last_action_coord(playerIndex); if (coord.x != 0 || coord.y != 0 || coord.z != 0) { int viewX, viewY; center_2d_coordinates(coord.x, coord.y, coord.z, &viewX, &viewY, viewport); // Don't scroll if the view was originally undefined if (w->var_492 == -1) { scroll = false; } if (!scroll || w->saved_view_x != viewX || w->saved_view_y != viewY) { w->flags |= WF_SCROLLING_TO_LOCATION; w->saved_view_x = viewX; w->saved_view_y = viewY; if (!scroll) { w->viewport->view_x = viewX; w->viewport->view_y = viewY; } widget_invalidate(w, WIDX_VIEWPORT); } // Draw the viewport w->var_492 = 0; } else { // Don't draw the viewport w->var_492 = -1; } } }
void window_player_open(uint8 id) { rct_window* window; int player = network_get_player_index(id); window = window_bring_to_front_by_number(WC_PLAYER, id); if (window == NULL) { window = window_create_auto_pos(240, 170, &window_player_overview_events, WC_PLAYER, WF_RESIZABLE); window->number = id; window->page = 0; window->viewport_focus_coordinates.y = 0; window->frame_no = 0; window->list_information_type = 0; window->picked_peep_frame = 0; window->highlighted_item = 0; window->min_width = 210; window->min_height = 134; window->max_width = 500; window->max_height = 450; window->no_list_items = 0; window->selected_list_item = -1; window->viewport_focus_coordinates.y = -1; window->error.var_480 = user_string_allocate(128, network_get_player_name(player)); // repurposing var_480 to store this } window->page = 0; window_invalidate(window); window->widgets = window_player_page_widgets[WINDOW_PLAYER_PAGE_OVERVIEW]; window->enabled_widgets = window_player_page_enabled_widgets[WINDOW_PLAYER_PAGE_OVERVIEW]; window->hold_down_widgets = 0; window->event_handlers = window_player_page_events[WINDOW_PLAYER_PAGE_OVERVIEW]; window->pressed_widgets = 0; window_init_scroll_widgets(window); window_player_set_page(window, WINDOW_PLAYER_PAGE_OVERVIEW); }
static money32 BannerPlace(sint16 x, sint16 y, uint8 pathBaseHeight, uint8 direction, uint8 colour, uint8 type, uint8 *bannerIndex, uint8 flags) { gCommandPosition.x = x + 16; gCommandPosition.y = y + 16; gCommandPosition.z = pathBaseHeight * 16; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; if (game_is_paused() && !gCheatsBuildInPauseMode) { gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } if (!map_check_free_elements_and_reorganise(1)) { return MONEY32_UNDEFINED; } if (!map_is_location_valid(x, y)) { return MONEY32_UNDEFINED; } rct_tile_element* tileElement = map_get_first_element_at(x / 32, y / 32); bool pathFound = false; do { if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_PATH) continue; if (tileElement->base_height != pathBaseHeight * 2 && tileElement->base_height != (pathBaseHeight - 1) * 2) continue; if (!(tileElement->properties.path.edges & (1 << direction))) continue; pathFound = true; break; } while (!tile_element_is_last_for_tile(tileElement++)); if (!pathFound) { gGameCommandErrorText = STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS; return MONEY32_UNDEFINED; } if (!map_can_build_at(x, y, pathBaseHeight * 16)) { return MONEY32_UNDEFINED; } uint8 baseHeight = (pathBaseHeight + 1) * 2; tileElement = map_get_banner_element_at(x / 32, y / 32, baseHeight, direction); if (tileElement != nullptr) { gGameCommandErrorText = STR_BANNER_SIGN_IN_THE_WAY; return MONEY32_UNDEFINED; } *bannerIndex = create_new_banner(flags); if (*bannerIndex == BANNER_NULL) { return MONEY32_UNDEFINED; } if (flags & GAME_COMMAND_FLAG_APPLY) { if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { LocationXYZ16 coord; coord.x = x + 16; coord.y = y + 16; coord.z = tile_element_height(coord.x, coord.y); network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); } rct_tile_element* newTileElement = tile_element_insert(x / 32, y / 32, baseHeight, 0); assert(newTileElement != nullptr); gBanners[*bannerIndex].type = type; gBanners[*bannerIndex].colour = colour; gBanners[*bannerIndex].x = x / 32; gBanners[*bannerIndex].y = y / 32; newTileElement->type = TILE_ELEMENT_TYPE_BANNER; newTileElement->clearance_height = newTileElement->base_height + 2; newTileElement->properties.banner.position = direction; newTileElement->properties.banner.flags = 0xFF; newTileElement->properties.banner.unused = 0; newTileElement->properties.banner.index = *bannerIndex; if (flags & GAME_COMMAND_FLAG_GHOST) { newTileElement->flags |= TILE_ELEMENT_FLAG_GHOST; } map_invalidate_tile_full(x, y); map_animation_create(MAP_ANIMATION_TYPE_BANNER, x, y, newTileElement->base_height); } rct_scenery_entry *bannerEntry = get_banner_entry(type); if (bannerEntry == nullptr) { return MONEY32_UNDEFINED; } if (gParkFlags & PARK_FLAGS_NO_MONEY) { return 0; } return bannerEntry->banner.price; }
static money32 RideEntranceExitPlace(sint16 x, sint16 y, sint16 z, uint8 direction, uint8 flags, uint8 rideIndex, uint8 stationNum, bool isExit) { // Remember when in Unknown station num mode rideIndex is unknown and z is set // When in known station num mode rideIndex is known and z is unknown money32 cost = 0; gCommandPosition.x = x; gCommandPosition.y = y; if (!map_check_free_elements_and_reorganise(1)) { return MONEY32_UNDEFINED; } if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode) { gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } if (stationNum == 0xFF) { z *= 16; if (flags & GAME_COMMAND_FLAG_APPLY) { return MONEY32_UNDEFINED; } if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) { return MONEY32_UNDEFINED; } sint16 clear_z = z / 8 + (isExit ? 5 : 7); if (!gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) { return MONEY32_UNDEFINED; } if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return MONEY32_UNDEFINED; } if (z / 8 > 244) { gGameCommandErrorText = STR_TOO_HIGH; return MONEY32_UNDEFINED; } } else { if (rideIndex >= MAX_RIDES) { log_warning("Invalid game command for ride %u", rideIndex); return MONEY32_UNDEFINED; } rct_ride* ride = get_ride(rideIndex); if (ride->type == RIDE_TYPE_NULL) { log_warning("Invalid game command for ride %u", rideIndex); return MONEY32_UNDEFINED; } if (ride->status != RIDE_STATUS_CLOSED) { gGameCommandErrorText = STR_MUST_BE_CLOSED_FIRST; return MONEY32_UNDEFINED; } if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) { gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION; return MONEY32_UNDEFINED; } ride_clear_for_construction(rideIndex); ride_remove_peeps(rideIndex); bool requiresRemove = false; rct_xy16 removeCoord = { 0, 0 }; if (isExit) { if (ride->exits[stationNum] != 0xFFFF) { if (flags & GAME_COMMAND_FLAG_GHOST) { gGameCommandErrorText = 0; return MONEY32_UNDEFINED; } removeCoord.x = (ride->exits[stationNum] & 0xFF) * 32; removeCoord.y = ((ride->exits[stationNum] >> 8) & 0xFF) * 32; requiresRemove = true; } } else if (ride->entrances[stationNum] != 0xFFFF) { if (flags & GAME_COMMAND_FLAG_GHOST) { gGameCommandErrorText = 0; return MONEY32_UNDEFINED; } removeCoord.x = (ride->entrances[stationNum] & 0xFF) * 32; removeCoord.y = ((ride->entrances[stationNum] >> 8) & 0xFF) * 32; requiresRemove = true; } if (requiresRemove) { money32 success = game_do_command( removeCoord.x, flags, removeCoord.y, rideIndex, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, stationNum, 0 ); if (success == MONEY32_UNDEFINED) { return MONEY32_UNDEFINED; } } z = ride->station_heights[stationNum] * 8; gCommandPosition.z = z; if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !(flags & GAME_COMMAND_FLAG_GHOST)) { footpath_remove_litter(x, y, z); wall_remove_at_z(x, y, z); } if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) { return MONEY32_UNDEFINED; } sint8 clear_z = (z / 8) + (isExit ? 5 : 7); if (!gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) { return MONEY32_UNDEFINED; } if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return MONEY32_UNDEFINED; } if (z / 8 > 244) { gGameCommandErrorText = STR_TOO_HIGH; return MONEY32_UNDEFINED; } if (flags & GAME_COMMAND_FLAG_APPLY) { rct_xyz16 coord; coord.x = x + 16; coord.y = y + 16; coord.z = map_element_height(coord.x, coord.y); network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); rct_map_element* mapElement = map_element_insert(x / 32, y / 32, z / 8, 0xF); assert(mapElement != NULL); mapElement->clearance_height = clear_z; mapElement->properties.entrance.type = isExit; mapElement->properties.entrance.index = stationNum << 4; mapElement->properties.entrance.ride_index = rideIndex; mapElement->type = MAP_ELEMENT_TYPE_ENTRANCE | direction; if (flags & GAME_COMMAND_FLAG_GHOST) { mapElement->flags |= MAP_ELEMENT_FLAG_GHOST; } if (isExit) { ride->exits[stationNum] = (x / 32) | (y / 32 << 8); } else { ride->entrances[stationNum] = (x / 32) | (y / 32 << 8); ride->last_peep_in_queue[stationNum] = SPRITE_INDEX_NULL; ride->queue_length[stationNum] = 0; map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, x, y, z / 8); } footpath_queue_chain_reset(); if (!(flags & GAME_COMMAND_FLAG_GHOST)) { maze_entrance_hedge_removal(x, y, mapElement); } footpath_connect_edges(x, y, mapElement, flags); sub_6A759F(); map_invalidate_tile_full(x, y); } }