summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c25
-rw-r--r--src/common/HPM.c4
-rw-r--r--src/common/HPM.h2
-rw-r--r--src/login/login.c12
-rw-r--r--src/map/chrif.c6
-rw-r--r--src/map/clif.c16
6 files changed, 33 insertions, 32 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 09f74034c..d05d13d4b 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2637,11 +2637,11 @@ int char_parse_fromlogin(int fd) {
}
}
- while(RFIFOREST(fd) >= 2) {
+ while (RFIFOREST(fd) >= 2) {
uint16 command = RFIFOW(fd,0);
if (VECTOR_LENGTH(HPM->packets[hpParse_FromLogin]) > 0) {
- int result = HPM->parse_packets(fd,hpParse_FromLogin);
+ int result = HPM->parse_packets(fd,command,hpParse_FromLogin);
if (result == 1)
continue;
if (result == 2)
@@ -3926,16 +3926,17 @@ int char_parse_frommap(int fd)
return 0;
}
- while(RFIFOREST(fd) >= 2) {
+ while (RFIFOREST(fd) >= 2) {
+ int packet_id = RFIFOW(fd,0);
if (VECTOR_LENGTH(HPM->packets[hpParse_FromMap]) > 0) {
- int result = HPM->parse_packets(fd,hpParse_FromMap);
+ int result = HPM->parse_packets(fd,packet_id,hpParse_FromMap);
if (result == 1)
continue;
if (result == 2)
return 0;
}
- switch(RFIFOW(fd,0)) {
+ switch (packet_id) {
case 0x2b0a:
if( RFIFOREST(fd) < RFIFOW(fd, 2) )
return 0;
@@ -5106,21 +5107,21 @@ int char_parse_char(int fd)
return 0;
}
- while( RFIFOREST(fd) >= 2 ) {
- //For use in packets that depend on an sd being present [Skotlex]
- #define FIFOSD_CHECK(rest) do { if(RFIFOREST(fd) < (rest)) return 0; if (sd==NULL || !sd->auth) { RFIFOSKIP(fd,(rest)); return 0; } } while (0)
+ while (RFIFOREST(fd) >= 2) {
+ cmd = RFIFOW(fd,0);
+
+//For use in packets that depend on an sd being present [Skotlex]
+#define FIFOSD_CHECK(rest) do { if(RFIFOREST(fd) < (rest)) return 0; if (sd==NULL || !sd->auth) { RFIFOSKIP(fd,(rest)); return 0; } } while (0)
if (VECTOR_LENGTH(HPM->packets[hpParse_Char]) > 0) {
- int result = HPM->parse_packets(fd,hpParse_Char);
+ int result = HPM->parse_packets(fd,cmd,hpParse_Char);
if (result == 1)
continue;
if (result == 2)
return 0;
}
- cmd = RFIFOW(fd,0);
-
- switch( cmd ) {
+ switch (cmd) {
// request to connect
// 0065 <account id>.L <login id1>.L <login id2>.L <???>.W <sex>.B
case 0x65:
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 62ef54499..d9c3262d7 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -718,13 +718,13 @@ CPCMD(plugins)
* @retval 1 OK
* @retval 2 incomplete packet
*/
-unsigned char hplugins_parse_packets(int fd, enum HPluginPacketHookingPoints point)
+unsigned char hplugins_parse_packets(int fd, int packet_id, enum HPluginPacketHookingPoints point)
{
struct HPluginPacket *packet = NULL;
int i;
int16 length;
- ARR_FIND(0, VECTOR_LENGTH(HPM->packets[point]), i, VECTOR_INDEX(HPM->packets[point], i).cmd == RFIFOW(fd,0));
+ ARR_FIND(0, VECTOR_LENGTH(HPM->packets[point]), i, VECTOR_INDEX(HPM->packets[point], i).cmd == packet_id);
if (i == VECTOR_LENGTH(HPM->packets[point]))
return 0;
diff --git a/src/common/HPM.h b/src/common/HPM.h
index 215161a86..109549aad 100644
--- a/src/common/HPM.h
+++ b/src/common/HPM.h
@@ -157,7 +157,7 @@ struct HPM_interface {
void (*share) (void *value, const char *name);
void (*config_read) (void);
char *(*pid2name) (unsigned int pid);
- unsigned char (*parse_packets) (int fd, enum HPluginPacketHookingPoints point);
+ unsigned char (*parse_packets) (int fd, int packet_id, enum HPluginPacketHookingPoints point);
void (*load_sub) (struct hplugin *plugin);
bool (*addhook_sub) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID);
/* for custom config parsing */
diff --git a/src/login/login.c b/src/login/login.c
index 7ed0ada89..d4768df86 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -808,18 +808,18 @@ int login_parse_fromchar(int fd)
ipl = server[id].ip;
sockt->ip2str(ipl, ip);
- while( RFIFOREST(fd) >= 2 ) {
+ while (RFIFOREST(fd) >= 2) {
uint16 command = RFIFOW(fd,0);
if (VECTOR_LENGTH(HPM->packets[hpParse_FromChar]) > 0) {
- int result = HPM->parse_packets(fd,hpParse_FromChar);
+ int result = HPM->parse_packets(fd,command,hpParse_FromChar);
if (result == 1)
continue;
if (result == 2)
return 0;
}
- switch( command ) {
+ switch (command) {
case 0x2712: // request from char-server to authenticate an account
if( RFIFOREST(fd) < 23 )
@@ -1619,18 +1619,18 @@ int login_parse_login(int fd)
sd->fd = fd;
}
- while( RFIFOREST(fd) >= 2 ) {
+ while (RFIFOREST(fd) >= 2) {
uint16 command = RFIFOW(fd,0);
if (VECTOR_LENGTH(HPM->packets[hpParse_Login]) > 0) {
- int result = HPM->parse_packets(fd,hpParse_Login);
+ int result = HPM->parse_packets(fd,command,hpParse_Login);
if (result == 1)
continue;
if (result == 2)
return 0;
}
- switch( command ) {
+ switch (command) {
case 0x0200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive.
if (RFIFOREST(fd) < 26)
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 1f7fbe96e..258d550d4 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1394,16 +1394,16 @@ int chrif_parse(int fd) {
}
while (RFIFOREST(fd) >= 2) {
+ cmd = RFIFOW(fd,0);
+
if (VECTOR_LENGTH(HPM->packets[hpChrif_Parse]) > 0) {
- int result = HPM->parse_packets(fd,hpChrif_Parse);
+ int result = HPM->parse_packets(fd,cmd,hpChrif_Parse);
if (result == 1)
continue;
if (result == 2)
return 0;
}
- cmd = RFIFOW(fd,0);
-
if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(chrif->packet_len_table) || chrif->packet_len_table[cmd-0x2af8] == 0) {
int result = intif->parse(fd); // Passed on to the intif
diff --git a/src/map/clif.c b/src/map/clif.c
index 3b15265f7..817579e23 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -18745,21 +18745,21 @@ int clif_parse(int fd) {
if (RFIFOREST(fd) < 2)
return 0;
+ if (sd)
+ parse_cmd_func = sd->parse_cmd_func;
+ else
+ parse_cmd_func = clif->parse_cmd;
+
+ cmd = parse_cmd_func(fd,sd);
+
if (VECTOR_LENGTH(HPM->packets[hpClif_Parse]) > 0) {
- int result = HPM->parse_packets(fd,hpClif_Parse);
+ int result = HPM->parse_packets(fd,cmd,hpClif_Parse);
if (result == 1)
continue;
if (result == 2)
return 0;
}
- if( sd )
- parse_cmd_func = sd->parse_cmd_func;
- else
- parse_cmd_func = clif->parse_cmd;
-
- cmd = parse_cmd_func(fd,sd);
-
// filter out invalid / unsupported packets
if (cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packet_db[cmd].len == 0) {
ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x (0x%04x), %"PRIuS" bytes received), disconnecting session #%d.\n",