summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-28 15:41:01 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-28 15:42:39 +0300
commit905642f167858017e1fa1582f6253da3c9a8ff97 (patch)
tree792d0cd12bab53cb03addb634ec0baa1cc2171ea
parent1ea90a6de5d0dc506b4be96ded4fe50e27df7e2b (diff)
downloadplugin-905642f167858017e1fa1582f6253da3c9a8ff97.tar.gz
plugin-905642f167858017e1fa1582f6253da3c9a8ff97.tar.bz2
plugin-905642f167858017e1fa1582f6253da3c9a8ff97.tar.xz
plugin-905642f167858017e1fa1582f6253da3c9a8ff97.zip
Send map mask to clients.
-rw-r--r--src/map/clif.c35
-rw-r--r--src/map/clif.h5
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/script.c10
-rw-r--r--src/map/send.c21
-rw-r--r--src/map/send.h2
6 files changed, 74 insertions, 1 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index c4766dc..3ceaabd 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -20,6 +20,8 @@
#include "map/mapd.h"
#include "map/mapdext.h"
#include "map/send.h"
+#include "map/session.h"
+#include "map/sessionext.h"
void eclif_quest_send_list(struct map_session_data *sd)
{
@@ -145,7 +147,20 @@ void eclif_getareachar_unit_post(struct map_session_data* sd, struct block_list
void eclif_authok_post(struct map_session_data *sd)
{
+ if (!sd)
+ return;
+
eclif_send_additional_slots(sd, sd);
+ struct MapdExt *data = mapd_get(sd->bl.m);
+ int mask = data ? data->mask : 1;
+ send_mapmask(sd->fd, mask);
+}
+
+void eclif_changemap_post(struct map_session_data *sd, short *m, int *x, int *y)
+{
+ struct MapdExt *data = mapd_get(sd->bl.m);
+ int mask = data ? data->mask : 1;
+ send_mapmask(sd->fd, mask);
}
void eclif_handle_invisible_map(struct block_list *bl, enum send_target target)
@@ -179,3 +194,23 @@ void eclif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, en
eclif_handle_invisible_map(bl, *target);
}
+
+int eclif_send_actual(int *fd, void *buf, int *len)
+{
+ if (*len >= 2)
+ {
+ const int packet = RBUFW (buf, 0);
+ if (packet == 0xb02)
+ {
+ struct SessionExt *data = session_get(*fd);
+ if (!data)
+ return 0;
+ if (data->clientVersion < 3)
+ { // not sending 0xb02 to old clients
+ hookStop();
+ return 0;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/map/clif.h b/src/map/clif.h
index 3180919..0699601 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -8,11 +8,14 @@ void eclif_quest_send_list(struct map_session_data *sd);
void eclif_quest_add(struct map_session_data *sd, struct quest *qd);
void eclif_charnameack(int *fdPtr, struct block_list *bl);
void eclif_getareachar_unit_post(struct map_session_data* sd, struct block_list *bl);
-void eclif_authok_post(struct map_session_data *sd);
void eclif_sendlook(struct block_list *bl, int *id, int *type,
int *val, int *val2, enum send_target *target);
bool eclif_send(const void* buf, int *len, struct block_list* bl, enum send_target *type);
void eclif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd,
enum send_target *target);
+int eclif_send_actual(int *fd, void *buf, int *len);
+
+void eclif_authok_post(struct map_session_data *sd);
+void eclif_changemap_post(struct map_session_data *sd, short *m, int *x, int *y);
#endif // EVOL_MAP_CLIF
diff --git a/src/map/init.c b/src/map/init.c
index 019f53c..e22bcba 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -94,9 +94,11 @@ HPExport void plugin_init (void)
addHookPre("clif->sendlook", eclif_sendlook);
addHookPre("clif->send", eclif_send);
addHookPre("clif->set_unit_idle", eclif_set_unit_idle);
+ addHookPre("clif->send_actual", eclif_send_actual);
addHookPost("clif->getareachar_unit", eclif_getareachar_unit_post);
addHookPost("clif->authok", eclif_authok_post);
+ addHookPost("clif->changemap", eclif_changemap_post);
langScriptId = script->add_str("Lang");
}
diff --git a/src/map/script.c b/src/map/script.c
index 93ca052..676d598 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -445,7 +445,10 @@ BUILDIN(setMapMask)
getMapData(m);
const int val = script_getnum(st, 3);
+ const unsigned int old = mapData->mask;
mapData->mask = val;
+ if (old != mapData->mask)
+ send_mapmask_brodcast(m, mapData->mask);
return true;
}
@@ -478,7 +481,11 @@ BUILDIN(addMapMask)
return false;
getMapData(m);
const int val = script_getnum(st, 3);
+ const unsigned int old = mapData->mask;
mapData->mask |= val;
+ if (old != mapData->mask)
+ send_mapmask_brodcast(m, mapData->mask);
+
return true;
}
@@ -492,7 +499,10 @@ BUILDIN(removeMapMask)
return false;
getMapData(m);
const int val = script_getnum(st, 3);
+ const unsigned int old = mapData->mask;
mapData->mask |= val;
mapData->mask ^= val;
+ if (old != mapData->mask)
+ send_mapmask_brodcast(m, mapData->mask);
return true;
}
diff --git a/src/map/send.c b/src/map/send.c
index 8e2f878..f923dbb 100644
--- a/src/map/send.c
+++ b/src/map/send.c
@@ -79,3 +79,24 @@ void send_changelook(int fd, int id, int type, int val)
WFIFOW (fd, 9) = 0;
WFIFOSET (fd, 11);
}
+
+void send_mapmask(int fd, int mask)
+{
+ WFIFOHEAD (fd, 10);
+ WFIFOW (fd, 0) = 0xb02;
+ WFIFOL (fd, 2) = mask;
+ WFIFOL (fd, 6) = 0;
+ WFIFOSET (fd, 10);
+}
+
+void send_mapmask_brodcast(const int map, const int mask)
+{
+ struct block_list bl;
+ char buf[10];
+
+ bl.m = map;
+ WBUFW (buf, 0) = 0xb02;
+ WBUFL (buf, 2) = mask;
+ WBUFL (buf, 6) = 0;
+ clif->send(buf, 10, &bl, ALL_SAMEMAP);
+}
diff --git a/src/map/send.h b/src/map/send.h
index afa0f3b..d79765a 100644
--- a/src/map/send.h
+++ b/src/map/send.h
@@ -8,5 +8,7 @@ void send_npccommand (struct map_session_data *sd, int npcId, int cmd);
void send_npccommand2 (struct map_session_data *sd, int npcId, int cmd, int id, int x, int y);
void send_local_message(int fd, struct block_list* bl, const char* msg);
void send_changelook(int fd, int id, int type, int val);
+void send_mapmask(int fd, int mask);
+void send_mapmask_brodcast(const int map, const int mask);
#endif // EVOL_MAP_PC