summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorAnnieRuru <jeankof@ymail.com>2015-12-14 22:55:58 +0800
committerHaru <haru@dotalux.com>2015-12-20 16:38:02 +0100
commit23235fab728d1ac5cba1bfefc4209c7c9ae209fb (patch)
tree0a4e3323ef1067a80cc2434540387745ab3a0193 /src/map/script.c
parent879915527ac3462d25c34a69ca2165a14ce6cbe3 (diff)
downloadhercules-23235fab728d1ac5cba1bfefc4209c7c9ae209fb.tar.gz
hercules-23235fab728d1ac5cba1bfefc4209c7c9ae209fb.tar.bz2
hercules-23235fab728d1ac5cba1bfefc4209c7c9ae209fb.tar.xz
hercules-23235fab728d1ac5cba1bfefc4209c7c9ae209fb.zip
Fix the *getcharip
-> it uses the dirties method to search for player -> seriously ? why have to search account_id AND char_id ? -> if the char_id gone big enough, it can reach to account_id
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 2123c6789..4010a7398 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -18365,20 +18365,27 @@ BUILDIN(getcharip) {
struct map_session_data* sd = NULL;
/* check if a character name is specified */
- if( script_hasdata(st, 2) ) {
+ if (script_hasdata(st, 2)) {
if (script_isstringtype(st, 2)) {
sd = map->nick2sd(script_getstr(st, 2));
} else {
int id = script_getnum(st, 2);
sd = (map->id2sd(id) ? map->id2sd(id) : map->charid2sd(id));
}
- } else {
- sd = script->rid2sd(st);
+ } else if ((sd = script->rid2sd(st)) == NULL) {
+ script_pushconststr(st, "");
+ return true;
}
- /* check for sd and IP */
- if (!sd || !sockt->session[sd->fd]->client_addr)
- {
+ if (sd == NULL) {
+ ShowWarning("buildin_getcharip: Player not found!\n");
+ script_pushconststr(st, "");
+ script->reportfunc(st);
+ return false;
+ }
+
+ /* check for IP */
+ if (!sockt->session[sd->fd]->client_addr) {
script_pushconststr(st, "");
return true;
}