Add a MP mod command to stop a game.
This command is of the form "/query stopgame <nick>". wesnothd then retrieves the id of the game that person is in and calls delete_game(<id>).
This commit is contained in:
parent
100e93706a
commit
c8976432af
2 changed files with 23 additions and 1 deletions
|
@ -212,7 +212,7 @@ const std::string help_msg =
|
|||
" k[ick]ban <mask> <time> <reason>, help, games, metrics,"
|
||||
" netstats [all], [lobby]msg <message>, motd [<message>],"
|
||||
" pm|privatemsg <nickname> <message>, requests, sample, searchlog <mask>,"
|
||||
" signout, stats, status [<mask>], unban <ipmask>\n"
|
||||
" signout, stats, status [<mask>], stopgame <nick>, unban <ipmask>\n"
|
||||
"Specific strings (those not in between <> like the command names)"
|
||||
" are case insensitive.";
|
||||
|
||||
|
@ -403,6 +403,7 @@ void server::setup_handlers()
|
|||
SETUP_HANDLER("sl", &server::searchlog_handler);
|
||||
SETUP_HANDLER("dul", &server::dul_handler);
|
||||
SETUP_HANDLER("deny_unregistered_login", &server::dul_handler);
|
||||
SETUP_HANDLER("stopgame", &server::stopgame);
|
||||
|
||||
#undef SETUP_HANDLER
|
||||
}
|
||||
|
@ -2819,6 +2820,26 @@ void server::dul_handler(const std::string& /*issuer_name*/,
|
|||
}
|
||||
}
|
||||
|
||||
void server::stopgame(const std::string& /*issuer_name*/,
|
||||
const std::string& /*query*/,
|
||||
std::string& parameters,
|
||||
std::ostringstream* out)
|
||||
{
|
||||
auto player = player_connections_.get<name_t>().find(parameters);
|
||||
|
||||
if(player != player_connections_.get<name_t>().end()){
|
||||
std::shared_ptr<game> g = player->get_game();
|
||||
if(g){
|
||||
*out << "Player '" << parameters << "' is in game with id '" << g->id() << "' named '" << g->name() << "'. Ending game...";
|
||||
delete_game(g->id());
|
||||
} else {
|
||||
*out << "Player '" << parameters << "' is not currently in a game.";
|
||||
}
|
||||
} else {
|
||||
*out << "Player '" << parameters << "' is not currently logged in.";
|
||||
}
|
||||
}
|
||||
|
||||
void server::delete_game(int gameid)
|
||||
{
|
||||
// Set the availability status for all quitting users.
|
||||
|
|
|
@ -219,6 +219,7 @@ private:
|
|||
void motd_handler(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
||||
void searchlog_handler(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
||||
void dul_handler(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
||||
void stopgame(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
||||
|
||||
#ifndef _WIN32
|
||||
void handle_sighup(const boost::system::error_code& error, int signal_number);
|
||||
|
|
Loading…
Add table
Reference in a new issue