summaryrefslogtreecommitdiff
path: root/src/common/socket.h
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-09-21 19:10:31 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-09-21 19:10:31 +0000
commit1441a347a96cffe355f66c33578c5976b9f379a8 (patch)
tree683d285b4299ddc527482bb71baac925fae48cea /src/common/socket.h
parente00521c627d42b772497ba55490bf2095f700458 (diff)
downloadhercules-1441a347a96cffe355f66c33578c5976b9f379a8.tar.gz
hercules-1441a347a96cffe355f66c33578c5976b9f379a8.tar.bz2
hercules-1441a347a96cffe355f66c33578c5976b9f379a8.tar.xz
hercules-1441a347a96cffe355f66c33578c5976b9f379a8.zip
- Improved a bit RFIFOFLUSH as suggested by Harbin.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8838 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/socket.h')
-rw-r--r--src/common/socket.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/common/socket.h b/src/common/socket.h
index 502529419..2774b9c7f 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -38,7 +38,14 @@ extern time_t stall_time;
#define RFIFOW(fd,pos) (*(unsigned short*)RFIFOP(fd,pos))
#define RFIFOL(fd,pos) (*(unsigned long*)RFIFOP(fd,pos))
#define RFIFOREST(fd) (session[fd]->rdata_size-session[fd]->rdata_pos)
-#define RFIFOFLUSH(fd) (memmove(session[fd]->rdata,RFIFOP(fd,0),RFIFOREST(fd)),session[fd]->rdata_size=RFIFOREST(fd),session[fd]->rdata_pos=0)
+#define RFIFOFLUSH(fd) \
+ if(session[fd]->rdata_size == session[fd]->rdata_pos) \
+ { session[fd]->rdata_size = session[fd]->rdata_pos = 0; } else { \
+ session[fd]->rdata_size -= session[fd]->rdata_pos; \
+ memmove(session[fd]->rdata, session[fd]->rdata+session[fd]->rdata_pos, session[fd]->rdata_size); \
+ session[fd]->rdata_pos=0; \
+ }
+
//#define RFIFOSKIP(fd,len) ((session[fd]->rdata_size-session[fd]->rdata_pos-(len)<0) ? (fprintf(stderr,"too many skip\n"),exit(1)) : (session[fd]->rdata_pos+=(len)))
#define RBUFP(p,pos) (((unsigned char*)(p))+(pos))