Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-09-27 17:16:15 +0000
committerStijn Buys <ingar@osirion.org>2008-09-27 17:16:15 +0000
commitca0c1d3e6f8b5fa4eb2e0a86fcf47b12fb600786 (patch)
tree5d72e330f11350065806e83cc8712693241b9aad /src/core/gameinterface.cc
parent29984680d6e0e52efec489497b1796e056164442 (diff)
mission targets, texture unloading, private messages
Diffstat (limited to 'src/core/gameinterface.cc')
-rw-r--r--src/core/gameinterface.cc44
1 files changed, 36 insertions, 8 deletions
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 <stdlib.h>
+#include <cstdlib>
#include <iostream>
+#include <iomanip>
+#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;
+}
+
}