Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/gameserver.cc')
-rw-r--r--src/core/gameserver.cc30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 7e03c61..c18b1fa 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -104,6 +104,8 @@ GameServer::~GameServer()
Func::remove("who");
server_instance = 0;
+
+ players.clear();
}
void GameServer::abort()
@@ -114,26 +116,16 @@ void GameServer::abort()
void GameServer::list_players(Player *player)
{
using namespace std;
-
stringstream msgstr;
int count = 0;
- if (!Cvar::sv_dedicated->value()) {
- msgstr << setw(3) << localplayer()->id() << aux::spaces(localplayer()->name(), 24);
+ for (std::list<Player *>:: iterator it = players.begin(); it != players.end(); it++) {
+ msgstr.str("");
+ msgstr << setw(3) << (*it)->id() << aux::spaces((*it)->name(), 24);
send(player, msgstr.str());
count++;
}
- if (server_network) {
- std::list<NetClient *>:: iterator it;
- for (it = server_network->clients.begin(); it != server_network->clients.end(); it++) {
- msgstr.str("");
- msgstr << setw(3) << (*it)->player()->id() << aux::spaces((*it)->player()->name(), 24);
- send(player, msgstr.str());
- count++;
- }
- }
-
msgstr.str("");
msgstr << count << " connected " << aux::plural("player", count);
send(player, msgstr.str());
@@ -270,7 +262,8 @@ void GameServer::player_connect(Player *player)
// notify the game module
server_module->player_connect(player);
- // TODO manage player list
+ // manage player list
+ players.push_back(player);
}
void GameServer::player_disconnect(Player *player)
@@ -283,7 +276,14 @@ void GameServer::player_disconnect(Player *player)
// notify the game module
server_module->player_disconnect(player);
- // TODO manage player list
+ // manage player list
+ std::list<Player *>:: iterator it = players.begin();
+ while (((*it)->id() != player->id()) && (it != players.end())) {
+ it++;
+ }
+ if (it != players.end()) {
+ players.erase(it);
+ }
}
void GameServer::frame(float seconds)