summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/socket.h18
-rw-r--r--src/map/clif.c4
2 files changed, 12 insertions, 10 deletions
diff --git a/src/common/socket.h b/src/common/socket.h
index e1ea94f5a..29f3eb3d7 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -50,13 +50,13 @@ struct config_setting_t;
#define RFIFOP(fd,pos) (sockt->session[fd]->rdata + sockt->session[fd]->rdata_pos + (pos))
#define WFIFOP(fd,pos) (sockt->session[fd]->wdata + sockt->session[fd]->wdata_size + (pos))
-#define RFIFOB(fd,pos) (*(uint8*)RFIFOP((fd),(pos)))
+#define RFIFOB(fd,pos) (*(const uint8*)RFIFOP((fd),(pos)))
#define WFIFOB(fd,pos) (*(uint8*)WFIFOP((fd),(pos)))
-#define RFIFOW(fd,pos) (*(uint16*)RFIFOP((fd),(pos)))
+#define RFIFOW(fd,pos) (*(const uint16*)RFIFOP((fd),(pos)))
#define WFIFOW(fd,pos) (*(uint16*)WFIFOP((fd),(pos)))
-#define RFIFOL(fd,pos) (*(uint32*)RFIFOP((fd),(pos)))
+#define RFIFOL(fd,pos) (*(const uint32*)RFIFOP((fd),(pos)))
#define WFIFOL(fd,pos) (*(uint32*)WFIFOP((fd),(pos)))
-#define RFIFOQ(fd,pos) (*(uint64*)RFIFOP((fd),(pos)))
+#define RFIFOQ(fd,pos) (*(const uint64*)RFIFOP((fd),(pos)))
#define WFIFOQ(fd,pos) (*(uint64*)WFIFOP((fd),(pos)))
#define RFIFOSPACE(fd) (sockt->session[fd]->max_rdata - sockt->session[fd]->rdata_size)
#define WFIFOSPACE(fd) (sockt->session[fd]->max_wdata - sockt->session[fd]->wdata_size)
@@ -85,11 +85,11 @@ struct config_setting_t;
#define WP2PTR(fd) WFIFO2PTR(fd)
// buffer I/O macros
-#define RBUFP(p,pos) (((const uint8*)(p)) + (pos))
-#define RBUFB(p,pos) (*(const uint8*)RBUFP((p),(pos)))
-#define RBUFW(p,pos) (*(const uint16*)RBUFP((p),(pos)))
-#define RBUFL(p,pos) (*(const uint32*)RBUFP((p),(pos)))
-#define RBUFQ(p,pos) (*(const uint64*)RBUFP((p),(pos)))
+#define RBUFP(p,pos) (((const uint8 *)(p)) + (pos))
+#define RBUFB(p,pos) (*(const uint8 *)RBUFP((p),(pos)))
+#define RBUFW(p,pos) (*(const uint16 *)RBUFP((p),(pos)))
+#define RBUFL(p,pos) (*(const uint32 *)RBUFP((p),(pos)))
+#define RBUFQ(p,pos) (*(const uint64 *)RBUFP((p),(pos)))
#define WBUFP(p,pos) (((uint8*)(p)) + (pos))
#define WBUFB(p,pos) (*(uint8*)WBUFP((p),(pos)))
diff --git a/src/map/clif.c b/src/map/clif.c
index a7d73d91f..a7d7dca97 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -18787,7 +18787,9 @@ int clif_parse(int fd) {
return 0; // not enough data received to form the packet
if( battle_config.packet_obfuscation == 2 || cmd != RFIFOW(fd, 0) || (sd && sd->parse_cmd_func == clif_parse_cmd_decrypt) ) {
- RFIFOW(fd, 0) = cmd;
+ // Note: Overriding const qualifier to re-inject the decoded packet ID.
+ int16 *packet_id = (int16 *)RFIFOP(fd, 0);
+ *packet_id = cmd;
if( sd ) {
sd->cryptKey = (( sd->cryptKey * clif->cryptKey[1] ) + clif->cryptKey[2]) & 0xFFFFFFFF; // Update key for the next packet
}