From 88a5d0cdda513357496b9d53878618e1620f47e8 Mon Sep 17 00:00:00 2001 From: ultramage Date: Thu, 5 Apr 2007 18:49:57 +0000 Subject: * Made a crazy attempt to at least partially synchronize login&char code * Major edit to the way the servers handle ip addresses, making them obey the "host byte order inside, network byte order outside" rule - hopefully covered all entry- and exit-points for IP address data - discovered several places where Gravity's client breaks the convention, will need to come up with a suitable countermeasure for that - other than that, the code should be portable, except for printing and ipban mask testing (those still assume a specific byte order) - tested both txt and sql in all usual situations; tested single- and multi-server setups, all seems to work (but watch out for hidden bugs!) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10162 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/utils.c | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) (limited to 'src/common/utils.c') diff --git a/src/common/utils.c b/src/common/utils.c index c06e57083..2f5cf8705 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -20,28 +20,28 @@ #include "../common/showmsg.h" #include "../common/cbasetypes.h" -void dump(unsigned char *buffer, int num) +void dump(unsigned char* buffer, int num) { - int icnt,jcnt; + int icnt, jcnt; printf(" Hex ASCII\n"); printf(" ----------------------------------------------- ----------------"); - for (icnt=0;icnt 31 && buffer[jcnt] < 127) - printf("%c",buffer[jcnt]); + printf("%c", buffer[jcnt]); else printf("."); } else @@ -266,30 +266,20 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) unsigned char GetByte(unsigned long val, size_t num) { - switch(num) - { - case 0: - return (unsigned char)((val & 0x000000FF) ); - case 1: - return (unsigned char)((val & 0x0000FF00)>>0x08); - case 2: - return (unsigned char)((val & 0x00FF0000)>>0x10); - case 3: - return (unsigned char)((val & 0xFF000000)>>0x18); - default: - return 0; //better throw something here + switch(num) { + case 0: return (unsigned char)((val & 0x000000FF) ); + case 1: return (unsigned char)((val & 0x0000FF00)>>0x08); + case 2: return (unsigned char)((val & 0x00FF0000)>>0x10); + case 3: return (unsigned char)((val & 0xFF000000)>>0x18); + default: return 0; //better throw something here } } unsigned short GetWord(unsigned long val, size_t num) { - switch(num) - { - case 0: - return (unsigned short)((val & 0x0000FFFF) ); - case 1: - return (unsigned short)((val & 0xFFFF0000)>>0x10); - default: - return 0; //better throw something here + switch(num) { + case 0: return (unsigned short)((val & 0x0000FFFF) ); + case 1: return (unsigned short)((val & 0xFFFF0000)>>0x10); + default: return 0; //better throw something here } } unsigned short MakeWord(unsigned char byte0, unsigned char byte1) -- cgit v1.2.3-60-g2f50