summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-11-22 16:34:34 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-11-22 16:34:34 +0000
commit3fe27e962cf2084d380b6229fcc07c47d0c51e67 (patch)
tree497f03f5e6b44a028506655786fcd223c0fb2913 /src/map/clif.c
parent825b015a7f9e2179e593f417658ec36e484e1e6d (diff)
downloadhercules-3fe27e962cf2084d380b6229fcc07c47d0c51e67.tar.gz
hercules-3fe27e962cf2084d380b6229fcc07c47d0c51e67.tar.bz2
hercules-3fe27e962cf2084d380b6229fcc07c47d0c51e67.tar.xz
hercules-3fe27e962cf2084d380b6229fcc07c47d0c51e67.zip
- Recoded @send so that it uses clif.c instead of doing all the WFIFO stuff itself.
- Cleaned up a bunch of very uglily coded atcommands which used the rather pointless charid2sessionid and accountid2sessionid functions. - Some miscellanous cleanups around usage of the session[] variable. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9293 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 548369d5d..8e468515d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -618,6 +618,47 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
return 0;
}
+//For use in the @send command.
+int clif_send_debug(struct map_session_data *sd, int cmd, int* args, int args_num)
+{
+ int fd = sd->fd;
+ int len;
+ if (cmd < 0 || cmd >= MAX_PACKET_DB)
+ return 0;
+
+ len = packet_db[sd->packet_ver][cmd].len;
+
+ if (!fd || !len || len == -1) //len -1, variable width, not supported!
+ return 0;
+
+ switch (cmd)
+ {
+ case 0x209:
+ {
+ WFIFOHEAD(fd, len);
+ WFIFOW(fd,0) = 0x209;
+ WFIFOW(fd,2) = 2;
+ memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
+ WFIFOSET(fd, len);
+ break;
+ }
+ default:
+ {
+ int i;
+ WFIFOHEAD(fd, len);
+ memset(WFIFOP(fd,0), 0, len);
+ WFIFOW(fd,0) = cmd;
+ //Packet can only have len/2 arguments. Since each arg is a Word
+ if (args_num > len/2 -2)
+ args_num = len/2 -2;
+ for(i=0; i<args_num; i++)
+ WFIFOW(fd,i+1) = args[i];
+ WFIFOSET(fd, len);
+ break;
+ }
+ }
+ return 1;
+}
//
// パケット作って送信
//
@@ -4234,7 +4275,7 @@ int clif_01ac(struct block_list *bl)
sd=va_arg(ap,struct map_session_data*);
- if (sd == NULL || session[sd->fd] == NULL)
+ if (sd == NULL || !sd->fd || session[sd->fd] == NULL)
return 0;
switch(bl->type){