diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-04-05 18:49:57 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-04-05 18:49:57 +0000 |
commit | 88a5d0cdda513357496b9d53878618e1620f47e8 (patch) | |
tree | 4f3c2bedbac4b715ff783de5e1c8d1aefe4395af /src/common/utils.c | |
parent | a7fd6bfe9bcce1862b554f5841d9ff1aedf473e3 (diff) | |
download | hercules-88a5d0cdda513357496b9d53878618e1620f47e8.tar.gz hercules-88a5d0cdda513357496b9d53878618e1620f47e8.tar.bz2 hercules-88a5d0cdda513357496b9d53878618e1620f47e8.tar.xz hercules-88a5d0cdda513357496b9d53878618e1620f47e8.zip |
* 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
Diffstat (limited to 'src/common/utils.c')
-rw-r--r-- | src/common/utils.c | 46 |
1 files changed, 18 insertions, 28 deletions
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<num;icnt+=16) { - printf("\n%p ",&buffer[icnt]); - for (jcnt=icnt;jcnt<icnt+16;++jcnt) { + for (icnt = 0; icnt < num; icnt += 16) { + printf("\n%p ", &buffer[icnt]); + for (jcnt = icnt; jcnt < icnt + 16; ++jcnt) { if (jcnt < num) { - printf("%02hX ",buffer[jcnt]); + printf("%02hX ", buffer[jcnt]); } else printf(" "); } printf(" | "); - for (jcnt=icnt;jcnt<icnt+16;++jcnt) { + for (jcnt = icnt; jcnt < icnt + 16; ++jcnt) { if (jcnt < num) { if (buffer[jcnt] > 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) |