17 #include <boost/utility.hpp>
21 #ifndef SERVER_ROOM_MANAGER_HPP_INCLUDED
22 #define SERVER_ROOM_MANAGER_HPP_INCLUDED
void process_room_part(simple_wml::document &data, const player_map::iterator user)
Process a player's request to leave a room.
void process_message(simple_wml::document &data, const player_map::iterator user)
Process a message (chat message) sent to a room.
std::map< std::string, room * > t_rooms_by_name_
Rooms by name.
t_rooms_by_name_ rooms_by_name_
static PRIVILEGE_POLICY pp_from_string(const std::string &str)
room * lobby_
The lobby-room, treated separetely.
void fill_member_list(const room *room, simple_wml::node &root)
Fill a wml node (message) with members of a room.
void unstore_player_rooms(const player_map::iterator user)
Unstores (rejoins) player's rooms that were previously stored.
void player_exits_room(network::connection player, room *room)
Removes a player from a room, maintaining internal consistency.
std::string filename_
Persistent room storage filename.
void store_player_rooms(network::connection player)
Stores the room names (other than lobby) of the given player for future use (rejoin) ...
void do_room_join(network::connection player, const std::string &room_name)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
void fill_room_list(simple_wml::node &root)
Fill a wml node (message) with a room list.
room_manager(player_map &all_players)
Room manager constructor.
The room manager manages the lobby and other rooms in the server, and related client message processi...
bool in_lobby(network::connection player) const
std::map< network::connection, player > player_map
~room_manager()
Room manager destructor.
room * get_room(const std::string &name)
Get a room by name, or nullptr if it does not exist.
room * require_member(const std::string &room_name, const player_map::iterator user, const char *log_string="use")
Check if the room exists and if the player is a member, log failures.
t_rooms_by_player_ rooms_by_player_
A room is a group of players that can communicate via messages.
void read_rooms()
Reads stored rooms from a file on disk, or returns immediately if load_config was not called before o...
void process_room_join(simple_wml::document &data, const player_map::iterator user)
Process a player's request to join a room.
bool compress_stored_rooms_
Flag controlling whether to compress the stored rooms or not.
room * get_create_room(const std::string &name, network::connection player)
Get a room by name or create that room if it does not exist and creating rooms is allowed...
std::map< network::connection, std::set< room * > > t_rooms_by_player_
Rooms by player.
PRIVILEGE_POLICY new_room_policy_
Policy regarding who can create new rooms.
void exit_lobby(network::connection player)
Player exits lobby.
std::map< network::connection, std::set< std::string > > t_player_stored_rooms_
Room names stored for players that have entered a game.
room * require_room(const std::string &room_name, const player_map::iterator user, const char *log_string="use")
Check if the room exists, log failures.
void load_config(const config &cfg)
Load settings from the main config file.
void write_rooms()
Writes rooms to the storage file or returns immediately if load_config was not called beforethe stora...
void process_room_query(simple_wml::document &data, const player_map::iterator user)
Process a general room query.
player_map & all_players_
Reference to the all players map.
GLuint const GLchar * name
bool dirty_
'Dirty' flag with regards to room info that will be stored on disk
void remove_player(network::connection player)
Remove info abut given player from all rooms.
static const char *const lobby_name_
The main (lobby) room name.
bool player_enters_room(network::connection player, room *room)
Adds a player to a room, maintaining internal consistency Will send appropriate error messages to the...
void enter_lobby(network::connection player)
Player-enters-lobby action.
bool room_exists(const std::string &name) const
A config object defines a single node in a WML file, with access to child nodes.
bool dirty() const
Dirty flag for rooms – true if there were changes that should be written to disk.
GLsizei const GLcharARB ** string
t_player_stored_rooms_ player_stored_rooms_
const room & lobby() const
Lobby convenience accesor.
room * create_room(const std::string &name)
Create room named "name" if it does not exist already.