summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/data/session.c1
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/map.c68
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/parse.c6
-rw-r--r--src/map/parse.h1
-rw-r--r--src/map/send.c12
-rw-r--r--src/map/send.h1
-rw-r--r--src/map/struct/sessionext.h1
9 files changed, 93 insertions, 0 deletions
diff --git a/src/map/data/session.c b/src/map/data/session.c
index 81fe697..24c5ed2 100644
--- a/src/map/data/session.c
+++ b/src/map/data/session.c
@@ -43,5 +43,6 @@ struct SessionExt *session_create(void)
data->clientVersion = 0;
data->language = 0;
data->state = 0;
+ data->onlinelistlasttime = 0;
return data;
}
diff --git a/src/map/init.c b/src/map/init.c
index e5dff10..78bd14d 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -110,6 +110,8 @@ HPExport void plugin_init (void)
addPacket(0xb0c, -1, map_parse_pet_say, hpClif_Parse);
addPacket(0xb0d, 3, map_parse_pet_emote, hpClif_Parse);
addPacket(0xb0e, 4, map_parse_set_status, hpClif_Parse);
+ addPacket(0xb0f, 2, map_parse_get_online_list, hpClif_Parse);
+
addHookPre("pc->readparam", epc_readparam_pre);
addHookPre("pc->setregistry", epc_setregistry);
addHookPre("pc->equipitem_pos", epc_equipitem_pos);
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);
+}
diff --git a/src/map/map.h b/src/map/map.h
index 9c77905..3b9afce 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -5,5 +5,6 @@
#define EVOL_MAP_MAP
int emap_addflooritem_post(int retVal, struct item *item, int *amount, int16 *m, int16 *x, int16 *y, int *first_charid, int *second_charid, int *third_charid, int *flags);
+void emap_online_list(int fd);
#endif // EVOL_MAP_MAP
diff --git a/src/map/parse.c b/src/map/parse.c
index 7044197..3cef1f9 100644
--- a/src/map/parse.c
+++ b/src/map/parse.c
@@ -16,6 +16,7 @@
#include "map/parse.h"
#include "map/send.h"
+#include "map/map.h"
#include "map/data/session.h"
#include "map/struct/sessionext.h"
@@ -130,3 +131,8 @@ void map_parse_set_status(int fd)
struct SessionExt *data = session_get(fd);
data->state = RFIFOB(fd, 2);
}
+
+void map_parse_get_online_list(int fd)
+{
+ emap_online_list(fd);
+}
diff --git a/src/map/parse.h b/src/map/parse.h
index 75a0392..f1488dd 100644
--- a/src/map/parse.h
+++ b/src/map/parse.h
@@ -10,5 +10,6 @@ void map_parse_part_channel(int fd);
void map_parse_pet_say(int fd);
void map_parse_pet_emote(int fd);
void map_parse_set_status(int fd);
+void map_parse_get_online_list(int fd);
#endif // EVOL_MAP_PARSE
diff --git a/src/map/send.c b/src/map/send.c
index 7471c1f..067ff5f 100644
--- a/src/map/send.c
+++ b/src/map/send.c
@@ -273,6 +273,7 @@ void send_pet_say(struct map_session_data *sd, const char *const message)
snprintf(buf, len, "%s : %s", name, message);
buf[len - 1] = 0;
clif->GlobalMessage(&sd->pd->bl, buf);
+ aFree(buf);
}
void send_pet_emote(struct map_session_data *sd, const int emote)
@@ -282,3 +283,14 @@ void send_pet_emote(struct map_session_data *sd, const int emote)
clif->emotion(&sd->pd->bl, emote);
}
+
+void send_online_list(int fd, const char *buf, unsigned size)
+{
+ const unsigned int len = size + 4 + 1;
+ WFIFOHEAD (fd, len);
+ WFIFOW (fd, 0) = 0xb10;
+ WFIFOW (fd, 2) = len;
+ memcpy (WFIFOP (fd, 4), buf, size);
+ WFIFOB (fd, size + 4) = 0;
+ WFIFOSET (fd, len);
+}
diff --git a/src/map/send.h b/src/map/send.h
index efb63e7..54bd844 100644
--- a/src/map/send.h
+++ b/src/map/send.h
@@ -23,5 +23,6 @@ void send_npc_info(struct block_list* bl1,
enum send_target target);
void send_pet_say(struct map_session_data *sd, const char *const message);
void send_pet_emote(struct map_session_data *sd, const int emote);
+void send_online_list(int fd, const char *buf, unsigned size);
#endif // EVOL_MAP_PC
diff --git a/src/map/struct/sessionext.h b/src/map/struct/sessionext.h
index c742faa..a592e50 100644
--- a/src/map/struct/sessionext.h
+++ b/src/map/struct/sessionext.h
@@ -6,6 +6,7 @@
struct SessionExt
{
+ time_t onlinelistlasttime;
int clientVersion;
int language;
uint8 state;