Revert "utils::optional -> std::optional for 8058dab"
This reverts commit 255fc0d450
.
This commit is contained in:
parent
c89c1b4b4a
commit
740aadb273
4 changed files with 39 additions and 37 deletions
|
@ -769,7 +769,7 @@ void game::send_leave_game(player_iterator user) const
|
|||
server.send_to_player(user, leave_game);
|
||||
}
|
||||
|
||||
std::optional<player_iterator> game::kick_member(const simple_wml::node& kick, player_iterator kicker)
|
||||
utils::optional<player_iterator> game::kick_member(const simple_wml::node& kick, player_iterator kicker)
|
||||
{
|
||||
if(kicker != owner_) {
|
||||
send_server_message("You cannot kick: not the game host", kicker);
|
||||
|
@ -801,7 +801,7 @@ std::optional<player_iterator> game::kick_member(const simple_wml::node& kick, p
|
|||
return user;
|
||||
}
|
||||
|
||||
std::optional<player_iterator> game::ban_user(const simple_wml::node& ban, player_iterator banner)
|
||||
utils::optional<player_iterator> game::ban_user(const simple_wml::node& ban, player_iterator banner)
|
||||
{
|
||||
if(banner != owner_) {
|
||||
send_server_message("You cannot ban: not the game host", banner);
|
||||
|
@ -1544,7 +1544,7 @@ bool game::remove_player(player_iterator player, const bool disconnect, const bo
|
|||
return false;
|
||||
}
|
||||
|
||||
void game::send_user_list(std::optional<player_iterator> exclude)
|
||||
void game::send_user_list(utils::optional<player_iterator> exclude)
|
||||
{
|
||||
// If the game hasn't started yet, then send all players a list of the users in the game.
|
||||
if(started_ /*|| description_ == nullptr*/) {
|
||||
|
@ -1632,7 +1632,7 @@ void game::load_next_scenario(player_iterator user)
|
|||
}
|
||||
|
||||
template<typename Container>
|
||||
void game::send_to_players(simple_wml::document& data, const Container& players, std::optional<player_iterator> exclude)
|
||||
void game::send_to_players(simple_wml::document& data, const Container& players, utils::optional<player_iterator> exclude)
|
||||
{
|
||||
for(const auto& player : players) {
|
||||
if(player != exclude) {
|
||||
|
@ -1641,14 +1641,14 @@ void game::send_to_players(simple_wml::document& data, const Container& players,
|
|||
}
|
||||
}
|
||||
|
||||
void game::send_data(simple_wml::document& data, std::optional<player_iterator> exclude)
|
||||
void game::send_data(simple_wml::document& data, utils::optional<player_iterator> exclude)
|
||||
{
|
||||
send_to_players(data, all_game_users(), exclude);
|
||||
}
|
||||
|
||||
void game::send_data_sides(simple_wml::document& data,
|
||||
const simple_wml::string_span& sides,
|
||||
std::optional<player_iterator> exclude)
|
||||
utils::optional<player_iterator> exclude)
|
||||
{
|
||||
std::vector<int> sides_vec = ::split<int>(sides, ::split_conv_impl);
|
||||
|
||||
|
@ -1690,7 +1690,7 @@ std::string game::has_same_ip(player_iterator user) const
|
|||
return clones;
|
||||
}
|
||||
|
||||
void game::send_observerjoins(std::optional<player_iterator> player)
|
||||
void game::send_observerjoins(utils::optional<player_iterator> player)
|
||||
{
|
||||
for(auto ob : observers_) {
|
||||
if(ob == player) {
|
||||
|
@ -1929,7 +1929,7 @@ std::string game::debug_sides_info() const
|
|||
return result.str();
|
||||
}
|
||||
|
||||
std::optional<player_iterator> game::find_user(const simple_wml::string_span& name)
|
||||
utils::optional<player_iterator> game::find_user(const simple_wml::string_span& name)
|
||||
{
|
||||
auto player { player_connections_.get<name_t>().find(name.to_string()) };
|
||||
if(player != player_connections_.get<name_t>().end()) {
|
||||
|
@ -1939,7 +1939,7 @@ std::optional<player_iterator> game::find_user(const simple_wml::string_span& na
|
|||
}
|
||||
}
|
||||
|
||||
void game::send_and_record_server_message(const char* message, std::optional<player_iterator> exclude)
|
||||
void game::send_and_record_server_message(const char* message, utils::optional<player_iterator> exclude)
|
||||
{
|
||||
auto doc = std::make_unique<simple_wml::document>();
|
||||
send_server_message(message, {}, doc.get());
|
||||
|
@ -1950,14 +1950,14 @@ void game::send_and_record_server_message(const char* message, std::optional<pla
|
|||
}
|
||||
}
|
||||
|
||||
void game::send_server_message_to_all(const char* message, std::optional<player_iterator> exclude)
|
||||
void game::send_server_message_to_all(const char* message, utils::optional<player_iterator> exclude)
|
||||
{
|
||||
simple_wml::document doc;
|
||||
send_server_message(message, {}, &doc);
|
||||
send_data(doc, exclude);
|
||||
}
|
||||
|
||||
void game::send_server_message(const char* message, std::optional<player_iterator> player, simple_wml::document* docptr) const
|
||||
void game::send_server_message(const char* message, utils::optional<player_iterator> player, simple_wml::document* docptr) const
|
||||
{
|
||||
simple_wml::document docbuf;
|
||||
if(docptr == nullptr) {
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
#include "server/common/simple_wml.hpp"
|
||||
#include "side_controller.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include "utils/optional_fwd.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
// class player;
|
||||
|
@ -28,7 +29,7 @@
|
|||
namespace wesnothd
|
||||
{
|
||||
typedef std::vector<player_iterator> user_vector;
|
||||
typedef std::vector<std::optional<player_iterator>> side_vector;
|
||||
typedef std::vector<utils::optional<player_iterator>> side_vector;
|
||||
class server;
|
||||
|
||||
class game
|
||||
|
@ -243,7 +244,7 @@ public:
|
|||
* @param kicker The player doing the kicking.
|
||||
* @return The iterator to the removed member if successful, empty optional otherwise.
|
||||
*/
|
||||
std::optional<player_iterator> kick_member(const simple_wml::node& kick, player_iterator kicker);
|
||||
utils::optional<player_iterator> kick_member(const simple_wml::node& kick, player_iterator kicker);
|
||||
|
||||
/**
|
||||
* Ban a user by name.
|
||||
|
@ -254,7 +255,7 @@ public:
|
|||
* @param banner The player doing the banning.
|
||||
* @return The iterator to the banned player if he was in this game, empty optional otherwise.
|
||||
*/
|
||||
std::optional<player_iterator> ban_user(const simple_wml::node& ban, player_iterator banner);
|
||||
utils::optional<player_iterator> ban_user(const simple_wml::node& ban, player_iterator banner);
|
||||
|
||||
/**
|
||||
* Unban a user by name.
|
||||
|
@ -373,11 +374,11 @@ public:
|
|||
* @param message The message to send.
|
||||
* @param exclude The players to not send the message to.
|
||||
*/
|
||||
void send_server_message_to_all(const char* message, std::optional<player_iterator> exclude = {});
|
||||
void send_server_message_to_all(const char* message, utils::optional<player_iterator> exclude = {});
|
||||
/**
|
||||
* @ref send_server_message_to_all
|
||||
*/
|
||||
void send_server_message_to_all(const std::string& message, std::optional<player_iterator> exclude = {})
|
||||
void send_server_message_to_all(const std::string& message, utils::optional<player_iterator> exclude = {})
|
||||
{
|
||||
send_server_message_to_all(message.c_str(), exclude);
|
||||
}
|
||||
|
@ -390,12 +391,12 @@ public:
|
|||
* @param doc The document to create the message in. If nullptr then a new document is created.
|
||||
*/
|
||||
void send_server_message(
|
||||
const char* message, std::optional<player_iterator> player = {}, simple_wml::document* doc = nullptr) const;
|
||||
const char* message, utils::optional<player_iterator> player = {}, simple_wml::document* doc = nullptr) const;
|
||||
/**
|
||||
* @ref send_server_message
|
||||
*/
|
||||
void send_server_message(
|
||||
const std::string& message, std::optional<player_iterator> player = {}, simple_wml::document* doc = nullptr) const
|
||||
const std::string& message, utils::optional<player_iterator> player = {}, simple_wml::document* doc = nullptr) const
|
||||
{
|
||||
send_server_message(message.c_str(), player, doc);
|
||||
}
|
||||
|
@ -407,11 +408,11 @@ public:
|
|||
* @param message The message to send.
|
||||
* @param exclude The players to not send the message to.
|
||||
*/
|
||||
void send_and_record_server_message(const char* message, std::optional<player_iterator> exclude = {});
|
||||
void send_and_record_server_message(const char* message, utils::optional<player_iterator> exclude = {});
|
||||
/**
|
||||
* @ref send_and_record_server_message
|
||||
*/
|
||||
void send_and_record_server_message(const std::string& message, std::optional<player_iterator> exclude = {})
|
||||
void send_and_record_server_message(const std::string& message, utils::optional<player_iterator> exclude = {})
|
||||
{
|
||||
send_and_record_server_message(message.c_str(), exclude);
|
||||
}
|
||||
|
@ -425,7 +426,7 @@ public:
|
|||
* @param exclude The player from @a players to not send the data to.
|
||||
*/
|
||||
template<typename Container>
|
||||
void send_to_players(simple_wml::document& data, const Container& players, std::optional<player_iterator> exclude = {});
|
||||
void send_to_players(simple_wml::document& data, const Container& players, utils::optional<player_iterator> exclude = {});
|
||||
|
||||
/**
|
||||
* Send data to all players and observers except those excluded.
|
||||
|
@ -433,7 +434,7 @@ public:
|
|||
* @param data The data to send.
|
||||
* @param exclude The players/observers to not send the data to.
|
||||
*/
|
||||
void send_data(simple_wml::document& data, std::optional<player_iterator> exclude = {});
|
||||
void send_data(simple_wml::document& data, utils::optional<player_iterator> exclude = {});
|
||||
|
||||
/**
|
||||
* Clears the history of recorded WML documents.
|
||||
|
@ -607,7 +608,7 @@ private:
|
|||
/**
|
||||
* @return The player who owns the current side.
|
||||
*/
|
||||
std::optional<player_iterator> current_player() const
|
||||
utils::optional<player_iterator> current_player() const
|
||||
{
|
||||
return sides_[current_side()];
|
||||
}
|
||||
|
@ -707,7 +708,7 @@ private:
|
|||
*/
|
||||
void send_data_sides(simple_wml::document& data,
|
||||
const simple_wml::string_span& sides,
|
||||
std::optional<player_iterator> exclude = {});
|
||||
utils::optional<player_iterator> exclude = {});
|
||||
|
||||
/**
|
||||
* Send a document per observer in the game.
|
||||
|
@ -715,7 +716,7 @@ private:
|
|||
*
|
||||
* @param player The observer who joined.
|
||||
*/
|
||||
void send_observerjoins(std::optional<player_iterator> player = {});
|
||||
void send_observerjoins(utils::optional<player_iterator> player = {});
|
||||
void send_observerquit(player_iterator observer);
|
||||
void send_history(player_iterator sock) const;
|
||||
void send_chat_history(player_iterator sock) const;
|
||||
|
@ -729,7 +730,7 @@ private:
|
|||
* @param name The name of the user to find.
|
||||
* @return The player if found, else empty.
|
||||
*/
|
||||
std::optional<player_iterator> find_user(const simple_wml::string_span& name);
|
||||
utils::optional<player_iterator> find_user(const simple_wml::string_span& name);
|
||||
|
||||
bool is_legal_command(const simple_wml::node& command, player_iterator user);
|
||||
|
||||
|
@ -760,7 +761,7 @@ private:
|
|||
*
|
||||
* @param exclude The players to not send the list of users to.
|
||||
*/
|
||||
void send_user_list(std::optional<player_iterator> exclude = {});
|
||||
void send_user_list(utils::optional<player_iterator> exclude = {});
|
||||
|
||||
/**
|
||||
* @param pl The player.
|
||||
|
|
|
@ -1989,7 +1989,7 @@ void server::remove_player(player_iterator iter)
|
|||
if(game_ended) delete_game(g->id());
|
||||
}
|
||||
|
||||
void server::send_to_lobby(simple_wml::document& data, std::optional<player_iterator> exclude)
|
||||
void server::send_to_lobby(simple_wml::document& data, utils::optional<player_iterator> exclude)
|
||||
{
|
||||
for(const auto& p : player_connections_.get<game_t>().equal_range(0)) {
|
||||
auto player { player_connections_.iterator_to(p) };
|
||||
|
@ -1999,7 +1999,7 @@ void server::send_to_lobby(simple_wml::document& data, std::optional<player_iter
|
|||
}
|
||||
}
|
||||
|
||||
void server::send_server_message_to_lobby(const std::string& message, std::optional<player_iterator> exclude)
|
||||
void server::send_server_message_to_lobby(const std::string& message, utils::optional<player_iterator> exclude)
|
||||
{
|
||||
for(const auto& p : player_connections_.get<game_t>().equal_range(0)) {
|
||||
auto player { player_connections_.iterator_to(p) };
|
||||
|
@ -2009,7 +2009,7 @@ void server::send_server_message_to_lobby(const std::string& message, std::optio
|
|||
}
|
||||
}
|
||||
|
||||
void server::send_server_message_to_all(const std::string& message, std::optional<player_iterator> exclude)
|
||||
void server::send_server_message_to_all(const std::string& message, utils::optional<player_iterator> exclude)
|
||||
{
|
||||
for(auto player = player_connections_.begin(); player != player_connections_.end(); ++player) {
|
||||
if(player != exclude) {
|
||||
|
@ -2970,7 +2970,7 @@ void server::delete_game(int gameid, const std::string& reason)
|
|||
}
|
||||
}
|
||||
|
||||
void server::update_game_in_lobby(const wesnothd::game& g, std::optional<player_iterator> exclude)
|
||||
void server::update_game_in_lobby(const wesnothd::game& g, utils::optional<player_iterator> exclude)
|
||||
{
|
||||
simple_wml::document diff;
|
||||
if(make_change_diff(*games_and_users_list_.child("gamelist"), "gamelist", "game", g.description(), diff)) {
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
#include "server/common/server_base.hpp"
|
||||
#include "server/wesnothd/player_connection.hpp"
|
||||
|
||||
#include "utils/optional_fwd.hpp"
|
||||
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <random>
|
||||
|
||||
namespace wesnothd
|
||||
|
@ -74,15 +75,15 @@ public:
|
|||
player->socket()
|
||||
);
|
||||
}
|
||||
void send_to_lobby(simple_wml::document& data, std::optional<player_iterator> exclude = {});
|
||||
void send_to_lobby(simple_wml::document& data, utils::optional<player_iterator> exclude = {});
|
||||
void send_to_player(player_iterator player, simple_wml::document& data) {
|
||||
utils::visit(
|
||||
[this, &data](auto&& socket) { async_send_doc_queued(socket, data); },
|
||||
player->socket()
|
||||
);
|
||||
}
|
||||
void send_server_message_to_lobby(const std::string& message, std::optional<player_iterator> exclude = {});
|
||||
void send_server_message_to_all(const std::string& message, std::optional<player_iterator> exclude = {});
|
||||
void send_server_message_to_lobby(const std::string& message, utils::optional<player_iterator> exclude = {});
|
||||
void send_server_message_to_all(const std::string& message, utils::optional<player_iterator> exclude = {});
|
||||
|
||||
bool player_is_in_game(player_iterator player) const {
|
||||
return player->get_game() != nullptr;
|
||||
|
@ -211,7 +212,7 @@ private:
|
|||
|
||||
void delete_game(int, const std::string& reason="");
|
||||
|
||||
void update_game_in_lobby(const game& g, std::optional<player_iterator> exclude = {});
|
||||
void update_game_in_lobby(const game& g, utils::optional<player_iterator> exclude = {});
|
||||
|
||||
void start_new_server();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue