summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2014-01-24 18:18:39 -0200
committershennetsind <ind@henn.et>2014-01-24 18:18:39 -0200
commit2263dc4660c6668c373f6a9e654e21bea8c419e4 (patch)
tree5a02d740a74d75979e6adee90acd4d63fe807036 /src/common
parent7438e401b4209198691d3c8ca65b6c702338fa41 (diff)
parent8fb2b31e8de73872baddc3d983a4eea5c359329d (diff)
downloadhercules-2263dc4660c6668c373f6a9e654e21bea8c419e4.tar.gz
hercules-2263dc4660c6668c373f6a9e654e21bea8c419e4.tar.bz2
hercules-2263dc4660c6668c373f6a9e654e21bea8c419e4.tar.xz
hercules-2263dc4660c6668c373f6a9e654e21bea8c419e4.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Diffstat (limited to 'src/common')
-rw-r--r--src/common/cbasetypes.h5
-rw-r--r--src/common/mmo.h8
-rw-r--r--src/common/strlib.c34
-rw-r--r--src/common/strlib.h2
4 files changed, 36 insertions, 13 deletions
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 <sys/param.h>
+#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/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
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