diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-20 15:36:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-20 15:43:11 +0300 |
commit | 60097ba0d9a71ab575c89a3d0162bb4df1cdc0ff (patch) | |
tree | 5efde0a4146398172ec80273db1f3eba8a8d8e6e /src/map/map.c | |
parent | c90ec19afcfc826a077ed300fc2a9f8347d9b1e6 (diff) | |
download | plugin-60097ba0d9a71ab575c89a3d0162bb4df1cdc0ff.tar.gz plugin-60097ba0d9a71ab575c89a3d0162bb4df1cdc0ff.tar.bz2 plugin-60097ba0d9a71ab575c89a3d0162bb4df1cdc0ff.tar.xz plugin-60097ba0d9a71ab575c89a3d0162bb4df1cdc0ff.zip |
Add support for online list packets.
Diffstat (limited to 'src/map/map.c')
-rw-r--r-- | src/map/map.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/map/map.c b/src/map/map.c index 5696723..1d18499 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5,6 +5,7 @@ #include <stdlib.h> #include <string.h> +#include "../../../common/db.h" #include "../../../common/HPMi.h" #include "../../../common/malloc.h" #include "../../../common/mmo.h" @@ -14,9 +15,14 @@ #include "../../../map/battle.h" #include "../../../map/itemdb.h" #include "../../../map/map.h" +#include "../../../map/pc.h" +#include "map/permission.h" +#include "map/send.h" #include "map/data/itemd.h" +#include "map/data/session.h" #include "map/struct/itemdext.h" +#include "map/struct/sessionext.h" int emap_addflooritem_post(int retVal, struct item *item, @@ -42,3 +48,65 @@ int emap_addflooritem_post(int retVal, } return retVal; } + +void emap_online_list(int fd) +{ + char *buf = aCalloc (1, 20000); + char *ptr = buf; + struct map_session_data* sd; + + + struct SessionExt *data1 = session_get(fd); + const time_t t = time(NULL); + if (data1->onlinelistlasttime + 15 >= t) + { // not more than 1 per 15 seconds + data1->onlinelistlasttime = t; + return; + } + + data1->onlinelistlasttime = t; + + DBIterator* iter = db_iterator(map->pc_db); + + for (sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter)) + { + if (!sd) + continue; + + if (ptr - buf > 19500) + break; + + struct SessionExt *data = session_get_bysd(sd); + // need skip invisible players + + uint8 state = data->state; + if (sd->status.sex == 1) + state |= 128; + else + state = (state | 128) ^ 128; + + if (pc_has_permission(sd, permission_send_gm_flag)) + state |= 64; + else + state = (state | 64) ^ 64; + + *ptr = state; + ptr ++; + + *ptr = sd->status.base_level; + ptr ++; + + // need permissions what allow show version. now show always + *ptr = data->clientVersion; + ptr ++; + + strcpy(ptr, sd->status.name); + ptr += strlen(sd->status.name); + *ptr = 0; + ptr ++; + + } + dbi_destroy(iter); + send_online_list(fd, buf, ptr - buf); + aFree(buf); +} |