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.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index c18b1fa..687623e 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -113,6 +113,29 @@ void GameServer::abort()
server_running = false;
}
+Player *GameServer::find_player(std::string const search)
+{
+ std::istringstream searchstr(search);
+ int id = 0;
+ if (searchstr >> id) {
+ for (std::list<Player *>:: iterator it = players.begin(); it != players.end(); it++) {
+ if ((*it)->id() == id) {
+ return (*it);
+ }
+ }
+ }
+
+ if (search.size() <3)
+ return 0;
+
+ for (std::list<Player *>:: iterator it = players.begin(); it != players.end(); it++) {
+ if ((*it)->name().find(search) != std::string::npos)
+ return (*it);
+ }
+
+ return 0;
+}
+
void GameServer::list_players(Player *player)
{
using namespace std;