diff options
author | MadCamel <madcamel@gmail.com> | 2010-08-26 13:59:45 -0400 |
---|---|---|
committer | MadCamel <madcamel@gmail.com> | 2010-08-26 13:59:45 -0400 |
commit | e6958780f0266e20f86de79c50aa227a5612d605 (patch) | |
tree | ba7fa5ed20b62f4c2a78e56c136cdc3552008b7f | |
parent | 117ef86613f187f4afa88947f60cf4a683fb6ee7 (diff) | |
download | tmwa-e6958780f0266e20f86de79c50aa227a5612d605.tar.gz tmwa-e6958780f0266e20f86de79c50aa227a5612d605.tar.bz2 tmwa-e6958780f0266e20f86de79c50aa227a5612d605.tar.xz tmwa-e6958780f0266e20f86de79c50aa227a5612d605.zip |
Added ipcheck GM command
usage: ipcheck <char name>
This new command defaults to level 60 and displays all characters
currently online from the same IP address. It does not reveal the
actual IP address.
-rw-r--r-- | src/map/atcommand.c | 64 | ||||
-rw-r--r-- | src/map/atcommand.h | 1 |
2 files changed, 65 insertions, 0 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 8d69b21..21ce01d 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -209,6 +209,7 @@ ATCOMMAND_FUNC (skillpool_focus); // [Fate] ATCOMMAND_FUNC (skillpool_unfocus); // [Fate] ATCOMMAND_FUNC (skill_learn); // [Fate] ATCOMMAND_FUNC (wgm); +ATCOMMAND_FUNC (ipcheck); /*========================================== *AtCommandInfo atcommand_info[]構造体の定義 @@ -406,6 +407,7 @@ static AtCommandInfo atcommand_info[] = { {AtCommand_IterateBackward, "@sp-unfocus", 80, atcommand_skillpool_unfocus}, // [Fate] {AtCommand_IterateBackward, "@skill-learn", 80, atcommand_skill_learn}, // [Fate] {AtCommand_Wgm, "@wgm", 0, atcommand_wgm}, + {AtCommand_IpCheck, "@ipcheck", 60, atcommand_ipcheck}, // add new commands before this line {AtCommand_Unknown, NULL, 1, NULL} @@ -8503,6 +8505,7 @@ int atcommand_wgm (const int fd, struct map_session_data *sd, return 0; } + int atcommand_skillpool_info (const int fd, struct map_session_data *sd, const char *command, const char *message) { @@ -8635,3 +8638,64 @@ int atcommand_skill_learn (const int fd, struct map_session_data *sd, return 0; } + +int atcommand_ipcheck (const int fd, struct map_session_data *sd, + const char *command, const char *message) +{ + struct map_session_data *pl_sd; + struct sockaddr_in sai; + char output[200]; + char character[25]; + int i; + socklen_t sa_len = sizeof (struct sockaddr); + unsigned long ip; + + memset(character, '\0', sizeof(character)); + + if (sscanf (message, "%24[^\n]", character) < 1) + { + clif_displaymessage (fd, "Usage: @ipcheck <char name>"); + return -1; + } + + if ((pl_sd = map_nick2sd (character)) == NULL) + { + clif_displaymessage (fd, "Character not found."); + return -1; + } + + if (getpeername (pl_sd->fd, (struct sockaddr *)&sai, &sa_len)) + { + clif_displaymessage (fd, + "Guru Meditation Error: getpeername() failed"); + return -1; + } + + ip = sai.sin_addr.s_addr; + + // We now have the IP address of a character. + // Loop over all logged in sessions looking for matches. + + for (i = 0; i < fd_max; i++) + { + if (session[i] && (pl_sd = session[i]->session_data) + && pl_sd->state.auth) + { + if (getpeername (pl_sd->fd, (struct sockaddr *)&sai, &sa_len)) + continue; + + // Is checking GM levels really needed here? + if (ip == sai.sin_addr.s_addr) + { + snprintf (output, sizeof(output), + "Name: %s | Location: %s %d %d", + pl_sd->status.name, pl_sd->mapname, + pl_sd->bl.x, pl_sd->bl.y); + clif_displaymessage (fd, output); + } + } + } + + clif_displaymessage (fd, "End of list"); + return 0; +} diff --git a/src/map/atcommand.h b/src/map/atcommand.h index afb7db5..859ac6b 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -183,6 +183,7 @@ enum AtCommandType AtCommand_IterateForward, AtCommand_IterateBackward, AtCommand_Wgm, + AtCommand_IpCheck, AtCommand_ListNearby, // [fate] // end AtCommand_Unknown, |