diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 93a3ea00..cf5da65a 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -748,6 +748,13 @@ void clearvote() { DELETEP(curvote); DELETEP(calledvote); } COMMAND(callvote, ARG_3STR); COMMAND(vote, ARG_1INT); +void whois(int cn) +{ + addmsg(SV_WHOIS, "ri", cn); +} + +COMMAND(whois, ARG_1INT); + void setmaster(int claim) { addmsg(SV_SETMASTER, "ri", claim != 0 ? 1 : 0); diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 24485df8..4ec8507e 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -597,6 +597,15 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) voteresult(getint(p)); break; + case SV_WHOISINFO: + { + int cn = getint(p); + playerent *pl = cn == getclientnum() ? player1 : getclient(cn); + int ip = getint(p); + conoutf("WHOIS for client %d:\n\f5name\t%s\n\f5IP\t%d.%d.%d.%d", cn, pl ? colorname(pl) : "", ip&0xFF, ip<<8&0xFF, ip<<16&0xFF, ip<<24&0xFF); + break; + } + default: neterr("type"); return; diff --git a/source/src/protocol.cpp b/source/src/protocol.cpp index 0853930d..3af0fee5 100644 --- a/source/src/protocol.cpp +++ b/source/src/protocol.cpp @@ -118,6 +118,7 @@ char msgsizesl[] = // size inclusive message token, 0 for variable SV_SETMASTER, 2, SV_SETADMIN, 0, SV_SERVOPINFO, 3, SV_CALLVOTE, 0, SV_CALLVOTESUC, 1, SV_CALLVOTEERR, 2, SV_VOTE, 2, SV_VOTERESULT, 2, SV_FORCETEAM, 2, SV_AUTOTEAM, 2, + SV_WHOIS, 2, SV_WHOISINFO, 3, SV_CONNECT, 0, SV_CLIENT, 0, -1 diff --git a/source/src/protocol.h b/source/src/protocol.h index 3aaabcc7..9ea094b3 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -23,6 +23,7 @@ enum SV_SETMASTER, SV_SETADMIN, SV_SERVOPINFO, SV_CALLVOTE, SV_CALLVOTESUC, SV_CALLVOTEERR, SV_VOTE, SV_VOTERESULT, SV_FORCETEAM, SV_AUTOTEAM, + SV_WHOIS, SV_WHOISINFO, SV_CONNECT, SV_CLIENT }; diff --git a/source/src/server.cpp b/source/src/server.cpp index 79bb4d1a..ad049be7 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1294,6 +1294,13 @@ bool callvote(voteinfo *v) // true if a regular vote was called } } +void sendwhois(int sender, int cn) +{ + if(!valid_client(sender) || !valid_client(cn)) return; + if(clients[cn]->type == ST_TCPIP && clients[cn]->peer) + sendf(sender, 1, "ri3", SV_WHOISINFO, cn, clients[cn]->peer->address.host); +} + // sending of maps between clients string copyname; @@ -1420,7 +1427,7 @@ int checktype(int type, client *cl) static int edittypes[] = { SV_EDITENT, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE }; if(cl && smode!=1) loopi(sizeof(edittypes)/sizeof(int)) if(type == edittypes[i]) return -1; // server only messages - static int servtypes[] = { SV_INITS2C, SV_MAPRELOAD, SV_SERVMSG, SV_GIBDAMAGE, SV_DAMAGE, SV_HITPUSH, SV_SHOTFX, SV_DIED, SV_SPAWNSTATE, SV_FORCEDEATH, SV_ITEMACC, SV_ITEMSPAWN, SV_TIMEUP, SV_CDIS, SV_PONG, SV_RESUME, SV_FLAGINFO, SV_ARENAWIN, SV_CLIENT, SV_VOTERESULT }; + static int servtypes[] = { SV_INITS2C, SV_MAPRELOAD, SV_SERVMSG, SV_GIBDAMAGE, SV_DAMAGE, SV_HITPUSH, SV_SHOTFX, SV_DIED, SV_SPAWNSTATE, SV_FORCEDEATH, SV_ITEMACC, SV_ITEMSPAWN, SV_TIMEUP, SV_CDIS, SV_PONG, SV_RESUME, SV_FLAGINFO, SV_ARENAWIN, SV_CLIENT, SV_CALLVOTESUC, SV_CALLVOTEERR, SV_VOTERESULT, SV_WHOISINFO }; if(cl) loopi(sizeof(servtypes)/sizeof(int)) if(type == servtypes[i]) return -1; return type; } @@ -1769,6 +1776,12 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 break; } + case SV_WHOIS: + { + sendwhois(sender, getint(p)); + break; + } + default: { int size = msgsizelookup(type);