summaryrefslogtreecommitdiff
path: root/src/char/inter.c
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-10-31 02:42:59 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-10-31 02:42:59 +0000
commitbfdd943126eb4227723fad000079fb73e1bd18b9 (patch)
tree6978be01d064b2c42fe2323bedfc3edc165682ec /src/char/inter.c
parent3ce90667d6a307bb09abad0f68412f0ab34d46e3 (diff)
downloadhercules-bfdd943126eb4227723fad000079fb73e1bd18b9.tar.gz
hercules-bfdd943126eb4227723fad000079fb73e1bd18b9.tar.bz2
hercules-bfdd943126eb4227723fad000079fb73e1bd18b9.tar.xz
hercules-bfdd943126eb4227723fad000079fb73e1bd18b9.zip
Improved char server packet 0x3087, gave it a variable/dynamic length so that it doesn't waste buffer size with messages too short.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16850 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char/inter.c')
-rw-r--r--src/char/inter.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/char/inter.c b/src/char/inter.c
index 8b66514e9..4cbb1e32b 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -419,19 +419,21 @@ const char* geoip_getcountry(uint32 ipnum){
void inter_to_fd(int fd, int u_fd, int aid, char* msg, ...) {
char msg_out[512];
va_list ap;
+ int len = 1;/* yes we start at 1 */
va_start(ap,msg);
- vsprintf(msg_out, msg, ap);
+ len += vsnprintf(msg_out, 512, msg, ap);
va_end(ap);
-
- WFIFOHEAD(fd,522);
+
+ WFIFOHEAD(fd,12 + len);
WFIFOW(fd,0) = 0x3807;
- WFIFOL(fd,2) = u_fd;
- WFIFOL(fd,6) = aid;
- safestrncpy((char*)WFIFOP(fd,10), msg_out, 512);
+ WFIFOW(fd,2) = 12 + (unsigned short)len;
+ WFIFOL(fd,4) = u_fd;
+ WFIFOL(fd,8) = aid;
+ safestrncpy((char*)WFIFOP(fd,12), msg_out, len);
- WFIFOSET(fd,522);
+ WFIFOSET(fd,12 + len);
return;
}