summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-30 17:11:40 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-30 17:48:44 +0300
commit5232d8fa98cbfb7a85e15b182eeb1e22d5b7376a (patch)
tree02fb3608af73a948adef7787e8f2ffd562b3c7d1 /src
parent4597146d5a26105130d2181cfae5403bd3013366 (diff)
downloadevol-hercules-5232d8fa98cbfb7a85e15b182eeb1e22d5b7376a.tar.gz
evol-hercules-5232d8fa98cbfb7a85e15b182eeb1e22d5b7376a.tar.bz2
evol-hercules-5232d8fa98cbfb7a85e15b182eeb1e22d5b7376a.tar.xz
evol-hercules-5232d8fa98cbfb7a85e15b182eeb1e22d5b7376a.zip
map: send full moving path to client.
Also fix memory issue in string translation.
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c23
-rw-r--r--src/map/clif.h3
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/send.c31
-rw-r--r--src/map/send.h1
5 files changed, 55 insertions, 5 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index f92a9f7..4e7f47b 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -78,7 +78,8 @@ void eclif_charnameack(int *fdPtr, struct block_list *bl)
int fd = *fdPtr;
struct map_session_data* sd = (struct map_session_data*)session[fd]->session_data;
const char *tr = lang_pctrans(((TBL_NPC*)bl)->name, sd);
- const int len = 8 + strlen(tr) + 1;
+ const int trLen = strlen(tr);
+ const int len = 8 + trLen + 1;
// if no recipient specified just update nearby clients
if (fd == 0)
{
@@ -87,7 +88,7 @@ void eclif_charnameack(int *fdPtr, struct block_list *bl)
WBUFW(buf, 0) = 0xB01;
WBUFW(buf, 2) = len;
WBUFL(buf, 4) = bl->id;
- memcpy(WBUFP(buf, 8), tr, len);
+ memcpy(WBUFP(buf, 8), tr, trLen);
clif->send(buf, len, bl, AREA);
aFree(buf);
}
@@ -97,7 +98,7 @@ void eclif_charnameack(int *fdPtr, struct block_list *bl)
WFIFOW(fd, 0) = 0xB01;
WFIFOW(fd, 2) = len;
WFIFOL(fd, 4) = bl->id;
- memcpy(WFIFOP(fd, 8), tr, len);
+ memcpy(WFIFOP(fd, 8), tr, trLen);
WFIFOSET(fd, len);
}
}
@@ -182,7 +183,7 @@ void eclif_sendlook(struct block_list *bl, int *id, int *type, int *val, int *va
bool eclif_send(const void* buf, int *len, struct block_list* bl, enum send_target *type)
{
if (*type == SELF)
- return;
+ return true;
eclif_handle_invisible_map(bl, *type);
return true;
}
@@ -200,13 +201,14 @@ int eclif_send_actual(int *fd, void *buf, int *len)
if (*len >= 2)
{
const int packet = RBUFW (buf, 0);
- if (packet == 0xb02 || packet == 0xb03)
+ if (packet >= 0xb02 && packet <= 0xb05)
{
struct SessionExt *data = session_get(*fd);
if (!data)
return 0;
if (data->clientVersion < 3)
{ // not sending new packets to old clients
+ ShowWarning("skip packet %d\n", packet);
hookStop();
return 0;
}
@@ -224,3 +226,14 @@ void eclif_set_unit_idle_post(struct block_list* bl, struct map_session_data *ts
if (bl->type == BL_MOB && tsd)
send_mob_info(bl, tsd ? &tsd->bl : bl, *target);
}
+
+void eclif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
+ struct unit_data* ud, enum send_target *target)
+{
+ send_advmoving(ud, tsd ? &tsd->bl : bl, *target);
+}
+
+void eclif_move(struct unit_data *ud)
+{
+ send_advmoving(ud, ud->bl, AREA_WOS);
+}
diff --git a/src/map/clif.h b/src/map/clif.h
index 3b28390..79da4a4 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -19,5 +19,8 @@ void eclif_authok_post(struct map_session_data *sd);
void eclif_changemap_post(struct map_session_data *sd, short *m, int *x, int *y);
void eclif_set_unit_idle_post(struct block_list* bl, struct map_session_data *tsd,
enum send_target *target);
+void eclif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
+ struct unit_data* ud, enum send_target *target);
+void eclif_move(struct unit_data *ud);
#endif // EVOL_MAP_CLIF
diff --git a/src/map/init.c b/src/map/init.c
index fb91cfe..2794692 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -115,6 +115,8 @@ HPExport void plugin_init (void)
addHookPost("clif->changemap", eclif_changemap_post);
addHookPost("clif->set_unit_idle", eclif_set_unit_idle_post);
addHookPost("status->set_viewdata", estatus_set_viewdata_post);
+ addHookPost("clif->set_unit_walking", eclif_set_unit_walking);
+ addHookPost("clif->move", eclif_move);
langScriptId = script->add_str("Lang");
}
diff --git a/src/map/send.c b/src/map/send.c
index 59402ad..b3ab051 100644
--- a/src/map/send.c
+++ b/src/map/send.c
@@ -12,6 +12,7 @@
#include "../../../common/strlib.h"
#include "../../../map/mob.h"
#include "../../../map/pc.h"
+#include "../../../map/unit.h"
#include "map/send.h"
@@ -119,3 +120,33 @@ void send_mob_info(struct block_list* bl1, struct block_list* bl2,
clif->send(&buf, sizeof(buf), bl2, target);
}
+
+void send_advmoving(struct unit_data* ud, struct block_list *tbl, enum send_target target)
+{
+ if (!ud)
+ return;
+
+ struct block_list *bl = ud->bl;
+
+ if (ud->walkpath.path_len <= ud->walkpath.path_pos)
+ return;
+ const bool haveMoves = (ud->walkpath.path_len > ud->walkpath.path_pos);
+
+ int i = 14;
+ const int len = ud->walkpath.path_len - ud->walkpath.path_pos;
+ if (haveMoves)
+ i += len;
+
+ char *buf;
+ CREATE(buf, char, i);
+ WBUFW (buf, 0) = 0xb04;
+ WBUFW (buf, 2) = i;
+ WBUFL (buf, 4) = bl->id;
+ WBUFW (buf, 8) = status->get_speed(bl);
+ WBUFW (buf, 10) = bl->x;
+ WBUFW (buf, 12) = bl->y;
+ if (haveMoves)
+ memcpy(buf + 14, ud->walkpath.path + ud->walkpath.path_pos, len);
+ clif->send(buf, i, tbl, target);
+ aFree(buf);
+}
diff --git a/src/map/send.h b/src/map/send.h
index 05b20f1..d66bca0 100644
--- a/src/map/send.h
+++ b/src/map/send.h
@@ -11,5 +11,6 @@ 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);
void send_mob_info(struct block_list* bl1, struct block_list* bl2, enum send_target target);
+void send_advmoving(struct unit_data* ud, struct block_list *tbl, enum send_target target);
#endif // EVOL_MAP_PC