Normalize all the line endings

This commit is contained in:
Arkshine 2015-03-10 16:51:45 +01:00
parent afc3cac54d
commit 48d6a3354a
64 changed files with 16240 additions and 16240 deletions

View File

@ -90,9 +90,9 @@ void CTaskMngr::CTask::changeBase(float fNewBase)
}
void CTaskMngr::CTask::resetNextExecTime(float fCurrentTime)
{
// If we're here while we're executing we would add m_fBase twice
if (!m_bInExecute)
{
// If we're here while we're executing we would add m_fBase twice
if (!m_bInExecute)
m_fNextExecTime = fCurrentTime + m_fBase;
}

View File

@ -6,208 +6,208 @@
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#ifndef DATASTRUCTS_H
#define DATASTRUCTS_H
#include <am-vector.h>
class CellArray
{
public:
CellArray(size_t blocksize, size_t basesize = 0) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_BaseSize(basesize > 0 ? basesize : 8), m_Size(0)
{
}
~CellArray()
{
free(m_Data);
}
size_t size() const
{
return m_Size;
}
cell *push()
{
if (!GrowIfNeeded(1))
{
return NULL;
}
cell *arr = &m_Data[m_Size * m_BlockSize];
m_Size++;
return arr;
}
cell *at(size_t b) const
{
return &m_Data[b * m_BlockSize];
}
size_t blocksize() const
{
return m_BlockSize;
}
void clear()
{
m_Size = 0;
}
bool swap(size_t item1, size_t item2)
{
/* Make sure there is extra space available */
if (!GrowIfNeeded(1))
{
return false;
}
cell *pri = at(item1);
cell *alt = at(item2);
/* Get our temporary array 1 after the limit */
cell *temp = &m_Data[m_Size * m_BlockSize];
memcpy(temp, pri, sizeof(cell)* m_BlockSize);
memcpy(pri, alt, sizeof(cell)* m_BlockSize);
memcpy(alt, temp, sizeof(cell)* m_BlockSize);
return true;
}
void remove(size_t index)
{
/* If we're at the end, take the easy way out */
if (index == m_Size - 1)
{
m_Size--;
return;
}
/* Otherwise, it's time to move stuff! */
size_t remaining_indexes = (m_Size - 1) - index;
cell *src = at(index + 1);
cell *dest = at(index);
memmove(dest, src, sizeof(cell)* m_BlockSize * remaining_indexes);
m_Size--;
}
cell *insert_at(size_t index)
{
/* Make sure it'll fit */
if (!GrowIfNeeded(1))
{
return NULL;
}
/* move everything up */
cell *src = at(index);
cell *dst = at(index + 1);
memmove(dst, src, sizeof(cell)* m_BlockSize * (m_Size - index));
m_Size++;
return src;
}
bool resize(size_t count)
{
if (count <= m_Size)
{
m_Size = count;
return true;
}
if (!GrowIfNeeded(count - m_Size))
{
return false;
}
m_Size = count;
return true;
}
CellArray *clone()
{
CellArray *array = new CellArray(m_BlockSize);
array->m_AllocSize = m_AllocSize;
array->m_Size = m_Size;
array->m_Data = (cell *)malloc(sizeof(cell)* m_BlockSize * m_AllocSize);
memcpy(array->m_Data, m_Data, sizeof(cell)* m_BlockSize * m_Size);
return array;
}
cell *base()
{
return m_Data;
}
size_t mem_usage()
{
return m_AllocSize * m_BlockSize * sizeof(cell);
}
private:
bool GrowIfNeeded(size_t count)
{
/* Shortcut out if we can store this */
if (m_Size + count <= m_AllocSize)
{
return true;
}
/* Set a base allocation size of 8 items */
if (!m_AllocSize)
{
m_AllocSize = m_BaseSize;
}
/* If it's not enough, keep doubling */
while (m_Size + count > m_AllocSize)
{
m_AllocSize *= 2;
}
/* finally, allocate the new block */
if (m_Data)
{
m_Data = (cell *)realloc(m_Data, sizeof(cell)* m_BlockSize * m_AllocSize);
}
else {
m_Data = (cell *)malloc(sizeof(cell)* m_BlockSize * m_AllocSize);
}
return (m_Data != NULL);
}
private:
cell *m_Data;
size_t m_BlockSize;
size_t m_AllocSize;
size_t m_BaseSize;
size_t m_Size;
};
extern ke::Vector<CellArray*> VectorHolder;
inline CellArray* HandleToVector(AMX* amx, int handle)
{
if (handle <= 0 || handle > (int)VectorHolder.length())
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", handle);
return NULL;
}
CellArray* ret = VectorHolder[handle - 1];
if (ret == NULL)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", handle);
return NULL;
}
return ret;
}
#endif
#ifndef DATASTRUCTS_H
#define DATASTRUCTS_H
#include <am-vector.h>
class CellArray
{
public:
CellArray(size_t blocksize, size_t basesize = 0) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_BaseSize(basesize > 0 ? basesize : 8), m_Size(0)
{
}
~CellArray()
{
free(m_Data);
}
size_t size() const
{
return m_Size;
}
cell *push()
{
if (!GrowIfNeeded(1))
{
return NULL;
}
cell *arr = &m_Data[m_Size * m_BlockSize];
m_Size++;
return arr;
}
cell *at(size_t b) const
{
return &m_Data[b * m_BlockSize];
}
size_t blocksize() const
{
return m_BlockSize;
}
void clear()
{
m_Size = 0;
}
bool swap(size_t item1, size_t item2)
{
/* Make sure there is extra space available */
if (!GrowIfNeeded(1))
{
return false;
}
cell *pri = at(item1);
cell *alt = at(item2);
/* Get our temporary array 1 after the limit */
cell *temp = &m_Data[m_Size * m_BlockSize];
memcpy(temp, pri, sizeof(cell)* m_BlockSize);
memcpy(pri, alt, sizeof(cell)* m_BlockSize);
memcpy(alt, temp, sizeof(cell)* m_BlockSize);
return true;
}
void remove(size_t index)
{
/* If we're at the end, take the easy way out */
if (index == m_Size - 1)
{
m_Size--;
return;
}
/* Otherwise, it's time to move stuff! */
size_t remaining_indexes = (m_Size - 1) - index;
cell *src = at(index + 1);
cell *dest = at(index);
memmove(dest, src, sizeof(cell)* m_BlockSize * remaining_indexes);
m_Size--;
}
cell *insert_at(size_t index)
{
/* Make sure it'll fit */
if (!GrowIfNeeded(1))
{
return NULL;
}
/* move everything up */
cell *src = at(index);
cell *dst = at(index + 1);
memmove(dst, src, sizeof(cell)* m_BlockSize * (m_Size - index));
m_Size++;
return src;
}
bool resize(size_t count)
{
if (count <= m_Size)
{
m_Size = count;
return true;
}
if (!GrowIfNeeded(count - m_Size))
{
return false;
}
m_Size = count;
return true;
}
CellArray *clone()
{
CellArray *array = new CellArray(m_BlockSize);
array->m_AllocSize = m_AllocSize;
array->m_Size = m_Size;
array->m_Data = (cell *)malloc(sizeof(cell)* m_BlockSize * m_AllocSize);
memcpy(array->m_Data, m_Data, sizeof(cell)* m_BlockSize * m_Size);
return array;
}
cell *base()
{
return m_Data;
}
size_t mem_usage()
{
return m_AllocSize * m_BlockSize * sizeof(cell);
}
private:
bool GrowIfNeeded(size_t count)
{
/* Shortcut out if we can store this */
if (m_Size + count <= m_AllocSize)
{
return true;
}
/* Set a base allocation size of 8 items */
if (!m_AllocSize)
{
m_AllocSize = m_BaseSize;
}
/* If it's not enough, keep doubling */
while (m_Size + count > m_AllocSize)
{
m_AllocSize *= 2;
}
/* finally, allocate the new block */
if (m_Data)
{
m_Data = (cell *)realloc(m_Data, sizeof(cell)* m_BlockSize * m_AllocSize);
}
else {
m_Data = (cell *)malloc(sizeof(cell)* m_BlockSize * m_AllocSize);
}
return (m_Data != NULL);
}
private:
cell *m_Data;
size_t m_BlockSize;
size_t m_AllocSize;
size_t m_BaseSize;
size_t m_Size;
};
extern ke::Vector<CellArray*> VectorHolder;
inline CellArray* HandleToVector(AMX* amx, int handle)
{
if (handle <= 0 || handle > (int)VectorHolder.length())
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", handle);
return NULL;
}
CellArray* ret = VectorHolder[handle - 1];
if (ret == NULL)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", handle);
return NULL;
}
return ret;
}
#endif

View File

@ -52,11 +52,11 @@ public:
}
};
enum FileTimeType
{
FileTime_LastAccess = 0, /* Last access (not available on FAT) */
FileTime_Created = 1, /* Creation (not available on FAT) */
FileTime_LastChange = 2, /* Last modification */
enum FileTimeType
{
FileTime_LastAccess = 0, /* Last access (not available on FAT) */
FileTime_Created = 1, /* Creation (not available on FAT) */
FileTime_LastChange = 2, /* Last modification */
};
static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
@ -855,26 +855,26 @@ static cell AMX_NATIVE_CALL GetFileTime(AMX *amx, cell *params)
char path[256];
build_pathname_r(path, sizeof(path), "%s", file);
#if defined(WIN32)
struct _stat s;
if (_stat(path, &s) != 0)
#elif defined(__linux__) || defined(__APPLE__)
struct stat s;
if (stat(path, &s) != 0)
#endif
{
return -1;
}
time_t time_val = -1;
switch( params[2] )
{
case FileTime_LastAccess : time_val = s.st_atime; break;
case FileTime_Created : time_val = s.st_ctime; break;
case FileTime_LastChange : time_val = s.st_mtime; break;
}
#if defined(WIN32)
struct _stat s;
if (_stat(path, &s) != 0)
#elif defined(__linux__) || defined(__APPLE__)
struct stat s;
if (stat(path, &s) != 0)
#endif
{
return -1;
}
time_t time_val = -1;
switch( params[2] )
{
case FileTime_LastAccess : time_val = s.st_atime; break;
case FileTime_Created : time_val = s.st_ctime; break;
case FileTime_LastChange : time_val = s.st_mtime; break;
}
return (cell)time_val;
}

View File

@ -58,14 +58,14 @@ void validate_menu_text(char *str)
*(str-offs) = '\0';
}
}
}
Menu *get_menu_by_id(int id)
{
if (id < 0 || size_t(id) >= g_NewMenus.size() || !g_NewMenus[id])
return NULL;
return g_NewMenus[id];
}
Menu *get_menu_by_id(int id)
{
if (id < 0 || size_t(id) >= g_NewMenus.size() || !g_NewMenus[id])
return NULL;
return g_NewMenus[id];
}
Menu::Menu(const char *title, AMX *amx, int fid) : m_Title(title), m_ItemColor("\\r"),
@ -311,11 +311,11 @@ bool Menu::Display(int player, page_t page)
void Menu::Close(int player)
{
CPlayer *pPlayer = GET_PLAYER_POINTER_I(player);
int status;
if (gpGlobals->time > pPlayer->menuexpire)
status = MENU_TIMEOUT;
else
int status;
if (gpGlobals->time > pPlayer->menuexpire)
status = MENU_TIMEOUT;
else
status = MENU_EXIT;
pPlayer->keys = 0;
@ -700,40 +700,40 @@ static cell AMX_NATIVE_CALL menu_addtext(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL menu_addblank2(AMX *amx, cell *params)
{
GETMENU(params[1]);
if (!pMenu->items_per_page && pMenu->GetItemCount() >= 10)
{
LogError(amx, AMX_ERR_NATIVE, "Non-paginated menus are limited to 10 items.");
return 0;
}
menuitem *pItem = pMenu->AddItem("", "", 0);
pItem->isBlank = true;
return 1;
}
static cell AMX_NATIVE_CALL menu_addtext2(AMX *amx, cell *params)
{
int len;
char *name;
GETMENU(params[1]);
if (!pMenu->items_per_page && pMenu->GetItemCount() >= 10)
{
LogError(amx, AMX_ERR_NATIVE, "Non-paginated menus are limited to 10 items.");
return 0;
}
name = get_amxstring(amx, params[2], 0, len);
validate_menu_text(name);
menuitem *pItem = pMenu->AddItem(name, "", 0);
pItem->isBlank = true;
static cell AMX_NATIVE_CALL menu_addblank2(AMX *amx, cell *params)
{
GETMENU(params[1]);
if (!pMenu->items_per_page && pMenu->GetItemCount() >= 10)
{
LogError(amx, AMX_ERR_NATIVE, "Non-paginated menus are limited to 10 items.");
return 0;
}
menuitem *pItem = pMenu->AddItem("", "", 0);
pItem->isBlank = true;
return 1;
}
static cell AMX_NATIVE_CALL menu_addtext2(AMX *amx, cell *params)
{
int len;
char *name;
GETMENU(params[1]);
if (!pMenu->items_per_page && pMenu->GetItemCount() >= 10)
{
LogError(amx, AMX_ERR_NATIVE, "Non-paginated menus are limited to 10 items.");
return 0;
}
name = get_amxstring(amx, params[2], 0, len);
validate_menu_text(name);
menuitem *pItem = pMenu->AddItem(name, "", 0);
pItem->isBlank = true;
return 1;
}
@ -805,7 +805,7 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
break;
}
Menu *pOther = g_NewMenus[menu];
Menu *pOther = g_NewMenus[menu];
pOther->Close(pPlayer->index);
/* Infinite loop counter */
@ -822,7 +822,7 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
if (time < 0)
pPlayer->menuexpire = INFINITE;
else
else
pPlayer->menuexpire = gpGlobals->time + static_cast<float>(time);
return pMenu->Display(player, page);
@ -1082,7 +1082,7 @@ static cell AMX_NATIVE_CALL menu_destroy(AMX *amx, cell *params)
{
player = GET_PLAYER_POINTER_I(i);
if (player->newmenu == pMenu->thisId)
{
{
pMenu->Close(player->index);
}
}

View File

@ -7,42 +7,42 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <string.h>
#include "nongpl_matches.h"
NONGPL_PLUGIN_T NONGPL_PLUGIN_LIST[] =
{
{"Live", "CZ Gun Game", "czgungame.amxx"},
{"Live", "AMXX Gun Game", "czgungame.amxx"},
{NULL, NULL, NULL},
};
NONGPL_CVAR_T NONGPL_CVAR_LIST[] =
{
{"gg_mode", 0},
{"gg_warmuptimer", 0},
{"gg_ff", 0},
{"gg_fflevel", 0},
{"gg_stats", 0},
{"gg_dm", 0},
{"gg_turbo", 0},
{"amx_ggreset", 1},
{"amx_gg", 1},
{NULL, 0},
};
bool CheckBadConList(const char *cvar, int type)
{
int i = 0;
while (NONGPL_CVAR_LIST[i].cvar != NULL)
{
if (NONGPL_CVAR_LIST[i].type == type
&& strcmp(NONGPL_CVAR_LIST[i].cvar, cvar) == 0)
{
return true;
}
i++;
}
return false;
}
#include <string.h>
#include "nongpl_matches.h"
NONGPL_PLUGIN_T NONGPL_PLUGIN_LIST[] =
{
{"Live", "CZ Gun Game", "czgungame.amxx"},
{"Live", "AMXX Gun Game", "czgungame.amxx"},
{NULL, NULL, NULL},
};
NONGPL_CVAR_T NONGPL_CVAR_LIST[] =
{
{"gg_mode", 0},
{"gg_warmuptimer", 0},
{"gg_ff", 0},
{"gg_fflevel", 0},
{"gg_stats", 0},
{"gg_dm", 0},
{"gg_turbo", 0},
{"amx_ggreset", 1},
{"amx_gg", 1},
{NULL, 0},
};
bool CheckBadConList(const char *cvar, int type)
{
int i = 0;
while (NONGPL_CVAR_LIST[i].cvar != NULL)
{
if (NONGPL_CVAR_LIST[i].type == type
&& strcmp(NONGPL_CVAR_LIST[i].cvar, cvar) == 0)
{
return true;
}
i++;
}
return false;
}

View File

@ -6,25 +6,25 @@
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#ifndef _INCLUDE_AMXMODX_NONGPL_MATCHES_H_
#define _INCLUDE_AMXMODX_NONGPL_MATCHES_H_
struct NONGPL_PLUGIN_T
{
const char *author;
const char *title;
const char *filename;
};
struct NONGPL_CVAR_T
{
const char *cvar;
int type;
};
extern NONGPL_PLUGIN_T NONGPL_PLUGIN_LIST[];
extern NONGPL_CVAR_T NONGPL_CVAR_LIST[];
extern bool CheckBadConList(const char *cvar, int type);
#endif //_INCLUDE_AMXMODX_NONGPL_MATCHES_H_
#ifndef _INCLUDE_AMXMODX_NONGPL_MATCHES_H_
#define _INCLUDE_AMXMODX_NONGPL_MATCHES_H_
struct NONGPL_PLUGIN_T
{
const char *author;
const char *title;
const char *filename;
};
struct NONGPL_CVAR_T
{
const char *cvar;
int type;
};
extern NONGPL_PLUGIN_T NONGPL_PLUGIN_LIST[];
extern NONGPL_CVAR_T NONGPL_CVAR_LIST[];
extern bool CheckBadConList(const char *cvar, int type);
#endif //_INCLUDE_AMXMODX_NONGPL_MATCHES_H_

View File

@ -75,21 +75,21 @@ int sort_ints_desc(const void *int1, const void *int2)
return (*(int *)int2) - (*(int *)int1);
}
void sort_random(cell *array, cell size)
{
srand((unsigned int)time(NULL));
for (int i = size-1; i > 0; i--)
{
int n = rand() % (i + 1);
if (array[i] != array[n])
{
array[i] ^= array[n];
array[n] ^= array[i];
array[i] ^= array[n];
}
}
void sort_random(cell *array, cell size)
{
srand((unsigned int)time(NULL));
for (int i = size-1; i > 0; i--)
{
int n = rand() % (i + 1);
if (array[i] != array[n])
{
array[i] ^= array[n];
array[n] ^= array[i];
array[i] ^= array[n];
}
}
}
static cell AMX_NATIVE_CALL SortIntegers(AMX *amx, cell *params)
@ -395,92 +395,92 @@ static cell AMX_NATIVE_CALL SortCustom2D(AMX *amx, cell *params)
return 1;
}
enum SortType
{
Sort_Integer = 0,
Sort_Float,
Sort_String,
};
int sort_adtarray_strings_asc(const void *str1, const void *str2)
{
return strcmp((char *) str1, (char *) str2);
}
int sort_adtarray_strings_desc(const void *str1, const void *str2)
{
return strcmp((char *) str2, (char *) str1);
enum SortType
{
Sort_Integer = 0,
Sort_Float,
Sort_String,
};
int sort_adtarray_strings_asc(const void *str1, const void *str2)
{
return strcmp((char *) str1, (char *) str2);
}
void sort_adt_random(CellArray *cArray)
{
size_t arraysize = cArray->size();
srand((unsigned int)time(NULL));
for (int i = arraysize-1; i > 0; i--)
{
int n = rand() % (i + 1);
cArray->swap(i, n);
}
int sort_adtarray_strings_desc(const void *str1, const void *str2)
{
return strcmp((char *) str2, (char *) str1);
}
void sort_adt_random(CellArray *cArray)
{
size_t arraysize = cArray->size();
srand((unsigned int)time(NULL));
for (int i = arraysize-1; i > 0; i--)
{
int n = rand() % (i + 1);
cArray->swap(i, n);
}
}
static cell AMX_NATIVE_CALL SortADTArray(AMX *amx, cell *params)
{
CellArray* vec = HandleToVector(amx, params[1]);
if (vec == NULL)
{
return 0;
CellArray* vec = HandleToVector(amx, params[1]);
if (vec == NULL)
{
return 0;
}
cell order = params[2];
if (order == Sort_Random)
{
sort_adt_random(vec);
return 1;
cell order = params[2];
if (order == Sort_Random)
{
sort_adt_random(vec);
return 1;
}
cell type = params[3];
size_t arraysize = vec->size();
size_t blocksize = vec->blocksize();
size_t arraysize = vec->size();
size_t blocksize = vec->blocksize();
cell *array = vec->base();
if (type == Sort_Integer)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_ints_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_ints_desc);
}
}
else if (type == Sort_Float)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_floats_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_floats_desc);
}
}
else if (type == Sort_String)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_adtarray_strings_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_adtarray_strings_desc);
}
if (type == Sort_Integer)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_ints_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_ints_desc);
}
}
else if (type == Sort_Float)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_floats_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_floats_desc);
}
}
else if (type == Sort_String)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_adtarray_strings_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_adtarray_strings_desc);
}
}
return 1;

File diff suppressed because it is too large Load Diff

View File

@ -11,375 +11,375 @@
// Counter-Strike Module
//
#include "CstrikeDatas.h"
#include "CstrikeUtils.h"
#include "CDetour/detours.h"
#include <sm_stringhashmap.h>
void CtrlDetours_ClientCommand(bool set);
void CtrlDetours_BuyCommands(bool set);
int ForwardInternalCommand = -1;
int ForwardOnBuy = -1;
int ForwardOnBuyAttempt = -1;
int *UseBotArgs = NULL;
const char **BotArgs = NULL;
CDetour *ClientCommandDetour = NULL;
CDetour *GiveShieldDetour = NULL;
CDetour *GiveNamedItemDetour = NULL;
CDetour *AddAccountDetour = NULL;
int CurrentItemId = 0;
StringHashMap<int> ItemAliasList;
extern enginefuncs_t *g_pengfuncsTable;
void InitializeHacks()
{
#if defined AMD64
#error UNSUPPORTED
#endif
CtrlDetours_ClientCommand(true);
CtrlDetours_BuyCommands(true);
}
void ShutdownHacks()
{
CtrlDetours_ClientCommand(false);
CtrlDetours_BuyCommands(false);
}
#undef CMD_ARGV
const char *CMD_ARGV(int i)
{
if (*UseBotArgs)
{
if (i < 4)
{
return BotArgs[i];
}
return NULL;
}
return g_engfuncs.pfnCmd_Argv(i);
}
void OnEmitSound(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch)
{
// If shield is blocked with CS_OnBuy, we need to block the pickup sound ("items/gunpickup2.wav")
// as well played right after. Why this sound is not contained in GiveShield()?
g_pengfuncsTable->pfnEmitSound = NULL;
RETURN_META(MRES_SUPERCEDE);
}
DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientCommand(edict_t *pEntity)
{
const char *command = CMD_ARGV(0);
// A new command is triggered, reset variable, always.
CurrentItemId = 0;
// Purpose is to retrieve an item id based on alias name or selected item from menu,
// to be used in OnBuy* forwards.
if ((ForwardOnBuyAttempt != -1 || ForwardOnBuy != -1) && command && *command)
{
int itemId = 0;
// Handling buy via menu.
if (!strcmp(command, "menuselect"))
{
int slot = atoi(CMD_ARGV(1));
if (slot > 0 && slot < 9)
{
static const int menuItemsTe[][9] =
{
/* Menu_Buy */ { 0, 0, 0, 0, 0, 0, CSI_PRIMAMMO, CSI_SECAMMO, 0 },
/* Menu_BuyPistol */ { 0, CSI_GLOCK18, CSI_USP, CSI_P228, CSI_DEAGLE, CSI_ELITE, 0, 0, 0 },
/* Menu_BuyRifle */ { 0, CSI_GALI, CSI_AK47, CSI_SCOUT, CSI_SG552, CSI_AWP, CSI_G3SG1, 0, 0 },
/* Menu_BuyMachineGun */ { 0, CSI_M249, 0, 0, 0, 0, 0, 0, 0 },
/* Menu_BuyShotgun */ { 0, CSI_M3, CSI_XM1014, 0, 0, 0, 0, 0, 0 },
/* Menu_BuySubMachineGun */ { 0, CSI_MAC10, CSI_MP5NAVY, CSI_UMP45, CSI_P90, 0, 0, 0, 0 },
/* Menu_BuyItem */ { 0, CSI_VEST, CSI_VESTHELM, CSI_FLASHBANG, CSI_HEGRENADE, CSI_SMOKEGRENADE, CSI_NVGS, 0, 0 }
};
static const int menuItemsCt[][9] =
{
/* Menu_Buy */ { 0, 0, 0, 0, 0, 0, CSI_PRIMAMMO, CSI_SECAMMO, 0 },
/* Menu_BuyPistol */ { 0, CSI_GLOCK18, CSI_USP, CSI_P228, CSI_DEAGLE, CSI_FIVESEVEN, 0, 0, 0 },
/* Menu_BuyRifle */ { 0, CSI_FAMAS, CSI_SCOUT, CSI_M4A1, CSI_AUG, CSI_SG550, CSI_AWP, 0, 0 },
/* Menu_BuyMachineGun */ { 0, CSI_M249, 0, 0, 0, 0, 0, 0, 0 },
/* Menu_BuyShotgun */ { 0, CSI_M3, CSI_XM1014, 0, 0, 0, 0, 0, 0 },
/* Menu_BuySubMachineGun */ { 0, CSI_TMP, CSI_MP5NAVY, CSI_UMP45, CSI_P90, 0, 0, 0, 0 },
/* Menu_BuyItem */ { 0, CSI_VEST, CSI_VESTHELM, CSI_FLASHBANG, CSI_HEGRENADE, CSI_SMOKEGRENADE, CSI_NVGS, CSI_DEFUSER, CSI_SHIELDGUN }
};
int menuId = *((int *)pEdict->pvPrivateData + OFFSET_MENU);
if (menuId >= Menu_Buy && menuId <= Menu_BuyItem)
{
int team = *((int *)pEdict->pvPrivateData + OFFSET_TEAM);
switch (team)
{
case TEAM_T: itemId = menuItemsTe[menuId - 4][slot]; break; // -4 because array is zero-based and Menu_Buy* constants starts from 4.
case TEAM_CT:itemId = menuItemsCt[menuId - 4][slot]; break;
}
if (itemId)
{
CurrentItemId = itemId;
}
}
}
}
else // Handling buy via alias
{
if (ItemAliasList.retrieve(command, &itemId))
{
CurrentItemId = itemId;
}
}
}
int client = ENTINDEX(pEdict);
if (ForwardInternalCommand != -1 && *UseBotArgs)
{
const char *args = *BotArgs;
if (MF_ExecuteForward(ForwardInternalCommand, static_cast<cell>(client), args) > 0)
{
return;
}
}
if (ForwardOnBuyAttempt != -1 &&
CurrentItemId &&
MF_IsPlayerAlive(client) &&
MF_ExecuteForward(ForwardOnBuyAttempt, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0)
{
return;
}
DETOUR_STATIC_CALL(C_ClientCommand)(pEdict);
}
DETOUR_DECL_MEMBER1(GiveNamedItem, void, const char*, pszName) // void CBasePlayer::GiveNamedItem(const char *pszName)
{
// If the current item id is not null, this means player has triggers a buy command.
if (CurrentItemId)
{
int client = PrivateToIndex(this);
if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0)
{
return;
}
}
// From here, forward is not blocked, resetting this
// to ignore code in AddAccount which is called right after.
CurrentItemId = 0;
// Give me my item!
DETOUR_MEMBER_CALL(GiveNamedItem)(pszName);
}
DETOUR_DECL_MEMBER1(GiveShield, void, bool, bRetire) // void CBasePlayer::GiveShield(bool bRetire)
{
// Special case for shield. Game doesn't use GiveNamedItem() to give a shield.
if (CurrentItemId == CSI_SHIELDGUN)
{
int client = PrivateToIndex(this);
if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), CSI_SHIELDGUN) > 0)
{
return;
}
}
// From here, forward is not blocked, resetting this
// to ignore code in AddAccount which is called right after.
CurrentItemId = 0;
// Give me my shield!
DETOUR_MEMBER_CALL(GiveShield)(bRetire);
}
DETOUR_DECL_MEMBER2(AddAccount, void, int, amount, bool, bTrackChange) // void CBasePlayer::AddAccount(int amount, bool bTrackChange)
{
// No buy command or forward not blocked.
// Resuming game flow.
if (!CurrentItemId)
{
DETOUR_MEMBER_CALL(AddAccount)(amount, bTrackChange);
}
// Shield is blocked.
// We need to hook EmitSound to block pickup sound played right after.
else if (CurrentItemId == CSI_SHIELDGUN)
{
g_pengfuncsTable->pfnEmitSound = OnEmitSound;
}
// Let's reset this right away to avoid issues.
CurrentItemId = 0;
}
void CtrlDetours_ClientCommand(bool set)
{
if (set)
{
void *target = (void *)MDLL_ClientCommand;
#if defined(WIN32)
UseBotArgs = *(int **)((unsigned char *)target + CS_CLICMD_OFFS_USEBOTARGS);
BotArgs = (const char **)*(const char **)((unsigned char *)target + CS_CLICMD_OFFS_BOTARGS);
#elif defined(__linux__) || defined(__APPLE__)
UseBotArgs = (int *)UTIL_FindAddressFromEntry(CS_IDENT_USEBOTARGS, CS_IDENT_HIDDEN_STATE);
BotArgs = (const char **)UTIL_FindAddressFromEntry(CS_IDENT_BOTARGS, CS_IDENT_HIDDEN_STATE);
#endif
ClientCommandDetour = DETOUR_CREATE_STATIC_FIXED(C_ClientCommand, target);
if (!ClientCommandDetour)
{
MF_Log("ClientCommand is not available - forward client_command has been disabled");
}
}
else
{
if (ClientCommandDetour)
ClientCommandDetour->Destroy();
ItemAliasList.clear();
}
}
void ToggleDetour_ClientCommands(bool enable)
{
if (ClientCommandDetour)
(enable) ? ClientCommandDetour->EnableDetour() : ClientCommandDetour->DisableDetour();
if (enable)
{
// Build the item alias list.
// Used in ClientCommand to check and get fastly item id from alias name.
typedef struct
{
const char *alias;
int id;
} itemBuyAliasInfo;
itemBuyAliasInfo aliasToId[] =
{
{ "p228" , CSI_P228 }, { "228compact" , CSI_P228 },
{ "scout" , CSI_SCOUT }, { "hegren" , CSI_HEGRENADE },
{ "xm1014" , CSI_XM1014 }, { "autoshotgun", CSI_XM1014 },
{ "mac10" , CSI_MAC10 }, { "aug" , CSI_AUG },
{ "bullpup" , CSI_AUG }, { "sgren" , CSI_SMOKEGRENADE },
{ "elites" , CSI_ELITE }, { "fn57" , CSI_FIVESEVEN },
{ "fiveseven" , CSI_FIVESEVEN }, { "ump45" , CSI_UMP45 },
{ "sg550" , CSI_SG550 }, { "krieg550" , CSI_SG550 },
{ "galil" , CSI_GALI }, { "defender" , CSI_GALI },
{ "famas" , CSI_FAMAS }, { "clarion" , CSI_FAMAS },
{ "usp" , CSI_USP }, { "km45" , CSI_USP },
{ "glock" , CSI_GLOCK18 }, { "9x19mm" , CSI_GLOCK18 },
{ "awp" , CSI_AWP }, { "magnum" , CSI_AWP },
{ "mp5" , CSI_MP5NAVY }, { "smg" , CSI_MP5NAVY },
{ "m249" , CSI_M249 }, { "m3" , CSI_M3 },
{ "12gauge" , CSI_M3 }, { "m4a1" , CSI_M4A1 },
{ "tmp" , CSI_TMP }, { "mp" , CSI_TMP },
{ "g3sg1" , CSI_G3SG1 }, { "d3au1" , CSI_G3SG1 },
{ "flash" , CSI_FLASHBANG }, { "deagle" , CSI_DEAGLE },
{ "nighthawk" , CSI_DEAGLE }, { "sg552" , CSI_SG552 },
{ "krieg552" , CSI_SG552 }, { "ak47" , CSI_AK47 },
{ "cv47" , CSI_AK47 }, { "p90" , CSI_P90 },
{ "c90" , CSI_P90 }, { "vest" , CSI_VEST },
{ "vesthelm" , CSI_VESTHELM }, { "defuser" , CSI_DEFUSER },
{ "nvgs" , CSI_NVGS }, { "shield" , CSI_SHIELDGUN },
{ "buyammo1" , CSI_PRIMAMMO }, { "primammo" , CSI_PRIMAMMO },
{ "buyammo2" , CSI_SECAMMO }, { "secammo" , CSI_SECAMMO },
{ NULL , 0 }
};
for (size_t i = 0; aliasToId[i].alias != NULL; ++i)
{
ItemAliasList.insert(aliasToId[i].alias, aliasToId[i].id);
}
}
else
{
ItemAliasList.clear();
}
}
void CtrlDetours_BuyCommands(bool set)
{
if (set)
{
void *giveShieldAddress = UTIL_FindAddressFromEntry(CS_IDENT_GIVENSHIELD , CS_IDENT_HIDDEN_STATE);
void *giveNamedItemAddress = UTIL_FindAddressFromEntry(CS_IDENT_GIVENAMEDITEM, CS_IDENT_HIDDEN_STATE);
void *addAccountAddress = UTIL_FindAddressFromEntry(CS_IDENT_ADDACCOUNT , CS_IDENT_HIDDEN_STATE);
GiveShieldDetour = DETOUR_CREATE_MEMBER_FIXED(GiveShield, giveShieldAddress);
GiveNamedItemDetour = DETOUR_CREATE_MEMBER_FIXED(GiveNamedItem, giveNamedItemAddress);
AddAccountDetour = DETOUR_CREATE_MEMBER_FIXED(AddAccount, addAccountAddress);
if (!GiveShieldDetour || !GiveNamedItemDetour || !AddAccountDetour)
{
if (!GiveShieldDetour)
{
MF_Log("GiveShield is not available");
}
if (!GiveNamedItemDetour)
{
MF_Log("GiveNamedItem is not available");
}
if (!AddAccountDetour)
{
MF_Log("AddAccount is not available");
}
MF_Log("Some functions are not available - forward CS_OnBuyAttempt and CS_OnBuy have been disabled");
}
}
else
{
if (GiveShieldDetour)
GiveShieldDetour->Destroy();
if (GiveNamedItemDetour)
GiveNamedItemDetour->Destroy();
if (AddAccountDetour)
AddAccountDetour->Destroy();
ItemAliasList.clear();
}
}
void ToggleDetour_BuyCommands(bool enable)
{
if (GiveShieldDetour)
(enable) ? GiveShieldDetour->EnableDetour() : GiveShieldDetour->DisableDetour();
if (GiveNamedItemDetour)
(enable) ? GiveNamedItemDetour->EnableDetour() : GiveNamedItemDetour->DisableDetour();
if (AddAccountDetour)
(enable) ? AddAccountDetour->EnableDetour() : AddAccountDetour->DisableDetour();
#include "CstrikeDatas.h"
#include "CstrikeUtils.h"
#include "CDetour/detours.h"
#include <sm_stringhashmap.h>
void CtrlDetours_ClientCommand(bool set);
void CtrlDetours_BuyCommands(bool set);
int ForwardInternalCommand = -1;
int ForwardOnBuy = -1;
int ForwardOnBuyAttempt = -1;
int *UseBotArgs = NULL;
const char **BotArgs = NULL;
CDetour *ClientCommandDetour = NULL;
CDetour *GiveShieldDetour = NULL;
CDetour *GiveNamedItemDetour = NULL;
CDetour *AddAccountDetour = NULL;
int CurrentItemId = 0;
StringHashMap<int> ItemAliasList;
extern enginefuncs_t *g_pengfuncsTable;
void InitializeHacks()
{
#if defined AMD64
#error UNSUPPORTED
#endif
CtrlDetours_ClientCommand(true);
CtrlDetours_BuyCommands(true);
}
void ShutdownHacks()
{
CtrlDetours_ClientCommand(false);
CtrlDetours_BuyCommands(false);
}
#undef CMD_ARGV
const char *CMD_ARGV(int i)
{
if (*UseBotArgs)
{
if (i < 4)
{
return BotArgs[i];
}
return NULL;
}
return g_engfuncs.pfnCmd_Argv(i);
}
void OnEmitSound(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch)
{
// If shield is blocked with CS_OnBuy, we need to block the pickup sound ("items/gunpickup2.wav")
// as well played right after. Why this sound is not contained in GiveShield()?
g_pengfuncsTable->pfnEmitSound = NULL;
RETURN_META(MRES_SUPERCEDE);
}
DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientCommand(edict_t *pEntity)
{
const char *command = CMD_ARGV(0);
// A new command is triggered, reset variable, always.
CurrentItemId = 0;
// Purpose is to retrieve an item id based on alias name or selected item from menu,
// to be used in OnBuy* forwards.
if ((ForwardOnBuyAttempt != -1 || ForwardOnBuy != -1) && command && *command)
{
int itemId = 0;
// Handling buy via menu.
if (!strcmp(command, "menuselect"))
{
int slot = atoi(CMD_ARGV(1));
if (slot > 0 && slot < 9)
{
static const int menuItemsTe[][9] =
{
/* Menu_Buy */ { 0, 0, 0, 0, 0, 0, CSI_PRIMAMMO, CSI_SECAMMO, 0 },
/* Menu_BuyPistol */ { 0, CSI_GLOCK18, CSI_USP, CSI_P228, CSI_DEAGLE, CSI_ELITE, 0, 0, 0 },
/* Menu_BuyRifle */ { 0, CSI_GALI, CSI_AK47, CSI_SCOUT, CSI_SG552, CSI_AWP, CSI_G3SG1, 0, 0 },
/* Menu_BuyMachineGun */ { 0, CSI_M249, 0, 0, 0, 0, 0, 0, 0 },
/* Menu_BuyShotgun */ { 0, CSI_M3, CSI_XM1014, 0, 0, 0, 0, 0, 0 },
/* Menu_BuySubMachineGun */ { 0, CSI_MAC10, CSI_MP5NAVY, CSI_UMP45, CSI_P90, 0, 0, 0, 0 },
/* Menu_BuyItem */ { 0, CSI_VEST, CSI_VESTHELM, CSI_FLASHBANG, CSI_HEGRENADE, CSI_SMOKEGRENADE, CSI_NVGS, 0, 0 }
};
static const int menuItemsCt[][9] =
{
/* Menu_Buy */ { 0, 0, 0, 0, 0, 0, CSI_PRIMAMMO, CSI_SECAMMO, 0 },
/* Menu_BuyPistol */ { 0, CSI_GLOCK18, CSI_USP, CSI_P228, CSI_DEAGLE, CSI_FIVESEVEN, 0, 0, 0 },
/* Menu_BuyRifle */ { 0, CSI_FAMAS, CSI_SCOUT, CSI_M4A1, CSI_AUG, CSI_SG550, CSI_AWP, 0, 0 },
/* Menu_BuyMachineGun */ { 0, CSI_M249, 0, 0, 0, 0, 0, 0, 0 },
/* Menu_BuyShotgun */ { 0, CSI_M3, CSI_XM1014, 0, 0, 0, 0, 0, 0 },
/* Menu_BuySubMachineGun */ { 0, CSI_TMP, CSI_MP5NAVY, CSI_UMP45, CSI_P90, 0, 0, 0, 0 },
/* Menu_BuyItem */ { 0, CSI_VEST, CSI_VESTHELM, CSI_FLASHBANG, CSI_HEGRENADE, CSI_SMOKEGRENADE, CSI_NVGS, CSI_DEFUSER, CSI_SHIELDGUN }
};
int menuId = *((int *)pEdict->pvPrivateData + OFFSET_MENU);
if (menuId >= Menu_Buy && menuId <= Menu_BuyItem)
{
int team = *((int *)pEdict->pvPrivateData + OFFSET_TEAM);
switch (team)
{
case TEAM_T: itemId = menuItemsTe[menuId - 4][slot]; break; // -4 because array is zero-based and Menu_Buy* constants starts from 4.
case TEAM_CT:itemId = menuItemsCt[menuId - 4][slot]; break;
}
if (itemId)
{
CurrentItemId = itemId;
}
}
}
}
else // Handling buy via alias
{
if (ItemAliasList.retrieve(command, &itemId))
{
CurrentItemId = itemId;
}
}
}
int client = ENTINDEX(pEdict);
if (ForwardInternalCommand != -1 && *UseBotArgs)
{
const char *args = *BotArgs;
if (MF_ExecuteForward(ForwardInternalCommand, static_cast<cell>(client), args) > 0)
{
return;
}
}
if (ForwardOnBuyAttempt != -1 &&
CurrentItemId &&
MF_IsPlayerAlive(client) &&
MF_ExecuteForward(ForwardOnBuyAttempt, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0)
{
return;
}
DETOUR_STATIC_CALL(C_ClientCommand)(pEdict);
}
DETOUR_DECL_MEMBER1(GiveNamedItem, void, const char*, pszName) // void CBasePlayer::GiveNamedItem(const char *pszName)
{
// If the current item id is not null, this means player has triggers a buy command.
if (CurrentItemId)
{
int client = PrivateToIndex(this);
if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0)
{
return;
}
}
// From here, forward is not blocked, resetting this
// to ignore code in AddAccount which is called right after.
CurrentItemId = 0;
// Give me my item!
DETOUR_MEMBER_CALL(GiveNamedItem)(pszName);
}
DETOUR_DECL_MEMBER1(GiveShield, void, bool, bRetire) // void CBasePlayer::GiveShield(bool bRetire)
{
// Special case for shield. Game doesn't use GiveNamedItem() to give a shield.
if (CurrentItemId == CSI_SHIELDGUN)
{
int client = PrivateToIndex(this);
if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), CSI_SHIELDGUN) > 0)
{
return;
}
}
// From here, forward is not blocked, resetting this
// to ignore code in AddAccount which is called right after.
CurrentItemId = 0;
// Give me my shield!
DETOUR_MEMBER_CALL(GiveShield)(bRetire);
}
DETOUR_DECL_MEMBER2(AddAccount, void, int, amount, bool, bTrackChange) // void CBasePlayer::AddAccount(int amount, bool bTrackChange)
{
// No buy command or forward not blocked.
// Resuming game flow.
if (!CurrentItemId)
{
DETOUR_MEMBER_CALL(AddAccount)(amount, bTrackChange);
}
// Shield is blocked.
// We need to hook EmitSound to block pickup sound played right after.
else if (CurrentItemId == CSI_SHIELDGUN)
{
g_pengfuncsTable->pfnEmitSound = OnEmitSound;
}
// Let's reset this right away to avoid issues.
CurrentItemId = 0;
}
void CtrlDetours_ClientCommand(bool set)
{
if (set)
{
void *target = (void *)MDLL_ClientCommand;
#if defined(WIN32)
UseBotArgs = *(int **)((unsigned char *)target + CS_CLICMD_OFFS_USEBOTARGS);
BotArgs = (const char **)*(const char **)((unsigned char *)target + CS_CLICMD_OFFS_BOTARGS);
#elif defined(__linux__) || defined(__APPLE__)
UseBotArgs = (int *)UTIL_FindAddressFromEntry(CS_IDENT_USEBOTARGS, CS_IDENT_HIDDEN_STATE);
BotArgs = (const char **)UTIL_FindAddressFromEntry(CS_IDENT_BOTARGS, CS_IDENT_HIDDEN_STATE);
#endif
ClientCommandDetour = DETOUR_CREATE_STATIC_FIXED(C_ClientCommand, target);
if (!ClientCommandDetour)
{
MF_Log("ClientCommand is not available - forward client_command has been disabled");
}
}
else
{
if (ClientCommandDetour)
ClientCommandDetour->Destroy();
ItemAliasList.clear();
}
}
void ToggleDetour_ClientCommands(bool enable)
{
if (ClientCommandDetour)
(enable) ? ClientCommandDetour->EnableDetour() : ClientCommandDetour->DisableDetour();
if (enable)
{
// Build the item alias list.
// Used in ClientCommand to check and get fastly item id from alias name.
typedef struct
{
const char *alias;
int id;
} itemBuyAliasInfo;
itemBuyAliasInfo aliasToId[] =
{
{ "p228" , CSI_P228 }, { "228compact" , CSI_P228 },
{ "scout" , CSI_SCOUT }, { "hegren" , CSI_HEGRENADE },
{ "xm1014" , CSI_XM1014 }, { "autoshotgun", CSI_XM1014 },
{ "mac10" , CSI_MAC10 }, { "aug" , CSI_AUG },
{ "bullpup" , CSI_AUG }, { "sgren" , CSI_SMOKEGRENADE },
{ "elites" , CSI_ELITE }, { "fn57" , CSI_FIVESEVEN },
{ "fiveseven" , CSI_FIVESEVEN }, { "ump45" , CSI_UMP45 },
{ "sg550" , CSI_SG550 }, { "krieg550" , CSI_SG550 },
{ "galil" , CSI_GALI }, { "defender" , CSI_GALI },
{ "famas" , CSI_FAMAS }, { "clarion" , CSI_FAMAS },
{ "usp" , CSI_USP }, { "km45" , CSI_USP },
{ "glock" , CSI_GLOCK18 }, { "9x19mm" , CSI_GLOCK18 },
{ "awp" , CSI_AWP }, { "magnum" , CSI_AWP },
{ "mp5" , CSI_MP5NAVY }, { "smg" , CSI_MP5NAVY },
{ "m249" , CSI_M249 }, { "m3" , CSI_M3 },
{ "12gauge" , CSI_M3 }, { "m4a1" , CSI_M4A1 },
{ "tmp" , CSI_TMP }, { "mp" , CSI_TMP },
{ "g3sg1" , CSI_G3SG1 }, { "d3au1" , CSI_G3SG1 },
{ "flash" , CSI_FLASHBANG }, { "deagle" , CSI_DEAGLE },
{ "nighthawk" , CSI_DEAGLE }, { "sg552" , CSI_SG552 },
{ "krieg552" , CSI_SG552 }, { "ak47" , CSI_AK47 },
{ "cv47" , CSI_AK47 }, { "p90" , CSI_P90 },
{ "c90" , CSI_P90 }, { "vest" , CSI_VEST },
{ "vesthelm" , CSI_VESTHELM }, { "defuser" , CSI_DEFUSER },
{ "nvgs" , CSI_NVGS }, { "shield" , CSI_SHIELDGUN },
{ "buyammo1" , CSI_PRIMAMMO }, { "primammo" , CSI_PRIMAMMO },
{ "buyammo2" , CSI_SECAMMO }, { "secammo" , CSI_SECAMMO },
{ NULL , 0 }
};
for (size_t i = 0; aliasToId[i].alias != NULL; ++i)
{
ItemAliasList.insert(aliasToId[i].alias, aliasToId[i].id);
}
}
else
{
ItemAliasList.clear();
}
}
void CtrlDetours_BuyCommands(bool set)
{
if (set)
{
void *giveShieldAddress = UTIL_FindAddressFromEntry(CS_IDENT_GIVENSHIELD , CS_IDENT_HIDDEN_STATE);
void *giveNamedItemAddress = UTIL_FindAddressFromEntry(CS_IDENT_GIVENAMEDITEM, CS_IDENT_HIDDEN_STATE);
void *addAccountAddress = UTIL_FindAddressFromEntry(CS_IDENT_ADDACCOUNT , CS_IDENT_HIDDEN_STATE);
GiveShieldDetour = DETOUR_CREATE_MEMBER_FIXED(GiveShield, giveShieldAddress);
GiveNamedItemDetour = DETOUR_CREATE_MEMBER_FIXED(GiveNamedItem, giveNamedItemAddress);
AddAccountDetour = DETOUR_CREATE_MEMBER_FIXED(AddAccount, addAccountAddress);
if (!GiveShieldDetour || !GiveNamedItemDetour || !AddAccountDetour)
{
if (!GiveShieldDetour)
{
MF_Log("GiveShield is not available");
}
if (!GiveNamedItemDetour)
{
MF_Log("GiveNamedItem is not available");
}
if (!AddAccountDetour)
{
MF_Log("AddAccount is not available");
}
MF_Log("Some functions are not available - forward CS_OnBuyAttempt and CS_OnBuy have been disabled");
}
}
else
{
if (GiveShieldDetour)
GiveShieldDetour->Destroy();
if (GiveNamedItemDetour)
GiveNamedItemDetour->Destroy();
if (AddAccountDetour)
AddAccountDetour->Destroy();
ItemAliasList.clear();
}
}
void ToggleDetour_BuyCommands(bool enable)
{
if (GiveShieldDetour)
(enable) ? GiveShieldDetour->EnableDetour() : GiveShieldDetour->DisableDetour();
if (GiveNamedItemDetour)
(enable) ? GiveNamedItemDetour->EnableDetour() : GiveNamedItemDetour->DisableDetour();
if (AddAccountDetour)
(enable) ? AddAccountDetour->EnableDetour() : AddAccountDetour->DisableDetour();
}

View File

@ -153,10 +153,10 @@ qboolean Voice_SetClientListening(int iReceiver, int iSender, qboolean bListen)
int AddToFullPack_Post(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet)
{
if( player && ent == host && plinfo[ENTINDEX(ent)].iViewType != CAMERA_NONE )
{
state->rendermode = kRenderTransTexture;
state->renderamt = 100;
if( player && ent == host && plinfo[ENTINDEX(ent)].iViewType != CAMERA_NONE )
{
state->rendermode = kRenderTransTexture;
state->renderamt = 100;
}
RETURN_META_VALUE(MRES_IGNORED, 0);

View File

@ -161,15 +161,15 @@ void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int
g_cmd->impulse = 0;
}
// client_CmdStart
if (CmdStartForward != -1)
{
incmd = true;
retVal = MF_ExecuteForward(CmdStartForward, (cell)ENTINDEX(pEntity));
incmd = false;
if (retVal)
RETURN_META(MRES_SUPERCEDE);
// client_CmdStart
if (CmdStartForward != -1)
{
incmd = true;
retVal = MF_ExecuteForward(CmdStartForward, (cell)ENTINDEX(pEntity));
incmd = false;
if (retVal)
RETURN_META(MRES_SUPERCEDE);
}
RETURN_META(MRES_IGNORED);

View File

@ -292,97 +292,97 @@ static cell AMX_NATIVE_CALL SetHamParamItemInfo(AMX *amx, cell *params)
}
static cell AMX_NATIVE_CALL GetHamItemInfo(AMX *amx, cell *params)
{
static cell AMX_NATIVE_CALL GetHamItemInfo(AMX *amx, cell *params)
{
if (params[1] == 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Null iteminfo handle provided.");
return 0;
}
int type = params[2];
if ((type == ItemInfo_pszAmmo1 || type == ItemInfo_pszAmmo2 || type == ItemInfo_pszName) && (*params / sizeof(cell)) != 4)
{
}
int type = params[2];
if ((type == ItemInfo_pszAmmo1 || type == ItemInfo_pszAmmo2 || type == ItemInfo_pszName) && (*params / sizeof(cell)) != 4)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Bad arg count. Expected %d, got %d.", 4, *params / sizeof(cell));
return 0;
}
ItemInfo *pItem = reinterpret_cast<ItemInfo *>(params[1]);
switch (type)
{
case ItemInfo_iSlot:
return pItem->iSlot;
case ItemInfo_iPosition:
return pItem->iPosition;
case ItemInfo_pszAmmo1:
return MF_SetAmxString( amx, params[3], pItem->pszAmmo1 > 0 ? pItem->pszAmmo1 : "", params[4] );
case ItemInfo_iMaxAmmo1:
return pItem->iMaxAmmo1;
case ItemInfo_pszAmmo2:
return MF_SetAmxString( amx, params[3], pItem->pszAmmo2 > 0 ? pItem->pszAmmo2 : "", params[4] );
case ItemInfo_iMaxAmmo2:
return pItem->iMaxAmmo2;
case ItemInfo_pszName:
return MF_SetAmxString( amx, params[3], pItem->pszName > 0 ? pItem->pszName : "", params[4] );
case ItemInfo_iMaxClip:
return pItem->iMaxClip;
case ItemInfo_iId:
return pItem->iId;
case ItemInfo_iFlags:
return pItem->iFlags;
case ItemInfo_iWeight:
return pItem->iWeight;
}
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown ItemInfo type %d", type);
return 0;
return 0;
}
ItemInfo *pItem = reinterpret_cast<ItemInfo *>(params[1]);
switch (type)
{
case ItemInfo_iSlot:
return pItem->iSlot;
case ItemInfo_iPosition:
return pItem->iPosition;
case ItemInfo_pszAmmo1:
return MF_SetAmxString( amx, params[3], pItem->pszAmmo1 > 0 ? pItem->pszAmmo1 : "", params[4] );
case ItemInfo_iMaxAmmo1:
return pItem->iMaxAmmo1;
case ItemInfo_pszAmmo2:
return MF_SetAmxString( amx, params[3], pItem->pszAmmo2 > 0 ? pItem->pszAmmo2 : "", params[4] );
case ItemInfo_iMaxAmmo2:
return pItem->iMaxAmmo2;
case ItemInfo_pszName:
return MF_SetAmxString( amx, params[3], pItem->pszName > 0 ? pItem->pszName : "", params[4] );
case ItemInfo_iMaxClip:
return pItem->iMaxClip;
case ItemInfo_iId:
return pItem->iId;
case ItemInfo_iFlags:
return pItem->iFlags;
case ItemInfo_iWeight:
return pItem->iWeight;
}
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown ItemInfo type %d", type);
return 0;
}
CStack<ItemInfo *> g_FreeIIs;
static cell AMX_NATIVE_CALL CreateHamItemInfo(AMX *amx, cell *params)
{
ItemInfo *ii;
if (g_FreeIIs.empty())
{
ii = new ItemInfo;
}
else
{
ii = g_FreeIIs.front();
g_FreeIIs.pop();
}
memset(ii, 0, sizeof(ItemInfo));
return reinterpret_cast<cell>(ii);
}
static cell AMX_NATIVE_CALL FreeHamItemInfo(AMX *amx, cell *params)
{
ItemInfo *ii = reinterpret_cast<ItemInfo *>(params[1]);
if (!ii)
{
return 0;
}
g_FreeIIs.push(ii);
return 1;
CStack<ItemInfo *> g_FreeIIs;
static cell AMX_NATIVE_CALL CreateHamItemInfo(AMX *amx, cell *params)
{
ItemInfo *ii;
if (g_FreeIIs.empty())
{
ii = new ItemInfo;
}
else
{
ii = g_FreeIIs.front();
g_FreeIIs.pop();
}
memset(ii, 0, sizeof(ItemInfo));
return reinterpret_cast<cell>(ii);
}
static cell AMX_NATIVE_CALL FreeHamItemInfo(AMX *amx, cell *params)
{
ItemInfo *ii = reinterpret_cast<ItemInfo *>(params[1]);
if (!ii)
{
return 0;
}
g_FreeIIs.push(ii);
return 1;
}
@ -394,61 +394,61 @@ static cell AMX_NATIVE_CALL SetHamItemInfo(AMX *amx, cell *params)
return 0;
}
ItemInfo *pItem = reinterpret_cast<ItemInfo *>(params[1]);
cell *ptr = MF_GetAmxAddr(amx, params[3]);
int iLen;
switch (params[2])
{
case ItemInfo_iSlot:
pItem->iSlot = *ptr;
break;
case ItemInfo_iPosition:
pItem->iPosition = *ptr;
break;
case ItemInfo_pszAmmo1:
pItem->pszAmmo1 = MF_GetAmxString(amx, params[3], 0, &iLen);
return iLen;
case ItemInfo_iMaxAmmo1:
pItem->iMaxAmmo1 = *ptr;
break;
case ItemInfo_pszAmmo2:
pItem->pszAmmo2 = MF_GetAmxString(amx, params[3], 0, &iLen);
return iLen;
case ItemInfo_iMaxAmmo2:
pItem->iMaxAmmo2 = *ptr;
break;
case ItemInfo_pszName:
pItem->pszName = MF_GetAmxString(amx, params[3], 0, &iLen);
return iLen;
case ItemInfo_iMaxClip:
pItem->iMaxClip = *ptr;
break;
case ItemInfo_iId:
pItem->iId = *ptr;
break;
case ItemInfo_iFlags:
pItem->iFlags = *ptr;
break;
case ItemInfo_iWeight:
pItem->iWeight = *ptr;
break;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown ItemInfo type %d", params[2]);
return 0;
}
ItemInfo *pItem = reinterpret_cast<ItemInfo *>(params[1]);
cell *ptr = MF_GetAmxAddr(amx, params[3]);
int iLen;
switch (params[2])
{
case ItemInfo_iSlot:
pItem->iSlot = *ptr;
break;
case ItemInfo_iPosition:
pItem->iPosition = *ptr;
break;
case ItemInfo_pszAmmo1:
pItem->pszAmmo1 = MF_GetAmxString(amx, params[3], 0, &iLen);
return iLen;
case ItemInfo_iMaxAmmo1:
pItem->iMaxAmmo1 = *ptr;
break;
case ItemInfo_pszAmmo2:
pItem->pszAmmo2 = MF_GetAmxString(amx, params[3], 0, &iLen);
return iLen;
case ItemInfo_iMaxAmmo2:
pItem->iMaxAmmo2 = *ptr;
break;
case ItemInfo_pszName:
pItem->pszName = MF_GetAmxString(amx, params[3], 0, &iLen);
return iLen;
case ItemInfo_iMaxClip:
pItem->iMaxClip = *ptr;
break;
case ItemInfo_iId:
pItem->iId = *ptr;
break;
case ItemInfo_iFlags:
pItem->iFlags = *ptr;
break;
case ItemInfo_iWeight:
pItem->iWeight = *ptr;
break;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown ItemInfo type %d", params[2]);
return 0;
}
return 1;
}

View File

@ -22,47 +22,47 @@
enum
{
RET_VOID,
RET_BOOL,
RET_BOOL,
RET_INTEGER,
RET_SHORT,
RET_SHORT,
RET_FLOAT,
RET_VECTOR,
RET_STRING,
RET_CBASE,
RET_ENTVAR,
RET_EDICT,
RET_EDICT,
RET_TRACE,
RET_ITEMINFO
};
typedef struct
{
int iSlot;
int iPosition;
const char *pszAmmo1;
int iMaxAmmo1;
const char *pszAmmo2;
int iMaxAmmo2;
const char *pszName;
int iMaxClip;
int iId;
int iFlags;
int iWeight;
}
typedef struct
{
int iSlot;
int iPosition;
const char *pszAmmo1;
int iMaxAmmo1;
const char *pszAmmo2;
int iMaxAmmo2;
const char *pszName;
int iMaxClip;
int iId;
int iFlags;
int iWeight;
}
ItemInfo;
enum
{
ItemInfo_iSlot,
ItemInfo_iPosition,
ItemInfo_pszAmmo1,
ItemInfo_iMaxAmmo1,
ItemInfo_pszAmmo2,
ItemInfo_iMaxAmmo2,
ItemInfo_pszName,
ItemInfo_iMaxClip,
ItemInfo_iId,
ItemInfo_iFlags,
ItemInfo_iSlot,
ItemInfo_iPosition,
ItemInfo_pszAmmo1,
ItemInfo_iMaxAmmo1,
ItemInfo_pszAmmo2,
ItemInfo_iMaxAmmo2,
ItemInfo_pszName,
ItemInfo_iMaxClip,
ItemInfo_iId,
ItemInfo_iFlags,
ItemInfo_iWeight
};

File diff suppressed because it is too large Load Diff

View File

@ -53,18 +53,18 @@ void OnAmxxAttach(void)
assert(strcmp(hooklist[Ham_NS_UpdateOnRemove].name, "ns_updateonremove")==0);
assert(strcmp(hooklist[Ham_TS_ShouldCollide].name, "ts_shouldcollide")==0);
assert(strcmp(hooklist[Ham_GetDeathActivity].name, "getdeathactivity")==0);
assert(strcmp(hooklist[Ham_StopFollowing].name, "stopfollowing")==0);
assert(strcmp(hooklist[Ham_CS_Player_OnTouchingWeapon].name, "cstrike_player_ontouchingweapon")==0);
assert(strcmp(hooklist[Ham_DOD_Weapon_Special].name, "dod_weapon_special")==0);
assert(strcmp(hooklist[Ham_TFC_RadiusDamage2].name, "tfc_radiusdamage2")==0);
assert(strcmp(hooklist[Ham_ESF_Weapon_HolsterWhenMeleed].name, "esf_weapon_holsterwhenmeleed") == 0);
assert(strcmp(hooklist[Ham_NS_Weapon_GetDeployTime].name, "ns_weapon_getdeploytime")==0);
assert(strcmp(hooklist[Ham_SC_MedicCallSound].name, "sc_mediccallsound")==0);
assert(strcmp(hooklist[Ham_SC_Player_CanTouchPlayer].name, "sc_player_cantouchplayer")==0);
assert(strcmp(hooklist[Ham_SC_Weapon_ChangeWeaponSkin].name, "sc_weapon_changeweaponskin")==0);
assert(strcmp(hooklist[Ham_Item_GetItemInfo].name, "item_getiteminfo") == 0);
assert(strcmp(hooklist[Ham_GetDeathActivity].name, "getdeathactivity")==0);
assert(strcmp(hooklist[Ham_StopFollowing].name, "stopfollowing")==0);
assert(strcmp(hooklist[Ham_CS_Player_OnTouchingWeapon].name, "cstrike_player_ontouchingweapon")==0);
assert(strcmp(hooklist[Ham_DOD_Weapon_Special].name, "dod_weapon_special")==0);
assert(strcmp(hooklist[Ham_TFC_RadiusDamage2].name, "tfc_radiusdamage2")==0);
assert(strcmp(hooklist[Ham_ESF_Weapon_HolsterWhenMeleed].name, "esf_weapon_holsterwhenmeleed") == 0);
assert(strcmp(hooklist[Ham_NS_Weapon_GetDeployTime].name, "ns_weapon_getdeploytime")==0);
assert(strcmp(hooklist[Ham_SC_MedicCallSound].name, "sc_mediccallsound")==0);
assert(strcmp(hooklist[Ham_SC_Player_CanTouchPlayer].name, "sc_player_cantouchplayer")==0);
assert(strcmp(hooklist[Ham_SC_Weapon_ChangeWeaponSkin].name, "sc_weapon_changeweaponskin")==0);
assert(strcmp(hooklist[Ham_Item_GetItemInfo].name, "item_getiteminfo") == 0);
MF_AddNatives(pdata_natives_safe);
if (ReadConfig() > 0)
{
@ -91,15 +91,15 @@ void OnAmxxAttach(void)
}
}
extern CStack<ItemInfo *> g_FreeIIs;
void OnAmxxDetach()
{
while (!g_FreeIIs.empty())
{
delete g_FreeIIs.front();
g_FreeIIs.pop();
}
extern CStack<ItemInfo *> g_FreeIIs;
void OnAmxxDetach()
{
while (!g_FreeIIs.empty())
{
delete g_FreeIIs.front();
g_FreeIIs.pop();
}
}
void HamCommand(void);

File diff suppressed because it is too large Load Diff

View File

@ -25,12 +25,12 @@ cell Call_Void_Cbase(AMX *amx, cell *params);
cell Call_Int_Float_Int(AMX *amx, cell *params);
cell Call_Int_Float_Int_Int(AMX *amx, cell *params);
cell Call_Int_Float_Int_Int(AMX *amx, cell *params);
cell Call_Void_Entvar_Int(AMX *amx, cell *params);
cell Call_Void_Entvar_Entvar_Int(AMX *amx, cell *params);
cell Call_Void_Entvar_Entvar_Int(AMX *amx, cell *params);
cell Call_Int_Cbase(AMX *amx, cell *params);
cell Call_Void_Int_Int(AMX *amx, cell *params);
@ -49,8 +49,8 @@ cell Call_Int_Entvar_Entvar_Float_Float_Int(AMX *amx, cell *params);
cell Call_Void_Int(AMX *amx, cell *params);
cell Call_Vector_Float_Cbase_Int(AMX *amx, cell *params);
cell Call_Vector_Float_Cbase_Int(AMX *amx, cell *params);
cell Call_Void_Cbase_Cbase_Int_Float(AMX *amx, cell *params);
cell Call_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, cell *params);
@ -81,111 +81,111 @@ cell Call_Float_Void(AMX *amx, cell *params);
cell Call_Void_Float_Int(AMX* amx, cell* params);
cell Call_Float_Float_Cbase(AMX* amx, cell* params);
cell Call_Void_Float(AMX* amx, cell* params);
cell Call_Void_Float_Float_Float_Int(AMX* amx, cell* params);
cell Call_Float_Int(AMX* amx, cell* params);
cell Call_Vector_Float(AMX* amx, cell* params);
cell Call_Void_Float_Cbase(AMX *amx, cell *params);
cell Call_Int_Float_Float(AMX *amx, cell *params);
cell Call_Int_Float(AMX *amx, cell *params);
cell Call_Int_Int_Int(AMX *amx, cell *params);
cell Call_Void_Str_Float_Float_Float(AMX *amx, cell *params);
cell Call_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, cell *params);
cell Call_Int_Vector_Vector_Float_Float(AMX *amx, cell *params);
cell Call_Int_Short(AMX *amx, cell *params);
cell Call_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, cell *params);
cell Call_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, cell *params);
cell Call_Float_Int_Float(AMX* amx, cell* params);
cell Call_Int_Str(AMX* amx, cell* params);
cell Call_Void_Edict(AMX* amx, cell* params);
cell Call_Void_Int_Str_Bool(AMX* amx, cell* params);
cell Call_Void_Vector_Vector(AMX* amx, cell* params);
cell Call_Void_Str_Bool(AMX* amx, cell* params);
cell Call_Int_Str_Str_Int_Str_Int_Int(AMX* amx, cell* params);
cell Call_Int_Int_Int_Float_Int(AMX* amx, cell* params);
cell Call_Void_Str_Int(AMX* amx, cell* params);
cell Call_Void_Cbase_Int(AMX* amx, cell* params);
cell Call_Void_Str(AMX* amx, cell* params);
cell Call_Void_Vector(AMX* amx, cell* params);
cell Call_Int_Str_Vector_Str(AMX* amx, cell* params);
cell Call_Int_Str_Str(AMX* amx, cell* params);
cell Call_Void_Float_Float(AMX* amx, cell* params);
cell Call_Void_Str_Str_Int(AMX* amx, cell* params);
cell Call_Int_pVector_pVector_Cbase_pFloat(AMX* amx, cell* params);
cell Call_Void_Cbase_pVector_Float(AMX* amx, cell* params);
cell Call_Int_pVector_pVector_Float_Cbase_pVector(AMX* amx, cell* params);
cell Call_Int_Cbase_Bool(AMX* amx, cell* params);
cell Call_Int_Vector_Vector(AMX *amx, cell *params);
cell Call_Int_Entvar_Float(AMX *amx, cell *params);
cell Call_Float_Float(AMX* amx, cell* params);
cell Call_Void_Entvar_Entvar_Float(AMX *amx, cell *params);
cell Call_Bool_Void(AMX *amx, cell *params);
cell Call_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX* amx, cell* params);
cell Call_Int_Vector_Cbase(AMX *amx, cell *params);
cell Call_Int_Vector(AMX *amx, cell *params);
cell Call_Int_Cbase_pVector(AMX *amx, cell *params);
cell Call_Void_Bool(AMX *amx, cell *params);
cell Call_Bool_Cbase(AMX *amx, cell *params);
cell Call_Bool_Int(AMX *amx, cell *params);
cell Call_Void_Cbase_Float(AMX* amx, cell* params);
cell Call_Void_Cbase_Bool(AMX* amx, cell* params);
cell Call_Vector_Vector_Vector_Vector(AMX *amx, cell *params);
cell Call_Str_Str(AMX *amx, cell *params);
cell Call_Void_Short(AMX *amx, cell *params);
cell Call_Float_Float_Cbase(AMX* amx, cell* params);
cell Call_Void_Float(AMX* amx, cell* params);
cell Call_Void_Float_Float_Float_Int(AMX* amx, cell* params);
cell Call_Float_Int(AMX* amx, cell* params);
cell Call_Vector_Float(AMX* amx, cell* params);
cell Call_Void_Float_Cbase(AMX *amx, cell *params);
cell Call_Int_Float_Float(AMX *amx, cell *params);
cell Call_Int_Float(AMX *amx, cell *params);
cell Call_Int_Int_Int(AMX *amx, cell *params);
cell Call_Void_Str_Float_Float_Float(AMX *amx, cell *params);
cell Call_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, cell *params);
cell Call_Int_Vector_Vector_Float_Float(AMX *amx, cell *params);
cell Call_Int_Short(AMX *amx, cell *params);
cell Call_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, cell *params);
cell Call_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, cell *params);
cell Call_Float_Int_Float(AMX* amx, cell* params);
cell Call_Int_Str(AMX* amx, cell* params);
cell Call_Void_Edict(AMX* amx, cell* params);
cell Call_Void_Int_Str_Bool(AMX* amx, cell* params);
cell Call_Void_Vector_Vector(AMX* amx, cell* params);
cell Call_Void_Str_Bool(AMX* amx, cell* params);
cell Call_Int_Str_Str_Int_Str_Int_Int(AMX* amx, cell* params);
cell Call_Int_Int_Int_Float_Int(AMX* amx, cell* params);
cell Call_Void_Str_Int(AMX* amx, cell* params);
cell Call_Void_Cbase_Int(AMX* amx, cell* params);
cell Call_Void_Str(AMX* amx, cell* params);
cell Call_Void_Vector(AMX* amx, cell* params);
cell Call_Int_Str_Vector_Str(AMX* amx, cell* params);
cell Call_Int_Str_Str(AMX* amx, cell* params);
cell Call_Void_Float_Float(AMX* amx, cell* params);
cell Call_Void_Str_Str_Int(AMX* amx, cell* params);
cell Call_Int_pVector_pVector_Cbase_pFloat(AMX* amx, cell* params);
cell Call_Void_Cbase_pVector_Float(AMX* amx, cell* params);
cell Call_Int_pVector_pVector_Float_Cbase_pVector(AMX* amx, cell* params);
cell Call_Int_Cbase_Bool(AMX* amx, cell* params);
cell Call_Int_Vector_Vector(AMX *amx, cell *params);
cell Call_Int_Entvar_Float(AMX *amx, cell *params);
cell Call_Float_Float(AMX* amx, cell* params);
cell Call_Void_Entvar_Entvar_Float(AMX *amx, cell *params);
cell Call_Bool_Void(AMX *amx, cell *params);
cell Call_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX* amx, cell* params);
cell Call_Int_Vector_Cbase(AMX *amx, cell *params);
cell Call_Int_Vector(AMX *amx, cell *params);
cell Call_Int_Cbase_pVector(AMX *amx, cell *params);
cell Call_Void_Bool(AMX *amx, cell *params);
cell Call_Bool_Cbase(AMX *amx, cell *params);
cell Call_Bool_Int(AMX *amx, cell *params);
cell Call_Void_Cbase_Float(AMX* amx, cell* params);
cell Call_Void_Cbase_Bool(AMX* amx, cell* params);
cell Call_Vector_Vector_Vector_Vector(AMX *amx, cell *params);
cell Call_Str_Str(AMX *amx, cell *params);
cell Call_Void_Short(AMX *amx, cell *params);
cell Call_Deprecated(AMX* amx, cell* params);
#endif

View File

@ -11,57 +11,57 @@
// Ham Sandwich Module
//
#ifndef CELLTOTYPE_H
#define CELLTOTYPE_H
#include <extdll.h>
#include "sdk/amxxmodule.h"
#include "CVector.h"
#include "hook.h"
#include "forward.h"
#include "ham_const.h"
#include "ham_utils.h"
inline void CellToType(const AMX*& amx, const cell& in, int& out)
{
out=static_cast<int>(in);
}
inline void CellToType(const AMX*& amx, const cell& in, float& out)
{
out=amx_ctof2(in);
}
inline void CellToType(const AMX*& amx, const cell& in, edict_t*& out)
{
out=INDEXENT_NEW(in);
}
inline void CellToType(const AMX*& amx, const cell& in, entvars_t*& out)
{
out=&(INDEXENT_NEW(in)->v);
}
inline void CellToType(const AMX*& amx, const cell& in, HLBaseEntity*& out)
{
out=(HLBaseEntity *)(INDEXENT_NEW(in)->pvPrivateData);
}
inline void CellToType(const AMX*& amx, const cell& in, Vector& out)
{
float *v=(float *)MF_GetAmxAddr(amx, in);
out.x=v[0];
out.y=v[1];
out.z=v[2];
}
inline void CellToType(const AMX*& amx, const cell& in, TraceResult*& out)
{
out=reinterpret_cast<TraceResult*>(in);
}
#endif
#ifndef CELLTOTYPE_H
#define CELLTOTYPE_H
#include <extdll.h>
#include "sdk/amxxmodule.h"
#include "CVector.h"
#include "hook.h"
#include "forward.h"
#include "ham_const.h"
#include "ham_utils.h"
inline void CellToType(const AMX*& amx, const cell& in, int& out)
{
out=static_cast<int>(in);
}
inline void CellToType(const AMX*& amx, const cell& in, float& out)
{
out=amx_ctof2(in);
}
inline void CellToType(const AMX*& amx, const cell& in, edict_t*& out)
{
out=INDEXENT_NEW(in);
}
inline void CellToType(const AMX*& amx, const cell& in, entvars_t*& out)
{
out=&(INDEXENT_NEW(in)->v);
}
inline void CellToType(const AMX*& amx, const cell& in, HLBaseEntity*& out)
{
out=(HLBaseEntity *)(INDEXENT_NEW(in)->pvPrivateData);
}
inline void CellToType(const AMX*& amx, const cell& in, Vector& out)
{
float *v=(float *)MF_GetAmxAddr(amx, in);
out.x=v[0];
out.y=v[1];
out.z=v[2];
}
inline void CellToType(const AMX*& amx, const cell& in, TraceResult*& out)
{
out=reinterpret_cast<TraceResult*>(in);
}
#endif

View File

@ -90,7 +90,7 @@ enum
Ham_Player_ShouldFadeOnDeath,
Ham_Player_ImpulseCommands,
Ham_Player_UpdateClientData,
Ham_Item_AddToPlayer,
Ham_Item_AddDuplicate,
Ham_Item_CanDeploy,
@ -167,323 +167,323 @@ enum
Ham_TS_OnFreeEntPrivateData,
Ham_TS_ShouldCollide,
//
// New addition - 2011
//
Ham_ChangeYaw,
Ham_HasHumanGibs,
Ham_HasAlienGibs,
Ham_FadeMonster,
Ham_GibMonster,
Ham_BecomeDead,
Ham_IRelationship,
Ham_PainSound,
Ham_ReportAIState,
Ham_MonsterInitDead,
Ham_Look,
Ham_BestVisibleEnemy,
Ham_FInViewCone,
Ham_FVecInViewCone,
Ham_GetDeathActivity,
// Not valid in CS, NS and TS.
Ham_RunAI,
Ham_MonsterThink,
Ham_MonsterInit,
Ham_CheckLocalMove,
Ham_Move,
Ham_MoveExecute,
Ham_ShouldAdvanceRoute,
Ham_GetStoppedActivity,
Ham_Stop,
Ham_CheckRangeAttack1,
Ham_CheckRangeAttack2,
Ham_CheckMeleeAttack1,
Ham_CheckMeleeAttack2,
Ham_ScheduleChange,
Ham_CanPlaySequence,
Ham_CanPlaySentence,
Ham_PlaySentence,
Ham_PlayScriptedSentence,
Ham_SentenceStop,
Ham_GetIdealState,
Ham_SetActivity,
Ham_CheckEnemy,
Ham_FTriangulate,
Ham_SetYawSpeed,
Ham_BuildNearestRoute,
Ham_FindCover,
Ham_CoverRadius,
Ham_FCanCheckAttacks,
Ham_CheckAmmo,
Ham_IgnoreConditions,
Ham_FValidateHintType,
Ham_FCanActiveIdle,
Ham_ISoundMask,
Ham_HearingSensitivity,
Ham_BarnacleVictimBitten,
Ham_BarnacleVictimReleased,
Ham_PrescheduleThink,
Ham_DeathSound,
Ham_AlertSound,
Ham_IdleSound,
Ham_StopFollowing,
Ham_CS_Weapon_SendWeaponAnim,
Ham_CS_Player_ResetMaxSpeed,
Ham_CS_Player_IsBot,
Ham_CS_Player_GetAutoaimVector,
Ham_CS_Player_Blind,
Ham_CS_Player_OnTouchingWeapon,
Ham_DOD_SetScriptReset,
Ham_DOD_Item_SpawnDeploy,
Ham_DOD_Item_SetDmgTime,
Ham_DOD_Item_DropGren,
Ham_DOD_Weapon_IsUseable,
Ham_DOD_Weapon_Aim,
Ham_DOD_Weapon_flAim,
Ham_DOD_Weapon_RemoveStamina,
Ham_DOD_Weapon_ChangeFOV,
Ham_DOD_Weapon_ZoomOut,
Ham_DOD_Weapon_ZoomIn,
Ham_DOD_Weapon_GetFOV,
Ham_DOD_Weapon_IsWaterSniping,
Ham_DOD_Weapon_UpdateZoomSpeed,
Ham_DOD_Weapon_Special,
Ham_TFC_DB_GetItemName,
Ham_TFC_RadiusDamage,
Ham_TFC_RadiusDamage2,
Ham_ESF_IsFighter,
Ham_ESF_IsBuddy,
Ham_ESF_EmitSound,
Ham_ESF_EmitNullSound,
Ham_ESF_IncreaseStrength,
Ham_ESF_IncreasePL,
Ham_ESF_SetPowerLevel,
Ham_ESF_SetMaxPowerLevel,
Ham_ESF_StopAniTrigger,
Ham_ESF_StopFly,
Ham_ESF_HideWeapon,
Ham_ESF_ClientRemoveWeapon,
Ham_ESF_SendClientsCustomModel,
Ham_ESF_CanTurbo,
Ham_ESF_CanPrimaryFire,
Ham_ESF_CanSecondaryFire,
Ham_ESF_CanStopFly,
Ham_ESF_CanBlock,
Ham_ESF_CanRaiseKi,
Ham_ESF_CanRaiseStamina,
Ham_ESF_CanTeleport,
Ham_ESF_CanStartFly,
Ham_ESF_CanStartPowerup,
Ham_ESF_CanJump,
Ham_ESF_CanWallJump,
Ham_ESF_IsSuperJump,
Ham_ESF_IsMoveBack,
Ham_ESF_CheckWallJump,
Ham_ESF_EnableWallJump,
Ham_ESF_DisableWallJump,
Ham_ESF_ResetWallJumpVars,
Ham_ESF_GetWallJumpAnim,
Ham_ESF_GetWallJumpAnim2,
Ham_ESF_SetWallJumpAnimation,
Ham_ESF_SetFlyMoveType,
Ham_ESF_IsFlyMoveType,
Ham_ESF_IsWalkMoveType,
Ham_ESF_SetWalkMoveType,
Ham_ESF_DrawChargeBar,
Ham_ESF_StartBlock,
Ham_ESF_StopBlock,
Ham_ESF_StartFly,
Ham_ESF_GetMaxSpeed,
Ham_ESF_SetAnimation,
Ham_ESF_PlayAnimation,
Ham_ESF_GetMoveForward,
Ham_ESF_GetMoveRight,
Ham_ESF_GetMoveUp,
Ham_ESF_AddBlindFX,
Ham_ESF_RemoveBlindFX,
Ham_ESF_DisablePSBar,
Ham_ESF_AddBeamBoxCrosshair,
Ham_ESF_RemoveBeamBoxCrosshair,
Ham_ESF_DrawPSWinBonus,
Ham_ESF_DrawPSBar,
Ham_ESF_LockCrosshair,
Ham_ESF_UnLockCrosshair,
Ham_ESF_RotateCrosshair,
Ham_ESF_UnRotateCrosshair,
Ham_ESF_WaterMove,
Ham_ESF_CheckTimeBasedDamage,
Ham_ESF_DoesSecondaryAttack,
Ham_ESF_DoesPrimaryAttack,
Ham_ESF_RemoveSpecialModes,
Ham_ESF_StopTurbo,
Ham_ESF_TakeBean,
Ham_ESF_GetPowerLevel,
Ham_ESF_RemoveAllOtherWeapons,
Ham_ESF_StopSwoop,
Ham_ESF_SetDeathAnimation,
Ham_ESF_SetModel,
Ham_ESF_AddAttacks,
Ham_ESF_EmitClassSound,
Ham_ESF_CheckLightning,
Ham_ESF_FreezeControls,
Ham_ESF_UnFreezeControls,
Ham_ESF_UpdateKi,
Ham_ESF_UpdateHealth,
Ham_ESF_GetTeleportDir,
Ham_ESF_Weapon_HolsterWhenMeleed,
Ham_NS_SetBoneController,
Ham_NS_SaveDataForReset,
Ham_NS_GetHull,
Ham_NS_GetMaxWalkSpeed,
Ham_NS_SetTeamID,
Ham_NS_GetEffectivePlayerClass,
Ham_NS_GetAuthenticationMask,
Ham_NS_EffectivePlayerClassChanged,
Ham_NS_NeedsTeamUpdate,
Ham_NS_SendTeamUpdate,
Ham_NS_SendWeaponUpdate,
Ham_NS_InitPlayerFromSpawn,
Ham_NS_PackDeadPlayerItems,
Ham_NS_GetAnimationForActivity,
Ham_NS_StartObserver,
Ham_NS_StopObserver,
Ham_NS_GetAdrenalineFactor,
Ham_NS_GetNamedItem,
Ham_NS_Suicide,
Ham_NS_GetCanUseWeapon,
Ham_NS_Weapon_GetWeapPrimeTime,
Ham_NS_Weapon_PrimeWeapon,
Ham_NS_Weapon_GetIsWeaponPrimed,
Ham_NS_Weapon_GetIsWeaponPriming,
Ham_NS_Weapon_DefaultDeploy,
Ham_NS_Weapon_DefaultReload,
Ham_NS_Weapon_GetDeployTime,
Ham_SC_GetClassification,
Ham_SC_IsMonster,
Ham_SC_IsPhysX,
Ham_SC_IsPointEntity,
Ham_SC_IsMachine,
Ham_SC_CriticalRemove,
Ham_SC_UpdateOnRemove,
Ham_SC_FVisible,
Ham_SC_FVisibleFromPos,
Ham_SC_IsFacings,
Ham_SC_GetPointsForDamage,
Ham_SC_GetDamagePoints,
Ham_SC_OnCreate,
Ham_SC_OnDestroy,
Ham_SC_IsValidEntity,
Ham_SC_ShouldFadeOnDeath,
Ham_SC_SetupFriendly,
Ham_SC_ReviveThink,
Ham_SC_Revive,
Ham_SC_StartMonster,
Ham_SC_CheckRangeAttack1_Move,
Ham_SC_CheckRangeAttack2_Move,
Ham_SC_CheckMeleeAttack1_Move,
Ham_SC_CheckMeleeAttack2_Move,
Ham_SC_CheckTankUsage,
Ham_SC_SetGaitActivity,
Ham_SC_FTriangulate,
Ham_SC_FTriangulateExtension,
Ham_SC_FindCoverGrenade,
Ham_SC_FindCoverDistance,
Ham_SC_FindAttackPoint,
Ham_SC_FValidateCover,
Ham_SC_NoFriendlyFire1,
Ham_SC_NoFriendlyFire2,
Ham_SC_NoFriendlyFire3,
Ham_SC_NoFriendlyFireToPos,
Ham_SC_FVisibleGunPos,
Ham_SC_FInBulletCone,
Ham_SC_CallGibMonster,
Ham_SC_CheckTimeBasedDamage,
Ham_SC_IsMoving,
Ham_SC_IsPlayerFollowing,
Ham_SC_StartPlayerFollowing,
Ham_SC_StopPlayerFollowing,
Ham_SC_UseSound,
Ham_SC_UnUseSound,
Ham_SC_RideMonster,
Ham_SC_CheckApplyGenericAttacks,
Ham_SC_CheckScared,
Ham_SC_CheckCreatureDanger,
Ham_SC_CheckFallDamage,
Ham_SC_CheckRevival,
Ham_SC_MedicCallSound,
Ham_SC_Player_MenuInputPerformed,
Ham_SC_Player_IsMenuInputDone,
Ham_SC_Player_SpecialSpawn,
Ham_SC_Player_IsValidInfoEntity,
Ham_SC_Player_LevelEnd,
Ham_SC_Player_VoteStarted,
Ham_SC_Player_CanStartNextVote,
Ham_SC_Player_Vote,
Ham_SC_Player_HasVoted,
Ham_SC_Player_ResetVote,
Ham_SC_Player_LastVoteInput,
Ham_SC_Player_InitVote,
Ham_SC_Player_TimeToStartNextVote,
Ham_SC_Player_ResetView,
Ham_SC_Player_GetLogFrequency,
Ham_SC_Player_LogPlayerStats,
Ham_SC_Player_DisableCollisionWithPlayer,
Ham_SC_Player_EnableCollisionWithPlayer,
Ham_SC_Player_CanTouchPlayer,
Ham_SC_Item_Materialize,
Ham_SC_Weapon_BulletAccuracy,
Ham_SC_Weapon_TertiaryAttack,
Ham_SC_Weapon_BurstSupplement,
Ham_SC_Weapon_GetP_Model,
Ham_SC_Weapon_GetW_Model,
Ham_SC_Weapon_GetV_Model,
Ham_SC_Weapon_PrecacheCustomModels,
Ham_SC_Weapon_IsMultiplayer,
Ham_SC_Weapon_FRunfuncs,
Ham_SC_Weapon_SetFOV,
Ham_SC_Weapon_FCanRun,
Ham_SC_Weapon_CustomDecrement,
Ham_SC_Weapon_SetV_Model,
Ham_SC_Weapon_SetP_Model,
Ham_SC_Weapon_ChangeWeaponSkin,
//
// New addition - 2013
//
Ham_TFC_Killed,
Ham_TFC_IsTriggered,
Ham_TFC_Weapon_SendWeaponAnim,
Ham_TFC_Weapon_GetNextAttackDelay,
Ham_SC_TakeHealth,
Ham_SC_TakeArmor,
Ham_SC_GiveAmmo,
Ham_SC_CheckAttacker,
Ham_SC_Player_IsConnected,
Ham_DOD_Weapon_SendWeaponAnim,
Ham_CS_Item_IsWeapon,
Ham_OPF_MySquadTalkMonsterPointer,
Ham_OPF_WeaponTimeBase,
Ham_TS_Weapon_AlternateAttack,
Ham_Item_GetItemInfo,
//
// New addition - 2011
//
Ham_ChangeYaw,
Ham_HasHumanGibs,
Ham_HasAlienGibs,
Ham_FadeMonster,
Ham_GibMonster,
Ham_BecomeDead,
Ham_IRelationship,
Ham_PainSound,
Ham_ReportAIState,
Ham_MonsterInitDead,
Ham_Look,
Ham_BestVisibleEnemy,
Ham_FInViewCone,
Ham_FVecInViewCone,
Ham_GetDeathActivity,
// Not valid in CS, NS and TS.
Ham_RunAI,
Ham_MonsterThink,
Ham_MonsterInit,
Ham_CheckLocalMove,
Ham_Move,
Ham_MoveExecute,
Ham_ShouldAdvanceRoute,
Ham_GetStoppedActivity,
Ham_Stop,
Ham_CheckRangeAttack1,
Ham_CheckRangeAttack2,
Ham_CheckMeleeAttack1,
Ham_CheckMeleeAttack2,
Ham_ScheduleChange,
Ham_CanPlaySequence,
Ham_CanPlaySentence,
Ham_PlaySentence,
Ham_PlayScriptedSentence,
Ham_SentenceStop,
Ham_GetIdealState,
Ham_SetActivity,
Ham_CheckEnemy,
Ham_FTriangulate,
Ham_SetYawSpeed,
Ham_BuildNearestRoute,
Ham_FindCover,
Ham_CoverRadius,
Ham_FCanCheckAttacks,
Ham_CheckAmmo,
Ham_IgnoreConditions,
Ham_FValidateHintType,
Ham_FCanActiveIdle,
Ham_ISoundMask,
Ham_HearingSensitivity,
Ham_BarnacleVictimBitten,
Ham_BarnacleVictimReleased,
Ham_PrescheduleThink,
Ham_DeathSound,
Ham_AlertSound,
Ham_IdleSound,
Ham_StopFollowing,
Ham_CS_Weapon_SendWeaponAnim,
Ham_CS_Player_ResetMaxSpeed,
Ham_CS_Player_IsBot,
Ham_CS_Player_GetAutoaimVector,
Ham_CS_Player_Blind,
Ham_CS_Player_OnTouchingWeapon,
Ham_DOD_SetScriptReset,
Ham_DOD_Item_SpawnDeploy,
Ham_DOD_Item_SetDmgTime,
Ham_DOD_Item_DropGren,
Ham_DOD_Weapon_IsUseable,
Ham_DOD_Weapon_Aim,
Ham_DOD_Weapon_flAim,
Ham_DOD_Weapon_RemoveStamina,
Ham_DOD_Weapon_ChangeFOV,
Ham_DOD_Weapon_ZoomOut,
Ham_DOD_Weapon_ZoomIn,
Ham_DOD_Weapon_GetFOV,
Ham_DOD_Weapon_IsWaterSniping,
Ham_DOD_Weapon_UpdateZoomSpeed,
Ham_DOD_Weapon_Special,
Ham_TFC_DB_GetItemName,
Ham_TFC_RadiusDamage,
Ham_TFC_RadiusDamage2,
Ham_ESF_IsFighter,
Ham_ESF_IsBuddy,
Ham_ESF_EmitSound,
Ham_ESF_EmitNullSound,
Ham_ESF_IncreaseStrength,
Ham_ESF_IncreasePL,
Ham_ESF_SetPowerLevel,
Ham_ESF_SetMaxPowerLevel,
Ham_ESF_StopAniTrigger,
Ham_ESF_StopFly,
Ham_ESF_HideWeapon,
Ham_ESF_ClientRemoveWeapon,
Ham_ESF_SendClientsCustomModel,
Ham_ESF_CanTurbo,
Ham_ESF_CanPrimaryFire,
Ham_ESF_CanSecondaryFire,
Ham_ESF_CanStopFly,
Ham_ESF_CanBlock,
Ham_ESF_CanRaiseKi,
Ham_ESF_CanRaiseStamina,
Ham_ESF_CanTeleport,
Ham_ESF_CanStartFly,
Ham_ESF_CanStartPowerup,
Ham_ESF_CanJump,
Ham_ESF_CanWallJump,
Ham_ESF_IsSuperJump,
Ham_ESF_IsMoveBack,
Ham_ESF_CheckWallJump,
Ham_ESF_EnableWallJump,
Ham_ESF_DisableWallJump,
Ham_ESF_ResetWallJumpVars,
Ham_ESF_GetWallJumpAnim,
Ham_ESF_GetWallJumpAnim2,
Ham_ESF_SetWallJumpAnimation,
Ham_ESF_SetFlyMoveType,
Ham_ESF_IsFlyMoveType,
Ham_ESF_IsWalkMoveType,
Ham_ESF_SetWalkMoveType,
Ham_ESF_DrawChargeBar,
Ham_ESF_StartBlock,
Ham_ESF_StopBlock,
Ham_ESF_StartFly,
Ham_ESF_GetMaxSpeed,
Ham_ESF_SetAnimation,
Ham_ESF_PlayAnimation,
Ham_ESF_GetMoveForward,
Ham_ESF_GetMoveRight,
Ham_ESF_GetMoveUp,
Ham_ESF_AddBlindFX,
Ham_ESF_RemoveBlindFX,
Ham_ESF_DisablePSBar,
Ham_ESF_AddBeamBoxCrosshair,
Ham_ESF_RemoveBeamBoxCrosshair,
Ham_ESF_DrawPSWinBonus,
Ham_ESF_DrawPSBar,
Ham_ESF_LockCrosshair,
Ham_ESF_UnLockCrosshair,
Ham_ESF_RotateCrosshair,
Ham_ESF_UnRotateCrosshair,
Ham_ESF_WaterMove,
Ham_ESF_CheckTimeBasedDamage,
Ham_ESF_DoesSecondaryAttack,
Ham_ESF_DoesPrimaryAttack,
Ham_ESF_RemoveSpecialModes,
Ham_ESF_StopTurbo,
Ham_ESF_TakeBean,
Ham_ESF_GetPowerLevel,
Ham_ESF_RemoveAllOtherWeapons,
Ham_ESF_StopSwoop,
Ham_ESF_SetDeathAnimation,
Ham_ESF_SetModel,
Ham_ESF_AddAttacks,
Ham_ESF_EmitClassSound,
Ham_ESF_CheckLightning,
Ham_ESF_FreezeControls,
Ham_ESF_UnFreezeControls,
Ham_ESF_UpdateKi,
Ham_ESF_UpdateHealth,
Ham_ESF_GetTeleportDir,
Ham_ESF_Weapon_HolsterWhenMeleed,
Ham_NS_SetBoneController,
Ham_NS_SaveDataForReset,
Ham_NS_GetHull,
Ham_NS_GetMaxWalkSpeed,
Ham_NS_SetTeamID,
Ham_NS_GetEffectivePlayerClass,
Ham_NS_GetAuthenticationMask,
Ham_NS_EffectivePlayerClassChanged,
Ham_NS_NeedsTeamUpdate,
Ham_NS_SendTeamUpdate,
Ham_NS_SendWeaponUpdate,
Ham_NS_InitPlayerFromSpawn,
Ham_NS_PackDeadPlayerItems,
Ham_NS_GetAnimationForActivity,
Ham_NS_StartObserver,
Ham_NS_StopObserver,
Ham_NS_GetAdrenalineFactor,
Ham_NS_GetNamedItem,
Ham_NS_Suicide,
Ham_NS_GetCanUseWeapon,
Ham_NS_Weapon_GetWeapPrimeTime,
Ham_NS_Weapon_PrimeWeapon,
Ham_NS_Weapon_GetIsWeaponPrimed,
Ham_NS_Weapon_GetIsWeaponPriming,
Ham_NS_Weapon_DefaultDeploy,
Ham_NS_Weapon_DefaultReload,
Ham_NS_Weapon_GetDeployTime,
Ham_SC_GetClassification,
Ham_SC_IsMonster,
Ham_SC_IsPhysX,
Ham_SC_IsPointEntity,
Ham_SC_IsMachine,
Ham_SC_CriticalRemove,
Ham_SC_UpdateOnRemove,
Ham_SC_FVisible,
Ham_SC_FVisibleFromPos,
Ham_SC_IsFacings,
Ham_SC_GetPointsForDamage,
Ham_SC_GetDamagePoints,
Ham_SC_OnCreate,
Ham_SC_OnDestroy,
Ham_SC_IsValidEntity,
Ham_SC_ShouldFadeOnDeath,
Ham_SC_SetupFriendly,
Ham_SC_ReviveThink,
Ham_SC_Revive,
Ham_SC_StartMonster,
Ham_SC_CheckRangeAttack1_Move,
Ham_SC_CheckRangeAttack2_Move,
Ham_SC_CheckMeleeAttack1_Move,
Ham_SC_CheckMeleeAttack2_Move,
Ham_SC_CheckTankUsage,
Ham_SC_SetGaitActivity,
Ham_SC_FTriangulate,
Ham_SC_FTriangulateExtension,
Ham_SC_FindCoverGrenade,
Ham_SC_FindCoverDistance,
Ham_SC_FindAttackPoint,
Ham_SC_FValidateCover,
Ham_SC_NoFriendlyFire1,
Ham_SC_NoFriendlyFire2,
Ham_SC_NoFriendlyFire3,
Ham_SC_NoFriendlyFireToPos,
Ham_SC_FVisibleGunPos,
Ham_SC_FInBulletCone,
Ham_SC_CallGibMonster,
Ham_SC_CheckTimeBasedDamage,
Ham_SC_IsMoving,
Ham_SC_IsPlayerFollowing,
Ham_SC_StartPlayerFollowing,
Ham_SC_StopPlayerFollowing,
Ham_SC_UseSound,
Ham_SC_UnUseSound,
Ham_SC_RideMonster,
Ham_SC_CheckApplyGenericAttacks,
Ham_SC_CheckScared,
Ham_SC_CheckCreatureDanger,
Ham_SC_CheckFallDamage,
Ham_SC_CheckRevival,
Ham_SC_MedicCallSound,
Ham_SC_Player_MenuInputPerformed,
Ham_SC_Player_IsMenuInputDone,
Ham_SC_Player_SpecialSpawn,
Ham_SC_Player_IsValidInfoEntity,
Ham_SC_Player_LevelEnd,
Ham_SC_Player_VoteStarted,
Ham_SC_Player_CanStartNextVote,
Ham_SC_Player_Vote,
Ham_SC_Player_HasVoted,
Ham_SC_Player_ResetVote,
Ham_SC_Player_LastVoteInput,
Ham_SC_Player_InitVote,
Ham_SC_Player_TimeToStartNextVote,
Ham_SC_Player_ResetView,
Ham_SC_Player_GetLogFrequency,
Ham_SC_Player_LogPlayerStats,
Ham_SC_Player_DisableCollisionWithPlayer,
Ham_SC_Player_EnableCollisionWithPlayer,
Ham_SC_Player_CanTouchPlayer,
Ham_SC_Item_Materialize,
Ham_SC_Weapon_BulletAccuracy,
Ham_SC_Weapon_TertiaryAttack,
Ham_SC_Weapon_BurstSupplement,
Ham_SC_Weapon_GetP_Model,
Ham_SC_Weapon_GetW_Model,
Ham_SC_Weapon_GetV_Model,
Ham_SC_Weapon_PrecacheCustomModels,
Ham_SC_Weapon_IsMultiplayer,
Ham_SC_Weapon_FRunfuncs,
Ham_SC_Weapon_SetFOV,
Ham_SC_Weapon_FCanRun,
Ham_SC_Weapon_CustomDecrement,
Ham_SC_Weapon_SetV_Model,
Ham_SC_Weapon_SetP_Model,
Ham_SC_Weapon_ChangeWeaponSkin,
//
// New addition - 2013
//
Ham_TFC_Killed,
Ham_TFC_IsTriggered,
Ham_TFC_Weapon_SendWeaponAnim,
Ham_TFC_Weapon_GetNextAttackDelay,
Ham_SC_TakeHealth,
Ham_SC_TakeArmor,
Ham_SC_GiveAmmo,
Ham_SC_CheckAttacker,
Ham_SC_Player_IsConnected,
Ham_DOD_Weapon_SendWeaponAnim,
Ham_CS_Item_IsWeapon,
Ham_OPF_MySquadTalkMonsterPointer,
Ham_OPF_WeaponTimeBase,
Ham_TS_Weapon_AlternateAttack,
Ham_Item_GetItemInfo,
HAM_LAST_ENTRY_DONT_USE_ME_LOL
};

View File

@ -114,21 +114,21 @@ inline int EntvarToIndex(entvars_t *pev)
return ENTINDEX_NEW(pev->pContainingEntity);
};
inline int EdictToIndex(edict_t *v)
{
if (v==NULL)
{
return -1;
}
return ENTINDEX_NEW(v);
}
inline int EdictToIndex(edict_t *v)
{
if (v==NULL)
{
return -1;
}
return ENTINDEX_NEW(v);
}
inline edict_t *IndexToEdict(int index)
{
return INDEXENT_NEW(index);
};
};
inline edict_t *EntvarToEdict(entvars_t *pev)
{
if (pev==NULL)

View File

@ -18,8 +18,8 @@
#include "Trampolines.h"
#include <am-vector.h>
#define ALIGN(ar) ((intptr_t)ar & ~(sysconf(_SC_PAGESIZE)-1))
#define ALIGN(ar) ((intptr_t)ar & ~(sysconf(_SC_PAGESIZE)-1))
// This is just a simple container for data so I only have to add 1 extra
// parameter to calls that get trampolined
@ -73,7 +73,7 @@ public:
#if defined(_WIN32)
DWORD OldFlags;
VirtualProtect(&ivtable[entry],sizeof(int*),PAGE_READWRITE,&OldFlags);
#elif defined(__linux__) || defined(__APPLE__)
#elif defined(__linux__) || defined(__APPLE__)
void *addr = (void *)ALIGN(&ivtable[entry]);
mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -45,21 +45,21 @@ const bool RB_Int_Float_Int = false;
const int PC_Int_Float_Int = 2;
int Hook_Int_Float_Int(Hook *hook, void *pthis, float f1, int i1);
const bool RT_Int_Float_Int_Int = false;
const bool RB_Int_Float_Int_Int = false;
const int PC_Int_Float_Int_Int = 3;
int Hook_Int_Float_Int_Int(Hook *hook, void *pthis, float f1, int i1, int i2);
const bool RT_Int_Float_Int_Int = false;
const bool RB_Int_Float_Int_Int = false;
const int PC_Int_Float_Int_Int = 3;
int Hook_Int_Float_Int_Int(Hook *hook, void *pthis, float f1, int i1, int i2);
const bool RT_Void_Entvar_Int = true;
const bool RB_Void_Entvar_Int = false;
const int PC_Void_Entvar_Int = 2;
void Hook_Void_Entvar_Int(Hook *hook, void *ptis, entvars_t *ev1, int i1);
const bool RT_Void_Entvar_Entvar_Int = true;
const bool RB_Void_Entvar_Entvar_Int = false;
const int PC_Void_Entvar_Entvar_Int = 3;
void Hook_Void_Entvar_Entvar_Int(Hook *hook, void *ptis, entvars_t *ev1, entvars_t *ev2, int i1);
const bool RT_Void_Entvar_Entvar_Int = true;
const bool RB_Void_Entvar_Entvar_Int = false;
const int PC_Void_Entvar_Entvar_Int = 3;
void Hook_Void_Entvar_Entvar_Int(Hook *hook, void *ptis, entvars_t *ev1, entvars_t *ev2, int i1);
const bool RT_Int_Cbase = false;
const bool RB_Int_Cbase = false;
const int PC_Int_Cbase = 1;
@ -76,9 +76,9 @@ const int PC_Int_Int_Str_Int = 3;
int Hook_Int_Int_Str_Int(Hook *hook, void *pthis, int i1, const char *sz1,
int i2);
const bool RT_Int_Int_Str_Int_Int = false;
const bool RB_Int_Int_Str_Int_Int = false;
const int PC_Int_Int_Str_Int_Int = 4;
const bool RT_Int_Int_Str_Int_Int = false;
const bool RB_Int_Int_Str_Int_Int = false;
const int PC_Int_Int_Str_Int_Int = 4;
int Hook_Int_Int_Str_Int_Int(Hook *hook, void *pthis, int i1, const char *sz1, int i2, int i3);
const bool RT_Int_Int = false;
@ -118,15 +118,15 @@ const int PC_Void_Cbase_Cbase_Int_Float = 4;
void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1,
void *cb2, int i1, float f1);
const bool RT_Vector_Float_Cbase_Int = true;
const bool RB_Vector_Float_Cbase_Int = true;
const int PC_Vector_Float_Cbase_Int = 4;
#if defined(_WIN32)
const bool RT_Vector_Float_Cbase_Int = true;
const bool RB_Vector_Float_Cbase_Int = true;
const int PC_Vector_Float_Cbase_Int = 4;
#if defined(_WIN32)
void Hook_Vector_Float_Cbase_Int(Hook *hook, void *pthis, Vector *out, float f1, void *cb, int i1);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Float_Cbase_Int(Hook *hook, Vector *out, void *pthis, float f1, void *cb, int i1);
#endif
#endif
const bool RT_Void_Entvar_Float_Vector_Trace_Int = true;
const bool RB_Void_Entvar_Float_Vector_Trace_Int = false;
const int PC_Void_Entvar_Float_Vector_Trace_Int = 7;
@ -157,7 +157,7 @@ void *Hook_Cbase_Void(Hook *hook, void *pthis);
const bool RT_Vector_Void = true;
const bool RB_Vector_Void = true;
const int PC_Vector_Void = 1;
#if defined(_WIN32)
#if defined(_WIN32)
void Hook_Vector_Void(Hook *hook, void *pthis, Vector *out);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis);
@ -166,7 +166,7 @@ void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis);
const bool RT_Vector_pVector = true;
const bool RB_Vector_pVector = true;
const int PC_Vector_pVector = 2;
#if defined(_WIN32)
#if defined(_WIN32)
void Hook_Vector_pVector(Hook *hook, void *pthis, Vector *out, Vector *v1);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1);
@ -209,290 +209,290 @@ const bool RB_Float_Void = false;
const int PC_Float_Void = 0;
float Hook_Float_Void(Hook *hook, void *pthis);
const bool RT_Float_Int = false;
const bool RB_Float_Int = false;
const int PC_Float_Int = 1;
float Hook_Float_Int(Hook *hook, void *pthis, int i1);
const bool RT_Float_Int = false;
const bool RB_Float_Int = false;
const int PC_Float_Int = 1;
float Hook_Float_Int(Hook *hook, void *pthis, int i1);
const bool RT_Void_Float_Int = true;
const bool RB_Void_Float_Int = false;
const int PC_Void_Float_Int = 2;
void Hook_Void_Float_Int(Hook *hook, void *pthis, float f1, int i1);
const bool RT_Float_Float_Cbase = true;
const bool RB_Float_Float_Cbase = false;
const int PC_Float_Float_Cbase = 2;
float Hook_Float_Float_Cbase(Hook *hook, void *pthis, float f1, void *cb1);
const bool RT_Void_Float = true;
const bool RB_Void_Float = false;
const int PC_Void_Float = 1;
void Hook_Void_Float(Hook *hook, void *pthis, float f1);
const bool RT_Void_Float_Float_Float_Int = true;
const bool RB_Void_Float_Float_Float_Int = false;
const int PC_Void_Float_Float_Float_Int = 4;
void Hook_Void_Float_Float_Float_Int(Hook *hook, void *pthis, float f1, float f2, float f3, int i1);
const bool RT_Vector_Float = true;
const bool RB_Vector_Float = true;
const int PC_Vector_Float = 2;
#if defined(_WIN32)
void Hook_Vector_Float(Hook *hook, void *pthis, Vector *out, float f1);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Float(Hook *hook, Vector *out, void *pthis, float f1);
#endif
const bool RT_Void_Float_Cbase = true;
const bool RB_Void_Float_Cbase = false;
const int PC_Void_Float_Cbase = 2;
void Hook_Void_Float_Cbase(Hook *hook, void *pthis, float f1, void *cb);
const bool RT_Int_Float_Float = false;
const bool RB_Int_Float_Float = false;
const int PC_Int_Float_Float = 2;
int Hook_Int_Float_Float(Hook *hook, void *pthis, float f1, float f2);
const bool RT_Int_Float = false;
const bool RB_Int_Float = false;
const int PC_Int_Float = 1;
int Hook_Int_Float(Hook *hook, void *pthis, float f1);
const bool RT_Int_Int_Int = false;
const bool RB_Int_Int_Int = false;
const int PC_Int_Int_Int = 2;
int Hook_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2);
const bool RT_Void_Str_Float_Float_Float = true;
const bool RB_Void_Str_Float_Float_Float = false;
const int PC_Void_Str_Float_Float_Float = 4;
void Hook_Void_Str_Float_Float_Float(Hook *hook, void *pthis, const char *sz1, float f1, float f2, float f3);
const bool RT_Void_Str_Float_Float_Float_Int_Cbase = true;
const bool RB_Void_Str_Float_Float_Float_Int_Cbase = false;
const int PC_Void_Str_Float_Float_Float_Int_Cbase = 6;
void Hook_Void_Str_Float_Float_Float_Int_Cbase(Hook *hook, void *pthis, const char *sz1, float f1, float f2, float f3, int i1, void *cb);
const bool RT_Int_Vector_Vector_Float_Float= false;
const bool RB_Int_Vector_Vector_Float_Float = false;
const int PC_Int_Vector_Vector_Float_Float = 8;
int Hook_Int_Vector_Vector_Float_Float(Hook *hook, void *pthis, Vector v1, Vector v2, float f1, float f2);
const bool RT_Int_Short = false;
const bool RB_Int_Short = false;
const int PC_Int_Short = 1;
int Hook_Int_Short(Hook *hook, void *pthis, short s1);
const bool RT_Void_Entvar_Entvar_Float_Int_Int = true;
const bool RB_Void_Entvar_Entvar_Float_Int_Int = false;
const int PC_Void_Entvar_Entvar_Float_Int_Int = 5;
void Hook_Void_Entvar_Entvar_Float_Int_Int(Hook *hook, void *pthis,
entvars_t *inflictor,
entvars_t *attacker, float damage,
int classignore, int damagebits);
const bool RT_Void_Vector_Entvar_Entvar_Float_Int_Int = true;
const bool RB_Void_Vector_Entvar_Entvar_Float_Int_Int = false;
const int PC_Void_Vector_Entvar_Entvar_Float_Int_Int = 8;
void Hook_Void_Vector_Entvar_Entvar_Float_Int_Int(Hook *hook, void *pthis,
Vector source,
entvars_t *inflictor,
entvars_t *attacker, float damage,
int classignore, int damagebits);
const bool RT_Float_Int_Float = false;
const bool RB_Float_Int_Float = false;
const int PC_Float_Int_Float = 2;
float Hook_Float_Int_Float(Hook *hook, void *pthis, int i1, float f2);
const bool RT_Int_Str = false;
const bool RB_Int_Str = false;
const int PC_Int_Str = 1;
int Hook_Int_Str(Hook *hook, void *pthis, const char *sz1);
const bool RT_Void_Edict = true;
const bool RB_Void_Edict = false;
const int PC_Void_Edict = 1;
void Hook_Void_Edict(Hook *hook, void *pthis, edict_t *ed1 );
const bool RT_Float_Float_Cbase = true;
const bool RB_Float_Float_Cbase = false;
const int PC_Float_Float_Cbase = 2;
float Hook_Float_Float_Cbase(Hook *hook, void *pthis, float f1, void *cb1);
const bool RT_Void_Int_Str_Bool = true;
const bool RB_Void_Int_Str_Bool = false;
const int PC_Void_Int_Str_Bool = 3;
void Hook_Void_Int_Str_Bool(Hook *hook, void *pthis, int i1, const char *sz2, bool b3);
const bool RT_Void_Float = true;
const bool RB_Void_Float = false;
const int PC_Void_Float = 1;
void Hook_Void_Float(Hook *hook, void *pthis, float f1);
const bool RT_Void_Vector_Vector= true;
const bool RB_Void_Vector_Vector = false;
const int PC_Void_Vector_Vector = 6;
void Hook_Void_Vector_Vector(Hook *hook, void *pthis, Vector v1, Vector v2);
const bool RT_Void_Float_Float_Float_Int = true;
const bool RB_Void_Float_Float_Float_Int = false;
const int PC_Void_Float_Float_Float_Int = 4;
void Hook_Void_Float_Float_Float_Int(Hook *hook, void *pthis, float f1, float f2, float f3, int i1);
const bool RT_Void_Str_Bool = true;
const bool RB_Void_Str_Bool = false;
const int PC_Void_Str_Bool = 2;
void Hook_Void_Str_Bool(Hook *hook, void *pthis, const char *sz1, bool b2);
const bool RT_Int_Str_Str_Int_Str_Int_Int = false;
const bool RB_Int_Str_Str_Int_Str_Int_Int = false;
const int PC_Int_Str_Str_Int_Str_Int_Int = 6;
int Hook_Int_Str_Str_Int_Str_Int_Int(Hook *hook, void *pthis, const char *sz1, const char *sz2, int i1, const char *sz3, int i2, int i3);
const bool RT_Int_Int_Int_Float_Int = false;
const bool RB_Int_Int_Int_Float_Int = false;
const int PC_Int_Int_Int_Float_Int = 4;
int Hook_Int_Int_Int_Float_Int(Hook *hook, void *pthis, int i1, int i2, float f1, int i3);
const bool RT_Void_Str_Int = true;
const bool RB_Void_Str_Int = false;
const int PC_Void_Str_Int = 2;
void Hook_Void_Str_Int(Hook *hook, void *pthis, const char *sz1, int i2);
const bool RT_Void_Cbase_Int = true;
const bool RB_Void_Cbase_Int = false;
const int PC_Void_Cbase_Int = 2;
void Hook_Void_Cbase_Int(Hook *hook, void *pthis, void *p1, int i1);
const bool RT_Void_Str = true;
const bool RB_Void_Str = false;
const int PC_Void_Str = 1;
void Hook_Void_Str(Hook *hook, void *pthis, const char *sz1);
const bool RT_Void_Vector = true;
const bool RB_Void_Vector = false;
const int PC_Void_Vector = 3;
void Hook_Void_Vector(Hook *hook, void *pthis, Vector v1);
const bool RT_Int_Str_Vector_Str = false;
const bool RB_Int_Str_Vector_Str = false;
const int PC_Int_Str_Vector_Str = 5;
int Hook_Int_Str_Vector_Str(Hook *hook, void *pthis, const char *sz1, Vector v2, const char *sz2);
const bool RT_Int_Str_Str = false;
const bool RB_Int_Str_Str = false;
const int PC_Int_Str_Str = 2;
int Hook_Int_Str_Str(Hook *hook, void *pthis, const char *sz1, const char *sz2);
const bool RT_Void_Float_Float = true;
const bool RB_Void_Float_Float = false;
const int PC_Void_Float_Float = 2;
void Hook_Void_Float_Float(Hook *hook, void *pthis, float f1, float f2);
const bool RT_Void_Str_Str_Int = true;
const bool RB_Void_Str_Str_Int = false;
const int PC_Void_Str_Str_Int = 3;
void Hook_Void_Str_Str_Int(Hook *hook, void *pthis, const char *sz1, const char *sz2, int i3);
const bool RT_Int_pVector_pVector_Cbase_pFloat = false;
const bool RB_Int_pVector_pVector_Cbase_pFloat = false;
const int PC_Int_pVector_pVector_Cbase_pFloat = 4;
int Hook_Int_pVector_pVector_Cbase_pFloat(Hook *hook, void *pthis, Vector *v1, Vector *v2, void* cb, float* fl);
const bool RT_Void_Cbase_pVector_Float = true;
const bool RB_Void_Cbase_pVector_Float = false;
const int PC_Void_Cbase_pVector_Float = 3;
void Hook_Void_Cbase_pVector_Float(Hook *hook, void *pthis, void *p1, Vector *v1, float fl);
const bool RT_Int_pVector_pVector_Float_Cbase_pVector = false;
const bool RB_Int_pVector_pVector_Float_Cbase_pVector = false;
const int PC_Int_pVector_pVector_Float_Cbase_pVector = 5;
int Hook_Int_pVector_pVector_Float_Cbase_pVector(Hook *hook, void *pthis, Vector *v1, Vector *v2, float fl, void* cb, Vector *v3);
const bool RT_Int_Cbase_Bool = false;
const bool RB_Int_Cbase_Bool = false;
const int PC_Int_Cbase_Bool = 2;
int Hook_Int_Cbase_Bool(Hook *hook, void *pthis, void *cb1, bool b1);
const bool RT_Int_Vector_Vector = false;
const bool RB_Int_Vector_Vector = false;
const int PC_Int_Vector_Vector = 6;
int Hook_Int_Vector_Vector(Hook *hook, void *pthis, Vector v1, Vector v2);
const bool RT_Int_Entvar_Float = false;
const bool RB_Int_Entvar_Float = false;
const int PC_Int_Entvar_Float = 2;
int Hook_Int_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1);
const bool RT_Float_Float = false;
const bool RB_Float_Float = false;
const int PC_Float_Float = 1;
float Hook_Float_Float(Hook *hook, void *pthis, float f1);
const bool RT_Void_Entvar_Entvar_Float = true;
const bool RB_Void_Entvar_Entvar_Float = false;
const int PC_Void_Entvar_Entvar_Float = 3;
void Hook_Void_Entvar_Entvar_Float(Hook *hook, void *pthis, entvars_t *attacker, entvars_t *inflictor, float damage);
const bool RT_Bool_Void = false;
const bool RB_Bool_Void = false;
const int PC_Bool_Void = 0;
bool Hook_Bool_Void(Hook *hook, void *pthis);
const bool RT_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool = false;
const bool RB_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool = false;
const int PC_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool = 7;
int Hook_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(Hook *hook, void *pthis, Vector *v1, Vector *v2, float fl, void* cb, Vector *v3, Vector *v4, bool b1);
const bool RT_Int_Vector_Cbase = false;
const bool RB_Int_Vector_Cbase = false;
const int PC_Int_Vector_Cbase = 4;
int Hook_Int_Vector_Cbase(Hook *hook, void *pthis, Vector v1, void *cb);
const bool RT_Int_Vector= false;
const bool RB_Int_Vector = false;
const int PC_Int_Vector = 3;
int Hook_Int_Vector(Hook *hook, void *pthis, Vector v1);
const bool RT_Int_Cbase_pVector = false;
const bool RB_Int_Cbase_pVector = false;
const int PC_Int_Cbase_pVector = 2;
int Hook_Int_Cbase_pVector(Hook *hook, void *pthis, void *cb1, Vector *v1);
const bool RT_Void_Bool = true;
const bool RB_Void_Bool = false;
const int PC_Void_Bool = 1;
void Hook_Void_Bool(Hook *hook, void *pthis, bool b1);
const bool RT_Bool_Cbase = false;
const bool RB_Bool_Cbase = false;
const int PC_Bool_Cbase = 1;
bool Hook_Bool_Cbase(Hook *hook, void *pthis, void *cb);
const bool RT_Bool_Int = false;
const bool RB_Bool_Int = false;
const int PC_Bool_Int = 1;
bool Hook_Bool_Int(Hook *hook, void *pthis, int i1);
const bool RT_Void_Cbase_Float = true;
const bool RB_Void_Cbase_Float = false;
const int PC_Void_Cbase_Float = 2;
void Hook_Void_Cbase_Float(Hook *hook, void *pthis, void *p1, float f1);
const bool RT_Void_Cbase_Bool = true;
const bool RB_Void_Cbase_Bool = false;
const int PC_Void_Cbase_Bool = 2;
void Hook_Void_Cbase_Bool(Hook *hook, void *pthis, void *p1, bool b1);
const bool RT_Vector_Vector_Vector_Vector = true;
const bool RB_Vector_Vector_Vector_Vector = true;
const int PC_Vector_Vector_Vector_Vector = 10;
#if defined(_WIN32)
void Hook_Vector_Vector_Vector_Vector(Hook *hook, void *pthis, Vector *out, Vector v1, Vector v2, Vector v3);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Vector_Vector_Vector(Hook *hook, Vector *out, void *pthis, Vector v1, Vector v2, Vector v3);
#endif
const bool RT_Str_Str = false;
const bool RB_Str_Str = false;
const int PC_Str_Str = 1;
const char *Hook_Str_Str(Hook *hook, void *pthis, const char* str);
const bool RT_Void_Short = true;
const bool RB_Void_Short = false;
const int PC_Void_Short = 1;
void Hook_Void_Short(Hook *hook, void *pthis, short i1);
const bool RT_Deprecated = true;
const bool RB_Deprecated = false;
const int PC_Deprecated = 0;
void Hook_Deprecated(Hook* hook);
const bool RT_Vector_Float = true;
const bool RB_Vector_Float = true;
const int PC_Vector_Float = 2;
#if defined(_WIN32)
void Hook_Vector_Float(Hook *hook, void *pthis, Vector *out, float f1);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Float(Hook *hook, Vector *out, void *pthis, float f1);
#endif
const bool RT_Void_Float_Cbase = true;
const bool RB_Void_Float_Cbase = false;
const int PC_Void_Float_Cbase = 2;
void Hook_Void_Float_Cbase(Hook *hook, void *pthis, float f1, void *cb);
const bool RT_Int_Float_Float = false;
const bool RB_Int_Float_Float = false;
const int PC_Int_Float_Float = 2;
int Hook_Int_Float_Float(Hook *hook, void *pthis, float f1, float f2);
const bool RT_Int_Float = false;
const bool RB_Int_Float = false;
const int PC_Int_Float = 1;
int Hook_Int_Float(Hook *hook, void *pthis, float f1);
const bool RT_Int_Int_Int = false;
const bool RB_Int_Int_Int = false;
const int PC_Int_Int_Int = 2;
int Hook_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2);
const bool RT_Void_Str_Float_Float_Float = true;
const bool RB_Void_Str_Float_Float_Float = false;
const int PC_Void_Str_Float_Float_Float = 4;
void Hook_Void_Str_Float_Float_Float(Hook *hook, void *pthis, const char *sz1, float f1, float f2, float f3);
const bool RT_Void_Str_Float_Float_Float_Int_Cbase = true;
const bool RB_Void_Str_Float_Float_Float_Int_Cbase = false;
const int PC_Void_Str_Float_Float_Float_Int_Cbase = 6;
void Hook_Void_Str_Float_Float_Float_Int_Cbase(Hook *hook, void *pthis, const char *sz1, float f1, float f2, float f3, int i1, void *cb);
const bool RT_Int_Vector_Vector_Float_Float= false;
const bool RB_Int_Vector_Vector_Float_Float = false;
const int PC_Int_Vector_Vector_Float_Float = 8;
int Hook_Int_Vector_Vector_Float_Float(Hook *hook, void *pthis, Vector v1, Vector v2, float f1, float f2);
const bool RT_Int_Short = false;
const bool RB_Int_Short = false;
const int PC_Int_Short = 1;
int Hook_Int_Short(Hook *hook, void *pthis, short s1);
const bool RT_Void_Entvar_Entvar_Float_Int_Int = true;
const bool RB_Void_Entvar_Entvar_Float_Int_Int = false;
const int PC_Void_Entvar_Entvar_Float_Int_Int = 5;
void Hook_Void_Entvar_Entvar_Float_Int_Int(Hook *hook, void *pthis,
entvars_t *inflictor,
entvars_t *attacker, float damage,
int classignore, int damagebits);
const bool RT_Void_Vector_Entvar_Entvar_Float_Int_Int = true;
const bool RB_Void_Vector_Entvar_Entvar_Float_Int_Int = false;
const int PC_Void_Vector_Entvar_Entvar_Float_Int_Int = 8;
void Hook_Void_Vector_Entvar_Entvar_Float_Int_Int(Hook *hook, void *pthis,
Vector source,
entvars_t *inflictor,
entvars_t *attacker, float damage,
int classignore, int damagebits);
const bool RT_Float_Int_Float = false;
const bool RB_Float_Int_Float = false;
const int PC_Float_Int_Float = 2;
float Hook_Float_Int_Float(Hook *hook, void *pthis, int i1, float f2);
const bool RT_Int_Str = false;
const bool RB_Int_Str = false;
const int PC_Int_Str = 1;
int Hook_Int_Str(Hook *hook, void *pthis, const char *sz1);
const bool RT_Void_Edict = true;
const bool RB_Void_Edict = false;
const int PC_Void_Edict = 1;
void Hook_Void_Edict(Hook *hook, void *pthis, edict_t *ed1 );
const bool RT_Void_Int_Str_Bool = true;
const bool RB_Void_Int_Str_Bool = false;
const int PC_Void_Int_Str_Bool = 3;
void Hook_Void_Int_Str_Bool(Hook *hook, void *pthis, int i1, const char *sz2, bool b3);
const bool RT_Void_Vector_Vector= true;
const bool RB_Void_Vector_Vector = false;
const int PC_Void_Vector_Vector = 6;
void Hook_Void_Vector_Vector(Hook *hook, void *pthis, Vector v1, Vector v2);
const bool RT_Void_Str_Bool = true;
const bool RB_Void_Str_Bool = false;
const int PC_Void_Str_Bool = 2;
void Hook_Void_Str_Bool(Hook *hook, void *pthis, const char *sz1, bool b2);
const bool RT_Int_Str_Str_Int_Str_Int_Int = false;
const bool RB_Int_Str_Str_Int_Str_Int_Int = false;
const int PC_Int_Str_Str_Int_Str_Int_Int = 6;
int Hook_Int_Str_Str_Int_Str_Int_Int(Hook *hook, void *pthis, const char *sz1, const char *sz2, int i1, const char *sz3, int i2, int i3);
const bool RT_Int_Int_Int_Float_Int = false;
const bool RB_Int_Int_Int_Float_Int = false;
const int PC_Int_Int_Int_Float_Int = 4;
int Hook_Int_Int_Int_Float_Int(Hook *hook, void *pthis, int i1, int i2, float f1, int i3);
const bool RT_Void_Str_Int = true;
const bool RB_Void_Str_Int = false;
const int PC_Void_Str_Int = 2;
void Hook_Void_Str_Int(Hook *hook, void *pthis, const char *sz1, int i2);
const bool RT_Void_Cbase_Int = true;
const bool RB_Void_Cbase_Int = false;
const int PC_Void_Cbase_Int = 2;
void Hook_Void_Cbase_Int(Hook *hook, void *pthis, void *p1, int i1);
const bool RT_Void_Str = true;
const bool RB_Void_Str = false;
const int PC_Void_Str = 1;
void Hook_Void_Str(Hook *hook, void *pthis, const char *sz1);
const bool RT_Void_Vector = true;
const bool RB_Void_Vector = false;
const int PC_Void_Vector = 3;
void Hook_Void_Vector(Hook *hook, void *pthis, Vector v1);
const bool RT_Int_Str_Vector_Str = false;
const bool RB_Int_Str_Vector_Str = false;
const int PC_Int_Str_Vector_Str = 5;
int Hook_Int_Str_Vector_Str(Hook *hook, void *pthis, const char *sz1, Vector v2, const char *sz2);
const bool RT_Int_Str_Str = false;
const bool RB_Int_Str_Str = false;
const int PC_Int_Str_Str = 2;
int Hook_Int_Str_Str(Hook *hook, void *pthis, const char *sz1, const char *sz2);
const bool RT_Void_Float_Float = true;
const bool RB_Void_Float_Float = false;
const int PC_Void_Float_Float = 2;
void Hook_Void_Float_Float(Hook *hook, void *pthis, float f1, float f2);
const bool RT_Void_Str_Str_Int = true;
const bool RB_Void_Str_Str_Int = false;
const int PC_Void_Str_Str_Int = 3;
void Hook_Void_Str_Str_Int(Hook *hook, void *pthis, const char *sz1, const char *sz2, int i3);
const bool RT_Int_pVector_pVector_Cbase_pFloat = false;
const bool RB_Int_pVector_pVector_Cbase_pFloat = false;
const int PC_Int_pVector_pVector_Cbase_pFloat = 4;
int Hook_Int_pVector_pVector_Cbase_pFloat(Hook *hook, void *pthis, Vector *v1, Vector *v2, void* cb, float* fl);
const bool RT_Void_Cbase_pVector_Float = true;
const bool RB_Void_Cbase_pVector_Float = false;
const int PC_Void_Cbase_pVector_Float = 3;
void Hook_Void_Cbase_pVector_Float(Hook *hook, void *pthis, void *p1, Vector *v1, float fl);
const bool RT_Int_pVector_pVector_Float_Cbase_pVector = false;
const bool RB_Int_pVector_pVector_Float_Cbase_pVector = false;
const int PC_Int_pVector_pVector_Float_Cbase_pVector = 5;
int Hook_Int_pVector_pVector_Float_Cbase_pVector(Hook *hook, void *pthis, Vector *v1, Vector *v2, float fl, void* cb, Vector *v3);
const bool RT_Int_Cbase_Bool = false;
const bool RB_Int_Cbase_Bool = false;
const int PC_Int_Cbase_Bool = 2;
int Hook_Int_Cbase_Bool(Hook *hook, void *pthis, void *cb1, bool b1);
const bool RT_Int_Vector_Vector = false;
const bool RB_Int_Vector_Vector = false;
const int PC_Int_Vector_Vector = 6;
int Hook_Int_Vector_Vector(Hook *hook, void *pthis, Vector v1, Vector v2);
const bool RT_Int_Entvar_Float = false;
const bool RB_Int_Entvar_Float = false;
const int PC_Int_Entvar_Float = 2;
int Hook_Int_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1);
const bool RT_Float_Float = false;
const bool RB_Float_Float = false;
const int PC_Float_Float = 1;
float Hook_Float_Float(Hook *hook, void *pthis, float f1);
const bool RT_Void_Entvar_Entvar_Float = true;
const bool RB_Void_Entvar_Entvar_Float = false;
const int PC_Void_Entvar_Entvar_Float = 3;
void Hook_Void_Entvar_Entvar_Float(Hook *hook, void *pthis, entvars_t *attacker, entvars_t *inflictor, float damage);
const bool RT_Bool_Void = false;
const bool RB_Bool_Void = false;
const int PC_Bool_Void = 0;
bool Hook_Bool_Void(Hook *hook, void *pthis);
const bool RT_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool = false;
const bool RB_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool = false;
const int PC_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool = 7;
int Hook_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(Hook *hook, void *pthis, Vector *v1, Vector *v2, float fl, void* cb, Vector *v3, Vector *v4, bool b1);
const bool RT_Int_Vector_Cbase = false;
const bool RB_Int_Vector_Cbase = false;
const int PC_Int_Vector_Cbase = 4;
int Hook_Int_Vector_Cbase(Hook *hook, void *pthis, Vector v1, void *cb);
const bool RT_Int_Vector= false;
const bool RB_Int_Vector = false;
const int PC_Int_Vector = 3;
int Hook_Int_Vector(Hook *hook, void *pthis, Vector v1);
const bool RT_Int_Cbase_pVector = false;
const bool RB_Int_Cbase_pVector = false;
const int PC_Int_Cbase_pVector = 2;
int Hook_Int_Cbase_pVector(Hook *hook, void *pthis, void *cb1, Vector *v1);
const bool RT_Void_Bool = true;
const bool RB_Void_Bool = false;
const int PC_Void_Bool = 1;
void Hook_Void_Bool(Hook *hook, void *pthis, bool b1);
const bool RT_Bool_Cbase = false;
const bool RB_Bool_Cbase = false;
const int PC_Bool_Cbase = 1;
bool Hook_Bool_Cbase(Hook *hook, void *pthis, void *cb);
const bool RT_Bool_Int = false;
const bool RB_Bool_Int = false;
const int PC_Bool_Int = 1;
bool Hook_Bool_Int(Hook *hook, void *pthis, int i1);
const bool RT_Void_Cbase_Float = true;
const bool RB_Void_Cbase_Float = false;
const int PC_Void_Cbase_Float = 2;
void Hook_Void_Cbase_Float(Hook *hook, void *pthis, void *p1, float f1);
const bool RT_Void_Cbase_Bool = true;
const bool RB_Void_Cbase_Bool = false;
const int PC_Void_Cbase_Bool = 2;
void Hook_Void_Cbase_Bool(Hook *hook, void *pthis, void *p1, bool b1);
const bool RT_Vector_Vector_Vector_Vector = true;
const bool RB_Vector_Vector_Vector_Vector = true;
const int PC_Vector_Vector_Vector_Vector = 10;
#if defined(_WIN32)
void Hook_Vector_Vector_Vector_Vector(Hook *hook, void *pthis, Vector *out, Vector v1, Vector v2, Vector v3);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Vector_Vector_Vector(Hook *hook, Vector *out, void *pthis, Vector v1, Vector v2, Vector v3);
#endif
const bool RT_Str_Str = false;
const bool RB_Str_Str = false;
const int PC_Str_Str = 1;
const char *Hook_Str_Str(Hook *hook, void *pthis, const char* str);
const bool RT_Void_Short = true;
const bool RB_Void_Short = false;
const int PC_Void_Short = 1;
void Hook_Void_Short(Hook *hook, void *pthis, short i1);
const bool RT_Deprecated = true;
const bool RB_Deprecated = false;
const int PC_Deprecated = 0;
void Hook_Deprecated(Hook* hook);
#endif

View File

@ -38,20 +38,20 @@ int Create_Int_Float_Int(AMX *amx, const char *func)
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Int_Float_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Float_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Entvar_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Entvar_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Cbase(AMX *amx, const char *func)
{
@ -68,9 +68,9 @@ int Create_Int_Int_Str_Int(AMX *amx, const char *func)
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Int_Int_Str_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_CELL, FP_DONE);
int Create_Int_Int_Str_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Int(AMX *amx, const char *func)
@ -103,11 +103,11 @@ int Create_Void_Cbase_Cbase_Int_Float(AMX *amx, const char *func)
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Vector_Float_Cbase_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Vector_Float_Cbase_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_ARRAY, FP_CELL, FP_CELL, FP_DONE);
@ -157,289 +157,289 @@ int Create_Void_Entvar_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Int_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_ItemInfo(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Float_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Float_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Float_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Float_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Float_Float_Cbase(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Void_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Float_Float_Float_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Vector_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Float_Cbase(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Int_Float_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Int_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Int_Int_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Str_Float_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_FLOAT, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_FLOAT, FP_FLOAT, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Vector_Vector_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Int_Short(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Float_Int_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Int_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_DONE);
}
int Create_Void_Edict(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Int_Str_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Void_Vector_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_DONE);
}
int Create_Void_Str_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Int_Str_Str_Int_Str_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_STRING, FP_CELL, FP_STRING, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Int_Int_Float_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Void_Str_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Void_Cbase_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_DONE);
}
int Create_Void_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_Str_Vector_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_ARRAY, FP_STRING, FP_DONE);
}
int Create_Int_Str_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_STRING, FP_DONE);
}
int Create_Void_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Void_Str_Str_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Int_pVector_pVector_Cbase_pFloat(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Cbase_pVector_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_ARRAY, FP_FLOAT, FP_DONE);
}
int Create_Int_pVector_pVector_Float_Cbase_pVector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_Cbase_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Vector_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_DONE);
}
int Create_Int_Entvar_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Entvar_Entvar_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Bool_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_CELL, FP_ARRAY, FP_ARRAY, FP_CELL, FP_DONE);
}
int Create_Int_Vector_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_CELL, FP_DONE);
}
int Create_Int_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_Cbase_pVector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Void_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Bool_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Bool_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Cbase_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Cbase_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Vector_Vector_Vector_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_ARRAY, FP_DONE);
}
int Create_Str_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_DONE);
}
int Create_Void_Short(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Float_Float_Cbase(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Void_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Float_Float_Float_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Vector_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Float_Cbase(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Int_Float_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Int_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Int_Int_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Str_Float_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_FLOAT, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_FLOAT, FP_FLOAT, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Vector_Vector_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Int_Short(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Float_Int_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Int_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_DONE);
}
int Create_Void_Edict(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Int_Str_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Void_Vector_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_DONE);
}
int Create_Void_Str_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Int_Str_Str_Int_Str_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_STRING, FP_CELL, FP_STRING, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Int_Int_Float_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Void_Str_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Void_Cbase_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_DONE);
}
int Create_Void_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_Str_Vector_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_ARRAY, FP_STRING, FP_DONE);
}
int Create_Int_Str_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_STRING, FP_DONE);
}
int Create_Void_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Void_Str_Str_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Int_pVector_pVector_Cbase_pFloat(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Cbase_pVector_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_ARRAY, FP_FLOAT, FP_DONE);
}
int Create_Int_pVector_pVector_Float_Cbase_pVector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_Cbase_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Vector_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_DONE);
}
int Create_Int_Entvar_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Entvar_Entvar_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Bool_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_CELL, FP_ARRAY, FP_ARRAY, FP_CELL, FP_DONE);
}
int Create_Int_Vector_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_CELL, FP_DONE);
}
int Create_Int_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_Cbase_pVector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Void_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Bool_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Bool_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Cbase_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Cbase_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Vector_Vector_Vector_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_ARRAY, FP_DONE);
}
int Create_Str_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_DONE);
}
int Create_Void_Short(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Deprecated(AMX* amx, const char* func)
{
return -1;

View File

@ -24,13 +24,13 @@ int Create_Void_Entvar(AMX *amx, const char *func);
int Create_Void_Cbase(AMX *amx, const char *func);
int Create_Int_Float_Int(AMX *amx, const char *func);
int Create_Int_Float_Int_Int(AMX *amx, const char *func);
int Create_Int_Float_Int_Int(AMX *amx, const char *func);
int Create_Void_Entvar_Int(AMX *amx, const char *func);
int Create_Void_Entvar_Entvar_Int(AMX *amx, const char *func);
int Create_Void_Entvar_Entvar_Int(AMX *amx, const char *func);
int Create_Int_Cbase(AMX *amx, const char *func);
int Create_Void_Int_Int(AMX *amx, const char *func);
@ -49,8 +49,8 @@ int Create_Int_Entvar_Entvar_Float_Float_Int(AMX *amx, const char *func);
int Create_Void_Int(AMX *amx, const char *func);
int Create_Vector_Float_Cbase_Int(AMX *amx, const char *func);
int Create_Vector_Float_Cbase_Int(AMX *amx, const char *func);
int Create_Void_Cbase_Cbase_Int_Float(AMX *amx, const char *func);
int Create_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, const char *func);
@ -79,112 +79,112 @@ int Create_Void_ItemInfo(AMX *amx, const char *func);
int Create_Float_Void(AMX *amx, const char *func);
int Create_Float_Int(AMX *amx, const char *func);
int Create_Float_Int(AMX *amx, const char *func);
int Create_Void_Float_Int(AMX *amx, const char *func);
int Create_Float_Float_Cbase(AMX *amx, const char *func);
int Create_Void_Float(AMX *amx, const char *func);
int Create_Void_Float_Float_Float_Int(AMX *amx, const char *func);
int Create_Vector_Float(AMX *amx, const char *func);
int Create_Void_Float_Cbase(AMX *amx, const char *func);
int Create_Int_Float_Float(AMX* amx, const char* func);
int Create_Int_Float(AMX* amx, const char* func);
int Create_Int_Int_Int(AMX* amx, const char* func);
int Create_Void_Str_Float_Float_Float(AMX* amx, const char* func);
int Create_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, const char *func);
int Create_Int_Vector_Vector_Float_Float(AMX *amx, const char *func);
int Create_Int_Short(AMX* amx, const char* func);
int Create_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func);
int Create_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func);
int Create_Float_Int_Float(AMX *amx, const char *func);
int Create_Int_Str(AMX *amx, const char *func);
int Create_Void_Edict(AMX *amx, const char *func);
int Create_Void_Int_Str_Bool(AMX *amx, const char *func);
int Create_Void_Vector_Vector(AMX *amx, const char *func);
int Create_Void_Str_Bool(AMX *amx, const char *func);
int Create_Int_Str_Str_Int_Str_Int_Int(AMX *amx, const char *func);
int Create_Int_Int_Int_Float_Int(AMX *amx, const char *func);
int Create_Void_Str_Int(AMX *amx, const char *func);
int Create_Void_Cbase_Int(AMX *amx, const char *func);
int Create_Void_Str(AMX *amx, const char *func);
int Create_Void_Vector(AMX *amx, const char *func);
int Create_Int_Str_Vector_Str(AMX *amx, const char *func);
int Create_Int_Str_Str(AMX *amx, const char *func);
int Create_Void_Float_Float(AMX *amx, const char *func);
int Create_Void_Str_Str_Int(AMX *amx, const char *func);
int Create_Int_pVector_pVector_Cbase_pFloat(AMX *amx, const char *func);
int Create_Void_Cbase_pVector_Float(AMX *amx, const char *func);
int Create_Int_pVector_pVector_Float_Cbase_pVector(AMX *amx, const char *func);
int Create_Int_Cbase_Bool(AMX *amx, const char *func);
int Create_Int_Vector_Vector(AMX *amx, const char *func);
int Create_Int_Entvar_Float(AMX *amx, const char *func);
int Create_Float_Float(AMX *amx, const char *func);
int Create_Void_Entvar_Entvar_Float(AMX *amx, const char *func);
int Create_Bool_Void(AMX *amx, const char *func);
int Create_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX *amx, const char *func);
int Create_Int_Vector_Cbase(AMX *amx, const char *func);
int Create_Int_Vector(AMX *amx, const char *func);
int Create_Int_Cbase_pVector(AMX *amx, const char *func);
int Create_Void_Bool(AMX *amx, const char *func);
int Create_Bool_Cbase(AMX *amx, const char *func);
int Create_Bool_Int(AMX *amx, const char *func);
int Create_Void_Cbase_Float(AMX *amx, const char *func);
int Create_Void_Cbase_Bool(AMX *amx, const char *func);
int Create_Vector_Vector_Vector_Vector(AMX *amx, const char *func);
int Create_Str_Str(AMX *amx, const char *func);
int Create_Void_Short(AMX *amx, const char *func);
int Create_Float_Float_Cbase(AMX *amx, const char *func);
int Create_Void_Float(AMX *amx, const char *func);
int Create_Void_Float_Float_Float_Int(AMX *amx, const char *func);
int Create_Vector_Float(AMX *amx, const char *func);
int Create_Void_Float_Cbase(AMX *amx, const char *func);
int Create_Int_Float_Float(AMX* amx, const char* func);
int Create_Int_Float(AMX* amx, const char* func);
int Create_Int_Int_Int(AMX* amx, const char* func);
int Create_Void_Str_Float_Float_Float(AMX* amx, const char* func);
int Create_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, const char *func);
int Create_Int_Vector_Vector_Float_Float(AMX *amx, const char *func);
int Create_Int_Short(AMX* amx, const char* func);
int Create_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func);
int Create_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func);
int Create_Float_Int_Float(AMX *amx, const char *func);
int Create_Int_Str(AMX *amx, const char *func);
int Create_Void_Edict(AMX *amx, const char *func);
int Create_Void_Int_Str_Bool(AMX *amx, const char *func);
int Create_Void_Vector_Vector(AMX *amx, const char *func);
int Create_Void_Str_Bool(AMX *amx, const char *func);
int Create_Int_Str_Str_Int_Str_Int_Int(AMX *amx, const char *func);
int Create_Int_Int_Int_Float_Int(AMX *amx, const char *func);
int Create_Void_Str_Int(AMX *amx, const char *func);
int Create_Void_Cbase_Int(AMX *amx, const char *func);
int Create_Void_Str(AMX *amx, const char *func);
int Create_Void_Vector(AMX *amx, const char *func);
int Create_Int_Str_Vector_Str(AMX *amx, const char *func);
int Create_Int_Str_Str(AMX *amx, const char *func);
int Create_Void_Float_Float(AMX *amx, const char *func);
int Create_Void_Str_Str_Int(AMX *amx, const char *func);
int Create_Int_pVector_pVector_Cbase_pFloat(AMX *amx, const char *func);
int Create_Void_Cbase_pVector_Float(AMX *amx, const char *func);
int Create_Int_pVector_pVector_Float_Cbase_pVector(AMX *amx, const char *func);
int Create_Int_Cbase_Bool(AMX *amx, const char *func);
int Create_Int_Vector_Vector(AMX *amx, const char *func);
int Create_Int_Entvar_Float(AMX *amx, const char *func);
int Create_Float_Float(AMX *amx, const char *func);
int Create_Void_Entvar_Entvar_Float(AMX *amx, const char *func);
int Create_Bool_Void(AMX *amx, const char *func);
int Create_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX *amx, const char *func);
int Create_Int_Vector_Cbase(AMX *amx, const char *func);
int Create_Int_Vector(AMX *amx, const char *func);
int Create_Int_Cbase_pVector(AMX *amx, const char *func);
int Create_Void_Bool(AMX *amx, const char *func);
int Create_Bool_Cbase(AMX *amx, const char *func);
int Create_Bool_Int(AMX *amx, const char *func);
int Create_Void_Cbase_Float(AMX *amx, const char *func);
int Create_Void_Cbase_Bool(AMX *amx, const char *func);
int Create_Vector_Vector_Vector_Vector(AMX *amx, const char *func);
int Create_Str_Str(AMX *amx, const char *func);
int Create_Void_Short(AMX *amx, const char *func);
int Create_Deprecated(AMX* amx, const char* func);

View File

@ -96,7 +96,7 @@ hook_t hooklist[] =
{ V("illumination", Int_Void) },
{ V("fvisible", Int_Cbase) },
{ V("fvecvisible", Int_pVector) },
/** Entity specific hooks **/
/* CBasePlayer */
@ -127,7 +127,7 @@ hook_t hooklist[] =
{ V("item_updateclientdata", Int_Cbase) },
{ V("item_getweaponptr", Cbase_Void) },
{ V("item_itemslot", Int_Void) },
/* CBasePlayerWeapon */
{ V("weapon_extractammo", Int_Cbase) },
{ V("weapon_extractclipammo", Int_Cbase) },
@ -143,7 +143,7 @@ hook_t hooklist[] =
{ V("weapon_retireweapon", Void_Void) },
{ V("weapon_shouldweaponidle", Int_Void) },
{ V("weapon_usedecrement", Int_Void) },
/** Mod specific hooks **/
/* The Specialists */
@ -195,326 +195,326 @@ hook_t hooklist[] =
{ V("ts_onfreeentprivatedata", Void_Void) },
{ V("ts_shouldcollide", Int_Cbase) },
/** New Additions (2011) **/
{ V("changeyaw", Float_Int) },
{ V("hashumangibs", Int_Void) },
{ V("hasaliengibs", Int_Void) },
{ V("fademonster", Void_Void) },
{ V("gibmonster", Void_Void) },
{ V("becomedead", Void_Void) },
{ V("irelationship", Int_Cbase) },
{ V("painsound", Void_Void) },
{ V("reportaistate", Void_Void) },
{ V("monsterinitdead", Void_Void) },
{ V("look", Void_Int) },
{ V("bestvisibleenemy", Cbase_Void) },
{ V("finviewcone", Int_Cbase) },
{ V("fvecinviewcone", Int_pVector) },
{ V("getdeathactivity", Int_Void) },
/* Not supported by Counter-Strike, The Specialists and Natural Selection mods. */
{ V("runai", Void_Void) },
{ V("monsterthink", Void_Void) },
{ V("monsterinit", Void_Void) },
{ V("checklocalmove", Int_pVector_pVector_Cbase_pFloat) },
{ V("move", Void_Float) },
{ V("moveexecute", Void_Cbase_pVector_Float) },
{ V("shouldadvanceroute", Int_Float) },
{ V("getstoppedactivity", Int_Void) },
{ V("stop", Void_Void) },
{ V("checkrangeattack1", Int_Float_Float) },
{ V("checkrangeattack2", Int_Float_Float) },
{ V("checkmeleeattack1", Int_Float_Float) },
{ V("checkmeleeattack2", Int_Float_Float) },
{ V("schedulechange", Void_Void) },
{ V("canplaysequence", Int_Int_Int) },
{ V("canplaysentence", Int_Int) },
{ V("playsentence", Void_Str_Float_Float_Float) },
{ V("playscriptedsentence", Void_Str_Float_Float_Float_Int_Cbase) },
{ V("sentencestop", Void_Void) },
{ V("getidealstate", Int_Void) },
{ V("setactivity", Void_Int) },
{ V("checkenemy", Int_Cbase) },
{ V("ftriangulate", Int_pVector_pVector_Float_Cbase_pVector) },
{ V("setyawspeed", Void_Void) },
{ V("buildnearestroute", Int_Vector_Vector_Float_Float) },
{ V("findcover", Int_Vector_Vector_Float_Float) },
{ V("coverradius", Float_Void) },
{ V("fcancheckattacks", Int_Void) },
{ V("checkammo", Void_Void) },
{ V("ignoreconditions", Int_Void) },
{ V("fvalidatehinttype", Int_Short) },
{ V("fcanactiveidle", Int_Void) },
{ V("isoundmask", Int_Void) },
{ V("hearingsensitivity", Float_Void) },
{ V("barnaclevictimbitten", Void_Entvar) },
{ V("barnaclevictimreleased", Void_Void) },
{ V("preschedulethink", Void_Void) },
{ V("deathsound", Void_Void) },
{ V("alertsound", Void_Void) },
{ V("idlesound", Void_Void) },
{ V("stopfollowing", Void_Int) },
/** Mod specific hooks **/
/* Counter-Strike */
{ V("cstrike_weapon_sendweaponanim",Void_Int_Int) },
{ V("cstrike_player_resetmaxspeed", Void_Void) },
{ V("cstrike_player_isbot", Int_Void) },
{ V("cstrike_player_getautoaimvector", Vector_Float) },
{ V("cstrike_player_blind", Void_Float_Float_Float_Int) },
{ V("cstrike_player_ontouchingweapon",Void_Cbase) },
/* Day of Defeat */
{ V("dod_setscriptreset", Void_Void) },
{ V("dod_item_spawndeploy", Int_Void) },
{ V("dod_item_setdmgtime", Void_Float) },
{ V("dod_item_dropgren", Void_Void) },
{ V("dod_weapon_isuseable", Int_Void) },
{ V("dod_weapon_aim", Vector_Float_Cbase_Int) },
{ V("dod_weapon_flaim", Float_Float_Cbase) },
{ V("dod_weapon_removestamina", Void_Float_Cbase) },
{ V("dod_weapon_changefov", Int_Int) },
{ V("dod_weapon_zoomout", Int_Void) },
{ V("dod_weapon_zoomin", Int_Void) },
{ V("dod_weapon_getfov", Int_Void) },
{ V("dod_weapon_playeriswatersniping", Bool_Void) },
{ V("dod_weapon_updatezoomspeed", Void_Void) },
{ V("dod_weapon_special", Void_Void) },
/* Team Fortress Classic */
{ V("tfc_dbgetitemname", Str_Void) },
{ V("tfc_radiusdamage", Void_Entvar_Entvar_Float_Int_Int) },
{ V("tfc_radiusdamage2", Void_Vector_Entvar_Entvar_Float_Int_Int) },
/* Earth's Special Forces */
{ V("esf_isfighter", Int_Void) },
{ V("esf_isbuddy", Int_Void) },
{ V("esf_emitsound", Void_Str_Int) },
{ V("esf_emitnullsound", Void_Int) },
{ V("esf_increasestrength", Void_Cbase_Int) },
{ V("esf_increasepl", Void_Int) },
{ V("esf_setpowerlevel", Void_Int) },
{ V("esf_setmaxpowerlevel", Void_Int) },
{ V("esf_stopanitrigger", Void_Int) },
{ V("esf_stopfly", Void_Void) },
{ V("esf_hideweapon", Void_Void) },
{ V("esf_clientremoveweapon", Void_Int) },
{ V("esf_sendclientcustommodel",Void_Str) },
{ V("esf_canturbo", Int_Void) },
{ V("esf_canprimaryfire", Int_Void) },
{ V("esf_cansecondaryfire", Int_Void) },
{ V("esf_canstopfly", Int_Void) },
{ V("esf_canblock", Int_Void) },
{ V("esf_canraiseKi", Int_Void) },
{ V("esf_canraisestamina", Int_Void) },
{ V("esf_canteleport", Int_Void) },
{ V("esf_canstartfly", Int_Void) },
{ V("esf_canstartpowerup", Int_Void) },
{ V("esf_canjump", Int_Void) },
{ V("esf_canwalljump", Int_Void) },
{ V("esf_issuperjump", Int_Void) },
{ V("esf_ismoveback", Int_Void) },
{ V("esf_checkwalljump", Int_Void) },
{ V("esf_enablewalljump", Void_Vector) },
{ V("esf_disablewalljump", Void_Void) },
{ V("esf_resetwalljumpvars", Void_Void) },
{ V("esf_getwalljumpanim", Int_Str_Vector_Str) },
{ V("esf_getwalljumpanim2", Int_Str_Str) },
{ V("esf_setwalljumpanimation", Void_Void) },
{ V("esf_setflymovetype", Void_Void) },
{ V("esf_isflymovetype", Int_Void) },
{ V("esf_iswalkmovetype", Int_Void) },
{ V("esf_setwalkmovetype", Void_Void) },
{ V("esf_drawchargebar", Void_Int) },
{ V("esf_startblock", Void_Void) },
{ V("esf_stopblock", Void_Void) },
{ V("esf_startfly", Void_Void) },
{ V("esf_getmaxspeed", Float_Void) },
{ V("esf_setanimation", Void_Int) },
{ V("esf_playanimation", Void_Void) },
{ V("esf_getmoveforward", Int_Void) },
{ V("esf_getmoveright", Int_Void) },
{ V("esf_getmoveup", Void_Void) },
{ V("esf_addblindfx", Void_Void) },
{ V("esf_removeblindfx", Void_Void) },
{ V("esf_disablepsbar", Void_Void) },
{ V("esf_addbeamboxcrosshair", Void_Int) },
{ V("esf_removebeamboxcrosshair", Void_Void) },
{ V("esf_drawpswinbonus", Void_Void) },
{ V("esf_drawpsbar", Void_Float_Float) },
{ V("esf_lockcrosshair", Void_Void) },
{ V("esf_unlockcrosshair", Void_Void) },
{ V("esf_rotatecrosshair", Void_Void) },
{ V("esf_unrotatecrosshair", Void_Void) },
{ V("esf_watermove", Void_Void) },
{ V("esf_checktimebaseddamage", Void_Void) },
{ V("esf_doessecondaryattack", Int_Void) },
{ V("esf_doesprimaryattack", Int_Void) },
{ V("esf_removespecialmodes", Void_Void) },
{ V("esf_stopturbo", Void_Void) },
{ V("esf_takebean", Void_Void) },
{ V("esf_getpowerlevel", Void_Void) },
{ V("esf_removeallotherweapons",Void_Void) },
{ V("esf_stopswoop", Void_Void) },
{ V("esf_setdeathanimation", Void_Void) },
{ V("esf_setmodel", Void_Void) },
{ V("esf_addattacks", Void_Void) },
{ V("esf_emitclasssound", Void_Str_Str_Int) },
{ V("esf_checklightning", Void_Void) },
{ V("esf_freezecontrols", Void_Void) },
{ V("esf_unfreezecontrols", Void_Void) },
{ V("esf_updateki", Void_Void) },
{ V("esf_updatehealth", Void_Void) },
{ V("esf_getteleportdir", Vector_Void) },
{ V("esf_weapon_holsterwhenmeleed", Void_Void) },
/* Natural-Selection */
{ V("ns_setbonecontroller", Float_Int_Float) },
{ V("ns_savedataforreset", Void_Void) },
{ V("ns_gethull", Int_Void) },
{ V("ns_getmaxwalkspeed", Float_Void) },
{ V("ns_setteamid", Str_Str) },
{ V("ns_geteffectiveplayerclass", Int_Void) },
{ V("ns_getauthenticationmask", Int_Void) },
{ V("ns_effectiveplayerclasschanged", Void_Void) },
{ V("ns_needsteamupdate", Void_Void) },
{ V("ns_sendteamupdate", Void_Void) },
{ V("ns_sendweaponupdate", Void_Void) },
{ V("ns_initplayerfromspawn", Void_Edict) },
{ V("ns_packdeadplayeritems", Void_Void) },
{ V("ns_getanimationforactivity",Void_Int_Str_Bool) },
{ V("ns_startobserver", Void_Vector_Vector) },
{ V("ns_stopobserver", Void_Void) },
{ V("ns_getadrenalinefactor", Float_Void) },
{ V("ns_givenameditem", Void_Str_Bool) },
{ V("ns_suicide", Void_Void) },
{ V("ns_getcanuseweapon", Int_Void) },
{ V("ns_weapon_getweaponprimetime", Float_Void) },
{ V("ns_weapon_primeweapon", Void_Void) },
{ V("ns_weapon_getisweaponprimed", Int_Void) },
{ V("ns_weapon_getisweaponpriming", Int_Void) },
{ V("ns_weapon_defaultdeploy", Int_Str_Str_Int_Str_Int_Int) },
{ V("ns_weapon_defaultreload", Int_Int_Int_Float_Int) },
{ V("ns_weapon_getdeploytime", Float_Void) },
/* Sven co-op */
{ V("sc_getclassification", Int_Int) },
{ V("sc_ismonster", Int_Void) },
{ V("sc_isphysx", Int_Void) },
{ V("sc_ispointentity", Int_Void) },
{ V("sc_ismachine", Int_Void) },
{ V("sc_criticalremove", Int_Void) },
{ V("sc_updateonremove", Void_Void) },
{ V("sc_fvisible", Int_Cbase_Bool) },
{ V("sc_fvisiblefrompos", Int_Vector_Vector) },
{ V("sc_isfacing", Int_Entvar_Float) },
{ V("sc_getpointsfordamage", Float_Float) },
{ V("sc_getdamagepoints", Void_Entvar_Entvar_Float) },
{ V("sc_oncreate", Void_Void) },
{ V("sc_ondestroy", Void_Void) },
{ V("sc_isvalidentity", Bool_Void) },
{ V("sc_shouldfadeondeath", Int_Void) },
{ V("sc_setupfriendly", Void_Void) },
{ V("sc_revivethink", Void_Void) },
{ V("sc_revive", Void_Void) },
{ V("sc_startmonster", Void_Void) },
{ V("sc_checkrangeattack1_move",Int_Float_Float) },
{ V("sc_checkrangeattack2_move",Int_Float_Float) },
{ V("sc_checkmeleeattack1_move",Int_Float_Float) },
{ V("sc_checkmeleeattack2_move",Int_Float_Float) },
{ V("sc_checktankusage", Int_Void) },
{ V("sc_setgaitactivity", Int_Void) },
{ V("sc_ftriangulate", Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool) },
{ V("sc_ftriangulateextension", Int_pVector_pVector_Float_Cbase_pVector) },
{ V("sc_findcovergrenade", Int_Vector_Vector_Float_Float) },
{ V("sc_findcoverdistance", Int_Vector_Vector_Float_Float) },
{ V("sc_findattackpoint", Int_Vector_Vector_Float_Float) },
{ V("sc_fvalidatecover", Int_pVector) },
{ V("sc_nofriendlyfire1", Int_Void) },
{ V("sc_nofriendlyfire2", Int_Vector) },
{ V("sc_nofriendlyfire3", Int_Vector_Cbase) },
{ V("sc_nofriendlyfiretopos", Int_Vector) },
{ V("sc_fvisiblegunpos", Int_Cbase_pVector) },
{ V("sc_finbulletcone", Int_Cbase_pVector) },
{ V("sc_callgibmonster", Void_Void) },
{ V("sc_checktimebaseddamage", Void_Void) },
{ V("sc_ismoving", Int_Void) },
{ V("sc_isplayerfollowing", Int_Void) },
{ V("sc_startplayerfollowing", Void_Cbase) },
{ V("sc_stopplayerfollowing", Void_Int) },
{ V("sc_usesound", Void_Void) },
{ V("sc_unusesound", Void_Void) },
{ V("sc_ridemonster", Void_Cbase) },
{ V("sc_checkandapplygenericattacks", Void_Void) },
{ V("sc_checkscared", Bool_Void) },
{ V("sc_checkcreaturedanger", Void_Void) },
{ V("sc_checkfalldamage", Void_Void) },
{ V("sc_checkrevival", Void_Void) },
{ V("sc_mediccallsound", Void_Void) },
{ V("sc_player_menuinputperformed", Void_Bool) },
{ V("sc_player_ismenuinputdone",Bool_Void) },
{ V("sc_player_specialspawn", Void_Void) },
{ V("sc_player_isvalidinfoentity", Bool_Void) },
{ V("sc_player_levelend", Void_Void) },
{ V("sc_player_votestarted", Void_Int) },
{ V("sc_player_canstartnextvote", Bool_Int) },
{ V("sc_player_vote", Void_Int) },
{ V("sc_player_hasvoted", Bool_Void) },
{ V("sc_player_resetvote", Void_Void) },
{ V("sc_player_lastvoteinput", Int_Void) },
{ V("sc_player_initvote", Void_Void) },
{ V("sc_player_timetostartnextvote", Float_Void) },
{ V("sc_player_resetview", Void_Void) },
{ V("sc_player_getlogfrequency",Float_Void) },
{ V("sc_player_logplayerstats", Bool_Void) },
{ V("sc_player_disablecollisionwithplayer", Void_Cbase_Float) },
{ V("sc_player_enablecollisionwithplayer", Void_Cbase_Bool) },
{ V("sc_player_cantouchplayer", Bool_Cbase) },
{ V("sc_item_materialize", Void_Void) },
{ V("sc_weapon_bulletaccuracy", Vector_Vector_Vector_Vector) },
{ V("sc_weapon_tertiaryattack", Void_Void) },
{ V("sc_weapon_burstsupplement",Void_Void) },
{ V("sc_weapon_getp_model", Str_Str) },
{ V("sc_weapon_getw_model", Str_Str) },
{ V("sc_weapon_getv_model", Str_Str) },
{ V("sc_weapon_precachecustommodels", Void_Void) },
{ V("sc_weapon_ismultiplayer", Int_Void) },
{ V("sc_weapon_frunfuncs", Int_Void) },
{ V("sc_weapon_setfov", Void_Int) },
{ V("sc_weapon_fcanrun", Int_Void) },
{ V("sc_weapon_customdecrement",Void_Float) },
{ V("sc_weapon_setv_model", Void_Str) },
{ V("sc_weapon_setp_model", Void_Str) },
{ V("sc_weapon_changeweaponskin",Void_Short) },
/** New Additions (2013) **/
{ V("tfc_killed",Void_Entvar_Entvar_Int) },
{ V("tfc_istriggered", Int_Void) },
{ V("tfc_weapon_sendweaponanim", Void_Int_Int) },
{ V("tfc_weapon_getnextattackdelay", Float_Float) },
{ V("sc_takehealth",Int_Float_Int_Int) },
{ V("sc_takearmor", Int_Float_Int_Int) },
{ V("sc_giveammo", Int_Int_Str_Int_Int) },
{ V("sc_checkattacker", Int_Cbase) },
{ V("sc_player_isconnected", Int_Void) },
{ V("dod_weapon_sendweaponanim", Void_Int_Int) },
/** New Additions (2011) **/
{ V("changeyaw", Float_Int) },
{ V("hashumangibs", Int_Void) },
{ V("hasaliengibs", Int_Void) },
{ V("fademonster", Void_Void) },
{ V("gibmonster", Void_Void) },
{ V("becomedead", Void_Void) },
{ V("irelationship", Int_Cbase) },
{ V("painsound", Void_Void) },
{ V("reportaistate", Void_Void) },
{ V("monsterinitdead", Void_Void) },
{ V("look", Void_Int) },
{ V("bestvisibleenemy", Cbase_Void) },
{ V("finviewcone", Int_Cbase) },
{ V("fvecinviewcone", Int_pVector) },
{ V("getdeathactivity", Int_Void) },
/* Not supported by Counter-Strike, The Specialists and Natural Selection mods. */
{ V("runai", Void_Void) },
{ V("monsterthink", Void_Void) },
{ V("monsterinit", Void_Void) },
{ V("checklocalmove", Int_pVector_pVector_Cbase_pFloat) },
{ V("move", Void_Float) },
{ V("moveexecute", Void_Cbase_pVector_Float) },
{ V("shouldadvanceroute", Int_Float) },
{ V("getstoppedactivity", Int_Void) },
{ V("stop", Void_Void) },
{ V("checkrangeattack1", Int_Float_Float) },
{ V("checkrangeattack2", Int_Float_Float) },
{ V("checkmeleeattack1", Int_Float_Float) },
{ V("checkmeleeattack2", Int_Float_Float) },
{ V("schedulechange", Void_Void) },
{ V("canplaysequence", Int_Int_Int) },
{ V("canplaysentence", Int_Int) },
{ V("playsentence", Void_Str_Float_Float_Float) },
{ V("playscriptedsentence", Void_Str_Float_Float_Float_Int_Cbase) },
{ V("sentencestop", Void_Void) },
{ V("getidealstate", Int_Void) },
{ V("setactivity", Void_Int) },
{ V("checkenemy", Int_Cbase) },
{ V("ftriangulate", Int_pVector_pVector_Float_Cbase_pVector) },
{ V("setyawspeed", Void_Void) },
{ V("buildnearestroute", Int_Vector_Vector_Float_Float) },
{ V("findcover", Int_Vector_Vector_Float_Float) },
{ V("coverradius", Float_Void) },
{ V("fcancheckattacks", Int_Void) },
{ V("checkammo", Void_Void) },
{ V("ignoreconditions", Int_Void) },
{ V("fvalidatehinttype", Int_Short) },
{ V("fcanactiveidle", Int_Void) },
{ V("isoundmask", Int_Void) },
{ V("hearingsensitivity", Float_Void) },
{ V("barnaclevictimbitten", Void_Entvar) },
{ V("barnaclevictimreleased", Void_Void) },
{ V("preschedulethink", Void_Void) },
{ V("deathsound", Void_Void) },
{ V("alertsound", Void_Void) },
{ V("idlesound", Void_Void) },
{ V("stopfollowing", Void_Int) },
/** Mod specific hooks **/
/* Counter-Strike */
{ V("cstrike_weapon_sendweaponanim",Void_Int_Int) },
{ V("cstrike_player_resetmaxspeed", Void_Void) },
{ V("cstrike_player_isbot", Int_Void) },
{ V("cstrike_player_getautoaimvector", Vector_Float) },
{ V("cstrike_player_blind", Void_Float_Float_Float_Int) },
{ V("cstrike_player_ontouchingweapon",Void_Cbase) },
/* Day of Defeat */
{ V("dod_setscriptreset", Void_Void) },
{ V("dod_item_spawndeploy", Int_Void) },
{ V("dod_item_setdmgtime", Void_Float) },
{ V("dod_item_dropgren", Void_Void) },
{ V("dod_weapon_isuseable", Int_Void) },
{ V("dod_weapon_aim", Vector_Float_Cbase_Int) },
{ V("dod_weapon_flaim", Float_Float_Cbase) },
{ V("dod_weapon_removestamina", Void_Float_Cbase) },
{ V("dod_weapon_changefov", Int_Int) },
{ V("dod_weapon_zoomout", Int_Void) },
{ V("dod_weapon_zoomin", Int_Void) },
{ V("dod_weapon_getfov", Int_Void) },
{ V("dod_weapon_playeriswatersniping", Bool_Void) },
{ V("dod_weapon_updatezoomspeed", Void_Void) },
{ V("dod_weapon_special", Void_Void) },
/* Team Fortress Classic */
{ V("tfc_dbgetitemname", Str_Void) },
{ V("tfc_radiusdamage", Void_Entvar_Entvar_Float_Int_Int) },
{ V("tfc_radiusdamage2", Void_Vector_Entvar_Entvar_Float_Int_Int) },
/* Earth's Special Forces */
{ V("esf_isfighter", Int_Void) },
{ V("esf_isbuddy", Int_Void) },
{ V("esf_emitsound", Void_Str_Int) },
{ V("esf_emitnullsound", Void_Int) },
{ V("esf_increasestrength", Void_Cbase_Int) },
{ V("esf_increasepl", Void_Int) },
{ V("esf_setpowerlevel", Void_Int) },
{ V("esf_setmaxpowerlevel", Void_Int) },
{ V("esf_stopanitrigger", Void_Int) },
{ V("esf_stopfly", Void_Void) },
{ V("esf_hideweapon", Void_Void) },
{ V("esf_clientremoveweapon", Void_Int) },
{ V("esf_sendclientcustommodel",Void_Str) },
{ V("esf_canturbo", Int_Void) },
{ V("esf_canprimaryfire", Int_Void) },
{ V("esf_cansecondaryfire", Int_Void) },
{ V("esf_canstopfly", Int_Void) },
{ V("esf_canblock", Int_Void) },
{ V("esf_canraiseKi", Int_Void) },
{ V("esf_canraisestamina", Int_Void) },
{ V("esf_canteleport", Int_Void) },
{ V("esf_canstartfly", Int_Void) },
{ V("esf_canstartpowerup", Int_Void) },
{ V("esf_canjump", Int_Void) },
{ V("esf_canwalljump", Int_Void) },
{ V("esf_issuperjump", Int_Void) },
{ V("esf_ismoveback", Int_Void) },
{ V("esf_checkwalljump", Int_Void) },
{ V("esf_enablewalljump", Void_Vector) },
{ V("esf_disablewalljump", Void_Void) },
{ V("esf_resetwalljumpvars", Void_Void) },
{ V("esf_getwalljumpanim", Int_Str_Vector_Str) },
{ V("esf_getwalljumpanim2", Int_Str_Str) },
{ V("esf_setwalljumpanimation", Void_Void) },
{ V("esf_setflymovetype", Void_Void) },
{ V("esf_isflymovetype", Int_Void) },
{ V("esf_iswalkmovetype", Int_Void) },
{ V("esf_setwalkmovetype", Void_Void) },
{ V("esf_drawchargebar", Void_Int) },
{ V("esf_startblock", Void_Void) },
{ V("esf_stopblock", Void_Void) },
{ V("esf_startfly", Void_Void) },
{ V("esf_getmaxspeed", Float_Void) },
{ V("esf_setanimation", Void_Int) },
{ V("esf_playanimation", Void_Void) },
{ V("esf_getmoveforward", Int_Void) },
{ V("esf_getmoveright", Int_Void) },
{ V("esf_getmoveup", Void_Void) },
{ V("esf_addblindfx", Void_Void) },
{ V("esf_removeblindfx", Void_Void) },
{ V("esf_disablepsbar", Void_Void) },
{ V("esf_addbeamboxcrosshair", Void_Int) },
{ V("esf_removebeamboxcrosshair", Void_Void) },
{ V("esf_drawpswinbonus", Void_Void) },
{ V("esf_drawpsbar", Void_Float_Float) },
{ V("esf_lockcrosshair", Void_Void) },
{ V("esf_unlockcrosshair", Void_Void) },
{ V("esf_rotatecrosshair", Void_Void) },
{ V("esf_unrotatecrosshair", Void_Void) },
{ V("esf_watermove", Void_Void) },
{ V("esf_checktimebaseddamage", Void_Void) },
{ V("esf_doessecondaryattack", Int_Void) },
{ V("esf_doesprimaryattack", Int_Void) },
{ V("esf_removespecialmodes", Void_Void) },
{ V("esf_stopturbo", Void_Void) },
{ V("esf_takebean", Void_Void) },
{ V("esf_getpowerlevel", Void_Void) },
{ V("esf_removeallotherweapons",Void_Void) },
{ V("esf_stopswoop", Void_Void) },
{ V("esf_setdeathanimation", Void_Void) },
{ V("esf_setmodel", Void_Void) },
{ V("esf_addattacks", Void_Void) },
{ V("esf_emitclasssound", Void_Str_Str_Int) },
{ V("esf_checklightning", Void_Void) },
{ V("esf_freezecontrols", Void_Void) },
{ V("esf_unfreezecontrols", Void_Void) },
{ V("esf_updateki", Void_Void) },
{ V("esf_updatehealth", Void_Void) },
{ V("esf_getteleportdir", Vector_Void) },
{ V("esf_weapon_holsterwhenmeleed", Void_Void) },
/* Natural-Selection */
{ V("ns_setbonecontroller", Float_Int_Float) },
{ V("ns_savedataforreset", Void_Void) },
{ V("ns_gethull", Int_Void) },
{ V("ns_getmaxwalkspeed", Float_Void) },
{ V("ns_setteamid", Str_Str) },
{ V("ns_geteffectiveplayerclass", Int_Void) },
{ V("ns_getauthenticationmask", Int_Void) },
{ V("ns_effectiveplayerclasschanged", Void_Void) },
{ V("ns_needsteamupdate", Void_Void) },
{ V("ns_sendteamupdate", Void_Void) },
{ V("ns_sendweaponupdate", Void_Void) },
{ V("ns_initplayerfromspawn", Void_Edict) },
{ V("ns_packdeadplayeritems", Void_Void) },
{ V("ns_getanimationforactivity",Void_Int_Str_Bool) },
{ V("ns_startobserver", Void_Vector_Vector) },
{ V("ns_stopobserver", Void_Void) },
{ V("ns_getadrenalinefactor", Float_Void) },
{ V("ns_givenameditem", Void_Str_Bool) },
{ V("ns_suicide", Void_Void) },
{ V("ns_getcanuseweapon", Int_Void) },
{ V("ns_weapon_getweaponprimetime", Float_Void) },
{ V("ns_weapon_primeweapon", Void_Void) },
{ V("ns_weapon_getisweaponprimed", Int_Void) },
{ V("ns_weapon_getisweaponpriming", Int_Void) },
{ V("ns_weapon_defaultdeploy", Int_Str_Str_Int_Str_Int_Int) },
{ V("ns_weapon_defaultreload", Int_Int_Int_Float_Int) },
{ V("ns_weapon_getdeploytime", Float_Void) },
/* Sven co-op */
{ V("sc_getclassification", Int_Int) },
{ V("sc_ismonster", Int_Void) },
{ V("sc_isphysx", Int_Void) },
{ V("sc_ispointentity", Int_Void) },
{ V("sc_ismachine", Int_Void) },
{ V("sc_criticalremove", Int_Void) },
{ V("sc_updateonremove", Void_Void) },
{ V("sc_fvisible", Int_Cbase_Bool) },
{ V("sc_fvisiblefrompos", Int_Vector_Vector) },
{ V("sc_isfacing", Int_Entvar_Float) },
{ V("sc_getpointsfordamage", Float_Float) },
{ V("sc_getdamagepoints", Void_Entvar_Entvar_Float) },
{ V("sc_oncreate", Void_Void) },
{ V("sc_ondestroy", Void_Void) },
{ V("sc_isvalidentity", Bool_Void) },
{ V("sc_shouldfadeondeath", Int_Void) },
{ V("sc_setupfriendly", Void_Void) },
{ V("sc_revivethink", Void_Void) },
{ V("sc_revive", Void_Void) },
{ V("sc_startmonster", Void_Void) },
{ V("sc_checkrangeattack1_move",Int_Float_Float) },
{ V("sc_checkrangeattack2_move",Int_Float_Float) },
{ V("sc_checkmeleeattack1_move",Int_Float_Float) },
{ V("sc_checkmeleeattack2_move",Int_Float_Float) },
{ V("sc_checktankusage", Int_Void) },
{ V("sc_setgaitactivity", Int_Void) },
{ V("sc_ftriangulate", Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool) },
{ V("sc_ftriangulateextension", Int_pVector_pVector_Float_Cbase_pVector) },
{ V("sc_findcovergrenade", Int_Vector_Vector_Float_Float) },
{ V("sc_findcoverdistance", Int_Vector_Vector_Float_Float) },
{ V("sc_findattackpoint", Int_Vector_Vector_Float_Float) },
{ V("sc_fvalidatecover", Int_pVector) },
{ V("sc_nofriendlyfire1", Int_Void) },
{ V("sc_nofriendlyfire2", Int_Vector) },
{ V("sc_nofriendlyfire3", Int_Vector_Cbase) },
{ V("sc_nofriendlyfiretopos", Int_Vector) },
{ V("sc_fvisiblegunpos", Int_Cbase_pVector) },
{ V("sc_finbulletcone", Int_Cbase_pVector) },
{ V("sc_callgibmonster", Void_Void) },
{ V("sc_checktimebaseddamage", Void_Void) },
{ V("sc_ismoving", Int_Void) },
{ V("sc_isplayerfollowing", Int_Void) },
{ V("sc_startplayerfollowing", Void_Cbase) },
{ V("sc_stopplayerfollowing", Void_Int) },
{ V("sc_usesound", Void_Void) },
{ V("sc_unusesound", Void_Void) },
{ V("sc_ridemonster", Void_Cbase) },
{ V("sc_checkandapplygenericattacks", Void_Void) },
{ V("sc_checkscared", Bool_Void) },
{ V("sc_checkcreaturedanger", Void_Void) },
{ V("sc_checkfalldamage", Void_Void) },
{ V("sc_checkrevival", Void_Void) },
{ V("sc_mediccallsound", Void_Void) },
{ V("sc_player_menuinputperformed", Void_Bool) },
{ V("sc_player_ismenuinputdone",Bool_Void) },
{ V("sc_player_specialspawn", Void_Void) },
{ V("sc_player_isvalidinfoentity", Bool_Void) },
{ V("sc_player_levelend", Void_Void) },
{ V("sc_player_votestarted", Void_Int) },
{ V("sc_player_canstartnextvote", Bool_Int) },
{ V("sc_player_vote", Void_Int) },
{ V("sc_player_hasvoted", Bool_Void) },
{ V("sc_player_resetvote", Void_Void) },
{ V("sc_player_lastvoteinput", Int_Void) },
{ V("sc_player_initvote", Void_Void) },
{ V("sc_player_timetostartnextvote", Float_Void) },
{ V("sc_player_resetview", Void_Void) },
{ V("sc_player_getlogfrequency",Float_Void) },
{ V("sc_player_logplayerstats", Bool_Void) },
{ V("sc_player_disablecollisionwithplayer", Void_Cbase_Float) },
{ V("sc_player_enablecollisionwithplayer", Void_Cbase_Bool) },
{ V("sc_player_cantouchplayer", Bool_Cbase) },
{ V("sc_item_materialize", Void_Void) },
{ V("sc_weapon_bulletaccuracy", Vector_Vector_Vector_Vector) },
{ V("sc_weapon_tertiaryattack", Void_Void) },
{ V("sc_weapon_burstsupplement",Void_Void) },
{ V("sc_weapon_getp_model", Str_Str) },
{ V("sc_weapon_getw_model", Str_Str) },
{ V("sc_weapon_getv_model", Str_Str) },
{ V("sc_weapon_precachecustommodels", Void_Void) },
{ V("sc_weapon_ismultiplayer", Int_Void) },
{ V("sc_weapon_frunfuncs", Int_Void) },
{ V("sc_weapon_setfov", Void_Int) },
{ V("sc_weapon_fcanrun", Int_Void) },
{ V("sc_weapon_customdecrement",Void_Float) },
{ V("sc_weapon_setv_model", Void_Str) },
{ V("sc_weapon_setp_model", Void_Str) },
{ V("sc_weapon_changeweaponskin",Void_Short) },
/** New Additions (2013) **/
{ V("tfc_killed",Void_Entvar_Entvar_Int) },
{ V("tfc_istriggered", Int_Void) },
{ V("tfc_weapon_sendweaponanim", Void_Int_Int) },
{ V("tfc_weapon_getnextattackdelay", Float_Float) },
{ V("sc_takehealth",Int_Float_Int_Int) },
{ V("sc_takearmor", Int_Float_Int_Int) },
{ V("sc_giveammo", Int_Int_Str_Int_Int) },
{ V("sc_checkattacker", Int_Cbase) },
{ V("sc_player_isconnected", Int_Void) },
{ V("dod_weapon_sendweaponanim", Void_Int_Int) },
{ V("cstrike_item_isweapon", Int_Void) },
{ V("gearbox_mysquadtalkmonsterpointer", Cbase_Void) },
{ V("gearbox_weapontimebase", Float_Void) },
{ V("ts_weapon_alternateattack", Void_Void) },
{ V("item_getiteminfo", Void_ItemInfo) }
{ V("gearbox_mysquadtalkmonsterpointer", Cbase_Void) },
{ V("gearbox_weapontimebase", Float_Void) },
{ V("ts_weapon_alternateattack", Void_Void) },
{ V("item_getiteminfo", Void_ItemInfo) }
};

View File

@ -16,12 +16,12 @@
#include "NEW_Util.h"
#include "ham_utils.h"
inline edict_t* INDEXENT2( int iEdictNum )
{
if (iEdictNum >= 1 && iEdictNum <= gpGlobals->maxClients)
return MF_GetPlayerEdict(iEdictNum);
else
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
inline edict_t* INDEXENT2( int iEdictNum )
{
if (iEdictNum >= 1 && iEdictNum <= gpGlobals->maxClients)
return MF_GetPlayerEdict(iEdictNum);
else
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
}
#ifdef DONT_TOUCH_THIS_AGAIN_BAIL

View File

@ -10,91 +10,91 @@
//
// Natural Selection Module
//
/* This file is a replacement for the engine call of ALLOC_STRING
* The main difference is that a string will not be allocated twice
* as to try to avoid wasting the HL zone space.
*
* NOTE: The lookup uses strcmp() in a linked list! It is not fast
* Its implementation in the NS module is on rarely used
* natives.
*/
#ifndef ALLOCSTRING_H
#define ALLOCSTRING_H
#include <am-string.h>
#include <am-linkedlist.h>
class StringManager
{
private:
ke::LinkedList<ke::AString *> m_StringList;
public:
/**
* sh_list.h does not delete objects put into
* the list, so I need to delete those and clear()
*/
inline void Clear(void)
{
ke::LinkedList<ke::AString *>::iterator end;
ke::LinkedList<ke::AString *>::iterator iter;
iter=m_StringList.begin();
end=m_StringList.end();
while (iter!=end)
{
delete (*iter++);
}
m_StringList.clear();
}
/**
* Iterate the list to see if the string exists
* This is slow and not very ideal, however
* this is *very* rarely used so it won't matter
*/
inline int Allocate(const char *str)
{
ke::LinkedList<ke::AString *>::iterator end;
ke::LinkedList<ke::AString *>::iterator iter;
iter=m_StringList.begin();
end=m_StringList.end();
while (iter!=end)
{
if (strcmp(str, (*iter)->chars()) == 0)
{
// String is already in the list, do not allocate it again
return MAKE_STRING((*iter)->chars());
}
++iter;
}
// Was not found in the linked list, allocate it and add it to the list
ke::AString *AllocStr = new ke::AString(str);
m_StringList.append(AllocStr);
return MAKE_STRING(AllocStr->chars());
};
};
extern StringManager AllocStringList;
/**
* Simple wrapper to make conversion easier
*/
inline int ALLOC_STRING2(const char *InputString)
{
return AllocStringList.Allocate(InputString);
}
#endif // ALLOCSTRING_H
/* This file is a replacement for the engine call of ALLOC_STRING
* The main difference is that a string will not be allocated twice
* as to try to avoid wasting the HL zone space.
*
* NOTE: The lookup uses strcmp() in a linked list! It is not fast
* Its implementation in the NS module is on rarely used
* natives.
*/
#ifndef ALLOCSTRING_H
#define ALLOCSTRING_H
#include <am-string.h>
#include <am-linkedlist.h>
class StringManager
{
private:
ke::LinkedList<ke::AString *> m_StringList;
public:
/**
* sh_list.h does not delete objects put into
* the list, so I need to delete those and clear()
*/
inline void Clear(void)
{
ke::LinkedList<ke::AString *>::iterator end;
ke::LinkedList<ke::AString *>::iterator iter;
iter=m_StringList.begin();
end=m_StringList.end();
while (iter!=end)
{
delete (*iter++);
}
m_StringList.clear();
}
/**
* Iterate the list to see if the string exists
* This is slow and not very ideal, however
* this is *very* rarely used so it won't matter
*/
inline int Allocate(const char *str)
{
ke::LinkedList<ke::AString *>::iterator end;
ke::LinkedList<ke::AString *>::iterator iter;
iter=m_StringList.begin();
end=m_StringList.end();
while (iter!=end)
{
if (strcmp(str, (*iter)->chars()) == 0)
{
// String is already in the list, do not allocate it again
return MAKE_STRING((*iter)->chars());
}
++iter;
}
// Was not found in the linked list, allocate it and add it to the list
ke::AString *AllocStr = new ke::AString(str);
m_StringList.append(AllocStr);
return MAKE_STRING(AllocStr->chars());
};
};
extern StringManager AllocStringList;
/**
* Simple wrapper to make conversion easier
*/
inline int ALLOC_STRING2(const char *InputString)
{
return AllocStringList.Allocate(InputString);
}
#endif // ALLOCSTRING_H

View File

@ -10,88 +10,88 @@
//
// Natural Selection Module
//
/* This holds the functions which determine which hooks I need forwareded */
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "CPlayer.h"
void GameManager::HookPreThink(void)
{
// Only need to hook prethink if at least 1 plugins has any of these forwards:
// client_spawn, client_changeteam, client_changeclass
if (UTIL_CheckForPublic("client_spawn") ||
UTIL_CheckForPublic("client_changeteam") ||
UTIL_CheckForPublic("client_changeclass"))
{
g_pFunctionTable->pfnPlayerPreThink=PlayerPreThink;
return;
}
g_pFunctionTable->pfnPlayerPreThink=NULL;
};
void GameManager::HookPostThink_Post(void)
{
int i=0;
while (i++<gpGlobals->maxClients)
{
if (GET_PLAYER_I(i)->NeedPostThink_Post())
{
g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post;
return;
}
}
g_pFunctionTable_Post->pfnPlayerPostThink=NULL;
};
void GameManager::HookPreThink_Post(void)
{
int i=1;
while (i<gpGlobals->maxClients)
{
if (GET_PLAYER_I(i++)->NeedPreThink_Post())
{
g_pFunctionTable_Post->pfnPlayerPreThink=PlayerPreThink_Post;
return;
}
}
g_pFunctionTable_Post->pfnPlayerPreThink=NULL;
};
void GameManager::HookUpdateClientData(void)
{
int i=1;
while (i<gpGlobals->maxClients)
{
if (GET_PLAYER_I(i++)->NeedUpdateClientData())
{
g_pFunctionTable->pfnUpdateClientData=UpdateClientData;
return;
}
}
g_pFunctionTable->pfnUpdateClientData=NULL;
};
void GameManager::HookLogs()
{
// These forwards only are needed in classic NS
if (!IsCombat() && UTIL_CheckForPublic("client_built"))
{
// Only hook if this public exists (wasteful otherwise)
m_BuiltForward = MF_RegisterForward("client_built", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
g_pengfuncsTable_Post->pfnAlertMessage=AlertMessage_Post;
g_pengfuncsTable_Post->pfnCreateNamedEntity=CreateNamedEntity_Post;
}
else
{
// no need for these hooks in co
g_pengfuncsTable_Post->pfnAlertMessage=NULL;
g_pengfuncsTable_Post->pfnCreateNamedEntity=NULL;
}
};
/* This holds the functions which determine which hooks I need forwareded */
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "CPlayer.h"
void GameManager::HookPreThink(void)
{
// Only need to hook prethink if at least 1 plugins has any of these forwards:
// client_spawn, client_changeteam, client_changeclass
if (UTIL_CheckForPublic("client_spawn") ||
UTIL_CheckForPublic("client_changeteam") ||
UTIL_CheckForPublic("client_changeclass"))
{
g_pFunctionTable->pfnPlayerPreThink=PlayerPreThink;
return;
}
g_pFunctionTable->pfnPlayerPreThink=NULL;
};
void GameManager::HookPostThink_Post(void)
{
int i=0;
while (i++<gpGlobals->maxClients)
{
if (GET_PLAYER_I(i)->NeedPostThink_Post())
{
g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post;
return;
}
}
g_pFunctionTable_Post->pfnPlayerPostThink=NULL;
};
void GameManager::HookPreThink_Post(void)
{
int i=1;
while (i<gpGlobals->maxClients)
{
if (GET_PLAYER_I(i++)->NeedPreThink_Post())
{
g_pFunctionTable_Post->pfnPlayerPreThink=PlayerPreThink_Post;
return;
}
}
g_pFunctionTable_Post->pfnPlayerPreThink=NULL;
};
void GameManager::HookUpdateClientData(void)
{
int i=1;
while (i<gpGlobals->maxClients)
{
if (GET_PLAYER_I(i++)->NeedUpdateClientData())
{
g_pFunctionTable->pfnUpdateClientData=UpdateClientData;
return;
}
}
g_pFunctionTable->pfnUpdateClientData=NULL;
};
void GameManager::HookLogs()
{
// These forwards only are needed in classic NS
if (!IsCombat() && UTIL_CheckForPublic("client_built"))
{
// Only hook if this public exists (wasteful otherwise)
m_BuiltForward = MF_RegisterForward("client_built", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
g_pengfuncsTable_Post->pfnAlertMessage=AlertMessage_Post;
g_pengfuncsTable_Post->pfnCreateNamedEntity=CreateNamedEntity_Post;
}
else
{
// no need for these hooks in co
g_pengfuncsTable_Post->pfnAlertMessage=NULL;
g_pengfuncsTable_Post->pfnCreateNamedEntity=NULL;
}
};

View File

@ -10,287 +10,287 @@
//
// Natural Selection Module
//
/* This file includes game-related stuff, such as message IDs
* and forwards
*/
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H
#include <am-string.h>
class GameManager
{
private:
// Basic game variables
int m_IsCombat;
int m_HudText2; // Message IDS
int m_SetFOV;
// Forwards
int m_ChangeclassForward;
int m_BuiltForward;
int m_SpawnForward;
int m_TeamForward;
int m_RoundStartForward;
int m_RoundEndForward;
int m_MapResetForward;
REAL m_fRoundStartTime; // Time the match should start
int m_RoundInProgress; // Whether or not there is a match in progress
edict_t *m_SavedEdict; // saved edict for client_built
int m_iTitlesMap;
bool m_SendMapReset;
public:
GameManager()
{
m_SendMapReset = true;
m_IsCombat=0;
m_HudText2=0;
m_SetFOV=0;
m_SavedEdict=NULL;
m_RoundInProgress=0;
ResetForwards();
};
inline void CheckMap(void)
{
ke::AString MapName;
MapName = UTIL_ToLowerCase(STRING(gpGlobals->mapname));
m_iTitlesMap=0;
if (MapName.compare("ns_bast")==0 ||
MapName.compare("ns_bast_classic") == 0 ||
MapName.compare("ns_hera") == 0 ||
MapName.compare("ns_nothing") == 0 ||
MapName.compare("ns_caged") == 0 ||
MapName.compare("ns_tanith") == 0 ||
MapName.compare("ns_eclipse") == 0 ||
MapName.compare("ns_veil") == 0 ||
MapName.compare("ns_nancy") == 0)
{
m_iTitlesMap=1;
}
};
inline int &TitleMap(void)
{
return m_iTitlesMap;
};
inline void SetCombat(int value)
{
m_IsCombat=value;
};
inline int &IsCombat(void)
{
return m_IsCombat;
};
inline void UpdateHudText2(void)
{
if (!m_HudText2)
{
GetMessageIDs();
}
};
inline void UpdateSetFOV(void)
{
if (!m_SetFOV)
{
GetMessageIDs();
}
};
inline int &GetHudText2(void)
{
return m_HudText2;
};
inline int &GetSetFOV(void)
{
return m_SetFOV;
};
inline void GetMessageIDs(void)
{
m_HudText2=GET_USER_MSG_ID(&Plugin_info,"HudText2",NULL);
m_SetFOV=GET_USER_MSG_ID(&Plugin_info,"SetFOV",NULL);
};
inline void EvaluateCombat(void)
{
const char *Map=STRING(gpGlobals->mapname);
// if map starts with co_ it is combat
// otherwise it is classic gameplay
if ((Map[0]=='c' || Map[0]=='C') &&
(Map[1]=='o' || Map[1]=='O') &&
(Map[2]=='_'))
{
SetCombat(1);
return;
}
SetCombat(0);
};
inline void ResetForwards(void)
{
m_ChangeclassForward=-1;
m_BuiltForward=-1;
m_SpawnForward=-1;
m_TeamForward=-1;
m_RoundStartForward=-1;
m_RoundEndForward=-1;
m_MapResetForward=-1;
};
inline void RegisterForwards(void)
{
ResetForwards();
m_SpawnForward = MF_RegisterForward("client_spawn",ET_IGNORE,FP_CELL/*id*/,FP_DONE);
m_TeamForward = MF_RegisterForward("client_changeteam",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*new team*/,FP_CELL/*old team*/,FP_DONE);
m_ChangeclassForward = MF_RegisterForward("client_changeclass", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
m_RoundStartForward = MF_RegisterForward("round_start", ET_IGNORE, FP_DONE);
m_RoundEndForward = MF_RegisterForward("round_end", ET_IGNORE, FP_FLOAT, FP_DONE);
m_MapResetForward = MF_RegisterForward("map_reset", ET_IGNORE, FP_CELL, FP_DONE);
};
inline void StartFrame(void)
{
if (gpGlobals->time >= m_fRoundStartTime)
{
g_pFunctionTable->pfnStartFrame=NULL;
RoundStart();
}
};
/**
* This is called from MessageHandler's Countdown
* hook. It passes the only byte sent (time)
*/
inline void HandleCountdown(int &Time)
{
// Begin hooking start frame
g_pFunctionTable->pfnStartFrame=::StartFrame;
// set time of round start
m_fRoundStartTime=gpGlobals->time + Time;
m_SendMapReset = true;
};
/**
* This is called from MessageHandler's GameStatus
* hook. It passes the first byte sent.
* 2 = Round End
*/
inline void HandleGameStatus(int &FirstByte)
{
switch (FirstByte)
{
case 0:
if (m_SendMapReset)
{
MF_ExecuteForward(m_MapResetForward, 0);
}
m_SendMapReset = false;
break;
case 1:
MF_ExecuteForward(m_MapResetForward, 1);
break;
case 2:
RoundEnd();
break;
}
};
inline void RoundStart()
{
m_RoundInProgress=1;
MF_ExecuteForward(m_RoundStartForward);
};
inline void RoundEnd()
{
m_RoundInProgress=0;
MF_ExecuteForward(m_RoundEndForward,gpGlobals->time - m_fRoundStartTime);
};
inline int &RoundInProgress()
{
return m_RoundInProgress;
};
// no need to check -1 forwards in these
// amxmodx checks it anyway
inline void ExecuteClientBuilt(int &PlayerID, int StructureID, int &StructureType, int &Impulse)
{
MF_ExecuteForward(m_BuiltForward,PlayerID, StructureID, StructureType, Impulse);
};
inline void ExecuteClientSpawn(int &PlayerID)
{
MF_ExecuteForward(m_SpawnForward,PlayerID);
};
inline void ExecuteClientChangeTeam(int &PlayerID, int &NewTeam, int &OldTeam)
{
MF_ExecuteForward(m_TeamForward, PlayerID, NewTeam, OldTeam);
};
inline void ExecuteClientChangeClass(int &PlayerID, int &NewClass, int &OldClass)
{
MF_ExecuteForward(m_ChangeclassForward,PlayerID,NewClass,OldClass);
};
inline void ExecuteRoundStart(void)
{
MF_ExecuteForward(m_RoundStartForward);
};
inline void ExecuteRoundEnd(void)
{
MF_ExecuteForward(m_RoundEndForward);
};
/**
* The next few functions tell the module what metamod hooks
* i need. This tries to run-time optimize out what we
* do not need.
*/
void HookPreThink(void);
void HookPostThink_Post(void);
void HookPreThink_Post(void);
void HookUpdateClientData(void);
void HookLogs(void); // AlertMessage AND CreateNamedEntity
inline void CheckAllHooks(void)
{
HookPreThink();
HookPostThink_Post();
HookPreThink_Post();
HookUpdateClientData();
HookLogs();
};
inline void SetTemporaryEdict(edict_t *Edict)
{
m_SavedEdict=Edict;
};
inline edict_t *GetTemporaryEdict(void)
{
return m_SavedEdict;
};
};
extern GameManager GameMan;
#endif // GAMEMANAGER_H
/* This file includes game-related stuff, such as message IDs
* and forwards
*/
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H
#include <am-string.h>
class GameManager
{
private:
// Basic game variables
int m_IsCombat;
int m_HudText2; // Message IDS
int m_SetFOV;
// Forwards
int m_ChangeclassForward;
int m_BuiltForward;
int m_SpawnForward;
int m_TeamForward;
int m_RoundStartForward;
int m_RoundEndForward;
int m_MapResetForward;
REAL m_fRoundStartTime; // Time the match should start
int m_RoundInProgress; // Whether or not there is a match in progress
edict_t *m_SavedEdict; // saved edict for client_built
int m_iTitlesMap;
bool m_SendMapReset;
public:
GameManager()
{
m_SendMapReset = true;
m_IsCombat=0;
m_HudText2=0;
m_SetFOV=0;
m_SavedEdict=NULL;
m_RoundInProgress=0;
ResetForwards();
};
inline void CheckMap(void)
{
ke::AString MapName;
MapName = UTIL_ToLowerCase(STRING(gpGlobals->mapname));
m_iTitlesMap=0;
if (MapName.compare("ns_bast")==0 ||
MapName.compare("ns_bast_classic") == 0 ||
MapName.compare("ns_hera") == 0 ||
MapName.compare("ns_nothing") == 0 ||
MapName.compare("ns_caged") == 0 ||
MapName.compare("ns_tanith") == 0 ||
MapName.compare("ns_eclipse") == 0 ||
MapName.compare("ns_veil") == 0 ||
MapName.compare("ns_nancy") == 0)
{
m_iTitlesMap=1;
}
};
inline int &TitleMap(void)
{
return m_iTitlesMap;
};
inline void SetCombat(int value)
{
m_IsCombat=value;
};
inline int &IsCombat(void)
{
return m_IsCombat;
};
inline void UpdateHudText2(void)
{
if (!m_HudText2)
{
GetMessageIDs();
}
};
inline void UpdateSetFOV(void)
{
if (!m_SetFOV)
{
GetMessageIDs();
}
};
inline int &GetHudText2(void)
{
return m_HudText2;
};
inline int &GetSetFOV(void)
{
return m_SetFOV;
};
inline void GetMessageIDs(void)
{
m_HudText2=GET_USER_MSG_ID(&Plugin_info,"HudText2",NULL);
m_SetFOV=GET_USER_MSG_ID(&Plugin_info,"SetFOV",NULL);
};
inline void EvaluateCombat(void)
{
const char *Map=STRING(gpGlobals->mapname);
// if map starts with co_ it is combat
// otherwise it is classic gameplay
if ((Map[0]=='c' || Map[0]=='C') &&
(Map[1]=='o' || Map[1]=='O') &&
(Map[2]=='_'))
{
SetCombat(1);
return;
}
SetCombat(0);
};
inline void ResetForwards(void)
{
m_ChangeclassForward=-1;
m_BuiltForward=-1;
m_SpawnForward=-1;
m_TeamForward=-1;
m_RoundStartForward=-1;
m_RoundEndForward=-1;
m_MapResetForward=-1;
};
inline void RegisterForwards(void)
{
ResetForwards();
m_SpawnForward = MF_RegisterForward("client_spawn",ET_IGNORE,FP_CELL/*id*/,FP_DONE);
m_TeamForward = MF_RegisterForward("client_changeteam",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*new team*/,FP_CELL/*old team*/,FP_DONE);
m_ChangeclassForward = MF_RegisterForward("client_changeclass", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
m_RoundStartForward = MF_RegisterForward("round_start", ET_IGNORE, FP_DONE);
m_RoundEndForward = MF_RegisterForward("round_end", ET_IGNORE, FP_FLOAT, FP_DONE);
m_MapResetForward = MF_RegisterForward("map_reset", ET_IGNORE, FP_CELL, FP_DONE);
};
inline void StartFrame(void)
{
if (gpGlobals->time >= m_fRoundStartTime)
{
g_pFunctionTable->pfnStartFrame=NULL;
RoundStart();
}
};
/**
* This is called from MessageHandler's Countdown
* hook. It passes the only byte sent (time)
*/
inline void HandleCountdown(int &Time)
{
// Begin hooking start frame
g_pFunctionTable->pfnStartFrame=::StartFrame;
// set time of round start
m_fRoundStartTime=gpGlobals->time + Time;
m_SendMapReset = true;
};
/**
* This is called from MessageHandler's GameStatus
* hook. It passes the first byte sent.
* 2 = Round End
*/
inline void HandleGameStatus(int &FirstByte)
{
switch (FirstByte)
{
case 0:
if (m_SendMapReset)
{
MF_ExecuteForward(m_MapResetForward, 0);
}
m_SendMapReset = false;
break;
case 1:
MF_ExecuteForward(m_MapResetForward, 1);
break;
case 2:
RoundEnd();
break;
}
};
inline void RoundStart()
{
m_RoundInProgress=1;
MF_ExecuteForward(m_RoundStartForward);
};
inline void RoundEnd()
{
m_RoundInProgress=0;
MF_ExecuteForward(m_RoundEndForward,gpGlobals->time - m_fRoundStartTime);
};
inline int &RoundInProgress()
{
return m_RoundInProgress;
};
// no need to check -1 forwards in these
// amxmodx checks it anyway
inline void ExecuteClientBuilt(int &PlayerID, int StructureID, int &StructureType, int &Impulse)
{
MF_ExecuteForward(m_BuiltForward,PlayerID, StructureID, StructureType, Impulse);
};
inline void ExecuteClientSpawn(int &PlayerID)
{
MF_ExecuteForward(m_SpawnForward,PlayerID);
};
inline void ExecuteClientChangeTeam(int &PlayerID, int &NewTeam, int &OldTeam)
{
MF_ExecuteForward(m_TeamForward, PlayerID, NewTeam, OldTeam);
};
inline void ExecuteClientChangeClass(int &PlayerID, int &NewClass, int &OldClass)
{
MF_ExecuteForward(m_ChangeclassForward,PlayerID,NewClass,OldClass);
};
inline void ExecuteRoundStart(void)
{
MF_ExecuteForward(m_RoundStartForward);
};
inline void ExecuteRoundEnd(void)
{
MF_ExecuteForward(m_RoundEndForward);
};
/**
* The next few functions tell the module what metamod hooks
* i need. This tries to run-time optimize out what we
* do not need.
*/
void HookPreThink(void);
void HookPostThink_Post(void);
void HookPreThink_Post(void);
void HookUpdateClientData(void);
void HookLogs(void); // AlertMessage AND CreateNamedEntity
inline void CheckAllHooks(void)
{
HookPreThink();
HookPostThink_Post();
HookPreThink_Post();
HookUpdateClientData();
HookLogs();
};
inline void SetTemporaryEdict(edict_t *Edict)
{
m_SavedEdict=Edict;
};
inline edict_t *GetTemporaryEdict(void)
{
return m_SavedEdict;
};
};
extern GameManager GameMan;
#endif // GAMEMANAGER_H

View File

@ -11,168 +11,168 @@
// Natural Selection Module
//
#ifndef _HASH_H_
#define _HASH_H_
#include <am-vector.h>
#include <am-string.h>
// Just a very simple hash map, no iteration or anything of the like (not needed)
inline int HashFunction(const ke::AString& name)
{
static const int kHashNumTable[128] =
{
0x1148FC3E, 0x0577C975, 0x3BED3AED, 0x62FBBD5F, 0x07DE2DA0, 0x6555C5E5, 0x24DB841A, 0x2AF3F568,
0x01EA1B65, 0x46F7D976, 0x18172B99, 0x394B2A58, 0x1ED39AA8, 0x1214E706, 0x5DD47295, 0x53574932,
0x2CE25D5C, 0x7A2E5BB4, 0x0F2F0153, 0x33888669, 0x729AC55F, 0x2A7BCA9E, 0x36C60816, 0x40F9A7E3,
0x2A37DF30, 0x3D81BB17, 0x6450B311, 0x75FA2DC9, 0x2A2678A5, 0x4C5E3675, 0x743F4486, 0x3B6F74E3,
0x51D5FFEA, 0x302C7F74, 0x1E6B3243, 0x59B42D8A, 0x15824559, 0x4346B65D, 0x04A822F2, 0x176C60BF,
0x0A3E8FD3, 0x1CBF4E8B, 0x50B78B17, 0x29122A7B, 0x2ED43591, 0x2E8BFDAC, 0x7C6973AE, 0x5BB692EE,
0x28BA5960, 0x0B987501, 0x0F3F1957, 0x1B551EBF, 0x36143F9F, 0x4605216D, 0x5C4EC6A2, 0x604C1ECF,
0x0386DC84, 0x409F79B4, 0x56464C99, 0x2DAD5529, 0x0CFDB029, 0x4A85911F, 0x691CCA0D, 0x5ED3B013,
0x7AB21093, 0x0787FC50, 0x3887DD9D, 0x103455ED, 0x4ACEB2AD, 0x3D30008F, 0x27A0B6AC, 0x550D4280,
0x59EF4F1B, 0x785841C3, 0x7E1F6CFC, 0x08C384AC, 0x26E43F70, 0x7A88E0AA, 0x647A179A, 0x4F9E98D0,
0x062155AB, 0x73B930F1, 0x6AF3B790, 0x3C35954B, 0x39BE525E, 0x47427E32, 0x1C81B41A, 0x3D452EE2,
0x07E1F7E6, 0x72C800B3, 0x6AF2840C, 0x14DFA80F, 0x3D4D91D3, 0x540F4E19, 0x73B35822, 0x37FFA266,
0x5B974A69, 0x2C3B35BF, 0x4833F853, 0x2665FD16, 0x696B364F, 0x6FD4AEFF, 0x7B733F96, 0x435A856A,
0x682CF0C3, 0x7992AC92, 0x4C1E0A16, 0x0F113033, 0x741B8D3C, 0x309821B1, 0x5EAFC903, 0x7A3CE2E8,
0x245152A2, 0x49A38093, 0x36727833, 0x5E0FA501, 0x10E5FEC6, 0x52F42C4D, 0x1B54D3E3, 0x18C7F6AC,
0x45BC2D01, 0x064757EF, 0x2DA79EBC, 0x0309BED4, 0x5A56A608, 0x215AF6DE, 0x3B09613A, 0x35EDF071
};
size_t size = name.length();
if (size == 0)
{
return 0;
}
int hasha = kHashNumTable[(*(name.chars() + (size - 1))) & 0x7F];
int hashb = kHashNumTable[size % 128];
unsigned char c = 0;
for (size_t i = 0; i < size; i++)
{
c = (*(name.chars() + (size - 1))) & 0x7F;
hasha = (hasha + hashb) ^ kHashNumTable[c];
hashb = hasha + hashb + c + (hasha << 8) + (hashb & 0xFF);
}
return hasha;
}
/**
* @param K Key type.
* @param D Data type.
* @param F Hash function.
* @param B Bucket count.
*/
template <typename K = ke::AString, typename D = ke::AString, int (*F)(const K&) = HashFunction, int B = 1024>
class Hash
{
protected:
ke::Vector<int> m_HashBuckets[B];
ke::Vector<K> m_KeyBuckets[B];
ke::Vector<D> m_DataBuckets[B];
inline int GetBucket(int hash)
{
return (*reinterpret_cast<unsigned int*>(&hash)) % B;
};
public:
// prints bucket distribution
inline void printbuckets() const
{
for (int i = 0; i < B; i++)
{
if (i % 32 == 0 && i != 0)
{
printf("\n");
}
printf("%d ", m_HashBuckets[i].size());
}
printf("\n");
}
inline void insert(const K& key, const D& value)
{
D* ptr;
if ((ptr = this->find(key)) != NULL)
{
*ptr = value;
return;
}
int hash = F(key);
int bucketnum = GetBucket(hash);
m_HashBuckets[bucketnum].append(hash);
m_KeyBuckets[bucketnum].append(key);
m_DataBuckets[bucketnum].append(value);
return;
}
inline D& lookup_or_add(const K& key)
{
D* ptr;
if ((ptr = this->find(key)) != NULL)
{
return *ptr;
}
int hash = F(key);
int bucketnum = GetBucket(hash);
m_HashBuckets[bucketnum].append(hash);
m_KeyBuckets[bucketnum].append(key);
m_DataBuckets[bucketnum].append(D());
return m_DataBuckets[bucketnum].at(m_DataBuckets[bucketnum].size() - 1);
}
inline bool exists(const K& key)
{
return this->find(key) != NULL;
}
inline D* find(const K& key)
{
int hash = F(key);
int bucketnum = GetBucket(hash);
// TODO: Possibly make this binary search?
// insertion would be annoying, don't think it is worth it
ke::Vector<int>* hashbucket = &m_HashBuckets[bucketnum];
ke::Vector<K>* keybucket = &m_KeyBuckets[bucketnum];
size_t bucketsize = hashbucket->length();
for (size_t i = 0; i < bucketsize; i++)
{
if (hashbucket->at(i) == hash)
{
if (key.compare(keybucket->at(i).chars()) == 0)
{
return &(m_DataBuckets[bucketnum].at(i));
}
}
}
return NULL;
};
};
#endif
#ifndef _HASH_H_
#define _HASH_H_
#include <am-vector.h>
#include <am-string.h>
// Just a very simple hash map, no iteration or anything of the like (not needed)
inline int HashFunction(const ke::AString& name)
{
static const int kHashNumTable[128] =
{
0x1148FC3E, 0x0577C975, 0x3BED3AED, 0x62FBBD5F, 0x07DE2DA0, 0x6555C5E5, 0x24DB841A, 0x2AF3F568,
0x01EA1B65, 0x46F7D976, 0x18172B99, 0x394B2A58, 0x1ED39AA8, 0x1214E706, 0x5DD47295, 0x53574932,
0x2CE25D5C, 0x7A2E5BB4, 0x0F2F0153, 0x33888669, 0x729AC55F, 0x2A7BCA9E, 0x36C60816, 0x40F9A7E3,
0x2A37DF30, 0x3D81BB17, 0x6450B311, 0x75FA2DC9, 0x2A2678A5, 0x4C5E3675, 0x743F4486, 0x3B6F74E3,
0x51D5FFEA, 0x302C7F74, 0x1E6B3243, 0x59B42D8A, 0x15824559, 0x4346B65D, 0x04A822F2, 0x176C60BF,
0x0A3E8FD3, 0x1CBF4E8B, 0x50B78B17, 0x29122A7B, 0x2ED43591, 0x2E8BFDAC, 0x7C6973AE, 0x5BB692EE,
0x28BA5960, 0x0B987501, 0x0F3F1957, 0x1B551EBF, 0x36143F9F, 0x4605216D, 0x5C4EC6A2, 0x604C1ECF,
0x0386DC84, 0x409F79B4, 0x56464C99, 0x2DAD5529, 0x0CFDB029, 0x4A85911F, 0x691CCA0D, 0x5ED3B013,
0x7AB21093, 0x0787FC50, 0x3887DD9D, 0x103455ED, 0x4ACEB2AD, 0x3D30008F, 0x27A0B6AC, 0x550D4280,
0x59EF4F1B, 0x785841C3, 0x7E1F6CFC, 0x08C384AC, 0x26E43F70, 0x7A88E0AA, 0x647A179A, 0x4F9E98D0,
0x062155AB, 0x73B930F1, 0x6AF3B790, 0x3C35954B, 0x39BE525E, 0x47427E32, 0x1C81B41A, 0x3D452EE2,
0x07E1F7E6, 0x72C800B3, 0x6AF2840C, 0x14DFA80F, 0x3D4D91D3, 0x540F4E19, 0x73B35822, 0x37FFA266,
0x5B974A69, 0x2C3B35BF, 0x4833F853, 0x2665FD16, 0x696B364F, 0x6FD4AEFF, 0x7B733F96, 0x435A856A,
0x682CF0C3, 0x7992AC92, 0x4C1E0A16, 0x0F113033, 0x741B8D3C, 0x309821B1, 0x5EAFC903, 0x7A3CE2E8,
0x245152A2, 0x49A38093, 0x36727833, 0x5E0FA501, 0x10E5FEC6, 0x52F42C4D, 0x1B54D3E3, 0x18C7F6AC,
0x45BC2D01, 0x064757EF, 0x2DA79EBC, 0x0309BED4, 0x5A56A608, 0x215AF6DE, 0x3B09613A, 0x35EDF071
};
size_t size = name.length();
if (size == 0)
{
return 0;
}
int hasha = kHashNumTable[(*(name.chars() + (size - 1))) & 0x7F];
int hashb = kHashNumTable[size % 128];
unsigned char c = 0;
for (size_t i = 0; i < size; i++)
{
c = (*(name.chars() + (size - 1))) & 0x7F;
hasha = (hasha + hashb) ^ kHashNumTable[c];
hashb = hasha + hashb + c + (hasha << 8) + (hashb & 0xFF);
}
return hasha;
}
/**
* @param K Key type.
* @param D Data type.
* @param F Hash function.
* @param B Bucket count.
*/
template <typename K = ke::AString, typename D = ke::AString, int (*F)(const K&) = HashFunction, int B = 1024>
class Hash
{
protected:
ke::Vector<int> m_HashBuckets[B];
ke::Vector<K> m_KeyBuckets[B];
ke::Vector<D> m_DataBuckets[B];
inline int GetBucket(int hash)
{
return (*reinterpret_cast<unsigned int*>(&hash)) % B;
};
public:
// prints bucket distribution
inline void printbuckets() const
{
for (int i = 0; i < B; i++)
{
if (i % 32 == 0 && i != 0)
{
printf("\n");
}
printf("%d ", m_HashBuckets[i].size());
}
printf("\n");
}
inline void insert(const K& key, const D& value)
{
D* ptr;
if ((ptr = this->find(key)) != NULL)
{
*ptr = value;
return;
}
int hash = F(key);
int bucketnum = GetBucket(hash);
m_HashBuckets[bucketnum].append(hash);
m_KeyBuckets[bucketnum].append(key);
m_DataBuckets[bucketnum].append(value);
return;
}
inline D& lookup_or_add(const K& key)
{
D* ptr;
if ((ptr = this->find(key)) != NULL)
{
return *ptr;
}
int hash = F(key);
int bucketnum = GetBucket(hash);
m_HashBuckets[bucketnum].append(hash);
m_KeyBuckets[bucketnum].append(key);
m_DataBuckets[bucketnum].append(D());
return m_DataBuckets[bucketnum].at(m_DataBuckets[bucketnum].size() - 1);
}
inline bool exists(const K& key)
{
return this->find(key) != NULL;
}
inline D* find(const K& key)
{
int hash = F(key);
int bucketnum = GetBucket(hash);
// TODO: Possibly make this binary search?
// insertion would be annoying, don't think it is worth it
ke::Vector<int>* hashbucket = &m_HashBuckets[bucketnum];
ke::Vector<K>* keybucket = &m_KeyBuckets[bucketnum];
size_t bucketsize = hashbucket->length();
for (size_t i = 0; i < bucketsize; i++)
{
if (hashbucket->at(i) == hash)
{
if (key.compare(keybucket->at(i).chars()) == 0)
{
return &(m_DataBuckets[bucketnum].at(i));
}
}
}
return NULL;
};
};
#endif

View File

@ -10,89 +10,89 @@
//
// Natural Selection Module
//
#ifndef LOCATIONMANAGER_H
#define LOCATIONMANAGER_H
#include <am-vector.h>
#include "GameManager.h"
#include "TitleManager.h"
typedef struct location_data_s
{
char name[128];
vec3_t mins;
vec3_t maxs;
const char *titlelookup;
} location_data_t;
class LocationManager
{
private:
ke::Vector<location_data_t> m_LocationList;
public:
LocationManager()
{
Clear();
};
inline void Clear(void)
{
m_LocationList.clear();
m_LocationList.ensure(32);
};
inline void Add(const char *Name, edict_t *Entity)
{
location_data_t Temp;
Temp.mins=Entity->v.mins;
Temp.maxs=Entity->v.maxs;
strncpy(Temp.name,Name,sizeof(Temp.name)-1);
ke::AString NameString(UTIL_ToLowerCase(Name));
Temp.titlelookup=TitleMan.Lookup(NameString);
m_LocationList.append(Temp);
};
inline const char *Lookup(vec3_t origin, cell titlelookup)
{
unsigned int i=0;
location_data_t Temp;
while (i<m_LocationList.length())
{
Temp=m_LocationList[i++];
if (origin.x <= Temp.maxs.x &&
origin.y <= Temp.maxs.y &&
origin.x >= Temp.mins.x &&
origin.y >= Temp.mins.y)
{
if (titlelookup==0)
{
return &(m_LocationList[i-1].name[0]);
}
else
{
if (m_LocationList[i-1].titlelookup!=NULL)
{
return m_LocationList[i-1].titlelookup;
}
return &(m_LocationList[i-1].name[0]);
}
}
}
return "";
};
};
extern LocationManager LocationMan;
#endif // LOCATIONMANAGER_H
#ifndef LOCATIONMANAGER_H
#define LOCATIONMANAGER_H
#include <am-vector.h>
#include "GameManager.h"
#include "TitleManager.h"
typedef struct location_data_s
{
char name[128];
vec3_t mins;
vec3_t maxs;
const char *titlelookup;
} location_data_t;
class LocationManager
{
private:
ke::Vector<location_data_t> m_LocationList;
public:
LocationManager()
{
Clear();
};
inline void Clear(void)
{
m_LocationList.clear();
m_LocationList.ensure(32);
};
inline void Add(const char *Name, edict_t *Entity)
{
location_data_t Temp;
Temp.mins=Entity->v.mins;
Temp.maxs=Entity->v.maxs;
strncpy(Temp.name,Name,sizeof(Temp.name)-1);
ke::AString NameString(UTIL_ToLowerCase(Name));
Temp.titlelookup=TitleMan.Lookup(NameString);
m_LocationList.append(Temp);
};
inline const char *Lookup(vec3_t origin, cell titlelookup)
{
unsigned int i=0;
location_data_t Temp;
while (i<m_LocationList.length())
{
Temp=m_LocationList[i++];
if (origin.x <= Temp.maxs.x &&
origin.y <= Temp.maxs.y &&
origin.x >= Temp.mins.x &&
origin.y >= Temp.mins.y)
{
if (titlelookup==0)
{
return &(m_LocationList[i-1].name[0]);
}
else
{
if (m_LocationList[i-1].titlelookup!=NULL)
{
return m_LocationList[i-1].titlelookup;
}
return &(m_LocationList[i-1].name[0]);
}
}
}
return "";
};
};
extern LocationManager LocationMan;
#endif // LOCATIONMANAGER_H

View File

@ -10,173 +10,173 @@
//
// Natural Selection Module
//
/* This file contains the initialization routine and message hooks
* for the message handler. Note that all of the message hooks
* except for MessageBegin_Post are NOT hooked unless the gameDLL
* is sending a message we care about.
*/
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "MessageHandler.h"
MessageHandler *MessageLists[256];
MessageHandler *HookedMessage;
bool MessageHandler_Initialized=false;
// This is called through ServerActivate_Post
void Initialize_MessageHandler(void)
{
if (MessageHandler_Initialized)
{
return;
}
MessageHandler_Initialized=true;
int i=0;
while (i<255)
{
MessageLists[i++]=NULL;
};
// Hook our messages
int index;
index=GET_USER_MSG_ID(&Plugin_info,"Countdown",NULL);
if (index)
{
MessageLists[index]=new MessageCountDown;
}
index=GET_USER_MSG_ID(&Plugin_info,"GameStatus",NULL);
if (index)
{
MessageLists[index]=new MessageGameStatus;
}
#if 0
index=GET_USER_MSG_ID(&Plugin_info,"Particles",NULL);
if (index)
{
MessageLists[index]=new MessageDebug;
}
#endif
// Start hooking messagebegin_post
g_pengfuncsTable_Post->pfnMessageBegin=MessageBegin_Post;
};
void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
{
// Sanity check, should never matter
if (msg_type < 0 || msg_type > 255)
{
RETURN_META(MRES_IGNORED);
}
// Has a hooked message?
if (MessageLists[msg_type]!=NULL)
{
// Should this message be hooked?
if (MessageLists[msg_type]->Begin(msg_dest,msg_type,pOrigin,ed)==1)
{
// This message is going to all be hooked
// save pointer to our class
HookedMessage=MessageLists[msg_type];
// Tell metamod to forward
g_pengfuncsTable_Post->pfnWriteByte=WriteByte_Post;
g_pengfuncsTable_Post->pfnWriteChar=WriteChar_Post;
g_pengfuncsTable_Post->pfnWriteShort=WriteShort_Post;
g_pengfuncsTable_Post->pfnWriteLong=WriteLong_Post;
g_pengfuncsTable_Post->pfnWriteAngle=WriteAngle_Post;
g_pengfuncsTable_Post->pfnWriteCoord=WriteCoord_Post;
g_pengfuncsTable_Post->pfnWriteString=WriteString_Post;
g_pengfuncsTable_Post->pfnWriteEntity=WriteEntity_Post;
g_pengfuncsTable_Post->pfnMessageEnd=MessageEnd_Post;
}
}
RETURN_META(MRES_IGNORED);
}
void MessageEnd_Post(void)
{
HookedMessage->End();
HookedMessage=NULL;
// Stop metamod forwarding
g_pengfuncsTable_Post->pfnWriteByte=NULL;
g_pengfuncsTable_Post->pfnWriteChar=NULL;
g_pengfuncsTable_Post->pfnWriteShort=NULL;
g_pengfuncsTable_Post->pfnWriteLong=NULL;
g_pengfuncsTable_Post->pfnWriteAngle=NULL;
g_pengfuncsTable_Post->pfnWriteCoord=NULL;
g_pengfuncsTable_Post->pfnWriteString=NULL;
g_pengfuncsTable_Post->pfnWriteEntity=NULL;
g_pengfuncsTable_Post->pfnMessageEnd=NULL;
RETURN_META(MRES_IGNORED);
};
void WriteByte_Post(int iValue)
{
HookedMessage->WriteByte(iValue);
RETURN_META(MRES_IGNORED);
};
void WriteChar_Post(int iValue)
{
HookedMessage->WriteChar(iValue);
RETURN_META(MRES_IGNORED);
};
void WriteShort_Post(int iValue)
{
HookedMessage->WriteShort(iValue);
RETURN_META(MRES_IGNORED);
};
void WriteLong_Post(int iValue)
{
HookedMessage->WriteLong(iValue);
RETURN_META(MRES_IGNORED);
};
void WriteAngle_Post(float flValue)
{
HookedMessage->WriteAngle(flValue);
RETURN_META(MRES_IGNORED);
};
void WriteCoord_Post(float flValue)
{
HookedMessage->WriteCoord(flValue);
RETURN_META(MRES_IGNORED);
};
void WriteString_Post(const char *sz)
{
HookedMessage->WriteString(sz);
RETURN_META(MRES_IGNORED);
};
void WriteEntity_Post(int iValue)
{
HookedMessage->WriteEntity(iValue);
RETURN_META(MRES_IGNORED);
};
/* This file contains the initialization routine and message hooks
* for the message handler. Note that all of the message hooks
* except for MessageBegin_Post are NOT hooked unless the gameDLL
* is sending a message we care about.
*/
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "MessageHandler.h"
MessageHandler *MessageLists[256];
MessageHandler *HookedMessage;
bool MessageHandler_Initialized=false;
// This is called through ServerActivate_Post
void Initialize_MessageHandler(void)
{
if (MessageHandler_Initialized)
{
return;
}
MessageHandler_Initialized=true;
int i=0;
while (i<255)
{
MessageLists[i++]=NULL;
};
// Hook our messages
int index;
index=GET_USER_MSG_ID(&Plugin_info,"Countdown",NULL);
if (index)
{
MessageLists[index]=new MessageCountDown;
}
index=GET_USER_MSG_ID(&Plugin_info,"GameStatus",NULL);
if (index)
{
MessageLists[index]=new MessageGameStatus;
}
#if 0
index=GET_USER_MSG_ID(&Plugin_info,"Particles",NULL);
if (index)
{
MessageLists[index]=new MessageDebug;
}
#endif
// Start hooking messagebegin_post
g_pengfuncsTable_Post->pfnMessageBegin=MessageBegin_Post;
};
void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
{
// Sanity check, should never matter
if (msg_type < 0 || msg_type > 255)
{
RETURN_META(MRES_IGNORED);
}
// Has a hooked message?
if (MessageLists[msg_type]!=NULL)
{
// Should this message be hooked?
if (MessageLists[msg_type]->Begin(msg_dest,msg_type,pOrigin,ed)==1)
{
// This message is going to all be hooked
// save pointer to our class
HookedMessage=MessageLists[msg_type];
// Tell metamod to forward
g_pengfuncsTable_Post->pfnWriteByte=WriteByte_Post;
g_pengfuncsTable_Post->pfnWriteChar=WriteChar_Post;
g_pengfuncsTable_Post->pfnWriteShort=WriteShort_Post;
g_pengfuncsTable_Post->pfnWriteLong=WriteLong_Post;
g_pengfuncsTable_Post->pfnWriteAngle=WriteAngle_Post;
g_pengfuncsTable_Post->pfnWriteCoord=WriteCoord_Post;
g_pengfuncsTable_Post->pfnWriteString=WriteString_Post;
g_pengfuncsTable_Post->pfnWriteEntity=WriteEntity_Post;
g_pengfuncsTable_Post->pfnMessageEnd=MessageEnd_Post;
}
}
RETURN_META(MRES_IGNORED);
}
void MessageEnd_Post(void)
{
HookedMessage->End();
HookedMessage=NULL;
// Stop metamod forwarding
g_pengfuncsTable_Post->pfnWriteByte=NULL;
g_pengfuncsTable_Post->pfnWriteChar=NULL;
g_pengfuncsTable_Post->pfnWriteShort=NULL;
g_pengfuncsTable_Post->pfnWriteLong=NULL;
g_pengfuncsTable_Post->pfnWriteAngle=NULL;
g_pengfuncsTable_Post->pfnWriteCoord=NULL;
g_pengfuncsTable_Post->pfnWriteString=NULL;
g_pengfuncsTable_Post->pfnWriteEntity=NULL;
g_pengfuncsTable_Post->pfnMessageEnd=NULL;
RETURN_META(MRES_IGNORED);
};
void WriteByte_Post(int iValue)
{
HookedMessage->WriteByte(iValue);
RETURN_META(MRES_IGNORED);
};
void WriteChar_Post(int iValue)
{
HookedMessage->WriteChar(iValue);
RETURN_META(MRES_IGNORED);
};
void WriteShort_Post(int iValue)
{
HookedMessage->WriteShort(iValue);
RETURN_META(MRES_IGNORED);
};
void WriteLong_Post(int iValue)
{
HookedMessage->WriteLong(iValue);
RETURN_META(MRES_IGNORED);
};
void WriteAngle_Post(float flValue)
{
HookedMessage->WriteAngle(flValue);
RETURN_META(MRES_IGNORED);
};
void WriteCoord_Post(float flValue)
{
HookedMessage->WriteCoord(flValue);
RETURN_META(MRES_IGNORED);
};
void WriteString_Post(const char *sz)
{
HookedMessage->WriteString(sz);
RETURN_META(MRES_IGNORED);
};
void WriteEntity_Post(int iValue)
{
HookedMessage->WriteEntity(iValue);
RETURN_META(MRES_IGNORED);
};

View File

@ -10,149 +10,149 @@
//
// Natural Selection Module
//
/* Class with virtual members for easy message handling
* Don't forget to add new messages to "Initialize_MessageHandler()"
*/
#ifndef MESSAGEHANDLER_H
#define MESSAGEHANDLER_H
#include "utilfunctions.h"
class MessageHandler
{
public:
unsigned int m_Count;
int m_Target;
float m_Origin[3];
edict_t *m_Entity;
int m_Msg;
/**
* Return 1 to hook the rest of this message, 0 otherwise
*/
virtual int Begin(int Target, int Msg, const float *Origin, edict_t *Entity)
{
return 0;
};
virtual void End(void)
{
return;
};
virtual void WriteByte(int Data)
{
++m_Count;
};
virtual void WriteChar(int Data)
{
++m_Count;
};
virtual void WriteShort(int Data)
{
++m_Count;
};
virtual void WriteLong(int Data)
{
++m_Count;
};
virtual void WriteAngle(REAL Data)
{
++m_Count;
};
virtual void WriteCoord(REAL Data)
{
++m_Count;
};
virtual void WriteString(const char *Data)
{
++m_Count;
};
virtual void WriteEntity(int Data)
{
++m_Count;
};
};
class MessageCountDown : public MessageHandler
{
public:
int m_CountDownTime;
virtual int Begin(int Target, int Msg, const float *Origin, edict_t *Entity)
{
m_Count=0;
return 1;
};
virtual void End(void)
{
if (m_Count!=1) // invalid message?
{
MF_Log("[NS] Invalid Countdown message received! Got %d args, expected 1.",m_Count);
return;
}
GameMan.HandleCountdown(m_CountDownTime);
};
virtual void WriteByte(int Data)
{
++m_Count;
m_CountDownTime=Data;
};
};
class MessageGameStatus : public MessageHandler
{
public:
int FirstByte;
virtual int Begin(int Target, int Msg, const float *Origin, edict_t *Entity)
{
m_Count=0;
return 1;
};
virtual void End(void)
{
GameMan.HandleGameStatus(FirstByte);
};
virtual void WriteByte(int iValue)
{
if (m_Count==0)
{
FirstByte=iValue;
};
++m_Count;
};
};
void Initialize_MessageHandler(void);
void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
void MessageEnd_Post(void);
void WriteByte_Post(int iValue);
void WriteChar_Post(int iValue);
void WriteShort_Post(int iValue);
void WriteLong_Post(int iValue);
void WriteAngle_Post(float flValue);
void WriteCoord_Post(float flValue);
void WriteString_Post(const char *sz);
void WriteEntity_Post(int iValue);
#endif // MESSAGEHANDLER_H
/* Class with virtual members for easy message handling
* Don't forget to add new messages to "Initialize_MessageHandler()"
*/
#ifndef MESSAGEHANDLER_H
#define MESSAGEHANDLER_H
#include "utilfunctions.h"
class MessageHandler
{
public:
unsigned int m_Count;
int m_Target;
float m_Origin[3];
edict_t *m_Entity;
int m_Msg;
/**
* Return 1 to hook the rest of this message, 0 otherwise
*/
virtual int Begin(int Target, int Msg, const float *Origin, edict_t *Entity)
{
return 0;
};
virtual void End(void)
{
return;
};
virtual void WriteByte(int Data)
{
++m_Count;
};
virtual void WriteChar(int Data)
{
++m_Count;
};
virtual void WriteShort(int Data)
{
++m_Count;
};
virtual void WriteLong(int Data)
{
++m_Count;
};
virtual void WriteAngle(REAL Data)
{
++m_Count;
};
virtual void WriteCoord(REAL Data)
{
++m_Count;
};
virtual void WriteString(const char *Data)
{
++m_Count;
};
virtual void WriteEntity(int Data)
{
++m_Count;
};
};
class MessageCountDown : public MessageHandler
{
public:
int m_CountDownTime;
virtual int Begin(int Target, int Msg, const float *Origin, edict_t *Entity)
{
m_Count=0;
return 1;
};
virtual void End(void)
{
if (m_Count!=1) // invalid message?
{
MF_Log("[NS] Invalid Countdown message received! Got %d args, expected 1.",m_Count);
return;
}
GameMan.HandleCountdown(m_CountDownTime);
};
virtual void WriteByte(int Data)
{
++m_Count;
m_CountDownTime=Data;
};
};
class MessageGameStatus : public MessageHandler
{
public:
int FirstByte;
virtual int Begin(int Target, int Msg, const float *Origin, edict_t *Entity)
{
m_Count=0;
return 1;
};
virtual void End(void)
{
GameMan.HandleGameStatus(FirstByte);
};
virtual void WriteByte(int iValue)
{
if (m_Count==0)
{
FirstByte=iValue;
};
++m_Count;
};
};
void Initialize_MessageHandler(void);
void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
void MessageEnd_Post(void);
void WriteByte_Post(int iValue);
void WriteChar_Post(int iValue);
void WriteShort_Post(int iValue);
void WriteLong_Post(int iValue);
void WriteAngle_Post(float flValue);
void WriteCoord_Post(float flValue);
void WriteString_Post(const char *sz);
void WriteEntity_Post(int iValue);
#endif // MESSAGEHANDLER_H

View File

@ -10,71 +10,71 @@
//
// Natural Selection Module
//
/* Inlined replacements for INDEXENT/ENTINDEX
* It only really removes the overhead of the push/jump
* but since INDEXENT/ENTINDEX are used a lot with amxx
* it might be beneficial to include.
* NOTE: Bad stuff will happen if you call these before
* NEW_Initialize()
* NOTE: No bounds checking is done because natives
* should use their own bounds checking!
*/
#ifndef NEW_UTIL_H
#define NEW_UTIL_H
extern edict_t *NEW_FirstEdict;
extern bool NEW_Initialized;
/**
* This is called on the first Spawn() ever hooked. This would be worldspawn (index 0)
*/
inline void NEW_Initialize(edict_t *Entity)
{
// call the HL Engine ENTINDEX to make sure this is index 0
int index=ENTINDEX(Entity);
if (index==0)
{
NEW_FirstEdict=Entity;
NEW_Initialized=true;
return;
}
// This is not worldspawn?
// compensate
NEW_FirstEdict=Entity - index;
NEW_Initialized=true;
}
/**
* Converts an integer index into an edict pointer
*/
inline edict_t *INDEXENT_NEW(const int Index)
{
return (edict_t *)(NEW_FirstEdict + Index);
};
/**
* Converts an edict pointer into an integer index
*/
inline int ENTINDEX_NEW(const edict_t *Ent)
{
return (int)(Ent - NEW_FirstEdict);
};
// Inlined replacement of MF_GetAmxAddr
// straight from amxmodx's string.cpp; no need for this to be an api call
inline cell *MF_GetAmxAddr_NEW(AMX *amx, cell amx_addr)
{
return (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
};
#endif // NEW_UTIL_H
/* Inlined replacements for INDEXENT/ENTINDEX
* It only really removes the overhead of the push/jump
* but since INDEXENT/ENTINDEX are used a lot with amxx
* it might be beneficial to include.
* NOTE: Bad stuff will happen if you call these before
* NEW_Initialize()
* NOTE: No bounds checking is done because natives
* should use their own bounds checking!
*/
#ifndef NEW_UTIL_H
#define NEW_UTIL_H
extern edict_t *NEW_FirstEdict;
extern bool NEW_Initialized;
/**
* This is called on the first Spawn() ever hooked. This would be worldspawn (index 0)
*/
inline void NEW_Initialize(edict_t *Entity)
{
// call the HL Engine ENTINDEX to make sure this is index 0
int index=ENTINDEX(Entity);
if (index==0)
{
NEW_FirstEdict=Entity;
NEW_Initialized=true;
return;
}
// This is not worldspawn?
// compensate
NEW_FirstEdict=Entity - index;
NEW_Initialized=true;
}
/**
* Converts an integer index into an edict pointer
*/
inline edict_t *INDEXENT_NEW(const int Index)
{
return (edict_t *)(NEW_FirstEdict + Index);
};
/**
* Converts an edict pointer into an integer index
*/
inline int ENTINDEX_NEW(const edict_t *Ent)
{
return (int)(Ent - NEW_FirstEdict);
};
// Inlined replacement of MF_GetAmxAddr
// straight from amxmodx's string.cpp; no need for this to be an api call
inline cell *MF_GetAmxAddr_NEW(AMX *amx, cell amx_addr)
{
return (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
};
#endif // NEW_UTIL_H

View File

@ -11,119 +11,119 @@
// Natural Selection Module
//
#include "amxxmodule.h"
#include "ns.h"
#include "ParticleManager.h"
void ParticleManager::ReadFile(void)
{
this->Prune();
if (m_iFileLoaded!=0)
{
return;
}
m_iFileLoaded=1;
char FileName[256];
UTIL_Format(FileName, sizeof(FileName)-1, "%s/ns.ps", MF_GetModname());
FILE *fp=fopen(FileName,"r");
if (!fp)
{
MF_Log("ParticleManager: Cannot open \"%s\" for reading!",FileName);
return;
}
// Since I don't care about the actual parameters of each
// particle system, just their order and name
// I only have to scan for "start pSystemName NAME"
char Buffer[1024];
char *Start;
char *End;
int Count=0;
memset(&Buffer[0],0x0,sizeof(Buffer));
while (!feof(fp))
{
Buffer[0]='\0';
fgets(Buffer,1023,fp);
Start=&Buffer[0];
// strip whitespace from the front
while (*Start==' ' ||
*Start=='\t')
{
++Start;
}
// if the first character is ' ignore it
if (*Start=='\'')
{
continue;
}
// if the first word is "start" then this is a line we want
if (strncmp("start ",Start,6)!=0)
{
continue;
}
// Move up past 2 space blocks
while (*Start!='\0' &&
*Start!=' ' &&
*Start!='\t')
{
++Start;
}
while (*Start==' ' ||
*Start=='\t')
{
++Start;
}
while (*Start!='\0' &&
*Start!=' ' &&
*Start!='\t')
{
++Start;
}
while (*Start==' ' ||
*Start=='\t')
{
++Start;
}
// now strip whitespace from the end
End=Start+strlen(Start)-1;
while (*End=='\n' ||
*End=='\r' ||
*End==' ' ||
*End=='\t')
{
*End--='\0';
}
// "Start" should now point to the name of this particle system
//printf("Particle system %d = \"%s\"\n",Count,Start);
this->Add(Start,1);
++Count;
}
fclose(fp);
};
#include "amxxmodule.h"
#include "ns.h"
#include "ParticleManager.h"
void ParticleManager::ReadFile(void)
{
this->Prune();
if (m_iFileLoaded!=0)
{
return;
}
m_iFileLoaded=1;
char FileName[256];
UTIL_Format(FileName, sizeof(FileName)-1, "%s/ns.ps", MF_GetModname());
FILE *fp=fopen(FileName,"r");
if (!fp)
{
MF_Log("ParticleManager: Cannot open \"%s\" for reading!",FileName);
return;
}
// Since I don't care about the actual parameters of each
// particle system, just their order and name
// I only have to scan for "start pSystemName NAME"
char Buffer[1024];
char *Start;
char *End;
int Count=0;
memset(&Buffer[0],0x0,sizeof(Buffer));
while (!feof(fp))
{
Buffer[0]='\0';
fgets(Buffer,1023,fp);
Start=&Buffer[0];
// strip whitespace from the front
while (*Start==' ' ||
*Start=='\t')
{
++Start;
}
// if the first character is ' ignore it
if (*Start=='\'')
{
continue;
}
// if the first word is "start" then this is a line we want
if (strncmp("start ",Start,6)!=0)
{
continue;
}
// Move up past 2 space blocks
while (*Start!='\0' &&
*Start!=' ' &&
*Start!='\t')
{
++Start;
}
while (*Start==' ' ||
*Start=='\t')
{
++Start;
}
while (*Start!='\0' &&
*Start!=' ' &&
*Start!='\t')
{
++Start;
}
while (*Start==' ' ||
*Start=='\t')
{
++Start;
}
// now strip whitespace from the end
End=Start+strlen(Start)-1;
while (*End=='\n' ||
*End=='\r' ||
*End==' ' ||
*End=='\t')
{
*End--='\0';
}
// "Start" should now point to the name of this particle system
//printf("Particle system %d = \"%s\"\n",Count,Start);
this->Add(Start,1);
++Count;
}
fclose(fp);
};

View File

@ -10,115 +10,115 @@
//
// Natural Selection Module
//
#ifndef PARTICLEMANAGER_H
#define PARTICLEMANAGER_H
#include <am-vector.h>
#include <am-string.h>
typedef struct psystem_s
{
ke::AString Name;
int id;
int IsStatic; // Set to 1 if the particle system is loaded from ns.ps
} ParticleSystem;
class ParticleManager
{
private:
ke::Vector<ParticleSystem *> Systems;
int m_iFileLoaded;
unsigned short m_iEventID;
public:
ParticleManager()
{
m_iFileLoaded=0;
m_iEventID=0;
Systems.ensure(64);
};
// Remove all non-static particle systems
inline void Prune()
{
for (size_t i = 0; i < Systems.length(); ++i)
{
if (Systems[i]->IsStatic)
{
break;
}
Systems.remove(i);
delete Systems.at(i);
if (!Systems.length())
{
break;
}
}
};
void ReadFile(void);
inline int Add(const char *Start, int Static)
{
ParticleSystem *ps=new ParticleSystem;
ps->id=Systems.length();
ps->IsStatic=Static;
ps->Name = Start;
Systems.append(ps);
return Systems.length()-1;
};
inline void FireSystem(int id, float *Origin, float *Angles, int flags)
{
PLAYBACK_EVENT_FULL(flags, /*flags*/
NULL, /*pInvoker*/
m_iEventID, /*eventid*/
0.0, /*delay*/
Origin, /*origin*/
Angles, /*angles*/
0.0, /*fparam1*/
0.0, /*fparam2*/
id, /*iparam1 - particle system id*/
0, /*iparam2*/
0, /*bparam1*/
0); /*bparam2*/
};
inline void PrecacheEvent(const char *file)
{
if (strcmp(file,"events/Particle.sc")==0)
{
if (META_RESULT_STATUS >= MRES_OVERRIDE)
{
m_iEventID=META_RESULT_OVERRIDE_RET(unsigned short);
}
else
{
m_iEventID=META_RESULT_ORIG_RET(unsigned short);
}
//printf("EVENT=%d\n",m_iEventID);
}
};
inline int Find(const char *Needle)
{
for (size_t i = 0; i < Systems.length(); ++i)
{
if (strcmp(Needle, Systems[i]->Name.chars()) == 0)
{
return Systems[i]->id;
}
}
return -1;
};
};
extern ParticleManager ParticleMan;
#endif // PARTICLEMANAGER_H
#ifndef PARTICLEMANAGER_H
#define PARTICLEMANAGER_H
#include <am-vector.h>
#include <am-string.h>
typedef struct psystem_s
{
ke::AString Name;
int id;
int IsStatic; // Set to 1 if the particle system is loaded from ns.ps
} ParticleSystem;
class ParticleManager
{
private:
ke::Vector<ParticleSystem *> Systems;
int m_iFileLoaded;
unsigned short m_iEventID;
public:
ParticleManager()
{
m_iFileLoaded=0;
m_iEventID=0;
Systems.ensure(64);
};
// Remove all non-static particle systems
inline void Prune()
{
for (size_t i = 0; i < Systems.length(); ++i)
{
if (Systems[i]->IsStatic)
{
break;
}
Systems.remove(i);
delete Systems.at(i);
if (!Systems.length())
{
break;
}
}
};
void ReadFile(void);
inline int Add(const char *Start, int Static)
{
ParticleSystem *ps=new ParticleSystem;
ps->id=Systems.length();
ps->IsStatic=Static;
ps->Name = Start;
Systems.append(ps);
return Systems.length()-1;
};
inline void FireSystem(int id, float *Origin, float *Angles, int flags)
{
PLAYBACK_EVENT_FULL(flags, /*flags*/
NULL, /*pInvoker*/
m_iEventID, /*eventid*/
0.0, /*delay*/
Origin, /*origin*/
Angles, /*angles*/
0.0, /*fparam1*/
0.0, /*fparam2*/
id, /*iparam1 - particle system id*/
0, /*iparam2*/
0, /*bparam1*/
0); /*bparam2*/
};
inline void PrecacheEvent(const char *file)
{
if (strcmp(file,"events/Particle.sc")==0)
{
if (META_RESULT_STATUS >= MRES_OVERRIDE)
{
m_iEventID=META_RESULT_OVERRIDE_RET(unsigned short);
}
else
{
m_iEventID=META_RESULT_ORIG_RET(unsigned short);
}
//printf("EVENT=%d\n",m_iEventID);
}
};
inline int Find(const char *Needle)
{
for (size_t i = 0; i < Systems.length(); ++i)
{
if (strcmp(Needle, Systems[i]->Name.chars()) == 0)
{
return Systems[i]->id;
}
}
return -1;
};
};
extern ParticleManager ParticleMan;
#endif // PARTICLEMANAGER_H

View File

@ -10,99 +10,99 @@
//
// Natural Selection Module
//
#ifndef SPAWNMANAGER_H
#define SPAWNMANAGER_H
#include <am-vector.h>
typedef struct spawndata_s
{
REAL Location[3];
REAL Angle[3];
} SpawnData;
class SpawnManager
{
private:
ke::Vector<SpawnData> TeamSpawns[5];
public:
SpawnManager()
{
this->Clear();
};
inline void Clear(void)
{
TeamSpawns[0].clear();
TeamSpawns[1].clear();
TeamSpawns[2].clear();
TeamSpawns[3].clear();
TeamSpawns[4].clear();
// Reserve data for a "typical" map layout
// makes data entry faster on map load
TeamSpawns[0].ensure(32);
TeamSpawns[1].ensure(16);
TeamSpawns[2].ensure(48);
};
inline void Insert(const edict_t *Entity)
{
// Bounds check team
if (Entity->v.team<0 || Entity->v.team > 4)
{
return;
}
SpawnData TemporaryData;
Entity->v.origin.CopyToArray(TemporaryData.Location);
Entity->v.angles.CopyToArray(TemporaryData.Angle);
TeamSpawns[Entity->v.team].append(TemporaryData);
};
inline void InsertReadyRoom(const edict_t *Entity)
{
SpawnData TemporaryData;
Entity->v.origin.CopyToArray(TemporaryData.Location);
Entity->v.angles.CopyToArray(TemporaryData.Angle);
TeamSpawns[0].append(TemporaryData);
};
// ns_get_spawn(team,number=0,Float:ret[3]);
inline cell Lookup(AMX *amx, cell *params)
{
if (params[1] < 0 || params[1] > 4)
{
return 0;
}
if (params[2]==0)
{
return static_cast<int>(TeamSpawns[params[1]].length());
}
if (params[2]>=(int)TeamSpawns[params[1]].length())
{
return 0;
}
cell *Return=MF_GetAmxAddr(amx,params[3]);
SpawnData SpawnRet=TeamSpawns[params[1]][params[2]];
Return[0]=amx_ftoc2(SpawnRet.Location[0]);
Return[1]=amx_ftoc2(SpawnRet.Location[1]);
Return[2]=amx_ftoc2(SpawnRet.Location[2]);
return 1;
};
};
extern SpawnManager SpawnMan;
#endif // SPAWNMANAGER_H
#ifndef SPAWNMANAGER_H
#define SPAWNMANAGER_H
#include <am-vector.h>
typedef struct spawndata_s
{
REAL Location[3];
REAL Angle[3];
} SpawnData;
class SpawnManager
{
private:
ke::Vector<SpawnData> TeamSpawns[5];
public:
SpawnManager()
{
this->Clear();
};
inline void Clear(void)
{
TeamSpawns[0].clear();
TeamSpawns[1].clear();
TeamSpawns[2].clear();
TeamSpawns[3].clear();
TeamSpawns[4].clear();
// Reserve data for a "typical" map layout
// makes data entry faster on map load
TeamSpawns[0].ensure(32);
TeamSpawns[1].ensure(16);
TeamSpawns[2].ensure(48);
};
inline void Insert(const edict_t *Entity)
{
// Bounds check team
if (Entity->v.team<0 || Entity->v.team > 4)
{
return;
}
SpawnData TemporaryData;
Entity->v.origin.CopyToArray(TemporaryData.Location);
Entity->v.angles.CopyToArray(TemporaryData.Angle);
TeamSpawns[Entity->v.team].append(TemporaryData);
};
inline void InsertReadyRoom(const edict_t *Entity)
{
SpawnData TemporaryData;
Entity->v.origin.CopyToArray(TemporaryData.Location);
Entity->v.angles.CopyToArray(TemporaryData.Angle);
TeamSpawns[0].append(TemporaryData);
};
// ns_get_spawn(team,number=0,Float:ret[3]);
inline cell Lookup(AMX *amx, cell *params)
{
if (params[1] < 0 || params[1] > 4)
{
return 0;
}
if (params[2]==0)
{
return static_cast<int>(TeamSpawns[params[1]].length());
}
if (params[2]>=(int)TeamSpawns[params[1]].length())
{
return 0;
}
cell *Return=MF_GetAmxAddr(amx,params[3]);
SpawnData SpawnRet=TeamSpawns[params[1]][params[2]];
Return[0]=amx_ftoc2(SpawnRet.Location[0]);
Return[1]=amx_ftoc2(SpawnRet.Location[1]);
Return[2]=amx_ftoc2(SpawnRet.Location[2]);
return 1;
};
};
extern SpawnManager SpawnMan;
#endif // SPAWNMANAGER_H

View File

@ -11,143 +11,143 @@
// Natural Selection Module
//
#include "amxxmodule.h"
#include "ns.h"
#include "TitleManager.h"
#include "utilfunctions.h"
void TitleManager::LoadTitles(void)
{
if (m_Loaded!=0) // already loaded?
{
return;
}
m_Loaded=1;
char FileName[128];
UTIL_Format(FileName, sizeof(FileName)-1, "%s/titles.txt", MF_GetModname());
FILE *fp=fopen(FileName,"r");
if (!fp)
{
MF_Log("Unable to load \"%s\": TitleManager will not work!",FileName);
return;
};
//MF_Log("TitleManager Loading titles from \"%s\"",FileName);
char KeyName[512]; // last known good keyname
char Data[2048]; // data for the key
// does not support multi line data, but for
// location namesthat is acceptable.
char TempBuffer[2048]; // currently read data
char *TempPointer;
char *TempPointerEnd;
unsigned int Line=0;
scan_for_key:
KeyName[0]='\0';
while (!feof(fp))
{
Line++;
fgets(TempBuffer,2047,fp);
TempPointer=&TempBuffer[0];
// get rid of white space at the front
while (*TempPointer=='\0' || // terminator
*TempPointer==' ' || // space
*TempPointer=='\t') // tab
{
++TempPointer;
}
if (*TempPointer=='\0' || // terminator
*TempPointer=='/') // comment
{
continue;
}
// get rid of \r\n at the end
TempPointerEnd=TempPointer+strlen(TempPointer)-1;
while (*TempPointerEnd=='\r' ||
*TempPointerEnd=='\n' ||
*TempPointerEnd=='\t' ||
*TempPointerEnd==' ')
{
*TempPointerEnd--='\0';
}
if (*TempPointer=='{') // start of data
{
if (KeyName[0]!='\0') // do we have a keyname
{
goto scan_for_data;
}
else
{
MF_Log("TitleManager: titles.txt line %u: began a data section with no key name in use!",Line);
goto scan_for_key;
}
}
// have a valid key name here
strncpy(KeyName,TempBuffer,sizeof(KeyName)-1);
// keep looping (until we hit a '{')
};
// if we're out here then !feof() failed
goto end_of_file;
scan_for_data:
Data[0]='\0';
while (!feof(fp))
{
Line++;
fgets(TempBuffer,2047,fp);
TempPointer=&TempBuffer[0];
// get rid of white space at the front
while (*TempPointer=='\0' || // terminator
*TempPointer==' ' || // space
*TempPointer=='\t') // tab
{
++TempPointer;
}
if (*TempPointer=='\0' || // terminator
*TempPointer=='/') // comment
{
continue;
}
// get rid of trailing whitespace
TempPointerEnd=TempPointer+strlen(TempPointer)-1;
while (*TempPointerEnd=='\r' ||
*TempPointerEnd=='\n' ||
*TempPointerEnd=='\t' ||
*TempPointerEnd==' ')
{
*TempPointerEnd--='\0';
}
if (*TempPointer=='}') // end of data
{
// insert KeyName & Data into the hash
ke::AString key(UTIL_ToLowerCase(KeyName));
this->m_Hash.insert(key, new ke::AString(Data));
goto scan_for_key;
}
// have valid data here
strncpy(Data,TempBuffer,sizeof(Data)-1);
};
end_of_file:
fclose(fp);
//MF_Log("TitleManager loaded %u entries from titles.txt (%u lines parsed)",m_List.size(),Line);
};
#include "amxxmodule.h"
#include "ns.h"
#include "TitleManager.h"
#include "utilfunctions.h"
void TitleManager::LoadTitles(void)
{
if (m_Loaded!=0) // already loaded?
{
return;
}
m_Loaded=1;
char FileName[128];
UTIL_Format(FileName, sizeof(FileName)-1, "%s/titles.txt", MF_GetModname());
FILE *fp=fopen(FileName,"r");
if (!fp)
{
MF_Log("Unable to load \"%s\": TitleManager will not work!",FileName);
return;
};
//MF_Log("TitleManager Loading titles from \"%s\"",FileName);
char KeyName[512]; // last known good keyname
char Data[2048]; // data for the key
// does not support multi line data, but for
// location namesthat is acceptable.
char TempBuffer[2048]; // currently read data
char *TempPointer;
char *TempPointerEnd;
unsigned int Line=0;
scan_for_key:
KeyName[0]='\0';
while (!feof(fp))
{
Line++;
fgets(TempBuffer,2047,fp);
TempPointer=&TempBuffer[0];
// get rid of white space at the front
while (*TempPointer=='\0' || // terminator
*TempPointer==' ' || // space
*TempPointer=='\t') // tab
{
++TempPointer;
}
if (*TempPointer=='\0' || // terminator
*TempPointer=='/') // comment
{
continue;
}
// get rid of \r\n at the end
TempPointerEnd=TempPointer+strlen(TempPointer)-1;
while (*TempPointerEnd=='\r' ||
*TempPointerEnd=='\n' ||
*TempPointerEnd=='\t' ||
*TempPointerEnd==' ')
{
*TempPointerEnd--='\0';
}
if (*TempPointer=='{') // start of data
{
if (KeyName[0]!='\0') // do we have a keyname
{
goto scan_for_data;
}
else
{
MF_Log("TitleManager: titles.txt line %u: began a data section with no key name in use!",Line);
goto scan_for_key;
}
}
// have a valid key name here
strncpy(KeyName,TempBuffer,sizeof(KeyName)-1);
// keep looping (until we hit a '{')
};
// if we're out here then !feof() failed
goto end_of_file;
scan_for_data:
Data[0]='\0';
while (!feof(fp))
{
Line++;
fgets(TempBuffer,2047,fp);
TempPointer=&TempBuffer[0];
// get rid of white space at the front
while (*TempPointer=='\0' || // terminator
*TempPointer==' ' || // space
*TempPointer=='\t') // tab
{
++TempPointer;
}
if (*TempPointer=='\0' || // terminator
*TempPointer=='/') // comment
{
continue;
}
// get rid of trailing whitespace
TempPointerEnd=TempPointer+strlen(TempPointer)-1;
while (*TempPointerEnd=='\r' ||
*TempPointerEnd=='\n' ||
*TempPointerEnd=='\t' ||
*TempPointerEnd==' ')
{
*TempPointerEnd--='\0';
}
if (*TempPointer=='}') // end of data
{
// insert KeyName & Data into the hash
ke::AString key(UTIL_ToLowerCase(KeyName));
this->m_Hash.insert(key, new ke::AString(Data));
goto scan_for_key;
}
// have valid data here
strncpy(Data,TempBuffer,sizeof(Data)-1);
};
end_of_file:
fclose(fp);
//MF_Log("TitleManager loaded %u entries from titles.txt (%u lines parsed)",m_List.size(),Line);
};

View File

@ -10,49 +10,49 @@
//
// Natural Selection Module
//
#ifndef TITLEMANAGER_H
#define TITLEMANAGER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <am-string.h>
#include "Hash.h"
class TitleManager
{
private:
int m_Loaded;
// Use a string pointer for the data type because the location manager
// stores a direct pointer to the c_str() of the title
Hash<ke::AString, ke::AString*> m_Hash;
public:
TitleManager()
{
m_Loaded=0;
};
inline const char *Lookup(ke::AString &input)
{
ke::AString** ret = m_Hash.find(input);
if (ret == NULL || *ret == NULL)
{
// was not found
return NULL;
}
return (*ret)->chars();
};
void LoadTitles(void);
};
extern TitleManager TitleMan;
#endif // TITLEMANAGER_H
#ifndef TITLEMANAGER_H
#define TITLEMANAGER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <am-string.h>
#include "Hash.h"
class TitleManager
{
private:
int m_Loaded;
// Use a string pointer for the data type because the location manager
// stores a direct pointer to the c_str() of the title
Hash<ke::AString, ke::AString*> m_Hash;
public:
TitleManager()
{
m_Loaded=0;
};
inline const char *Lookup(ke::AString &input)
{
ke::AString** ret = m_Hash.find(input);
if (ret == NULL || *ret == NULL)
{
// was not found
return NULL;
}
return (*ret)->chars();
};
void LoadTitles(void);
};
extern TitleManager TitleMan;
#endif // TITLEMANAGER_H

View File

@ -10,82 +10,82 @@
//
// Natural Selection Module
//
/* Calls sent by AMX Mod X are handled here */
#include "sdk/amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "TitleManager.h"
#include "MessageHandler.h"
#include "ParticleManager.h"
#include "AllocString.h"
extern int gmsgHudText2;
extern BOOL iscombat;
TitleManager TitleMan;
ParticleManager ParticleMan;
void MFuncs_Initialize(void);
// Native register calls here
void AddNatives_MemberFunc();
void AddNatives_Particles();
void AddNatives_Player();
void AddNatives_PlayerMemory();
void AddNatives_Weapons();
void AddNatives_Structure();
void AddNatives_General();
// All plugins have loaded (called during spawning worldspawn)
void OnPluginsLoaded()
{
// This message is used for the ns_popup native
GameMan.GetMessageIDs();
// Check the map name and see if it's combat or not.
GameMan.EvaluateCombat();
GameMan.RegisterForwards();
GameMan.CheckAllHooks();
AllocStringList.Clear();
TitleMan.LoadTitles();
GameMan.CheckMap();
ParticleMan.ReadFile();
}
int AmxxCheckGame(const char *game)
{
if (strcasecmp(game, "ns") == 0 ||
strcasecmp(game, "nsp") == 0)
{
return AMXX_GAME_OK;
}
return AMXX_GAME_BAD;
}
// Module is attaching to AMXX
void OnAmxxAttach()
{
AddNatives_MemberFunc();
AddNatives_Particles();
AddNatives_Player();
AddNatives_PlayerMemory();
AddNatives_Weapons();
AddNatives_Structure();
AddNatives_General();
MFuncs_Initialize();
}
/* Calls sent by AMX Mod X are handled here */
#include "sdk/amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "TitleManager.h"
#include "MessageHandler.h"
#include "ParticleManager.h"
#include "AllocString.h"
extern int gmsgHudText2;
extern BOOL iscombat;
TitleManager TitleMan;
ParticleManager ParticleMan;
void MFuncs_Initialize(void);
// Native register calls here
void AddNatives_MemberFunc();
void AddNatives_Particles();
void AddNatives_Player();
void AddNatives_PlayerMemory();
void AddNatives_Weapons();
void AddNatives_Structure();
void AddNatives_General();
// All plugins have loaded (called during spawning worldspawn)
void OnPluginsLoaded()
{
// This message is used for the ns_popup native
GameMan.GetMessageIDs();
// Check the map name and see if it's combat or not.
GameMan.EvaluateCombat();
GameMan.RegisterForwards();
GameMan.CheckAllHooks();
AllocStringList.Clear();
TitleMan.LoadTitles();
GameMan.CheckMap();
ParticleMan.ReadFile();
}
int AmxxCheckGame(const char *game)
{
if (strcasecmp(game, "ns") == 0 ||
strcasecmp(game, "nsp") == 0)
{
return AMXX_GAME_OK;
}
return AMXX_GAME_BAD;
}
// Module is attaching to AMXX
void OnAmxxAttach()
{
AddNatives_MemberFunc();
AddNatives_Particles();
AddNatives_Player();
AddNatives_PlayerMemory();
AddNatives_Weapons();
AddNatives_Structure();
AddNatives_General();
MFuncs_Initialize();
}

View File

@ -10,205 +10,205 @@
//
// Natural Selection Module
//
/* Calls going from the engine to the game dll are handled here */
#ifndef HAVE_STDINT_H
#define HAVE_STDINT_H
#endif
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "SpawnManager.h"
#include "GameManager.h"
#include "CPlayer.h"
#include "MessageHandler.h"
#include "LocationManager.h"
#include "ParticleManager.h"
LocationManager LocationMan;
GameManager GameMan;
SpawnManager SpawnMan;
extern edict_t* avhgameplay;
CPlayer g_player[33];
extern void *GameRules;
bool NEW_Initialized=false;
edict_t *NEW_FirstEdict=NULL;
/**
* This is only called during the CountDown
* This call will unhook itself with Metamod
* when it is finished.
*/
void StartFrame()
{
GameMan.StartFrame();
RETURN_META(MRES_IGNORED);
}
/**
* Check spawning for:
* - Worldspawn
* - Initialize NEW_Utilities
* - Clear CPlayer / CSpawn data
* - info_team_start (team spawn point)
* - Save in list
* - info_player_start (ready room spawn point)
* - Save in list
*/
int DispatchSpawn(edict_t *pEntity)
{
if (!NEW_Initialized)
{
NEW_Initialize(pEntity);
}
if (ENTINDEX_NEW(pEntity)==0) // worldspawn
{
int i=0;
while (i<=32)
{
GET_PLAYER_I(i++)->Reset();
}
LocationMan.Clear();
SpawnMan.Clear();
}
else if (FStrEq(STRING(pEntity->v.classname),"info_player_start"))
{
// Mark down the ready room spawn point.
SpawnMan.InsertReadyRoom(pEntity);
}
else if (FStrEq(STRING(pEntity->v.classname),"info_team_start"))
{
// Mark down the team based spawn point.
SpawnMan.Insert(pEntity);
}
else if (FStrEq(STRING(pEntity->v.classname),"env_particles_custom"))
{
ParticleMan.Add(STRING(pEntity->v.targetname),0);
}
RETURN_META_VALUE(MRES_IGNORED, 0);
}
void DispatchKeyValue(edict_t *pEntity,KeyValueData *pkvd)
{
if (strcmp(pkvd->szKeyName,"locationname")==0)
{
if (pkvd->szClassName && strcmp(pkvd->szClassName,"info_location")==0)
{
// this is a BSP model, so calling SetModel
// will update the mins/maxs
SET_MODEL(pEntity,STRING(pEntity->v.model));
// Add it to our list
LocationMan.Add(pkvd->szValue,pEntity);
RETURN_META(MRES_IGNORED);
}
}
RETURN_META(MRES_IGNORED);
}
void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
// Reset CPlayer classes (again?)
for(int i = 1; i <= gpGlobals->maxClients;i++)
{
CPlayer *player=GET_PLAYER_I(i);
player->FullReset();
player->SetEdict(pEdictList + i);
}
GameRules=NULL;
RETURN_META(MRES_IGNORED);
}
void ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
{
Initialize_MessageHandler();
g_pFunctionTable_Post->pfnServerActivate=NULL;
RETURN_META(MRES_IGNORED);
}
/**
* PlayerPreThink, PlayerPreThink_Post and PlayerPostThink_Post
* all disable their Metamod hook calls when they are no longer needed.
* (Actually it is disabled in the native calls)
*/
void PlayerPreThink(edict_t *pEntity)
{
GET_PLAYER_E(pEntity)->PreThink();
RETURN_META(MRES_IGNORED);
}
void PlayerPreThink_Post(edict_t *pEntity)
{
GET_PLAYER_E(pEntity)->PreThink_Post();
RETURN_META(MRES_IGNORED);
}
void PlayerPostThink_Post(edict_t *pEntity)
{
GET_PLAYER_E(pEntity)->PostThink_Post();
RETURN_META(MRES_IGNORED);
}
// Map is changing/server is shutting down.
// We do all cleanup routines here, since, as noted in metamod's dllapi
// ServerDeactivate is the very last function called before the server loads up a new map.
void ServerDeactivate(void)
{
for (int i=1;i<=gpGlobals->maxClients;i++)
{
GET_PLAYER_I(i)->Disconnect();
}
GameRules = NULL;
avhgameplay = NULL;
RETURN_META(MRES_IGNORED);
}
// Reset player data here..
qboolean ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ])
{
// Client's connecting. Freshen up his save data, and mark him as being connected.
GET_PLAYER_E(pEntity)->Connect();
RETURN_META_VALUE(MRES_HANDLED,0);
}
void ClientDisconnect(edict_t *pEntity)
{
// Client is disconnecting, clear all his saved information.
GET_PLAYER_E(pEntity)->Disconnect(1);
RETURN_META(MRES_HANDLED);
}
/**
* NS resets pev->fov every single frame, but this is called right before the data is sent to the client.
* Reset FOV if we need to.
* -
* NOTE: This function is not called if no clients have FoV changed
*/
void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd )
{
GET_PLAYER_E(const_cast<edict_t *>(static_cast<const edict_t *>(ent)))->UpdateFOV();
RETURN_META(MRES_HANDLED);
}
/* Calls going from the engine to the game dll are handled here */
#ifndef HAVE_STDINT_H
#define HAVE_STDINT_H
#endif
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "SpawnManager.h"
#include "GameManager.h"
#include "CPlayer.h"
#include "MessageHandler.h"
#include "LocationManager.h"
#include "ParticleManager.h"
LocationManager LocationMan;
GameManager GameMan;
SpawnManager SpawnMan;
extern edict_t* avhgameplay;
CPlayer g_player[33];
extern void *GameRules;
bool NEW_Initialized=false;
edict_t *NEW_FirstEdict=NULL;
/**
* This is only called during the CountDown
* This call will unhook itself with Metamod
* when it is finished.
*/
void StartFrame()
{
GameMan.StartFrame();
RETURN_META(MRES_IGNORED);
}
/**
* Check spawning for:
* - Worldspawn
* - Initialize NEW_Utilities
* - Clear CPlayer / CSpawn data
* - info_team_start (team spawn point)
* - Save in list
* - info_player_start (ready room spawn point)
* - Save in list
*/
int DispatchSpawn(edict_t *pEntity)
{
if (!NEW_Initialized)
{
NEW_Initialize(pEntity);
}
if (ENTINDEX_NEW(pEntity)==0) // worldspawn
{
int i=0;
while (i<=32)
{
GET_PLAYER_I(i++)->Reset();
}
LocationMan.Clear();
SpawnMan.Clear();
}
else if (FStrEq(STRING(pEntity->v.classname),"info_player_start"))
{
// Mark down the ready room spawn point.
SpawnMan.InsertReadyRoom(pEntity);
}
else if (FStrEq(STRING(pEntity->v.classname),"info_team_start"))
{
// Mark down the team based spawn point.
SpawnMan.Insert(pEntity);
}
else if (FStrEq(STRING(pEntity->v.classname),"env_particles_custom"))
{
ParticleMan.Add(STRING(pEntity->v.targetname),0);
}
RETURN_META_VALUE(MRES_IGNORED, 0);
}
void DispatchKeyValue(edict_t *pEntity,KeyValueData *pkvd)
{
if (strcmp(pkvd->szKeyName,"locationname")==0)
{
if (pkvd->szClassName && strcmp(pkvd->szClassName,"info_location")==0)
{
// this is a BSP model, so calling SetModel
// will update the mins/maxs
SET_MODEL(pEntity,STRING(pEntity->v.model));
// Add it to our list
LocationMan.Add(pkvd->szValue,pEntity);
RETURN_META(MRES_IGNORED);
}
}
RETURN_META(MRES_IGNORED);
}
void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
// Reset CPlayer classes (again?)
for(int i = 1; i <= gpGlobals->maxClients;i++)
{
CPlayer *player=GET_PLAYER_I(i);
player->FullReset();
player->SetEdict(pEdictList + i);
}
GameRules=NULL;
RETURN_META(MRES_IGNORED);
}
void ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
{
Initialize_MessageHandler();
g_pFunctionTable_Post->pfnServerActivate=NULL;
RETURN_META(MRES_IGNORED);
}
/**
* PlayerPreThink, PlayerPreThink_Post and PlayerPostThink_Post
* all disable their Metamod hook calls when they are no longer needed.
* (Actually it is disabled in the native calls)
*/
void PlayerPreThink(edict_t *pEntity)
{
GET_PLAYER_E(pEntity)->PreThink();
RETURN_META(MRES_IGNORED);
}
void PlayerPreThink_Post(edict_t *pEntity)
{
GET_PLAYER_E(pEntity)->PreThink_Post();
RETURN_META(MRES_IGNORED);
}
void PlayerPostThink_Post(edict_t *pEntity)
{
GET_PLAYER_E(pEntity)->PostThink_Post();
RETURN_META(MRES_IGNORED);
}
// Map is changing/server is shutting down.
// We do all cleanup routines here, since, as noted in metamod's dllapi
// ServerDeactivate is the very last function called before the server loads up a new map.
void ServerDeactivate(void)
{
for (int i=1;i<=gpGlobals->maxClients;i++)
{
GET_PLAYER_I(i)->Disconnect();
}
GameRules = NULL;
avhgameplay = NULL;
RETURN_META(MRES_IGNORED);
}
// Reset player data here..
qboolean ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ])
{
// Client's connecting. Freshen up his save data, and mark him as being connected.
GET_PLAYER_E(pEntity)->Connect();
RETURN_META_VALUE(MRES_HANDLED,0);
}
void ClientDisconnect(edict_t *pEntity)
{
// Client is disconnecting, clear all his saved information.
GET_PLAYER_E(pEntity)->Disconnect(1);
RETURN_META(MRES_HANDLED);
}
/**
* NS resets pev->fov every single frame, but this is called right before the data is sent to the client.
* Reset FOV if we need to.
* -
* NOTE: This function is not called if no clients have FoV changed
*/
void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd )
{
GET_PLAYER_E(const_cast<edict_t *>(static_cast<const edict_t *>(ent)))->UpdateFOV();
RETURN_META(MRES_HANDLED);
}

View File

@ -10,283 +10,283 @@
//
// Natural Selection Module
//
/* Calls going from the game dll to the engine are handled here */
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "ParticleManager.h"
#include "CPlayer.h"
// Parse log messages here for any desired information (structure_built, etc.)
// The following logs are needed:
// "sawce<1><STEAM_0:1:4560311><alien1team>" triggered "structure_built" (type "defensechamber")`
void AlertMessage_Post(ALERT_TYPE atype, const char *szFmt, ...)
{
if (atype != at_logged)
{
RETURN_META(MRES_IGNORED);
}
char *MessageStart; // original pointer to start of the message
char *TypePointer; // pointer to the structure type
char *CIDPointer; // pointer to the name text
int CID; // connection ID of the player
va_list LogArgs;
va_start(LogArgs,szFmt);
MessageStart=va_arg(LogArgs,char *);
va_end(LogArgs);
if (MessageStart==NULL) // Somehow got a null pointer, get out of here now
{
RETURN_META(MRES_IGNORED);
}
if ((TypePointer=strstr(MessageStart,"\"structure_built\""))==NULL) // was not found
{
RETURN_META(MRES_IGNORED);
}
if (*(TypePointer - 2) != 'd') // If this is not from a 'triggered "structure_built"', then ignore the message
{
RETURN_META(MRES_IGNORED);
}
// If we got here, then for all we can tell this message is good
// Move up a few spaces
TypePointer+=25; // strlen("\"structure_built\" (type \"")=25
// Now get the player's CID
CIDPointer=MessageStart+1; // skip over the very first quotation mark
while (*CIDPointer++ != '"') /*do nothing*/;
--CIDPointer;
// Move back past three <
while (*CIDPointer-- != '<') /* do nothing*/;
while (*CIDPointer-- != '<') /* do nothing*/;
while (*CIDPointer-- != '<') /* do nothing*/;
++CIDPointer;
// now skip past the <
++CIDPointer;
// We now point to the CID string, atoi will stop at the > so just atoi it for the CID
CID=atoi(CIDPointer);
CPlayer *Player;
if ((Player=UTIL_PlayerByCID(CID))==NULL)
{
RETURN_META(MRES_IGNORED);
}
// list of what impulses represent what type of structure building
// use
// 0 for unknown (shouldn't be used ever)
// 1 for marine
// 2 for alien
// I'm marking the upgrades as marine structures just incase
// they should never be used though!
static int StructureTypes[128] =
{
0, // 0 = unknown
0, // 1 = next weapon
0, // 2 = reload
0, // 3 = drop weapon
0, // 4 = unknown
0, // 5 = unknown
0, // 6 = unknown
0, // 7 = radio comm
0, // 8 = radio comm
0, // 9 = radio comm
0, // 10 = radio comm
0, // 11 = radio comm
0, // 12 = radio comm
0, // 13 = radio comm
0, // 14 = radio comm
0, // 15 = radio comm
0, // 16 = unknown
0, // 17 = unknown
0, // 18 = unknown
0, // 19 = unknown
1, // 20 = armor 1
1, // 21 = armor 2
1, // 22 = armor 3
1, // 23 = weapons 1
1, // 24 = weapons 2
1, // 25 = weapons 3
1, // 26 = siege upgrade
1, // 27 = drop catalyst
1, // 28 = research jp
1, // 29 = research ha
1, // 30 = distress beacon
1, // 31 = resupply (combat)
0, // 32 = unknown
1, // 33 = motion tracking
1, // 34 = phase gates upgrade
0, // 35 = unknown
1, // 36 = electricity upgrade
1, // 37 = handgrenades upgrade
1, // 38 = drop jetpack
1, // 39 = drop heavy armor
1, // 40 = infantry portal
1, // 41 = marine RT
0, // 42 = unused
1, // 43 = turret factory
0, // 44 = unused
1, // 45 = arms lab
1, // 46 = proto lab
1, // 47 = upgrade
1, // 48 = armory
1, // 49 = advanced armory
0, // 50 = unknown
1, // 51 = observatory
0, // 52 = unknown
1, // 53 = scanner sweep
0, // 54 = unknown
1, // 55 = build phase gate
1, // 56 = build turret
1, // 57 = build siege turret
1, // 58 = build command chair
1, // 59 = drop health pack
1, // 60 = drop ammo pack
1, // 61 = drop mine pack
1, // 62 = drop welder
0, // 63 = unknown
1, // 64 = drop shotgun
1, // 65 = drop heavymachinegun
1, // 66 = drop grenadelauncher
0, // 67 = unknown
0, // 68 = unknown
0, // 69 = unknown
0, // 70 = unknown
0, // 71 = unknown
0, // 72 = unknown
0, // 73 = unknown
0, // 74 = unknown
0, // 75 = unknown
0, // 76 = unknown
0, // 77 = unknown
0, // 78 = unknown
0, // 79 = unknown
0, // 80 = radio comm
0, // 81 = radio comm
1, // 82 = commander message
0, // 83 = commander message
0, // 84 = commander message
0, // 85 = unknown
0, // 86 = unknown
0, // 87 = unknown
0, // 88 = unknown
0, // 89 = unknown
2, // 90 = alienresourcetower
2, // 91 = offensechamber
2, // 92 = defensechamber
2, // 93 = sensorychamber
2, // 94 = movementchamber
2, // 95 = team_hive
0, // 96 = unknown
0, // 97 = unknown
0, // 98 = unknown
0, // 99 = unknown
0, // 100 = unknown
2, // 101 = carapace
2, // 102 = regeneration
2, // 103 = redemption
0, // 104 = unknown
1, // 105 = select all marines
0, // 106 = unknown
2, // 107 = celerity
2, // 108 = adrenaline
2, // 109 = silence
2, // 110 = cloaking
2, // 111 = focus
2, // 112 = scent of fear
2, // 113 = skulk
2, // 114 = gorge
2, // 115 = lerk
2, // 116 = fade
2, // 117 = onos
2, // 118 = unlock next ability (combat)
0, // 119 = unknown
0, // 120 = unknown
0, // 121 = unknown
0, // 122 = unknown
0, // 123 = unknown
0, // 124 = unknown
0, // 125 = unknown
2, // 126 = unlock next ability (combat)
0 // 127 = unknown
};
int impulse=Player->GetPev()->impulse;
if (impulse < 0 || impulse > 127)
{
RETURN_META(MRES_IGNORED);
}
if (impulse==95/*hive*/)
{
GameMan.ExecuteClientBuilt(Player->index(), UTIL_FindBuildingHive(), StructureTypes[impulse], impulse);
}
else
{
GameMan.ExecuteClientBuilt(Player->index(), ENTINDEX_NEW(GameMan.GetTemporaryEdict()), StructureTypes[impulse], impulse);
}
RETURN_META(MRES_IGNORED);
}
// We hook newly created entities here.
// This is where we check for client_built created entities.
edict_t* CreateNamedEntity_Post(int className)
{
if (GameMan.IsCombat()) // this shouldn't be called during co, just incase
{
RETURN_META_VALUE(MRES_IGNORED,0);
}
// Incase another plugin supercedes/overrides, use their returned value here.
// (Untested).
if (gpMetaGlobals->status >= MRES_OVERRIDE)
{
GameMan.SetTemporaryEdict(META_RESULT_OVERRIDE_RET(edict_t *));
}
else
{
GameMan.SetTemporaryEdict(META_RESULT_ORIG_RET(edict_t *));
}
RETURN_META_VALUE(MRES_IGNORED,0);
}
unsigned short PrecacheEvent_Post(int type, const char *psz)
{
ParticleMan.PrecacheEvent(psz);
RETURN_META_VALUE(MRES_IGNORED,0);
}
/* Calls going from the game dll to the engine are handled here */
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "ParticleManager.h"
#include "CPlayer.h"
// Parse log messages here for any desired information (structure_built, etc.)
// The following logs are needed:
// "sawce<1><STEAM_0:1:4560311><alien1team>" triggered "structure_built" (type "defensechamber")`
void AlertMessage_Post(ALERT_TYPE atype, const char *szFmt, ...)
{
if (atype != at_logged)
{
RETURN_META(MRES_IGNORED);
}
char *MessageStart; // original pointer to start of the message
char *TypePointer; // pointer to the structure type
char *CIDPointer; // pointer to the name text
int CID; // connection ID of the player
va_list LogArgs;
va_start(LogArgs,szFmt);
MessageStart=va_arg(LogArgs,char *);
va_end(LogArgs);
if (MessageStart==NULL) // Somehow got a null pointer, get out of here now
{
RETURN_META(MRES_IGNORED);
}
if ((TypePointer=strstr(MessageStart,"\"structure_built\""))==NULL) // was not found
{
RETURN_META(MRES_IGNORED);
}
if (*(TypePointer - 2) != 'd') // If this is not from a 'triggered "structure_built"', then ignore the message
{
RETURN_META(MRES_IGNORED);
}
// If we got here, then for all we can tell this message is good
// Move up a few spaces
TypePointer+=25; // strlen("\"structure_built\" (type \"")=25
// Now get the player's CID
CIDPointer=MessageStart+1; // skip over the very first quotation mark
while (*CIDPointer++ != '"') /*do nothing*/;
--CIDPointer;
// Move back past three <
while (*CIDPointer-- != '<') /* do nothing*/;
while (*CIDPointer-- != '<') /* do nothing*/;
while (*CIDPointer-- != '<') /* do nothing*/;
++CIDPointer;
// now skip past the <
++CIDPointer;
// We now point to the CID string, atoi will stop at the > so just atoi it for the CID
CID=atoi(CIDPointer);
CPlayer *Player;
if ((Player=UTIL_PlayerByCID(CID))==NULL)
{
RETURN_META(MRES_IGNORED);
}
// list of what impulses represent what type of structure building
// use
// 0 for unknown (shouldn't be used ever)
// 1 for marine
// 2 for alien
// I'm marking the upgrades as marine structures just incase
// they should never be used though!
static int StructureTypes[128] =
{
0, // 0 = unknown
0, // 1 = next weapon
0, // 2 = reload
0, // 3 = drop weapon
0, // 4 = unknown
0, // 5 = unknown
0, // 6 = unknown
0, // 7 = radio comm
0, // 8 = radio comm
0, // 9 = radio comm
0, // 10 = radio comm
0, // 11 = radio comm
0, // 12 = radio comm
0, // 13 = radio comm
0, // 14 = radio comm
0, // 15 = radio comm
0, // 16 = unknown
0, // 17 = unknown
0, // 18 = unknown
0, // 19 = unknown
1, // 20 = armor 1
1, // 21 = armor 2
1, // 22 = armor 3
1, // 23 = weapons 1
1, // 24 = weapons 2
1, // 25 = weapons 3
1, // 26 = siege upgrade
1, // 27 = drop catalyst
1, // 28 = research jp
1, // 29 = research ha
1, // 30 = distress beacon
1, // 31 = resupply (combat)
0, // 32 = unknown
1, // 33 = motion tracking
1, // 34 = phase gates upgrade
0, // 35 = unknown
1, // 36 = electricity upgrade
1, // 37 = handgrenades upgrade
1, // 38 = drop jetpack
1, // 39 = drop heavy armor
1, // 40 = infantry portal
1, // 41 = marine RT
0, // 42 = unused
1, // 43 = turret factory
0, // 44 = unused
1, // 45 = arms lab
1, // 46 = proto lab
1, // 47 = upgrade
1, // 48 = armory
1, // 49 = advanced armory
0, // 50 = unknown
1, // 51 = observatory
0, // 52 = unknown
1, // 53 = scanner sweep
0, // 54 = unknown
1, // 55 = build phase gate
1, // 56 = build turret
1, // 57 = build siege turret
1, // 58 = build command chair
1, // 59 = drop health pack
1, // 60 = drop ammo pack
1, // 61 = drop mine pack
1, // 62 = drop welder
0, // 63 = unknown
1, // 64 = drop shotgun
1, // 65 = drop heavymachinegun
1, // 66 = drop grenadelauncher
0, // 67 = unknown
0, // 68 = unknown
0, // 69 = unknown
0, // 70 = unknown
0, // 71 = unknown
0, // 72 = unknown
0, // 73 = unknown
0, // 74 = unknown
0, // 75 = unknown
0, // 76 = unknown
0, // 77 = unknown
0, // 78 = unknown
0, // 79 = unknown
0, // 80 = radio comm
0, // 81 = radio comm
1, // 82 = commander message
0, // 83 = commander message
0, // 84 = commander message
0, // 85 = unknown
0, // 86 = unknown
0, // 87 = unknown
0, // 88 = unknown
0, // 89 = unknown
2, // 90 = alienresourcetower
2, // 91 = offensechamber
2, // 92 = defensechamber
2, // 93 = sensorychamber
2, // 94 = movementchamber
2, // 95 = team_hive
0, // 96 = unknown
0, // 97 = unknown
0, // 98 = unknown
0, // 99 = unknown
0, // 100 = unknown
2, // 101 = carapace
2, // 102 = regeneration
2, // 103 = redemption
0, // 104 = unknown
1, // 105 = select all marines
0, // 106 = unknown
2, // 107 = celerity
2, // 108 = adrenaline
2, // 109 = silence
2, // 110 = cloaking
2, // 111 = focus
2, // 112 = scent of fear
2, // 113 = skulk
2, // 114 = gorge
2, // 115 = lerk
2, // 116 = fade
2, // 117 = onos
2, // 118 = unlock next ability (combat)
0, // 119 = unknown
0, // 120 = unknown
0, // 121 = unknown
0, // 122 = unknown
0, // 123 = unknown
0, // 124 = unknown
0, // 125 = unknown
2, // 126 = unlock next ability (combat)
0 // 127 = unknown
};
int impulse=Player->GetPev()->impulse;
if (impulse < 0 || impulse > 127)
{
RETURN_META(MRES_IGNORED);
}
if (impulse==95/*hive*/)
{
GameMan.ExecuteClientBuilt(Player->index(), UTIL_FindBuildingHive(), StructureTypes[impulse], impulse);
}
else
{
GameMan.ExecuteClientBuilt(Player->index(), ENTINDEX_NEW(GameMan.GetTemporaryEdict()), StructureTypes[impulse], impulse);
}
RETURN_META(MRES_IGNORED);
}
// We hook newly created entities here.
// This is where we check for client_built created entities.
edict_t* CreateNamedEntity_Post(int className)
{
if (GameMan.IsCombat()) // this shouldn't be called during co, just incase
{
RETURN_META_VALUE(MRES_IGNORED,0);
}
// Incase another plugin supercedes/overrides, use their returned value here.
// (Untested).
if (gpMetaGlobals->status >= MRES_OVERRIDE)
{
GameMan.SetTemporaryEdict(META_RESULT_OVERRIDE_RET(edict_t *));
}
else
{
GameMan.SetTemporaryEdict(META_RESULT_ORIG_RET(edict_t *));
}
RETURN_META_VALUE(MRES_IGNORED,0);
}
unsigned short PrecacheEvent_Post(int type, const char *psz)
{
ParticleMan.PrecacheEvent(psz);
RETURN_META_VALUE(MRES_IGNORED,0);
}

File diff suppressed because it is too large Load Diff

View File

@ -11,278 +11,278 @@
// Natural Selection Module
//
#include <string.h>
#include "amxxmodule.h"
#include "ns.h"
#include "ns_const.h"
#include "utilfunctions.h"
#include "FastDelegate.h"
#include "GameManager.h"
extern int IsValidBuilding[AVH_USER3_MAX + 1];
using namespace fastdelegate::detail;
void *GameRules=NULL;
mBOOL dlclose_handle_invalid; // Linking errors with metamod
// void AvHBaseBuildable::StartRecycle()
static void (GenericClass::*MFP_Recycle)();
// void AvHWeldable::AddBuildTime(float)
static void (GenericClass::*MFP_WeldFinished)(float);
// AvHGameRules *GetGameRules(void)
static void *(*FP_GetGameRules)();
char *FuncBase;
/**
* sizeof(void (detail::GenericClass::*fptr)())
* is 8 in GCC. Add an empty void * pointer at
* the end to compensate.
* Layout in GCC:
* union {
* void *address; // When this is an address it will always be positive
* int vtable_index; // When it is a vtable index it will always be odd = (vindex*2)+1
* };
* int delta;
* -
* Delta is the adjustment to the this pointer
* For my implementations I will only need it to 0
*/
#ifdef __GNUC__
template <typename OutType>
inline void set_mfp(OutType &out, void *in)
{
union
{
void *in[2];
OutType out;
} mfpu;
mfpu.in[0]=in;
mfpu.in[1]=NULL;
out=mfpu.out;
};
#else
template <typename OutType>
inline void set_mfp(OutType &out, void *in)
{
out=horrible_cast<OutType>(in);
};
#endif
void MFuncs_Initialize(void)
{
char FileName[256];
DLHANDLE DLLBase;
#ifdef __linux__
UTIL_Format(FileName,sizeof(FileName)-1,"%s/dlls/ns_i386.so",MF_GetModname());
#else
UTIL_Format(FileName, sizeof(FileName)-1, "%s\\dlls\\ns.dll", MF_GetModname());
#endif
DLLBase=DLOPEN(FileName);
FuncBase=(char *)DLSYM(DLLBase, MAKE_OFFSET(BASE));
DLCLOSE(DLLBase);
#define MFP(Offs) (((void *)(((char *)FuncBase)+MAKE_OFFSET(Offs))))
set_mfp(MFP_Recycle,MFP(MEMBER_RECYCLE));
set_mfp(MFP_WeldFinished,MFP(MEMBER_TRIGGER_WELDABLE));
// This is not a member function pointer, but use MFP since it
// uses the same address conversion as MFPs do
FP_GetGameRules=horrible_cast<void *(*)()>(MFP(GETGAMERULES));
};
static cell AMX_NATIVE_CALL ns_recycle(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->free || Entity->pvPrivateData==NULL)
{
return 0;
}
if (Entity->v.iuser3 <= AVH_USER3_NONE || Entity->v.iuser3 >= AVH_USER3_MAX)
{
return 0;
}
if (IsValidBuilding[Entity->v.iuser3]!=1) // Not a marine structure?
{
return 0;
}
// Make sure it's a marine building, undefined stuff happens on alien structures
(reinterpret_cast<GenericClass *>(Entity->pvPrivateData)->*(MFP_Recycle))();
return 1;
};
static cell AMX_NATIVE_CALL ns_finish_weldable(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->free || Entity->pvPrivateData==NULL)
{
return 0;
}
// verify the classname since this will crash if it's the wrong class!
if (strcmp(STRING(Entity->v.classname),"avhweldable")!=0)
{
return 0;
}
// First need to set the weldable to 100% complete
set_private_f(Entity,MAKE_OFFSET(WELD_DONE),get_private_f(Entity,MAKE_OFFSET(WELD_TIME)));
// Now make NS think the weldable has been welded again
// This has to call AvHWeldable::AddBuildTime(float)
// because AvHWeldable::TriggerFinished() does not work properly
(reinterpret_cast<GenericClass *>(Entity->pvPrivateData)->*(MFP_WeldFinished))(100.0);
return 1;
};
static cell AMX_NATIVE_CALL ns_get_teamres(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
if (GameRules==NULL) // GameRules not initialized yet
{
GameRules=(*(FP_GetGameRules))();
}
if (GameRules==NULL) // Still null? Get out of here
{
return 0;
}
switch(params[1])
{
case 1:
{
return amx_ftoc2(*(REAL *)((char *)GameRules+GAMERULES_TEAMA_RESOURCES));
}
case 2:
{
return amx_ftoc2(*(REAL *)((char *)GameRules+GAMERULES_TEAMB_RESOURCES));
}
default:
{
MF_LogError(amx, AMX_ERR_NATIVE, "ns_get_teamres: Expected 1 for team a or 2 for team b, got %d", params[1]);
return 0;
}
}
return 0;
}
static cell AMX_NATIVE_CALL ns_set_teamres(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
if (GameRules==NULL) // GameRules not initialized yet
{
GameRules=(*(FP_GetGameRules))();
}
if (GameRules==NULL) // Still null? Get out of here
{
return 0;
}
switch(params[1])
{
case 1:
{
*(REAL *)((char *)GameRules+GAMERULES_TEAMA_RESOURCES)=amx_ctof2(params[2]);
return 1;
}
case 2:
{
*(REAL *)((char *)GameRules+GAMERULES_TEAMB_RESOURCES)=amx_ctof2(params[2]);
return 1;
}
default:
{
MF_LogError(amx, AMX_ERR_NATIVE, "ns_set_teamres: Expected 1 for team a or 2 for team b, got %d", params[1]);
return 0;
}
}
return 0;
}
static cell AMX_NATIVE_CALL ns_add_teamres(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
if (GameRules==NULL) // GameRules not initialized yet
{
GameRules=(*(FP_GetGameRules))();
}
if (GameRules==NULL) // Still null? Get out of here
{
return 0;
}
switch(params[1])
{
case 1:
{
return amx_ftoc2(*(REAL *)((char *)GameRules+GAMERULES_TEAMA_RESOURCES)+=amx_ctof2(params[2]));
}
case 2:
{
return amx_ftoc2(*(REAL *)((char *)GameRules+GAMERULES_TEAMB_RESOURCES)+=amx_ctof2(params[2]));
}
default:
{
MF_LogError(amx, AMX_ERR_NATIVE, "ns_add_teamres: Expected 1 for team a or 2 for team b, got %d", params[1]);
return 0;
}
}
return 0;
}
#ifdef DEVELOPER_BUILD
static cell AMX_NATIVE_CALL findgameinfo(AMX *amx, cell *params)
{
void *Ret=(*(FP_GetGameRules))();
union
{
void *v;
int i;
}vi;
vi.v=Ret;
printf("GameRules=%d\n",vi.i);
return 1;
};
#endif
AMX_NATIVE_INFO memberfunc_natives[] = {
#ifdef DEVELOPER_BUILD
{ "getgameinfo", findgameinfo },
#endif
{ "ns_recycle", ns_recycle },
{ "ns_finish_weldable", ns_finish_weldable },
{ "ns_get_teamres", ns_get_teamres },
{ "ns_set_teamres", ns_set_teamres },
{ "ns_add_teamres", ns_add_teamres },
{ NULL, NULL }
};
void AddNatives_MemberFunc()
{
MF_AddNatives(memberfunc_natives);
};
#include <string.h>
#include "amxxmodule.h"
#include "ns.h"
#include "ns_const.h"
#include "utilfunctions.h"
#include "FastDelegate.h"
#include "GameManager.h"
extern int IsValidBuilding[AVH_USER3_MAX + 1];
using namespace fastdelegate::detail;
void *GameRules=NULL;
mBOOL dlclose_handle_invalid; // Linking errors with metamod
// void AvHBaseBuildable::StartRecycle()
static void (GenericClass::*MFP_Recycle)();
// void AvHWeldable::AddBuildTime(float)
static void (GenericClass::*MFP_WeldFinished)(float);
// AvHGameRules *GetGameRules(void)
static void *(*FP_GetGameRules)();
char *FuncBase;
/**
* sizeof(void (detail::GenericClass::*fptr)())
* is 8 in GCC. Add an empty void * pointer at
* the end to compensate.
* Layout in GCC:
* union {
* void *address; // When this is an address it will always be positive
* int vtable_index; // When it is a vtable index it will always be odd = (vindex*2)+1
* };
* int delta;
* -
* Delta is the adjustment to the this pointer
* For my implementations I will only need it to 0
*/
#ifdef __GNUC__
template <typename OutType>
inline void set_mfp(OutType &out, void *in)
{
union
{
void *in[2];
OutType out;
} mfpu;
mfpu.in[0]=in;
mfpu.in[1]=NULL;
out=mfpu.out;
};
#else
template <typename OutType>
inline void set_mfp(OutType &out, void *in)
{
out=horrible_cast<OutType>(in);
};
#endif
void MFuncs_Initialize(void)
{
char FileName[256];
DLHANDLE DLLBase;
#ifdef __linux__
UTIL_Format(FileName,sizeof(FileName)-1,"%s/dlls/ns_i386.so",MF_GetModname());
#else
UTIL_Format(FileName, sizeof(FileName)-1, "%s\\dlls\\ns.dll", MF_GetModname());
#endif
DLLBase=DLOPEN(FileName);
FuncBase=(char *)DLSYM(DLLBase, MAKE_OFFSET(BASE));
DLCLOSE(DLLBase);
#define MFP(Offs) (((void *)(((char *)FuncBase)+MAKE_OFFSET(Offs))))
set_mfp(MFP_Recycle,MFP(MEMBER_RECYCLE));
set_mfp(MFP_WeldFinished,MFP(MEMBER_TRIGGER_WELDABLE));
// This is not a member function pointer, but use MFP since it
// uses the same address conversion as MFPs do
FP_GetGameRules=horrible_cast<void *(*)()>(MFP(GETGAMERULES));
};
static cell AMX_NATIVE_CALL ns_recycle(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->free || Entity->pvPrivateData==NULL)
{
return 0;
}
if (Entity->v.iuser3 <= AVH_USER3_NONE || Entity->v.iuser3 >= AVH_USER3_MAX)
{
return 0;
}
if (IsValidBuilding[Entity->v.iuser3]!=1) // Not a marine structure?
{
return 0;
}
// Make sure it's a marine building, undefined stuff happens on alien structures
(reinterpret_cast<GenericClass *>(Entity->pvPrivateData)->*(MFP_Recycle))();
return 1;
};
static cell AMX_NATIVE_CALL ns_finish_weldable(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->free || Entity->pvPrivateData==NULL)
{
return 0;
}
// verify the classname since this will crash if it's the wrong class!
if (strcmp(STRING(Entity->v.classname),"avhweldable")!=0)
{
return 0;
}
// First need to set the weldable to 100% complete
set_private_f(Entity,MAKE_OFFSET(WELD_DONE),get_private_f(Entity,MAKE_OFFSET(WELD_TIME)));
// Now make NS think the weldable has been welded again
// This has to call AvHWeldable::AddBuildTime(float)
// because AvHWeldable::TriggerFinished() does not work properly
(reinterpret_cast<GenericClass *>(Entity->pvPrivateData)->*(MFP_WeldFinished))(100.0);
return 1;
};
static cell AMX_NATIVE_CALL ns_get_teamres(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
if (GameRules==NULL) // GameRules not initialized yet
{
GameRules=(*(FP_GetGameRules))();
}
if (GameRules==NULL) // Still null? Get out of here
{
return 0;
}
switch(params[1])
{
case 1:
{
return amx_ftoc2(*(REAL *)((char *)GameRules+GAMERULES_TEAMA_RESOURCES));
}
case 2:
{
return amx_ftoc2(*(REAL *)((char *)GameRules+GAMERULES_TEAMB_RESOURCES));
}
default:
{
MF_LogError(amx, AMX_ERR_NATIVE, "ns_get_teamres: Expected 1 for team a or 2 for team b, got %d", params[1]);
return 0;
}
}
return 0;
}
static cell AMX_NATIVE_CALL ns_set_teamres(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
if (GameRules==NULL) // GameRules not initialized yet
{
GameRules=(*(FP_GetGameRules))();
}
if (GameRules==NULL) // Still null? Get out of here
{
return 0;
}
switch(params[1])
{
case 1:
{
*(REAL *)((char *)GameRules+GAMERULES_TEAMA_RESOURCES)=amx_ctof2(params[2]);
return 1;
}
case 2:
{
*(REAL *)((char *)GameRules+GAMERULES_TEAMB_RESOURCES)=amx_ctof2(params[2]);
return 1;
}
default:
{
MF_LogError(amx, AMX_ERR_NATIVE, "ns_set_teamres: Expected 1 for team a or 2 for team b, got %d", params[1]);
return 0;
}
}
return 0;
}
static cell AMX_NATIVE_CALL ns_add_teamres(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
if (GameRules==NULL) // GameRules not initialized yet
{
GameRules=(*(FP_GetGameRules))();
}
if (GameRules==NULL) // Still null? Get out of here
{
return 0;
}
switch(params[1])
{
case 1:
{
return amx_ftoc2(*(REAL *)((char *)GameRules+GAMERULES_TEAMA_RESOURCES)+=amx_ctof2(params[2]));
}
case 2:
{
return amx_ftoc2(*(REAL *)((char *)GameRules+GAMERULES_TEAMB_RESOURCES)+=amx_ctof2(params[2]));
}
default:
{
MF_LogError(amx, AMX_ERR_NATIVE, "ns_add_teamres: Expected 1 for team a or 2 for team b, got %d", params[1]);
return 0;
}
}
return 0;
}
#ifdef DEVELOPER_BUILD
static cell AMX_NATIVE_CALL findgameinfo(AMX *amx, cell *params)
{
void *Ret=(*(FP_GetGameRules))();
union
{
void *v;
int i;
}vi;
vi.v=Ret;
printf("GameRules=%d\n",vi.i);
return 1;
};
#endif
AMX_NATIVE_INFO memberfunc_natives[] = {
#ifdef DEVELOPER_BUILD
{ "getgameinfo", findgameinfo },
#endif
{ "ns_recycle", ns_recycle },
{ "ns_finish_weldable", ns_finish_weldable },
{ "ns_get_teamres", ns_get_teamres },
{ "ns_set_teamres", ns_set_teamres },
{ "ns_add_teamres", ns_add_teamres },
{ NULL, NULL }
};
void AddNatives_MemberFunc()
{
MF_AddNatives(memberfunc_natives);
};

View File

@ -10,246 +10,246 @@
//
// Natural Selection Module
//
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "ParticleManager.h"
#include <am-vector.h>
#include <am-string.h>
#define KVI(__KEY) PSKeyValueI(__KEY,amx,params)
#define KVF(__KEY) PSKeyValueF(__KEY,amx,params)
#define KVS(__KEY) PSKeyValueS(__KEY,amx,params)
#define NEXT params[__pcount++]
typedef enum partsystype_e
{
PSYS_TYPE_INT,
PSYS_TYPE_FLOAT,
PSYS_TYPE_STRING
}partsystype;
typedef struct partsyskey_s
{
const char *Name;
partsystype type;
}partsyskey;
cell PSKeyValueI(const char *name, AMX *amx, cell *params)
{
if (params[1]==0)
{
MF_LogError(amx,AMX_ERR_NATIVE,"Invalid particle system handle provided!");
return 0;
}
KeyValueData kvd;
char StrData[1024];
UTIL_Format(StrData, sizeof(StrData)-1, "%d", params[2]);
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
kvd.szKeyName=name;
kvd.szValue=&StrData[0];
kvd.fHandled=0;
//printf("\"%s\" \"%s\"\n",kvd.szKeyName,kvd.szValue);
MDLL_KeyValue(reinterpret_cast<edict_t *>(params[1]),&kvd);
return 1;
}
cell PSKeyValueF(const char *name, AMX *amx, cell *params)
{
if (params[1]==0)
{
MF_LogError(amx,AMX_ERR_NATIVE,"Invalid particle system handle provided!");
return 0;
}
KeyValueData kvd;
char StrData[1024];
UTIL_Format(StrData, sizeof(StrData)-1, "%f", amx_ctof2(params[2]));
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
kvd.szKeyName=name;
kvd.szValue=&StrData[0];
kvd.fHandled=0;
//printf("\"%s\" \"%s\"\n",kvd.szKeyName,kvd.szValue);
MDLL_KeyValue(reinterpret_cast<edict_t *>(params[1]),&kvd);
return 1;
}
cell PSKeyValueS(const char *name, AMX *amx, cell *params)
{
if (params[1]==0)
{
MF_LogError(amx,AMX_ERR_NATIVE,"Invalid particle system handle provided!");
return 0;
}
KeyValueData kvd;
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
kvd.szKeyName=name;
kvd.szValue=MF_GetAmxString(amx,params[2],0,NULL);
kvd.fHandled=0;
//printf("\"%s\" \"%s\"\n",kvd.szKeyName,kvd.szValue);
MDLL_KeyValue(reinterpret_cast<edict_t *>(params[1]),&kvd);
return 1;
}
static cell AMX_NATIVE_CALL ns_set_ps_name(AMX *amx, cell *params)
{
return KVS("targetname");
}
static cell AMX_NATIVE_CALL ns_set_ps_sprite(AMX *amx, cell *params)
{
return KVS("pSprite");
}
static cell AMX_NATIVE_CALL ns_set_ps_genrate(AMX *amx, cell *params)
{
return KVI("pGenRate");
}
static cell AMX_NATIVE_CALL ns_set_ps_genshape(AMX *amx, cell *params)
{
return KVI("pGenShape");
}
static cell AMX_NATIVE_CALL ns_set_ps_genshape_params(AMX *amx, cell *params)
{
return KVS("pGenShapeParams");
}
static cell AMX_NATIVE_CALL ns_set_ps_spriteframes(AMX *amx, cell *params)
{
return KVI("pSpriteNumFrames");
}
static cell AMX_NATIVE_CALL ns_set_ps_numparticles(AMX *amx, cell *params)
{
return KVI("pNumParticles");
}
static cell AMX_NATIVE_CALL ns_set_ps_size(AMX *amx, cell *params)
{
return KVF("pSize");
}
static cell AMX_NATIVE_CALL ns_set_ps_vel_params(AMX *amx, cell *params)
{
return KVS("pVelParams");
}
static cell AMX_NATIVE_CALL ns_set_ps_vel_shape(AMX *amx, cell *params)
{
return KVI("pVelShape");
}
static cell AMX_NATIVE_CALL ns_set_ps_sys_life(AMX *amx, cell *params)
{
return KVF("pSystemLifetime");
}
static cell AMX_NATIVE_CALL ns_set_ps_particle_life(AMX *amx, cell *params)
{
return KVF("pLifetime");
}
static cell AMX_NATIVE_CALL ns_set_ps_rendermode(AMX *amx, cell *params)
{
return KVI("pRenderMode");
}
static cell AMX_NATIVE_CALL ns_set_ps_to_gen(AMX *amx, cell *params)
{
return KVS("pPSToGen");
}
static cell AMX_NATIVE_CALL ns_set_ps_anim_speed(AMX *amx, cell *params)
{
return KVI("pAnimationSpeed");
}
static cell AMX_NATIVE_CALL ns_set_ps_spawn_flags(AMX *amx, cell *params)
{
return KVI("spawnflags");
}
static cell AMX_NATIVE_CALL ns_set_ps_base_color(AMX *amx, cell *params)
{
return KVS("pBaseColor");
}
static cell AMX_NATIVE_CALL ns_set_ps_scale(AMX *amx, cell *params)
{
return KVF("pScale");
}
static cell AMX_NATIVE_CALL ns_set_ps_max_alpha(AMX *amx, cell *params)
{
return KVF("pMaxAlpha");
}
// ns_create_partsys(const name[], pGenShape, const pGenShapeParams[], pGenRate, const pSprite[],
// pSpriteFrames, pNumParticles, Float:pSize, const pVelParams[], pVelShape,
// Float:pSystemLifetime, Float:pParticleLifetime, pRenderMode, const pPSToGen[], pAnimationSpeed, pSpawnFlags)
static cell AMX_NATIVE_CALL ns_create_partsys(AMX *amx, cell *params)
{
return (cell)CREATE_NAMED_ENTITY(MAKE_STRING("env_particles_custom"));
};
static cell AMX_NATIVE_CALL ns_spawn_ps(AMX *amx, cell *params)
{
if (params[1]==0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid particle system handle");
return 0;
}
edict_t *Ent=reinterpret_cast<edict_t *>(params[1]);
MDLL_Spawn(Ent);
if (!Ent->free)
{
REMOVE_ENTITY(Ent);
}
return ParticleMan.Add(STRING(Ent->v.targetname),0);
}
// ns_fire_ps(Particle:id,Float:origin[3],Float:angles[3],flags=0)
static cell AMX_NATIVE_CALL ns_fire_partsys(AMX *amx, cell *params)
{
float *origin=(float*)MF_GetAmxAddr(amx,params[2]);
float *angles=(float*)MF_GetAmxAddr(amx,params[3]);
ParticleMan.FireSystem(static_cast<int>(params[1]),origin,angles,static_cast<int>(params[4]));
return 0;
};
static cell AMX_NATIVE_CALL ns_get_partsys_id(AMX *amx, cell *params)
{
return ParticleMan.Find(MF_GetAmxString(amx,params[1],0,NULL));;
};
AMX_NATIVE_INFO particle_natives[] = {
{ "ns_create_ps", ns_create_partsys },
{ "ns_set_ps_name", ns_set_ps_name },
{ "ns_set_ps_sprite", ns_set_ps_sprite },
{ "ns_set_ps_genrate", ns_set_ps_genrate },
{ "ns_set_ps_genshape", ns_set_ps_genshape },
{ "ns_set_ps_genshape_params", ns_set_ps_genshape_params },
{ "ns_set_ps_spriteframes", ns_set_ps_spriteframes },
{ "ns_set_ps_numparticles", ns_set_ps_numparticles },
{ "ns_set_ps_size", ns_set_ps_size },
{ "ns_set_ps_vel_params", ns_set_ps_vel_params },
{ "ns_set_ps_vel_shape", ns_set_ps_vel_shape },
{ "ns_set_ps_sys_life", ns_set_ps_sys_life },
{ "ns_set_ps_particle_life", ns_set_ps_particle_life },
{ "ns_set_ps_rendermode", ns_set_ps_rendermode },
{ "ns_set_ps_to_gen", ns_set_ps_to_gen },
{ "ns_set_ps_anim_speed", ns_set_ps_anim_speed },
{ "ns_set_ps_spawn_flags", ns_set_ps_spawn_flags },
{ "ns_set_ps_base_color", ns_set_ps_base_color },
{ "ns_set_ps_scale", ns_set_ps_scale },
{ "ns_set_ps_max_alpha", ns_set_ps_max_alpha },
{ "ns_spawn_ps", ns_spawn_ps },
{ "ns_fire_ps", ns_fire_partsys },
{ "ns_get_ps_id", ns_get_partsys_id },
{ NULL, NULL }
};
void AddNatives_Particles()
{
MF_AddNatives(particle_natives);
}
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "ParticleManager.h"
#include <am-vector.h>
#include <am-string.h>
#define KVI(__KEY) PSKeyValueI(__KEY,amx,params)
#define KVF(__KEY) PSKeyValueF(__KEY,amx,params)
#define KVS(__KEY) PSKeyValueS(__KEY,amx,params)
#define NEXT params[__pcount++]
typedef enum partsystype_e
{
PSYS_TYPE_INT,
PSYS_TYPE_FLOAT,
PSYS_TYPE_STRING
}partsystype;
typedef struct partsyskey_s
{
const char *Name;
partsystype type;
}partsyskey;
cell PSKeyValueI(const char *name, AMX *amx, cell *params)
{
if (params[1]==0)
{
MF_LogError(amx,AMX_ERR_NATIVE,"Invalid particle system handle provided!");
return 0;
}
KeyValueData kvd;
char StrData[1024];
UTIL_Format(StrData, sizeof(StrData)-1, "%d", params[2]);
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
kvd.szKeyName=name;
kvd.szValue=&StrData[0];
kvd.fHandled=0;
//printf("\"%s\" \"%s\"\n",kvd.szKeyName,kvd.szValue);
MDLL_KeyValue(reinterpret_cast<edict_t *>(params[1]),&kvd);
return 1;
}
cell PSKeyValueF(const char *name, AMX *amx, cell *params)
{
if (params[1]==0)
{
MF_LogError(amx,AMX_ERR_NATIVE,"Invalid particle system handle provided!");
return 0;
}
KeyValueData kvd;
char StrData[1024];
UTIL_Format(StrData, sizeof(StrData)-1, "%f", amx_ctof2(params[2]));
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
kvd.szKeyName=name;
kvd.szValue=&StrData[0];
kvd.fHandled=0;
//printf("\"%s\" \"%s\"\n",kvd.szKeyName,kvd.szValue);
MDLL_KeyValue(reinterpret_cast<edict_t *>(params[1]),&kvd);
return 1;
}
cell PSKeyValueS(const char *name, AMX *amx, cell *params)
{
if (params[1]==0)
{
MF_LogError(amx,AMX_ERR_NATIVE,"Invalid particle system handle provided!");
return 0;
}
KeyValueData kvd;
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
kvd.szKeyName=name;
kvd.szValue=MF_GetAmxString(amx,params[2],0,NULL);
kvd.fHandled=0;
//printf("\"%s\" \"%s\"\n",kvd.szKeyName,kvd.szValue);
MDLL_KeyValue(reinterpret_cast<edict_t *>(params[1]),&kvd);
return 1;
}
static cell AMX_NATIVE_CALL ns_set_ps_name(AMX *amx, cell *params)
{
return KVS("targetname");
}
static cell AMX_NATIVE_CALL ns_set_ps_sprite(AMX *amx, cell *params)
{
return KVS("pSprite");
}
static cell AMX_NATIVE_CALL ns_set_ps_genrate(AMX *amx, cell *params)
{
return KVI("pGenRate");
}
static cell AMX_NATIVE_CALL ns_set_ps_genshape(AMX *amx, cell *params)
{
return KVI("pGenShape");
}
static cell AMX_NATIVE_CALL ns_set_ps_genshape_params(AMX *amx, cell *params)
{
return KVS("pGenShapeParams");
}
static cell AMX_NATIVE_CALL ns_set_ps_spriteframes(AMX *amx, cell *params)
{
return KVI("pSpriteNumFrames");
}
static cell AMX_NATIVE_CALL ns_set_ps_numparticles(AMX *amx, cell *params)
{
return KVI("pNumParticles");
}
static cell AMX_NATIVE_CALL ns_set_ps_size(AMX *amx, cell *params)
{
return KVF("pSize");
}
static cell AMX_NATIVE_CALL ns_set_ps_vel_params(AMX *amx, cell *params)
{
return KVS("pVelParams");
}
static cell AMX_NATIVE_CALL ns_set_ps_vel_shape(AMX *amx, cell *params)
{
return KVI("pVelShape");
}
static cell AMX_NATIVE_CALL ns_set_ps_sys_life(AMX *amx, cell *params)
{
return KVF("pSystemLifetime");
}
static cell AMX_NATIVE_CALL ns_set_ps_particle_life(AMX *amx, cell *params)
{
return KVF("pLifetime");
}
static cell AMX_NATIVE_CALL ns_set_ps_rendermode(AMX *amx, cell *params)
{
return KVI("pRenderMode");
}
static cell AMX_NATIVE_CALL ns_set_ps_to_gen(AMX *amx, cell *params)
{
return KVS("pPSToGen");
}
static cell AMX_NATIVE_CALL ns_set_ps_anim_speed(AMX *amx, cell *params)
{
return KVI("pAnimationSpeed");
}
static cell AMX_NATIVE_CALL ns_set_ps_spawn_flags(AMX *amx, cell *params)
{
return KVI("spawnflags");
}
static cell AMX_NATIVE_CALL ns_set_ps_base_color(AMX *amx, cell *params)
{
return KVS("pBaseColor");
}
static cell AMX_NATIVE_CALL ns_set_ps_scale(AMX *amx, cell *params)
{
return KVF("pScale");
}
static cell AMX_NATIVE_CALL ns_set_ps_max_alpha(AMX *amx, cell *params)
{
return KVF("pMaxAlpha");
}
// ns_create_partsys(const name[], pGenShape, const pGenShapeParams[], pGenRate, const pSprite[],
// pSpriteFrames, pNumParticles, Float:pSize, const pVelParams[], pVelShape,
// Float:pSystemLifetime, Float:pParticleLifetime, pRenderMode, const pPSToGen[], pAnimationSpeed, pSpawnFlags)
static cell AMX_NATIVE_CALL ns_create_partsys(AMX *amx, cell *params)
{
return (cell)CREATE_NAMED_ENTITY(MAKE_STRING("env_particles_custom"));
};
static cell AMX_NATIVE_CALL ns_spawn_ps(AMX *amx, cell *params)
{
if (params[1]==0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid particle system handle");
return 0;
}
edict_t *Ent=reinterpret_cast<edict_t *>(params[1]);
MDLL_Spawn(Ent);
if (!Ent->free)
{
REMOVE_ENTITY(Ent);
}
return ParticleMan.Add(STRING(Ent->v.targetname),0);
}
// ns_fire_ps(Particle:id,Float:origin[3],Float:angles[3],flags=0)
static cell AMX_NATIVE_CALL ns_fire_partsys(AMX *amx, cell *params)
{
float *origin=(float*)MF_GetAmxAddr(amx,params[2]);
float *angles=(float*)MF_GetAmxAddr(amx,params[3]);
ParticleMan.FireSystem(static_cast<int>(params[1]),origin,angles,static_cast<int>(params[4]));
return 0;
};
static cell AMX_NATIVE_CALL ns_get_partsys_id(AMX *amx, cell *params)
{
return ParticleMan.Find(MF_GetAmxString(amx,params[1],0,NULL));;
};
AMX_NATIVE_INFO particle_natives[] = {
{ "ns_create_ps", ns_create_partsys },
{ "ns_set_ps_name", ns_set_ps_name },
{ "ns_set_ps_sprite", ns_set_ps_sprite },
{ "ns_set_ps_genrate", ns_set_ps_genrate },
{ "ns_set_ps_genshape", ns_set_ps_genshape },
{ "ns_set_ps_genshape_params", ns_set_ps_genshape_params },
{ "ns_set_ps_spriteframes", ns_set_ps_spriteframes },
{ "ns_set_ps_numparticles", ns_set_ps_numparticles },
{ "ns_set_ps_size", ns_set_ps_size },
{ "ns_set_ps_vel_params", ns_set_ps_vel_params },
{ "ns_set_ps_vel_shape", ns_set_ps_vel_shape },
{ "ns_set_ps_sys_life", ns_set_ps_sys_life },
{ "ns_set_ps_particle_life", ns_set_ps_particle_life },
{ "ns_set_ps_rendermode", ns_set_ps_rendermode },
{ "ns_set_ps_to_gen", ns_set_ps_to_gen },
{ "ns_set_ps_anim_speed", ns_set_ps_anim_speed },
{ "ns_set_ps_spawn_flags", ns_set_ps_spawn_flags },
{ "ns_set_ps_base_color", ns_set_ps_base_color },
{ "ns_set_ps_scale", ns_set_ps_scale },
{ "ns_set_ps_max_alpha", ns_set_ps_max_alpha },
{ "ns_spawn_ps", ns_spawn_ps },
{ "ns_fire_ps", ns_fire_partsys },
{ "ns_get_ps_id", ns_get_partsys_id },
{ NULL, NULL }
};
void AddNatives_Particles()
{
MF_AddNatives(particle_natives);
}

View File

@ -10,261 +10,261 @@
//
// Natural Selection Module
//
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "GameManager.h"
#include "CPlayer.h"
#include "AllocString.h"
StringManager AllocStringList;
// ns_set_player_model(id,const Model[]="")
static cell AMX_NATIVE_CALL ns_set_player_model(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
player->SetModel(MF_GetAmxString(amx,params[2],0,NULL));
GameMan.HookPostThink_Post();
return 1;
}
// ns_set_player_skin(id,skin=-1)
static cell AMX_NATIVE_CALL ns_set_player_skin(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
player->SetSkin(params[2]);
GameMan.HookPostThink_Post();
return 1;
}
// ns_set_player_body(id,body=-1)
static cell AMX_NATIVE_CALL ns_set_player_body(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
player->SetBody(params[2]);
GameMan.HookPostThink_Post();
return 1;
}
// ns_get_class(id)
static cell AMX_NATIVE_CALL ns_get_class(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
return player->GetClass();
}
// ns_get_jpfuel(id)
static cell AMX_NATIVE_CALL ns_get_jpfuel(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
REAL ret=(player->GetPev()->fuser3) / 10.0;
return amx_ftoc2(ret);
}
// ns_set_jpfuel(id,Float:fuelpercent)
static cell AMX_NATIVE_CALL ns_set_jpfuel(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
REAL fuel = amx_ctof2(params[2]);
if (fuel > 100.0)
{
fuel = 100.0;
}
if (fuel < 0.0)
{
fuel = 0.0;
}
player->GetPev()->fuser3 = fuel * 10.0;
return 1;
}
static cell AMX_NATIVE_CALL ns_add_jpfuel(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
REAL fuel = clamp(amx_ctof2(params[2]),0.0,100.0);
return amx_ftoc2(player->GetPev()->fuser3 = clamp(static_cast<float>(player->GetPev()->fuser3 + (fuel * 10.0)),static_cast<float>(0.0)));
};
// ns_get_speedchange(index)
static cell AMX_NATIVE_CALL ns_get_speedchange(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
return player->GetSpeedChange();
}
// ns_set_speedchange(index,speedchange=0)
static cell AMX_NATIVE_CALL ns_set_speedchange(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
player->SetSpeedChange(params[2]);
// Update PreThink_Post if we need to
GameMan.HookPreThink_Post();
return 1;
}
// ns_get_maxspeed(index) (returns the max speed of the player BEFORE speed change is factored in.)
static cell AMX_NATIVE_CALL ns_get_maxspeed(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
return player->GetMaxSpeed();
}
// ns_set_fov(id,Float:fov);
static cell AMX_NATIVE_CALL ns_set_fov(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
return player->SetFOV(amx_ctof3(&params[2]));
}
// ns_giveiteM(id,"item");
static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
char *classname = MF_GetAmxString(amx,params[2],0,NULL);
if (!player->IsConnected())
{
return 0;
}
if (player->GetPev()->deadflag > 0)
{
return 0;
}
edict_t *object=CREATE_NAMED_ENTITY(ALLOC_STRING2(classname));
if (!object)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Error creating entity \"%s\"", classname);
return 0;
}
SET_ORIGIN(object,player->GetPev()->origin); // move to player
gpGamedllFuncs->dllapi_table->pfnSpawn(object); // emulate spawn
object->v.flags |= FL_ONGROUND; // make it think it's touched the ground
gpGamedllFuncs->dllapi_table->pfnThink(object); //
gpGamedllFuncs->dllapi_table->pfnTouch(object,player->GetEdict()); // give it to the player
return 1;
}
static cell AMX_NATIVE_CALL ns_get_user_team(AMX* amx, cell* params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
int team = player->GetPev()->team;
if (team > 4 || team < 0)
{
MF_SetAmxString(amx, params[2], "undefinedteam", params[3]);
return 0;
}
switch (team)
{
case 0:
{
// iuser1 means readyroom (I think!)
if (player->GetPev()->iuser1 == 0)
{
MF_SetAmxString(amx, params[2], "undefinedteam", params[3]);
return 0;
}
MF_SetAmxString(amx, params[2], "spectatorteam", params[3]);
return 0;
}
case 1:
{
MF_SetAmxString(amx, params[2], "marine1team", params[3]);
return 1;
}
case 2:
{
MF_SetAmxString(amx, params[2], "alien1team", params[3]);
return 2;
}
case 3:
{
MF_SetAmxString(amx, params[2], "marine2team", params[3]);
return 3;
}
case 4:
{
MF_SetAmxString(amx, params[2], "alien2team", params[3]);
return 4;
}
default:
{
break;
}
}
MF_SetAmxString(amx, params[2], "spectatorteam", params[3]);
return 0;
}
AMX_NATIVE_INFO player_natives[] = {
{ "ns_set_player_model", ns_set_player_model },
{ "ns_set_player_skin", ns_set_player_skin },
{ "ns_set_player_body", ns_set_player_body },
{ "ns_get_class", ns_get_class },
{ "ns_get_jpfuel", ns_get_jpfuel },
{ "ns_set_jpfuel", ns_set_jpfuel },
{ "ns_add_jpfuel", ns_add_jpfuel },
{ "ns_get_energy", ns_get_jpfuel }, // They do the same thing...
{ "ns_set_energy", ns_set_jpfuel }, //
{ "ns_add_energy", ns_add_jpfuel },
{ "ns_get_speedchange", ns_get_speedchange },
{ "ns_set_speedchange", ns_set_speedchange },
{ "ns_get_maxspeed", ns_get_maxspeed },
{ "ns_set_fov", ns_set_fov },
{ "ns_give_item", ns_giveitem },
{ "ns_get_user_team", ns_get_user_team },
{ NULL, NULL }
};
void AddNatives_Player()
{
MF_AddNatives(player_natives);
}
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "GameManager.h"
#include "CPlayer.h"
#include "AllocString.h"
StringManager AllocStringList;
// ns_set_player_model(id,const Model[]="")
static cell AMX_NATIVE_CALL ns_set_player_model(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
player->SetModel(MF_GetAmxString(amx,params[2],0,NULL));
GameMan.HookPostThink_Post();
return 1;
}
// ns_set_player_skin(id,skin=-1)
static cell AMX_NATIVE_CALL ns_set_player_skin(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
player->SetSkin(params[2]);
GameMan.HookPostThink_Post();
return 1;
}
// ns_set_player_body(id,body=-1)
static cell AMX_NATIVE_CALL ns_set_player_body(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
player->SetBody(params[2]);
GameMan.HookPostThink_Post();
return 1;
}
// ns_get_class(id)
static cell AMX_NATIVE_CALL ns_get_class(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
return player->GetClass();
}
// ns_get_jpfuel(id)
static cell AMX_NATIVE_CALL ns_get_jpfuel(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
REAL ret=(player->GetPev()->fuser3) / 10.0;
return amx_ftoc2(ret);
}
// ns_set_jpfuel(id,Float:fuelpercent)
static cell AMX_NATIVE_CALL ns_set_jpfuel(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
REAL fuel = amx_ctof2(params[2]);
if (fuel > 100.0)
{
fuel = 100.0;
}
if (fuel < 0.0)
{
fuel = 0.0;
}
player->GetPev()->fuser3 = fuel * 10.0;
return 1;
}
static cell AMX_NATIVE_CALL ns_add_jpfuel(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
REAL fuel = clamp(amx_ctof2(params[2]),0.0,100.0);
return amx_ftoc2(player->GetPev()->fuser3 = clamp(static_cast<float>(player->GetPev()->fuser3 + (fuel * 10.0)),static_cast<float>(0.0)));
};
// ns_get_speedchange(index)
static cell AMX_NATIVE_CALL ns_get_speedchange(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
return player->GetSpeedChange();
}
// ns_set_speedchange(index,speedchange=0)
static cell AMX_NATIVE_CALL ns_set_speedchange(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
player->SetSpeedChange(params[2]);
// Update PreThink_Post if we need to
GameMan.HookPreThink_Post();
return 1;
}
// ns_get_maxspeed(index) (returns the max speed of the player BEFORE speed change is factored in.)
static cell AMX_NATIVE_CALL ns_get_maxspeed(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
return player->GetMaxSpeed();
}
// ns_set_fov(id,Float:fov);
static cell AMX_NATIVE_CALL ns_set_fov(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
return player->SetFOV(amx_ctof3(&params[2]));
}
// ns_giveiteM(id,"item");
static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
char *classname = MF_GetAmxString(amx,params[2],0,NULL);
if (!player->IsConnected())
{
return 0;
}
if (player->GetPev()->deadflag > 0)
{
return 0;
}
edict_t *object=CREATE_NAMED_ENTITY(ALLOC_STRING2(classname));
if (!object)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Error creating entity \"%s\"", classname);
return 0;
}
SET_ORIGIN(object,player->GetPev()->origin); // move to player
gpGamedllFuncs->dllapi_table->pfnSpawn(object); // emulate spawn
object->v.flags |= FL_ONGROUND; // make it think it's touched the ground
gpGamedllFuncs->dllapi_table->pfnThink(object); //
gpGamedllFuncs->dllapi_table->pfnTouch(object,player->GetEdict()); // give it to the player
return 1;
}
static cell AMX_NATIVE_CALL ns_get_user_team(AMX* amx, cell* params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
int team = player->GetPev()->team;
if (team > 4 || team < 0)
{
MF_SetAmxString(amx, params[2], "undefinedteam", params[3]);
return 0;
}
switch (team)
{
case 0:
{
// iuser1 means readyroom (I think!)
if (player->GetPev()->iuser1 == 0)
{
MF_SetAmxString(amx, params[2], "undefinedteam", params[3]);
return 0;
}
MF_SetAmxString(amx, params[2], "spectatorteam", params[3]);
return 0;
}
case 1:
{
MF_SetAmxString(amx, params[2], "marine1team", params[3]);
return 1;
}
case 2:
{
MF_SetAmxString(amx, params[2], "alien1team", params[3]);
return 2;
}
case 3:
{
MF_SetAmxString(amx, params[2], "marine2team", params[3]);
return 3;
}
case 4:
{
MF_SetAmxString(amx, params[2], "alien2team", params[3]);
return 4;
}
default:
{
break;
}
}
MF_SetAmxString(amx, params[2], "spectatorteam", params[3]);
return 0;
}
AMX_NATIVE_INFO player_natives[] = {
{ "ns_set_player_model", ns_set_player_model },
{ "ns_set_player_skin", ns_set_player_skin },
{ "ns_set_player_body", ns_set_player_body },
{ "ns_get_class", ns_get_class },
{ "ns_get_jpfuel", ns_get_jpfuel },
{ "ns_set_jpfuel", ns_set_jpfuel },
{ "ns_add_jpfuel", ns_add_jpfuel },
{ "ns_get_energy", ns_get_jpfuel }, // They do the same thing...
{ "ns_set_energy", ns_set_jpfuel }, //
{ "ns_add_energy", ns_add_jpfuel },
{ "ns_get_speedchange", ns_get_speedchange },
{ "ns_set_speedchange", ns_set_speedchange },
{ "ns_get_maxspeed", ns_get_maxspeed },
{ "ns_set_fov", ns_set_fov },
{ "ns_give_item", ns_giveitem },
{ "ns_get_user_team", ns_get_user_team },
{ NULL, NULL }
};
void AddNatives_Player()
{
MF_AddNatives(player_natives);
}

View File

@ -10,418 +10,418 @@
//
// Natural Selection Module
//
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "GameManager.h"
#include "CPlayer.h"
// Float:ns_get_res(Player)
static cell AMX_NATIVE_CALL ns_get_res(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return amx_ftoc2(get_private_f(player->GetEdict(),MAKE_OFFSET(RESOURCES)));
}
// ns_set_res(Player,Float:res)
static cell AMX_NATIVE_CALL ns_set_res(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
set_private_f(player->GetEdict(),MAKE_OFFSET(RESOURCES),amx_ctof2(params[2]));
return 1;
}
// Float:ns_add_res(Player,Float:res)
static cell AMX_NATIVE_CALL ns_add_res(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return amx_ftoc2(inc_private_f(player->GetEdict(),MAKE_OFFSET(RESOURCES),amx_ctof2(params[2]),0.0,100.0));
}
// Float:ns_get_exp(Player)
static cell AMX_NATIVE_CALL ns_get_exp(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return amx_ftoc2(get_private_f(player->GetEdict(),MAKE_OFFSET(EXP)));
}
// ns_set_exp(Player,Float:exp)
static cell AMX_NATIVE_CALL ns_set_exp(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
set_private_f(player->GetEdict(),MAKE_OFFSET(EXP),amx_ctof2(params[2]));
return 1;
}
// Float:ns_add_exp(Player,Float:exp)
static cell AMX_NATIVE_CALL ns_add_exp(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return amx_ftoc2(inc_private_f(player->GetEdict(),MAKE_OFFSET(EXP),amx_ctof2(params[2]),0.0));
}
// ns_get_points(Player)
static cell AMX_NATIVE_CALL ns_get_points(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return get_private(player->GetEdict(),MAKE_OFFSET(POINTS));
}
// ns_set_points(Player,points)
static cell AMX_NATIVE_CALL ns_set_points(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx, params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
set_private(player->GetEdict(),MAKE_OFFSET(POINTS),static_cast<int>(params[2]));
return 1;
}
// ns_add_points(Player,points)
static cell AMX_NATIVE_CALL ns_add_points(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx, params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return inc_private(player->GetEdict(),MAKE_OFFSET(POINTS),static_cast<int>(params[2]),0,9);
}
static cell AMX_NATIVE_CALL ns_get_score(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
return get_private(player->GetEdict(),MAKE_OFFSET(SCORE));
}
static cell AMX_NATIVE_CALL ns_set_score(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
set_private(player->GetEdict(),MAKE_OFFSET(SCORE),static_cast<int>(params[2]));
return 1;
}
static cell AMX_NATIVE_CALL ns_add_score(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
return inc_private(player->GetEdict(),MAKE_OFFSET(SCORE),static_cast<int>(params[2]));
}
static cell AMX_NATIVE_CALL ns_get_deaths(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
return get_private(player->GetEdict(),MAKE_OFFSET(DEATHS));
}
static cell AMX_NATIVE_CALL ns_set_deaths(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
set_private(player->GetEdict(),MAKE_OFFSET(DEATHS),static_cast<int>(params[2]));
return 1;
}
static cell AMX_NATIVE_CALL ns_add_deaths(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
return inc_private(player->GetEdict(),MAKE_OFFSET(DEATHS),static_cast<int>(params[2]));
}
static cell AMX_NATIVE_CALL ns_get_hive_ability(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
int result = get_private(player->GetEdict(), MAKE_OFFSET(HIVEABILITY));
return (params[2] > 0) ? (result >= params[2] - 1) : result;
}
static cell AMX_NATIVE_CALL ns_remove_upgrade(AMX *amx, cell *params)
{
CreatePlayerPointer(amx, params[1]);
if (!GameMan.IsCombat())
{
return 0;
}
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
// Upgrades are stored in a std::vector<int> in the player's private data
// The integer value represents the impulse for the offset
// std::vector's memory layout is:
// void *start
// void *lastobject
// void *lastreserved
struct upgradevector
{
int *start;
int *end;
int *allocated;
inline int size() { return static_cast<int>((reinterpret_cast<unsigned int>(end) - reinterpret_cast<unsigned int>(start)) / sizeof(int)); }
inline int at(int which) { return start[which]; }
inline void set(int which, int val) { start[which] = val; }
inline bool remove(int val)
{
for (int i = 0; i < this->size(); i++)
{
if (this->at(i) == val)
{
int last = this->size() - 1;
while (i < last)
{
this->set(i, this->at(i + 1));
i++;
}
this->end--;
return true;
}
}
return false;
}
inline void print()
{
printf("size: %d values: ", this->size());
for (int i = 0; i < this->size(); i++)
{
if (i != 0)
printf(", ");
printf("%d", this->at(i));
}
printf("\n");
}
};
upgradevector *bought = reinterpret_cast<upgradevector *>(reinterpret_cast<char *>(player->GetEdict()->pvPrivateData) + MAKE_OFFSET(UPGRADES_BOUGHT));
upgradevector *active = reinterpret_cast<upgradevector *>(reinterpret_cast<char *>(player->GetEdict()->pvPrivateData) + MAKE_OFFSET(UPGRADES_ACTIVE));
//bought->print();
//active->print();
bool bfound = bought->remove(params[2]);
bool afound = active->remove(params[2]);
if (bfound)
{
if (afound)
{
return 2;
}
return 1;
}
if (afound)
{
// shouldn't happen, but just incase
return 3;
}
return 0;
}
AMX_NATIVE_INFO player_memory_natives[] = {
{ "ns_get_res", ns_get_res },
{ "ns_set_res", ns_set_res },
{ "ns_add_res", ns_add_res },
{ "ns_get_exp", ns_get_exp },
{ "ns_set_exp", ns_set_exp },
{ "ns_add_exp", ns_add_exp },
{ "ns_get_points", ns_get_points },
{ "ns_set_points", ns_set_points },
{ "ns_add_points", ns_add_points },
{ "ns_set_score", ns_set_score },
{ "ns_get_score", ns_get_score },
{ "ns_add_score", ns_add_score },
{ "ns_get_deaths", ns_get_deaths },
{ "ns_set_deaths", ns_set_deaths },
{ "ns_add_deaths", ns_add_deaths },
{ "ns_get_hive_ability", ns_get_hive_ability },
{ "ns_remove_upgrade", ns_remove_upgrade },
{ NULL, NULL }
};
void AddNatives_PlayerMemory()
{
MF_AddNatives(player_memory_natives);
}
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "GameManager.h"
#include "CPlayer.h"
// Float:ns_get_res(Player)
static cell AMX_NATIVE_CALL ns_get_res(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return amx_ftoc2(get_private_f(player->GetEdict(),MAKE_OFFSET(RESOURCES)));
}
// ns_set_res(Player,Float:res)
static cell AMX_NATIVE_CALL ns_set_res(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
set_private_f(player->GetEdict(),MAKE_OFFSET(RESOURCES),amx_ctof2(params[2]));
return 1;
}
// Float:ns_add_res(Player,Float:res)
static cell AMX_NATIVE_CALL ns_add_res(AMX *amx, cell *params)
{
if (GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return amx_ftoc2(inc_private_f(player->GetEdict(),MAKE_OFFSET(RESOURCES),amx_ctof2(params[2]),0.0,100.0));
}
// Float:ns_get_exp(Player)
static cell AMX_NATIVE_CALL ns_get_exp(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return amx_ftoc2(get_private_f(player->GetEdict(),MAKE_OFFSET(EXP)));
}
// ns_set_exp(Player,Float:exp)
static cell AMX_NATIVE_CALL ns_set_exp(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
set_private_f(player->GetEdict(),MAKE_OFFSET(EXP),amx_ctof2(params[2]));
return 1;
}
// Float:ns_add_exp(Player,Float:exp)
static cell AMX_NATIVE_CALL ns_add_exp(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return amx_ftoc2(inc_private_f(player->GetEdict(),MAKE_OFFSET(EXP),amx_ctof2(params[2]),0.0));
}
// ns_get_points(Player)
static cell AMX_NATIVE_CALL ns_get_points(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return get_private(player->GetEdict(),MAKE_OFFSET(POINTS));
}
// ns_set_points(Player,points)
static cell AMX_NATIVE_CALL ns_set_points(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx, params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
set_private(player->GetEdict(),MAKE_OFFSET(POINTS),static_cast<int>(params[2]));
return 1;
}
// ns_add_points(Player,points)
static cell AMX_NATIVE_CALL ns_add_points(AMX *amx, cell *params)
{
if (!GameMan.IsCombat())
{
return 0;
}
CreatePlayerPointer(amx, params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
return inc_private(player->GetEdict(),MAKE_OFFSET(POINTS),static_cast<int>(params[2]),0,9);
}
static cell AMX_NATIVE_CALL ns_get_score(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
return get_private(player->GetEdict(),MAKE_OFFSET(SCORE));
}
static cell AMX_NATIVE_CALL ns_set_score(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
set_private(player->GetEdict(),MAKE_OFFSET(SCORE),static_cast<int>(params[2]));
return 1;
}
static cell AMX_NATIVE_CALL ns_add_score(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
return inc_private(player->GetEdict(),MAKE_OFFSET(SCORE),static_cast<int>(params[2]));
}
static cell AMX_NATIVE_CALL ns_get_deaths(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
return get_private(player->GetEdict(),MAKE_OFFSET(DEATHS));
}
static cell AMX_NATIVE_CALL ns_set_deaths(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
set_private(player->GetEdict(),MAKE_OFFSET(DEATHS),static_cast<int>(params[2]));
return 1;
}
static cell AMX_NATIVE_CALL ns_add_deaths(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
return inc_private(player->GetEdict(),MAKE_OFFSET(DEATHS),static_cast<int>(params[2]));
}
static cell AMX_NATIVE_CALL ns_get_hive_ability(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
int result = get_private(player->GetEdict(), MAKE_OFFSET(HIVEABILITY));
return (params[2] > 0) ? (result >= params[2] - 1) : result;
}
static cell AMX_NATIVE_CALL ns_remove_upgrade(AMX *amx, cell *params)
{
CreatePlayerPointer(amx, params[1]);
if (!GameMan.IsCombat())
{
return 0;
}
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
// Upgrades are stored in a std::vector<int> in the player's private data
// The integer value represents the impulse for the offset
// std::vector's memory layout is:
// void *start
// void *lastobject
// void *lastreserved
struct upgradevector
{
int *start;
int *end;
int *allocated;
inline int size() { return static_cast<int>((reinterpret_cast<unsigned int>(end) - reinterpret_cast<unsigned int>(start)) / sizeof(int)); }
inline int at(int which) { return start[which]; }
inline void set(int which, int val) { start[which] = val; }
inline bool remove(int val)
{
for (int i = 0; i < this->size(); i++)
{
if (this->at(i) == val)
{
int last = this->size() - 1;
while (i < last)
{
this->set(i, this->at(i + 1));
i++;
}
this->end--;
return true;
}
}
return false;
}
inline void print()
{
printf("size: %d values: ", this->size());
for (int i = 0; i < this->size(); i++)
{
if (i != 0)
printf(", ");
printf("%d", this->at(i));
}
printf("\n");
}
};
upgradevector *bought = reinterpret_cast<upgradevector *>(reinterpret_cast<char *>(player->GetEdict()->pvPrivateData) + MAKE_OFFSET(UPGRADES_BOUGHT));
upgradevector *active = reinterpret_cast<upgradevector *>(reinterpret_cast<char *>(player->GetEdict()->pvPrivateData) + MAKE_OFFSET(UPGRADES_ACTIVE));
//bought->print();
//active->print();
bool bfound = bought->remove(params[2]);
bool afound = active->remove(params[2]);
if (bfound)
{
if (afound)
{
return 2;
}
return 1;
}
if (afound)
{
// shouldn't happen, but just incase
return 3;
}
return 0;
}
AMX_NATIVE_INFO player_memory_natives[] = {
{ "ns_get_res", ns_get_res },
{ "ns_set_res", ns_set_res },
{ "ns_add_res", ns_add_res },
{ "ns_get_exp", ns_get_exp },
{ "ns_set_exp", ns_set_exp },
{ "ns_add_exp", ns_add_exp },
{ "ns_get_points", ns_get_points },
{ "ns_set_points", ns_set_points },
{ "ns_add_points", ns_add_points },
{ "ns_set_score", ns_set_score },
{ "ns_get_score", ns_get_score },
{ "ns_add_score", ns_add_score },
{ "ns_get_deaths", ns_get_deaths },
{ "ns_set_deaths", ns_set_deaths },
{ "ns_add_deaths", ns_add_deaths },
{ "ns_get_hive_ability", ns_get_hive_ability },
{ "ns_remove_upgrade", ns_remove_upgrade },
{ NULL, NULL }
};
void AddNatives_PlayerMemory()
{
MF_AddNatives(player_memory_natives);
}

View File

@ -10,376 +10,376 @@
//
// Natural Selection Module
//
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
int IsValidBuilding[AVH_USER3_MAX + 1] = {
0, // AVH_USER3_NONE = 0,
0, // AVH_USER3_MARINE_PLAYER,
0, // AVH_USER3_COMMANDER_PLAYER,
0, // AVH_USER3_ALIEN_PLAYER1,
0, // AVH_USER3_ALIEN_PLAYER2,
0, // AVH_USER3_ALIEN_PLAYER3,
0, // AVH_USER3_ALIEN_PLAYER4,
0, // AVH_USER3_ALIEN_PLAYER5,
0, // AVH_USER3_ALIEN_EMBRYO,
0, // AVH_USER3_SPAWN_TEAMONE,
0, // AVH_USER3_SPAWN_TEAMTWO,
0, // AVH_USER3_PARTICLE_ON, // only valid for AvHParticleEntity: entindex as int in fuser1, template index stored in fuser2
0, // AVH_USER3_PARTICLE_OFF, // only valid for AvHParticleEntity: particle system handle in fuser1
0, // AVH_USER3_WELD, // float progress (0 - 100) stored in fuser1
0, // AVH_USER3_ALPHA, // fuser1 indicates how much alpha this entity toggles to in commander mode, fuser2 for players
0, // AVH_USER3_MARINEITEM, // Something a friendly marine can pick up
0, // AVH_USER3_WAYPOINT,
2, // AVH_USER3_HIVE,
0, // AVH_USER3_NOBUILD,
0, // AVH_USER3_USEABLE,
0, // AVH_USER3_AUDIO_ON,
0, // AVH_USER3_AUDIO_OFF,
0, // AVH_USER3_FUNC_RESOURCE,
1, // AVH_USER3_COMMANDER_STATION,
1, // AVH_USER3_TURRET_FACTORY,
1, // AVH_USER3_ARMORY,
1, // AVH_USER3_ADVANCED_ARMORY,
1, // AVH_USER3_ARMSLAB,
1, // AVH_USER3_PROTOTYPE_LAB,
1, // AVH_USER3_OBSERVATORY,
0, // AVH_USER3_CHEMLAB,
0, // AVH_USER3_MEDLAB,
0, // AVH_USER3_NUKEPLANT,
1, // AVH_USER3_TURRET,
1, // AVH_USER3_SIEGETURRET,
1, // AVH_USER3_RESTOWER,
0, // AVH_USER3_PLACEHOLDER,
1, // AVH_USER3_INFANTRYPORTAL,
0, // AVH_USER3_NUKE,
0, // AVH_USER3_BREAKABLE,
0, // AVH_USER3_UMBRA,
1, // AVH_USER3_PHASEGATE,
2, // AVH_USER3_DEFENSE_CHAMBER,
2, // AVH_USER3_MOVEMENT_CHAMBER,
2, // AVH_USER3_OFFENSE_CHAMBER,
2, // AVH_USER3_SENSORY_CHAMBER,
2, // AVH_USER3_ALIENRESTOWER,
0, // AVH_USER3_HEAVY,
0, // AVH_USER3_JETPACK,
1, // AVH_USER3_ADVANCED_TURRET_FACTORY,
0, // AVH_USER3_SPAWN_READYROOM,
0, // AVH_USER3_CLIENT_COMMAND,
0, // AVH_USER3_FUNC_ILLUSIONARY,
0, // AVH_USER3_MENU_BUILD,
0, // AVH_USER3_MENU_BUILD_ADVANCED,
0, // AVH_USER3_MENU_ASSIST,
0, // AVH_USER3_MENU_EQUIP,
0, // AVH_USER3_MINE,
0 // AVH_USER3_MAX
};
// ns_build_structure(idStructure);
static cell AMX_NATIVE_CALL ns_build_structure(AMX *amx, cell *params)
{
// Trick NS into thinking that this structure is being spawned from the map
// set the "startbuilt" setting to 1, then remove it.
// "startbuilt" is set as "spawnflag" "1" in the ns.fgd
CreateNonPlayerEdict(amx,params[1]);
if (Entity->free)
{
return 0;
};
if (Entity->v.iuser3 <= AVH_USER3_NONE || Entity->v.iuser3 >= AVH_USER3_MAX)
{
return 0;
}
int StructureType=IsValidBuilding[Entity->v.iuser3];
if (StructureType==0)
{
return 0;
}
if (Entity->v.iuser3==AVH_USER3_HIVE)
{
return 0;
}
// Already set?
if (Entity->v.spawnflags & 1)
{
MDLL_Spawn(Entity);
goto undo_ghost;
}
Entity->v.spawnflags |= 1;
MDLL_Spawn(Entity);
Entity->v.spawnflags &= ~1;
undo_ghost:
if (StructureType==1) // marine, remove "ghost" appearance
{
if (get_private(Entity,MAKE_OFFSET(GHOST_STRUCTURE))!=0)
{
set_private(Entity,MAKE_OFFSET(GHOST_STRUCTURE),0);
Entity->v.rendermode=kRenderNormal;
Entity->v.renderamt=100.0;
}
}
return 1;
};
#define MASK_ELECTRICITY 8192
static cell AMX_NATIVE_CALL ns_get_build(AMX *amx, cell *params)
{
int iLength;
char *buildtype = MF_GetAmxString(amx,params[1],0,&iLength);
int iBuiltOnly = params[2];
int iNumber = params[3];
edict_t* pBuild = NULL;
int iCount=0;
while ((pBuild = UTIL_FindEntityByString(pBuild,"classname",buildtype)) != NULL)
{
if (iBuiltOnly > 0)
{
if (FStrEq("team_advarmory",buildtype) || FStrEq("team_advturretfactory",buildtype))
{
iCount++;
}
else
{
if (pBuild->v.fuser1 >= 1000 || pBuild->v.iuser4 & MASK_ELECTRICITY)
{
iCount++;
}
}
}
else
{
iCount++;
}
if (iNumber > 0 && iCount == iNumber)
return ENTINDEX_NEW(pBuild);
}
return iCount++;
}
static cell AMX_NATIVE_CALL ns_set_hive_trait(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private(Entity,MAKE_OFFSET(HIVE_TRAIT),static_cast<int>(params[2]));
return 1;
}
static cell AMX_NATIVE_CALL ns_get_hive_trait(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return get_private(Entity,MAKE_OFFSET(HIVE_TRAIT));
}
static cell AMX_NATIVE_CALL ns_get_struct_owner(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return get_private(Entity,MAKE_OFFSET(STRUCTOWNER));
}
// ns_set_struct_owner(idStructure,idPlayer) - -1 means no owner
static cell AMX_NATIVE_CALL ns_set_struct_owner(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (params[2] > gpGlobals->maxClients || params[2] < -1)
{
return 0;
}
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private(Entity,MAKE_OFFSET(STRUCTOWNER),params[2]);
return 1;
}
// Float:ns_get_obs_energy(id);
static cell AMX_NATIVE_CALL ns_get_obs_energy(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(get_private(Entity,MAKE_OFFSET(OBS_ENERGY)));
};
// Float:ns_set_obs_energy(id,Float:energy);
static cell AMX_NATIVE_CALL ns_set_obs_energy(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(OBS_ENERGY),amx_ctof2(params[2]));
return 1;
};
// Float:ns_add_obs_energy(id,Float:energy);
static cell AMX_NATIVE_CALL ns_add_obs_energy(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(inc_private_f(Entity,MAKE_OFFSET(OBS_ENERGY),amx_ctof2(params[2]),0.0,100.0));
};
// Float:ns_get_weld_time(idWeldable);
static cell AMX_NATIVE_CALL ns_get_weld_time(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(get_private_f(Entity,MAKE_OFFSET(WELD_TIME)));
};
// ns_set_weld_time(idWeldable,Float:value);
static cell AMX_NATIVE_CALL ns_set_weld_time(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(WELD_TIME),amx_ctof2(params[2]));
return 1;
};
// Float:ns_add_weld_time(idWeldable,Float:value);
static cell AMX_NATIVE_CALL ns_add_weld_time(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(inc_private_f(Entity,MAKE_OFFSET(WELD_TIME),amx_ctof2(params[2]),0.0));
};
// Float:ns_get_weld_done(idWeldable);
static cell AMX_NATIVE_CALL ns_get_weld_done(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(get_private_f(Entity,MAKE_OFFSET(WELD_DONE)));
};
// ns_set_weld_done(idWeldable,Float:value);
static cell AMX_NATIVE_CALL ns_set_weld_done(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(WELD_DONE),amx_ctof2(params[2]));
return 1;
};
// Float:ns_add_weld_done(idWeldable,Float:value);
static cell AMX_NATIVE_CALL ns_add_weld_done(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(inc_private_f(Entity,MAKE_OFFSET(WELD_DONE),amx_ctof2(params[2]),0.0));
};
AMX_NATIVE_INFO structure_natives[] = {
{ "ns_build_structure", ns_build_structure },
{ "ns_get_build", ns_get_build },
{ "ns_get_hive_trait", ns_get_hive_trait },
{ "ns_set_hive_trait", ns_set_hive_trait },
{ "ns_get_struct_owner", ns_get_struct_owner },
{ "ns_set_struct_owner", ns_set_struct_owner },
{ "ns_get_obs_energy", ns_get_obs_energy },
{ "ns_set_obs_energy", ns_set_obs_energy },
{ "ns_add_obs_energy", ns_add_obs_energy },
{ "ns_get_weld_time", ns_get_weld_time },
{ "ns_set_weld_time", ns_set_weld_time },
{ "ns_add_weld_time", ns_add_weld_time },
{ "ns_get_weld_done", ns_get_weld_done },
{ "ns_set_weld_done", ns_set_weld_done },
{ "ns_add_weld_done", ns_add_weld_done },
/* prototypes for natives i have planned */
//{ "ns_get_phase_target", ns_get_phase_target },
//{ "ns_set_phase_target", ns_set_phase_target },
//{ "ns_set_phase_nextuse", ns_set_phase_nextuse },
//{ "ns_get_phase_nextuse", ns_get_phase_nextuse },
//{ "ns_add_phase_nextuse", ns_add_phase_nextuse },
{ NULL, NULL }
};
void AddNatives_Structure()
{
MF_AddNatives(structure_natives);
}
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
int IsValidBuilding[AVH_USER3_MAX + 1] = {
0, // AVH_USER3_NONE = 0,
0, // AVH_USER3_MARINE_PLAYER,
0, // AVH_USER3_COMMANDER_PLAYER,
0, // AVH_USER3_ALIEN_PLAYER1,
0, // AVH_USER3_ALIEN_PLAYER2,
0, // AVH_USER3_ALIEN_PLAYER3,
0, // AVH_USER3_ALIEN_PLAYER4,
0, // AVH_USER3_ALIEN_PLAYER5,
0, // AVH_USER3_ALIEN_EMBRYO,
0, // AVH_USER3_SPAWN_TEAMONE,
0, // AVH_USER3_SPAWN_TEAMTWO,
0, // AVH_USER3_PARTICLE_ON, // only valid for AvHParticleEntity: entindex as int in fuser1, template index stored in fuser2
0, // AVH_USER3_PARTICLE_OFF, // only valid for AvHParticleEntity: particle system handle in fuser1
0, // AVH_USER3_WELD, // float progress (0 - 100) stored in fuser1
0, // AVH_USER3_ALPHA, // fuser1 indicates how much alpha this entity toggles to in commander mode, fuser2 for players
0, // AVH_USER3_MARINEITEM, // Something a friendly marine can pick up
0, // AVH_USER3_WAYPOINT,
2, // AVH_USER3_HIVE,
0, // AVH_USER3_NOBUILD,
0, // AVH_USER3_USEABLE,
0, // AVH_USER3_AUDIO_ON,
0, // AVH_USER3_AUDIO_OFF,
0, // AVH_USER3_FUNC_RESOURCE,
1, // AVH_USER3_COMMANDER_STATION,
1, // AVH_USER3_TURRET_FACTORY,
1, // AVH_USER3_ARMORY,
1, // AVH_USER3_ADVANCED_ARMORY,
1, // AVH_USER3_ARMSLAB,
1, // AVH_USER3_PROTOTYPE_LAB,
1, // AVH_USER3_OBSERVATORY,
0, // AVH_USER3_CHEMLAB,
0, // AVH_USER3_MEDLAB,
0, // AVH_USER3_NUKEPLANT,
1, // AVH_USER3_TURRET,
1, // AVH_USER3_SIEGETURRET,
1, // AVH_USER3_RESTOWER,
0, // AVH_USER3_PLACEHOLDER,
1, // AVH_USER3_INFANTRYPORTAL,
0, // AVH_USER3_NUKE,
0, // AVH_USER3_BREAKABLE,
0, // AVH_USER3_UMBRA,
1, // AVH_USER3_PHASEGATE,
2, // AVH_USER3_DEFENSE_CHAMBER,
2, // AVH_USER3_MOVEMENT_CHAMBER,
2, // AVH_USER3_OFFENSE_CHAMBER,
2, // AVH_USER3_SENSORY_CHAMBER,
2, // AVH_USER3_ALIENRESTOWER,
0, // AVH_USER3_HEAVY,
0, // AVH_USER3_JETPACK,
1, // AVH_USER3_ADVANCED_TURRET_FACTORY,
0, // AVH_USER3_SPAWN_READYROOM,
0, // AVH_USER3_CLIENT_COMMAND,
0, // AVH_USER3_FUNC_ILLUSIONARY,
0, // AVH_USER3_MENU_BUILD,
0, // AVH_USER3_MENU_BUILD_ADVANCED,
0, // AVH_USER3_MENU_ASSIST,
0, // AVH_USER3_MENU_EQUIP,
0, // AVH_USER3_MINE,
0 // AVH_USER3_MAX
};
// ns_build_structure(idStructure);
static cell AMX_NATIVE_CALL ns_build_structure(AMX *amx, cell *params)
{
// Trick NS into thinking that this structure is being spawned from the map
// set the "startbuilt" setting to 1, then remove it.
// "startbuilt" is set as "spawnflag" "1" in the ns.fgd
CreateNonPlayerEdict(amx,params[1]);
if (Entity->free)
{
return 0;
};
if (Entity->v.iuser3 <= AVH_USER3_NONE || Entity->v.iuser3 >= AVH_USER3_MAX)
{
return 0;
}
int StructureType=IsValidBuilding[Entity->v.iuser3];
if (StructureType==0)
{
return 0;
}
if (Entity->v.iuser3==AVH_USER3_HIVE)
{
return 0;
}
// Already set?
if (Entity->v.spawnflags & 1)
{
MDLL_Spawn(Entity);
goto undo_ghost;
}
Entity->v.spawnflags |= 1;
MDLL_Spawn(Entity);
Entity->v.spawnflags &= ~1;
undo_ghost:
if (StructureType==1) // marine, remove "ghost" appearance
{
if (get_private(Entity,MAKE_OFFSET(GHOST_STRUCTURE))!=0)
{
set_private(Entity,MAKE_OFFSET(GHOST_STRUCTURE),0);
Entity->v.rendermode=kRenderNormal;
Entity->v.renderamt=100.0;
}
}
return 1;
};
#define MASK_ELECTRICITY 8192
static cell AMX_NATIVE_CALL ns_get_build(AMX *amx, cell *params)
{
int iLength;
char *buildtype = MF_GetAmxString(amx,params[1],0,&iLength);
int iBuiltOnly = params[2];
int iNumber = params[3];
edict_t* pBuild = NULL;
int iCount=0;
while ((pBuild = UTIL_FindEntityByString(pBuild,"classname",buildtype)) != NULL)
{
if (iBuiltOnly > 0)
{
if (FStrEq("team_advarmory",buildtype) || FStrEq("team_advturretfactory",buildtype))
{
iCount++;
}
else
{
if (pBuild->v.fuser1 >= 1000 || pBuild->v.iuser4 & MASK_ELECTRICITY)
{
iCount++;
}
}
}
else
{
iCount++;
}
if (iNumber > 0 && iCount == iNumber)
return ENTINDEX_NEW(pBuild);
}
return iCount++;
}
static cell AMX_NATIVE_CALL ns_set_hive_trait(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private(Entity,MAKE_OFFSET(HIVE_TRAIT),static_cast<int>(params[2]));
return 1;
}
static cell AMX_NATIVE_CALL ns_get_hive_trait(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return get_private(Entity,MAKE_OFFSET(HIVE_TRAIT));
}
static cell AMX_NATIVE_CALL ns_get_struct_owner(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return get_private(Entity,MAKE_OFFSET(STRUCTOWNER));
}
// ns_set_struct_owner(idStructure,idPlayer) - -1 means no owner
static cell AMX_NATIVE_CALL ns_set_struct_owner(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (params[2] > gpGlobals->maxClients || params[2] < -1)
{
return 0;
}
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private(Entity,MAKE_OFFSET(STRUCTOWNER),params[2]);
return 1;
}
// Float:ns_get_obs_energy(id);
static cell AMX_NATIVE_CALL ns_get_obs_energy(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(get_private(Entity,MAKE_OFFSET(OBS_ENERGY)));
};
// Float:ns_set_obs_energy(id,Float:energy);
static cell AMX_NATIVE_CALL ns_set_obs_energy(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(OBS_ENERGY),amx_ctof2(params[2]));
return 1;
};
// Float:ns_add_obs_energy(id,Float:energy);
static cell AMX_NATIVE_CALL ns_add_obs_energy(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(inc_private_f(Entity,MAKE_OFFSET(OBS_ENERGY),amx_ctof2(params[2]),0.0,100.0));
};
// Float:ns_get_weld_time(idWeldable);
static cell AMX_NATIVE_CALL ns_get_weld_time(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(get_private_f(Entity,MAKE_OFFSET(WELD_TIME)));
};
// ns_set_weld_time(idWeldable,Float:value);
static cell AMX_NATIVE_CALL ns_set_weld_time(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(WELD_TIME),amx_ctof2(params[2]));
return 1;
};
// Float:ns_add_weld_time(idWeldable,Float:value);
static cell AMX_NATIVE_CALL ns_add_weld_time(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(inc_private_f(Entity,MAKE_OFFSET(WELD_TIME),amx_ctof2(params[2]),0.0));
};
// Float:ns_get_weld_done(idWeldable);
static cell AMX_NATIVE_CALL ns_get_weld_done(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(get_private_f(Entity,MAKE_OFFSET(WELD_DONE)));
};
// ns_set_weld_done(idWeldable,Float:value);
static cell AMX_NATIVE_CALL ns_set_weld_done(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(WELD_DONE),amx_ctof2(params[2]));
return 1;
};
// Float:ns_add_weld_done(idWeldable,Float:value);
static cell AMX_NATIVE_CALL ns_add_weld_done(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL)
{
return 0;
}
return amx_ftoc2(inc_private_f(Entity,MAKE_OFFSET(WELD_DONE),amx_ctof2(params[2]),0.0));
};
AMX_NATIVE_INFO structure_natives[] = {
{ "ns_build_structure", ns_build_structure },
{ "ns_get_build", ns_get_build },
{ "ns_get_hive_trait", ns_get_hive_trait },
{ "ns_set_hive_trait", ns_set_hive_trait },
{ "ns_get_struct_owner", ns_get_struct_owner },
{ "ns_set_struct_owner", ns_set_struct_owner },
{ "ns_get_obs_energy", ns_get_obs_energy },
{ "ns_set_obs_energy", ns_set_obs_energy },
{ "ns_add_obs_energy", ns_add_obs_energy },
{ "ns_get_weld_time", ns_get_weld_time },
{ "ns_set_weld_time", ns_set_weld_time },
{ "ns_add_weld_time", ns_add_weld_time },
{ "ns_get_weld_done", ns_get_weld_done },
{ "ns_set_weld_done", ns_set_weld_done },
{ "ns_add_weld_done", ns_add_weld_done },
/* prototypes for natives i have planned */
//{ "ns_get_phase_target", ns_get_phase_target },
//{ "ns_set_phase_target", ns_set_phase_target },
//{ "ns_set_phase_nextuse", ns_set_phase_nextuse },
//{ "ns_get_phase_nextuse", ns_get_phase_nextuse },
//{ "ns_add_phase_nextuse", ns_add_phase_nextuse },
{ NULL, NULL }
};
void AddNatives_Structure()
{
MF_AddNatives(structure_natives);
}

View File

@ -10,450 +10,450 @@
//
// Natural Selection Module
//
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "GameManager.h"
#include "CPlayer.h"
// ns_has_weapon(idPlayer,NsWeapon,set=0)
static cell AMX_NATIVE_CALL ns_has_weapon(AMX *amx,cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (params[3] == -1)
{
if ((player->GetPev()->weapons & (1<<params[2])) > 0)
{
return 1;
}
}
else
{
if ((player->GetPev()->weapons & (1<<params[2])) > 0)
{
if (params[3] == 0)
{
player->GetPev()->weapons &= ~(1<<params[2]);
return 1;
}
return 0;
}
else
{
if (params[3] == 1)
{
player->GetPev()->weapons |= (1<<params[2]);
return 1;
}
}
return 0;
}
return 0;
}
// ns_set_weap_dmg(WeaponID,Float:damage)
static cell AMX_NATIVE_CALL ns_set_weapon_dmg(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(WEAPDMG),amx_ctof2(params[2]));
return 1;
}
// Float:ns_get_weap_dmg(WeaponID)
static cell AMX_NATIVE_CALL ns_get_weapon_dmg(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
REAL ret=get_private_f(Entity,MAKE_OFFSET(WEAPDMG));
return amx_ftoc2(ret);
}
// ns_set_weap_range(WeaponID,Float:range)
static cell AMX_NATIVE_CALL ns_set_weapon_range(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(WEAPRANGE),amx_ctof2(params[2]));
return 1;
}
// Float:ns_get_weap_range(WeaponID)
static cell AMX_NATIVE_CALL ns_get_weapon_range(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
REAL ret=get_private_f(Entity,MAKE_OFFSET(WEAPRANGE));
return amx_ftoc2(ret);
}
// ns_get_weap_ammo(WeaponID)
static cell AMX_NATIVE_CALL ns_get_weapon_clip(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
return get_private(Entity,MAKE_OFFSET(WEAPCLIP));
}
// ns_set_weap_ammo(WeaponID,ammo)
static cell AMX_NATIVE_CALL ns_set_weapon_clip(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
set_private(Entity,MAKE_OFFSET(WEAPCLIP),params[2]);
return 1;
}
static cell AMX_NATIVE_CALL ns_add_weapon_clip(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
return inc_private(Entity,MAKE_OFFSET(WEAPCLIP),static_cast<int>(params[2]),0);
}
// ns_get_weap_reserve(PlayerID,WeaponType)
static cell AMX_NATIVE_CALL ns_get_weap_reserve(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
switch (params[2])
{
case WEAPON_PISTOL:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_PISTOL));
case WEAPON_LMG:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_LMG));
case WEAPON_SHOTGUN:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_SHOTGUN));
case WEAPON_HMG:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_HMG));
case WEAPON_GRENADE_GUN:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_GL));
case WEAPON_GRENADE:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_HG));
default:
return 0;
}
return 0;
}
static cell AMX_NATIVE_CALL ns_set_weap_reserve(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
switch (params[2])
{
case WEAPON_PISTOL:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_PISTOL),params[3]);
return 1;
case WEAPON_LMG:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_LMG),(int)params[3]);
return 1;
case WEAPON_SHOTGUN:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_SHOTGUN),(int)params[3]);
return 1;
case WEAPON_HMG:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_HMG),(int)params[3]);
return 1;
case WEAPON_GRENADE_GUN:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_GL),(int)params[3]);
return 1;
case WEAPON_GRENADE:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_HG),(int)params[3]);
return 1;
default:
return 0;
}
return 0;
}
static cell AMX_NATIVE_CALL ns_add_weap_reserve(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
switch (params[2])
{
case WEAPON_PISTOL:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_PISTOL),params[3],0);
case WEAPON_LMG:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_LMG),(int)params[3],0);
case WEAPON_SHOTGUN:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_SHOTGUN),(int)params[3],0);
case WEAPON_HMG:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_HMG),(int)params[3],0);
case WEAPON_GRENADE_GUN:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_GL),(int)params[3],0);
case WEAPON_GRENADE:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_HG),(int)params[3],0);
default:
return 0;
}
return 0;
}
// ns_get_weapon(idPlayer,weaponid,&weapontype=0)
static cell AMX_NATIVE_CALL ns_get_weapon(AMX *amx, cell *params)
{
// Peachy did it like this:
// if weapontype is 0, return the primary weapon index of the player
// if weapontype is < 0, return the last inventory weapon index of the player
// otherwise, scan the player's inventory and look for a weapon of the given type
// such as WEAPON_KNIFE, etc, etc
// I added the last parameter, which will byref the weapontype of the weapon found
// returns 0 on failure
// last param default value added to not conflict with his version
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
if (params[2]<0) // find lastinv weapon
{
edict_t *Weapon=private_to_edict(get_private_p<void *>(player->GetEdict(),MAKE_OFFSET(LAST_WEAPON)));
if (Weapon==NULL) // no weapon
{
return 0;
}
if ((params[0] / sizeof(cell))>2) // If this plugin was compiled with peachy's .inc then don't byref
{
*MF_GetAmxAddr_NEW(amx,params[3])=get_private(Weapon,MAKE_OFFSET(WEAPID));
}
return ENTINDEX_NEW(Weapon);
}
if (params[2]==0) // find current weapon
{
edict_t *Weapon=private_to_edict(get_private_p<void *>(player->GetEdict(),MAKE_OFFSET(CURRENT_WEAPON)));
if (Weapon==NULL) // no weapon
{
return 0;
}
if ((params[0] / sizeof(cell))>2) // If this plugin was compiled with peachy's .inc then don't byref
{
*MF_GetAmxAddr_NEW(amx,params[3])=get_private(Weapon,MAKE_OFFSET(WEAPID));
}
return ENTINDEX_NEW(Weapon);
}
// Finding weapon by ID
char **pPlayerItems = reinterpret_cast<char**>(static_cast<char*>(player->GetEdict()->pvPrivateData) + MAKE_OFFSET(PLAYER_ITEMS));
char *pItem;
int weapon=params[2];
for (int i = 0; i < 6; i++)
{
pItem = pPlayerItems[i];
while (pItem)
{
if (*(int *)(pItem + MAKE_OFFSET(WEAPID)) == weapon)
{
return ENTINDEX_NEW(private_to_edict(pItem));
}
else
{
pItem = *(char **)(pItem + MAKE_OFFSET(WEAP_NEXT));
}
}
}
return 0;
}
#ifdef DEVELOPER_BUILD
// ns_find_weapon_offset(idPlayer,"primweapon","lastinvweapon")
static cell AMX_NATIVE_CALL ns_find_weapon_offset(AMX *amx, cell *params)
{
char *SPrimWeapon=MF_GetAmxString(amx,params[2],0,NULL);
char *SLastInv=MF_GetAmxString(amx,params[3],1,NULL);
edict_t *ePlayer=INDEXENT_NEW(params[1]);
// Locate entities by name
edict_t *PrimWeapon=NULL;
edict_t *LastInv=NULL;
edict_t *Temp=NULL;
while ((Temp=UTIL_FindEntityByString(Temp,"classname",SPrimWeapon))!=NULL)
{
if (Temp->v.owner==ePlayer)
{
PrimWeapon=Temp;
break;
}
}
Temp=NULL;
while ((Temp=UTIL_FindEntityByString(Temp,"classname",SLastInv))!=NULL)
{
if (Temp->v.owner==ePlayer)
{
LastInv=Temp;
break;
}
}
if (LastInv == NULL || PrimWeapon == NULL)
{
if (LastInv==NULL)
{
MF_Log("LastInv==NULL");
}
if (PrimWeapon==NULL)
{
MF_Log("PrimWeapon=NULL");
}
return 0;
}
// now iterate through the client's private data until we find the pointer to PrimWeapon/LastInv's offset
unsigned int *Ptr=(unsigned int*)ePlayer->pvPrivateData;
int FoundLastInv=0;
int FoundPrim=0;
size_t count=0;
unsigned int iPrim;
unsigned int iLast;
// so nasty D: this is basically horrible_cast
union bleh
{
void *ptr;
unsigned int ival;
}blah;
blah.ptr=PrimWeapon->pvPrivateData;
iPrim=blah.ival;
blah.ptr=LastInv->pvPrivateData;
iLast=blah.ival;
while (count<4000)
{
if (*Ptr==iLast)
{
MF_Log("Found LastInv: %d",count);
FoundLastInv=1;
}
if (*Ptr==iPrim)
{
MF_Log("Found Primary: %d",count);
FoundPrim=1;
}
if (FoundLastInv && FoundPrim)
{
//break;
}
count+=4;
Ptr++;
}
return 1;
}
#endif
AMX_NATIVE_INFO weapon_natives[] = {
{ "ns_has_weapon", ns_has_weapon },
{ "ns_set_weap_dmg", ns_set_weapon_dmg },
{ "ns_get_weap_dmg", ns_get_weapon_dmg },
{ "ns_set_weap_range", ns_set_weapon_range },
{ "ns_get_weap_range", ns_get_weapon_range },
{ "ns_set_weap_clip", ns_set_weapon_clip },
{ "ns_get_weap_clip", ns_get_weapon_clip },
{ "ns_add_weap_clip", ns_add_weapon_clip },
{ "ns_set_weap_reserve", ns_set_weap_reserve },
{ "ns_get_weap_reserve", ns_get_weap_reserve },
{ "ns_add_weap_reserve", ns_add_weap_reserve },
{ "ns_get_weapon", ns_get_weapon},
#ifdef DEVELOPER_BUILD
{ "ns_find_weapon_offset", ns_find_weapon_offset},
#endif
{ NULL, NULL }
};
void AddNatives_Weapons()
{
MF_AddNatives(weapon_natives);
}
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "GameManager.h"
#include "CPlayer.h"
// ns_has_weapon(idPlayer,NsWeapon,set=0)
static cell AMX_NATIVE_CALL ns_has_weapon(AMX *amx,cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (params[3] == -1)
{
if ((player->GetPev()->weapons & (1<<params[2])) > 0)
{
return 1;
}
}
else
{
if ((player->GetPev()->weapons & (1<<params[2])) > 0)
{
if (params[3] == 0)
{
player->GetPev()->weapons &= ~(1<<params[2]);
return 1;
}
return 0;
}
else
{
if (params[3] == 1)
{
player->GetPev()->weapons |= (1<<params[2]);
return 1;
}
}
return 0;
}
return 0;
}
// ns_set_weap_dmg(WeaponID,Float:damage)
static cell AMX_NATIVE_CALL ns_set_weapon_dmg(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(WEAPDMG),amx_ctof2(params[2]));
return 1;
}
// Float:ns_get_weap_dmg(WeaponID)
static cell AMX_NATIVE_CALL ns_get_weapon_dmg(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
REAL ret=get_private_f(Entity,MAKE_OFFSET(WEAPDMG));
return amx_ftoc2(ret);
}
// ns_set_weap_range(WeaponID,Float:range)
static cell AMX_NATIVE_CALL ns_set_weapon_range(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
set_private_f(Entity,MAKE_OFFSET(WEAPRANGE),amx_ctof2(params[2]));
return 1;
}
// Float:ns_get_weap_range(WeaponID)
static cell AMX_NATIVE_CALL ns_get_weapon_range(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
REAL ret=get_private_f(Entity,MAKE_OFFSET(WEAPRANGE));
return amx_ftoc2(ret);
}
// ns_get_weap_ammo(WeaponID)
static cell AMX_NATIVE_CALL ns_get_weapon_clip(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
return get_private(Entity,MAKE_OFFSET(WEAPCLIP));
}
// ns_set_weap_ammo(WeaponID,ammo)
static cell AMX_NATIVE_CALL ns_set_weapon_clip(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
set_private(Entity,MAKE_OFFSET(WEAPCLIP),params[2]);
return 1;
}
static cell AMX_NATIVE_CALL ns_add_weapon_clip(AMX *amx, cell *params)
{
CreateNonPlayerEdict(amx,params[1]);
if (Entity->pvPrivateData == NULL || Entity->free)
{
return 0;
}
return inc_private(Entity,MAKE_OFFSET(WEAPCLIP),static_cast<int>(params[2]),0);
}
// ns_get_weap_reserve(PlayerID,WeaponType)
static cell AMX_NATIVE_CALL ns_get_weap_reserve(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
switch (params[2])
{
case WEAPON_PISTOL:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_PISTOL));
case WEAPON_LMG:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_LMG));
case WEAPON_SHOTGUN:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_SHOTGUN));
case WEAPON_HMG:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_HMG));
case WEAPON_GRENADE_GUN:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_GL));
case WEAPON_GRENADE:
return get_private(player->GetEdict(),MAKE_OFFSET(AMMO_HG));
default:
return 0;
}
return 0;
}
static cell AMX_NATIVE_CALL ns_set_weap_reserve(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
switch (params[2])
{
case WEAPON_PISTOL:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_PISTOL),params[3]);
return 1;
case WEAPON_LMG:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_LMG),(int)params[3]);
return 1;
case WEAPON_SHOTGUN:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_SHOTGUN),(int)params[3]);
return 1;
case WEAPON_HMG:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_HMG),(int)params[3]);
return 1;
case WEAPON_GRENADE_GUN:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_GL),(int)params[3]);
return 1;
case WEAPON_GRENADE:
set_private(player->GetEdict(),MAKE_OFFSET(AMMO_HG),(int)params[3]);
return 1;
default:
return 0;
}
return 0;
}
static cell AMX_NATIVE_CALL ns_add_weap_reserve(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected() || !player->HasPrivateData())
{
return 0;
}
switch (params[2])
{
case WEAPON_PISTOL:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_PISTOL),params[3],0);
case WEAPON_LMG:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_LMG),(int)params[3],0);
case WEAPON_SHOTGUN:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_SHOTGUN),(int)params[3],0);
case WEAPON_HMG:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_HMG),(int)params[3],0);
case WEAPON_GRENADE_GUN:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_GL),(int)params[3],0);
case WEAPON_GRENADE:
return inc_private(player->GetEdict(),MAKE_OFFSET(AMMO_HG),(int)params[3],0);
default:
return 0;
}
return 0;
}
// ns_get_weapon(idPlayer,weaponid,&weapontype=0)
static cell AMX_NATIVE_CALL ns_get_weapon(AMX *amx, cell *params)
{
// Peachy did it like this:
// if weapontype is 0, return the primary weapon index of the player
// if weapontype is < 0, return the last inventory weapon index of the player
// otherwise, scan the player's inventory and look for a weapon of the given type
// such as WEAPON_KNIFE, etc, etc
// I added the last parameter, which will byref the weapontype of the weapon found
// returns 0 on failure
// last param default value added to not conflict with his version
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
if (!player->HasPrivateData())
{
return 0;
}
if (params[2]<0) // find lastinv weapon
{
edict_t *Weapon=private_to_edict(get_private_p<void *>(player->GetEdict(),MAKE_OFFSET(LAST_WEAPON)));
if (Weapon==NULL) // no weapon
{
return 0;
}
if ((params[0] / sizeof(cell))>2) // If this plugin was compiled with peachy's .inc then don't byref
{
*MF_GetAmxAddr_NEW(amx,params[3])=get_private(Weapon,MAKE_OFFSET(WEAPID));
}
return ENTINDEX_NEW(Weapon);
}
if (params[2]==0) // find current weapon
{
edict_t *Weapon=private_to_edict(get_private_p<void *>(player->GetEdict(),MAKE_OFFSET(CURRENT_WEAPON)));
if (Weapon==NULL) // no weapon
{
return 0;
}
if ((params[0] / sizeof(cell))>2) // If this plugin was compiled with peachy's .inc then don't byref
{
*MF_GetAmxAddr_NEW(amx,params[3])=get_private(Weapon,MAKE_OFFSET(WEAPID));
}
return ENTINDEX_NEW(Weapon);
}
// Finding weapon by ID
char **pPlayerItems = reinterpret_cast<char**>(static_cast<char*>(player->GetEdict()->pvPrivateData) + MAKE_OFFSET(PLAYER_ITEMS));
char *pItem;
int weapon=params[2];
for (int i = 0; i < 6; i++)
{
pItem = pPlayerItems[i];
while (pItem)
{
if (*(int *)(pItem + MAKE_OFFSET(WEAPID)) == weapon)
{
return ENTINDEX_NEW(private_to_edict(pItem));
}
else
{
pItem = *(char **)(pItem + MAKE_OFFSET(WEAP_NEXT));
}
}
}
return 0;
}
#ifdef DEVELOPER_BUILD
// ns_find_weapon_offset(idPlayer,"primweapon","lastinvweapon")
static cell AMX_NATIVE_CALL ns_find_weapon_offset(AMX *amx, cell *params)
{
char *SPrimWeapon=MF_GetAmxString(amx,params[2],0,NULL);
char *SLastInv=MF_GetAmxString(amx,params[3],1,NULL);
edict_t *ePlayer=INDEXENT_NEW(params[1]);
// Locate entities by name
edict_t *PrimWeapon=NULL;
edict_t *LastInv=NULL;
edict_t *Temp=NULL;
while ((Temp=UTIL_FindEntityByString(Temp,"classname",SPrimWeapon))!=NULL)
{
if (Temp->v.owner==ePlayer)
{
PrimWeapon=Temp;
break;
}
}
Temp=NULL;
while ((Temp=UTIL_FindEntityByString(Temp,"classname",SLastInv))!=NULL)
{
if (Temp->v.owner==ePlayer)
{
LastInv=Temp;
break;
}
}
if (LastInv == NULL || PrimWeapon == NULL)
{
if (LastInv==NULL)
{
MF_Log("LastInv==NULL");
}
if (PrimWeapon==NULL)
{
MF_Log("PrimWeapon=NULL");
}
return 0;
}
// now iterate through the client's private data until we find the pointer to PrimWeapon/LastInv's offset
unsigned int *Ptr=(unsigned int*)ePlayer->pvPrivateData;
int FoundLastInv=0;
int FoundPrim=0;
size_t count=0;
unsigned int iPrim;
unsigned int iLast;
// so nasty D: this is basically horrible_cast
union bleh
{
void *ptr;
unsigned int ival;
}blah;
blah.ptr=PrimWeapon->pvPrivateData;
iPrim=blah.ival;
blah.ptr=LastInv->pvPrivateData;
iLast=blah.ival;
while (count<4000)
{
if (*Ptr==iLast)
{
MF_Log("Found LastInv: %d",count);
FoundLastInv=1;
}
if (*Ptr==iPrim)
{
MF_Log("Found Primary: %d",count);
FoundPrim=1;
}
if (FoundLastInv && FoundPrim)
{
//break;
}
count+=4;
Ptr++;
}
return 1;
}
#endif
AMX_NATIVE_INFO weapon_natives[] = {
{ "ns_has_weapon", ns_has_weapon },
{ "ns_set_weap_dmg", ns_set_weapon_dmg },
{ "ns_get_weap_dmg", ns_get_weapon_dmg },
{ "ns_set_weap_range", ns_set_weapon_range },
{ "ns_get_weap_range", ns_get_weapon_range },
{ "ns_set_weap_clip", ns_set_weapon_clip },
{ "ns_get_weap_clip", ns_get_weapon_clip },
{ "ns_add_weap_clip", ns_add_weapon_clip },
{ "ns_set_weap_reserve", ns_set_weap_reserve },
{ "ns_get_weap_reserve", ns_get_weap_reserve },
{ "ns_add_weap_reserve", ns_add_weap_reserve },
{ "ns_get_weapon", ns_get_weapon},
#ifdef DEVELOPER_BUILD
{ "ns_find_weapon_offset", ns_find_weapon_offset},
#endif
{ NULL, NULL }
};
void AddNatives_Weapons()
{
MF_AddNatives(weapon_natives);
}

View File

@ -10,174 +10,174 @@
//
// Natural Selection Module
//
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "CPlayer.h"
/**
* Scans through all hives and finds the one currently building
*/
int UTIL_FindBuildingHive(void)
{
edict_t *Entity=NULL;
while ((Entity = UTIL_FindEntityByString(Entity,"classname","team_hive")))
{
// is alive active not fully built
if (Entity->v.health > 0 && Entity->v.solid > 0 && Entity->v.fuser1 < 1000)
{
return ENTINDEX_NEW(Entity);
}
}
return 0;
}
edict_t *UTIL_FindEntityByString(edict_t *Start, const char *Keyword, const char *Value)
{
edict_t *Entity;
Entity=FIND_ENTITY_BY_STRING(Start, Keyword, Value);
if(!FNullEnt(Entity))
{
return Entity;
}
return NULL;
}
/**
* Returns TRUE if the provided native is used in a loaded plugin
* FALSE otherwise.
*/
BOOL UTIL_CheckForNative(const char *NativeName)
{
AMX *amx;
char blah[64];
int FunctionIndex;
int i=0;
strncpy(blah,NativeName,63);
// Loop through all running scripts
while((amx=MF_GetScriptAmx(i++))!=NULL)
{
// Scan for native
if (MF_AmxFindNative(amx, blah, &FunctionIndex) == AMX_ERR_NONE)
{
// Native was found.
return TRUE;
}
}
return FALSE; // no native found in any loaded script
}
/**
* Scans an amxx plugin for a public
* returns whether or not that public exists
*/
BOOL UTIL_CheckForPublic(const char *publicname)
{
AMX *amx;
char blah[64];
int FunctionIndex;
int i=0;
strncpy(blah,publicname,63);
// Loop through all running scripts
while((amx=MF_GetScriptAmx(i++))!=NULL)
{
// Scan for public
if (MF_AmxFindPublic(amx, blah, &FunctionIndex) == AMX_ERR_NONE)
{
// Public was found.
return TRUE;
}
}
return FALSE; // no public found in any loaded script
}
CPlayer *UTIL_PlayerByCID(int CID)
{
int i=0;
while (i++<gpGlobals->maxClients)
{
if (GETPLAYERUSERID(g_player[i].GetEdict())==CID)
{
return &g_player[i];
}
}
return NULL;
}
/**
* Converts a log string (eg: "sawce<1><STEAM_0:1:4560311><marine1team>")
* into a player index
*/
int UTIL_LogToIndex(const char *LogLine)
{
char NameBuffer[33] ; // Temporary buffer to store the CID String
char *StrLocation; // Location in the LogLine pointer
unsigned int Count=0; // Count for how many <'s we've passed
size_t Length; // Length of LogLine
Length=strlen(LogLine);
StrLocation=const_cast<char *>(LogLine) + Length; // Should now point to the last >
while (Length--)
{
if (*StrLocation--=='<')
{
if (++Count==3) // 3rd match is end of CID
{
break;
}
}
}
if (Count!=3) // Invalid name somehow??
{
return 0;
}
if (Length > 32) // The name is too long somehow? stop here...
{
return 0;
}
strncpy(NameBuffer,LogLine,Length);
Count=0;
while ((int)Count++<gpGlobals->maxClients)
{
if (strcmp(NameBuffer,STRING(INDEXENT_NEW(Count)->v.netname))==0)
{
return Count;
}
}
return 0;
}
char *UTIL_ToLowerCase(const char *str)
{
size_t len = strlen(str);
char *buffer = new char[len + 1];
for (size_t i = 0; i < len; i++)
{
if (str[i] >= 'A' && str[i] <= 'Z')
buffer[i] = tolower(str[i]);
else
buffer[i] = str[i];
}
buffer[len] = '\0';
return buffer;
}
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "CPlayer.h"
/**
* Scans through all hives and finds the one currently building
*/
int UTIL_FindBuildingHive(void)
{
edict_t *Entity=NULL;
while ((Entity = UTIL_FindEntityByString(Entity,"classname","team_hive")))
{
// is alive active not fully built
if (Entity->v.health > 0 && Entity->v.solid > 0 && Entity->v.fuser1 < 1000)
{
return ENTINDEX_NEW(Entity);
}
}
return 0;
}
edict_t *UTIL_FindEntityByString(edict_t *Start, const char *Keyword, const char *Value)
{
edict_t *Entity;
Entity=FIND_ENTITY_BY_STRING(Start, Keyword, Value);
if(!FNullEnt(Entity))
{
return Entity;
}
return NULL;
}
/**
* Returns TRUE if the provided native is used in a loaded plugin
* FALSE otherwise.
*/
BOOL UTIL_CheckForNative(const char *NativeName)
{
AMX *amx;
char blah[64];
int FunctionIndex;
int i=0;
strncpy(blah,NativeName,63);
// Loop through all running scripts
while((amx=MF_GetScriptAmx(i++))!=NULL)
{
// Scan for native
if (MF_AmxFindNative(amx, blah, &FunctionIndex) == AMX_ERR_NONE)
{
// Native was found.
return TRUE;
}
}
return FALSE; // no native found in any loaded script
}
/**
* Scans an amxx plugin for a public
* returns whether or not that public exists
*/
BOOL UTIL_CheckForPublic(const char *publicname)
{
AMX *amx;
char blah[64];
int FunctionIndex;
int i=0;
strncpy(blah,publicname,63);
// Loop through all running scripts
while((amx=MF_GetScriptAmx(i++))!=NULL)
{
// Scan for public
if (MF_AmxFindPublic(amx, blah, &FunctionIndex) == AMX_ERR_NONE)
{
// Public was found.
return TRUE;
}
}
return FALSE; // no public found in any loaded script
}
CPlayer *UTIL_PlayerByCID(int CID)
{
int i=0;
while (i++<gpGlobals->maxClients)
{
if (GETPLAYERUSERID(g_player[i].GetEdict())==CID)
{
return &g_player[i];
}
}
return NULL;
}
/**
* Converts a log string (eg: "sawce<1><STEAM_0:1:4560311><marine1team>")
* into a player index
*/
int UTIL_LogToIndex(const char *LogLine)
{
char NameBuffer[33] ; // Temporary buffer to store the CID String
char *StrLocation; // Location in the LogLine pointer
unsigned int Count=0; // Count for how many <'s we've passed
size_t Length; // Length of LogLine
Length=strlen(LogLine);
StrLocation=const_cast<char *>(LogLine) + Length; // Should now point to the last >
while (Length--)
{
if (*StrLocation--=='<')
{
if (++Count==3) // 3rd match is end of CID
{
break;
}
}
}
if (Count!=3) // Invalid name somehow??
{
return 0;
}
if (Length > 32) // The name is too long somehow? stop here...
{
return 0;
}
strncpy(NameBuffer,LogLine,Length);
Count=0;
while ((int)Count++<gpGlobals->maxClients)
{
if (strcmp(NameBuffer,STRING(INDEXENT_NEW(Count)->v.netname))==0)
{
return Count;
}
}
return 0;
}
char *UTIL_ToLowerCase(const char *str)
{
size_t len = strlen(str);
char *buffer = new char[len + 1];
for (size_t i = 0; i < len; i++)
{
if (str[i] >= 'A' && str[i] <= 'Z')
buffer[i] = tolower(str[i]);
else
buffer[i] = str[i];
}
buffer[len] = '\0';
return buffer;
}

View File

@ -10,118 +10,118 @@
//
// Message Stocks
//
#if defined _message_stocks_included
#endinput
#endif
#define _message_stocks_included
/* Creates a death message. */
stock dod_make_deathmsg(killer, victim, weaponNUM)
{
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
write_byte(killer);
write_byte(victim);
write_byte(weaponNUM);
message_end();
return 1;
}
/* Kills a user without a message. */
stock user_silentkill(index)
{
static msgid = 0;
new msgblock;
if (!msgid)
{
msgid = get_user_msgid("DeathMsg");
}
msgblock = get_msg_block(msgid);
set_msg_block(msgid, BLOCK_ONCE);
user_kill(index, 1);
set_msg_block(msgid, msgblock);
return 1;
}
/* Creates a death message. */
stock make_deathmsg(killer, victim, headshot, const weapon[])
{
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
write_byte(killer);
write_byte(victim);
new mod_name[32];
get_modname(mod_name, 31);
if (equal(mod_name, "cstrike") || equal(mod_name, "czero") || equal(mod_name, "csv15") || equal(mod_name, "cs13"))
write_byte(headshot);
write_string(weapon);
message_end();
return 1;
}
/**
* Sends a predefined text message to player.
* Predefined texts are default game messages which will be translated
* to player's game language, e.g. #Game_join_ct.
*
* @note Set index to 0 to send text globally.
*
* @note There does not necessarily have to be a total of 6 arguments.
* It will depend if message takes arguments, e.g.:
* client_printex(id, print_chat, "#Game_join_ct", "Pimp Daddy")
* client_printex(id, print_chat, "1", "#Game_radio", "Pimp Daddy", "Hello world!")
*
* @param index Index of the player, use 0 to send to all players.
* @param type The message destination. See print_* constants.
* @param msg_name The custom or predefined message to send.
* @param msg_param1 Optional message argument.
* @param msg_param2 Optional message argument.
* @param msg_param3 Optional message argument.
* @param msg_param4 Optional message argument.
*
* @noreturn
*/
stock client_printex(index, type, const msg_name[], const msg_param1[] = "", const msg_param2[] = "", const msg_param3[] = "", const msg_param4[] = "")
{
new ch = msg_name[0];
// If not a predefined message, we don't care about it and forward directly to client_print.
// Special case for radio message. msg_name is an index, msg_param1 #Game_radio*, etc. Checking index should be enough.
if (ch != '#' && (type != print_radio || !strtol(msg_name)))
{
return client_print(index, type, msg_name, msg_param1, msg_param2, msg_param3, msg_param4);
}
// Even if message starts with '#', we should check its length for safety.
new length = strlen(msg_name);
// If string is larger than expected, we forward to client_print which will cut message properly.
// This means also this can't be a predefined game message.
// Max console length: 128 = \n (126) + \0 (127)
// Max SayText length: 192 = \n (190) + \0 (191)
if ((length > 126 && (print_notify <= type <= print_console))
|| ( length > 190 && (print_chat <= type <= print_radio)))
{
return client_print(index, type, msg_name, msg_param1, msg_param2, msg_param3, msg_param4);
}
static msgTextMsg;
if (!msgTextMsg)
{
msgTextMsg = get_user_msgid("TextMsg");
}
message_begin(index > 0 ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgTextMsg, .player = index);
write_byte(type);
write_string(msg_name);
if (msg_param1[0]) { write_string(msg_param1); }
if (msg_param2[0]) { write_string(msg_param2); }
if (msg_param3[0]) { write_string(msg_param3); }
if (msg_param4[0]) { write_string(msg_param4); }
message_end();
return 1;
}
#if defined _message_stocks_included
#endinput
#endif
#define _message_stocks_included
/* Creates a death message. */
stock dod_make_deathmsg(killer, victim, weaponNUM)
{
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
write_byte(killer);
write_byte(victim);
write_byte(weaponNUM);
message_end();
return 1;
}
/* Kills a user without a message. */
stock user_silentkill(index)
{
static msgid = 0;
new msgblock;
if (!msgid)
{
msgid = get_user_msgid("DeathMsg");
}
msgblock = get_msg_block(msgid);
set_msg_block(msgid, BLOCK_ONCE);
user_kill(index, 1);
set_msg_block(msgid, msgblock);
return 1;
}
/* Creates a death message. */
stock make_deathmsg(killer, victim, headshot, const weapon[])
{
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
write_byte(killer);
write_byte(victim);
new mod_name[32];
get_modname(mod_name, 31);
if (equal(mod_name, "cstrike") || equal(mod_name, "czero") || equal(mod_name, "csv15") || equal(mod_name, "cs13"))
write_byte(headshot);
write_string(weapon);
message_end();
return 1;
}
/**
* Sends a predefined text message to player.
* Predefined texts are default game messages which will be translated
* to player's game language, e.g. #Game_join_ct.
*
* @note Set index to 0 to send text globally.
*
* @note There does not necessarily have to be a total of 6 arguments.
* It will depend if message takes arguments, e.g.:
* client_printex(id, print_chat, "#Game_join_ct", "Pimp Daddy")
* client_printex(id, print_chat, "1", "#Game_radio", "Pimp Daddy", "Hello world!")
*
* @param index Index of the player, use 0 to send to all players.
* @param type The message destination. See print_* constants.
* @param msg_name The custom or predefined message to send.
* @param msg_param1 Optional message argument.
* @param msg_param2 Optional message argument.
* @param msg_param3 Optional message argument.
* @param msg_param4 Optional message argument.
*
* @noreturn
*/
stock client_printex(index, type, const msg_name[], const msg_param1[] = "", const msg_param2[] = "", const msg_param3[] = "", const msg_param4[] = "")
{
new ch = msg_name[0];
// If not a predefined message, we don't care about it and forward directly to client_print.
// Special case for radio message. msg_name is an index, msg_param1 #Game_radio*, etc. Checking index should be enough.
if (ch != '#' && (type != print_radio || !strtol(msg_name)))
{
return client_print(index, type, msg_name, msg_param1, msg_param2, msg_param3, msg_param4);
}
// Even if message starts with '#', we should check its length for safety.
new length = strlen(msg_name);
// If string is larger than expected, we forward to client_print which will cut message properly.
// This means also this can't be a predefined game message.
// Max console length: 128 = \n (126) + \0 (127)
// Max SayText length: 192 = \n (190) + \0 (191)
if ((length > 126 && (print_notify <= type <= print_console))
|| ( length > 190 && (print_chat <= type <= print_radio)))
{
return client_print(index, type, msg_name, msg_param1, msg_param2, msg_param3, msg_param4);
}
static msgTextMsg;
if (!msgTextMsg)
{
msgTextMsg = get_user_msgid("TextMsg");
}
message_begin(index > 0 ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgTextMsg, .player = index);
write_byte(type);
write_string(msg_name);
if (msg_param1[0]) { write_string(msg_param1); }
if (msg_param2[0]) { write_string(msg_param2); }
if (msg_param3[0]) { write_string(msg_param3); }
if (msg_param4[0]) { write_string(msg_param4); }
message_end();
return 1;
}

View File

@ -6,311 +6,311 @@
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#if defined _newmenus_included
#endinput
#endif
#define _newmenus_included
#define MEXIT_ALL 1 /* Menu will have an exit option (default)*/
#define MEXIT_FORCE 2 /* Menu will have an exit option, even when pagination is disabled.
* There have to be less than 10 items in the menu or it won't appear. The exit
* option will be appended to the last item with no extra slot padding. If you
* want it in the 10th slot you have to pad it manually with menu_addblank2 */
#define MEXIT_NEVER -1 /* Menu will not have an exit option */
#define MPROP_PERPAGE 1 /* Number of items per page (param1 = number, 0=no paginating, 7=default) */
#define MPROP_BACKNAME 2 /* Name of the back button (param1 = string) */
#define MPROP_NEXTNAME 3 /* Name of the next button (param1 = string) */
#define MPROP_EXITNAME 4 /* Name of the exit button (param1 = string) */
#define MPROP_TITLE 5 /* Menu title text (param1 = string) */
#define MPROP_EXIT 6 /* Exit functionality (param1 = number, see MEXIT constants) */
#define MPROP_NOCOLORS 8 /* Sets whether colors are not auto (param1 = number, 0=default) */
#define MPROP_NUMBER_COLOR 10 /* Color indicator to use for numbers (param1 = string, "\r"=default) */
#define MEXIT_NORMAL 0 /* DEPRECATED, do not use (has no effect) */
#define MENUPAD_NONE 0 /* DEPRECATED, do not use (has no effect) */
#define MENUPAD_PAGE 1 /* DEPRECATED, do not use (has no effect) */
#define MPROP_ORDER 7 /* DEPRECATED, do not use (has no effect) */
#define MPROP_PADMENU 9 /* DEPRECATED, do not use (has no effect) */
/**
* @brief Creates a new menu object.
*
* The handler function should be prototyped as:
*
* public <function>(id, menu, item)
* id - Client the menu is being acted upon.
* menu - Menu resource identifier.
* item - Item the client selected. If less than 0, the menu was
* cancelled and the item is a status code. menu_display
* should never be called immediately if the item is a status
* code, for re-entrancy reasons.
*
* The handler function should always return PLUGIN_HANDLED to block
* any old menu handlers from potentially feeding on the menu, unless
* that is the desired functionality.
*
* @param title Title the menu should use.
* @param handler Name of the handler function. The function will be invoked
* once and only once to every menu_display() call.
* @param ml Unused (should be 0).
* @return Menu resource identifier which must be destroyed via
* menu_destroy(). All menus are destroyed when the plugin
* unloads.
* @error Function name not found.
*/
native menu_create(const title[], const handler[], ml=0);
/**
* Creates a menu item callback handler.
*
* The handler function should be prototyped as:
*
* public <function>(id, menu, item)
* id - Client index being displayed to.
* menu - Menu resource identifier.
* item - Item being drawn.
* <return> - ITEM_IGNORE to use the default functionality. ITEM_ENABLED to
* explicitly enable or ITEM_DISABLED to explicitly disable.
*
* @param function Function name.
* @return Menu callback ID.
*/
native menu_makecallback(const function[]);
/**
* Adds an menu to a menu.
*
* @param menu Menu resource identifier.
* @param name Item text to display.
* @param info Item info string for internal information.
* @param paccess Access required by the player viewing the menu.
* @param callback If set to a valid ID from menu_makecallback(), the
* callback will be invoked before drawing the item.
* @noreturn
* @error Invalid menu resource.
*/
native menu_additem(menu, const name[], const info[]="", paccess=0, callback=-1);
/**
* Returns the number of pages in a menu.
*
* @param menu Menu resource identifier.
* @return Number of pages in the menu.
* @error Invalid menu resource.
*/
native menu_pages(menu);
/**
* Returns the number of items in a menu.
*
* @param menu Menu resource identifier.
* @return Number of items in the menu.
* @error Invalid menu resource.
*/
native menu_items(menu);
/**
* Displays a menu to one client. This should never be called from a handler
* when the item is less than 0 (i.e. calling this from a cancelled menu will
* result in an error).
*
* Starting with 1.8.3 this allows to specify a menu timeout similar to the
* show_menu native. If the menu exists on the client past the timeout *any*
* further action will send the MENU_TIMEOUT status code to the menu handler.
* That includes actions which would otherwise send MENU_EXIT, such as the
* client selecting an item or disconnecting and calling menu_cancel or
* menu_destroy on a live menu.
*
* @param id Client index.
* @param menu Menu resource identifier.
* @param page Page to start from (starting from 0).
* @param time If >=0 menu will timeout after this many seconds
* @noreturn
* @error Invalid menu resource or client index.
*/
native menu_display(id, menu, page=0, time=-1);
/**
* Given a page on a menu and a keypress on that page, returns the item id selected.
* If the item is less than 0, a special option was chosen (such as MENU_EXIT).
*
* @param menu Menu resource identifier.
* @param page Page on the menu.
* @param key Key pressed (from 1 to 10).
* @return Item identifier, or <0 for a special selection code.
* @error Invalid menu resource.
*/
native menu_find_id(menu, page, key);
/**
* Retrieves info about a menu item.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param access Variable to store access value.
* @param info Buffer to store item info.
* @param infolen Item info buffer length.
* @param name Buffer to store item display text.
* @param namelen Item name buffer length.
* @param callback Callback ID.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_getinfo(menu, item, &access, info[], infolen, name[]="", namelen=0, &callback);
/**
* Sets an item's display text.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param name New item display text.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setname(menu, item, const name[]);
/**
* Sets an item's info string.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param info New item info string.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setcmd(menu, item, const info[]);
/**
* Sets an item's callback.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param callback New callback from menu_makecallback(), or -1 to clear.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setcall(menu, item, callback=-1);
/**
* Destroys a menu. Player menus will be cancelled (although may still linger
* on the HUD), and future attempts to access the menu resource will result in
* an error.
*
* This must be called if you create menus dynamically, otherwise you will
* leak memory. For normal dynamic menus, you will destroy the menu in the
* handler function (remembering to handle the case of a menu being cancelled,
* it must still be destroyed).
*
* @param menu Menu resource identifier.
* @noreturn
* @error Invalid menu resource.
*/
native menu_destroy(menu);
/**
* Returns information about a menu (if any) the client is currently viewing.
*
* If newmenu is valid, then the menu will refer to the menuid associated with
* the title. If newmenu is not valid, and the menu is valid, then the player
* is viewing a menu displayed with show_menu().
*
* Both may be invalid if the player is not viewing a menu.
*
* @param id Client index.
* @param menu Variable to store old menu id. If none, then <1 will be
* stored.
* @param newmenu Variable to store new menu id. If none, then -1 will be
* stored.
* @param menupage Variable to store current page of the new menu, if any.
* @return 1 if the player is viewing a menu, 0 otherwise.
* @error Invalid client.
*/
native player_menu_info(id, &menu, &newmenu, &menupage=0);
/**
* Adds a blank line to a menu.
*
* When using slot=1 this might break your menu. To achieve this functionality
* menu_addblank2 should be used.
*
* @param menu Menu resource identifier.
* @param slot 1 (default) if the line should shift the numbering down.
* 0 if the line should be a visual shift only.
* @noreturn
* @error Invalid menu resource.
*/
native menu_addblank(menu, slot=1);
/**
* Adds a text line to a menu. Only available in amxmodx 1.8.1 and above.
*
* When using slot=1 this might break your menu. To achieve this functionality
* menu_addtext2 should be used.
*
* @param menu Menu resource identifier.
* @param text Text to add.
* @param slot 1 (default) if the line should shift the numbering down.
* 0 if the line should be a visual shift only.
* @noreturn
* @error Invalid menu resource.
*/
native menu_addtext(menu, const text[], slot=1);
/**
* Adds a blank line to a menu, always shifting the numbering down.
*
* This will add a special item to create a blank line. It will affect the menu
* item count and pagination. These items can be modified later but will ignore
* access and item callback results.
*
* Only available in 1.8.3 and above.
*
* @param menu Menu resource identifier.
*
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
* Too many items on non-paginated menu (max is 10)
*/
native menu_addblank2( menu );
/**
* Adds a text line to a menu, always shifting the numbering down.
*
* This will add a special item to create a blank line. It will affect the menu
* item count and pagination. These items can be modified later but will ignore
* access and item callback results.
*
* Only available in 1.8.3 and above.
*
* @param menu Menu resource identifier.
* @param text Text to add.
*
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
* Too many items on non-paginated menu (max is 10)
*/
native menu_addtext2( menu, const text[] );
/**
* Sets a menu property.
*
* @param menu Menu resource identifier.
* @param prop MPROP_ constant.
* @param ... Property parameters.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource or property.
*/
native menu_setprop(menu, prop, ...);
/**
* Cancels a player's menu, effectively forcing the player to select MENU_EXIT.
* The menu will still exist on their screen but any results are invalidated,
* and the callback is invoked.
*
* @param player Client index.
* @noreturn
* @error Invalid client index.
*/
native menu_cancel(player);
#if defined _newmenus_included
#endinput
#endif
#define _newmenus_included
#define MEXIT_ALL 1 /* Menu will have an exit option (default)*/
#define MEXIT_FORCE 2 /* Menu will have an exit option, even when pagination is disabled.
* There have to be less than 10 items in the menu or it won't appear. The exit
* option will be appended to the last item with no extra slot padding. If you
* want it in the 10th slot you have to pad it manually with menu_addblank2 */
#define MEXIT_NEVER -1 /* Menu will not have an exit option */
#define MPROP_PERPAGE 1 /* Number of items per page (param1 = number, 0=no paginating, 7=default) */
#define MPROP_BACKNAME 2 /* Name of the back button (param1 = string) */
#define MPROP_NEXTNAME 3 /* Name of the next button (param1 = string) */
#define MPROP_EXITNAME 4 /* Name of the exit button (param1 = string) */
#define MPROP_TITLE 5 /* Menu title text (param1 = string) */
#define MPROP_EXIT 6 /* Exit functionality (param1 = number, see MEXIT constants) */
#define MPROP_NOCOLORS 8 /* Sets whether colors are not auto (param1 = number, 0=default) */
#define MPROP_NUMBER_COLOR 10 /* Color indicator to use for numbers (param1 = string, "\r"=default) */
#define MEXIT_NORMAL 0 /* DEPRECATED, do not use (has no effect) */
#define MENUPAD_NONE 0 /* DEPRECATED, do not use (has no effect) */
#define MENUPAD_PAGE 1 /* DEPRECATED, do not use (has no effect) */
#define MPROP_ORDER 7 /* DEPRECATED, do not use (has no effect) */
#define MPROP_PADMENU 9 /* DEPRECATED, do not use (has no effect) */
/**
* @brief Creates a new menu object.
*
* The handler function should be prototyped as:
*
* public <function>(id, menu, item)
* id - Client the menu is being acted upon.
* menu - Menu resource identifier.
* item - Item the client selected. If less than 0, the menu was
* cancelled and the item is a status code. menu_display
* should never be called immediately if the item is a status
* code, for re-entrancy reasons.
*
* The handler function should always return PLUGIN_HANDLED to block
* any old menu handlers from potentially feeding on the menu, unless
* that is the desired functionality.
*
* @param title Title the menu should use.
* @param handler Name of the handler function. The function will be invoked
* once and only once to every menu_display() call.
* @param ml Unused (should be 0).
* @return Menu resource identifier which must be destroyed via
* menu_destroy(). All menus are destroyed when the plugin
* unloads.
* @error Function name not found.
*/
native menu_create(const title[], const handler[], ml=0);
/**
* Creates a menu item callback handler.
*
* The handler function should be prototyped as:
*
* public <function>(id, menu, item)
* id - Client index being displayed to.
* menu - Menu resource identifier.
* item - Item being drawn.
* <return> - ITEM_IGNORE to use the default functionality. ITEM_ENABLED to
* explicitly enable or ITEM_DISABLED to explicitly disable.
*
* @param function Function name.
* @return Menu callback ID.
*/
native menu_makecallback(const function[]);
/**
* Adds an menu to a menu.
*
* @param menu Menu resource identifier.
* @param name Item text to display.
* @param info Item info string for internal information.
* @param paccess Access required by the player viewing the menu.
* @param callback If set to a valid ID from menu_makecallback(), the
* callback will be invoked before drawing the item.
* @noreturn
* @error Invalid menu resource.
*/
native menu_additem(menu, const name[], const info[]="", paccess=0, callback=-1);
/**
* Returns the number of pages in a menu.
*
* @param menu Menu resource identifier.
* @return Number of pages in the menu.
* @error Invalid menu resource.
*/
native menu_pages(menu);
/**
* Returns the number of items in a menu.
*
* @param menu Menu resource identifier.
* @return Number of items in the menu.
* @error Invalid menu resource.
*/
native menu_items(menu);
/**
* Displays a menu to one client. This should never be called from a handler
* when the item is less than 0 (i.e. calling this from a cancelled menu will
* result in an error).
*
* Starting with 1.8.3 this allows to specify a menu timeout similar to the
* show_menu native. If the menu exists on the client past the timeout *any*
* further action will send the MENU_TIMEOUT status code to the menu handler.
* That includes actions which would otherwise send MENU_EXIT, such as the
* client selecting an item or disconnecting and calling menu_cancel or
* menu_destroy on a live menu.
*
* @param id Client index.
* @param menu Menu resource identifier.
* @param page Page to start from (starting from 0).
* @param time If >=0 menu will timeout after this many seconds
* @noreturn
* @error Invalid menu resource or client index.
*/
native menu_display(id, menu, page=0, time=-1);
/**
* Given a page on a menu and a keypress on that page, returns the item id selected.
* If the item is less than 0, a special option was chosen (such as MENU_EXIT).
*
* @param menu Menu resource identifier.
* @param page Page on the menu.
* @param key Key pressed (from 1 to 10).
* @return Item identifier, or <0 for a special selection code.
* @error Invalid menu resource.
*/
native menu_find_id(menu, page, key);
/**
* Retrieves info about a menu item.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param access Variable to store access value.
* @param info Buffer to store item info.
* @param infolen Item info buffer length.
* @param name Buffer to store item display text.
* @param namelen Item name buffer length.
* @param callback Callback ID.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_getinfo(menu, item, &access, info[], infolen, name[]="", namelen=0, &callback);
/**
* Sets an item's display text.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param name New item display text.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setname(menu, item, const name[]);
/**
* Sets an item's info string.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param info New item info string.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setcmd(menu, item, const info[]);
/**
* Sets an item's callback.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param callback New callback from menu_makecallback(), or -1 to clear.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setcall(menu, item, callback=-1);
/**
* Destroys a menu. Player menus will be cancelled (although may still linger
* on the HUD), and future attempts to access the menu resource will result in
* an error.
*
* This must be called if you create menus dynamically, otherwise you will
* leak memory. For normal dynamic menus, you will destroy the menu in the
* handler function (remembering to handle the case of a menu being cancelled,
* it must still be destroyed).
*
* @param menu Menu resource identifier.
* @noreturn
* @error Invalid menu resource.
*/
native menu_destroy(menu);
/**
* Returns information about a menu (if any) the client is currently viewing.
*
* If newmenu is valid, then the menu will refer to the menuid associated with
* the title. If newmenu is not valid, and the menu is valid, then the player
* is viewing a menu displayed with show_menu().
*
* Both may be invalid if the player is not viewing a menu.
*
* @param id Client index.
* @param menu Variable to store old menu id. If none, then <1 will be
* stored.
* @param newmenu Variable to store new menu id. If none, then -1 will be
* stored.
* @param menupage Variable to store current page of the new menu, if any.
* @return 1 if the player is viewing a menu, 0 otherwise.
* @error Invalid client.
*/
native player_menu_info(id, &menu, &newmenu, &menupage=0);
/**
* Adds a blank line to a menu.
*
* When using slot=1 this might break your menu. To achieve this functionality
* menu_addblank2 should be used.
*
* @param menu Menu resource identifier.
* @param slot 1 (default) if the line should shift the numbering down.
* 0 if the line should be a visual shift only.
* @noreturn
* @error Invalid menu resource.
*/
native menu_addblank(menu, slot=1);
/**
* Adds a text line to a menu. Only available in amxmodx 1.8.1 and above.
*
* When using slot=1 this might break your menu. To achieve this functionality
* menu_addtext2 should be used.
*
* @param menu Menu resource identifier.
* @param text Text to add.
* @param slot 1 (default) if the line should shift the numbering down.
* 0 if the line should be a visual shift only.
* @noreturn
* @error Invalid menu resource.
*/
native menu_addtext(menu, const text[], slot=1);
/**
* Adds a blank line to a menu, always shifting the numbering down.
*
* This will add a special item to create a blank line. It will affect the menu
* item count and pagination. These items can be modified later but will ignore
* access and item callback results.
*
* Only available in 1.8.3 and above.
*
* @param menu Menu resource identifier.
*
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
* Too many items on non-paginated menu (max is 10)
*/
native menu_addblank2( menu );
/**
* Adds a text line to a menu, always shifting the numbering down.
*
* This will add a special item to create a blank line. It will affect the menu
* item count and pagination. These items can be modified later but will ignore
* access and item callback results.
*
* Only available in 1.8.3 and above.
*
* @param menu Menu resource identifier.
* @param text Text to add.
*
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
* Too many items on non-paginated menu (max is 10)
*/
native menu_addtext2( menu, const text[] );
/**
* Sets a menu property.
*
* @param menu Menu resource identifier.
* @param prop MPROP_ constant.
* @param ... Property parameters.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource or property.
*/
native menu_setprop(menu, prop, ...);
/**
* Cancels a player's menu, effectively forcing the player to select MENU_EXIT.
* The menu will still exist on their screen but any results are invalidated,
* and the callback is invoked.
*
* @param player Client index.
* @noreturn
* @error Invalid client index.
*/
native menu_cancel(player);

View File

@ -16,92 +16,92 @@
// C standard library, which uses the Quick Sort algorithm.
// For more info, see: http://linux.wku.edu/~lamonml/algor/sort/sort.html
//
#if defined _sorting_included
#endinput
#endif
#define _sorting_included
/**
* Contains sorting orders.
*/
enum SortMethod
{
Sort_Ascending = 0,
Sort_Descending,
Sort_Random,
};
/**
* Data types for ADT Array Sorts
*/
enum SortType
{
Sort_Integer = 0,
Sort_Float,
Sort_String,
};
/**
* Basic sorting functions below.
*/
native SortIntegers(array[], array_size, SortMethod:order = Sort_Ascending);
native SortFloats(Float:array[], array_size, SortMethod:order = Sort_Ascending);
native SortStrings(array[][], num_strings, SortMethod:order = Sort_Ascending);
/**
* Custom sorting functions below.
*/
/**
* Sorts a custom 1D array. You must pass in a comparison function.
* The sorting algorithm then uses your comparison function to sort the data.
* The function is called in the following manner:
*
* public MySortFunc(elem1, elem2, const array[], const data[], data_size)
*
* elem1, elem2 - Current element pair being compared
* array[] - Array in its current mid-sorted state.
* data[] - Extra data array you passed to the sort func.
* data_size - Size of extra data you passed to the sort func.
*
* Your function should return:
* -1 if elem1 should go before elem2
* 0 if elem1 and elem2 are equal
* 1 if elem1 should go after elem2
* Note that the parameters after elem2 are all optional and you do not need to specify them.
*/
native SortCustom1D(array[], array_size, const comparefunc[], data[]="", data_size=0);
/**
* Sorts a custom 2D array.
* The sorting algorithm then uses your comparison function to sort the data.
* The function is called in the following manner:
*
* public MySortFunc(const elem1[], const elem2[], const array[], data[], data_size)
*
* elem1[], elem2[] - Current element array pairs being compared
* array[][] - Array in its currently being sorted state.
* data[] - Extra data array you passed to the sort func.
* data_size - Size of extra data you passed to the sort func.
*
* Your function should return:
* -1 if elem1[] should go before elem2[]
* 0 if elem1[] and elem2 are equal[]
* 1 if elem1[] should go after elem2[]
* Note that the parameters after elem2[] are all optional and you do not need to specify them.
*/
native SortCustom2D(array[][], array_size, const comparefunc[], data[]="", data_size=0);
/**
* Sort an ADT Array. Specify the type as Integer, Float, or String.
*
* @param array Array Handle to sort
* @param order Sort order to use, same as other sorts.
* @param type Data type stored in the ADT Array
* @noreturn
*/
native SortADTArray(Array:array, SortMethod:order, SortType:type);
#if defined _sorting_included
#endinput
#endif
#define _sorting_included
/**
* Contains sorting orders.
*/
enum SortMethod
{
Sort_Ascending = 0,
Sort_Descending,
Sort_Random,
};
/**
* Data types for ADT Array Sorts
*/
enum SortType
{
Sort_Integer = 0,
Sort_Float,
Sort_String,
};
/**
* Basic sorting functions below.
*/
native SortIntegers(array[], array_size, SortMethod:order = Sort_Ascending);
native SortFloats(Float:array[], array_size, SortMethod:order = Sort_Ascending);
native SortStrings(array[][], num_strings, SortMethod:order = Sort_Ascending);
/**
* Custom sorting functions below.
*/
/**
* Sorts a custom 1D array. You must pass in a comparison function.
* The sorting algorithm then uses your comparison function to sort the data.
* The function is called in the following manner:
*
* public MySortFunc(elem1, elem2, const array[], const data[], data_size)
*
* elem1, elem2 - Current element pair being compared
* array[] - Array in its current mid-sorted state.
* data[] - Extra data array you passed to the sort func.
* data_size - Size of extra data you passed to the sort func.
*
* Your function should return:
* -1 if elem1 should go before elem2
* 0 if elem1 and elem2 are equal
* 1 if elem1 should go after elem2
* Note that the parameters after elem2 are all optional and you do not need to specify them.
*/
native SortCustom1D(array[], array_size, const comparefunc[], data[]="", data_size=0);
/**
* Sorts a custom 2D array.
* The sorting algorithm then uses your comparison function to sort the data.
* The function is called in the following manner:
*
* public MySortFunc(const elem1[], const elem2[], const array[], data[], data_size)
*
* elem1[], elem2[] - Current element array pairs being compared
* array[][] - Array in its currently being sorted state.
* data[] - Extra data array you passed to the sort func.
* data_size - Size of extra data you passed to the sort func.
*
* Your function should return:
* -1 if elem1[] should go before elem2[]
* 0 if elem1[] and elem2 are equal[]
* 1 if elem1[] should go after elem2[]
* Note that the parameters after elem2[] are all optional and you do not need to specify them.
*/
native SortCustom2D(array[][], array_size, const comparefunc[], data[]="", data_size=0);
/**
* Sort an ADT Array. Specify the type as Integer, Float, or String.
*
* @param array Array Handle to sort
* @param order Sort order to use, same as other sorts.
* @param type Data type stored in the ADT Array
* @noreturn
*/
native SortADTArray(Array:array, SortMethod:order, SortType:type);

File diff suppressed because it is too large Load Diff

View File

@ -7,126 +7,126 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <amxmodx>
new __testnumber;
new errcount;
enum TestType
{
TT_Equal = 0,
TT_LessThan,
TT_GreaterThan,
TT_LessThanEqual,
TT_GreaterThanEqual,
TT_NotEqual
};
new TestWords[6][] = {
"==",
"<",
">",
"<=",
">=",
"!="
};
stock test(A,B=0,TestType:Type=TT_Equal)
{
++__testnumber;
new passed=0;
switch (Type)
{
case TT_Equal: if (A==B) passed=1;
case TT_LessThan: if (A<B) passed=1;
case TT_GreaterThan: if (A>B) passed=1;
case TT_LessThanEqual: if (A<=B) passed=1;
case TT_GreaterThanEqual: if (A>=B) passed=1;
case TT_NotEqual: if (A!=B) passed=1;
}
if (!passed)
{
log_amx("Failed test #%d (%d %s %d)",__testnumber,A,TestWords[_:Type],B);
errcount++;
}
}
public plugin_init()
{
register_srvcmd("testadmins","testadmins");
}
public testadmins()
{
new AuthData[44];
new Password[32];
new Access;
new Flags;
new id;
__testnumber=0;
errcount=0;
test(admins_num(),0);
admins_push("STEAM_0:1:23456","",read_flags("abcdefghijklmnopqrstu"),read_flags("ce"));
test(admins_num(),1);
admins_push("ABCDEFGHIJKLMNOP","abcdefghijklmnop",read_flags("z"),read_flags("a"));
test(admins_num(),2);
admins_push("ZYXWVUTSRQPONMLKJIHGFEDCBA","plop",read_flags("a"),read_flags("b"));
test(admins_num(),3);
id=0;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"STEAM_0:1:23456"),0);
test(strcmp(Password,""),0);
test(Access,read_flags("abcdefghijklmnopqrstu"));
test(Flags,read_flags("ce"));
id++;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"ABCDEFGHIJKLMNOP"),0);
test(strcmp(Password,"abcdefghijklmnop"),0);
test(Access,read_flags("z"));
test(Flags,read_flags("a"));
id++;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"ZYXWVUTSRQPONMLKJIHGFEDCBA"),0);
test(strcmp(Password,"plop"),0);
test(Access,read_flags("a"));
test(Flags,read_flags("b"));
admins_flush();
test(admins_num(),0);
server_print("test complete, %d errors",errcount);
#include <amxmodx>
new __testnumber;
new errcount;
enum TestType
{
TT_Equal = 0,
TT_LessThan,
TT_GreaterThan,
TT_LessThanEqual,
TT_GreaterThanEqual,
TT_NotEqual
};
new TestWords[6][] = {
"==",
"<",
">",
"<=",
">=",
"!="
};
stock test(A,B=0,TestType:Type=TT_Equal)
{
++__testnumber;
new passed=0;
switch (Type)
{
case TT_Equal: if (A==B) passed=1;
case TT_LessThan: if (A<B) passed=1;
case TT_GreaterThan: if (A>B) passed=1;
case TT_LessThanEqual: if (A<=B) passed=1;
case TT_GreaterThanEqual: if (A>=B) passed=1;
case TT_NotEqual: if (A!=B) passed=1;
}
if (!passed)
{
log_amx("Failed test #%d (%d %s %d)",__testnumber,A,TestWords[_:Type],B);
errcount++;
}
}
public plugin_init()
{
register_srvcmd("testadmins","testadmins");
}
public testadmins()
{
new AuthData[44];
new Password[32];
new Access;
new Flags;
new id;
__testnumber=0;
errcount=0;
test(admins_num(),0);
admins_push("STEAM_0:1:23456","",read_flags("abcdefghijklmnopqrstu"),read_flags("ce"));
test(admins_num(),1);
admins_push("ABCDEFGHIJKLMNOP","abcdefghijklmnop",read_flags("z"),read_flags("a"));
test(admins_num(),2);
admins_push("ZYXWVUTSRQPONMLKJIHGFEDCBA","plop",read_flags("a"),read_flags("b"));
test(admins_num(),3);
id=0;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"STEAM_0:1:23456"),0);
test(strcmp(Password,""),0);
test(Access,read_flags("abcdefghijklmnopqrstu"));
test(Flags,read_flags("ce"));
id++;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"ABCDEFGHIJKLMNOP"),0);
test(strcmp(Password,"abcdefghijklmnop"),0);
test(Access,read_flags("z"));
test(Flags,read_flags("a"));
id++;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"ZYXWVUTSRQPONMLKJIHGFEDCBA"),0);
test(strcmp(Password,"plop"),0);
test(Access,read_flags("a"));
test(Flags,read_flags("b"));
admins_flush();
test(admins_num(),0);
server_print("test complete, %d errors",errcount);
}

File diff suppressed because it is too large Load Diff

View File

@ -7,63 +7,63 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <amxmodx>
public plugin_init()
{
register_plugin("callfunc test", "1.0", "BAILOPAN")
register_srvcmd("test_callfunc", "Command_Callfunc")
}
public OnCallfuncReceived(num, str[], &val, array[], array2[], size, hello2[1])
{
server_print("num = %d (expected: %d)", num, 5)
server_print("str[] = ^"%s^" (expected: %s)", str, "Gaben")
server_print("val = %d (expected %d, setting to %d)", val, 62, 15)
val = 15
server_print("printing %d elements of array[] (expected: %d)", size, 6)
for (new i=0; i<size; i++)
{
server_print("array[%d] = %d (expected: %d)", i, array[i], i)
}
for (new i=0; i<size; i++)
{
server_print("array2[%d] = %d (expected: %d)", i, array[i], i)
}
array[0] = 5
array2[1] = 6
hello2[0] = 25
}
public Command_Callfunc()
{
new a = 62
new hello[] = {0,1,2,3,4,5}
new hello2[] = {9}
new pm = 6
new err
if ((err=callfunc_begin("OnCallfuncReceived")) < 1)
{
server_print("Failed to call callfunc_begin()! Error: %d", err)
return PLUGIN_HANDLED
}
callfunc_push_int(5)
callfunc_push_str("Gaben")
callfunc_push_intrf(a)
callfunc_push_array(hello, pm)
callfunc_push_array(hello, pm)
callfunc_push_int(pm)
callfunc_push_array(hello2, 1, false)
callfunc_end()
server_print("a = %d (expected: %d)", a, 15)
server_print("hello[0] = %d (expected: %d)", hello[0], 5)
server_print("hello[1] = %d (expected: %d)", hello[1], 6)
server_print("hello2[0] = %d (expected: %d)", hello2[0], 9)
return PLUGIN_HANDLED
}
#include <amxmodx>
public plugin_init()
{
register_plugin("callfunc test", "1.0", "BAILOPAN")
register_srvcmd("test_callfunc", "Command_Callfunc")
}
public OnCallfuncReceived(num, str[], &val, array[], array2[], size, hello2[1])
{
server_print("num = %d (expected: %d)", num, 5)
server_print("str[] = ^"%s^" (expected: %s)", str, "Gaben")
server_print("val = %d (expected %d, setting to %d)", val, 62, 15)
val = 15
server_print("printing %d elements of array[] (expected: %d)", size, 6)
for (new i=0; i<size; i++)
{
server_print("array[%d] = %d (expected: %d)", i, array[i], i)
}
for (new i=0; i<size; i++)
{
server_print("array2[%d] = %d (expected: %d)", i, array[i], i)
}
array[0] = 5
array2[1] = 6
hello2[0] = 25
}
public Command_Callfunc()
{
new a = 62
new hello[] = {0,1,2,3,4,5}
new hello2[] = {9}
new pm = 6
new err
if ((err=callfunc_begin("OnCallfuncReceived")) < 1)
{
server_print("Failed to call callfunc_begin()! Error: %d", err)
return PLUGIN_HANDLED
}
callfunc_push_int(5)
callfunc_push_str("Gaben")
callfunc_push_intrf(a)
callfunc_push_array(hello, pm)
callfunc_push_array(hello, pm)
callfunc_push_int(pm)
callfunc_push_array(hello2, 1, false)
callfunc_end()
server_print("a = %d (expected: %d)", a, 15)
server_print("hello[0] = %d (expected: %d)", hello[0], 5)
server_print("hello[1] = %d (expected: %d)", hello[1], 6)
server_print("hello2[0] = %d (expected: %d)", hello2[0], 9)
return PLUGIN_HANDLED
}

View File

@ -7,21 +7,21 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <amxmodx>
#include <fakemeta>
public plugin_init()
{
register_plugin("Fakemeta Tests", "1.0", "BAILOPAN")
register_forward(FM_ServerDeactivate, "Hook_ServerDeactivate")
}
public Hook_ServerDeactivate()
{
server_print("[FAKEMETA TEST] ServerDeactivate() at %f", get_gametime())
}
public plugin_end()
{
server_print("[FAKEMETA TEST] plugin_end() at %f", get_gametime())
}
#include <amxmodx>
#include <fakemeta>
public plugin_init()
{
register_plugin("Fakemeta Tests", "1.0", "BAILOPAN")
register_forward(FM_ServerDeactivate, "Hook_ServerDeactivate")
}
public Hook_ServerDeactivate()
{
server_print("[FAKEMETA TEST] ServerDeactivate() at %f", get_gametime())
}
public plugin_end()
{
server_print("[FAKEMETA TEST] plugin_end() at %f", get_gametime())
}

View File

@ -7,61 +7,61 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <amxmodx>
public plugin_init()
{
register_plugin("Format Test", "1.0", "BAILOPAN")
register_srvcmd("test_format", "Command_TestFormat")
register_srvcmd("test_replace", "Command_TestReplace")
}
public gabprint(const fmt[], ...)
{
static buffer[2048]
vformat(buffer, 2047, fmt, 2)
server_print("%s", buffer)
}
public Command_TestFormat()
{
server_print("Printing -1 with d: %d", -1)
server_print("Printing -1 with u: %u", -1)
server_print("Printing (1<<31) with d: %d", (1<<31))
server_print("Printing (1<<31) with u: %u", (1<<31))
server_print("Printing 1 with d: %d", 1)
server_print("Printing 1 with u: %u", 1)
}
public Command_TestReplace()
{
new message[192] = "^"@test^""
replace_all(message, 191, "^"", "")
server_print("Got: %s (expected: %s)", message, "@test")
copy(message, 191, "test")
replace_all(message, 191, "t", "tt")
server_print("Got: %s (expected: %s)", message, "ttestt")
replace_all(message, 191, "tt", "")
server_print("Got: %s (expected: %s)", message, "es")
copy(message, 191, "good boys do fine always")
replace_all(message, 191, " ", "-----")
server_print("Got %s (expected: %s)", message, "good-----boys-----do-----fine-----always")
copy(message, 191, "-----")
replace_all(message, 191, "-", "")
server_print("Got ^"%s%^" (expected: ^"%s%^")", message, "")
copy(message, 191, "-----")
replace_all(message, 191, "--", "")
server_print("Got ^"%s%^" (expected: ^"%s%^")", message, "-")
copy(message, 191, "aaaa")
replace_all(message, 191, "a", "Aaa")
server_print("Got %s (expected: %s)", message, "AaaAaaAaaAaa")
}
#include <amxmodx>
public plugin_init()
{
register_plugin("Format Test", "1.0", "BAILOPAN")
register_srvcmd("test_format", "Command_TestFormat")
register_srvcmd("test_replace", "Command_TestReplace")
}
public gabprint(const fmt[], ...)
{
static buffer[2048]
vformat(buffer, 2047, fmt, 2)
server_print("%s", buffer)
}
public Command_TestFormat()
{
server_print("Printing -1 with d: %d", -1)
server_print("Printing -1 with u: %u", -1)
server_print("Printing (1<<31) with d: %d", (1<<31))
server_print("Printing (1<<31) with u: %u", (1<<31))
server_print("Printing 1 with d: %d", 1)
server_print("Printing 1 with u: %u", 1)
}
public Command_TestReplace()
{
new message[192] = "^"@test^""
replace_all(message, 191, "^"", "")
server_print("Got: %s (expected: %s)", message, "@test")
copy(message, 191, "test")
replace_all(message, 191, "t", "tt")
server_print("Got: %s (expected: %s)", message, "ttestt")
replace_all(message, 191, "tt", "")
server_print("Got: %s (expected: %s)", message, "es")
copy(message, 191, "good boys do fine always")
replace_all(message, 191, " ", "-----")
server_print("Got %s (expected: %s)", message, "good-----boys-----do-----fine-----always")
copy(message, 191, "-----")
replace_all(message, 191, "-", "")
server_print("Got ^"%s%^" (expected: ^"%s%^")", message, "")
copy(message, 191, "-----")
replace_all(message, 191, "--", "")
server_print("Got ^"%s%^" (expected: ^"%s%^")", message, "-")
copy(message, 191, "aaaa")
replace_all(message, 191, "a", "Aaa")
server_print("Got %s (expected: %s)", message, "AaaAaaAaaAaa")
}

View File

@ -7,48 +7,48 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <amxmodx>
new g_BlockLog
public plugin_init()
{
register_plugin("Log Tester", "1.0", "BAILOPAN")
register_srvcmd("log_addlogevent", "Command_AddLogEvent")
register_srvcmd("log_setblock", "Command_LogSetBlock")
}
public event_round_start()
{
}
public Command_LogSetBlock()
{
if (read_argc() < 2)
{
server_print("Specify 1 or 0.")
return PLUGIN_HANDLED
}
new temp[12]
read_argv(1, temp, 11)
g_BlockLog = str_to_num(temp) ? true : false
return PLUGIN_HANDLED
}
public plugin_log()
{
server_print("Got log event! Blocking: %d", g_BlockLog)
return g_BlockLog ? PLUGIN_HANDLED : PLUGIN_CONTINUE
}
public Command_AddLogEvent(id)
{
register_logevent("event_round_start", 2, "0=World triggered", "1=Round_Start")
return PLUGIN_HANDLED
}
#include <amxmodx>
new g_BlockLog
public plugin_init()
{
register_plugin("Log Tester", "1.0", "BAILOPAN")
register_srvcmd("log_addlogevent", "Command_AddLogEvent")
register_srvcmd("log_setblock", "Command_LogSetBlock")
}
public event_round_start()
{
}
public Command_LogSetBlock()
{
if (read_argc() < 2)
{
server_print("Specify 1 or 0.")
return PLUGIN_HANDLED
}
new temp[12]
read_argv(1, temp, 11)
g_BlockLog = str_to_num(temp) ? true : false
return PLUGIN_HANDLED
}
public plugin_log()
{
server_print("Got log event! Blocking: %d", g_BlockLog)
return g_BlockLog ? PLUGIN_HANDLED : PLUGIN_CONTINUE
}
public Command_AddLogEvent(id)
{
register_logevent("event_round_start", 2, "0=World triggered", "1=Round_Start")
return PLUGIN_HANDLED
}

View File

@ -7,34 +7,34 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <amxmodx>
native Factorial(num)
public __Factorial(id, num)
{
new num = get_param(1)
if (num == 0)
{
return 1
}
return num * Factorial(num - 1)
}
public plugin_natives()
{
register_native("Factorial", "__Factorial")
}
public plugin_init()
{
register_plugin("Native Test", "1.0", "BAILOPAN")
register_srvcmd("test_native1", "Command_TestNative1")
}
public Command_TestNative1()
{
new num = Factorial(6)
server_print("Factorial of 6 is: %d", num)
}
#include <amxmodx>
native Factorial(num)
public __Factorial(id, num)
{
new num = get_param(1)
if (num == 0)
{
return 1
}
return num * Factorial(num - 1)
}
public plugin_natives()
{
register_native("Factorial", "__Factorial")
}
public plugin_init()
{
register_plugin("Native Test", "1.0", "BAILOPAN")
register_srvcmd("test_native1", "Command_TestNative1")
}
public Command_TestNative1()
{
new num = Factorial(6)
server_print("Factorial of 6 is: %d", num)
}

View File

@ -7,23 +7,23 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <amxmodx>
#include <nvault>
public plugin_init()
{
register_plugin("nVault Test", "1.0", "BAILOPAN")
register_srvcmd("test_nvault", "Command_TestNvault")
}
public Command_TestNvault()
{
new v = nvault_open("://:/1/R!?#@41345$%:$")
server_print("Vault value: %d (expected: %d)", v, -1)
if (v != -1)
{
nvault_close(v)
}
}
#include <amxmodx>
#include <nvault>
public plugin_init()
{
register_plugin("nVault Test", "1.0", "BAILOPAN")
register_srvcmd("test_nvault", "Command_TestNvault")
}
public Command_TestNvault()
{
new v = nvault_open("://:/1/R!?#@41345$%:$")
server_print("Vault value: %d (expected: %d)", v, -1)
if (v != -1)
{
nvault_close(v)
}
}

View File

@ -7,294 +7,294 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <amxmodx>
public plugin_init()
{
register_plugin("Sort Test", "1.0", "BAILOPAN")
register_srvcmd("test_sort_ints", "Command_TestSortInts")
register_srvcmd("test_sort_floats", "Command_TestSortFloats")
register_srvcmd("test_sort_strings", "Command_TestSortStrings")
register_srvcmd("test_sort_1d", "Command_TestSort1D")
register_srvcmd("test_sort_2d", "Command_TestSort2D")
register_srvcmd("test_adtsort_ints", "Command_TestSortADTInts")
register_srvcmd("test_adtsort_floats", "Command_TestSortADTFloats")
register_srvcmd("test_adtsort_strings", "Command_TestSortADTStrings")
}
/*****************
* INTEGER TESTS *
*****************/
// Note that integer comparison is just int1-int2 (or a variation therein)
PrintIntegers(const array[], size)
{
for (new i=0; i<size; i++)
{
server_print("array[%d] = %d", i, array[i])
}
}
public Command_TestSortInts()
{
new array[10] = {6, 7, 3, 2, 8, 5, 0, 1, 4, 9}
server_print("Testing ascending sort:")
SortIntegers(array, 10, Sort_Ascending)
PrintIntegers(array, 10)
server_print("Testing descending sort:")
SortIntegers(array, 10, Sort_Descending)
PrintIntegers(array, 10)
server_print("Testing random sort:")
SortIntegers(array, 10, Sort_Random)
PrintIntegers(array, 10)
}
/**************************
* Float comparison tests *
**************************/
PrintFloats(const Float:array[], size)
{
for (new i=0; i<size; i++)
{
server_print("array[%d] = %f", i, array[i])
}
}
public Command_TestSortFloats()
{
new Float:array[10] = {6.3, 7.6, 3.2, 2.1, 8.5, 5.2, 0.4, 1.7, 4.8, 8.2}
server_print("Testing ascending sort:")
SortFloats(array, 10, Sort_Ascending)
PrintFloats(array, 10)
server_print("Testing descending sort:")
SortFloats(array, 10, Sort_Descending)
PrintFloats(array, 10)
server_print("Testing random sort:")
SortFloats(array, 10, Sort_Random)
PrintFloats(array, 10)
return PLUGIN_HANDLED
}
public Custom1DSort(Float:elem1, Float:elem2)
{
if (elem1 > elem2)
{
return -1;
} else if (elem1 < elem2) {
return 1;
}
return 0;
}
public Command_TestSort1D()
{
new Float:array[10] = {6.3, 7.6, 3.2, 2.1, 8.5, 5.2, 0.4, 1.7, 4.8, 8.2}
SortCustom1D(_:array, 10, "Custom1DSort")
PrintFloats(array, 10)
return PLUGIN_HANDLED
}
/***************************
* String comparison tests *
***************************/
PrintStrings(const array[][], size)
{
for (new i=0; i<size; i++)
{
server_print("array[%d] = %s", i, array[i])
}
}
public Command_TestSortStrings()
{
new array[][] =
{
"faluco",
"bailopan",
"pm onoto",
"damaged soul",
"sniperbeamer",
"sidluke",
"johnny got his gun",
"gabe newell",
"hello",
"WHAT?!"
}
server_print("Testing ascending sort:")
SortStrings(array, 10, Sort_Ascending)
PrintStrings(array, 10)
server_print("Testing descending sort:")
SortStrings(array, 10, Sort_Descending)
PrintStrings(array, 10)
server_print("Testing random sort:")
SortStrings(array, 10, Sort_Random)
PrintStrings(array, 10)
return PLUGIN_HANDLED
}
public Custom2DSort(const elem1[], const elem2[])
{
return strcmp(elem1, elem2)
}
public Command_TestSort2D()
{
new array[][] =
{
"faluco",
"bailopan",
"pm onoto",
"damaged soul",
"sniperbeamer",
"sidluke",
"johnny got his gun",
"gabe newell",
"hello",
"WHAT?!"
}
SortCustom2D(array, 10, "Custom2DSort")
PrintStrings(array, 10)
return PLUGIN_HANDLED
}
/*******************
* ADT ARRAY TESTS *
*******************/
// Int and floats work the same as normal comparisions. Strings are direct
// comparisions with no hacky memory stuff like Pawn arrays.
PrintADTArrayIntegers(Array:array)
{
new size = ArraySize(array);
for (new i=0; i<size;i++)
{
server_print("array[%d] = %d", i, ArrayGetCell(array, i));
}
}
public Command_TestSortADTInts()
{
new Array:array = ArrayCreate();
ArrayPushCell(array, 6);
ArrayPushCell(array, 7);
ArrayPushCell(array, 3);
ArrayPushCell(array, 2);
ArrayPushCell(array, 8);
ArrayPushCell(array, 5);
ArrayPushCell(array, 0);
ArrayPushCell(array, 1);
ArrayPushCell(array, 4);
ArrayPushCell(array, 9);
server_print("Testing ascending sort:")
SortADTArray(array, Sort_Ascending, Sort_Integer)
PrintADTArrayIntegers(array)
server_print("Testing descending sort:")
SortADTArray(array, Sort_Descending, Sort_Integer)
PrintADTArrayIntegers(array)
server_print("Testing random sort:")
SortADTArray(array, Sort_Random, Sort_Integer)
PrintADTArrayIntegers(array)
return PLUGIN_HANDLED
}
PrintADTArrayFloats(Array:array)
{
new size = ArraySize(array);
for (new i=0; i<size;i++)
{
server_print("array[%d] = %f", i, Float:ArrayGetCell(array, i));
}
}
public Command_TestSortADTFloats()
{
new Array:array = ArrayCreate();
ArrayPushCell(array, 6.0);
ArrayPushCell(array, 7.0);
ArrayPushCell(array, 3.0);
ArrayPushCell(array, 2.0);
ArrayPushCell(array, 8.0);
ArrayPushCell(array, 5.0);
ArrayPushCell(array, 0.0);
ArrayPushCell(array, 1.0);
ArrayPushCell(array, 4.0);
ArrayPushCell(array, 9.0);
server_print("Testing ascending sort:")
SortADTArray(array, Sort_Ascending, Sort_Float)
PrintADTArrayFloats(array)
server_print("Testing descending sort:")
SortADTArray(array, Sort_Descending, Sort_Float)
PrintADTArrayFloats(array)
server_print("Testing random sort:")
SortADTArray(array, Sort_Random, Sort_Float)
PrintADTArrayFloats(array)
return PLUGIN_HANDLED
}
PrintADTArrayStrings(Array:array)
{
new size = ArraySize(array);
new buffer[64];
for (new i=0; i<size;i++)
{
ArrayGetString(array, i, buffer, sizeof(buffer));
server_print("array[%d] = %s", i, buffer);
}
}
public Command_TestSortADTStrings()
{
new Array:array = ArrayCreate(64);
ArrayPushString(array, "faluco");
ArrayPushString(array, "bailopan");
ArrayPushString(array, "pm onoto");
ArrayPushString(array, "damaged soul");
ArrayPushString(array, "sniperbeamer");
ArrayPushString(array, "sidluke");
ArrayPushString(array, "johnny got his gun");
ArrayPushString(array, "gabe newell");
ArrayPushString(array, "Hello pRED*");
ArrayPushString(array, "WHAT?!");
server_print("Testing ascending sort:")
SortADTArray(array, Sort_Ascending, Sort_String)
PrintADTArrayStrings(array)
server_print("Testing descending sort:")
SortADTArray(array, Sort_Descending, Sort_String)
PrintADTArrayStrings(array)
server_print("Testing random sort:")
SortADTArray(array, Sort_Random, Sort_String)
PrintADTArrayStrings(array)
return PLUGIN_HANDLED
}
#include <amxmodx>
public plugin_init()
{
register_plugin("Sort Test", "1.0", "BAILOPAN")
register_srvcmd("test_sort_ints", "Command_TestSortInts")
register_srvcmd("test_sort_floats", "Command_TestSortFloats")
register_srvcmd("test_sort_strings", "Command_TestSortStrings")
register_srvcmd("test_sort_1d", "Command_TestSort1D")
register_srvcmd("test_sort_2d", "Command_TestSort2D")
register_srvcmd("test_adtsort_ints", "Command_TestSortADTInts")
register_srvcmd("test_adtsort_floats", "Command_TestSortADTFloats")
register_srvcmd("test_adtsort_strings", "Command_TestSortADTStrings")
}
/*****************
* INTEGER TESTS *
*****************/
// Note that integer comparison is just int1-int2 (or a variation therein)
PrintIntegers(const array[], size)
{
for (new i=0; i<size; i++)
{
server_print("array[%d] = %d", i, array[i])
}
}
public Command_TestSortInts()
{
new array[10] = {6, 7, 3, 2, 8, 5, 0, 1, 4, 9}
server_print("Testing ascending sort:")
SortIntegers(array, 10, Sort_Ascending)
PrintIntegers(array, 10)
server_print("Testing descending sort:")
SortIntegers(array, 10, Sort_Descending)
PrintIntegers(array, 10)
server_print("Testing random sort:")
SortIntegers(array, 10, Sort_Random)
PrintIntegers(array, 10)
}
/**************************
* Float comparison tests *
**************************/
PrintFloats(const Float:array[], size)
{
for (new i=0; i<size; i++)
{
server_print("array[%d] = %f", i, array[i])
}
}
public Command_TestSortFloats()
{
new Float:array[10] = {6.3, 7.6, 3.2, 2.1, 8.5, 5.2, 0.4, 1.7, 4.8, 8.2}
server_print("Testing ascending sort:")
SortFloats(array, 10, Sort_Ascending)
PrintFloats(array, 10)
server_print("Testing descending sort:")
SortFloats(array, 10, Sort_Descending)
PrintFloats(array, 10)
server_print("Testing random sort:")
SortFloats(array, 10, Sort_Random)
PrintFloats(array, 10)
return PLUGIN_HANDLED
}
public Custom1DSort(Float:elem1, Float:elem2)
{
if (elem1 > elem2)
{
return -1;
} else if (elem1 < elem2) {
return 1;
}
return 0;
}
public Command_TestSort1D()
{
new Float:array[10] = {6.3, 7.6, 3.2, 2.1, 8.5, 5.2, 0.4, 1.7, 4.8, 8.2}
SortCustom1D(_:array, 10, "Custom1DSort")
PrintFloats(array, 10)
return PLUGIN_HANDLED
}
/***************************
* String comparison tests *
***************************/
PrintStrings(const array[][], size)
{
for (new i=0; i<size; i++)
{
server_print("array[%d] = %s", i, array[i])
}
}
public Command_TestSortStrings()
{
new array[][] =
{
"faluco",
"bailopan",
"pm onoto",
"damaged soul",
"sniperbeamer",
"sidluke",
"johnny got his gun",
"gabe newell",
"hello",
"WHAT?!"
}
server_print("Testing ascending sort:")
SortStrings(array, 10, Sort_Ascending)
PrintStrings(array, 10)
server_print("Testing descending sort:")
SortStrings(array, 10, Sort_Descending)
PrintStrings(array, 10)
server_print("Testing random sort:")
SortStrings(array, 10, Sort_Random)
PrintStrings(array, 10)
return PLUGIN_HANDLED
}
public Custom2DSort(const elem1[], const elem2[])
{
return strcmp(elem1, elem2)
}
public Command_TestSort2D()
{
new array[][] =
{
"faluco",
"bailopan",
"pm onoto",
"damaged soul",
"sniperbeamer",
"sidluke",
"johnny got his gun",
"gabe newell",
"hello",
"WHAT?!"
}
SortCustom2D(array, 10, "Custom2DSort")
PrintStrings(array, 10)
return PLUGIN_HANDLED
}
/*******************
* ADT ARRAY TESTS *
*******************/
// Int and floats work the same as normal comparisions. Strings are direct
// comparisions with no hacky memory stuff like Pawn arrays.
PrintADTArrayIntegers(Array:array)
{
new size = ArraySize(array);
for (new i=0; i<size;i++)
{
server_print("array[%d] = %d", i, ArrayGetCell(array, i));
}
}
public Command_TestSortADTInts()
{
new Array:array = ArrayCreate();
ArrayPushCell(array, 6);
ArrayPushCell(array, 7);
ArrayPushCell(array, 3);
ArrayPushCell(array, 2);
ArrayPushCell(array, 8);
ArrayPushCell(array, 5);
ArrayPushCell(array, 0);
ArrayPushCell(array, 1);
ArrayPushCell(array, 4);
ArrayPushCell(array, 9);
server_print("Testing ascending sort:")
SortADTArray(array, Sort_Ascending, Sort_Integer)
PrintADTArrayIntegers(array)
server_print("Testing descending sort:")
SortADTArray(array, Sort_Descending, Sort_Integer)
PrintADTArrayIntegers(array)
server_print("Testing random sort:")
SortADTArray(array, Sort_Random, Sort_Integer)
PrintADTArrayIntegers(array)
return PLUGIN_HANDLED
}
PrintADTArrayFloats(Array:array)
{
new size = ArraySize(array);
for (new i=0; i<size;i++)
{
server_print("array[%d] = %f", i, Float:ArrayGetCell(array, i));
}
}
public Command_TestSortADTFloats()
{
new Array:array = ArrayCreate();
ArrayPushCell(array, 6.0);
ArrayPushCell(array, 7.0);
ArrayPushCell(array, 3.0);
ArrayPushCell(array, 2.0);
ArrayPushCell(array, 8.0);
ArrayPushCell(array, 5.0);
ArrayPushCell(array, 0.0);
ArrayPushCell(array, 1.0);
ArrayPushCell(array, 4.0);
ArrayPushCell(array, 9.0);
server_print("Testing ascending sort:")
SortADTArray(array, Sort_Ascending, Sort_Float)
PrintADTArrayFloats(array)
server_print("Testing descending sort:")
SortADTArray(array, Sort_Descending, Sort_Float)
PrintADTArrayFloats(array)
server_print("Testing random sort:")
SortADTArray(array, Sort_Random, Sort_Float)
PrintADTArrayFloats(array)
return PLUGIN_HANDLED
}
PrintADTArrayStrings(Array:array)
{
new size = ArraySize(array);
new buffer[64];
for (new i=0; i<size;i++)
{
ArrayGetString(array, i, buffer, sizeof(buffer));
server_print("array[%d] = %s", i, buffer);
}
}
public Command_TestSortADTStrings()
{
new Array:array = ArrayCreate(64);
ArrayPushString(array, "faluco");
ArrayPushString(array, "bailopan");
ArrayPushString(array, "pm onoto");
ArrayPushString(array, "damaged soul");
ArrayPushString(array, "sniperbeamer");
ArrayPushString(array, "sidluke");
ArrayPushString(array, "johnny got his gun");
ArrayPushString(array, "gabe newell");
ArrayPushString(array, "Hello pRED*");
ArrayPushString(array, "WHAT?!");
server_print("Testing ascending sort:")
SortADTArray(array, Sort_Ascending, Sort_String)
PrintADTArrayStrings(array)
server_print("Testing descending sort:")
SortADTArray(array, Sort_Descending, Sort_String)
PrintADTArrayStrings(array)
server_print("Testing random sort:")
SortADTArray(array, Sort_Random, Sort_String)
PrintADTArrayStrings(array)
return PLUGIN_HANDLED
}