diff --git a/amxmodx/CString.h b/amxmodx/CString.h index cf410a1a..4ecfa5d3 100755 --- a/amxmodx/CString.h +++ b/amxmodx/CString.h @@ -32,6 +32,8 @@ #ifndef _INCLUDE_CSTRING_H #define _INCLUDE_CSTRING_H +#include + //by David "BAILOPAN" Anderson class String { @@ -40,7 +42,7 @@ public: { v = NULL; a_size = 0; - assign(""); + //assign(""); } ~String() @@ -63,19 +65,19 @@ public: assign(src.c_str()); } - const char *c_str() { return v; } + const char *c_str() { return v?v:""; } - const char *c_str() const { return v; } + const char *c_str() const { return v?v:""; } void append(const char *t) { - Grow(strlen(v) + strlen(t) + 1); + Grow(size() + strlen(t) + 1); strcat(v, t); } void append(const char c) { - size_t len = strlen(v); + size_t len = size(); Grow(len + 2); v[len] = c; v[len + 1] = '\0'; @@ -104,17 +106,24 @@ public: void clear() { - v[0] = '\0'; + if (v) + v[0] = '\0'; } int compare (const char *d) { - return strcmp(v, d); + if (!v) + return strcmp("", d); + else + return strcmp(v, d); } //Added this for amxx inclusion bool empty() { + if (!v) + return false; + if (v[0] == '\0') return true; @@ -123,23 +132,21 @@ public: size_t size() { - return strlen(v); - } - - const char * _fread(FILE *fp) - { - Grow(512, false); - char *ret = fgets(v, 511, fp); - return ret; + if (v) + return strlen(v); + else + return 0; } int find(const char c, int index = 0) { - size_t len = strlen(v); + size_t len = size(); + if (len < 1) + return npos; if (index >= (int)len || index < 0) return npos; unsigned int i = 0; - for (i=index; i<(unsigned int)len; i++) + for (i=index; i<(int)len; i++) { if (v[i] == c) { @@ -164,6 +171,9 @@ public: void trim() { + if (!v) + return; + unsigned int i = 0; unsigned int j = 0; size_t len = strlen(v); @@ -224,6 +234,8 @@ public: void erase(unsigned int start, int num = npos) { + if (!v) + return; unsigned int i = 0; size_t len = size(); //check for bounds @@ -257,6 +269,9 @@ public: String substr(unsigned int index, int num = npos) { + if (!v) + return String(""); + String ns; size_t len = size(); @@ -271,7 +286,7 @@ public: num = len - index; } - unsigned int i = 0; + unsigned int i = 0, j=0; unsigned int nslen = num + 2; ns.Grow(nslen); @@ -284,6 +299,8 @@ public: void toLower() { + if (!v) + return; unsigned int i = 0; size_t len = strlen(v); for (i=0; i size()) + if (index > size() || !v) { return -1; } else { @@ -318,7 +335,7 @@ public: int at(int a) { - if (a < 0 || a >= (int)size()) + if (a < 0 || a >= (int)size() || !v) return -1; return v[a]; @@ -326,7 +343,7 @@ public: bool at(int at, char c) { - if (at < 0 || at >= (int)size()) + if (at < 0 || at >= (int)size() || !v) return false; v[at] = c; @@ -340,9 +357,10 @@ private: if (d <= a_size) return; char *n = new char[d + 1]; - if (copy) + if (copy && v) strcpy(n, v); - delete [] v; + if (v) + delete [] v; v = n; a_size = d + 1; } diff --git a/amxmodx/amxmodx.h b/amxmodx/amxmodx.h index 1002eb19..918adcb6 100755 --- a/amxmodx/amxmodx.h +++ b/amxmodx/amxmodx.h @@ -69,7 +69,7 @@ #include "amxxlog.h" #define AMXXLOG_Log g_log.Log -#define AMX_VERSION "1.50-RC1" +#define AMX_VERSION "1.50" extern AMX_NATIVE_INFO core_Natives[]; extern AMX_NATIVE_INFO time_Natives[]; diff --git a/amxmodx/modules.cpp b/amxmodx/modules.cpp index 7f2a7aa6..2d2d7485 100755 --- a/amxmodx/modules.cpp +++ b/amxmodx/modules.cpp @@ -1672,7 +1672,7 @@ void Module_CacheFunctions() // other amx stuff REGISTER_FUNC("amx_Exec", amx_Exec) - REGISTER_FUNC("amx_Push", amx_Push); + REGISTER_FUNC("amx_Push", amx_Push) REGISTER_FUNC("amx_Execv", amx_Execv) //I HOPE NO ONE USES THIS!!!! REGISTER_FUNC("amx_Allot", amx_Allot) REGISTER_FUNC("amx_FindPublic", amx_FindPublic)