summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-02 22:55:06 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-02 22:55:06 +0300
commit1aba90595c3bc5b39186a2352971127ca715bd9e (patch)
treec40e71b4a92e0976442fa935014619ed2f3a6ca9
parent53edb4dd94fda5157944dbd0fc619f92ce4db500 (diff)
downloadevol-hercules-1aba90595c3bc5b39186a2352971127ca715bd9e.tar.gz
evol-hercules-1aba90595c3bc5b39186a2352971127ca715bd9e.tar.bz2
evol-hercules-1aba90595c3bc5b39186a2352971127ca715bd9e.tar.xz
evol-hercules-1aba90595c3bc5b39186a2352971127ca715bd9e.zip
trim and translate mob names before sending to client.
-rw-r--r--src/map/clif.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index ccf5502..84f8332 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11,6 +11,7 @@
#include "../../../common/socket.h"
#include "../../../common/strlib.h"
#include "../../../common/cbasetypes.h"
+#include "../../../map/mob.h"
#include "../../../map/npc.h"
#include "../../../map/pc.h"
#include "../../../map/quest.h"
@@ -125,6 +126,69 @@ void eclif_charnameack(int *fdPtr, struct block_list *bl)
}
hookStop();
}
+ else if (bl->type == BL_MOB)
+ {
+ struct mob_data *md = (struct mob_data *)bl;
+ if (!md)
+ {
+ hookStop();
+ return;
+ }
+ if (md->guardian_data && md->guardian_data->g)
+ return; // allow default code to work
+ int fd = *fdPtr;
+ TBL_PC* sd = (TBL_PC*)session[fd]->session_data;
+ if (!sd)
+ {
+ hookStop();
+ return;
+ }
+
+ char tmpBuf[25];
+ char *ptr = tmpBuf;
+ memcpy(tmpBuf, md->name, 24);
+ tmpBuf[24] = 0;
+ for (int f = 23; f > 1; f --)
+ {
+ if (tmpBuf[f] == ' ')
+ tmpBuf[f] = 0;
+ else
+ break;
+ }
+ for (int f = 0; f < 24; f ++)
+ {
+ if (*ptr == ' ')
+ ptr ++;
+ else
+ break;
+ }
+ const char *tr = lang_pctrans(ptr, sd);
+ const int trLen = strlen(tr);
+ const int len = 8 + trLen;
+
+ // if no recipient specified just update nearby clients
+ if (fd == 0)
+ {
+ char *buf;
+ CREATE(buf, char, len);
+ WBUFW(buf, 0) = 0xB01;
+ WBUFW(buf, 2) = len;
+ WBUFL(buf, 4) = bl->id;
+ memcpy(WBUFP(buf, 8), tr, trLen);
+ clif->send(buf, len, bl, AREA);
+ aFree(buf);
+ }
+ else
+ {
+ WFIFOHEAD(fd, len);
+ WFIFOW(fd, 0) = 0xB01;
+ WFIFOW(fd, 2) = len;
+ WFIFOL(fd, 4) = bl->id;
+ memcpy(WFIFOP(fd, 8), tr, trLen);
+ WFIFOSET(fd, len);
+ }
+ hookStop();
+ }
}
#define equipPos(index, field) \