#pragma once #include #include #include #include #include #include #include #include #include "Client.hh" #include "FunctionCompiler.hh" #include "GSLArchive.hh" #include "Items.hh" #include "LevelTable.hh" #include "License.hh" #include "Lobby.hh" #include "Menu.hh" #include "Quest.hh" // Forward declarations due to reference cycles class ProxyServer; class Server; struct PortConfiguration { std::string name; uint16_t port; GameVersion version; ServerBehavior behavior; }; struct ServerState { enum class RunShellBehavior { DEFAULT = 0, ALWAYS, NEVER, }; std::u16string name; std::unordered_map> name_to_port_config; std::unordered_map> number_to_port_config; std::string username; uint16_t dns_server_port; std::vector ip_stack_addresses; bool ip_stack_debug; bool allow_unregistered_users; bool allow_saving; bool item_tracking_enabled; RunShellBehavior run_shell_behavior; std::vector> bb_private_keys; std::shared_ptr function_code_index; std::shared_ptr pc_patch_file_index; std::shared_ptr bb_patch_file_index; std::shared_ptr dol_file_index; std::shared_ptr ep3_data_index; std::shared_ptr quest_index; std::shared_ptr level_table; std::shared_ptr battle_params; std::shared_ptr common_item_data; std::shared_ptr bb_data_gsl; std::shared_ptr rare_item_set; std::shared_ptr license_manager; std::vector main_menu; std::shared_ptr> information_menu_v2; std::shared_ptr> information_menu_v3; std::shared_ptr> information_contents; std::vector proxy_destinations_menu_dc; std::vector proxy_destinations_menu_pc; std::vector proxy_destinations_menu_gc; std::vector proxy_destinations_menu_xb; std::vector> proxy_destinations_dc; std::vector> proxy_destinations_pc; std::vector> proxy_destinations_gc; std::vector> proxy_destinations_xb; std::pair proxy_destination_patch; std::pair proxy_destination_bb; std::u16string welcome_message; std::u16string pc_patch_server_message; std::u16string bb_patch_server_message; std::map> id_to_lobby; std::vector> public_lobby_search_order; std::vector> public_lobby_search_order_ep3; // TODO: Use a free-list instead of an incrementer to prevent wrap-around // behavioral bugs. This... will probably never be an issue for anyone, but we // technically should handle it. std::atomic next_lobby_id; uint8_t pre_lobby_event; int32_t ep3_menu_song; std::map all_addresses; uint32_t local_address; uint32_t external_address; std::shared_ptr proxy_server; std::shared_ptr game_server; ServerState(); void add_client_to_available_lobby(std::shared_ptr c); void remove_client_from_lobby(std::shared_ptr c); bool change_client_lobby(std::shared_ptr c, std::shared_ptr new_lobby); void send_lobby_join_notifications(std::shared_ptr l, std::shared_ptr joining_client); std::shared_ptr find_lobby(uint32_t lobby_id); std::vector> all_lobbies(); std::shared_ptr create_lobby(); void remove_lobby(uint32_t lobby_id); std::shared_ptr find_client( const std::u16string* identifier = nullptr, uint64_t serial_number = 0, std::shared_ptr l = nullptr); uint32_t connect_address_for_client(std::shared_ptr c); std::shared_ptr> information_menu_for_version(GameVersion version); const std::vector& proxy_destinations_menu_for_version(GameVersion version); const std::vector>& proxy_destinations_for_version(GameVersion version); void set_port_configuration( const std::vector& port_configs); void create_menus(std::shared_ptr config_json); std::shared_ptr load_bb_file( const std::string& patch_index_filename, const std::string& gsl_filename = "", const std::string& bb_directory_filename = "") const; };