diff --git a/dlls/nvault/NVault.cpp b/dlls/nvault/NVault.cpp index e1643461..b1133512 100755 --- a/dlls/nvault/NVault.cpp +++ b/dlls/nvault/NVault.cpp @@ -1,7 +1,7 @@ +#include "amxxmodule.h" #include "NVault.h" #include "Binary.h" #include "CString.h" -#include "amxxmodule.h" #ifdef __linux__ #define _snprintf snprintf diff --git a/dlls/nvault/amxxapi.h b/dlls/nvault/amxxapi.h index 84ce47e4..0190d84f 100755 --- a/dlls/nvault/amxxapi.h +++ b/dlls/nvault/amxxapi.h @@ -1,10 +1,10 @@ #ifndef _INCLUDE_AMXXAPI_H #define _INCLUDE_AMXXAPI_H +#include "amxxmodule.h" #include "CVector.h" #include "CQueue.h" #include "CString.h" -#include "amxxmodule.h" extern AMX_NATIVE_INFO nVault_natives[]; diff --git a/dlls/nvault/amxxmodule.cpp b/dlls/nvault/amxxmodule.cpp index 7355cded..9d92f6f5 100755 --- a/dlls/nvault/amxxmodule.cpp +++ b/dlls/nvault/amxxmodule.cpp @@ -2504,6 +2504,8 @@ PFN_REQ_FNPTR g_fn_RequestFunction; PFN_AMX_PUSH g_fn_AmxPush; PFN_SET_TEAM_INFO g_fn_SetTeamInfo; PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr; +PFN_REG_AUTH_FUNC g_fn_RegAuthFunc; +PFN_UNREG_AUTH_FUNC g_fn_UnregAuthFunc; // *** Exports *** C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) @@ -2615,6 +2617,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc) REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH); REQFUNC("SetPlayerTeamInfo", g_fn_SetTeamInfo, PFN_SET_TEAM_INFO); REQFUNC("PlayerPropAddr", g_fn_PlayerPropAddr, PFN_PLAYER_PROP_ADDR); + REQFUNC("RegAuthFunc", g_fn_RegAuthFunc, PFN_REG_AUTH_FUNC); + REQFUNC("UnregAuthFunc", g_fn_UnregAuthFunc, PFN_UNREG_AUTH_FUNC); #ifdef MEMORY_TEST // Memory @@ -2653,11 +2657,10 @@ C_DLLEXPORT int AMXX_PluginsLoaded() // Advanced MF functions void MF_Log(const char *fmt, ...) { - // :TODO: Overflow possible here char msg[3072]; va_list arglst; va_start(arglst, fmt); - vsprintf(msg, fmt, arglst); + vsnprintf(msg, sizeof(msg) - 1, fmt, arglst); va_end(arglst); g_fn_Log("[%s] %s", MODULE_LOGTAG, msg); @@ -2665,11 +2668,10 @@ void MF_Log(const char *fmt, ...) void MF_LogError(AMX *amx, int err, const char *fmt, ...) { - // :TODO: Overflow possible here char msg[3072]; va_list arglst; va_start(arglst, fmt); - vsprintf(msg, fmt, arglst); + vsnprintf(msg, sizeof(msg) - 1, fmt, arglst); va_end(arglst); g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_LOGTAG, msg); @@ -2739,6 +2741,8 @@ void ValidateMacros_DontCallThis_Smiley() MF_RegisterFunction(NULL, ""); MF_SetPlayerTeamInfo(0, 0, ""); MF_PlayerPropAddr(0, 0); + MF_RegAuthFunc(NULL); + MF_UnregAuthFunc(NULL); } #endif diff --git a/dlls/nvault/amxxmodule.h b/dlls/nvault/amxxmodule.h index 3d20f50e..71077bdd 100755 --- a/dlls/nvault/amxxmodule.h +++ b/dlls/nvault/amxxmodule.h @@ -153,9 +153,137 @@ typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx); #endif #if defined _MSC_VER - #pragma warning(disable:4103) /* disable warning message 4103 that complains - * about pragma pack in a header file */ - #pragma warning(disable:4100) /* "'%$S' : unreferenced formal parameter" */ + #pragma warning(disable:4103) /* disable warning message 4103 that complains + * about pragma pack in a header file */ + #pragma warning(disable:4100) /* "'%$S' : unreferenced formal parameter" */ + + #if _MSC_VER >= 1400 + #if !defined NO_MSVC8_AUTO_COMPAT + + /* Disable deprecation warnings concerning unsafe CRT functions */ + #if !defined _CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE + #endif + + /* Replace the POSIX function with ISO C++ conformant ones as they are now deprecated */ + #define access _access + #define cabs _cabs + #define cgets _cgets + #define chdir _chdir + #define chmod _chmod + #define chsize _chsize + #define close _close + #define cprintf _cprintf + #define cputs _cputts + #define creat _creat + #define cscanf _cscanf + #define cwait _cwait + #define dup _dup + #define dup2 _dup2 + #define ecvt _ecvt + #define eof _eof + #define execl _execl + #define execle _execle + #define execlp _execlp + #define execlpe _execlpe + #define execv _execv + #define execve _execv + #define execvp _execvp + #define execvpe _execvpe + #define fcloseall _fcloseall + #define fcvt _fcvt + #define fdopen _fdopen + #define fgetchar _fgetchar + #define filelength _filelength + #define fileno _fileno + #define flushall _flushall + #define fputchar _fputchar + #define gcvt _gcvt + #define getch _getch + #define getche _getche + #define getcwd _getcwd + #define getpid _getpid + #define getw _getw + #define hypot _hypot + #define inp _inp + #define inpw _inpw + #define isascii __isascii + #define isatty _isatty + #define iscsym __iscsym + #define iscsymf __iscsymf + #define itoa _itoa + #define j0 _j0 + #define j1 _j1 + #define jn _jn + #define kbhit _kbhit + #define lfind _lfind + #define locking _locking + #define lsearch _lsearch + #define lseek _lseek + #define ltoa _ltoa + #define memccpy _memccpy + #define memicmp _memicmp + #define mkdir _mkdir + #define mktemp _mktemp + #define open _open + #define outp _outp + #define outpw _outpw + #define putch _putch + #define putenv _putenv + #define putw _putw + #define read _read + #define rmdir _rmdir + #define rmtmp _rmtmp + #define setmode _setmode + #define sopen _sopen + #define spawnl _spawnl + #define spawnle _spawnle + #define spawnlp _spawnlp + #define spawnlpe _spawnlpe + #define spawnv _spawnv + #define spawnve _spawnve + #define spawnvp _spawnvp + #define spawnvpe _spawnvpe + #define strcmpi _strcmpi + #define strdup _strdup + #define stricmp _stricmp + #define strlwr _strlwr + #define strnicmp _strnicmp + #define strnset _strnset + #define strrev _strrev + #define strset _strset + #define strupr _strupr + #define swab _swab + #define tell _tell + #define tempnam _tempnam + #define toascii __toascii + #define tzset _tzset + #define ultoa _ultoa + #define umask _umask + #define ungetch _ungetch + #define unlink _unlink + #define wcsdup _wcsdup + #define wcsicmp _wcsicmp + #define wcsicoll _wcsicoll + #define wcslwr _wcslwr + #define wcsnicmp _wcsnicmp + #define wcsnset _wcsnset + #define wcsrev _wcsrev + #define wcsset _wcsset + #define wcsupr _wcsupr + #define write _write + #define y0 _y0 + #define y1 _y1 + #define yn _yn + + /* Disable deprecation warnings because MSVC8 seemingly thinks the ISO C++ conformant + * functions above are deprecated. */ + #pragma warning (disable:4996) + + #endif + #else + #define vsnprintf _vsnprintf + #endif #endif @@ -1950,6 +2078,8 @@ enum PlayerProp Player_NewmenuPage, //int }; +typedef void (*AUTHORIZEFUNC)(int player, const char *authstring); + typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...); @@ -2027,6 +2157,8 @@ typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/); typedef int (*PFN_AMX_PUSH) (AMX * /*amx*/, cell /*value*/); typedef int (*PFN_SET_TEAM_INFO) (int /*player */, int /*teamid */, const char * /*name */); +typedef void (*PFN_REG_AUTH_FUNC) (AUTHORIZEFUNC); +typedef void (*PFN_UNREG_AUTH_FUNC) (AUTHORIZEFUNC); extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_BUILD_PATHNAME g_fn_BuildPathname; @@ -2092,6 +2224,8 @@ extern PFN_REQ_FNPTR g_fn_RequestFunction; extern PFN_AMX_PUSH g_fn_AmxPush; extern PFN_SET_TEAM_INFO g_fn_SetTeamInfo; extern PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr; +extern PFN_REG_AUTH_FUNC g_fn_RegAuthFunc; +extern PFN_UNREG_AUTH_FUNC g_fn_UnregAuthFunc; #ifdef MAY_NEVER_BE_DEFINED // Function prototypes for intellisense and similar systems @@ -2154,6 +2288,8 @@ int MF_AmxPush (AMX *amx, cell *params) { } int MF_AmxExec (AMX *amx, cell *retval, int idx) { } int MF_SetPlayerTeamInfo (int id, int teamid, const char *teamname) { } void * MF_PlayerPropAddr (int id, int prop) { } +void MF_RegAuthFunc (AUTHORIZEFUNC fn) { } +void MF_UnregAuthFunc (AUTHORIZEFUNC fn) { } #endif // MAY_NEVER_BE_DEFINED #define MF_AddNatives g_fn_AddNatives @@ -2217,10 +2353,12 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...); #define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_Format g_fn_Format #define MF_RegisterFunction g_fn_RegisterFunction -#define MF_RequestFunction g_fn_RequestFunction; +#define MF_RequestFunction g_fn_RequestFunction #define MF_AmxPush g_fn_AmxPush #define MF_SetPlayerTeamInfo g_fn_SetTeamInfo #define MF_PlayerPropAddr g_fn_PlayerPropAddr +#define MF_RegAuthFunc g_fn_RegAuthFunc +#define MF_UnregAuthFunc g_fn_UnregAuthFunc #ifdef MEMORY_TEST /*** Memory ***/ diff --git a/dlls/nvault/moduleconfig.h b/dlls/nvault/moduleconfig.h index af356b57..23b74f88 100755 --- a/dlls/nvault/moduleconfig.h +++ b/dlls/nvault/moduleconfig.h @@ -21,6 +21,19 @@ // metamod plugin? #define USE_METAMOD +// use memory manager/tester? +// note that if you use this, you cannot construct/allocate +// anything before the module attached (OnAmxxAttach). +// be careful of default constructors using new/malloc! +// #define MEMORY_TEST + +// Unless you use STL or exceptions, keep this commented. +// It allows you to compile without libstdc++.so as a dependency +// #define NO_ALLOC_OVERRIDES + +// Uncomment this if you are using MSVC8 or greater and want to fix some of the compatibility issues yourself +// #define NO_MSVC8_AUTO_COMPAT + // - AMXX Init functions // Also consider using FN_META_* // AMXX query @@ -460,4 +473,3 @@ #endif // USE_METAMOD #endif // __MODULECONFIG_H__ - diff --git a/dlls/nvault/msvc8/nvault.vcproj b/dlls/nvault/msvc8/nvault.vcproj new file mode 100644 index 00000000..d549749b --- /dev/null +++ b/dlls/nvault/msvc8/nvault.vcproj @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dlls/nvault/sdk/CString.h b/dlls/nvault/sdk/CString.h deleted file mode 100755 index 95b347c7..00000000 --- a/dlls/nvault/sdk/CString.h +++ /dev/null @@ -1,407 +0,0 @@ -/* AMX Mod X -* -* by the AMX Mod X Development Team -* originally developed by OLO -* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -*/ - -#ifndef _INCLUDE_CSTRING_H -#define _INCLUDE_CSTRING_H - -#include -#include - -//by David "BAILOPAN" Anderson -class String -{ -public: - String() - { - v = NULL; - mSize = 0; - cSize = 0; - Grow(2); - assign(""); - } - - ~String() - { - if (v) - delete [] v; - } - - String(const char *src) - { - v = NULL; - mSize = 0; - cSize = 0; assign(src); - } - - String(String &src) - { - v = NULL; - mSize = 0; - cSize = 0; - assign(src.c_str()); - } - - const char *c_str() { return v?v:""; } - const char *c_str() const { return v?v:""; } - - void append(const char *t) - { - Grow(cSize + strlen(t) + 1); - strcat(v, t); - cSize = strlen(v); - } - - void append(const char c) - { - Grow(cSize + 2); - v[cSize] = c; - v[++cSize] = 0; - } - - void append(String &d) - { - const char *t = d.c_str(); - Grow(cSize + strlen(t)); - strcat(v, t); - cSize = strlen(v); - } - - void assign(const String &src) - { - assign(src.c_str()); - } - - void assign(const char *d) - { - if (!d) - { - Grow(1); - cSize = 0; - strcpy(v, ""); - return; - } - Grow(strlen(d)); - if (v) - { - strcpy(v, d); - cSize = strlen(v); - } else { - cSize = 0; - } - } - - void clear() - { - if (v) - { - v[0] = 0; - cSize = 0; - } - } - - int compare (const char *d) - { - if (v) { - if (d) { - return strcmp(v, d); - } else { - return strlen(v); - } - } else { - if (d) { - return strlen(d); - } else { - return 0; - } - } - } - - //Added this for amxx inclusion - bool empty() - { - if (!v || !cSize) - return true; - - return false; - } - - int size() - { - if (!v) - return 0; - return cSize; - } - - const char * _fread(FILE *fp) - { - Grow(512); - char * ret = fgets(v, 511, fp); - cSize = strlen(v); - return ret; - } - - int find(const char c, int index = 0) - { - if (!v) - return npos; - if (index >= (int)cSize || index < 0) - return npos; - unsigned int i = 0; - for (i=index; i=0; i--) - { - if (!is_space(v[i]) - || (is_space(v[i]) && i==0)) - { - erase(i+1, j); - break; - } - j++; - } - } - - if (cSize == 1) - { - if (is_space(v[0])) - { - clear(); - return; - } - } - } - - String & erase(unsigned int start, int num = npos) - { - if (!v) - return (*this); - unsigned int i = 0; - //check for bounds - if (num == npos || start+num > cSize-num+1) - num = cSize - start; - //do the erasing - bool copyflag = false; - for (i=0; i=start && i= cSize || !v) - return ns; - - if (num == npos) - { - num = cSize - index; - } else if (index+num >= cSize) { - num = cSize - index; - } - - unsigned int i = 0, j=0; - char *s = new char[cSize+1]; - - for (i=index; i= 65 && v[i] <= 90) - v[i] |= 32; - } - } - - String & operator = (const String &src) - { - assign(src); - return *this; - } - - String & operator = (const char *src) - { - assign(src); - return *this; - - } - - char operator [] (unsigned int index) - { - if (index > cSize) - { - return -1; - } else { - return v[index]; - } - } - - int at(int a) - { - if (a < 0 || a >= (int)cSize) - return -1; - - return v[a]; - } - - bool at(int at, char c) - { - if (at < 0 || at >= (int)cSize) - return false; - - v[at] = c; - - return true; - } - -private: - void Grow(unsigned int d) - { - if (d<1) - return; - if (d > mSize) - { - mSize = d + 16; // allocate a buffer - char *t = new char[d+1]; - if (v) { - strcpy(t, v); - t[cSize] = 0; - delete [] v; - } - v = t; - mSize = d; - } - } - - char *v; - unsigned int mSize; - unsigned int cSize; -public: - static const int npos = -1; -}; - -#endif //_INCLUDE_CSTRING_H diff --git a/dlls/nvault/sh_list.h b/dlls/nvault/sh_list.h index 3c786ec4..9c97406f 100755 --- a/dlls/nvault/sh_list.h +++ b/dlls/nvault/sh_list.h @@ -11,6 +11,13 @@ #ifndef _INCLUDE_SMM_LIST_H #define _INCLUDE_SMM_LIST_H +// MSVC8 fix for offsetof macro redefition warnings +#ifdef _MSC_VER + #if _MSC_VER >= 1400 + #undef offsetof + #endif +#endif + #include #include