From ca0c1d3e6f8b5fa4eb2e0a86fcf47b12fb600786 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 27 Sep 2008 17:16:15 +0000 Subject: mission targets, texture unloading, private messages --- src/core/gameinterface.cc | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) (limited to 'src/core/gameinterface.cc') diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc index 70224b0..17623f2 100644 --- a/src/core/gameinterface.cc +++ b/src/core/gameinterface.cc @@ -4,9 +4,11 @@ the terms of the GNU General Public License version 2 */ -#include +#include #include +#include +#include "auxiliary/functions.h" #include "core/application.h" #include "core/cvar.h" #include "core/func.h" @@ -19,13 +21,13 @@ namespace core { -const float MIN_DELTA = 10e-10; - -void func_list_model(std::string const &args) +void func_list_players(std::string const &args) { - model::Model::list(); + game()->list_players(); } +const float MIN_DELTA = 10e-10; + Player GameInterface::game_localplayer; EntityControlable *localcontrol() @@ -52,13 +54,14 @@ GameInterface::GameInterface() game_localplayer.player_name.assign("Player"); game_localplayer.update_info(); } - - Func::add("list_model", (FuncPtr) func_list_model); + + Func *func = Func::add("list_players", func_list_players); + func->set_info("get the local list of connected players"); } GameInterface::~GameInterface() { - Func::remove("list_model"); + Func::remove("list_players"); game_localplayer.clear(); @@ -105,6 +108,16 @@ void GameInterface::clear() // remove all models model::Model::clear(); + // clear player list + for (Players::iterator it = game_players.begin(); it != game_players.end(); it++) { + Player *player = (*it); + if (player != localplayer()) { + delete player; + } + } + + game_players.clear(); + game_previousframetime = 0; game_serverframetime = 0; game_clientframetime = 0; @@ -220,4 +233,19 @@ float GameInterface::timeoffset() { return t/d; } +void GameInterface::list_players() +{ + using namespace std; + stringstream msgstr; + int count = 0; + + for (Players::iterator it = game_players.begin(); it != game_players.end(); it++) { + msgstr.str(""); + con_print << setw(3) << (*it)->id() << aux::pad_left((*it)->name(), 24) << std::endl; + count++; + } + + con_print << count << " connected " << aux::plural("player", count) << std::endl; +} + } -- cgit v1.2.3