From 9701fe324412112c6288afbc956b299f2b9cc779 Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 21 Jan 2014 12:34:46 +0100 Subject: Fixed --disable-packetver-re / --enable-packetver-re in ./configure - Follow-up to c50e094dff1898badd4136d9cdeb7318c803cb61 Signed-off-by: Haru --- src/common/mmo.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/mmo.h b/src/common/mmo.h index 670c2f7f7..573962601 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -51,9 +51,11 @@ #define PACKETVER 20131223 #endif // PACKETVER -#ifndef DISABLE_PACKETVER_RE - //Uncomment the following line if your client is ragexeRE instead of ragexe (required because of conflicting packets in ragexe vs ragexeRE). - //#define PACKETVER_RE +//Uncomment the following line if your client is ragexeRE instead of ragexe (required because of conflicting packets in ragexe vs ragexeRE). +//#define ENABLE_PACKETVER_RE +#ifdef ENABLE_PACKETVER_RE + #define PACKETVER_RE + #undef ENABLE_PACKETVER_RE #endif // DISABLE_PACKETVER_RE // Client support for experimental RagexeRE UI present in 2012-04-10 and 2012-04-18 -- cgit v1.2.3-70-g09d2 From 22b7f90297184775ad94d8cb4806e8664c78d934 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 20 Jan 2014 15:56:09 +0100 Subject: Minor fixes to the strlib interface - Fixed a typo in the strnlen() macro (was strnln) - Initialized strlib->strnlen and strlib->strtoull to NULL on platforms that don't require them. Please note that those two functions are supposed to never be called directly but only through the strnlen() and strtoull() macros, which take care of the platform abstraction. - Removed localized versions of yes/no from config_switch (if you really want to be able to use "oui", "ja", "si", "non", "nein", feel free to add them back yourself following the example in strlib.c) Signed-off-by: Haru --- src/common/strlib.c | 34 +++++++++++++++++++++++++--------- src/common/strlib.h | 2 +- 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'src/common') diff --git a/src/common/strlib.c b/src/common/strlib.c index 0f68eb206..361595b07 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -240,16 +240,19 @@ char* _strtok_r(char *s1, const char *s2, char **lasts) { } #endif +// TODO: The _MSC_VER check can probably be removed (we no longer support VS +// versions <= 2003, do we?), but this implementation might be still necessary +// for NetBSD 5.x and possibly some Solaris versions. #if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) /* Find the length of STRING, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ -size_t strnlen (const char* string, size_t maxlen) -{ - const char* end = (const char*)memchr(string, '\0', maxlen); - return end ? (size_t) (end - string) : maxlen; +size_t strnlen(const char* string, size_t maxlen) { + const char* end = (const char*)memchr(string, '\0', maxlen); + return end ? (size_t) (end - string) : maxlen; } #endif +// TODO: This should probably be removed, I don't think we support MSVC++ 6.0 anymore. #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 uint64 strtoull(const char* str, char** endptr, int base) { @@ -331,13 +334,22 @@ int e_mail_check(char* email) //-------------------------------------------------- // Return numerical value of a switch configuration -// on/off, english, français, deutsch, español +// on/off, yes/no, true/false, number //-------------------------------------------------- -int config_switch(const char* str) -{ - if (strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0) +int config_switch(const char* str) { + size_t len = strlen(str); + if ((len == 2 && strcmpi(str, "on") == 0) + || (len == 3 && strcmpi(str, "yes") == 0) + || (len == 4 && strcmpi(str, "true") == 0) + // || (len == 3 && strcmpi(str, "oui") == 0) // Uncomment and edit to add your own localized versions + ) return 1; - if (strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0) + + if ((len == 3 && strcmpi(str, "off") == 0) + || (len == 2 && strcmpi(str, "no") == 0) + || (len == 5 && strcmpi(str, "false") == 0) + // || (len == 3 && strcmpi(str, "non") == 0) // Uncomment and edit to add your own localized versions + ) return 0; return (int)strtol(str, NULL, 0); @@ -1119,10 +1131,14 @@ void strlib_defaults(void) { #if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) strlib->strnlen = strnlen; +#else + strlib->strnlen = NULL; #endif #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 strlib->strtoull = strtoull; +#else + strlib->strtoull = NULL; #endif strlib->e_mail_check = e_mail_check; strlib->config_switch = config_switch; diff --git a/src/common/strlib.h b/src/common/strlib.h index 5336260f6..7a1066401 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -175,7 +175,7 @@ void strlib_defaults(void); #define stristr(haystack,needle) (strlib->stristr((haystack),(needle))) #if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) - #define strnln(string,maxlen) (strlib->strnlen((string),(maxlen))) + #define strnlen(string,maxlen) (strlib->strnlen((string),(maxlen))) #endif #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 -- cgit v1.2.3-70-g09d2 From e68d860dbaa6b1bcf8104463cd3001ae946b7d4e Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 23 Jan 2014 16:51:56 +0100 Subject: Compatibility fixes for NetBSD and Solaris - Fixed some warnings in NetBSD (5.x and 6.x) and Solaris (11) Signed-off-by: Haru --- src/common/cbasetypes.h | 5 +++++ src/map/clif.c | 4 ++++ src/map/npc.c | 4 ++-- src/map/packets_struct.h | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 120f4f861..977897506 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -42,6 +42,11 @@ #define __DARWIN__ #endif +// Necessary for __NetBSD_Version__ (defined as VVRR00PP00) on NetBSD +#ifdef __NETBSD__ +#include +#endif // __NETBSD__ + // 64bit OS #if defined(_M_IA64) || defined(_M_X64) || defined(_WIN64) || defined(_LP64) || defined(_ILP64) || defined(__LP64__) || defined(__ppc64__) #define __64BIT__ diff --git a/src/map/clif.c b/src/map/clif.c index 5f835a8ab..fe3e7cfe9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12959,14 +12959,18 @@ bool clif_validate_emblem(const uint8 *emblem, unsigned long emblem_len) { BITMAP_WIDTH = 24, BITMAP_HEIGHT = 24, }; +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(push, 1) +#endif // not NetBSD < 6 / Solaris struct s_bitmaptripple { //uint8 b; //uint8 g; //uint8 r; unsigned int rgb:24; } __attribute__((packed)); +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) +#endif // not NetBSD < 6 / Solaris uint8 buf[1800]; // no well-formed emblem bitmap is larger than 1782 (24 bit) / 1654 (8 bit) bytes unsigned long buf_len = sizeof(buf); int header = 0, bitmap = 0, offbits = 0, palettesize = 0, i = 0; diff --git a/src/map/npc.c b/src/map/npc.c index 722e5199c..458fc52ed 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2432,7 +2432,7 @@ int npc_parseview(const char* w4, const char* start, const char* buffer, const c // Extract view ID / constant while (w4[i] != '\0') { - if (isspace(w4[i]) || w4[i] == '/' || w4[i] == ',') + if (ISSPACE(w4[i]) || w4[i] == '/' || w4[i] == ',') break; i++; @@ -2464,7 +2464,7 @@ bool npc_viewisid(const char * viewid) { // Loop through view, looking for non-numeric character. while (*viewid) { - if (isdigit(*viewid++) == 0) return false; + if (ISDIGIT(*viewid++) == 0) return false; } } diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 8f0989f3d..1156f4465 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -205,7 +205,9 @@ enum packet_headers { npcmarketopenType = 0x9d5, }; +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(push, 1) +#endif // not NetBSD < 6 / Solaris /** * structs for data @@ -939,6 +941,8 @@ struct packet_npc_market_open { } list[1000];/* TODO: whats the actual max of this? */ } __attribute__((packed)); +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) +#endif // not NetBSD < 6 / Solaris #endif /* _PACKETS_STRUCT_H_ */ -- cgit v1.2.3-70-g09d2