summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-01-29 11:48:42 +0100
committerHaru <haru@dotalux.com>2016-01-29 11:48:42 +0100
commit11a952e03a01ba9e7c9b9d3cd588cddef52082f8 (patch)
treec1eba9bf08048474b210175ae142a808d6a3079e /src/map/atcommand.c
parent1500f9a168d61f36e8b1167e964e73a4e764f974 (diff)
parentfb42b0d7cde6af0e10926682eaefe0e98aa8be33 (diff)
downloadhercules-11a952e03a01ba9e7c9b9d3cd588cddef52082f8.tar.gz
hercules-11a952e03a01ba9e7c9b9d3cd588cddef52082f8.tar.bz2
hercules-11a952e03a01ba9e7c9b9d3cd588cddef52082f8.tar.xz
hercules-11a952e03a01ba9e7c9b9d3cd588cddef52082f8.zip
Merge pull request #1105 from dastgir/20-SendFix
Fixes crash with @send
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 08119457d..bc539837d 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -260,24 +260,28 @@ ACMD(send)
if (type >= MIN_PACKET_DB && type <= MAX_PACKET_DB) {
int off = 2;
+ if (clif->packet(type) == NULL) {
+ // unknown packet - ERROR
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,905), type); // Unknown packet: 0x%x
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
if (len) {
// show packet length
safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, clif->packet(type)->len); // Packet 0x%x length: %d
clif->message(fd, atcmd_output);
return true;
}
-
+
len = clif->packet(type)->len;
- if (len == 0) {
- // unknown packet - ERROR
- safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,905), type); // Unknown packet: 0x%x
- clif->message(fd, atcmd_output);
- return false;
- } else if (len == -1) {
+
+ if (len == -1) {
// dynamic packet
len = SHRT_MAX-4; // maximum length
off = 4;
}
+
WFIFOHEAD(sd->fd, len);
WFIFOW(sd->fd,0)=TOW(type);