The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
wesnothd::room Class Reference

A room is a group of players that can communicate via messages. More...

#include <room.hpp>

Public Member Functions

 room (const std::string &name)
 Construct a room with just a name and default settings. More...
 
 room (const config &cfg)
 Construct a room from WML. More...
 
void write (config &cfg) const
 Write room info to a config. More...
 
const std::stringname () const
 The name of this room. More...
 
bool persistent () const
 Whether this room should be 'persistent', i.e. More...
 
void set_persistent (bool v)
 Set the persistent flag for this room. More...
 
bool logged () const
 Whether the room is logged (and might end up in e.g. More...
 
void set_logged (bool v)
 Set the room's logged flag. More...
 
const std::stringtopic () const
 This room's topic/motd, sent to all joining players. More...
 
void set_topic (const std::string &v)
 Set the topic for this room. More...
 
size_t size () const
 Return the number of players in this room. More...
 
bool empty () const
 Return true iif the room is empty. More...
 
const std::vector
< network::connection > & 
members () const
 Return the members of this room. More...
 
bool is_member (network::connection player) const
 Membership checker. More...
 
bool add_player (network::connection player)
 Joining the room. More...
 
void remove_player (network::connection player)
 Leaving the room. More...
 
void process_message (simple_wml::document &data, const player_map::iterator user)
 Chat message processing. More...
 
void send_data (simple_wml::document &data, const network::connection exclude=0, std::string packet_type="") const
 Convenience function for sending a wml document to all (or all except one) members. More...
 
void send_server_message_to_all (const char *message, network::connection exclude=0) const
 Send a text message to all members. More...
 
void send_server_message_to_all (const std::string &message, network::connection exclude=0) const
 
void send_server_message (const char *message, network::connection sock, simple_wml::document *docptr=nullptr) const
 Prepare a text message and/or send it to a player. More...
 
void send_server_message (const std::string &message, network::connection sock, simple_wml::document *docptr=nullptr) const
 

Private Attributes

std::string name_
 
connection_vector members_
 
bool persistent_
 
std::string topic_
 
bool logged_
 

Detailed Description

A room is a group of players that can communicate via messages.

Definition at line 31 of file room.hpp.

Constructor & Destructor Documentation

wesnothd::room::room ( const std::string name)

Construct a room with just a name and default settings.

Definition at line 30 of file room.cpp.

wesnothd::room::room ( const config cfg)

Construct a room from WML.

Definition at line 39 of file room.cpp.

Member Function Documentation

bool wesnothd::room::add_player ( network::connection  player)

Joining the room.

Returns
true if the player was successfully added

Definition at line 91 of file room.cpp.

References ERR_ROOM, is_member(), and members_.

Referenced by wesnothd::room_manager::enter_lobby(), and wesnothd::room_manager::player_enters_room().

bool wesnothd::room::empty ( ) const
inline

Return true iif the room is empty.

Definition at line 94 of file room.hpp.

References members_.

Referenced by wesnothd::room_manager::process_room_part().

bool wesnothd::room::is_member ( network::connection  player) const
inline

Membership checker.

Returns
true iif player is a member of this room

Definition at line 109 of file room.hpp.

References gui2::event::find(), and members_.

Referenced by add_player(), wesnothd::room_manager::in_lobby(), wesnothd::room_manager::player_enters_room(), and wesnothd::room_manager::require_member().

bool wesnothd::room::logged ( ) const

Whether the room is logged (and might end up in e.g.

the lobby bot

Definition at line 81 of file room.cpp.

References logged_.

Referenced by wesnothd::room_manager::process_message().

const std::vector<network::connection>& wesnothd::room::members ( ) const
inline

Return the members of this room.

Definition at line 101 of file room.hpp.

References members_.

Referenced by wesnothd::room_manager::fill_member_list(), wesnothd::room_manager::fill_room_list(), and send_data().

const std::string & wesnothd::room::name ( ) const

The name of this room.

Definition at line 56 of file room.cpp.

References name_.

Referenced by wesnothd::room_manager::fill_room_list(), wesnothd::room_manager::read_rooms(), and wesnothd::room_manager::store_player_rooms().

bool wesnothd::room::persistent ( ) const

Whether this room should be 'persistent', i.e.

not deleted when there are no players within and stored on disk if needed.

Definition at line 61 of file room.cpp.

References persistent_.

Referenced by wesnothd::room_manager::process_room_part(), wesnothd::room_manager::process_room_query(), and wesnothd::room_manager::write_rooms().

void wesnothd::room::process_message ( simple_wml::document data,
const player_map::iterator  user 
)

Chat message processing.

Definition at line 147 of file room.cpp.

void wesnothd::room::remove_player ( network::connection  player)
void wesnothd::room::send_data ( simple_wml::document data,
const network::connection  exclude = 0,
std::string  packet_type = "" 
) const

Convenience function for sending a wml document to all (or all except one) members.

See also
send_to_many
Parameters
datathe document to send
excludeif nonzero, do not send to this player
packet_typethe packet type, if empty the root node name is used

Definition at line 115 of file room.cpp.

References members().

Referenced by wesnothd::room_manager::process_message(), wesnothd::room_manager::process_room_join(), wesnothd::room_manager::process_room_part(), send_server_message_to_all(), and wesnothd::room_manager::unstore_player_rooms().

void wesnothd::room::send_server_message ( const char *  message,
network::connection  sock,
simple_wml::document docptr = nullptr 
) const

Prepare a text message and/or send it to a player.

If a nonzero sock is passed, the message is sent to this player. If a non-null pointer to a simple_wml::document is passed, the message is stored in that document.

Parameters
messagethe message text
sockthe socket to send the message to, if nonzero
docptrthe wml document to store the message in, if nonnull

Definition at line 129 of file room.cpp.

References simple_wml::node::add_child(), game_logic::msg(), simple_wml::document::root(), simple_wml::node::set_attr(), and simple_wml::node::set_attr_dup().

Referenced by wesnothd::room_manager::get_create_room(), wesnothd::room_manager::player_enters_room(), wesnothd::room_manager::process_message(), wesnothd::room_manager::process_room_part(), wesnothd::room_manager::process_room_query(), wesnothd::room_manager::require_member(), wesnothd::room_manager::require_room(), send_server_message(), and send_server_message_to_all().

void wesnothd::room::send_server_message ( const std::string message,
network::connection  sock,
simple_wml::document docptr = nullptr 
) const
inline

Definition at line 162 of file room.hpp.

References send_server_message().

void wesnothd::room::send_server_message_to_all ( const char *  message,
network::connection  exclude = 0 
) const

Send a text message to all members.

Parameters
messagethe message text
excludeif nonzero, do not send to this player

Definition at line 122 of file room.cpp.

References send_data(), and send_server_message().

Referenced by send_server_message_to_all().

void wesnothd::room::send_server_message_to_all ( const std::string message,
network::connection  exclude = 0 
) const
inline

Definition at line 145 of file room.hpp.

References send_server_message_to_all().

void wesnothd::room::set_logged ( bool  v)

Set the room's logged flag.

Definition at line 86 of file room.cpp.

References logged_.

Referenced by wesnothd::room_manager::process_room_query(), and wesnothd::room_manager::read_rooms().

void wesnothd::room::set_persistent ( bool  v)

Set the persistent flag for this room.

Definition at line 66 of file room.cpp.

References persistent_.

Referenced by wesnothd::room_manager::process_room_query(), and wesnothd::room_manager::read_rooms().

void wesnothd::room::set_topic ( const std::string v)

Set the topic for this room.

Definition at line 76 of file room.cpp.

References topic_.

Referenced by wesnothd::room_manager::process_room_query().

size_t wesnothd::room::size ( ) const
inline

Return the number of players in this room.

Definition at line 87 of file room.hpp.

References members_.

const std::string & wesnothd::room::topic ( ) const

This room's topic/motd, sent to all joining players.

Definition at line 71 of file room.cpp.

References topic_.

Referenced by wesnothd::room_manager::process_room_join(), wesnothd::room_manager::process_room_query(), and wesnothd::room_manager::unstore_player_rooms().

void wesnothd::room::write ( config cfg) const

Write room info to a config.

Definition at line 48 of file room.cpp.

References logged_, name_, persistent_, and topic_.

Referenced by wesnothd::room_manager::write_rooms().

Member Data Documentation

bool wesnothd::room::logged_
private

Definition at line 174 of file room.hpp.

Referenced by logged(), set_logged(), and write().

connection_vector wesnothd::room::members_
private

Definition at line 171 of file room.hpp.

Referenced by add_player(), empty(), is_member(), members(), remove_player(), and size().

std::string wesnothd::room::name_
private

Definition at line 170 of file room.hpp.

Referenced by name(), and write().

bool wesnothd::room::persistent_
private

Definition at line 172 of file room.hpp.

Referenced by persistent(), set_persistent(), and write().

std::string wesnothd::room::topic_
private

Definition at line 173 of file room.hpp.

Referenced by set_topic(), topic(), and write().


The documentation for this class was generated from the following files: