CVector fix - corrupt memory on size change
Version bumps
This commit is contained in:
parent
c5aae0d8aa
commit
e188bf087a
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "CSX"
|
#define MODULE_NAME "CSX"
|
||||||
#define MODULE_VERSION "1.01"
|
#define MODULE_VERSION "1.10RC1"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org/"
|
#define MODULE_URL "http://www.amxmodx.org/"
|
||||||
#define MODULE_LOGTAG "CSX"
|
#define MODULE_LOGTAG "CSX"
|
||||||
|
@ -48,7 +48,8 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, m_Size * sizeof(T));
|
for (size_t i=0; i<m_CurrentUsedSize; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
m_Data = newData;
|
m_Data = newData;
|
||||||
@ -74,7 +75,9 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, (m_Size < size) ? (m_Size * sizeof(T)) : (size * sizeof(T)));
|
size_t end = (m_Size < size) ? (m_Size) : size;
|
||||||
|
for (size_t i=0; i<end; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
if (m_Size < size)
|
if (m_Size < size)
|
||||||
@ -251,10 +254,11 @@ public:
|
|||||||
CVector<T>(const CVector<T> & other)
|
CVector<T>(const CVector<T> & other)
|
||||||
{
|
{
|
||||||
// copy data
|
// copy data
|
||||||
m_Data = new T [other.m_Size];
|
m_Data = new T [other.m_CurrentUsedSize];
|
||||||
m_Size = other.m_Size;
|
m_Size = other.m_CurrentUsedSize;
|
||||||
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
||||||
memcpy(m_Data, other.m_Data, m_CurrentUsedSize * sizeof(T));
|
for (size_t i=0; i<other.m_CurrentUsedSize; i++)
|
||||||
|
m_Data[i] = other.m_Data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
~CVector<T>()
|
~CVector<T>()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "DoD Fun"
|
#define MODULE_NAME "DoD Fun"
|
||||||
#define MODULE_VERSION "1.02"
|
#define MODULE_VERSION "1.10RC1"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org"
|
#define MODULE_URL "http://www.amxmodx.org"
|
||||||
#define MODULE_LOGTAG "DODFUN"
|
#define MODULE_LOGTAG "DODFUN"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "DoDX"
|
#define MODULE_NAME "DoDX"
|
||||||
#define MODULE_VERSION "1.01"
|
#define MODULE_VERSION "1.10RC1"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org"
|
#define MODULE_URL "http://www.amxmodx.org"
|
||||||
#define MODULE_LOGTAG "DODX"
|
#define MODULE_LOGTAG "DODX"
|
||||||
|
@ -48,7 +48,8 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, m_Size * sizeof(T));
|
for (size_t i=0; i<m_CurrentUsedSize; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
m_Data = newData;
|
m_Data = newData;
|
||||||
@ -74,7 +75,9 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, (m_Size < size) ? (m_Size * sizeof(T)) : (size * sizeof(T)));
|
size_t end = (m_Size < size) ? (m_Size) : size;
|
||||||
|
for (size_t i=0; i<end; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
if (m_Size < size)
|
if (m_Size < size)
|
||||||
@ -251,10 +254,11 @@ public:
|
|||||||
CVector<T>(const CVector<T> & other)
|
CVector<T>(const CVector<T> & other)
|
||||||
{
|
{
|
||||||
// copy data
|
// copy data
|
||||||
m_Data = new T [other.m_Size];
|
m_Data = new T [other.m_CurrentUsedSize];
|
||||||
m_Size = other.m_Size;
|
m_Size = other.m_CurrentUsedSize;
|
||||||
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
||||||
memcpy(m_Data, other.m_Data, m_CurrentUsedSize * sizeof(T));
|
for (size_t i=0; i<other.m_CurrentUsedSize; i++)
|
||||||
|
m_Data[i] = other.m_Data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
~CVector<T>()
|
~CVector<T>()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "GeoIP"
|
#define MODULE_NAME "GeoIP"
|
||||||
#define MODULE_VERSION "1.01"
|
#define MODULE_VERSION "1.10RC1"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org/"
|
#define MODULE_URL "http://www.amxmodx.org/"
|
||||||
#define MODULE_LOGTAG "GEOIP"
|
#define MODULE_LOGTAG "GEOIP"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "NS"
|
#define MODULE_NAME "NS"
|
||||||
#define MODULE_VERSION "1.10-RC1"
|
#define MODULE_VERSION "1.10RC1"
|
||||||
#define MODULE_AUTHOR "Steve Dudenhoeffer"
|
#define MODULE_AUTHOR "Steve Dudenhoeffer"
|
||||||
#define MODULE_URL "http://www.amxmodx.org/"
|
#define MODULE_URL "http://www.amxmodx.org/"
|
||||||
#define MODULE_LOGTAG "NS"
|
#define MODULE_LOGTAG "NS"
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
#include "amxxapi.h"
|
#include "amxxapi.h"
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <unistd.h>
|
||||||
|
#else
|
||||||
|
#include <direct.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
CVector<Vault *> Vaults;
|
CVector<Vault *> Vaults;
|
||||||
|
|
||||||
static cell nvault_open(AMX *amx, cell *params)
|
static cell nvault_open(AMX *amx, cell *params)
|
||||||
@ -31,13 +38,115 @@ static cell nvault_open(AMX *amx, cell *params)
|
|||||||
static cell nvault_get(AMX *amx, cell *params)
|
static cell nvault_get(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1];
|
unsigned int id = params[1];
|
||||||
if (id > Vaults.size() || !Vaults.at(i))
|
if (id > Vaults.size() || !Vaults.at(id))
|
||||||
|
{
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid vault id: %d\n", id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
unsigned int numParams = (*params)/sizeof(cell);
|
||||||
|
int len;
|
||||||
|
char *key = MF_GetAmxString(amx, params[2], 0, &len);
|
||||||
|
const char *val = Vaults.at(id)->Find(key)->val.c_str();
|
||||||
|
switch (numParams)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
return atoi(val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
cell *fAddr = MF_GetAmxAddr(amx, params[3]);
|
||||||
|
*fAddr = amx_ftoc((REAL)atof(val));
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
len = *(MF_GetAmxAddr(amx, params[4]));
|
||||||
|
return MF_SetAmxString(amx, params[3], val, len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell nvault_timeget(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
unsigned int id = params[1];
|
||||||
|
if (id > Vaults.size() || !Vaults.at(id))
|
||||||
|
{
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid vault id: %d\n", id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
unsigned int numParams = (*params)/sizeof(cell);
|
||||||
|
int len;
|
||||||
|
HashTable::htNode *node;
|
||||||
|
char *key = MF_GetAmxString(amx, params[2], 0, &len);
|
||||||
|
node = Vaults.at(id)->Find(key);
|
||||||
|
const char *val = node->val.c_str();
|
||||||
|
cell *t_addr = MF_GetAmxAddr(amx, params[3]);
|
||||||
|
*t_addr = (cell)(node->stamp);
|
||||||
|
switch (numParams)
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
return atoi(val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
cell *fAddr = MF_GetAmxAddr(amx, params[4]);
|
||||||
|
*fAddr = amx_ftoc((REAL)atof(val));
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
len = *(MF_GetAmxAddr(amx, params[5]));
|
||||||
|
return MF_SetAmxString(amx, params[4], val, len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell nvault_set(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
unsigned int id = params[1];
|
||||||
|
if (id > Vaults.size() || !Vaults.at(id))
|
||||||
{
|
{
|
||||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid vault id: %d\n", id);
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid vault id: %d\n", id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int len;
|
||||||
|
char *key = MF_GetAmxString(amx, params[2], 0, &len);
|
||||||
|
char *val = MF_FormatAmxString(amx, params, 3, &len);
|
||||||
|
|
||||||
|
Vaults.at(id)->Store(key, val);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell nvault_pset(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
unsigned int id = params[1];
|
||||||
|
if (id > Vaults.size() || !Vaults.at(id))
|
||||||
|
{
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid vault id: %d\n", id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int len;
|
||||||
|
char *key = MF_GetAmxString(amx, params[2], 0, &len);
|
||||||
|
char *val = MF_FormatAmxString(amx, params, 3, &len);
|
||||||
|
|
||||||
|
Vaults.at(id)->Store(key, val, false);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnAmxxAttach()
|
void OnAmxxAttach()
|
||||||
@ -46,6 +155,6 @@ void OnAmxxAttach()
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
mkdir(MF_BuildPathname("%s/nvault", LOCALINFO("amxx_datadir")), 0700);
|
mkdir(MF_BuildPathname("%s/nvault", LOCALINFO("amxx_datadir")), 0700);
|
||||||
#else
|
#else
|
||||||
mkdir(MF_BuildPathname("%s/nvault", LOCALINFO("amxx_datadir"));
|
mkdir(MF_BuildPathname("%s/nvault", LOCALINFO("amxx_datadir")));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,13 @@
|
|||||||
#include "sdk/amxxmodule.h"
|
#include "sdk/amxxmodule.h"
|
||||||
#include "sdk/CString.h"
|
#include "sdk/CString.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (C)2005 David "BAILOPAN" Anderson
|
||||||
|
* Licensed under the GNU General Public License, version 2
|
||||||
|
*
|
||||||
|
* Small hash table implementation
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
typedef unsigned __int8 uint8_t;
|
typedef unsigned __int8 uint8_t;
|
||||||
typedef __int8 int8_t;
|
typedef __int8 int8_t;
|
||||||
@ -13,7 +20,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash Table implementation (by David "BAILOPAN" Anderson)
|
* Hash Table implementation
|
||||||
* This is not designed to be flexible for size/type, it's hardcoded.
|
* This is not designed to be flexible for size/type, it's hardcoded.
|
||||||
* The table size is 2^11, which should be good enough for fast small lookups.
|
* The table size is 2^11, which should be good enough for fast small lookups.
|
||||||
* A hash is computed by two chopped up 8bit versions of CRC32, which is then combined to
|
* A hash is computed by two chopped up 8bit versions of CRC32, which is then combined to
|
||||||
|
@ -3,6 +3,13 @@
|
|||||||
|
|
||||||
#include "nvault.h"
|
#include "nvault.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (C)2005 David "BAILOPAN" Anderson
|
||||||
|
* Licensed under the GNU General Public License, version 2
|
||||||
|
*
|
||||||
|
* Adds Journaling capabilities for an nVault
|
||||||
|
*/
|
||||||
|
|
||||||
#define JOURNAL_MAGIC 0x6E564A4C
|
#define JOURNAL_MAGIC 0x6E564A4C
|
||||||
|
|
||||||
class Journal
|
class Journal
|
||||||
|
@ -4,6 +4,13 @@
|
|||||||
#include "sdk/CString.h"
|
#include "sdk/CString.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (C)2005 David "BAILOPAN" Anderson
|
||||||
|
* Licensed under the GNU General Public License, version 2
|
||||||
|
*
|
||||||
|
* Vault implementation using a Hash Table
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault file format:
|
* Vault file format:
|
||||||
* Headers
|
* Headers
|
||||||
|
@ -20,12 +20,23 @@ native vault_open(const name[]);
|
|||||||
* One extra param - Float byref
|
* One extra param - Float byref
|
||||||
* Two extra params - gets as a string
|
* Two extra params - gets as a string
|
||||||
*/
|
*/
|
||||||
native nvault_get(id, const name[], ...);
|
native nvault_get(id, const key[], ...);
|
||||||
|
|
||||||
|
/* Reads from a vault, includes time
|
||||||
|
* Parameter format same as nvault_get()
|
||||||
|
*/
|
||||||
|
native nvault_timeget(id, const key[], &time, ...);
|
||||||
|
|
||||||
|
/* Sets a key/value pair
|
||||||
|
* valFmt is formatted according to format()
|
||||||
|
*/
|
||||||
|
native nvault_set(id, const key[], const valFmt[], {Float,_}:...);
|
||||||
|
|
||||||
|
/* Sets a permanent key/value pair
|
||||||
|
* A permanent key isn't timestamped, so it can be invulnerable to pruning.
|
||||||
|
*/
|
||||||
|
native nvault_pset(id, const key[], const valFmt[], {Float,_}:...);
|
||||||
|
|
||||||
/* Reads a data from given key.
|
|
||||||
* If len is set to zero then get_vaultdata
|
|
||||||
* returns value as an number. */
|
|
||||||
native get_vaultdata(const key[], data[] = "", len = 0);
|
|
||||||
|
|
||||||
/* Sets a data under given key. */
|
/* Sets a data under given key. */
|
||||||
native set_vaultdata(const key[], const data[] = "" );
|
native set_vaultdata(const key[], const data[] = "" );
|
||||||
|
@ -48,7 +48,8 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, m_Size * sizeof(T));
|
for (size_t i=0; i<m_CurrentUsedSize; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
m_Data = newData;
|
m_Data = newData;
|
||||||
@ -74,7 +75,9 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, (m_Size < size) ? (m_Size * sizeof(T)) : (size * sizeof(T)));
|
size_t end = (m_Size < size) ? (m_Size) : size;
|
||||||
|
for (size_t i=0; i<end; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
if (m_Size < size)
|
if (m_Size < size)
|
||||||
@ -251,10 +254,11 @@ public:
|
|||||||
CVector<T>(const CVector<T> & other)
|
CVector<T>(const CVector<T> & other)
|
||||||
{
|
{
|
||||||
// copy data
|
// copy data
|
||||||
m_Data = new T [other.m_Size];
|
m_Data = new T [other.m_CurrentUsedSize];
|
||||||
m_Size = other.m_Size;
|
m_Size = other.m_CurrentUsedSize;
|
||||||
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
||||||
memcpy(m_Data, other.m_Data, m_CurrentUsedSize * sizeof(T));
|
for (size_t i=0; i<other.m_CurrentUsedSize; i++)
|
||||||
|
m_Data[i] = other.m_Data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
~CVector<T>()
|
~CVector<T>()
|
||||||
|
@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
|
|||||||
|
|
||||||
/************* AMXX Stuff *************/
|
/************* AMXX Stuff *************/
|
||||||
|
|
||||||
// *** Types ***
|
|
||||||
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
|
|
||||||
|
|
||||||
// *** Globals ***
|
// *** Globals ***
|
||||||
// Module info
|
// Module info
|
||||||
static amxx_module_info_s g_ModuleInfo =
|
static amxx_module_info_s g_ModuleInfo =
|
||||||
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
|
|||||||
MODULE_AUTHOR,
|
MODULE_AUTHOR,
|
||||||
MODULE_VERSION,
|
MODULE_VERSION,
|
||||||
#ifdef MODULE_RELOAD_ON_MAPCHANGE
|
#ifdef MODULE_RELOAD_ON_MAPCHANGE
|
||||||
1
|
1,
|
||||||
#else // MODULE_RELOAD_ON_MAPCHANGE
|
#else // MODULE_RELOAD_ON_MAPCHANGE
|
||||||
0
|
0,
|
||||||
#endif // MODULE_RELOAD_ON_MAPCHANGE
|
#endif // MODULE_RELOAD_ON_MAPCHANGE
|
||||||
|
MODULE_LOGTAG
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for the requested functions
|
// Storage for the requested functions
|
||||||
PFN_ADD_NATIVES g_fn_AddNatives;
|
PFN_ADD_NATIVES g_fn_AddNatives;
|
||||||
PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
||||||
|
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
|
||||||
PFN_GET_AMXADDR g_fn_GetAmxAddr;
|
PFN_GET_AMXADDR g_fn_GetAmxAddr;
|
||||||
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
|
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
|
||||||
PFN_GET_MODNAME g_fn_GetModname;
|
PFN_GET_MODNAME g_fn_GetModname;
|
||||||
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
|
|||||||
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
|
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
|
||||||
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
|
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
|
||||||
PFN_FORMAT g_fn_Format;
|
PFN_FORMAT g_fn_Format;
|
||||||
|
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
||||||
|
PFN_REQ_FNPTR g_fn_RequestFunction;
|
||||||
|
|
||||||
// *** Exports ***
|
// *** Exports ***
|
||||||
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
||||||
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||||||
if (!reqFnptrFunc)
|
if (!reqFnptrFunc)
|
||||||
return AMXX_PARAM;
|
return AMXX_PARAM;
|
||||||
|
|
||||||
|
g_fn_RequestFunction = reqFnptrFunc;
|
||||||
|
|
||||||
// Req all known functions
|
// Req all known functions
|
||||||
// Misc
|
// Misc
|
||||||
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
|
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
|
||||||
|
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
|
||||||
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
|
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
|
||||||
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
|
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
|
||||||
REQFUNC("Log", g_fn_Log, PFN_LOG);
|
REQFUNC("Log", g_fn_Log, PFN_LOG);
|
||||||
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
|
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
|
||||||
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
|
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
|
||||||
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
|
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
|
||||||
|
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
|
||||||
|
|
||||||
// Amx scripts
|
// Amx scripts
|
||||||
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
|
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
|
||||||
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
|
|||||||
void ValidateMacros_DontCallThis_Smiley()
|
void ValidateMacros_DontCallThis_Smiley()
|
||||||
{
|
{
|
||||||
MF_BuildPathname("str", "str", 0);
|
MF_BuildPathname("str", "str", 0);
|
||||||
|
MF_BuildPathnameR(NULL, 0, "%d", 0);
|
||||||
MF_FormatAmxString(NULL, 0, 0, NULL);
|
MF_FormatAmxString(NULL, 0, 0, NULL);
|
||||||
MF_GetAmxAddr(NULL, 0);
|
MF_GetAmxAddr(NULL, 0);
|
||||||
MF_PrintSrvConsole("str", "str", 0);
|
MF_PrintSrvConsole("str", "str", 0);
|
||||||
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
MF_GetPlayerFrags(0);
|
MF_GetPlayerFrags(0);
|
||||||
MF_GetPlayerEdict(0);
|
MF_GetPlayerEdict(0);
|
||||||
MF_Format("", 4, "str");
|
MF_Format("", 4, "str");
|
||||||
|
MF_RegisterFunction(NULL, "");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
// ***** AMXX stuff *****
|
// ***** AMXX stuff *****
|
||||||
|
|
||||||
// module interface version is 1
|
// module interface version is 1
|
||||||
#define AMXX_INTERFACE_VERSION 1
|
#define AMXX_INTERFACE_VERSION 2
|
||||||
|
|
||||||
// amxx module info
|
// amxx module info
|
||||||
struct amxx_module_info_s
|
struct amxx_module_info_s
|
||||||
@ -41,6 +41,7 @@ struct amxx_module_info_s
|
|||||||
const char *author;
|
const char *author;
|
||||||
const char *version;
|
const char *version;
|
||||||
int reload; // reload on mapchange when nonzero
|
int reload; // reload on mapchange when nonzero
|
||||||
|
const char *logtag; // added in version 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
|
|||||||
void FN_AMXX_PLUGINSLOADED(void);
|
void FN_AMXX_PLUGINSLOADED(void);
|
||||||
#endif // FN_AMXX_PLUGINSLOADED
|
#endif // FN_AMXX_PLUGINSLOADED
|
||||||
|
|
||||||
|
// *** Types ***
|
||||||
|
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
|
||||||
|
|
||||||
// ***** Module funcs stuff *****
|
// ***** Module funcs stuff *****
|
||||||
enum ForwardExecType
|
enum ForwardExecType
|
||||||
{
|
{
|
||||||
@ -1906,6 +1910,7 @@ enum ForwardParam
|
|||||||
|
|
||||||
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
|
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
|
||||||
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
|
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
|
||||||
|
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
|
||||||
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
|
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
|
||||||
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
|
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
|
||||||
typedef const char * (*PFN_GET_MODNAME) (void);
|
typedef const char * (*PFN_GET_MODNAME) (void);
|
||||||
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
|
|||||||
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
|
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
|
||||||
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
|
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
|
||||||
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
|
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
|
||||||
|
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
|
||||||
|
|
||||||
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
||||||
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
||||||
|
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
|
||||||
extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
|
extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
|
||||||
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
|
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
|
||||||
extern PFN_GET_MODNAME g_fn_GetModname;
|
extern PFN_GET_MODNAME g_fn_GetModname;
|
||||||
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
|
|||||||
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
|
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
|
||||||
extern PFN_FORMAT g_fn_Format;
|
extern PFN_FORMAT g_fn_Format;
|
||||||
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
|
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
|
||||||
|
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
||||||
|
extern PFN_REQ_FNPTR g_fn_RequestFunction;
|
||||||
|
|
||||||
#ifdef MAY_NEVER_BE_DEFINED
|
#ifdef MAY_NEVER_BE_DEFINED
|
||||||
// Function prototypes for intellisense and similar systems
|
// Function prototypes for intellisense and similar systems
|
||||||
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
|
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
|
||||||
int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
|
int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
|
||||||
char * MF_BuildPathname (const char * format, ...) { }
|
char * MF_BuildPathname (const char * format, ...) { }
|
||||||
|
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
|
||||||
cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
|
cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
|
||||||
void MF_PrintSrvConsole (char * format, ...) { }
|
void MF_PrintSrvConsole (char * format, ...) { }
|
||||||
const char * MF_GetModname (void) { }
|
const char * MF_GetModname (void) { }
|
||||||
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
|
|||||||
int MF_GetPlayerFlags (int id) { }
|
int MF_GetPlayerFlags (int id) { }
|
||||||
edict_t* MF_GetPlayerEdict (int id) { }
|
edict_t* MF_GetPlayerEdict (int id) { }
|
||||||
const char * MF_Format (const char *fmt, ...) { }
|
const char * MF_Format (const char *fmt, ...) { }
|
||||||
|
void MF_RegisterFunction (void *pfn, const char *description) { }
|
||||||
|
void * MF_RequestFunction (const char *description) { }
|
||||||
#endif // MAY_NEVER_BE_DEFINED
|
#endif // MAY_NEVER_BE_DEFINED
|
||||||
|
|
||||||
#define MF_AddNatives g_fn_AddNatives
|
#define MF_AddNatives g_fn_AddNatives
|
||||||
#define MF_BuildPathname g_fn_BuildPathname
|
#define MF_BuildPathname g_fn_BuildPathname
|
||||||
|
#define MF_BuildPathnameR g_fn_BuildPathnameR
|
||||||
#define MF_FormatAmxString g_fn_FormatAmxString
|
#define MF_FormatAmxString g_fn_FormatAmxString
|
||||||
#define MF_GetAmxAddr g_fn_GetAmxAddr
|
#define MF_GetAmxAddr g_fn_GetAmxAddr
|
||||||
#define MF_PrintSrvConsole g_fn_PrintSrvConsole
|
#define MF_PrintSrvConsole g_fn_PrintSrvConsole
|
||||||
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
|
|||||||
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
|
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
|
||||||
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
|
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
|
||||||
#define MF_Format g_fn_Format
|
#define MF_Format g_fn_Format
|
||||||
|
#define MF_RegisterFunction g_fn_RegisterFunction
|
||||||
|
#define MF_RequestFunction g_fn_RequestFunction;
|
||||||
|
|
||||||
/*** Memory ***/
|
/*** Memory ***/
|
||||||
void *operator new(size_t reportedSize);
|
void *operator new(size_t reportedSize);
|
||||||
|
@ -48,7 +48,8 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, m_Size * sizeof(T));
|
for (size_t i=0; i<m_CurrentUsedSize; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
m_Data = newData;
|
m_Data = newData;
|
||||||
@ -74,7 +75,9 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, (m_Size < size) ? (m_Size * sizeof(T)) : (size * sizeof(T)));
|
size_t end = (m_Size < size) ? (m_Size) : size;
|
||||||
|
for (size_t i=0; i<end; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
if (m_Size < size)
|
if (m_Size < size)
|
||||||
@ -251,10 +254,11 @@ public:
|
|||||||
CVector<T>(const CVector<T> & other)
|
CVector<T>(const CVector<T> & other)
|
||||||
{
|
{
|
||||||
// copy data
|
// copy data
|
||||||
m_Data = new T [other.m_Size];
|
m_Data = new T [other.m_CurrentUsedSize];
|
||||||
m_Size = other.m_Size;
|
m_Size = other.m_CurrentUsedSize;
|
||||||
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
||||||
memcpy(m_Data, other.m_Data, m_CurrentUsedSize * sizeof(T));
|
for (size_t i=0; i<other.m_CurrentUsedSize; i++)
|
||||||
|
m_Data[i] = other.m_Data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
~CVector<T>()
|
~CVector<T>()
|
||||||
|
@ -48,7 +48,8 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, m_Size * sizeof(T));
|
for (size_t i=0; i<m_CurrentUsedSize; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
m_Data = newData;
|
m_Data = newData;
|
||||||
@ -74,7 +75,9 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, (m_Size < size) ? (m_Size * sizeof(T)) : (size * sizeof(T)));
|
size_t end = (m_Size < size) ? (m_Size) : size;
|
||||||
|
for (size_t i=0; i<end; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
if (m_Size < size)
|
if (m_Size < size)
|
||||||
@ -251,10 +254,11 @@ public:
|
|||||||
CVector<T>(const CVector<T> & other)
|
CVector<T>(const CVector<T> & other)
|
||||||
{
|
{
|
||||||
// copy data
|
// copy data
|
||||||
m_Data = new T [other.m_Size];
|
m_Data = new T [other.m_CurrentUsedSize];
|
||||||
m_Size = other.m_Size;
|
m_Size = other.m_CurrentUsedSize;
|
||||||
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
||||||
memcpy(m_Data, other.m_Data, m_CurrentUsedSize * sizeof(T));
|
for (size_t i=0; i<other.m_CurrentUsedSize; i++)
|
||||||
|
m_Data[i] = other.m_Data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
~CVector<T>()
|
~CVector<T>()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "Sockets"
|
#define MODULE_NAME "Sockets"
|
||||||
#define MODULE_VERSION "1.01"
|
#define MODULE_VERSION "1.10RC1"
|
||||||
#define MODULE_AUTHOR "HLSW Dev Team"
|
#define MODULE_AUTHOR "HLSW Dev Team"
|
||||||
#define MODULE_URL "http://www.hlsw.net/"
|
#define MODULE_URL "http://www.hlsw.net/"
|
||||||
#define MODULE_LOGTAG "SOCKET"
|
#define MODULE_LOGTAG "SOCKET"
|
||||||
|
@ -48,7 +48,8 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, m_Size * sizeof(T));
|
for (size_t i=0; i<m_CurrentUsedSize; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
m_Data = newData;
|
m_Data = newData;
|
||||||
@ -74,7 +75,9 @@ template <class T> class CVector
|
|||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
memcpy(newData, m_Data, (m_Size < size) ? (m_Size * sizeof(T)) : (size * sizeof(T)));
|
size_t end = (m_Size < size) ? (m_Size) : size;
|
||||||
|
for (size_t i=0; i<end; i++)
|
||||||
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
if (m_Size < size)
|
if (m_Size < size)
|
||||||
@ -251,10 +254,11 @@ public:
|
|||||||
CVector<T>(const CVector<T> & other)
|
CVector<T>(const CVector<T> & other)
|
||||||
{
|
{
|
||||||
// copy data
|
// copy data
|
||||||
m_Data = new T [other.m_Size];
|
m_Data = new T [other.m_CurrentUsedSize];
|
||||||
m_Size = other.m_Size;
|
m_Size = other.m_CurrentUsedSize;
|
||||||
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
||||||
memcpy(m_Data, other.m_Data, m_CurrentUsedSize * sizeof(T));
|
for (size_t i=0; i<other.m_CurrentUsedSize; i++)
|
||||||
|
m_Data[i] = other.m_Data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
~CVector<T>()
|
~CVector<T>()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "Sqlite"
|
#define MODULE_NAME "Sqlite"
|
||||||
#define MODULE_VERSION "1.00"
|
#define MODULE_VERSION "1.10RC1"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org/"
|
#define MODULE_URL "http://www.amxmodx.org/"
|
||||||
#define MODULE_LOGTAG "SQLITE"
|
#define MODULE_LOGTAG "SQLITE"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "TfcX"
|
#define MODULE_NAME "TfcX"
|
||||||
#define MODULE_VERSION "1.01"
|
#define MODULE_VERSION "1.10RC1"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org"
|
#define MODULE_URL "http://www.amxmodx.org"
|
||||||
#define MODULE_LOGTAG "TFCX"
|
#define MODULE_LOGTAG "TFCX"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "TSX"
|
#define MODULE_NAME "TSX"
|
||||||
#define MODULE_VERSION "1.01"
|
#define MODULE_VERSION "1.10RC1"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org"
|
#define MODULE_URL "http://www.amxmodx.org"
|
||||||
#define MODULE_LOGTAG "TSX"
|
#define MODULE_LOGTAG "TSX"
|
||||||
|
Loading…
Reference in New Issue
Block a user