From 48791b8a73f04b0c84587e328786e3505cb7db65 Mon Sep 17 00:00:00 2001 From: flowtron Date: Mon, 5 Jul 2010 18:08:11 +0000 Subject: [PATCH] commands "findcn"/"findpn" clientnum/playername query functions git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5283 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 366cbd72..547159de 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1177,19 +1177,24 @@ void whois(int cn) } COMMAND(whois, ARG_1INT); -int findcn(char *name) +void findcn(char *name) { - loopv(players) - { - if(players[i]) - { - if(!strcmp(name, players[i]->name)) return players[i]->clientnum; - } - } - return -1; + bool found = false; + loopv(players) { if(players[i]) { if(!strcmp(name, players[i]->name)) { found = true; intret(players[i]->clientnum); } } } + if(!found) if(!strcmp(name, player1->name)) { found = true; intret(player1->clientnum); } + if(!found) intret(-1); } COMMAND(findcn, ARG_1STR); +void findpn(int cn) +{ + bool found = false; + loopv(players) { if(players[i]) { if( players[i]->clientnum == cn) { found = true; result(players[i]->name); } } } + if(!found) if(player1->clientnum == cn) { found = true; result(player1->name); } + if(!found) result(""); +} +COMMAND(findpn, ARG_1INT); + int sessionid = 0; void setadmin(char *claim, char *password)