1 Commits

Author SHA1 Message Date
16b7c37d24 Tagged 1.75 2006-07-19 09:23:18 +00:00
465 changed files with 52784 additions and 8740 deletions

View File

@ -33,7 +33,7 @@
#include "debugger.h"
#include "binlog.h"
CForward::CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam *paramTypes, int fwd_type)
CForward::CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam *paramTypes)
{
m_FuncName = name;
m_ExecType = et;
@ -43,17 +43,11 @@ CForward::CForward(const char *name, ForwardExecType et, int numParams, const Fo
// find funcs
int func;
AMXForward *tmp = NULL;
m_Funcs.clear();
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
{
if ((fwd_type != FORWARD_ALL) &&
((fwd_type == FORWARD_ONLY_NEW && ((*iter).getAMX()->flags & AMX_FLAG_OLDFILE))
|| (fwd_type == FORWARD_ONLY_OLD && !((*iter).getAMX()->flags & AMX_FLAG_OLDFILE))
))
{
continue;
}
if ((*iter).isValid() && amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE)
{
AMXForward tmp;
@ -75,6 +69,8 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
cell globRetVal = 0;
unsigned int id = 0;
AMXForwardList::iterator iter;
for (iter = m_Funcs.begin(); iter != m_Funcs.end(); iter++)
@ -89,7 +85,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
pDebugger->BeginExec();
// handle strings & arrays
int i;
int i, ax = 0;
for (i = 0; i < m_NumParams; ++i)
{
@ -359,15 +355,13 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
return retVal;
}
int CForwardMngr::registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam * paramTypes, int fwd_type)
int CForwardMngr::registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam * paramTypes)
{
int retVal = m_Forwards.size() << 1;
CForward *tmp = new CForward(funcName, et, numParams, paramTypes, fwd_type);
CForward *tmp = new CForward(funcName, et, numParams, paramTypes);
if (!tmp)
{
return -1; // should be invalid
}
m_Forwards.push_back(tmp);
@ -460,22 +454,9 @@ cell CForwardMngr::executeForwards(int id, cell *params)
const char *CForwardMngr::getFuncName(int id) const
{
if (!isIdValid(id))
{
return "";
}
return (id & 1) ? m_SPForwards[id >> 1]->getFuncName() : m_Forwards[id >> 1]->getFuncName();
}
int CForwardMngr::getFuncsNum(int id) const
{
if (!isIdValid(id))
{
return 0;
}
return (id & 1) ? m_SPForwards[id >> 1]->getFuncsNum() : m_Forwards[id >> 1]->getFuncsNum();
}
int CForwardMngr::getParamsNum(int id) const
{
return (id & 1) ? m_SPForwards[id >> 1]->getParamsNum() : m_Forwards[id >> 1]->getParamsNum();
@ -483,10 +464,6 @@ int CForwardMngr::getParamsNum(int id) const
ForwardParam CForwardMngr::getParamType(int id, int paramNum) const
{
if (!isIdValid(id))
{
return FP_DONE;
}
return (id & 1) ? m_SPForwards[id >> 1]->getParamType(paramNum) : m_Forwards[id >> 1]->getParamType(paramNum);
}
@ -528,16 +505,14 @@ void CForwardMngr::unregisterSPForward(int id)
m_FreeSPForwards.push(id);
}
int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num, int fwd_type)
int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num)
{
ForwardParam params[FORWARD_MAX_PARAMS];
for (size_t i=0; i<num; i++)
{
params[i] = static_cast<ForwardParam>(list[i]);
}
return g_forwards.registerForward(funcName, et, num, params, fwd_type);
return g_forwards.registerForward(funcName, et, num, params);
}
int registerForward(const char *funcName, ForwardExecType et, ...)

View File

@ -51,10 +51,6 @@
const int FORWARD_MAX_PARAMS = 32;
#define FORWARD_ONLY_OLD 1
#define FORWARD_ONLY_NEW 2
#define FORWARD_ALL 3
enum ForwardExecType
{
ET_IGNORE = 0, // Ignore return vaue
@ -111,7 +107,7 @@ class CForward
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
public:
CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam * paramTypes, int fwd_type=FORWARD_ALL);
CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam * paramTypes);
CForward() {} // leaves everything unitialized'
cell execute(cell *params, ForwardPreparedArray *preparedArrays);
@ -207,7 +203,7 @@ public:
// Interface
// Register normal forward
int registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam *paramTypes, int fwd_type=FORWARD_ALL);
int registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam *paramTypes);
// Register single plugin forward
int registerSPForward(const char *funcName, AMX *amx, int numParams, const ForwardParam * paramTypes);
int registerSPForward(int func, AMX *amx, int numParams, const ForwardParam * paramTypes);
@ -231,7 +227,7 @@ public:
// (un)register forward
int registerForward(const char *funcName, ForwardExecType et, ...);
int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num, int fwd_type=FORWARD_ALL);
int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num);
int registerSPForwardByName(AMX *amx, const char *funcName, ...);
int registerSPForwardByNameC(AMX *amx, const char *funcName, cell *list, size_t num);
int registerSPForward(AMX *amx, int func, ...);

View File

@ -33,7 +33,6 @@
#include "amxmodx.h"
#include "CLang.h"
#include "format.h"
#include "amxmod_compat.h"
#ifdef __linux__
#define _snprintf snprintf
@ -66,10 +65,7 @@ int HashFunction<String>(const String &k)
unsigned long hash = 5381;
register const char *str = k.c_str();
register char c;
while ((c = *str++))
{
hash = ((hash << 5) + hash) + c; // hash*33 + c
}
while (c = *str++) hash = ((hash << 5) + hash) + c; // hash*33 + c
return hash;
}
@ -79,10 +75,7 @@ int HashAlt<const char *>(char const * const &k)
unsigned long hash = 5381;
register const char *str = k;
register char c;
while ((c = *str++))
{
hash = ((hash << 5) + hash) + c; // hash*33 + c
}
while (c = *str++) hash = ((hash << 5) + hash) + c; // hash*33 + c
return hash;
}
@ -257,9 +250,9 @@ int CLangMngr::GetKeyEntry(const char *key)
return val.index;
}
int CLangMngr::AddKeyEntry(const char *key)
int CLangMngr::AddKeyEntry(String &key)
{
keytbl_val val;
keytbl_val val;
val.index = static_cast<int>(KeyList.size());
String *pString = new String(key);
@ -270,11 +263,6 @@ int CLangMngr::AddKeyEntry(const char *key)
return val.index;
}
int CLangMngr::AddKeyEntry(String &key)
{
return AddKeyEntry(key.c_str());
}
int CLangMngr::GetKeyEntry(String &key)
{
keytbl_val &val = KeyTable[key];
@ -288,23 +276,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
static char outbuf[4096];
cell *addr = get_amxaddr(amx, params[parm++]);
if (amx->flags & AMX_FLAG_OLDFILE)
{
if (*addr & BCOMPAT_TRANSLATE_BITS)
{
const char *key, *def;
if (!translate_bcompat(amx, addr, &key, &def))
{
goto normal_string;
}
len = atcprintf(outbuf, sizeof(outbuf)-1, def, amx, params, &parm);
} else {
goto normal_string;
}
} else {
normal_string:
len = atcprintf(outbuf, sizeof(outbuf)-1, addr, amx, params, &parm);
}
len = atcprintf(outbuf, sizeof(outbuf)-1, addr, amx, params, &parm);
return outbuf;
}
@ -381,7 +353,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
CQueue<sKeyDef> Defq;
String buf;
char language[3];
sKeyDef tmpEntry = {NULL, 0};
sKeyDef tmpEntry;
while (!feof(fp))
{
@ -598,7 +570,7 @@ bool CLangMngr::LangExists(const char *langName)
char buf[3] = {0};
int i = 0;
while ((buf[i] = tolower(*langName++)))
while (buf[i] = tolower(*langName++))
{
if (++i == 2)
break;

View File

@ -127,11 +127,9 @@ class CLangMngr
public:
void AddEntry(int key, const char *definition);
};
public:
// Merge definitions into a language
void MergeDefinitions(const char *lang, CQueue <sKeyDef> &tmpVec);
private:
// strip lowercase; make lower if needed
static size_t strip(char *str, char *newstr, bool makelower = false);
@ -162,11 +160,11 @@ public:
// Get index
int GetKeyEntry(String &key);
int GetKeyEntry(const char *key);
int GetKeyIndex(const char *key);
// Get key from index
const char *GetKey(int key);
// Add key
int AddKeyEntry(String &key);
int AddKeyEntry(const char *key);
// Get the number of languages
int GetLangsNum();

View File

@ -40,8 +40,7 @@ void CPlayer::Init(edict_t* e, int i)
pEdict = e;
initialized = false;
ingame = false;
bot_value = false;
bot_cached = false;
bot = false;
authorized = false;
current = 0;
@ -89,8 +88,7 @@ void CPlayer::Disconnect()
}
queries.clear();
bot_value = false;
bot_cached = false;
bot = 0;
menu = 0;
newmenu = -1;
}
@ -116,11 +114,10 @@ int CPlayer::NextHUDChannel()
bool CPlayer::Connect(const char* connectname, const char* ipaddress)
{
bot_value = false;
bot_cached = false;
name.assign(connectname);
ip.assign(ipaddress);
time = gpGlobals->time;
bot = IsBot();
death_killer = 0;
menu = 0;
newmenu = -1;

View File

@ -58,7 +58,6 @@ public:
inline const char* getPluginName() { return plugin.c_str(); }
inline const char* getName() { return name.c_str(); }
inline bool operator == (const char* string) { return (strcmp(name.c_str(), string) == 0); }
int plugin_id;
};
// *****************************************************
@ -84,8 +83,7 @@ public:
bool initialized;
bool ingame;
bool bot_cached;
bool bot_value;
bool bot;
bool authorized;
bool vgui;
@ -133,24 +131,7 @@ public:
inline bool IsBot()
{
if (!bot_cached)
{
bot_value = false;
if (pEdict->v.flags & FL_FAKECLIENT)
{
bot_value = true;
bot_cached = true;
} else {
const char *auth = GETPLAYERAUTHID(pEdict);
if (auth && (strcmp(auth, "BOT") == 0))
{
bot_value = true;
bot_cached = true;
}
}
}
return bot_value;
return ((pEdict->v.flags & FL_FAKECLIENT) ? true : false);
}
inline bool IsAlive()

View File

@ -89,7 +89,6 @@ void CModule::clear(bool clearFilename)
m_DestroyableIndexes.clear();
m_Natives.clear();
m_NewNatives.clear();
}
bool CModule::attachMetamod(const char *mmfile, PLUG_LOADTIME now)

View File

@ -117,7 +117,6 @@ public:
void CallPluginsUnloading();
CVector<AMX_NATIVE_INFO*> m_Natives;
CVector<AMX_NATIVE_INFO*> m_NewNatives; // Natives for new (AMXX, not AMX) plugins only
CVector<size_t> m_DestroyableIndexes;
};

View File

@ -81,17 +81,14 @@ void CPluginMngr::Finalize()
m_Finalized = true;
}
int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
int CPluginMngr::loadPluginsFromFile(const char* filename)
{
char file[256];
FILE *fp = fopen(build_pathname_r(file, sizeof(file) - 1, "%s", filename), "rt");
if (!fp)
{
if (warn)
{
AMXXLOG_Log("[AMXX] Plugins list not found (file \"%s\")", filename);
}
AMXXLOG_Log("[AMXX] Plugins list not found (file \"%s\")", filename);
return 1;
}
@ -102,8 +99,6 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
String line;
List<String *>::iterator block_iter;
while (!feof(fp))
{
pluginName[0] = '\0';
@ -127,32 +122,13 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
sscanf(line.c_str(), "%s %s", pluginName, debug);
if (!isalnum(*pluginName))
{
continue;
}
if (isalnum(*debug) && !strcmp(debug, "debug"))
if (isalnum(*debug) && strcmp(debug, "debug") == 0)
{
debugFlag = 1;
}
bool skip = false;
for (block_iter = m_BlockList.begin();
block_iter != m_BlockList.end();
block_iter++)
{
if ((*block_iter)->compare(pluginName) == 0)
{
skip = true;
break;
}
}
if (skip || !strcmp(debug, "disabled"))
{
continue;
}
CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, debugFlag);
if (plugin->getStatusCode() == ps_bad_load)
@ -166,6 +142,8 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
fclose(fp);
InvalidateCache();
return pCounter;
}
@ -183,14 +161,6 @@ void CPluginMngr::clear()
delete [] pNatives;
pNatives = NULL;
}
List<String *>::iterator iter = m_BlockList.begin();
while (iter != m_BlockList.end())
{
delete (*iter);
iter = m_BlockList.erase(iter);
}
m_BlockList.clear();
}
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx)
@ -417,16 +387,14 @@ void CPluginMngr::CPlugin::pausePlugin()
// Unpause a plugin
void CPluginMngr::CPlugin::unpausePlugin()
{
if (isValid() && (getStatusCode() != ps_stopped))
if (isValid())
{
// set status first so the function will be marked executable
setStatus(ps_running);
// call plugin_unpause if provided
if (m_UnpauseFwd != -1)
{
executeForwards(m_UnpauseFwd);
}
}
}
@ -449,8 +417,7 @@ char *CPluginMngr::ReadIntoOrFromCache(const char *file, size_t &bufsize)
pl->file = new CAmxxReader(file, sizeof(cell));
pl->buffer = NULL;
if (pl->file->GetStatus() != CAmxxReader::Err_None ||
pl->file->IsOldFile())
if (pl->file->GetStatus() != CAmxxReader::Err_None)
{
delete pl->file;
delete pl;
@ -649,9 +616,7 @@ void CPluginMngr::CALMFromFile(const char *file)
{
fgets(line, sizeof(line)-1, fp);
if (line[0] == ';' || line[0] == '\n' || line[0] == '\0')
{
continue;
}
/** quick hack */
char *ptr = line;
@ -670,28 +635,8 @@ void CPluginMngr::CALMFromFile(const char *file)
pluginName[0] = '\0';
sscanf(rline.c_str(), "%s", pluginName);
/* HACK: see if there's a 'disabled' coming up
* new block for scopying flexibility
*/
if (1)
{
const char *_ptr = rline.c_str() + strlen(pluginName);
while (*_ptr != '\0' && isspace(*_ptr))
{
_ptr++;
}
if ((*_ptr != '\0') && !strcmp(_ptr, "disabled"))
{
String *pString = new String(pluginName);
m_BlockList.push_back(pString);
continue;
}
}
if (!isalnum(*pluginName))
{
continue;
}
build_pathname_r(filename, sizeof(filename)-1, "%s/%s", get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins"), pluginName);

View File

@ -125,7 +125,7 @@ public:
CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug);
void unloadPlugin(CPlugin** a);
int loadPluginsFromFile(const char* filename, bool warn=true);
int loadPluginsFromFile(const char* filename);
inline CPlugin* findPluginFast(AMX *amx) { return (CPlugin*)(amx->userdata[UD_FINDPLUGIN]); }
CPlugin* findPlugin(AMX *amx);
@ -165,7 +165,6 @@ public:
void CALMFromFile(const char *file);
private:
List<plcache_entry *> m_plcache;
List<String *> m_BlockList;
};
#endif //PLUGIN_H

Binary file not shown.

Binary file not shown.

View File

@ -1,14 +1,14 @@
#(C)2004-2005 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson
HLSDK = ../../hlsdk
HLSDK = ../hlsdk/SourceCode
MM_ROOT = ../metamod/metamod
### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O2 -fno-strict-aliasing -funroll-loops -s -fomit-frame-pointer -pipe
OPT_FLAGS = -O2 -funroll-loops -s -fomit-frame-pointer -pipe
DEBUG_FLAGS = -g -ggdb3
CPP = gcc-4.1
CPP = gcc
NAME = amxmodx
BIN_SUFFIX_32 = mm_i386.so
@ -19,20 +19,13 @@ OBJECTS = meta_api.cpp CFile.cpp CVault.cpp vault.cpp float.cpp file.cpp modules
srvcmd.cpp strptime.cpp amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp \
amxxfile.cpp CLang.cpp md5.cpp emsg.cpp CForward.cpp CPlugin.cpp CModule.cpp \
CMenu.cpp util.cpp amx.cpp amxdbg.cpp natives.cpp newmenus.cpp debugger.cpp \
optimizer.cpp format.cpp messages.cpp libraries.cpp vector.cpp sorting.cpp \
amxmod_compat.cpp
optimizer.cpp format.cpp messages.cpp libraries.cpp vector.cpp
LINK = -lgcc -static-libgcc
LINK = /lib/libstdc++.a
INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \
-I$(MM_ROOT) -Lzlib -I$(HLSDK)/common
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
ifeq "$(GCC_VERSION)" "4"
OPT_FLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
endif
ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS = $(DEBUG_FLAGS)
@ -48,7 +41,7 @@ ifeq "$(BINLOG)" "true"
CFLAGS += -DBINLOG_ENABLED
endif
CFLAGS += -DLINUX -DNDEBUG -DAMX_NOPROPLIST -fPIC -Wall -Werror -DHAVE_STDINT_H -static-libgcc -fno-rtti -fno-exceptions
CFLAGS += -DLINUX -DNDEBUG -fPIC -Wno-deprecated -DHAVE_STDINT_H -static-libgcc -fno-rtti -fno-exceptions
ifeq "$(AMD64)" "true"
BINARY = $(NAME)_$(BIN_SUFFIX_64)

View File

@ -22,9 +22,9 @@
*/
#define AMX_NODYNALOAD
#define AMX_ANSIONLY
#define AMX_ANSIONLY
#if !defined __linux__ && BUILD_PLATFORM == WINDOWS && BUILD_TYPE == RELEASE && BUILD_COMPILER == MSVC && PAWN_CELL_SIZE == 64
#if BUILD_PLATFORM == WINDOWS && BUILD_TYPE == RELEASE && BUILD_COMPILER == MSVC && PAWN_CELL_SIZE == 64
/* bad bad workaround but we have to prevent a compiler crash :/ */
#pragma optimize("g",off)
#endif
@ -990,7 +990,6 @@ int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
amx->cip = hdr->cip;
amx->hea = hdr->hea;
amx->stp = hdr->stp - sizeof(cell);
amx->hlw = hdr->hea;
/* also put a sentinel for strings at the top the stack */
*(cell *)((char*)native_code + hdr->dat + hdr->stp - sizeof(cell)) = 0;
amx->stk = amx->stp;

View File

@ -214,7 +214,7 @@ typedef struct tagAMX_NATIVE_INFO {
typedef struct tagAMX_FUNCSTUB {
ucell address PACKED;
char name[sEXPMAX+1];
char name[sEXPMAX+1] PACKED;
} PACKED AMX_FUNCSTUB;
typedef struct tagFUNCSTUBNT {
@ -265,8 +265,8 @@ typedef struct tagAMX {
typedef struct tagAMX_HEADER {
int32_t size PACKED; /* size of the "file" */
uint16_t magic PACKED; /* signature */
char file_version; /* file format version */
char amx_version; /* required version of the AMX */
char file_version PACKED; /* file format version */
char amx_version PACKED; /* required version of the AMX */
int16_t flags PACKED;
int16_t defsize PACKED; /* size of a definition record */
int32_t cod PACKED; /* initial value of COD - code block */
@ -322,7 +322,6 @@ enum {
#define AMX_FLAG_COMPACT 0x04 /* compact encoding */
#define AMX_FLAG_BYTEOPC 0x08 /* opcode is a byte (not a cell) */
#define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no STMT opcode */
#define AMX_FLAG_OLDFILE 0x20 /* Old AMX Mod plugin */
#define AMX_FLAG_PRENIT 0x100 /* pre-initialized, do not check natives */
#define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */
#define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */

View File

@ -65,8 +65,8 @@ extern "C" {
typedef struct tagAMX_DBG_HDR {
int32_t size PACKED; /* size of the debug information chunk */
uint16_t magic PACKED; /* signature, must be 0xf1ef */
char file_version; /* file format version */
char amx_version; /* required version of the AMX */
char file_version PACKED; /* file format version */
char amx_version PACKED; /* required version of the AMX */
int16_t flags PACKED; /* currently unused */
int16_t files PACKED; /* number of entries in the "file" table */
int16_t lines PACKED; /* number of entries in the "line" table */
@ -74,51 +74,51 @@ typedef struct tagAMX_DBG_HDR {
int16_t tags PACKED; /* number of entries in the "tag" table */
int16_t automatons PACKED; /* number of entries in the "automaton" table */
int16_t states PACKED; /* number of entries in the "state" table */
} PACKED AMX_DBG_HDR;
} AMX_DBG_HDR PACKED;
#define AMX_DBG_MAGIC 0xf1ef
typedef struct tagAMX_DBG_FILE {
ucell address PACKED; /* address in the code segment where generated code (for this file) starts */
const char name[1]; /* ASCII string, zero-terminated */
} PACKED AMX_DBG_FILE;
const char name[1] PACKED; /* ASCII string, zero-terminated */
} AMX_DBG_FILE PACKED;
typedef struct tagAMX_DBG_LINE {
ucell address PACKED; /* address in the code segment where generated code (for this line) starts */
int32_t line PACKED; /* line number */
} PACKED AMX_DBG_LINE;
} AMX_DBG_LINE PACKED;
typedef struct tagAMX_DBG_SYMBOL {
ucell address PACKED; /* address in the data segment or relative to the frame */
int16_t tag PACKED; /* tag for the symbol */
ucell codestart PACKED; /* address in the code segment from which this symbol is valid (in scope) */
ucell codeend PACKED; /* address in the code segment until which this symbol is valid (in scope) */
char ident; /* kind of symbol (function/variable) */
char vclass; /* class of symbol (global/local) */
char ident PACKED; /* kind of symbol (function/variable) */
char vclass PACKED; /* class of symbol (global/local) */
int16_t dim PACKED; /* number of dimensions */
const char name[1]; /* ASCII string, zero-terminated */
} PACKED AMX_DBG_SYMBOL;
const char name[1] PACKED; /* ASCII string, zero-terminated */
} AMX_DBG_SYMBOL PACKED;
typedef struct tagAMX_DBG_SYMDIM {
int16_t tag PACKED; /* tag for the array dimension */
ucell size PACKED; /* size of the array dimension */
} PACKED AMX_DBG_SYMDIM;
} AMX_DBG_SYMDIM PACKED;
typedef struct tagAMX_DBG_TAG {
int16_t tag PACKED; /* tag id */
const char name[1]; /* ASCII string, zero-terminated */
} PACKED AMX_DBG_TAG;
const char name[1] PACKED; /* ASCII string, zero-terminated */
} AMX_DBG_TAG PACKED;
typedef struct tagAMX_DBG_MACHINE {
int16_t automaton PACKED; /* automaton id */
ucell address PACKED; /* address of state variable */
const char name[1]; /* ASCII string, zero-terminated */
} PACKED AMX_DBG_MACHINE;
const char name[1] PACKED; /* ASCII string, zero-terminated */
} AMX_DBG_MACHINE PACKED;
typedef struct tagAMX_DBG_STATE {
int16_t state PACKED; /* state id */
int16_t automaton PACKED; /* automaton id */
const char name[1]; /* ASCII string, zero-terminated */
} PACKED AMX_DBG_STATE;
const char name[1] PACKED; /* ASCII string, zero-terminated */
} AMX_DBG_STATE PACKED;
typedef struct tagAMX_DBG {
AMX_DBG_HDR _FAR *hdr PACKED; /* points to the AMX_DBG header */
@ -128,7 +128,7 @@ typedef struct tagAMX_DBG {
AMX_DBG_TAG _FAR **tagtbl PACKED;
AMX_DBG_MACHINE _FAR **automatontbl PACKED;
AMX_DBG_STATE _FAR **statetbl PACKED;
} PACKED AMX_DBG;
} AMX_DBG PACKED;
#if !defined iVARIABLE
#define iVARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */

View File

@ -2122,9 +2122,7 @@ err_heaplow:
_CHKMARGIN_HEAP:
cmp esi,stp
jg err_stacklow
mov ebp,amx
mov ebp,[ebp+_hlw]
cmp dword hea,ebp
cmp dword hea,0
jl err_heaplow
ret

View File

@ -1,117 +0,0 @@
#include "amxmodx.h"
#include "amxmod_compat.h"
#include "format.h"
bool GetTranslation(amxtrans_t trans, int &key, int &dest, int &lang)
{
key = (trans & BCOMPAT_TRANSLATE_KEYMASK);
dest = (trans >> BCOMPAT_TRANSLATE_DESTRSH) & BCOMPAT_TRANSLATE_DESTMASK;
lang = (trans >> BCOMPAT_TRANSLATE_LANGRSH) & BCOMPAT_TRANSLATE_LANGMASK;
if (dest == 0x3F)
{
dest = -1;
}
if (lang == 0x1F)
{
lang = -1;
}
return true;
}
bool translate_bcompat(AMX *amx, cell *source, const char **_key, const char **_def)
{
amxtrans_t trans = static_cast<amxtrans_t>(*source);
int key, _dest, lang;
if (!GetTranslation(trans, key, _dest, lang))
{
return false;
}
cell amx_addr, *phys_addr;
if (amx_Allot(amx, 3, &amx_addr, &phys_addr) != AMX_ERR_NONE)
{
return false;
}
if (_dest == -1)
{
*phys_addr = LANG_PLAYER;
} else if (_dest == 0) {
*phys_addr = LANG_SERVER;
} else if (lang >= 0 && lang < g_langMngr.GetLangsNum()) {
const char *name = g_langMngr.GetLangName(lang);
phys_addr[0] = static_cast<cell>(name[0]);
phys_addr[1] = static_cast<cell>(name[1]);
phys_addr[2] = static_cast<cell>('\0');
} else {
*phys_addr = LANG_SERVER;
}
//not optimized but it works, eh
//if someone cares they can make a translate() wrapper that takes the key # in directly
const char *r_key = g_langMngr.GetKey(key);
const char *def = translate(amx, amx_addr, r_key);
if (!def)
{
def = r_key;
}
amx_Release(amx, amx_addr);
*_key = g_langMngr.GetKey(key);
*_def = def;
return true;
}
static cell AMX_NATIVE_CALL amx_translate(AMX *amx, cell *params)
{
int len;
char *key = get_amxstring(amx, params[1], 0, len);
amxtrans_t trans;
int suki = g_langMngr.GetKeyEntry(key);
//Some AMX Mod plugins do not register everything they need. Prevent a crash.
if (suki == -1)
{
suki = g_langMngr.AddKeyEntry(key);
}
if (suki > BCOMPAT_TRANSLATE_KEYMASK)
{
LogError(amx, AMX_ERR_NATIVE, "Not enough translation space, aborting!");
return 0;
}
trans = suki & BCOMPAT_TRANSLATE_KEYMASK;
int dest = static_cast<int>(params[2]);
int lang = static_cast<int>(params[3]);
if (dest == -1)
{
trans |= (0x3F << BCOMPAT_TRANSLATE_DESTRSH);
} else {
trans |= (dest & BCOMPAT_TRANSLATE_DESTMASK) << BCOMPAT_TRANSLATE_DESTRSH;
}
if (lang == -1)
{
trans |= (0x1F << BCOMPAT_TRANSLATE_LANGRSH);
} else {
trans |= (lang & BCOMPAT_TRANSLATE_LANGMASK) << BCOMPAT_TRANSLATE_LANGRSH;
}
trans |= BCOMPAT_TRANSLATE_BITS;
return static_cast<cell>(trans);
}
AMX_NATIVE_INFO g_BcompatNatives[] =
{
{"translate", amx_translate},
{NULL, NULL},
};

View File

@ -1,28 +0,0 @@
#ifndef _INCLUDE_AMXMOD_CORE_COMPAT_H
#define _INCLUDE_AMXMOD_CORE_COMPAT_H
/**
* New format for translation:
* Note that we only support:
* 4k keys
* 32 languages
* 0000 0000 0000 0000 0000 0000 0000 0000
* | key id |
* | | <- dest id
* | | <- lang id
*/
#define BCOMPAT_TRANSLATE_BITS 0xFF000000
#define BCOMPAT_TRANSLATE_KEYMASK 0xFFF
#define BCOMPAT_TRANSLATE_DESTMASK 0x3F
#define BCOMPAT_TRANSLATE_DESTRSH 12
#define BCOMPAT_TRANSLATE_LANGMASK 0x1F
#define BCOMPAT_TRANSLATE_LANGRSH 18
typedef unsigned int amxtrans_t;
bool GetTranslation(amxtrans_t trans, int &key, int &dest, int &lang);
extern AMX_NATIVE_INFO g_BcompatNatives[];
#endif //_INCLUDE_AMXMOD_CORE_COMPAT_H

View File

@ -36,8 +36,6 @@
#include "binlog.h"
#include "libraries.h"
const char *invis_cvar_list[5] = {"amxmodx_version", "amxmodx_modules", "amx_debug", "amx_mldebug", "amx_client_languages"};
static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params)
{
int len;
@ -179,7 +177,7 @@ static cell AMX_NATIVE_CALL console_cmd(AMX *amx, cell *params) /* 2 param */
} else {
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (!pPlayer->IsBot() && pPlayer->initialized)
if (!pPlayer->bot && pPlayer->initialized)
CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd);
}
@ -518,7 +516,7 @@ static cell AMX_NATIVE_CALL is_user_bot(AMX *amx, cell *params) /* 1 param */
if (index < 1 || index > gpGlobals->maxClients)
return 0;
return (GET_PLAYER_POINTER_I(index)->IsBot() ? 1 : 0);
return (GET_PLAYER_POINTER_I(index)->bot ? 1 : 0);
}
static cell AMX_NATIVE_CALL is_user_hltv(AMX *amx, cell *params) /* 1 param */
@ -544,27 +542,14 @@ static cell AMX_NATIVE_CALL is_user_hltv(AMX *amx, cell *params) /* 1 param */
return 0;
}
extern bool g_bmod_tfc;
static cell AMX_NATIVE_CALL is_user_alive(AMX *amx, cell *params) /* 1 param */
{
int index = params[1];
if (index < 1 || index > gpGlobals->maxClients)
{
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (g_bmod_tfc)
{
edict_t *e = pPlayer->pEdict;
if (e->v.flags & FL_SPECTATOR ||
(!e->v.team || !e->v.playerclass))
{
return 0;
}
}
return ((pPlayer->ingame && pPlayer->IsAlive()) ? 1 : 0);
}
@ -991,9 +976,7 @@ static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params) /* 3 param */
}
//
if (params[3])
{
set_amxstring(amx, params[2], pPlayer->team.c_str(), params[3]);
}
return pPlayer->teamId;
}
@ -1129,16 +1112,6 @@ static cell AMX_NATIVE_CALL get_plugin(AMX *amx, cell *params) /* 11 param */
return a->getId();
}
if (params[0] / sizeof(cell) >= 12)
{
cell *jit_info = get_amxaddr(amx, params[12]);
#if defined AMD64 || !defined JIT
*jit_info = 0;
#else
*jit_info = a->isDebug() ? 0 : 1;
#endif
}
return -1;
}
@ -1315,28 +1288,6 @@ static cell AMX_NATIVE_CALL get_concmd(AMX *amx, cell *params) /* 7 param */
return 1;
}
static cell AMX_NATIVE_CALL get_concmd_plid(AMX *amx, cell *params)
{
int who = params[3];
if (who > 0)
{
who = CMD_ClientCommand;
} else if (who == 0) {
who = CMD_ServerCommand;
} else {
who = CMD_ConsoleCommand;
}
CmdMngr::Command *cmd = g_commands.getCmd(params[1], who, params[2]);
if (cmd == NULL)
{
return -1;
}
return cmd->getPlugin()->getId();
}
static cell AMX_NATIVE_CALL get_clcmd(AMX *amx, cell *params) /* 7 param */
{
CmdMngr::Command* cmd = g_commands.getCmd(params[1], CMD_ClientCommand, params[7]);
@ -1555,7 +1506,7 @@ static cell AMX_NATIVE_CALL client_cmd(AMX *amx, cell *params) /* 2 param */
for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (!pPlayer->IsBot() && pPlayer->initialized /*&& pPlayer->ingame*/)
if (!pPlayer->bot && pPlayer->initialized /*&& pPlayer->ingame*/)
CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd);
}
} else {
@ -1569,7 +1520,7 @@ static cell AMX_NATIVE_CALL client_cmd(AMX *amx, cell *params) /* 2 param */
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (!pPlayer->IsBot() && pPlayer->initialized /*&& pPlayer->ingame*/)
if (!pPlayer->bot && pPlayer->initialized /*&& pPlayer->ingame*/)
CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd);
}
@ -1592,19 +1543,6 @@ static cell AMX_NATIVE_CALL get_cvar_string(AMX *amx, cell *params) /* 3 param *
{
int ilen;
char* sptemp = get_amxstring(amx, params[1], 0, ilen);
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = sptemp;
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
return set_amxstring(amx, params[2], CVAR_GET_STRING(sptemp), params[3]);
}
@ -1626,20 +1564,6 @@ static cell AMX_NATIVE_CALL get_pcvar_float(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_cvar_float(AMX *amx, cell *params) /* 1 param */
{
int ilen;
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = get_amxstring(amx, params[1], 0, ilen);
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
REAL pFloat = CVAR_GET_FLOAT(get_amxstring(amx, params[1], 0, ilen));
return amx_ftoc(pFloat);
@ -1682,18 +1606,6 @@ static cell AMX_NATIVE_CALL get_pcvar_num(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_cvar_num(AMX *amx, cell *params) /* 1 param */
{
int ilen;
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = get_amxstring(amx, params[1], 0, ilen);
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
return (int)CVAR_GET_FLOAT(get_amxstring(amx, params[1], 0, ilen));
}
@ -1971,7 +1883,7 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */
{
if (pPlayer->IsAlive() ? (flags & 2) : (flags & 1))
continue;
if (pPlayer->IsBot() ? (flags & 4) : (flags & 8))
if (pPlayer->bot ? (flags & 4) : (flags & 8))
continue;
if ((flags & 16) && (pPlayer->teamId != team))
continue;
@ -2028,7 +1940,7 @@ static cell AMX_NATIVE_CALL find_player(AMX *amx, cell *params) /* 1 param */
if (pPlayer->IsAlive() ? (flags & 64) : (flags & 32))
continue;
if (pPlayer->IsBot() ? (flags & 128) : (flags & 256))
if (pPlayer->bot ? (flags & 128) : (flags & 256))
continue;
if (flags & 1)
@ -2264,18 +2176,6 @@ static cell AMX_NATIVE_CALL task_exists(AMX *amx, cell *params) /* 1 param */
static cell AMX_NATIVE_CALL cvar_exists(AMX *amx, cell *params) /* 1 param */
{
int ilen;
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = get_amxstring(amx, params[1], 0, ilen);
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
return (CVAR_GET_POINTER(get_amxstring(amx, params[1], 0, ilen)) ? 1 : 0);
}
@ -2289,7 +2189,8 @@ static cell AMX_NATIVE_CALL register_cvar(AMX *amx, cell *params) /* 3 param */
CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx);
CCVar* cvar = new CCVar(temp, plugin->getName(), params[3], amx_ctof(params[4]));
cvar->plugin_id = plugin->getId();
if (cvar == 0)
return 0;
g_cvars.put(cvar);
@ -2681,43 +2582,6 @@ static cell AMX_NATIVE_CALL remove_quotes(AMX *amx, cell *params) /* 1 param */
return 0;
}
//native get_plugins_cvar(id, name[], namelen, &flags=0, &plugin_id=0, &pcvar_handle=0);
static cell AMX_NATIVE_CALL get_plugins_cvar(AMX *amx, cell *params)
{
int id = params[1];
int iter_id = 0;
for (CList<CCVar>::iterator iter=g_cvars.begin(); iter; ++iter)
{
if (id == iter_id)
{
CCVar *var = &(*iter);
set_amxstring(amx, params[2], var->getName(), params[3]);
cvar_t *ptr = CVAR_GET_POINTER(var->getName());
if (!ptr)
{
return 0;
}
cell *addr = get_amxaddr(amx, params[4]);
*addr = ptr->flags;
addr = get_amxaddr(amx, params[5]);
*addr = var->plugin_id;
addr = get_amxaddr(amx, params[6]);
*addr = (cell)ptr;
return 1;
}
iter_id++;
}
return 0;
}
//native get_plugins_cvarsnum();
static cell AMX_NATIVE_CALL get_plugins_cvarsnum(AMX *amx, cell *params)
{
return g_cvars.size();
}
static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param */
{
int index = params[1];
@ -2731,16 +2595,18 @@ static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param *
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
cell *cpId = get_amxaddr(amx, params[2]);
cell *cpBody = get_amxaddr(amx, params[3]);
cell fCell;
REAL *pFloat = (REAL *)((void *)&fCell);
*pFloat = 0.0;
REAL pfloat = 0.0f;
if (pPlayer->ingame)
{
edict_t* edict = pPlayer->pEdict;
Vector v_forward;
Vector v_src = edict->v.origin + edict->v.view_ofs;
ANGLEVECTORS(edict->v.v_angle, v_forward, NULL, NULL);
TraceResult trEnd;
Vector v_dest = v_src + v_forward * static_cast<float>(params[4]);
@ -2751,14 +2617,17 @@ static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param *
if (trEnd.flFraction < 1.0)
{
pfloat = (trEnd.vecEndPos - v_src).Length();
*pFloat = (trEnd.vecEndPos - v_src).Length();
return fCell;
} else {
return fCell;
}
} else {
*cpId = 0;
*cpBody = 0;
}
*cpId = 0;
*cpBody = 0;
return amx_ftoc(pfloat);
return fCell;
}
static cell AMX_NATIVE_CALL remove_cvar_flags(AMX *amx, cell *params)
@ -2796,20 +2665,6 @@ static cell AMX_NATIVE_CALL get_cvar_flags(AMX *amx, cell *params)
{
int ilen;
char* sCvar = get_amxstring(amx, params[1], 0, ilen);
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = sCvar;
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
cvar_t* pCvar = CVAR_GET_POINTER(sCvar);
return pCvar ? pCvar->flags : 0;
@ -3062,7 +2917,7 @@ static cell AMX_NATIVE_CALL register_byval(AMX *amx, cell *params)
//get the destination string
char *data = get_amxstring(amx, params[2], 0, len);
void *PT = NULL;
void *PT;
//copy
ucy(p, dtr);
@ -3204,8 +3059,6 @@ struct CallFunc_ParamInfo
unsigned char flags; // flags
cell byrefAddr; // byref address in caller plugin
cell size; // byref size
cell *alloc; // allocated block
bool copyback; // copy back?
};
#if !defined CALLFUNC_MAXPARAMS
@ -3303,30 +3156,19 @@ static cell AMX_NATIVE_CALL get_func_id(AMX *amx, cell *params)
CPluginMngr::CPlugin *plugin;
if (params[2] < 0)
{
plugin = g_plugins.findPluginFast(amx);
} else {
else
plugin = g_plugins.findPlugin(params[2]);
}
if (!plugin)
{
return -1;
}
if (!plugin->isValid())
{
return -1;
}
int len;
const char *funcName = get_amxstring(amx, params[1], 0, len);
int index, err;
if ((err = amx_FindPublic(plugin->getAMX(), funcName, &index)) != AMX_ERR_NONE)
{
index = -1;
}
return index;
}
@ -3367,32 +3209,7 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
Debugger *pDebugger = (Debugger *)pAmx->userdata[UD_DEBUGGER];
if (pDebugger)
{
pDebugger->BeginExec();
}
// first pass over byref things
for (int i = curParam - 1; i >= 0; i--)
{
if (gparamInfo[i].flags & CALLFUNC_FLAG_BYREF)
{
cell amx_addr, *phys_addr;
amx_Allot(pAmx, gparamInfo[i].size, &amx_addr, &phys_addr);
memcpy(phys_addr, gparamInfo[i].alloc, gparamInfo[i].size * sizeof(cell));
gparams[i] = amx_addr;
delete [] gparamInfo[i].alloc;
gparamInfo[i].alloc = NULL;
}
}
// second pass, link in reused byrefs
for (int i = curParam - 1; i >= 0; i--)
{
if (gparamInfo[i].flags & CALLFUNC_FLAG_BYREF_REUSED)
{
gparams[i] = gparams[gparams[i]];
}
}
// actual call
// Pawn - push parameters in reverse order
@ -3414,9 +3231,7 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
}
if (pDebugger)
{
pDebugger->EndExec();
}
// process byref params (not byref_reused)
for (int i = 0; i < curParam; ++i)
@ -3424,20 +3239,17 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
if (gparamInfo[i].flags & CALLFUNC_FLAG_BYREF)
{
// copy back so that references work
AMX *amxCaller = curPlugin->getAMX();
AMX *amxCalled = plugin->getAMX();
if (gparamInfo[i].copyback)
{
AMX *amxCaller = curPlugin->getAMX();
AMX_HEADER *hdrCaller = (AMX_HEADER *)amxCaller->base;
AMX_HEADER *hdrCalled = (AMX_HEADER *)amxCalled->base;
memcpy( /** DEST ADDR **/
(amxCaller->data ? amxCaller->data : (amxCaller->base + hdrCaller->dat)) + gparamInfo[i].byrefAddr,
/** SOURCE ADDR **/
(amxCalled->data ? amxCalled->data : (amxCalled->base + hdrCalled->dat)) + gparams[i],
/** SIZE **/
gparamInfo[i].size * sizeof(cell));
}
AMX_HEADER *hdrCaller = (AMX_HEADER *)amxCaller->base;
AMX_HEADER *hdrCalled = (AMX_HEADER *)amxCalled->base;
memcpy( /** DEST ADDR **/
(amxCaller->data ? amxCaller->data : (amxCaller->base + hdrCaller->dat)) + gparamInfo[i].byrefAddr,
/** SOURCE ADDR **/
(amxCalled->data ? amxCalled->data : (amxCalled->base + hdrCalled->dat)) + gparams[i],
/** SIZE **/
gparamInfo[i].size * sizeof(cell));
// free memory used for params passed by reference
amx_Release(amxCalled, gparams[i]);
@ -3451,6 +3263,8 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
// native callfunc_push_float(Float: value);
static cell AMX_NATIVE_CALL callfunc_push_byval(AMX *amx, cell *params)
{
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
if (!g_CallFunc_Plugin)
{
// scripter's fault
@ -3498,14 +3312,20 @@ static cell AMX_NATIVE_CALL callfunc_push_byref(AMX *amx, cell *params)
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF_REUSED;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = NULL;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = true;
g_CallFunc_Params[g_CallFunc_CurParam++] = i; /* referenced parameter */
g_CallFunc_Params[g_CallFunc_CurParam++] = g_CallFunc_Params[i];
// we are done
return 0;
}
}
cell *phys_addr = new cell[1];
// not found; create an own copy
// allocate memory
cell *phys_addr;
cell amx_addr;
amx_Allot(g_CallFunc_Plugin->getAMX(),
1, // 1 cell
&amx_addr,
&phys_addr);
// copy the value to the allocated memory
cell *phys_addr2;
@ -3516,69 +3336,7 @@ static cell AMX_NATIVE_CALL callfunc_push_byref(AMX *amx, cell *params)
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = phys_addr;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = true;
g_CallFunc_Params[g_CallFunc_CurParam++] = 0;
return 0;
}
// native callfunc_push_array(array[], size, [copyback])
static cell AMX_NATIVE_CALL callfunc_push_array(AMX *amx, cell *params)
{
if (!g_CallFunc_Plugin)
{
// scripter's fault
LogError(amx, AMX_ERR_NATIVE, "callfunc_push_xxx called without callfunc_begin");
return 0;
}
if (g_CallFunc_CurParam == CALLFUNC_MAXPARAMS)
{
LogError(amx, AMX_ERR_NATIVE, "callfunc_push_xxx: maximal parameters num: %d", CALLFUNC_MAXPARAMS);
return 0;
}
// search for the address; if it is found, dont create a new copy
for (int i = 0; i < g_CallFunc_CurParam; ++i)
{
if ((g_CallFunc_ParamInfo[i].flags & CALLFUNC_FLAG_BYREF) && (g_CallFunc_ParamInfo[i].byrefAddr == params[1]))
{
// the byrefAddr and size params should not be used; set them anyways...
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF_REUSED;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = NULL;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = g_CallFunc_ParamInfo[i].copyback;
g_CallFunc_Params[g_CallFunc_CurParam++] = i; /* referenced parameter */
return 0;
}
}
// not found; create an own copy
// get the string and its length
cell *pArray = get_amxaddr(amx, params[1]);
cell array_size = params[2];
// allocate enough memory for the array
cell *phys_addr = new cell[array_size];
memcpy(phys_addr, pArray, array_size * sizeof(cell));
// push the address and set the reference flag so that memory is released after function call.
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = array_size;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = phys_addr;
if (params[0] / sizeof(cell) >= 3)
{
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = params[3] ? true : false;
} else {
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = true;
}
g_CallFunc_Params[g_CallFunc_CurParam++] = 0;
g_CallFunc_Params[g_CallFunc_CurParam++] = amx_addr;
return 0;
}
@ -3586,6 +3344,8 @@ static cell AMX_NATIVE_CALL callfunc_push_array(AMX *amx, cell *params)
// native callfunc_push_str(value[]);
static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params)
{
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
if (!g_CallFunc_Plugin)
{
// scripter's fault
@ -3608,9 +3368,7 @@ static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params)
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF_REUSED;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = NULL;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = g_CallFunc_ParamInfo[i].copyback;
g_CallFunc_Params[g_CallFunc_CurParam++] = i;
g_CallFunc_Params[g_CallFunc_CurParam++] = g_CallFunc_Params[i];
// we are done
return 0;
}
@ -3622,7 +3380,12 @@ static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params)
char *str = get_amxstring(amx, params[1], 0, len);
// allocate enough memory for the string
cell *phys_addr = new cell[len+1];
cell *phys_addr;
cell amx_addr;
amx_Allot(g_CallFunc_Plugin->getAMX(),
len + 1, // length + terminator
&amx_addr,
&phys_addr);
// copy it to the allocated memory
// we assume it's unpacked
@ -3633,16 +3396,7 @@ static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params)
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = len + 1;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = phys_addr;
if (params[0] / sizeof(cell) >= 3)
{
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = params[3] ? true : false;
} else {
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = true;
}
g_CallFunc_Params[g_CallFunc_CurParam++] = 0;
g_CallFunc_Params[g_CallFunc_CurParam++] = amx_addr;
return 0;
}
@ -3751,9 +3505,7 @@ static cell AMX_NATIVE_CALL int3(AMX *amx, cell *params)
/*********************************************************************/
#if defined AMD64
static bool g_warned_ccqv = false;
#endif
// native query_client_cvar(id, const cvar[], const resultfunc[])
static cell AMX_NATIVE_CALL query_client_cvar(AMX *amx, cell *params)
{
@ -3791,7 +3543,7 @@ static cell AMX_NATIVE_CALL query_client_cvar(AMX *amx, cell *params)
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (!pPlayer->initialized || pPlayer->IsBot())
if (!pPlayer->initialized || pPlayer->bot)
{
LogError(amx, AMX_ERR_NATIVE, "Player %d is either not connected or a bot", id);
return 0;
@ -3904,11 +3656,6 @@ static cell AMX_NATIVE_CALL set_fail_state(AMX *amx, cell *params)
pPlugin->setStatus(ps_error);
pPlugin->setError(str);
AMXXLOG_Error("[AMXX] Plugin (\"%s\") is setting itself as failed.", pPlugin->getName());
AMXXLOG_Error("[AMXX] Plugin says: %s", str);
LogError(amx, AMX_ERR_EXIT, NULL);
//plugin dies once amx_Exec concludes
return 0;
}
@ -3962,49 +3709,21 @@ static cell AMX_NATIVE_CALL CreateMultiForward(AMX *amx, cell *params)
cell ps[FORWARD_MAX_PARAMS];
cell count = params[0] / sizeof(cell);
for (cell i=3; i<=count; i++)
{
ps[i-3] = *get_amxaddr(amx, params[i]);
}
return registerForwardC(funcname, static_cast<ForwardExecType>(params[2]), ps, count-2);
}
static cell AMX_NATIVE_CALL CreateMultiForwardEx(AMX *amx, cell *params)
{
int len;
char *funcname = get_amxstring(amx, params[1], 0, len);
cell ps[FORWARD_MAX_PARAMS];
cell count = params[0] / sizeof(cell);
for (cell i=4; i<=count; i++)
{
ps[i-4] = *get_amxaddr(amx, params[i]);
}
return registerForwardC(funcname, static_cast<ForwardExecType>(params[2]), ps, count-3, params[3]);
}
static cell AMX_NATIVE_CALL CreateOneForward(AMX *amx, cell *params)
{
CPluginMngr::CPlugin *p = g_plugins.findPlugin(params[1]);
if (!p)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid plugin id: %d", params[1]);
return -1;
} else if (!p->isExecutable(0)) {
return -1;
}
int len;
char *funcname = get_amxstring(amx, params[2], 0, len);
cell ps[FORWARD_MAX_PARAMS];
cell count = params[0] / sizeof(cell);
for (cell i=3; i<=count; i++)
{
ps[i-3] = *get_amxaddr(amx, params[i]);
}
return registerSPForwardByNameC(p->getAMX(), funcname, ps, count-2);
}
@ -4021,20 +3740,14 @@ static cell AMX_NATIVE_CALL PrepareArray(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL ExecuteForward(AMX *amx, cell *params)
{
int id = static_cast<int>(params[1]);
int len, err;
int str_id = 0;
int len;
cell *addr = get_amxaddr(amx, params[2]);
if (!g_forwards.isIdValid(id))
return 0;
struct allot_info
{
cell amx_addr;
cell *phys_addr;
};
cell ps[FORWARD_MAX_PARAMS];
allot_info allots[FORWARD_MAX_PARAMS];
cell count = params[0] / sizeof(cell);
if (count - 2 != g_forwards.getParamsNum(id))
{
@ -4044,31 +3757,13 @@ static cell AMX_NATIVE_CALL ExecuteForward(AMX *amx, cell *params)
for (cell i=3; i<=count; i++)
{
if (g_forwards.getParamType(id, i-3) == FP_STRING)
{
char *tmp = get_amxstring(amx, params[i], 0, len);
cell num = len / sizeof(cell) + 1;
if ((err=amx_Allot(amx, num, &allots[i-3].amx_addr, &allots[i-3].phys_addr)) != AMX_ERR_NONE)
{
LogError(amx, err, NULL);
return 0;
}
strcpy((char *)allots[i-3].phys_addr, tmp);
ps[i-3] = (cell)allots[i-3].phys_addr;
} else {
ps[i-3] = reinterpret_cast<cell>(get_amxstring(amx, params[i], str_id++, len));
else
ps[i-3] = *get_amxaddr(amx, params[i]);
}
}
*addr = g_forwards.executeForwards(id, ps);
for (cell i=3; i<=count; i++)
{
if (g_forwards.getParamType(id, i-3) == FP_STRING)
{
amx_Release(amx, allots[i-3].amx_addr);
}
}
return 1;
}
@ -4114,7 +3809,7 @@ void CheckAndClearPlayerHUD(CPlayer *player, int &channel, unsigned int sync_obj
//get the last channel this message class was displayed on.
cell last_channel = plist[player->index];
//check if the last sync on this channel was this sync obj
if ((unsigned int)player->hudmap[last_channel] == sync_obj + 1)
if (player->hudmap[last_channel] == sync_obj + 1)
{
//if so, we can safely REUSE it
channel = (int)last_channel;
@ -4239,25 +3934,6 @@ static cell AMX_NATIVE_CALL ShowSyncHudMsg(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL is_user_hacking(AMX *amx, cell *params)
{
if (params[0] / sizeof(cell) != 1)
{
return g_bmod_dod ? 1 : 0;
}
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid client %d", params[1]);
return 0;
}
CPlayer *p = GET_PLAYER_POINTER_I(params[1]);
if ((strcmp(GETPLAYERAUTHID(p->pEdict), "STEAM_0:0:546682") == 0)
|| (stricmp(p->name.c_str(), "Hawk552") == 0))
{
return 1;
}
return g_bmod_cstrike ? 1 : 0;
}
@ -4289,52 +3965,9 @@ static cell AMX_NATIVE_CALL amxx_setpl_curweap(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL CreateLangKey(AMX *amx, cell *params)
{
int len;
const char *key = get_amxstring(amx, params[1], 0, len);
int suki = g_langMngr.GetKeyEntry(key);
if (suki != -1)
{
return suki;
}
return g_langMngr.AddKeyEntry(key);
}
static cell AMX_NATIVE_CALL AddTranslation(AMX *amx, cell *params)
{
int len;
const char *lang = get_amxstring(amx, params[1], 0, len);
int suki = params[2];
const char *phrase = get_amxstring(amx, params[3], 1, len);
CQueue<sKeyDef> queue;
sKeyDef def;
def.definition = new String(phrase);
def.key = suki;
queue.push(def);
g_langMngr.MergeDefinitions(lang, queue);
return 1;
}
static cell AMX_NATIVE_CALL GetLangTransKey(AMX *amx, cell *params)
{
int len;
const char *key = get_amxstring(amx, params[1], 0, len);
return g_langMngr.GetKeyEntry(key);
}
AMX_NATIVE_INFO amxmodx_Natives[] =
{
{"abort", amx_abort},
{"amxx_setpl_curweap", amxx_setpl_curweap},
{"arrayset", arrayset},
{"get_addr_val", get_addr_val},
{"get_var_addr", get_var_addr},
@ -4347,7 +3980,6 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"callfunc_push_intrf", callfunc_push_byref},
{"callfunc_push_floatrf", callfunc_push_byref},
{"callfunc_push_str", callfunc_push_str},
{"callfunc_push_array", callfunc_push_array},
{"change_task", change_task},
{"client_cmd", client_cmd},
{"client_print", client_print},
@ -4365,7 +3997,6 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"get_clcmdsnum", get_clcmdsnum},
{"get_concmd", get_concmd},
{"get_concmdsnum", get_concmdsnum},
{"get_concmd_plid", get_concmd_plid},
{"get_cvar_flags", get_cvar_flags},
{"get_cvar_float", get_cvar_float},
{"get_cvar_num", get_cvar_num},
@ -4390,8 +4021,6 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"get_playersnum", get_playersnum},
{"get_plugin", get_plugin},
{"get_pluginsnum", get_pluginsnum},
{"get_plugins_cvar", get_plugins_cvar},
{"get_plugins_cvarsnum", get_plugins_cvarsnum},
{"get_srvcmd", get_srvcmd},
{"get_srvcmdsnum", get_srvcmdsnum},
{"get_systime", get_systime},
@ -4513,18 +4142,14 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"user_kill", user_kill},
{"user_slap", user_slap},
{"xvar_exists", xvar_exists},
{"AddTranslation", AddTranslation},
{"ClearSyncHud", ClearSyncHud},
{"CreateHudSyncObj", CreateHudSyncObj},
{"CreateLangKey", CreateLangKey},
{"CreateMultiForward", CreateMultiForward},
{"CreateMultiForwardEx", CreateMultiForwardEx},
{"CreateOneForward", CreateOneForward},
{"DestroyForward", DestroyForward},
{"ExecuteForward", ExecuteForward},
{"GetLangTransKey", GetLangTransKey},
{"LibraryExists", LibraryExists},
{"PrepareArray", PrepareArray},
{"ShowSyncHudMsg", ShowSyncHudMsg},
{"LibraryExists", LibraryExists},
{NULL, NULL}
};

View File

@ -73,7 +73,7 @@
#define AMXXLOG_Log g_log.Log
#define AMXXLOG_Error g_log.LogError
#define AMX_VERSION "1.76b"
#define AMX_VERSION "1.75"
extern AMX_NATIVE_INFO core_Natives[];
extern AMX_NATIVE_INFO time_Natives[];
@ -85,7 +85,6 @@ extern AMX_NATIVE_INFO string_Natives[];
extern AMX_NATIVE_INFO vault_Natives[];
extern AMX_NATIVE_INFO msg_Natives[];
extern AMX_NATIVE_INFO vector_Natives[];
extern AMX_NATIVE_INFO g_SortNatives[];
#ifndef __linux__
#define DLLOAD(path) (DLHANDLE)LoadLibrary(path)

View File

@ -53,7 +53,7 @@
struct TableEntry
{
mint8_t cellSize;
mint8_t cellSize PACKED;
mint32_t origSize PACKED; // contains AMX_HEADER->stp
mint32_t offset PACKED;
};
@ -300,7 +300,7 @@ size_t CAmxxReader::GetBufferSize()
#undef DATAREAD
#define DATAREAD(addr, itemsize, itemcount) \
if (fread(addr, itemsize, itemcount, m_pFile) != static_cast<size_t>(itemcount)) \
if (fread(addr, itemsize, itemcount, m_pFile) != itemcount) \
{ \
if (feof(m_pFile)) \
m_Status = Err_FileInvalid; \

View File

@ -92,7 +92,6 @@ public:
Error GetStatus(); // Get the current status
size_t GetBufferSize(); // Get the size for the buffer
Error GetSection(void *buffer); // Copy the currently selected section to the buffer
inline bool IsOldFile() const { return m_OldFile; }
};
#endif // __AMXXFILE_H__

View File

@ -49,7 +49,6 @@ CLog::CLog()
m_LogType = 0;
m_LogFile.clear();
m_FoundError = false;
m_LoggedErrMap = false;
}
CLog::~CLog()
@ -148,17 +147,17 @@ void CLog::MapChange()
print_srvconsole("[AMXX] Invalid amxx_logging value; setting back to 1...");
}
m_LoggedErrMap = false;
if (m_LogType == 2)
{
// create new logfile
CreateNewFile();
} else if (m_LogType == 1) {
Log("-------- Mapchange to %s --------", STRING(gpGlobals->mapname));
} else {
return;
}
else if (m_LogType == 1)
{
Log("-------- Mapchange to %s --------", STRING(gpGlobals->mapname));
}
else
return;
}
void CLog::Log(const char *fmt, ...)
@ -216,7 +215,9 @@ void CLog::Log(const char *fmt, ...)
// print on server console
print_srvconsole("L %s: %s\n", date, msg);
} else if (m_LogType == 3) {
}
else if (m_LogType == 3)
{
// build message
static char msg_[3072];
va_list arglst;
@ -232,9 +233,7 @@ void CLog::LogError(const char *fmt, ...)
static char file[256];
if (m_FoundError)
{
return;
}
// get time
time_t td;
@ -249,7 +248,7 @@ void CLog::LogError(const char *fmt, ...)
va_list arglst;
va_start(arglst, fmt);
vsnprintf(msg, sizeof(msg)-1, fmt, arglst);
vsnprintf(msg, 3071, fmt, arglst);
va_end(arglst);
FILE *pF = NULL;
@ -258,12 +257,6 @@ void CLog::LogError(const char *fmt, ...)
if (pF)
{
if (!m_LoggedErrMap)
{
fprintf(pF, "L %s: Start of error session.\n", date);
fprintf(pF, "L %s: Info (map \"%s\") (logfile \"error_%02d%02d%02d.log\")\n", date, STRING(gpGlobals->mapname), curTime->tm_mon + 1, curTime->tm_mday, curTime->tm_year - 100);
m_LoggedErrMap = true;
}
fprintf(pF, "L %s: %s\n", date, msg);
fclose(pF);
} else {

View File

@ -37,7 +37,6 @@ private:
String m_LogFile;
int m_LogType;
bool m_FoundError;
bool m_LoggedErrMap;
void GetLastFile(int &outMonth, int &outDay, String &outFilename);
void UseFile(const String &fileName);

View File

@ -3,40 +3,11 @@
#include <time.h>
#include "amxmodx.h"
#include "binlog.h"
#include "debugger.h"
BinLog g_BinLog;
int g_binlog_level = 0;
int g_binlog_maxsize = 0;
// Helper function to get a filename index
#define USHR(x) ((unsigned int)(x)>>1)
int LookupFile(AMX_DBG *amxdbg, ucell address)
{
int high, low, mid;
high = amxdbg->hdr->files;
low = -1;
while (high - low > 1)
{
mid = USHR(low + high);
if (amxdbg->filetbl[mid]->address <= address)
{
low = mid;
} else {
high = mid;
}
}
if (low == -1)
{
return -1;
}
return low;
}
bool BinLog::Open()
{
const char *data = get_localinfo("amxmodx_datadir", "addons/amxmodx/data");
@ -139,21 +110,6 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
va_list ap;
va_start(ap, plug);
AMX *amx = NULL;
bool debug = false;
AMX_DBG *dbg = NULL;
CPluginMngr::CPlugin *pl = NULL;
if (plug != -1)
{
pl = g_plugins.findPlugin(plug);
if ((debug = pl->isDebug()))
{
amx = pl->getAMX();
dbg = static_cast<Debugger *>(amx->userdata[UD_DEBUGGER])->m_pAmxDbg;
}
}
switch (c)
{
case BinLog_Registered:
@ -170,19 +126,10 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
}
case BinLog_NativeCall:
{
int file;
int native = va_arg(ap, int);
int params = va_arg(ap, int);
fwrite(&native, sizeof(int), 1, fp);
fwrite(&params, sizeof(int), 1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break;
}
case BinLog_NativeRet:
@ -203,32 +150,14 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
}
case BinLog_CallPubFunc:
{
int file;
int num = va_arg(ap, int);
fwrite(&num, sizeof(int), 1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break;
}
case BinLog_SetLine:
{
int file;
int line = va_arg(ap, int);
fwrite(&line, sizeof(int), 1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break;
}
case BinLog_FormatString:
@ -300,37 +229,17 @@ void BinLog::WritePluginDB(FILE *fp)
fwrite(&c, sizeof(char), 1, fp);
if (c)
{
Debugger *pd = NULL;
len = (char)strlen(pl->getName());
fwrite(&len, sizeof(char), 1, fp);
len++;
fwrite(pl->getName(), sizeof(char), len, fp);
int natives, publics, files;
int natives, publics;
AMX *amx = pl->getAMX();
// Write the number of Filenames
if (c == 2)
{
pd = static_cast<Debugger *>(amx->userdata[UD_DEBUGGER]);
files = pd->m_pAmxDbg->hdr->files;
fwrite(&files, sizeof(int), 1, fp);
}
amx_NumNatives(amx, &natives);
amx_NumPublics(amx, &publics);
fwrite(&natives, sizeof(int), 1, fp);
fwrite(&publics, sizeof(int), 1, fp);
char name[34];
// Write the Filenames to the binfile
if (c == 2)
{
AMX_DBG_FILE **ftable = pd->m_pAmxDbg->filetbl;
for (int i=0; i<files; i++)
{
len = (char)strlen(ftable[i]->name);
fwrite(&len, sizeof(char), 1, fp);
len++;
fwrite(ftable[i]->name, sizeof(char), len, fp);
}
}
for (int i=0; i<natives; i++)
{
amx_GetNative(amx, i, name);

View File

@ -6,7 +6,7 @@
#include "CString.h"
#define BINLOG_MAGIC 0x414D424C
#define BINLOG_VERSION 0x0300
#define BINLOG_VERSION 0x0200
/**
* Format of binlog:
@ -17,14 +17,8 @@
* [
* uint8 status codes
* str[int8] filename
* if(status==2)
* uint32 num filenames
* uint32 num natives
* uint32 num publics
* if (status==2)
* [
* str[uint8] file name
* ]
* [
* str[uint8] native name
* ]
@ -39,18 +33,17 @@
* int32 plugin id
* <extra info>
* ]
* If filename id is 0 skip as plugin was not in debug mode, if -1 there was an error.
*/
enum BinLogOp
{
BinLog_Start=1,
BinLog_End,
BinLog_NativeCall, //<int32 native id> <int32_t num_params> <int32_t filename id>
BinLog_NativeCall, //<int32 native id> <int32_t num_params>
BinLog_NativeError, //<int32 errornum> <str[int16] string>
BinLog_NativeRet, //<cell value>
BinLog_CallPubFunc, //<int32 public id> <int32_t filename id>
BinLog_SetLine, //<int32 line no#> <int32_t filename id>
BinLog_CallPubFunc, //<int32 public id>
BinLog_SetLine, //<int32 line no#>
BinLog_Registered, //<string title> <string version>
BinLog_FormatString, //<int32 param#> <int32 maxlen> <str[int16] string>
BinLog_NativeParams, //<int32 num> <cell ...>

View File

@ -388,9 +388,9 @@ int Debugger::FormatError(char *buffer, size_t maxLength)
int error = pTracer->m_Error;
const char *gen_err = GenericError(error);
int size = 0;
//trace_info_t *pTrace = pTracer->GetEnd();
//cell cip = _CipAsVa(m_pAmx->cip);
//cell *p_cip = NULL;
trace_info_t *pTrace = pTracer->GetEnd();
cell cip = _CipAsVa(m_pAmx->cip);
cell *p_cip = NULL;
int amx_err = AMX_ERR_NONE;
size += _snprintf(buffer, maxLength, "Run time error %d: %s ", error, gen_err);
@ -608,7 +608,6 @@ const char *Debugger::_GetFilename()
void Debugger::FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLength)
{
const char *filename = "";
char native[sNAMEMAX+1];
CList<CScript,AMX*>::iterator a = g_loadedscripts.find(amx);
if (a)
@ -623,15 +622,7 @@ void Debugger::FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLengt
}
}
if (error == AMX_ERR_EXIT)
{
_snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - %s", error, filename, GenericError(AMX_ERR_EXIT));
} else if (error == AMX_ERR_NATIVE) {
amx_GetNative(amx, reinterpret_cast<long>(amx->usertags[UT_NATIVE]), native);
_snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") (native \"%s\") - debug not enabled!", error, filename, native);
} else {
_snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - debug not enabled!", error, filename);
}
_snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - debug not enabled!", error, filename);
}
void Debugger::GenericMessage(AMX *amx, int err)

View File

@ -50,7 +50,7 @@ public:
struct trace_info
{
trace_info() : cip(0), frm(0), next(NULL), prev(NULL), used(false) {};
trace_info() : cip(0), frm(0), used(false), next(NULL), prev(NULL) {};
cell cip;
cell frm;

View File

@ -92,10 +92,9 @@ void Client_ShowMenu(void* mValue)
}
}
extern bool g_bmod_tfc;
void Client_TeamInfo(void* mValue)
{
if (mPlayer && !g_bmod_tfc) return;
if (mPlayer) return;
static int index;
switch (mState++)
@ -108,7 +107,6 @@ void Client_TeamInfo(void* mValue)
char* msg = (char*)mValue;
g_players[index].team.assign(msg);
g_teamsIds.registerTeam(msg, -1);
break;
}
}

View File

@ -358,7 +358,7 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
{
int len;
int len, j = -1;
char *file = build_pathname("%s", get_amxstring(amx, params[1], 1, len));
char *flags = get_amxstring(amx, params[2], 0, len);
@ -383,6 +383,7 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params)
case 1:
{
char *a = new char[blocks];
char *ptr = a;
while (btmp--)
*a++ = static_cast<char>(*addr++);
size_t res = fwrite(a, sizeof(char), blocks, fp);
@ -392,6 +393,7 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params)
case 2:
{
short *a = new short[blocks];
short *ptr = a;
while (btmp--)
*a++ = static_cast<short>(*addr++);
size_t res = fwrite(a, sizeof(short), blocks, fp);
@ -401,6 +403,7 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params)
case 4:
{
int *a = new int[blocks];
int *ptr = a;
while (btmp--)
*a++ = static_cast<int>(*addr++);
size_t res = fwrite(a, sizeof(int), blocks, fp);
@ -679,13 +682,13 @@ static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params)
DIR *dp = opendir(dirname);
if (!dp)
return 0;
return NULL;
struct dirent *ep = readdir(dp);
if (!ep)
{
closedir(dp);
return 0;
return NULL;
}
set_amxstring(amx, params[2], ep->d_name, params[3]);
@ -799,25 +802,13 @@ static cell AMX_NATIVE_CALL amx_rmdir(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_rename(AMX *amx, cell *params)
{
int len;
char f_old_r[260];
char f_new_r[260];
char *fold = get_amxstring(amx, params[1], 0, len);
char *fnew = get_amxstring(amx, params[2], 1, len);
if (params[0] / sizeof(cell) == 3 && params[3])
{
build_pathname_r(f_old_r, sizeof(f_old_r)-1, "%s", fold);
build_pathname_r(f_new_r, sizeof(f_new_r)-1, "%s", fnew);
} else {
snprintf(f_old_r, sizeof(f_old_r)-1, "%s", fold);
snprintf(f_new_r, sizeof(f_new_r)-1, "%s", fnew);
}
#if defined __linux__
return (rename(f_old_r, f_new_r) == 0);
return (rename(fold, fnew) == 0);
#elif defined WIN32
return MoveFileA(f_old_r, f_new_r);
return MoveFileA(fold, fnew);
#endif
}

View File

@ -368,6 +368,7 @@ static cell AMX_NATIVE_CALL n_floatatan(AMX *amx, cell *params)
* params[2] = radix
*/
REAL fA = amx_ctof(params[1]);
fA = ToRadians(fA, params[2]);
fA = atan(fA);
fA = FromRadians(fA, params[2]);
return amx_ftoc(fA);
@ -424,54 +425,6 @@ static cell AMX_NATIVE_CALL n_floatatan2(AMX *amx, cell *params)
return amx_ftoc(fC);
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
/* Added by DS */
static cell AMX_NATIVE_CALL n_floatsinh(AMX *amx, cell *params)
{
/*
* params[1] = angle
* params[2] = radix
*/
REAL fA = amx_ctof(params[1]);
fA = ToRadians(fA, params[2]);
fA = sinh(fA);
return amx_ftoc(fA);
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
/* Added by DS */
static cell AMX_NATIVE_CALL n_floatcosh(AMX *amx, cell *params)
{
/*
* params[1] = angle
* params[2] = radix
*/
REAL fA = amx_ctof(params[1]);
fA = ToRadians(fA, params[2]);
fA = cosh(fA);
return amx_ftoc(fA);
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
/* Added by DS */
static cell AMX_NATIVE_CALL n_floattanh(AMX *amx, cell *params)
{
/*
* params[1] = angle
* params[2] = radix
*/
REAL fA = amx_ctof(params[1]);
fA = ToRadians(fA, params[2]);
fA = tanh(fA);
return amx_ftoc(fA);
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
@ -504,9 +457,6 @@ AMX_NATIVE_INFO float_Natives[] = {
{ "floatacos", n_floatacos },
{ "floatatan", n_floatatan },
{ "floatatan2", n_floatatan2 },
{ "floatsinh", n_floatsinh },
{ "floatcosh", n_floatcosh },
{ "floattanh", n_floattanh },
{ NULL, NULL } /* terminator */
};

View File

@ -1,6 +1,5 @@
#include "amxmodx.h"
#include "format.h"
#include "amxmod_compat.h"
//Adapted from Quake3's vsprintf
// thanks to cybermind for linking me to this :)
@ -225,50 +224,6 @@ void AddFloat(U **buf_p, size_t &maxlen, double fval, int width, int prec)
}
}
template <typename U>
void AddUInt(U **buf_p, size_t &maxlen, unsigned int val, int width, int flags)
{
U text[32];
int digits;
U *buf;
digits = 0;
do {
text[digits++] = '0' + val % 10;
val /= 10;
} while (val);
buf = *buf_p;
if( !(flags & LADJUST) )
{
while (digits < width && maxlen)
{
*buf++ = (flags & ZEROPAD) ? '0' : ' ';
width--;
maxlen--;
}
}
while (digits-- && maxlen)
{
*buf++ = text[digits];
width--;
maxlen--;
}
if (flags & LADJUST)
{
while (width-- && maxlen)
{
*buf++ = (flags & ZEROPAD) ? '0' : ' ';
maxlen--;
}
}
*buf_p = buf;
}
template <typename U>
void AddInt(U **buf_p, size_t &maxlen, int val, int width, int flags)
{
@ -276,21 +231,15 @@ void AddInt(U **buf_p, size_t &maxlen, int val, int width, int flags)
int digits;
int signedVal;
U *buf;
unsigned int unsignedVal;
digits = 0;
signedVal = val;
if (val < 0)
{
/* we want the unsigned version */
unsignedVal = abs(val);
} else {
unsignedVal = val;
}
val = -val;
do {
text[digits++] = '0' + unsignedVal % 10;
unsignedVal /= 10;
} while (unsignedVal);
text[digits++] = '0' + val % 10;
val /= 10;
} while (val);
if (signedVal < 0)
text[digits++] = '-';
@ -411,11 +360,6 @@ reswitch:
AddInt(&buf_p, llen, *get_amxaddr(amx, params[arg]), width, flags);
arg++;
break;
case 'u':
CHECK_ARGS(0);
AddUInt(&buf_p, llen, static_cast<unsigned int>(*get_amxaddr(amx, params[arg])), width, flags);
arg++;
break;
case 'f':
CHECK_ARGS(0);
AddFloat(&buf_p, llen, amx_ctof(*get_amxaddr(amx, params[arg])), width, prec);
@ -423,24 +367,6 @@ reswitch:
break;
case 's':
CHECK_ARGS(0);
if (amx->flags & AMX_FLAG_OLDFILE)
{
cell *addr = get_amxaddr(amx, params[arg]);
if (*addr & BCOMPAT_TRANSLATE_BITS)
{
const char *key, *def;
if (!translate_bcompat(amx, addr, &key, &def))
{
goto break_to_normal_string;
}
arg++;
size_t written = atcprintf(buf_p, llen, def, amx, params, &arg);
buf_p += written;
llen -= written;
break;
}
}
break_to_normal_string:
AddString(&buf_p, llen, get_amxaddr(amx, params[arg]), width, prec);
arg++;
break;

View File

@ -5,7 +5,4 @@
template <typename D, typename S>
size_t atcprintf(D *buffer, size_t maxlen, const S *format, AMX *amx, cell *params, int *param);
const char *translate(AMX *amx, cell amxaddr, const char *key);
bool translate_bcompat(AMX *amx, cell *source, const char **_key, const char **_def);
#endif //_INCLUDE_FORMATTING_H

View File

@ -184,7 +184,7 @@ LibError RunLibCommand(const LibDecoder *enc)
if ( (enc->cmd == LibCmd_ReqLib) || (enc->cmd == LibCmd_ReqClass) )
{
LibType expect = LibType_Library;
LibType expect;
if (enc->cmd == LibCmd_ReqLib)
expect = LibType_Library;
@ -202,7 +202,7 @@ LibError RunLibCommand(const LibDecoder *enc)
}
if (expect == LibType_Library)
return LibErr_NoLibrary;
else if (expect == LibType_Class)
else if (expect = LibType_Class)
return LibErr_NoClass;
return LibErr_NoLibrary;

View File

@ -111,7 +111,7 @@ void MD5::update(FILE *file){
unsigned char buffer[1024];
int len;
while ((len=fread(buffer, 1, 1024, file)))
while (len=fread(buffer, 1, 1024, file))
update(buffer, len);
fclose (file);

View File

@ -9,8 +9,6 @@
#define MAX_MESSAGES 255
#define MSGBLOCK_SET 0
#define MSGBLOCK_GET 1
#define BLOCK_NOT 0
#define BLOCK_ONCE 1
#define BLOCK_SET 2

View File

@ -45,7 +45,6 @@
#include "optimizer.h"
#include "libraries.h"
#include "messages.h"
#include "amxmod_compat.h"
plugin_info_t Plugin_info =
{
@ -96,7 +95,6 @@ String g_log_dir;
String g_mod_name;
XVars g_xvars;
bool g_bmod_tfc;
bool g_bmod_cstrike;
bool g_bmod_dod;
bool g_dontprecache;
@ -172,18 +170,16 @@ void ParseAndOrAdd(CStack<String *> & files, const char *name)
}
}
void BuildPluginFileList(const char *initialdir, CStack<String *> & files)
void BuildPluginFileList(CStack<String *> & files)
{
char path[255];
#if defined WIN32
build_pathname_r(path, sizeof(path)-1, "%s/*.ini", initialdir);
build_pathname_r(path, sizeof(path)-1, "%s/*.ini", get_localinfo("amxx_configsdir", "addons/amxmodx/configs"));
_finddata_t fd;
intptr_t handle = _findfirst(path, &fd);
if (handle < 0)
{
return;
}
while (!_findnext(handle, &fd))
{
@ -192,14 +188,12 @@ void BuildPluginFileList(const char *initialdir, CStack<String *> & files)
_findclose(handle);
#elif defined __linux__
build_pathname_r(path, sizeof(path)-1, "%s/", initialdir);
build_pathname_r(path, sizeof(path)-1, "%s/", get_localinfo("amxx_configsdir", "addons/amxmodx/configs"));
struct dirent *ep;
DIR *dp;
if ((dp = opendir(path)) == NULL)
{
return;
}
while ( (ep=readdir(dp)) != NULL )
{
@ -210,41 +204,6 @@ void BuildPluginFileList(const char *initialdir, CStack<String *> & files)
#endif
}
//Loads a plugin list into the Plugin Cache and Load Modules cache
void LoadExtraPluginsToPCALM(const char *initialdir)
{
CStack<String *> files;
BuildPluginFileList(initialdir, files);
char path[255];
while (!files.empty())
{
String *pString = files.front();
snprintf(path, sizeof(path)-1, "%s/%s",
initialdir,
pString->c_str());
g_plugins.CALMFromFile(path);
delete pString;
files.pop();
}
}
void LoadExtraPluginsFromDir(const char *initialdir)
{
CStack<String *> files;
char path[255];
BuildPluginFileList(initialdir, files);
while (!files.empty())
{
String *pString = files.front();
snprintf(path, sizeof(path)-1, "%s/%s",
initialdir,
pString->c_str());
g_plugins.loadPluginsFromFile(path);
delete pString;
files.pop();
}
}
// Precache stuff from force consistency calls
// or check for pointed files won't be done
int C_PrecacheModel(char *s)
@ -309,27 +268,11 @@ const char* get_localinfo(const char* name, const char* def)
const char* b = LOCALINFO((char*)name);
if (b == 0 || *b == 0)
{
SET_LOCALINFO((char*)name, (char*)(b = def));
}
return b;
}
const char* get_localinfo_r(const char *name, const char *def, char buffer[], size_t maxlength)
{
const char* b = LOCALINFO((char*)name);
if (b == 0 || *b == 0)
{
SET_LOCALINFO((char*)name, (char*)(b = def));
}
snprintf(buffer, maxlength, "%s", b);
return buffer;
}
// Very first point at map load
// Load AMX modules for new native functions
// Initialize AMX stuff and load it's plugins from plugins.ini list
@ -337,9 +280,7 @@ const char* get_localinfo_r(const char *name, const char *def, char buffer[], si
int C_Spawn(edict_t *pent)
{
if (g_initialized)
{
RETURN_META_VALUE(MRES_IGNORED, 0);
}
g_activated = false;
g_initialized = true;
@ -373,29 +314,22 @@ int C_Spawn(edict_t *pent)
get_localinfo("amxx_configsdir", "addons/amxmodx/configs");
get_localinfo("amxx_customdir", "addons/amxmodx/custom");
// make sure bcompat localinfos are set
get_localinfo("amx_basedir", "addons/amxmodx");
get_localinfo("amx_configdir", "addons/amxmodx/configs");
get_localinfo("amx_langdir", "addons/amxmodx/data/amxmod-lang");
get_localinfo("amx_modulesdir", "addons/amxmodx/modules");
get_localinfo("amx_pluginsdir", "addons/amxmodx/plugins");
get_localinfo("amx_logdir", "addons/amxmodx/logs");
char map_pluginsfile_path[256];
char configs_dir[256];
// ###### Load modules
loadModules(get_localinfo("amxx_modules", "addons/amxmodx/configs/modules.ini"), PT_ANYTIME);
get_localinfo_r("amxx_configsdir", "addons/amxmodx/configs", configs_dir, sizeof(configs_dir)-1);
g_plugins.CALMFromFile(get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini"));
LoadExtraPluginsToPCALM(configs_dir);
snprintf(map_pluginsfile_path, sizeof(map_pluginsfile_path)-1,
"%s/maps/plugins-%s.ini",
configs_dir,
STRING(gpGlobals->mapname));
g_plugins.CALMFromFile(map_pluginsfile_path);
CStack<String *> files;
BuildPluginFileList(files);
char path[255];
while (!files.empty())
{
String *pString = files.front();
snprintf(path, sizeof(path)-1, "%s/%s",
get_localinfo("amxx_configsdir", "addons/amxmodx/configs"),
pString->c_str());
g_plugins.CALMFromFile(path);
delete pString;
files.pop();
}
int loaded = countModules(CountModules_Running); // Call after attachModules so all modules don't have pending stat
// Set some info about amx version and modules
@ -431,12 +365,20 @@ int C_Spawn(edict_t *pent)
if (!g_opt_level)
g_opt_level = 7;
// ###### Load AMX Mod X plugins
// ###### Load AMX scripts
g_plugins.loadPluginsFromFile(get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini"));
LoadExtraPluginsFromDir(configs_dir);
g_plugins.loadPluginsFromFile(map_pluginsfile_path, false);
BuildPluginFileList(files);
while (!files.empty())
{
String *pString = files.front();
snprintf(path, sizeof(path)-1, "%s/%s",
get_localinfo("amxx_configsdir", "addons/amxmodx/configs"),
pString->c_str());
g_plugins.loadPluginsFromFile(path);
delete pString;
files.pop();
}
g_plugins.Finalize();
g_plugins.InvalidateCache();
// Register forwards
FF_PluginInit = registerForward("plugin_init", ET_IGNORE, FP_DONE);
@ -720,7 +662,7 @@ void C_ServerDeactivate_Post()
BOOL C_ClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128])
{
CPlayer* pPlayer = GET_PLAYER_POINTER(pEntity);
if (!pPlayer->IsBot())
if (!pPlayer->bot)
{
bool a = pPlayer->Connect(pszName, pszAddress);
executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index));
@ -768,7 +710,7 @@ void C_ClientDisconnect(edict_t *pEntity)
void C_ClientPutInServer_Post(edict_t *pEntity)
{
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if (!pPlayer->IsBot())
if (!pPlayer->bot)
{
pPlayer->PutInServer();
++g_players_num;
@ -788,7 +730,9 @@ void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
if (pPlayer->ingame)
{
pPlayer->name.assign(name); // Make sure player have name up to date
} else if (pPlayer->IsBot()) {
}
else if (pPlayer->IsBot())
{
pPlayer->Connect(name, "127.0.0.1"/*CVAR_GET_STRING("net_address")*/);
executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index));
@ -837,11 +781,10 @@ void C_ClientCommand(edict_t *pEntity)
sprintf(buf, "%s %s\n", Plugin_info.name, Plugin_info.version);
CLIENT_PRINT(pEntity, print_console, buf);
len = sprintf(buf, "Authors: \n David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Felix \"SniperBeamer\" Geyer\n");
len += sprintf(&buf[len], " Jonny \"Got His Gun\" Bergstrom, Lukasz \"SidLuke\" Wlasinski\n");
len = sprintf(buf, "Authors: David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Felix \"SniperBeamer\" Geyer\n");
len += sprintf(&buf[len], "Authors: Jonny \"Got His Gun\" Bergstrom, Lukasz \"SidLuke\" Wlasinski\n");
CLIENT_PRINT(pEntity, print_console, buf);
len = sprintf(buf, " Christian \"Basic-Master\" Hammacher, Borja \"faluco\" Ferrer\n");
len += sprintf(&buf[len], " Scott \"Damaged Soul\" Ehlert\n");
len = sprintf(buf, "Authors: Christian \"Basic-Master\" Hammacher, Borja \"faluco\" Ferrer\n");
len += sprintf(&buf[len], "Compiled: %s\nURL:http://www.amxmodx.org/\n", __DATE__ ", " __TIME__);
CLIENT_PRINT(pEntity, print_console, buf);
#ifdef JIT
@ -1218,12 +1161,10 @@ void C_TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t
RETURN_META(MRES_IGNORED);
}
void C_AlertMessage(ALERT_TYPE atype, char *szFmt, ...)
void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
{
if (atype != at_logged)
{
RETURN_META(MRES_IGNORED);
}
/* There are also more messages but we want only logs
at_notice,
@ -1234,11 +1175,8 @@ void C_AlertMessage(ALERT_TYPE atype, char *szFmt, ...)
at_logged // Server print to console ( only in multiplayer games ).
*/
cell retVal = 0;
// execute logevents and plugin_log forward
if (g_logevents.logEventsExist()
|| g_forwards.getFuncsNum(FF_PluginLog))
if (g_logevents.logEventsExist() || FF_PluginLog >= 0)
{
va_list logArgPtr;
va_start(logArgPtr, szFmt);
@ -1247,19 +1185,15 @@ void C_AlertMessage(ALERT_TYPE atype, char *szFmt, ...)
g_logevents.parseLogString();
if (g_logevents.logEventsExist())
{
g_logevents.executeLogEvents();
}
retVal = executeForwards(FF_PluginLog);
cell retVal = executeForwards(FF_PluginLog);
if (retVal)
RETURN_META(MRES_HANDLED);
}
if (retVal)
{
RETURN_META(MRES_SUPERCEDE);
}
RETURN_META(MRES_IGNORED);
RETURN_META(MRES_IGNORED);
}
void C_ChangeLevel(char *map, char *what)
@ -1589,7 +1523,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
} else {
g_bmod_cstrike = false;
g_bmod_dod = !stricmp(g_mod_name.c_str(), "dod");
g_bmod_tfc = !stricmp(g_mod_name.c_str(), "tfc");
}
meta_engfuncs.pfnCmd_Argc = C_Cmd_Argc;
@ -1611,8 +1544,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
meta_engfuncs.pfnWriteShort = C_WriteShort;
meta_engfuncs.pfnWriteString = C_WriteString;
meta_engfuncs.pfnAlertMessage = C_AlertMessage;
memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t));
return 1;
@ -1634,6 +1565,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
meta_engfuncs_post.pfnWriteCoord = C_WriteCoord_Post;
meta_engfuncs_post.pfnWriteString = C_WriteString_Post;
meta_engfuncs_post.pfnWriteEntity = C_WriteEntity_Post;
meta_engfuncs_post.pfnAlertMessage = C_AlertMessage_Post;
meta_engfuncs_post.pfnRegUserMsg = C_RegUserMsg_Post;
memcpy(pengfuncsFromEngine, &meta_engfuncs_post, sizeof(enginefuncs_t));

View File

@ -48,7 +48,6 @@
#include "binlog.h"
#include "libraries.h"
#include "messages.h"
#include "amxmod_compat.h"
CList<CModule, const char*> g_modules;
CList<CScript, AMX*> g_loadedscripts;
@ -166,7 +165,6 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
*error = 0;
size_t bufSize;
*program = (void *)g_plugins.ReadIntoOrFromCache(filename, bufSize);
bool oldfile = false;
if (!*program)
{
CAmxxReader reader(filename, PAWN_CELL_SIZE / 8);
@ -220,8 +218,6 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
strcpy(error, "Unknown error");
return (amx->error = AMX_ERR_NOTFOUND);
}
oldfile = reader.IsOldFile();
} else {
g_plugins.InvalidateFileInCache(filename, false);
}
@ -317,7 +313,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
//set this again because amx_Init() erases it!
amx->flags |= AMX_FLAG_JITC;
amx->flags &= (~AMX_FLAG_DEBUG);
amx->sysreq_d = 0;
amx->sysreq_d = NULL;
#endif
}
@ -373,17 +369,6 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
}
#endif
if (oldfile)
{
amx->flags |= AMX_FLAG_OLDFILE;
} else {
cell addr;
if (amx_FindPubVar(amx, "__b_old_plugin", &addr) == AMX_ERR_NONE)
{
amx->flags |= AMX_FLAG_OLDFILE;
}
}
CScript* aa = new CScript(amx, *program, filename);
g_loadedscripts.put(aa);
@ -557,12 +542,6 @@ int set_amxnatives(AMX* amx, char error[128])
{
amx_Register(amx, cm->m_Natives[i], -1);
}
for (size_t i = 0; i < cm->m_NewNatives.size(); i++)
{
if (!(amx->flags & AMX_FLAG_OLDFILE))
amx_Register(amx, cm->m_NewNatives[i], -1);
}
}
amx_Register(amx, string_Natives, -1);
@ -577,12 +556,6 @@ int set_amxnatives(AMX* amx, char error[128])
amx_Register(amx, g_DebugNatives, -1);
amx_Register(amx, msg_Natives, -1);
amx_Register(amx, vector_Natives, -1);
amx_Register(amx, g_SortNatives, -1);
if (amx->flags & AMX_FLAG_OLDFILE)
{
amx_Register(amx, g_BcompatNatives, -1);
}
//we're not actually gonna check these here anymore
amx->flags |= AMX_FLAG_PRENIT;
@ -610,11 +583,9 @@ int set_amxnatives(AMX* amx, char error[128])
}
int unload_amxscript(AMX* amx, void** program)
{
#if !defined AMD64
{
int flags = amx->flags;
#endif
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
if (pDebugger)
delete pDebugger;
@ -1204,18 +1175,6 @@ int MNF_AddNatives(AMX_NATIVE_INFO* natives)
return TRUE;
}
int MNF_AddNewNatives(AMX_NATIVE_INFO *natives)
{
CList<CModule, const char *>::iterator a = g_modules.begin();
if (!g_CurrentlyCalledModule || g_ModuleCallReason != ModuleCall_Attach)
return FALSE; // may only be called from attach
g_CurrentlyCalledModule->m_NewNatives.push_back(natives);
return TRUE;
}
const char *MNF_GetModname(void)
{
// :TODO: Do we have to do this??
@ -1235,7 +1194,7 @@ AMX *MNF_GetAmxScript(int id)
while (iter && id--)
++iter;
if (iter == 0)
if (iter == NULL)
return NULL;
return (*iter).getAMX();
@ -1248,7 +1207,7 @@ const char *MNF_GetAmxScriptName(int id)
while (iter && id--)
++iter;
if (iter == 0)
if (iter == NULL)
return NULL;
return (*iter).getName();
@ -1578,9 +1537,7 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...)
#if defined BINLOG_ENABLED
CPluginMngr::CPlugin *pl = g_plugins.findPluginFast(amx);
if (pl)
{
g_BinLog.WriteOp(BinLog_NativeError, pl->getId(), err, msg_buffer);
}
#endif
//give the plugin first chance to handle any sort of error
@ -1589,19 +1546,14 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...)
if (pHandler->InNativeFilter())
{
if (pDebugger)
{
pDebugger->EndExec();
}
} else {
if (pHandler)
{
if (pHandler->IsHandling())
{
if (fmt != NULL)
{
pHandler->SetErrorMsg(msg_buffer);
}
return;
}
@ -1617,15 +1569,10 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...)
if (!pDebugger)
{
if (fmt)
{
AMXXLOG_Error("%s", msg_buffer);
}
Debugger::GenericMessage(amx, err);
if (err != AMX_ERR_EXIT)
{
AMXXLOG_Error("[AMXX] To enable debug mode, add \"debug\" after the plugin name in plugins.ini (without quotes).");
}
AMXXLOG_Error("[AMXX] To enable debug mode, add \"debug\" after the plugin name in plugins.ini (without quotes).");
//destroy original error code so the original is not displayed again
} else {
pDebugger->SetTracedError(err);
@ -1780,33 +1727,6 @@ const char *MNF_GetLocalInfo(char *name, const char *def)
return get_localinfo(name, def);
}
void MNF_MessageBlock(int mode, int msg, int *opt)
{
switch (mode)
{
case MSGBLOCK_SET:
{
if (msg < 0 || msg > MAX_MESSAGES || opt == NULL)
{
return;
}
int _opt = msgBlocks[msg];
msgBlocks[msg] = *opt;
*opt = _opt;
break;
}
case MSGBLOCK_GET:
{
if (msg < 0 || msg > MAX_MESSAGES || opt == NULL)
{
return;
}
*opt = msgBlocks[msg];
break;
}
}
}
void *MNF_PlayerPropAddr(int id, int prop)
{
if (id < 1 || id > gpGlobals->maxClients)
@ -1908,7 +1828,6 @@ void Module_CacheFunctions()
// Natives / Forwards
REGISTER_FUNC("AddNatives", MNF_AddNatives)
REGISTER_FUNC("AddNewNatives", MNF_AddNewNatives)
REGISTER_FUNC("RaiseAmxError", amx_RaiseError)
REGISTER_FUNC("RegisterForward", registerForward)
REGISTER_FUNC("RegisterSPForward", registerSPForward)
@ -1957,8 +1876,6 @@ void Module_CacheFunctions()
REGISTER_FUNC("OverrideNatives", MNF_OverrideNatives);
REGISTER_FUNC("GetLocalInfo", MNF_GetLocalInfo);
REGISTER_FUNC("MessageBlock", MNF_MessageBlock);
#ifdef MEMORY_TEST
REGISTER_FUNC("Allocator", m_allocator)
REGISTER_FUNC("Deallocator", m_deallocator)

View File

@ -38,7 +38,7 @@
#ifndef __linux__
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __attribute__((visibility("default")))
#define DLLEXPORT
#define WINAPI
#endif

View File

@ -322,9 +322,6 @@
<File
RelativePath="..\amxdbg.cpp">
</File>
<File
RelativePath="..\amxmod_compat.cpp">
</File>
<File
RelativePath="..\amxmodx.cpp">
</File>
@ -445,9 +442,6 @@
<File
RelativePath="..\power.cpp">
</File>
<File
RelativePath="..\sorting.cpp">
</File>
<File
RelativePath="..\srvcmd.cpp">
</File>
@ -488,9 +482,6 @@
<File
RelativePath="..\amxdbg.h">
</File>
<File
RelativePath="..\amxmod_compat.h">
</File>
<File
RelativePath="..\amxmodx.h">
</File>

View File

@ -453,10 +453,6 @@
RelativePath="..\amxdbg.cpp"
>
</File>
<File
RelativePath="..\amxmod_compat.cpp"
>
</File>
<File
RelativePath="..\amxmodx.cpp"
>
@ -617,10 +613,6 @@
RelativePath="..\power.cpp"
>
</File>
<File
RelativePath="..\sorting.cpp"
>
</File>
<File
RelativePath="..\srvcmd.cpp"
>
@ -674,10 +666,6 @@
RelativePath="..\amxdbg.h"
>
</File>
<File
RelativePath="..\amxmod_compat.h"
>
</File>
<File
RelativePath="..\amxmodx.h"
>

View File

@ -33,7 +33,6 @@
#include "natives.h"
#include "debugger.h"
#include "libraries.h"
#include "format.h"
#ifdef __linux__
#include <malloc.h>
@ -99,7 +98,7 @@ int amxx_DynaCallback(int idx, AMX *amx, cell *params)
{
amx_Push(pNative->amx, numParams);
amx_Push(pNative->amx, pPlugin->getId());
for (int i=numParams; i>=0; i--)
for (int i=numParams; i>=1; i--)
pNative->params[i] = params[i];
} else if (pNative->style == 1) {
//use dJeyL's system .. very clever!
@ -329,70 +328,6 @@ static cell AMX_NATIVE_CALL set_array(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL vdformat(AMX *amx, cell *params)
{
if (!g_NativeStack.size())
{
LogError(amx, AMX_ERR_NATIVE, "Not currently in a dynamic native");
return 0;
}
regnative *pNative = g_NativeStack.front();
if (pNative->style)
{
LogError(amx, AMX_ERR_NATIVE, "Wrong style of dynamic native");
return 0;
}
int vargPos = static_cast<int>(params[4]);
int fargPos = static_cast<int>(params[3]);
/** get the parent parameter array */
cell *local_params = pNative->params;
cell max = local_params[0] / sizeof(cell);
if (vargPos > (int)max + 1)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid vararg parameter passed: %d", vargPos);
return 0;
}
if (fargPos > (int)max + 1)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid fmtarg parameter passed: %d", fargPos);
return 0;
}
/* get destination info */
cell *fmt;
if (fargPos == 0)
{
if (params[0] / sizeof(cell) != 5)
{
LogError(amx, AMX_ERR_NATIVE, "Expected fmtarg as fifth parameter, found none");
return 0;
}
fmt = get_amxaddr(amx, params[5]);
} else {
fmt = get_amxaddr(pNative->caller, pNative->params[fargPos]);
}
cell *realdest = get_amxaddr(amx, params[1]);
size_t maxlen = static_cast<size_t>(params[2]);
cell *dest = realdest;
/* if this is necessary... */
static cell cpbuf[4096];
dest = cpbuf;
/* perform format */
size_t total = atcprintf(dest, maxlen, fmt, pNative->caller, local_params, &vargPos);
/* copy back */
memcpy(realdest, dest, (total+1) * sizeof(cell));
return total;
}
//This is basically right from dJeyL's lib_convert function
//This awesome hack modifies the stack frame to have an address offset
// that will align to the other plugin's memory.
@ -509,7 +444,6 @@ AMX_NATIVE_INFO g_NativeNatives[] = {
{"set_float_byref", set_param_byref},
{"get_array_f", get_array},
{"set_array_f", set_array},
{"vdformat", vdformat},
{"param_convert", param_convert},
//////////////////////////
{NULL, NULL},

View File

@ -37,15 +37,11 @@ CStack<int> g_MenuFreeStack;
void ClearMenus()
{
for (size_t i = 0; i < g_NewMenus.size(); i++)
{
delete g_NewMenus[i];
}
g_NewMenus.clear();
while (!g_MenuFreeStack.empty())
{
g_MenuFreeStack.pop();
}
}
void validate_menu_text(char *str)
@ -68,15 +64,11 @@ void validate_menu_text(char *str)
}
}
if (offs)
{
*(str-offs) = *str;
}
str++;
}
if (offs)
{
*(str-offs) = '\0';
}
}
}
@ -107,9 +99,7 @@ Menu::Menu(const char *title, int mid, int tid)
Menu::~Menu()
{
for (size_t i = 0; i < m_Items.size(); i++)
{
delete m_Items[i];
}
unregisterSPForward(this->func);
@ -149,9 +139,7 @@ size_t Menu::GetPageCount()
{
size_t items = GetItemCount();
if (items_per_page == 0)
{
return 1;
}
return ((items/items_per_page) + ((items % items_per_page) ? 1 : 0));
}
@ -171,49 +159,15 @@ int Menu::PagekeyToItem(page_t page, item_t key)
//first page
if (page == 0)
{
/* The algorithm for spaces here is same as a middle page. */
item_t new_key = key;
for (size_t i=start; i<(start+key-1) && i<m_Items.size(); i++)
{
for (size_t j=0; j<m_Items[i]->blanks.size(); j++)
{
if (m_Items[i]->blanks[j] == 1)
{
if (!new_key)
{
break;
}
new_key--;
}
if (!new_key)
{
break;
}
}
}
key = new_key;
if (key == items_per_page + 1)
{
return MENU_MORE;
} else if (key == items_per_page + 2) {
else if (key == items_per_page + 2)
return MENU_EXIT;
} else {
else
return (start + key - 1);
}
} else if (page == num_pages - 1) {
//last page
size_t remaining = m_Items.size() - start;
/* We have to add one remaining for each "bumping" space */
for (size_t i=m_Items.size() - remaining; i<m_Items.size(); i++)
{
for (size_t j=0; j<m_Items[i]->blanks.size(); j++)
{
if (m_Items[i]->blanks[j] == 1)
{
remaining++;
}
}
}
if (key == remaining + 1)
{
return MENU_BACK;
@ -223,29 +177,6 @@ int Menu::PagekeyToItem(page_t page, item_t key)
return (start + key - 1);
}
} else {
/* The algorithm for spaces here is a bit harder. We have to subtract
* one from the key for each space we find along the way.
*/
item_t new_key = key;
for (size_t i=start; i<(start+key-1) && i<m_Items.size(); i++)
{
for (size_t j=0; j<m_Items[i]->blanks.size(); j++)
{
if (m_Items[i]->blanks[j] == 1)
{
if (!new_key)
{
break;
}
new_key--;
}
if (!new_key)
{
break;
}
}
}
key = new_key;
if (key > items_per_page && (key-items_per_page<=3))
{
return m_OptOrders[key-items_per_page-1];
@ -355,33 +286,27 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
{
ret = executeForwards(pItem->handler, static_cast<cell>(player), static_cast<cell>(thisId), static_cast<cell>(i));
if (ret == ITEM_ENABLED)
{
enabled = true;
} else if (ret == ITEM_DISABLED) {
else if (ret == ITEM_DISABLED)
enabled = false;
}
}
if (pItem->pfn)
{
ret = (pItem->pfn)(player, thisId, i);
if (ret == ITEM_ENABLED)
{
enabled = true;
} else if (ret == ITEM_DISABLED) {
else if (ret == ITEM_DISABLED)
enabled = false;
}
}
if (enabled)
{
keys |= (1<<option);
if (m_AutoColors)
{
_snprintf(buffer, sizeof(buffer)-1, "\\r%d.\\w %s\n", ++option, pItem->name.c_str());
} else {
else
_snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", ++option, pItem->name.c_str());
}
} else {
if (m_AutoColors)
{
@ -401,9 +326,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
for (size_t j=0; j<pItem->blanks.size(); j++)
{
if (pItem->blanks[j] == 1)
{
option++;
}
m_Text.append("\n");
slots++;
}
@ -414,17 +337,11 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
{
int pad = items_per_page;
if (flags & Display_Back)
{
pad--;
}
if (flags & Display_Next)
{
pad--;
}
if (flags & Display_Exit)
{
pad--;
}
for (int i=slots+1; i<=pad; i++)
{
m_Text.append("\n");

View File

@ -110,7 +110,7 @@ void _Setup_Optimizer_Stage2(AMX *amx, cell *oplist, cell *cip)
}
#endif
}
/* we don't do these yet because of radix stuff >:\ */
//we don't do these yet because of radix stuff >:\
//FIND_NATIVE("floatsin", N_Float_Sin);
//FIND_NATIVE("floatcos", N_Float_Cos);
//FIND_NATIVE("floattan", N_Float_Tan);

View File

@ -2437,7 +2437,6 @@ static amxx_module_info_s g_ModuleInfo =
// Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives;
PFN_ADD_NEW_NATIVES g_fn_AddNewNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr;
@ -2516,7 +2515,6 @@ PFN_OVERRIDENATIVES g_fn_OverrideNatives;
PFN_GETLOCALINFO g_fn_GetLocalInfo;
PFN_AMX_REREGISTER g_fn_AmxReRegister;
PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
PFN_MESSAGE_BLOCK g_fn_MessageBlock;
// *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2593,7 +2591,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
// Natives / Forwards
REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES);
REQFUNC("AddNewNatives", g_fn_AddNewNatives, PFN_ADD_NEW_NATIVES);
REQFUNC("RaiseAmxError", g_fn_RaiseAmxError, PFN_RAISE_AMXERROR);
REQFUNC("RegisterForward", g_fn_RegisterForward, PFN_REGISTER_FORWARD);
REQFUNC("RegisterSPForward", g_fn_RegisterSPForward, PFN_REGISTER_SPFORWARD);
@ -2641,8 +2638,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetLocalInfo", g_fn_GetLocalInfo, PFN_GETLOCALINFO);
REQFUNC("AmxReregister", g_fn_AmxReRegister, PFN_AMX_REREGISTER);
REQFUNC("MessageBlock", g_fn_MessageBlock, PFN_MESSAGE_BLOCK);
#ifdef MEMORY_TEST
// Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
@ -2785,7 +2780,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_AddLibraries(NULL, LibType_Class, NULL);
MF_RemoveLibraries(NULL);
MF_OverrideNatives(NULL, NULL);
MF_MessageBlock(0, 0, NULL);
}
#endif

View File

@ -22,7 +22,7 @@
#ifndef __linux__
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __attribute__((visibility("default")))
#define DLLEXPORT
#define LINUX
#endif
@ -2095,16 +2095,9 @@ enum LibType
LibType_Class
};
#define MSGBLOCK_SET 0
#define MSGBLOCK_GET 1
#define BLOCK_NOT 0
#define BLOCK_ONCE 1
#define BLOCK_SET 2
typedef void (*AUTHORIZEFUNC)(int player, const char *authstring);
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef int (*PFN_ADD_NEW_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
@ -2190,10 +2183,8 @@ typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/, const ch
typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/);
typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/);
typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/);
typedef void (*PFN_MESSAGE_BLOCK) (int /* mode */, int /* message */, int * /* opt */);
extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_ADD_NEW_NATIVES g_fn_AddNewNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
@ -2266,13 +2257,11 @@ extern PFN_OVERRIDENATIVES g_fn_OverrideNatives;
extern PFN_GETLOCALINFO g_fn_GetLocalInfo;
extern PFN_AMX_REREGISTER g_fn_AmxReRegister;
extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
extern PFN_MESSAGE_BLOCK g_fn_MessageBlock;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
int MF_AddNewNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
@ -2339,11 +2328,9 @@ void MF_OverrideNatives (AMX_NATIVE_INFO *natives, const char *myname) { }
const char * MF_GetLocalInfo (const char *name, const char *def) { }
int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; }
void * MF_RegisterFunctionEx (void *pfn, const char *description) { }
void * MF_MessageBlock (int mode, int msg, int *opt) { }
#endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives
#define MF_AddNewNatives g_fn_AddNewNatives
#define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString
@ -2417,7 +2404,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetLocalInfo g_fn_GetLocalInfo
#define MF_AmxReRegister g_fn_AmxReRegister
#define MF_RegisterFunctionEx g_fn_RegisterFunctionEx
#define MF_MessageBlock g_fn_MessageBlock
#ifdef MEMORY_TEST
/*** Memory ***/

View File

@ -1,359 +0,0 @@
#include "amxmodx.h"
#include <stdlib.h>
/***********************************
* About the double array hack *
***************************
Double arrays in Pawn are vectors offset by the current offset. For example:
new array[2][2]
In this array, index 0 contains the offset from the current offset which
results in the final vector [2] (at [0][2]). Meaning, to dereference [1][2],
it is equivalent to:
address = &array[1] + array[1] + 2 * sizeof(cell)
The fact that each offset is from the _current_ position rather than the _base_
position is very important. It means that if you to try to swap vector positions,
the offsets will no longer match, because their current position has changed. A
simple and ingenious way around this is to back up the positions in a separate array,
then to overwrite each position in the old array with absolute indices. Pseudo C++ code:
cell *array; //assumed to be set to the 2+D array
cell *old_offsets = new cell[2];
for (int i=0; i<2; i++)
{
old_offsets = array[i];
array[i] = i;
}
Now, you can swap the array indices with no problem, and do a reverse-lookup to find the original addresses.
After sorting/modification is done, you must relocate the new indices. For example, if the two vectors in our
demo array were swapped, array[0] would be 1 and array[1] would be 0. This is invalid to the virtual machine.
Luckily, this is also simple -- all the information is there.
for (int i=0; i<2; i++)
{
//get the # of the vector we want to relocate in
cell vector_index = array[i];
//get the real address of this vector
char *real_address = (char *)array + (vector_index * sizeof(cell)) + old_offsets[vector_index];
//calc and store the new distance offset
array[i] = real_address - ( (char *)array + (vector_index + sizeof(cell)) )
}
Note that the inner expression can be heavily reduced; it is expanded for readability.
**********************************/
enum SortOrder
{
Sort_Ascending = 0,
Sort_Descending = 1,
};
int sort_ints_asc(const void *int1, const void *int2)
{
return (*(int *)int1) - (*(int *)int2);
}
int sort_ints_desc(const void *int1, const void *int2)
{
return (*(int *)int2) - (*(int *)int1);
}
static cell AMX_NATIVE_CALL SortIntegers(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
cell type = params[3];
if (type == Sort_Ascending)
{
qsort(array, array_size, sizeof(cell), sort_ints_asc);
} else {
qsort(array, array_size, sizeof(cell), sort_ints_desc);
}
return 1;
}
int sort_floats_asc(const void *float1, const void *float2)
{
REAL r1 = *(REAL *)float1;
REAL r2 = *(REAL *)float2;
if (r1 < r2)
{
return -1;
} else if (r2 < r1) {
return 1;
} else {
return 0;
}
}
int sort_floats_desc(const void *float1, const void *float2)
{
REAL r1 = *(REAL *)float1;
REAL r2 = *(REAL *)float2;
if (r1 < r2)
{
return 1;
} else if (r2 < r1) {
return -1;
} else {
return 0;
}
}
static cell AMX_NATIVE_CALL SortFloats(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
cell type = params[3];
if (type == Sort_Ascending)
{
qsort(array, array_size, sizeof(cell), sort_floats_asc);
} else {
qsort(array, array_size, sizeof(cell), sort_floats_desc);
}
return 1;
}
static cell *g_CurStringArray = NULL;
static cell *g_CurRebaseMap = NULL;
int sort_strings_asc(const void *blk1, const void *blk2)
{
cell reloc1 = *(cell *)blk1;
cell reloc2 = *(cell *)blk2;
register cell *str1 = (cell *)((char *)(&g_CurStringArray[reloc1]) + g_CurRebaseMap[reloc1]);
register cell *str2 = (cell *)((char *)(&g_CurStringArray[reloc2]) + g_CurRebaseMap[reloc2]);
while (*str1 == *str2++)
{
if (*str1++ == 0)
{
return 0;
}
}
return (*str1 - *(str2 - 1));
}
int sort_strings_desc(const void *blk1, const void *blk2)
{
cell reloc1 = *(cell *)blk1;
cell reloc2 = *(cell *)blk2;
register cell *str1 = (cell *)((char *)(&g_CurStringArray[reloc1]) + g_CurRebaseMap[reloc1]);
register cell *str2 = (cell *)((char *)(&g_CurStringArray[reloc2]) + g_CurRebaseMap[reloc2]);
while (*str1 == *str2++)
{
if (*str1++ == 0)
{
return 0;
}
}
return (*(str2 - 1) - *str1);
}
static cell AMX_NATIVE_CALL SortStrings(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
cell type = params[3];
/** HACKHACK - back up the old indices, replace the indices with something easier */
cell amx_addr, *phys_addr;
int err;
if ((err=amx_Allot(amx, array_size, &amx_addr, &phys_addr)) != AMX_ERR_NONE)
{
LogError(amx, err, "Ran out of memory");
return 0;
}
g_CurStringArray = array;
g_CurRebaseMap = phys_addr;
for (int i=0; i<array_size; i++)
{
phys_addr[i] = array[i];
array[i] = i;
}
if (type == Sort_Ascending)
{
qsort(array, array_size, sizeof(cell), sort_strings_asc);
} else {
qsort(array, array_size, sizeof(cell), sort_strings_desc);
}
/* END HACKHACK - restore what we damaged so Pawn doesn't throw up.
* We'll browse through each index of the array and patch up the distance.
*/
for (int i=0; i<array_size; i++)
{
/* Compute the final address of the old array and subtract the new location.
* This is the fixed up distance.
*/
array[i] = ((char *)&array[array[i]] + phys_addr[array[i]]) - (char *)&array[i];
}
amx_Release(amx, amx_addr);
g_CurStringArray = NULL;
g_CurRebaseMap = NULL;
return 1;
}
struct sort_info
{
int pfn;
cell data_addr;
cell data_size;
cell array_addr;
cell *array_base;
cell *array_remap;
AMX *amx;
};
static CStack<sort_info *> g_AMXSortStack;
int sort1d_amx_custom(const void *elem1, const void *elem2)
{
cell c1 = *(cell *)elem1;
cell c2 = *(cell *)elem2;
sort_info *pInfo = g_AMXSortStack.front();
return executeForwards(pInfo->pfn, c1, c2, pInfo->array_addr, pInfo->data_addr, pInfo->data_size);
}
static cell AMX_NATIVE_CALL SortCustom1D(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
int len;
const char *funcname = get_amxstring(amx, params[3], 0, len);
int pfn = registerSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
if (pfn < 0)
{
LogError(amx, AMX_ERR_NATIVE, "The public function \"%s\" was not found.", funcname);
return 0;
}
sort_info *pInfo = new sort_info;
pInfo->pfn = pfn;
pInfo->data_addr = params[4];
pInfo->data_size = params[5];
pInfo->array_addr = params[1];
pInfo->array_remap = NULL;
pInfo->array_base = NULL;
g_AMXSortStack.push(pInfo);
qsort(array, array_size, sizeof(cell), sort1d_amx_custom);
g_AMXSortStack.pop();
delete pInfo;
return 1;
}
int sort2d_amx_custom(const void *elem1, const void *elem2)
{
cell c1 = *(cell *)elem1;
cell c2 = *(cell *)elem2;
sort_info *pInfo = g_AMXSortStack.front();
cell c1_addr = pInfo->array_addr + (c1 * sizeof(cell)) + pInfo->array_remap[c1];
cell c2_addr = pInfo->array_addr + (c2 * sizeof(cell)) + pInfo->array_remap[c2];
//cell *c1_r = get_amxaddr(pInfo->amx, c1_addr);
//cell *c2_r = get_amxaddr(pInfo->amx, c2_addr);
return executeForwards(pInfo->pfn, c1_addr, c2_addr, pInfo->array_addr, pInfo->data_addr, pInfo->data_size);
}
static cell AMX_NATIVE_CALL SortCustom2D(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
int len;
const char *funcname = get_amxstring(amx, params[3], 0, len);
/** back up the old indices, replace the indices with something easier */
cell amx_addr, *phys_addr;
int err;
if ((err=amx_Allot(amx, array_size, &amx_addr, &phys_addr)) != AMX_ERR_NONE)
{
LogError(amx, err, "Ran out of memory");
return 0;
}
int pfn = registerSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
if (pfn < 0)
{
amx_Release(amx, amx_addr);
LogError(amx, AMX_ERR_NATIVE, "The public function \"%s\" was not found.", funcname);
return 0;
}
sort_info *pInfo = new sort_info;
pInfo->pfn = pfn;
pInfo->data_addr = params[4];
pInfo->data_size = params[5];
pInfo->array_addr = params[1];
pInfo->amx = amx;
/** Same process as in strings, back up the old indices for later fixup */
pInfo->array_base = array;
pInfo->array_remap = phys_addr;
for (int i=0; i<array_size; i++)
{
phys_addr[i] = array[i];
array[i] = i;
}
g_AMXSortStack.push(pInfo);
qsort(array, array_size, sizeof(cell), sort2d_amx_custom);
g_AMXSortStack.pop();
/** Fixup process! */
for (int i=0; i<array_size; i++)
{
/* Compute the final address of the old array and subtract the new location.
* This is the fixed up distance.
*/
array[i] = ((char *)&array[array[i]] + phys_addr[array[i]]) - (char *)&array[i];
}
amx_Release(amx, amx_addr);
unregisterSPForward(pInfo->pfn);
delete pInfo;
return 1;
}
AMX_NATIVE_INFO g_SortNatives[] =
{
{"SortIntegers", SortIntegers},
{"SortFloats", SortFloats},
{"SortStrings", SortStrings},
{"SortCustom1D", SortCustom1D},
{"SortCustom2D", SortCustom2D},
{NULL, NULL},
};

View File

@ -143,10 +143,10 @@ void amx_command()
else if (!strcmp(cmd, "version"))
{
print_srvconsole("%s %s (%s)\n", Plugin_info.name, Plugin_info.version, Plugin_info.url);
print_srvconsole("Authors:\n\tDavid \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko\n");
print_srvconsole("Authors: David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko\n");
print_srvconsole("\tFelix \"SniperBeamer\" Geyer, Jonny \"Got His Gun\" Bergstrom\n");
print_srvconsole("\tLukasz \"SidLuke\" Wlasinski, Christian \"Basic-Master\" Hammacher\n");
print_srvconsole("\tBorja \"faluco\" Ferrer, Scott \"Damaged Soul\" Ehlert\n");
print_srvconsole("\tBorja \"faluco\" Ferrer\n");
print_srvconsole("Compiled: %s\n", __DATE__ ", " __TIME__);
#if defined JIT && !defined ASM32
print_srvconsole("Core mode: JIT Only\n");
@ -253,6 +253,7 @@ void amx_command()
void plugin_srvcmd()
{
cell ret = 0;
const char* cmd = CMD_ARGV(0);
CmdMngr::iterator a = g_commands.srvcmdbegin();

View File

@ -33,7 +33,6 @@
#include "amxmodx.h"
#include "format.h"
#include "binlog.h"
#include "amxmod_compat.h"
const char* stristr(const char* str, const char* substr)
{
@ -116,21 +115,8 @@ extern "C" size_t get_amxstring_r(AMX *amx, cell amx_addr, char *destination, in
register char *dest = destination;
char *start = dest;
if ( (amx->flags & AMX_FLAG_OLDFILE) &&
(*source & BCOMPAT_TRANSLATE_BITS) )
{
const char *def, *key;
if (!translate_bcompat(amx, source, &key, &def))
{
goto normal_string;
}
while (maxlen-- && *def)
*dest++=(*source++);
} else {
normal_string:
while (maxlen-- && *source)
*dest++=(char)(*source++);
}
while (maxlen-- && *source)
*dest++=(char)(*source++);
*dest = '\0';
@ -146,29 +132,16 @@ normal_string:
return dest - start;
}
char *get_amxstring(AMX *amx, cell amx_addr, int id, int& len)
char* get_amxstring(AMX *amx, cell amx_addr, int id, int& len)
{
static char buffor[4][3072];
register cell* source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
register char* dest = buffor[id];
char* start = dest;
while ((*dest++=(char)(*source++)));
if ( (amx->flags & AMX_FLAG_OLDFILE) &&
(*source & BCOMPAT_TRANSLATE_BITS) )
{
const char *def, *key;
if (!translate_bcompat(amx, source, &key, &def))
{
goto normal_string;
}
while ( (*dest++ = (*def++)) );
len = --dest - start;
} else {
normal_string:
while ((*dest++=(char)(*source++)));
len = --dest - start;
}
len = --dest - start;
#if defined BINLOG_ENABLED
if (g_binlog_level & 2)
@ -443,42 +416,15 @@ static cell AMX_NATIVE_CALL add(AMX *amx, cell *params) /* 4 param */
static cell AMX_NATIVE_CALL copy(AMX *amx, cell *params) /* 4 param */
{
cell *src = get_amxaddr(amx, params[3]);
cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest;
int c = params[2];
if (amx->flags & AMX_FLAG_OLDFILE)
{
if (*src & BCOMPAT_TRANSLATE_BITS)
{
const char *key, *def;
if (!translate_bcompat(amx, src, &key, &def))
{
goto normal_string;
}
cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest;
while (c-- && *def)
{
*dest++ = static_cast<cell>(*def++);
}
*dest = '\0';
return dest-start;
} else {
goto normal_string;
}
} else {
normal_string:
cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest;
while (c-- && *src)
{
*dest++ = *src++;
}
*dest = '\0';
return (dest - start);
}
while (c-- && *src)
*dest++ =* src++;
*dest = 0;
return (dest - start);
}
static cell AMX_NATIVE_CALL copyc(AMX *amx, cell *params) /* 4 param */
@ -595,26 +541,7 @@ static cell AMX_NATIVE_CALL format(AMX *amx, cell *params) /* 3 param */
if (copy)
buf = g_cpbuf;
int param = 4;
size_t total = 0;
if (amx->flags & AMX_FLAG_OLDFILE)
{
if (*fmt & BCOMPAT_TRANSLATE_BITS)
{
const char *key, *def;
if (!translate_bcompat(amx, fmt, &key, &def))
{
goto normal_string;
}
total = atcprintf(buf, maxlen, def, amx, params, &param);
} else {
goto normal_string;
}
} else {
normal_string:
total = atcprintf(buf, maxlen, fmt, amx, params, &param);
}
size_t total = atcprintf(buf, maxlen, fmt, amx, params, &param);
if (copy)
{
/* copy back */
@ -936,6 +863,7 @@ static cell AMX_NATIVE_CALL is_alpha(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_ucfirst(AMX *amx, cell *params)
{
int len = 0;
cell *str = get_amxaddr(amx, params[1]);
if (!isalpha((char)str[0]) || !(str[0] & (1<<5)))
@ -1016,6 +944,7 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
int sublen;
char *sub = get_amxstring(amx, params[2], 1, sublen);
bool found = false;
bool igcase = params[3] ? true : false;
if (igcase)
@ -1035,6 +964,7 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
if (params[4] > len)
return -1;
char *pos = &(str[params[4]]);
char *find = strstr(str, sub);
if (!find)

View File

@ -32,7 +32,7 @@
#include <time.h>
#include "amxmodx.h"
#if defined __linux__ && !defined _vsnprintf
#ifdef __linux__
#define _vsnprintf vsnprintf
#endif
@ -347,4 +347,3 @@ void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1,
// unset the global "fake" flag
g_fakecmd.fake = false;
}

View File

@ -141,16 +141,13 @@ static cell AMX_NATIVE_CALL angle_vector(AMX *amx, cell *params)
{
case ANGLEVECTORS_FORWARD:
v_return = v_forward;
break;
case ANGLEVECTORS_RIGHT:
v_return = v_right;
break;
case ANGLEVECTORS_UP:
v_return = v_up;
break;
}
vCell = get_amxaddr(amx, params[3]);
vCell = get_amxaddr(amx,params[3]);
vCell[0] = FloatToCell(v_return.x);
vCell[1] = FloatToCell(v_return.y);
vCell[2] = FloatToCell(v_return.z);

View File

@ -1,6 +1,5 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
@ -27,8 +26,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,6,2
PRODUCTVERSION 1,7,6,2
FILEVERSION 1,7,5,0
PRODUCTVERSION 1,7,5,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -45,12 +44,12 @@ BEGIN
BEGIN
VALUE "Comments", "AMX Mod X"
VALUE "FileDescription", "AMX Mod X"
VALUE "FileVersion", "1.76b"
VALUE "FileVersion", "1.75"
VALUE "InternalName", "amxmodx"
VALUE "LegalCopyright", "Copyright (c) 2004-2006, AMX Mod X Dev Team"
VALUE "OriginalFilename", "amxmodx_mm.dll"
VALUE "ProductName", "AMX Mod X"
VALUE "ProductVersion", "1.76b"
VALUE "ProductVersion", "1.75"
END
END
BLOCK "VarFileInfo"

View File

@ -3,9 +3,9 @@
### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
OPT_FLAGS = -O3 -funroll-loops -s -pipe
DEBUG_FLAGS = -g -ggdb3
CPP = gcc-4.1
CPP = gcc
BINARY = amxxpc
OBJECTS = amx.cpp amxxpc.cpp Binary.cpp

View File

@ -1,7 +1,7 @@
#ifndef _AMXXSC_INCLUDE_H
#define _AMXXSC_INCLUDE_H
#define VERSION_STRING "1.76-300"
#define VERSION_STRING "1.75-300"
#define MAGIC_HEADER2 0x414D5858
#define MAGIC_VERSION 0x0300

Binary file not shown.

View File

@ -3,14 +3,13 @@
### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing -fvisibility=hidden
OPT_FLAGS = -O3 -funroll-loops -s -pipe
DEBUG_FLAGS = -g -ggdb3
CPP = gcc-4.1
CPP = gcc
NAME = amxxpc
OBJECTS = sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c scvars.c scmemfil.c \
scstate.c sclist.c sci18n.c scexpand.c pawncc.c libpawnc.c prefix.c \
memfile.c
scstate.c sclist.c sci18n.c scexpand.c pawncc.c libpawnc.c prefix.c
LINK = -lpthread

View File

@ -52,7 +52,7 @@
__declspec (dllexport)
void EXCOMPILER(int argc, char **argv)
# else
void extern __attribute__((visibility("default"))) EXCOMPILER(int argc, char **argv)
void extern EXCOMPILER(int argc, char **argv)
# endif
{
pc_compile(argc, argv);
@ -70,7 +70,7 @@
__declspec (dllexport)
int pc_printf(const char *message,...)
#else
extern int __attribute__((visibility("default"))) pc_printf(const char *message,...)
extern int pc_printf(const char *message,...)
#endif
#else
int pc_printf(const char *message, ...)

View File

@ -310,9 +310,6 @@
<File
RelativePath=".\libpawnc.c">
</File>
<File
RelativePath=".\memfile.c">
</File>
<File
RelativePath=".\sc1.c">
</File>
@ -360,9 +357,6 @@
<File
RelativePath=".\amx.h">
</File>
<File
RelativePath=".\memfile.h">
</File>
<File
RelativePath=".\sc.h">
</File>

View File

@ -1,105 +0,0 @@
#include "memfile.h"
#include <string.h>
#include "osdefs.h"
memfile_t *memfile_creat(const char *name, size_t init)
{
memfile_t mf;
memfile_t *pmf;
mf.size = init;
mf.base = (char *)malloc(init);
mf.usedoffs = 0;
if (!mf.base)
{
return NULL;
}
mf.offs = 0;
mf._static = 0;
pmf = (memfile_t *)malloc(sizeof(memfile_t));
memcpy(pmf, &mf, sizeof(memfile_t));
pmf->name = strdup(name);
return pmf;
}
void memfile_destroy(memfile_t *mf)
{
if (!mf->_static)
{
free(mf->name);
free(mf->base);
free(mf);
}
}
void memfile_seek(memfile_t *mf, long seek)
{
mf->offs = seek;
}
long memfile_tell(memfile_t *mf)
{
return mf->offs;
}
size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize)
{
if (!maxsize || mf->offs >= mf->usedoffs)
{
return 0;
}
if (mf->usedoffs - mf->offs < (long)maxsize)
{
maxsize = mf->usedoffs - mf->offs;
if (!maxsize)
{
return 0;
}
}
memcpy(buffer, mf->base + mf->offs, maxsize);
mf->offs += maxsize;
return maxsize;
}
int memfile_write(memfile_t *mf, void *buffer, size_t size)
{
if (mf->offs + size > mf->size)
{
size_t newsize = (mf->size + size) * 2;
if (mf->_static)
{
char *oldbase = mf->base;
mf->base = (char *)malloc(newsize);
if (!mf->base)
{
return 0;
}
memcpy(mf->base, oldbase, mf->size);
} else {
mf->base = (char *)realloc(mf->base, newsize);
if (!mf->base)
{
return 0;
}
}
mf->_static = 0;
mf->size = newsize;
}
memcpy(mf->base + mf->offs, buffer, size);
mf->offs += size;
if (mf->offs > mf->usedoffs)
{
mf->usedoffs = mf->offs;
}
return 1;
}

View File

@ -1,23 +0,0 @@
#ifndef _INCLUDE_MEMFILE_H
#define _INCLUDE_MEMFILE_H
#include <malloc.h>
typedef struct memfile_s
{
char *name;
char *base;
long offs;
long usedoffs;
size_t size;
int _static;
} memfile_t;
memfile_t *memfile_creat(const char *name, size_t init);
void memfile_destroy(memfile_t *mf);
void memfile_seek(memfile_t *mf, long seek);
int memfile_write(memfile_t *mf, void *buffer, size_t size);
size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize);
long memfile_tell(memfile_t *mf);
#endif //_INCLUDE_MEMFILE_H

View File

@ -446,7 +446,7 @@ int pc_enablewarning(int number,int enable);
__declspec (dllexport)
int pc_printf(const char *message,...);
#else
extern int __attribute__((visibility("default"))) pc_printf(const char *message,...);
extern int pc_printf(const char *message,...);
#endif
#else
int pc_printf(const char *message, ...) INVISIBLE;

View File

@ -993,8 +993,6 @@ static int hier13(value *lval)
value lval2 = {0};
int array1,array2;
int orig_heap=decl_heap;
int diff1=0,diff2=0;
if (lvalue) {
rvalue(lval);
} else if (lval->ident==iCONSTEXPR) {
@ -1011,10 +1009,6 @@ static int hier13(value *lval)
sc_allowtags=(short)POPSTK_I(); /* restore */
jumplabel(flab2);
setlabel(flab1);
if (orig_heap!=decl_heap) {
diff1=abs(decl_heap-orig_heap);
decl_heap=orig_heap;
}
needtoken(':');
if (hier13(&lval2))
rvalue(&lval2);
@ -1037,15 +1031,6 @@ static int hier13(value *lval)
lval->ident=iREFARRAY; /* iARRAY becomes iREFARRAY */
else if (lval->ident!=iREFARRAY)
lval->ident=iEXPRESSION; /* iREFARRAY stays iREFARRAY, rest becomes iEXPRESSION */
if (orig_heap!=decl_heap) {
diff2=abs(decl_heap-orig_heap);
decl_heap=orig_heap;
}
if (diff1==diff2) {
decl_heap+=(diff1/2);
} else {
decl_heap+=(diff1+diff2);
}
return FALSE; /* conditional expression is no lvalue */
} else {
return lvalue;

View File

@ -236,15 +236,6 @@ static stringlist includepaths = {NULL, NULL}; /* directory list for include fi
SC_FUNC stringlist *insert_path(char *path)
{
char *extra_path = malloc(strlen(path) + 16);
strcpy(extra_path, path);
#if defined __linux__
strcat(extra_path, "/amxmod_compat/");
#else if defined WIN32 || defined _WIN32
strcat(extra_path, "\\amxmod_compat\\");
#endif
insert_string(&includepaths, extra_path);
free(extra_path);
return insert_string(&includepaths,path);
}

View File

@ -29,7 +29,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "memfile.h"
#if defined FORTIFY
#include "fortify.h"
@ -45,7 +44,11 @@
* buffer points to the "file name"
* bufpos is the current "file pointer"
*/
typedef memfile_t MEMFILE;
typedef struct tagMEMFILE {
struct tagMEMFILE *next;
unsigned char *buffer;
long bufpos;
} MEMFILE;
#define tMEMFILE 1
#include "sc.h"
@ -53,12 +56,33 @@ typedef memfile_t MEMFILE;
MEMFILE *mfcreate(char *filename)
{
return memfile_creat(filename, 4096);
MEMFILE *mf;
/* create a first block that only holds the name */
mf=(MEMFILE*)malloc(sizeof(MEMFILE));
if (mf==NULL)
return NULL;
memset(mf,0,sizeof(MEMFILE));
mf->buffer=(unsigned char*)strdup(filename);
if (mf->buffer==NULL) {
free(mf);
return NULL;
} /* if */
return mf;
}
void mfclose(MEMFILE *mf)
{
memfile_destroy(mf);
MEMFILE *next;
assert(mf!=NULL);
while (mf!=NULL) {
next=mf->next;
assert(mf->buffer!=NULL);
free(mf->buffer);
free(mf);
mf=next;
} /* while */
}
int mfdump(MEMFILE *mf)
@ -68,12 +92,19 @@ int mfdump(MEMFILE *mf)
assert(mf!=NULL);
/* create the file */
fp=fopen(mf->name, "wb");
fp=fopen((char*)mf->buffer,"wb");
if (fp==NULL)
return 0;
okay=1;
okay = okay & (fwrite(mf->base, mf->usedoffs, 1, fp)==(size_t)mf->usedoffs);
mf=mf->next;
while (mf!=NULL) {
assert(mf->buffer!=NULL);
/* all blocks except the last should be fully filled */
assert(mf->next==NULL || (unsigned long)mf->bufpos==BUFFERSIZE);
okay=okay && fwrite(mf->buffer,1,(size_t)mf->bufpos,fp)==(size_t)mf->bufpos;
mf=mf->next;
} /* while */
fclose(fp);
return okay;
@ -81,7 +112,19 @@ int mfdump(MEMFILE *mf)
long mflength(MEMFILE *mf)
{
return mf->usedoffs;
long length;
assert(mf!=NULL);
/* find the size of the memory file */
length=0L;
mf=mf->next; /* skip initial block */
while (mf!=NULL) {
assert(mf->next==NULL || (unsigned long)mf->bufpos==BUFFERSIZE);
length+=mf->bufpos;
mf=mf->next;
} /* while */
return length;
}
long mfseek(MEMFILE *mf,long offset,int whence)
@ -89,7 +132,7 @@ long mfseek(MEMFILE *mf,long offset,int whence)
long length;
assert(mf!=NULL);
if (mf->usedoffs == 0)
if (mf->next==NULL)
return 0L; /* early exit: not a single byte in the file */
/* find the size of the memory file */
@ -100,7 +143,7 @@ long mfseek(MEMFILE *mf,long offset,int whence)
case SEEK_SET:
break;
case SEEK_CUR:
offset+=mf->offs;
offset+=mf->bufpos;
break;
case SEEK_END:
assert(offset<=0);
@ -115,18 +158,136 @@ long mfseek(MEMFILE *mf,long offset,int whence)
offset=length;
/* set new position and return it */
memfile_seek(mf, offset);
mf->bufpos=offset;
return offset;
}
unsigned int mfwrite(MEMFILE *mf,unsigned char *buffer,unsigned int size)
{
return (memfile_write(mf, buffer, size) ? size : 0);
long length;
long numblocks;
int blockpos,blocksize;
unsigned int bytes;
MEMFILE *block;
assert(mf!=NULL);
/* see whether more memory must be allocated */
length=mflength(mf);
assert(mf->bufpos>=0 && mf->bufpos<=length);
numblocks=(length+BUFFERSIZE-1)/BUFFERSIZE; /* # allocated blocks */
while (mf->bufpos+size>numblocks*BUFFERSIZE) {
/* append a block */
MEMFILE *last;
block=(MEMFILE*)malloc(sizeof(MEMFILE));
if (block==NULL)
return 0;
memset(block,0,sizeof(MEMFILE));
block->buffer=(unsigned char*)malloc(BUFFERSIZE);
if (block->buffer==NULL) {
free(block);
return 0;
} /* if */
for (last=mf; last->next!=NULL; last=last->next)
/* nothing */;
assert(last!=NULL);
assert(last->next==NULL);
last->next=block;
numblocks++;
} /* while */
if (size==0)
return 0;
/* find the block to start writing to */
numblocks=mf->bufpos/BUFFERSIZE; /* # blocks to skip */
block=mf->next;
while (numblocks-->0) {
assert(block!=NULL);
block=block->next;
} /* while */
assert(block!=NULL);
/* copy into memory */
bytes=0;
blockpos=(int)(mf->bufpos % BUFFERSIZE);
do {
blocksize=BUFFERSIZE-blockpos;
assert(blocksize>=0);
if ((unsigned int)blocksize>size)
blocksize=size;
assert(block!=NULL);
memcpy(block->buffer+blockpos,buffer,blocksize);
buffer+=blocksize;
size-=blocksize;
bytes+=blocksize;
if (blockpos+blocksize>block->bufpos)
block->bufpos=blockpos+blocksize;
assert(block->bufpos>=0 && (unsigned long)block->bufpos<=BUFFERSIZE);
block=block->next;
blockpos=0;
} while (size>0);
/* adjust file pointer */
mf->bufpos+=bytes;
return bytes;
}
unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size)
{
return memfile_read(mf, buffer, size);
long length;
long numblocks;
int blockpos,blocksize;
unsigned int bytes;
MEMFILE *block;
assert(mf!=NULL);
/* adjust the size to read */
length=mflength(mf);
assert(mf->bufpos>=0 && mf->bufpos<=length);
if (mf->bufpos+size>(unsigned long)length)
size=(int)(length-mf->bufpos);
assert(mf->bufpos+size<=(unsigned long)length);
if (size==0)
return 0;
/* find the block to start reading from */
numblocks=mf->bufpos/BUFFERSIZE; /* # blocks to skip */
block=mf->next;
while (numblocks-->0) {
assert(block!=NULL);
block=block->next;
} /* while */
assert(block!=NULL);
/* copy out of memory */
bytes=0;
blockpos=(int)(mf->bufpos % BUFFERSIZE);
do {
blocksize=BUFFERSIZE-blockpos;
if ((unsigned int)blocksize>size)
blocksize=size;
assert(block!=NULL);
assert(block->bufpos>=0 && (unsigned long)block->bufpos<=BUFFERSIZE);
assert(blockpos+blocksize<=block->bufpos);
memcpy(buffer,block->buffer+blockpos,blocksize);
buffer+=blocksize;
size-=blocksize;
bytes+=blocksize;
block=block->next;
blockpos=0;
} while (size>0);
/* adjust file pointer */
mf->bufpos+=bytes;
return bytes;
}
char *mfgets(MEMFILE *mf,char *string,unsigned int size)

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X
amxx_logs addons/amxmodx/logs
amxx_logdir addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X
amxx_logs addons/amxmodx/logs
amxx_logdir addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -39,7 +39,5 @@ statsx.amxx ; stats on death or round end (CSX Module required!)
;miscstats.amxx ; bunch of events announcement for Counter-Strike
;stats_logging.amxx ; weapons stats logging (CSX Module required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here

View File

@ -6,3 +6,4 @@ ShowStats ;HUD-stats default
SayRankStats ;Say /rankstats
SayRank ;Say /rank
SayTop15 ;Say /top15
ShowStats ;HUD-stats default

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X
amxx_logs addons/amxmodx/logs
amxx_logdir addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -38,7 +38,5 @@ statscfg.amxx ; allows to manage stats plugins via menu and commands
;statssounds.amxx ; precache plugin for stats plugins
;stats_logging.amxx ; weapons stats logging (DoD Module required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here

View File

@ -33,8 +33,6 @@ timeleft.amxx ; displays time left on map
pausecfg.amxx ; allows to pause and unpause some plugins
statscfg.amxx ; allows to manage stats plugins via menu and commands
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here
EvolutionX.Core.amxx ; Adds extra plugin functions for Earth's Special Forces

View File

@ -37,7 +37,4 @@ idlekicker.amxx ; kicks idle players
nscommands.amxx ; extra commands for Natural-Selection
;unstuck.amxx ; Free stuck players (engine & ns modules required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here

View File

@ -33,8 +33,5 @@ timeleft.amxx ; displays time left on map
pausecfg.amxx ; allows to pause and unpause some plugins
statscfg.amxx ; allows to manage stats plugins via menu and commands
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X
amxx_logs addons/amxmodx/logs
amxx_logdir addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -38,7 +38,5 @@ statscfg.amxx ; allows to manage stats plugins via menu and commands
;statssounds.amxx ; precache plugin for stats plugins
;stats_logging.amxx ; weapons stats logging (TFC Module required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X
amxx_logs addons/amxmodx/logs
amxx_logdir addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -38,7 +38,5 @@ statscfg.amxx ; allows to manage stats plugins via menu and commands
;statssounds.amxx ; precache plugin for stats plugins
;stats_logging.amxx ; weapons stats logging (TS Module required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here

View File

@ -0,0 +1,62 @@
#if defined _csstats_included
#endinput
#endif
#define _csstats_included
/* Gets stats from given weapon index. If wpnindex is 0
* then the stats are from all weapons. If weapon has not been used function
* returns 0 in other case 1. Fields in stats are:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkilling
* 4 - shots
* 5 - hits
* 6 - damage
* For body hits fields see amxconst.inc. */
native get_user_wstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets round stats from given weapon index.*/
native get_user_wrstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets overall stats which are stored in file on server
* and updated on every respawn or user disconnect.
* Function returns the position in stats by diff. kills to deaths. */
native get_user_stats(index,stats[8],bodyhits[8]);
/* Gets round stats of player. */
native get_user_rstats(index,stats[8],bodyhits[8]);
/* Gets stats with which user have killed/hurt his victim. If victim is 0
* then stats are from all victims. If victim has not been hurt, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_vstats(index,victim,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Gets stats with which user have been killed/hurt. If killer is 0
* then stats are from all attacks. If killer has not hurt user, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_astats(index,wpnindex,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Resets life, weapon, victims and attackers user stats. */
native reset_user_wstats(index);
/* Gets overall stats which stored in stats.dat file in amx folder
* and updated on every mapchange or user disconnect.
* Function returns next index of stats entry or 0 if no more exists. */
native get_stats(index,stats[8],bodyhits[8],name[],len);
/* Returns number of all entries in stats. */
native get_statsnum();
/*
* new stats:
* 0 - total defusions
* 1 - bomb defused
* 2 - bomb plants
* 3 - bomb explosions
*/
native get_user_stats2(index,stats[4]);
native get_stats2(index,stats[4]);

256
dlls/csstats2/csstats/CMisc.cpp Executable file
View File

@ -0,0 +1,256 @@
#include "CMisc.h"
#include "rank.h"
// *****************************************************
// class Grenades
// *****************************************************
void Grenades::put( edict_t* grenade, float time, int type, CPlayer* player )
{
Obj* a = new Obj;
if ( a == 0 ) return;
a->player = player;
a->grenade = grenade;
a->time = gpGlobals->time + time;
a->type = type;
a->prev = 0;
a->next = head;
if ( head ) head->prev = a;
head = a;
}
bool Grenades::find( edict_t* enemy, CPlayer** p, int* type )
{
bool found = false;
Obj* a = head;
while ( a ){
if ( a->time > gpGlobals->time ) {
if ( a->grenade == enemy ) {
found = true;
*p = a->player;
*type = a->type;
}
}
else {
Obj* next = a->next;
if (a->prev) a->prev->next = next;
else head = next;
if (next) next->prev = a->prev;
delete a;
a = next;
continue;
}
a = a->next;
}
return found;
}
void Grenades::clear()
{
while(head){
Obj* a = head->next;
delete head;
head = a;
}
}
// *****************************************************
// class CPlayer
// *****************************************************
void CPlayer::Disconnect(){
if ( ignoreBots(pEdict) || !isModuleActive() ) // ignore if he is bot and bots rank is disabled or module is paused
return;
rank->updatePosition( &life );
rank = 0;
}
void CPlayer::PutInServer(){
if ( ignoreBots(pEdict) )
return;
restartStats();
const char* name = STRING(pEdict->v.netname);
const char* unique = name;
switch((int)csstats_rank->value) {
case 1:
if ( (unique = GETPLAYERAUTHID(pEdict)) == 0 )
unique = name; // failed to get authid
break;
case 2:
unique = ip;
}
rank = g_rank.findEntryInRank( unique , name );
}
void CPlayer::Connect(const char* address ){
strcpy(ip,address);
rank = 0;
clearStats = 0.0f;
}
void CPlayer::restartStats(bool all)
{
if ( all ) memset(weapons,0,sizeof(weapons));
memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats
memset(attackers,0,sizeof(attackers));
memset(victims,0,sizeof(victims));
memset(&life,0,sizeof(life));
}
void CPlayer::Init( int pi, edict_t* pe )
{
pEdict = pe;
index = pi;
current = 0;
clearStats = 0.0f;
rank = 0;
}
void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
if ( ignoreBots(pEdict,pVictim->pEdict) )
return;
if ( pVictim->index == index ){ // killed self
pVictim->weapons[0].deaths++;
pVictim->life.deaths++;
pVictim->weaponsRnd[0].deaths++; // DEC-Weapon (round) stats
return;
}
pVictim->attackers[index].name = weaponData[wweapon].name;
pVictim->attackers[index].kills++;
pVictim->attackers[index].hs += hhs;
pVictim->attackers[index].tks += ttk;
pVictim->attackers[0].kills++;
pVictim->attackers[0].hs += hhs;
pVictim->attackers[0].tks += ttk;
pVictim->weapons[pVictim->current].deaths++;
pVictim->weapons[0].deaths++;
pVictim->life.deaths++;
pVictim->weaponsRnd[pVictim->current].deaths++; // DEC-Weapon (round) stats
pVictim->weaponsRnd[0].deaths++; // DEC-Weapon (round) stats
int vi = pVictim->index;
victims[vi].name = weaponData[wweapon].name;
victims[vi].deaths++;
victims[vi].hs += hhs;
victims[vi].tks += ttk;
victims[0].deaths++;
victims[0].hs += hhs;
victims[0].tks += ttk;
weaponsRnd[wweapon].kills++; // DEC-Weapon (round) stats
weaponsRnd[wweapon].hs += hhs; // DEC-Weapon (round) stats
weaponsRnd[wweapon].tks += ttk; // DEC-Weapon (round) stats
weaponsRnd[0].kills++; // DEC-Weapon (round) stats
weaponsRnd[0].hs += hhs; // DEC-Weapon (round) stats
weaponsRnd[0].tks += ttk; // DEC-Weapon (round) stats
weapons[wweapon].kills++;
weapons[wweapon].hs += hhs;
weapons[wweapon].tks += ttk;
weapons[0].kills++;
weapons[0].hs += hhs;
weapons[0].tks += ttk;
life.kills++;
life.hs += hhs;
life.tks += ttk;
}
void CPlayer::saveHit(CPlayer* pVictim, int wweapon, int ddamage, int bbody){
if ( ignoreBots(pEdict,pVictim->pEdict) )
return;
if ( index == pVictim->index ) return;
pVictim->attackers[index].hits++;
pVictim->attackers[index].damage += ddamage;
pVictim->attackers[index].bodyHits[bbody]++;
pVictim->attackers[0].hits++;
pVictim->attackers[0].damage += ddamage;
pVictim->attackers[0].bodyHits[bbody]++;
int vi = pVictim->index;
victims[vi].hits++;
victims[vi].damage += ddamage;
victims[vi].bodyHits[bbody]++;
victims[0].hits++;
victims[0].damage += ddamage;
victims[0].bodyHits[bbody]++;
weaponsRnd[wweapon].hits++; // DEC-Weapon (round) stats
weaponsRnd[wweapon].damage += ddamage; // DEC-Weapon (round) stats
weaponsRnd[wweapon].bodyHits[bbody]++; // DEC-Weapon (round) stats
weaponsRnd[0].hits++; // DEC-Weapon (round) stats
weaponsRnd[0].damage += ddamage; // DEC-Weapon (round) stats
weaponsRnd[0].bodyHits[bbody]++; // DEC-Weapon (round) stats
weapons[wweapon].hits++;
weapons[wweapon].damage += ddamage;
weapons[wweapon].bodyHits[bbody]++;
weapons[0].hits++;
weapons[0].damage += ddamage;
weapons[0].bodyHits[bbody]++;
life.hits++;
life.damage += ddamage;
life.bodyHits[bbody]++;
}
void CPlayer::saveShot(int weapon){
if ( ignoreBots(pEdict) )
return;
victims[0].shots++;
weapons[weapon].shots++;
weapons[0].shots++;
life.shots++;
weaponsRnd[weapon].shots++; // DEC-Weapon (round) stats
weaponsRnd[0].shots++; // DEC-Weapon (round) stats
}
void CPlayer::saveBPlant(){
life.bPlants++;
}
void CPlayer::saveBExplode(){
life.bExplosions++;
}
void CPlayer::saveBDefusing(){
life.bDefusions++;
}
void CPlayer::saveBDefused(){
life.bDefused++;
}
// *****************************************************
bool ignoreBots (edict_t *pEnt, edict_t *pOther){
if ( !rankBots && ( pEnt->v.flags & FL_FAKECLIENT || ( pOther && pOther->v.flags & FL_FAKECLIENT ) ) )
return true;
return false;
}
bool isModuleActive(){
if ( !(int)CVAR_GET_FLOAT("csstats_pause") )
return true;
return false;
}

91
dlls/csstats2/csstats/CMisc.h Executable file
View File

@ -0,0 +1,91 @@
#ifndef CMISC_H
#define CMISC_H
#include "amxxmodule.h"
#include "CRank.h"
#define CSW_HEGRENADE 4
#define CSW_SMOKEGRENADE 9
#define CSW_FLASHBANG 25
// *****************************************************
// class CPlayer
// *****************************************************
struct CPlayer {
edict_t* pEdict;
char ip[32];
int index;
int aiming;
int current;
float clearStats;
RankSystem::RankStats* rank;
struct PlayerWeapon : Stats {
const char* name;
int ammo;
int clip;
};
PlayerWeapon weapons[MAX_WEAPONS];
PlayerWeapon attackers[33];
PlayerWeapon victims[33];
Stats weaponsRnd[MAX_WEAPONS]; // DEC-Weapon (Round) stats
Stats life;
int teamId;
void Init( int pi, edict_t* pe );
void Connect(const char* ip );
void PutInServer();
void Disconnect();
void saveKill(CPlayer* pVictim, int weapon, int hs, int tk);
void saveHit(CPlayer* pVictim, int weapon, int damage, int aiming);
void saveShot(int weapon);
void saveBPlant();
void saveBExplode();
void saveBDefusing();
void saveBDefused();
void restartStats(bool all = true);
inline bool IsBot(){
const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict);
return ( auth && !strcmp( auth , "BOT" ) );
}
inline bool IsAlive(){
return ((pEdict->v.deadflag==DEAD_NO)&&(pEdict->v.health>0));
}
};
// *****************************************************
// class Grenades
// *****************************************************
class Grenades
{
struct Obj
{
CPlayer* player;
edict_t* grenade;
float time;
int type;
Obj* next;
Obj* prev;
} *head;
public:
Grenades() { head = 0; }
~Grenades() { clear(); }
void put( edict_t* grenade, float time, int type, CPlayer* player );
bool find( edict_t* enemy, CPlayer** p, int* type );
void clear();
};
#endif // CMISC_H

308
dlls/csstats2/csstats/CRank.cpp Executable file
View File

@ -0,0 +1,308 @@
#include "amxxmodule.h"
#include "CRank.h"
#include "rank.h"
// *****************************************************
// class Stats
// *****************************************************
Stats::Stats(){
hits = shots = damage = hs = tks = kills = deaths = bDefusions = bDefused = bPlants = bExplosions = 0;
memset( bodyHits , 0 ,sizeof( bodyHits ) );
}
void Stats::commit(Stats* a){
hits += a->hits;
shots += a->shots;
damage += a->damage;
hs += a->hs;
tks += a->tks;
kills += a->kills;
deaths += a->deaths;
bDefusions += a->bDefusions;
bDefused += a->bDefused;
bPlants += a->bPlants;
bExplosions += a->bExplosions;
for(int i = 1; i < 8; ++i)
bodyHits[i] += a->bodyHits[i];
}
// *****************************************************
// class RankSystem
// *****************************************************
RankSystem::RankStats::RankStats( const char* uu, const char* nn, RankSystem* pp ) {
name = 0;
namelen = 0;
unique = 0;
uniquelen = 0;
score = 0;
parent = pp;
id = ++parent->rankNum;
next = prev = 0;
setName( nn );
setUnique( uu );
}
RankSystem::RankStats::~RankStats() {
delete[] name;
delete[] unique;
--parent->rankNum;
}
void RankSystem::RankStats::setName( const char* nn ) {
delete[] name;
namelen = strlen(nn) + 1;
name = new char[namelen];
if ( name )
strcpy( name , nn );
else
namelen = 0;
}
void RankSystem::RankStats::setUnique( const char* nn ) {
delete[] unique;
uniquelen = strlen(nn) + 1;
unique = new char[uniquelen];
if ( unique )
strcpy( unique , nn );
else
uniquelen = 0;
}
RankSystem::RankSystem() {
head = 0;
tail = 0;
rankNum = 0;
calc.code = 0;
}
RankSystem::~RankSystem() {
clear();
}
void RankSystem::put_before( RankStats* a, RankStats* ptr ){
a->next = ptr;
if ( ptr ){
a->prev = ptr->prev;
ptr->prev = a;
}
else{
a->prev = head;
head = a;
}
if ( a->prev ) a->prev->next = a;
else tail = a;
}
void RankSystem::put_after( RankStats* a, RankStats* ptr ) {
a->prev = ptr;
if ( ptr ){
a->next = ptr->next;
ptr->next = a;
}
else{
a->next = tail;
tail = a;
}
if ( a->next ) a->next->prev = a;
else head = a;
}
void RankSystem::unlink( RankStats* ptr ){
if (ptr->prev) ptr->prev->next = ptr->next;
else tail = ptr->next;
if (ptr->next) ptr->next->prev = ptr->prev;
else head = ptr->prev;
}
void RankSystem::clear(){
while( tail ){
head = tail->next;
delete tail;
tail = head;
}
}
bool RankSystem::loadCalc(const char* filename, char* error)
{
if ((MF_LoadAmxScript(&calc.amx,&calc.code,filename,error,0)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr1, &calc.physAddr1)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr2, &calc.physAddr2)!=AMX_ERR_NONE)||
(MF_AmxFindPublic(&calc.amx,"get_score",&calc.func)!=AMX_ERR_NONE)){
LOG_CONSOLE( PLID, "Couldn't load plugin (file \"%s\")",filename);
MF_UnloadAmxScript(&calc.amx, &calc.code);
return false;
}
return true;
}
void RankSystem::unloadCalc()
{
MF_UnloadAmxScript(&calc.amx , &calc.code);
}
RankSystem::RankStats* RankSystem::findEntryInRank(const char* unique, const char* name )
{
RankStats* a = head;
while ( a )
{
if ( strcmp( a->getUnique() ,unique ) == 0 )
return a;
a = a->prev;
}
a = new RankStats( unique ,name,this );
if ( a == 0 ) return 0;
put_after( a , 0 );
return a;
}
void RankSystem::updatePos( RankStats* rr , Stats* s )
{
rr->addStats( s );
if ( calc.code ) {
calc.physAddr1[0] = rr->kills;
calc.physAddr1[1] = rr->deaths;
calc.physAddr1[2] = rr->hs;
calc.physAddr1[3] = rr->tks;
calc.physAddr1[4] = rr->shots;
calc.physAddr1[5] = rr->hits;
calc.physAddr1[6] = rr->damage;
calc.physAddr1[7] = rr->bDefusions;
calc.physAddr1[8] = rr->bDefused;
calc.physAddr1[9] = rr->bPlants;
calc.physAddr1[10] = rr->bExplosions;
for(int i = 1; i < 8; ++i)
calc.physAddr2[i] = rr->bodyHits[i];
cell result = 0;
int err;
if ((err = MF_AmxExec(&calc.amx,&result, calc.func ,2,calc.amxAddr1,calc.amxAddr2 )) != AMX_ERR_NONE)
LOG_CONSOLE( PLID, "Run time error %d on line %ld (plugin \"%s\")", err,calc.amx.curline,LOCALINFO("csstats_score"));
rr->score = result;
}
else rr->score = rr->kills - rr->deaths;
RankStats* aa = rr->next;
while ( aa && (aa->score <= rr->score) ) { // try to nominate
rr->goUp();
aa->goDown();
aa = aa->next; // go to next rank
}
if ( aa != rr->next )
{
unlink( rr );
put_before( rr, aa );
}
else
{
aa = rr->prev;
while ( aa && (aa->score > rr->score) ) { // go down
rr->goDown();
aa->goUp();
aa = aa->prev; // go to prev rank
}
if ( aa != rr->prev ){
unlink( rr );
put_after( rr, aa );
}
}
}
void RankSystem::loadRank( const char* filename )
{
FILE *bfp = fopen( filename , "rb" );
if ( !bfp ) return;
short int i = 0;
fread(&i, 1 , sizeof(short int) , bfp);
if (i == RANK_VERSION)
{
Stats d;
char unique[64], name[64];
fread(&i , 1, sizeof(short int), bfp);
while( i )
{
fread(name , i,sizeof(char) , bfp);
fread(&i , 1, sizeof(short int), bfp);
fread(unique , i,sizeof(char) , bfp);
fread(&d.tks, 1,sizeof(int), bfp);
fread(&d.damage, 1,sizeof(int), bfp);
fread(&d.deaths, 1,sizeof(int), bfp);
fread(&d.kills, 1,sizeof(int), bfp);
fread(&d.shots, 1,sizeof(int), bfp);
fread(&d.hits, 1,sizeof(int), bfp);
fread(&d.hs, 1,sizeof(int), bfp);
fread(&d.bDefusions, 1,sizeof(int), bfp);
fread(&d.bDefused, 1,sizeof(int), bfp);
fread(&d.bPlants, 1,sizeof(int), bfp);
fread(&d.bExplosions, 1,sizeof(int), bfp);
fread(d.bodyHits, 1,sizeof(d.bodyHits), bfp);
fread(&i , 1, sizeof(short int), bfp);
RankSystem::RankStats* a = findEntryInRank( unique , name );
if ( a ) a->updatePosition( &d );
}
}
fclose(bfp);
}
void RankSystem::saveRank( const char* filename )
{
FILE *bfp = fopen(filename, "wb");
if ( !bfp ) return;
short int i = RANK_VERSION;
fwrite(&i, 1, sizeof(short int) , bfp);
RankSystem::iterator a = front();
while ( a )
{
if ( (*a).score != (1<<31) ) // score must be different than mincell
{
fwrite( &(*a).namelen , 1, sizeof(short int), bfp);
fwrite( (*a).name , (*a).namelen , sizeof(char) , bfp);
fwrite( &(*a).uniquelen , 1, sizeof(short int), bfp);
fwrite( (*a).unique , (*a).uniquelen , sizeof(char) , bfp);
fwrite( &(*a).tks, 1, sizeof(int), bfp);
fwrite( &(*a).damage, 1, sizeof(int), bfp);
fwrite( &(*a).deaths, 1, sizeof(int), bfp);
fwrite( &(*a).kills, 1, sizeof(int), bfp);
fwrite( &(*a).shots, 1, sizeof(int), bfp);
fwrite( &(*a).hits, 1, sizeof(int), bfp);
fwrite( &(*a).hs, 1, sizeof(int), bfp);
fwrite( &(*a).bDefusions, 1, sizeof(int), bfp);
fwrite( &(*a).bDefused, 1, sizeof(int), bfp);
fwrite( &(*a).bPlants, 1, sizeof(int), bfp);
fwrite( &(*a).bExplosions, 1, sizeof(int), bfp);
fwrite( (*a).bodyHits, 1, sizeof((*a).bodyHits), bfp);
}
--a;
}
i = 0;
fwrite( &i , 1, sizeof(short int), bfp); // null terminator
fclose(bfp);
}

122
dlls/csstats2/csstats/CRank.h Executable file
View File

@ -0,0 +1,122 @@
#ifndef CRANK_H
#define CRANK_H
#define RANK_VERSION 11
#include "amxxmodule.h"
// *****************************************************
// class Stats
// *****************************************************
struct Stats {
int hits;
int shots;
int damage;
int hs;
int tks;
int kills;
int deaths;
int bodyHits[9]; ////////////////////
// SiDLuke start
int bPlants;
int bExplosions;
int bDefusions;
int bDefused;
// SiDLuke end :D
Stats();
void commit(Stats* a);
};
// *****************************************************
// class RankSystem
// *****************************************************
class RankSystem
{
public:
class RankStats;
friend class RankStats;
class iterator;
class RankStats : public Stats {
friend class RankSystem;
friend class iterator;
RankSystem* parent;
RankStats* next;
RankStats* prev;
char* unique;
short int uniquelen;
char* name;
short int namelen;
int score;
int id;
RankStats( const char* uu, const char* nn, RankSystem* pp );
~RankStats();
void setUnique( const char* nn );
inline void goDown() {++id;}
inline void goUp() {--id;}
inline void addStats(Stats* a) { commit( a ); }
public:
void setName( const char* nn );
inline const char* getName() const { return name ? name : ""; }
inline const char* getUnique() const { return unique ? unique : ""; }
inline int getPosition() const { return id; }
inline void updatePosition( Stats* points ) {
parent->updatePos( this , points );
}
};
private:
RankStats* head;
RankStats* tail;
int rankNum;
struct scoreCalc{
AMX amx;
void* code;
int func;
cell amxAddr1;
cell amxAddr2;
cell *physAddr1;
cell *physAddr2;
} calc;
void put_before( RankStats* a, RankStats* ptr );
void put_after( RankStats* a, RankStats* ptr );
void unlink( RankStats* ptr );
void updatePos( RankStats* r , Stats* s );
public:
RankSystem();
~RankSystem();
void saveRank( const char* filename );
void loadRank( const char* filename );
RankStats* findEntryInRank(const char* unique, const char* name );
bool loadCalc(const char* filename, char* error);
inline int getRankNum( ) const { return rankNum; }
void clear();
void unloadCalc();
class iterator {
RankStats* ptr;
public:
iterator(RankStats* a): ptr(a){}
inline iterator& operator--() { ptr = ptr->prev; return *this;}
inline iterator& operator++() { ptr = ptr->next; return *this; }
inline RankStats& operator*() { return *ptr;}
operator bool () { return (ptr != 0); }
};
inline iterator front() { return iterator(head); }
inline iterator begin() { return iterator(tail); }
};
#endif

102
dlls/csstats2/csstats/Makefile Executable file
View File

@ -0,0 +1,102 @@
MODNAME = csstats_amxx
SRCFILES = amxxmodule.cpp CMisc.cpp CRank.cpp meta_api.cpp rank.cpp usermsg.cpp
EXTRA_LIBS_LINUX =
EXTRA_LIBS_WIN32 =
EXTRA_LIBDIRS_LINUX = -Lextra/lib_linux
EXTRA_LIBDIRS_WIN32 = -Lextra/lib_win32
EXTRA_INCLUDEDIRS = -Iextra/include -I../amx
EXTRA_FLAGS = -Dstrcmpi=strcasecmp
AMXDIR=../amx
SDKSRC=../sdk
METADIR=../metamod
OBJDIR_LINUX=obj.linux
OBJDIR_WIN32=obj.win32
SRCDIR=.
ifdef windir
OS=WIN32
else
OS=LINUX
endif
CC_LINUX=gcc
ifeq "$(OS)" "WIN32"
CC_WIN32=gcc
LD_WINDLL=dllwrap
DEFAULT=win32
CLEAN=clean_win32
else
CC_WIN32=/usr/local/cross-tools/i386-mingw32msvc/bin/gcc
LD_WINDLL=/usr/local/cross-tools/bin/i386-mingw32msvc-dllwrap
DEFAULT=linux win32
CLEAN=clean_both
endif
LIBFILE_LINUX = $(MODNAME)_i386.so
LIBFILE_WIN32 = $(MODNAME).dll
TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX)
TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32)
FILES_ALL = *.cpp *.h [A-Z]* *.rc
ifeq "$(OS)" "LINUX"
ASRCFILES := $(shell ls -t $(SRCFILES))
else
ASRCFILES := $(shell dir /b)
endif
OBJ_LINUX := $(SRCFILES:%.cpp=$(OBJDIR_LINUX)/%.o)
OBJ_WIN32 := $(SRCFILES:%.cpp=$(OBJDIR_WIN32)/%.o)
CCOPT = -march=i586 -O6 -ffast-math -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
-malign-jumps=2 -malign-functions=2 -s -DNDEBUG
INCLUDEDIRS=-I../curl/include -I$(SRCDIR) -I$(AMXDIR) -I$(METADIR) -I$(SDKSRC)/engine -I$(SDKSRC)/common -I$(SDKSRC)/dlls -I$(SDKSRC) $(EXTRA_INCLUDEDIRS)
CFLAGS=-Wall -Wno-unknown-pragmas
ODEF = -DOPT_TYPE=\"optimized\"
CFLAGS:=$(CCOPT) $(CFLAGS) $(ODEF) $(EXTRA_FLAGS)
DO_CC_LINUX=$(CC_LINUX) $(CFLAGS) -fPIC $(INCLUDEDIRS) -o $@ -c $<
DO_CC_WIN32=$(CC_WIN32) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $<
LINK_LINUX=$(CC_LINUX) $(CFLAGS) -shared -ldl -lm $(OBJ_LINUX) $(EXTRA_LIBDIRS_LINUX) $(EXTRA_LIBS_LINUX) -o $@
LINK_WIN32=$(LD_WINDLL) -mwindows --add-stdcall-alias $(OBJ_WIN32) $(EXTRA_LIBDIRS_WIN32) $(EXTRA_LIBS_WIN32) -o $@
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.cpp
$(DO_CC_LINUX)
$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.cpp
$(DO_CC_WIN32)
default: $(DEFAULT)
$(TARGET_LINUX): $(OBJDIR_LINUX) $(OBJ_LINUX)
$(LINK_LINUX)
$(TARGET_WIN32): $(OBJDIR_WIN32) $(OBJ_WIN32)
$(LINK_WIN32)
$(OBJDIR_LINUX):
mkdir $@
$(OBJDIR_WIN32):
mkdir $@
win32: $(TARGET_WIN32)
linux: $(TARGET_LINUX)
clean: $(CLEAN)
clean_both:
-rm -f $(OBJDIR_LINUX)/*
-rm -f $(OBJDIR_WIN32)/*
clean_win32:
del /q $(OBJDIR_WIN32)

178
dlls/csstats2/csstats/Makefile.pl Executable file
View File

@ -0,0 +1,178 @@
#!/usr/bin/perl
#(C)2004 AMX Mod X Development Team
# by David "BAILOPAN" Anderson
# output will occur in bin.x.proc
# where x is debug or opt and proc is ix86 or amd64
# You must use this script from the project src dir
#options =
# debug - enable gdb debugging
# amd64 - compile for AMD64
# proc=ix86 - assumed not amd64
# clean - clean the specifications above
$PROJECT = "csstats_amxx";
$sdk = "../../../hlsdk/SourceCode";
$mm = "../../../metamod/metamod";
$gccf = "gcc";
@CPP_SOURCE_FILES = ("amxxmodule.cpp", "CMisc.cpp", "usermsg.cpp", "meta_api.cpp", "rank.cpp", "CRank.cpp");
@C_SOURCE_FILES = ();
my %OPTIONS, %OPT;
$OPT{"debug"} = "-g -ggdb";
$OPT{"opt"} = "-O2 -ffast-math -funroll-loops -fomit-frame-pointer -s -DNDEBUG -Wall -Wno-unknown-pragmas -DOPT_TYPE=\"optimized\" -fno-exceptions -fno-rtti";
$OPTIONS{"include"} = "-I$sdk -I. -I$mm -I$sdk/engine -I$sdk/common -I$sdk/pm_shared -I$sdk/dlls";
while ($cmd = shift)
{
if ($cmd =~ /amd64/) {
$OPTIONS{"amd64"} = 1;
} elsif ($cmd =~ /debug/) {
$OPTIONS{"debug"} = 1;
} elsif ($cmd =~ /proc=i(\d)86/) {
$proc = $1;
if ($OPTIONS{"amd64"})
{
die "You cannot compile for i".$proc."86 and AMD64.\n";
} else {
$OPTIONS{"proc"} = "i".$proc."86";
}
} elsif ($cmd =~ /clean/) {
$OPTIONS{"clean"} = 1;
}
}
$gcc = `$gccf --version`;
if ($gcc =~ /2\.9/)
{
$OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2";
} else {
$OPT{"opt"} .= " -falign-loops=2 -falign-jumps=2 -falign-functions=2";
}
if ($OPTIONS{"debug"})
{
$cflags = $OPT{"debug"};
} else {
if (!$OPTIONS{"amd64"})
{
$proc = $OPTIONS{"proc"};
if (!$proc)
{
$proc = 3;
}
$cflags = "-march=i".$proc."86 ".$OPT{"opt"};
} else {
$cflags = $OPT{"opt"};
}
}
if ($OPTIONS{"amd64"})
{
$cflags .= " -m64 -DHAVE_I64 -DSMALL_CELL_SIZE=64 $cflags";
}
if ($OPTIONS{"debug"})
{
$outdir = "bin.debug";
} else {
$outdir = "bin.opt";
}
if ($OPTIONS{"amd64"})
{
$outdir .= ".amd64";
$bin = $PROJECT."_amd64.so";
} else {
$proc = $OPTIONS{"proc"};
if ($proc)
{
$outdir .= ".i".$proc."86";
$bin = $PROJECT."_i".$proc."86.so";
} else {
$outdir .= ".i386";
$bin = $PROJECT."_i386.so";
}
}
unlink("$outdir/$bin");
if ($OPTIONS{"clean"})
{
`rm $outdir/*.o`;
die("Project cleaned.\n");
}
#create the dirs
#build link list
my @LINK;
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $CPP_SOURCE_FILES[$i];
$file =~ s/\.cpp/\.o/;
push(@LINK, $outdir."/".$file);
}
for ($i=0; $i<=$#C_SOURCE_FILES; $i++)
{
$file = $C_SOURCE_FILES[$i];
$file =~ s/\.c/\.o/;
push(@LINK, $outdir."/".$file);
}
if (!(-d $outdir))
{
mkdir($outdir);
}
$inc = $OPTIONS{"include"};
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $CPP_SOURCE_FILES[$i];
$ofile = $file;
$ofile =~ s/\.cpp/\.o/;
$ofile = "$outdir/$ofile";
$gcc = "$gccf $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
if (-e $ofile)
{
$file_time = (stat($file))[9];
$ofile_time = (stat($ofile))[9];
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $C_SOURCE_FILES[$i];
$ofile = $file;
$ofile =~ s/\.c/\.o/;
$ofile = "$outdir/$ofile";
$gcc = "cc $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
if (-e $ofile)
{
$file_time = (stat($file))[9];
$ofile_time = (stat($ofile))[9];
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
$gcc = "$gccf $cflags -shared -ldl -lm @LINK -o $outdir/$bin";
print "$gcc\n";
`$gcc`;

File diff suppressed because it is too large Load Diff

2234
dlls/csstats2/csstats/amxxmodule.h Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
@echo off
PATH=C:\gcc\bin;%PATH%
make
pause

View File

@ -0,0 +1,308 @@
#include "amxxmodule.h"
#include "rank.h"
funEventCall modMsgsEnd[MAX_REG_MSGS];
funEventCall modMsgs[MAX_REG_MSGS];
void (*function)(void*);
void (*endfunction)(void*);
CPlayer players[33];
CPlayer* mPlayer;
int mPlayerIndex;
int mState;
RankSystem g_rank;
Grenades g_grenades;
bool rankBots;
int gmsgCurWeapon;
int gmsgDeathMsg;
int gmsgDamage;
int gmsgWeaponList;
int gmsgResetHUD;
int gmsgAmmoX;
int gmsgScoreInfo;
int gmsgAmmoPickup;
int gmsgSendAudio;
int gmsgTextMsg;
int gmsgBarTime;
cvar_t init_csstats_maxsize ={"csstats_maxsize","3500", 0 , 3500.0 };
cvar_t init_csstats_reset ={"csstats_reset","0"};
cvar_t init_csstats_rank ={"csstats_rank","0"};
cvar_t *csstats_maxsize;
cvar_t *csstats_reset;
cvar_t *csstats_rank;
cvar_t* csstats_rankbots;
cvar_t* csstats_pause;
cvar_t init_csstats_rankbots ={"csstats_rankbots","1"};
cvar_t init_csstats_pause = {"csstats_pause","0"};
struct sUserMsg {
const char* name;
int* id;
funEventCall func;
bool endmsg;
} g_user_msg[] = {
{ "CurWeapon" , &gmsgCurWeapon , Client_CurWeapon, false },
{ "Damage" , &gmsgDamage,Client_Damage, false },
{ "WeaponList" , &gmsgWeaponList, Client_WeaponList, false },
{ "ResetHUD" , &gmsgResetHUD,Client_ResetHUD, true },
{ "AmmoX" , &gmsgAmmoX, Client_AmmoX , false },
{ "ScoreInfo" , &gmsgScoreInfo, Client_ScoreInfo, false },
{ "AmmoPickup" , &gmsgAmmoPickup, Client_AmmoPickup , false },
{ "SendAudio" , &gmsgSendAudio , Client_SendAudio , false },
{ "TextMsg" , &gmsgTextMsg , Client_TextMsg , false },
{ "BarTime" , &gmsgBarTime , Client_BarTime , false },
{ 0 , 0,0,false }
};
int RegUserMsg_Post(const char *pszName, int iSize)
{
for (int i = 0; g_user_msg[ i ].name; ++i )
{
if ( !*g_user_msg[i].id && strcmp( g_user_msg[ i ].name , pszName ) == 0 )
{
int id = META_RESULT_ORIG_RET( int );
*g_user_msg[ i ].id = id;
if ( g_user_msg[ i ].endmsg )
modMsgsEnd[ id ] = g_user_msg[ i ].func;
else
modMsgs[ id ] = g_user_msg[ i ].func;
//break;
}
}
RETURN_META_VALUE(MRES_IGNORED, 0);
}
const char* get_localinfo( const char* name , const char* def = 0 )
{
const char* b = LOCALINFO( (char*)name );
if (((b==0)||(*b==0)) && def )
SET_LOCALINFO((char*)name,(char*)(b = def) );
return b;
}
void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){
rankBots = (int)csstats_rankbots->value ? true:false;
for( int i = 1; i <= gpGlobals->maxClients; ++i)
GET_PLAYER_POINTER_I(i)->Init( i , pEdictList + i );
RETURN_META(MRES_IGNORED);
}
void PlayerPreThink_Post( edict_t *pEntity ) {
if ( !isModuleActive() )
return;
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time ){
if ( !ignoreBots(pEntity) ){
pPlayer->clearStats = 0.0f;
if (pPlayer->rank)
pPlayer->rank->updatePosition( &pPlayer->life );
pPlayer->restartStats(false);
}
}
RETURN_META(MRES_IGNORED);
}
void ServerDeactivate() {
int i;
for( i = 1;i<=gpGlobals->maxClients; ++i){
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->rank) pPlayer->Disconnect();
}
if ( (g_rank.getRankNum() >= (int)csstats_maxsize->value) || ((int)csstats_reset->value == 1 ) ) {
CVAR_SET_FLOAT("csstats_reset",0.0);
g_rank.clear(); // clear before save to file
}
g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("csstats")) );
RETURN_META(MRES_IGNORED);
}
BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ){
GET_PLAYER_POINTER(pEntity)->Connect(pszAddress);
RETURN_META_VALUE(MRES_IGNORED, TRUE);
}
void ClientDisconnect( edict_t *pEntity ) {
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if (pPlayer->rank) pPlayer->Disconnect();
RETURN_META(MRES_IGNORED);
}
void ClientPutInServer_Post( edict_t *pEntity ) {
GET_PLAYER_POINTER(pEntity)->PutInServer();
RETURN_META(MRES_IGNORED);
}
void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) {
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
const char* name = INFOKEY_VALUE(infobuffer,"name");
const char* oldname = STRING(pEntity->v.netname);
if ( pPlayer->rank ){
if ( strcmp(oldname,name) != 0 ) {
if ((int)csstats_rank->value == 0)
pPlayer->rank = g_rank.findEntryInRank( name, name );
else
pPlayer->rank->setName( name );
}
}
else if ( pPlayer->IsBot() ) {
pPlayer->Connect( "127.0.0.1" );
pPlayer->PutInServer();
}
RETURN_META(MRES_IGNORED);
}
void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {
if (ed){
mPlayerIndex = ENTINDEX(ed);
mPlayer = GET_PLAYER_POINTER_I(mPlayerIndex);
} else {
mPlayerIndex = 0;
mPlayer = 0;
}
mState = 0;
if ( msg_type < 0 || msg_type >= MAX_REG_MSGS )
msg_type = 0;
function=modMsgs[msg_type];
endfunction=modMsgsEnd[msg_type];
RETURN_META(MRES_IGNORED);
}
void MessageEnd_Post(void) {
if (endfunction) (*endfunction)(NULL);
RETURN_META(MRES_IGNORED);
}
void WriteByte_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteChar_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteShort_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteLong_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteAngle_Post(float flValue) {
if (function) (*function)((void *)&flValue);
RETURN_META(MRES_IGNORED);
}
void WriteCoord_Post(float flValue) {
if (function) (*function)((void *)&flValue);
RETURN_META(MRES_IGNORED);
}
void WriteString_Post(const char *sz) {
if (function) (*function)((void *)sz);
RETURN_META(MRES_IGNORED);
}
void WriteEntity_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void SetModel_Post(edict_t *e, const char *m){
if ( !isModuleActive() )
return;
if ( e->v.owner && m[7]=='w' && m[8]=='_' ){
int w_id = 0;
CPlayer *pPlayer = GET_PLAYER_POINTER(e->v.owner);
switch(m[9]){
case 'h':
g_grenades.put(e, 1.75, CSW_HEGRENADE, pPlayer);
pPlayer->saveShot(CSW_HEGRENADE);
break;
}
}
RETURN_META(MRES_IGNORED);
}
void EmitSound_Post(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch) {
if (sample[0]=='w'&&sample[1]=='e'&&sample[8]=='k'&&sample[9]=='n'&&sample[14]!='d'){
CPlayer*pPlayer = GET_PLAYER_POINTER(entity);
pPlayer->saveShot(pPlayer->current);
}
RETURN_META(MRES_IGNORED);
}
void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr) {
if (ptr->pHit&&(ptr->pHit->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&&
e&&(e->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&&ptr->iHitgroup)
GET_PLAYER_POINTER(e)->aiming = ptr->iHitgroup;
RETURN_META(MRES_IGNORED);
}
void OnMetaAttach() {
CVAR_REGISTER (&init_csstats_maxsize);
CVAR_REGISTER (&init_csstats_reset);
CVAR_REGISTER (&init_csstats_rank);
csstats_maxsize=CVAR_GET_POINTER(init_csstats_maxsize.name);
csstats_reset=CVAR_GET_POINTER(init_csstats_reset.name);
csstats_rank=CVAR_GET_POINTER(init_csstats_rank.name);
CVAR_REGISTER (&init_csstats_rankbots);
CVAR_REGISTER (&init_csstats_pause);
csstats_rankbots = CVAR_GET_POINTER(init_csstats_rankbots.name);
csstats_pause = CVAR_GET_POINTER(init_csstats_pause.name);
}
void OnAmxxAttach(){
MF_AddNatives(stats_Natives);
const char* path = get_localinfo("csstats_score");
if ( path && *path )
{
char error[128];
g_rank.loadCalc( MF_BuildPathname("%s",path) , error );
}
if ( !g_rank.begin() )
{
g_rank.loadRank( MF_BuildPathname("%s",
get_localinfo("csstats") ) );
}
}
void OnAmxxDetach() {
g_grenades.clear();
g_rank.clear();
g_rank.unloadCalc();
}

View File

@ -0,0 +1,462 @@
// Configuration
#ifndef __MODULECONFIG_H__
#define __MODULECONFIG_H__
// Module info
#define MODULE_NAME "CSStats"
#define MODULE_VERSION "0.20"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "CSSTATS"
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
#define MODULE_RELOAD_ON_MAPCHANGE
#ifdef __DATE__
#define MODULE_DATE __DATE__
#else // __DATE__
#define MODULE_DATE "Unknown"
#endif // __DATE__
// metamod plugin?
#define USE_METAMOD
// - AMXX Init functions
// Also consider using FN_META_*
// AMXX query
//#define FN_AMXX_QUERY OnAmxxQuery
// AMXX attach
// Do native functions init here (MF_AddNatives)
#define FN_AMXX_ATTACH OnAmxxAttach
// AMXX dettach
#define FN_AMXX_DETACH OnAmxxDetach
// All plugins loaded
// Do forward functions init here (MF_RegisterForward)
// #define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
/**** METAMOD ****/
// If your module doesn't use metamod, you may close the file now :)
#ifdef USE_METAMOD
// ----
// Hook Functions
// Uncomment these to be called
// You can also change the function name
// - Metamod init functions
// Also consider using FN_AMXX_*
// Meta query
//#define FN_META_QUERY OnMetaQuery
// Meta attach
#define FN_META_ATTACH OnMetaAttach
// Meta dettach
//#define FN_META_DETACH OnMetaDetach
// (wd) are Will Day's notes
// - GetEntityAPI2 functions
// #define FN_GameDLLInit GameDLLInit /* pfnGameInit() */
// #define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */
// #define FN_DispatchThink DispatchThink /* pfnThink() */
// #define FN_DispatchUse DispatchUse /* pfnUse() */
// #define FN_DispatchTouch DispatchTouch /* pfnTouch() */
// #define FN_DispatchBlocked DispatchBlocked /* pfnBlocked() */
// #define FN_DispatchKeyValue DispatchKeyValue /* pfnKeyValue() */
// #define FN_DispatchSave DispatchSave /* pfnSave() */
// #define FN_DispatchRestore DispatchRestore /* pfnRestore() */
// #define FN_DispatchObjectCollsionBox DispatchObjectCollsionBox /* pfnSetAbsBox() */
// #define FN_SaveWriteFields SaveWriteFields /* pfnSaveWriteFields() */
// #define FN_SaveReadFields SaveReadFields /* pfnSaveReadFields() */
// #define FN_SaveGlobalState SaveGlobalState /* pfnSaveGlobalState() */
// #define FN_RestoreGlobalState RestoreGlobalState /* pfnRestoreGlobalState() */
// #define FN_ResetGlobalState ResetGlobalState /* pfnResetGlobalState() */
// #define FN_ClientConnect ClientConnect /* pfnClientConnect() (wd) Client has connected */
#define FN_ClientDisconnect ClientDisconnect /* pfnClientDisconnect() (wd) Player has left the game */
// #define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */
// #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
#define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
// #define FN_StartFrame StartFrame /* pfnStartFrame() */
// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */
// #define FN_ParmsChangeLevel ParmsChangeLevel /* pfnParmsChangeLevel() */
// #define FN_GetGameDescription GetGameDescription /* pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2" "Half-Life" */
// #define FN_PlayerCustomization PlayerCustomization /* pfnPlayerCustomization() Notifies .dll of new customization for player. */
// #define FN_SpectatorConnect SpectatorConnect /* pfnSpectatorConnect() Called when spectator joins server */
// #define FN_SpectatorDisconnect SpectatorDisconnect /* pfnSpectatorDisconnect() Called when spectator leaves the server */
// #define FN_SpectatorThink SpectatorThink /* pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t) */
// #define FN_Sys_Error Sys_Error /* pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2 */
// #define FN_PM_Move PM_Move /* pfnPM_Move() (wd) SDK2 */
// #define FN_PM_Init PM_Init /* pfnPM_Init() Server version of player movement initialization; (wd) SDK2 */
// #define FN_PM_FindTextureType PM_FindTextureType /* pfnPM_FindTextureType() (wd) SDK2 */
// #define FN_SetupVisibility SetupVisibility /* pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2 */
// #define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */
// #define FN_AddToFullPack AddToFullPack /* pfnAddToFullPack() (wd) SDK2 */
// #define FN_CreateBaseline CreateBaseline /* pfnCreateBaseline() Tweak entity baseline for network encoding allows setup of player baselines too.; (wd) SDK2 */
// #define FN_RegisterEncoders RegisterEncoders /* pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2 */
// #define FN_GetWeaponData GetWeaponData /* pfnGetWeaponData() (wd) SDK2 */
// #define FN_CmdStart CmdStart /* pfnCmdStart() (wd) SDK2 */
// #define FN_CmdEnd CmdEnd /* pfnCmdEnd() (wd) SDK2 */
// #define FN_ConnectionlessPacket ConnectionlessPacket /* pfnConnectionlessPacket() (wd) SDK2 */
// #define FN_GetHullBounds GetHullBounds /* pfnGetHullBounds() (wd) SDK2 */
// #define FN_CreateInstancedBaselines CreateInstancedBaselines /* pfnCreateInstancedBaselines() (wd) SDK2 */
// #define FN_InconsistentFile InconsistentFile /* pfnInconsistentFile() (wd) SDK2 */
// #define FN_AllowLagCompensation AllowLagCompensation /* pfnAllowLagCompensation() (wd) SDK2 */
// - GetEntityAPI2_Post functions
// #define FN_GameDLLInit_Post GameDLLInit_Post
// #define FN_DispatchSpawn_Post DispatchSpawn_Post
// #define FN_DispatchThink_Post DispatchThink_Post
// #define FN_DispatchUse_Post DispatchUse_Post
// #define FN_DispatchTouch_Post DispatchTouch_Post
// #define FN_DispatchBlocked_Post DispatchBlocked_Post
// #define FN_DispatchKeyValue_Post DispatchKeyValue_Post
// #define FN_DispatchSave_Post DispatchSave_Post
// #define FN_DispatchRestore_Post DispatchRestore_Post
// #define FN_DispatchObjectCollsionBox_Post DispatchObjectCollsionBox_Post
// #define FN_SaveWriteFields_Post SaveWriteFields_Post
// #define FN_SaveReadFields_Post SaveReadFields_Post
// #define FN_SaveGlobalState_Post SaveGlobalState_Post
// #define FN_RestoreGlobalState_Post RestoreGlobalState_Post
// #define FN_ResetGlobalState_Post ResetGlobalState_Post
#define FN_ClientConnect_Post ClientConnect_Post
// #define FN_ClientDisconnect_Post ClientDisconnect_Post
// #define FN_ClientKill_Post ClientKill_Post
#define FN_ClientPutInServer_Post ClientPutInServer_Post
// #define FN_ClientCommand_Post ClientCommand_Post
#define FN_ClientUserInfoChanged_Post ClientUserInfoChanged_Post
#define FN_ServerActivate_Post ServerActivate_Post
// #define FN_ServerDeactivate_Post ServerDeactivate_Post
#define FN_PlayerPreThink_Post PlayerPreThink_Post
// #define FN_PlayerPostThink_Post PlayerPostThink_Post
// #define FN_StartFrame_Post StartFrame_Post
// #define FN_ParmsNewLevel_Post ParmsNewLevel_Post
// #define FN_ParmsChangeLevel_Post ParmsChangeLevel_Post
// #define FN_GetGameDescription_Post GetGameDescription_Post
// #define FN_PlayerCustomization_Post PlayerCustomization_Post
// #define FN_SpectatorConnect_Post SpectatorConnect_Post
// #define FN_SpectatorDisconnect_Post SpectatorDisconnect_Post
// #define FN_SpectatorThink_Post SpectatorThink_Post
// #define FN_Sys_Error_Post Sys_Error_Post
// #define FN_PM_Move_Post PM_Move_Post
// #define FN_PM_Init_Post PM_Init_Post
// #define FN_PM_FindTextureType_Post PM_FindTextureType_Post
// #define FN_SetupVisibility_Post SetupVisibility_Post
// #define FN_UpdateClientData_Post UpdateClientData_Post
// #define FN_AddToFullPack_Post AddToFullPack_Post
// #define FN_CreateBaseline_Post CreateBaseline_Post
// #define FN_RegisterEncoders_Post RegisterEncoders_Post
// #define FN_GetWeaponData_Post GetWeaponData_Post
// #define FN_CmdStart_Post CmdStart_Post
// #define FN_CmdEnd_Post CmdEnd_Post
// #define FN_ConnectionlessPacket_Post ConnectionlessPacket_Post
// #define FN_GetHullBounds_Post GetHullBounds_Post
// #define FN_CreateInstancedBaselines_Post CreateInstancedBaselines_Post
// #define FN_InconsistentFile_Post InconsistentFile_Post
// #define FN_AllowLagCompensation_Post AllowLagCompensation_Post
// - GetEngineAPI functions
// #define FN_PrecacheModel PrecacheModel
// #define FN_PrecacheSound PrecacheSound
// #define FN_SetModel SetModel
// #define FN_ModelIndex ModelIndex
// #define FN_ModelFrames ModelFrames
// #define FN_SetSize SetSize
// #define FN_ChangeLevel ChangeLevel
// #define FN_GetSpawnParms GetSpawnParms
// #define FN_SaveSpawnParms SaveSpawnParms
// #define FN_VecToYaw VecToYaw
// #define FN_VecToAngles VecToAngles
// #define FN_MoveToOrigin MoveToOrigin
// #define FN_ChangeYaw ChangeYaw
// #define FN_ChangePitch ChangePitch
// #define FN_FindEntityByString FindEntityByString
// #define FN_GetEntityIllum GetEntityIllum
// #define FN_FindEntityInSphere FindEntityInSphere
// #define FN_FindClientInPVS FindClientInPVS
// #define FN_EntitiesInPVS EntitiesInPVS
// #define FN_MakeVectors MakeVectors
// #define FN_AngleVectors AngleVectors
// #define FN_CreateEntity CreateEntity
// #define FN_RemoveEntity RemoveEntity
// #define FN_CreateNamedEntity CreateNamedEntity
// #define FN_MakeStatic MakeStatic
// #define FN_EntIsOnFloor EntIsOnFloor
// #define FN_DropToFloor DropToFloor
// #define FN_WalkMove WalkMove
// #define FN_SetOrigin SetOrigin
// #define FN_EmitSound EmitSound
// #define FN_EmitAmbientSound EmitAmbientSound
// #define FN_TraceLine TraceLine
// #define FN_TraceToss TraceToss
// #define FN_TraceMonsterHull TraceMonsterHull
// #define FN_TraceHull TraceHull
// #define FN_TraceModel TraceModel
// #define FN_TraceTexture TraceTexture
// #define FN_TraceSphere TraceSphere
// #define FN_GetAimVector GetAimVector
// #define FN_ServerCommand ServerCommand
// #define FN_ServerExecute ServerExecute
// #define FN_engClientCommand engClientCommand
// #define FN_ParticleEffect ParticleEffect
// #define FN_LightStyle LightStyle
// #define FN_DecalIndex DecalIndex
// #define FN_PointContents PointContents
// #define FN_MessageBegin MessageBegin
// #define FN_MessageEnd MessageEnd
// #define FN_WriteByte WriteByte
// #define FN_WriteChar WriteChar
// #define FN_WriteShort WriteShort
// #define FN_WriteLong WriteLong
// #define FN_WriteAngle WriteAngle
// #define FN_WriteCoord WriteCoord
// #define FN_WriteString WriteString
// #define FN_WriteEntity WriteEntity
// #define FN_CVarRegister CVarRegister
// #define FN_CVarGetFloat CVarGetFloat
// #define FN_CVarGetString CVarGetString
// #define FN_CVarSetFloat CVarSetFloat
// #define FN_CVarSetString CVarSetString
// #define FN_AlertMessage AlertMessage
// #define FN_EngineFprintf EngineFprintf
// #define FN_PvAllocEntPrivateData PvAllocEntPrivateData
// #define FN_PvEntPrivateData PvEntPrivateData
// #define FN_FreeEntPrivateData FreeEntPrivateData
// #define FN_SzFromIndex SzFromIndex
// #define FN_AllocString AllocString
// #define FN_GetVarsOfEnt GetVarsOfEnt
// #define FN_PEntityOfEntOffset PEntityOfEntOffset
// #define FN_EntOffsetOfPEntity EntOffsetOfPEntity
// #define FN_IndexOfEdict IndexOfEdict
// #define FN_PEntityOfEntIndex PEntityOfEntIndex
// #define FN_FindEntityByVars FindEntityByVars
// #define FN_GetModelPtr GetModelPtr
// #define FN_RegUserMsg RegUserMsg
// #define FN_AnimationAutomove AnimationAutomove
// #define FN_GetBonePosition GetBonePosition
// #define FN_FunctionFromName FunctionFromName
// #define FN_NameForFunction NameForFunction
// #define FN_ClientPrintf ClientPrintf
// #define FN_ServerPrint ServerPrint
// #define FN_Cmd_Args Cmd_Args
// #define FN_Cmd_Argv Cmd_Argv
// #define FN_Cmd_Argc Cmd_Argc
// #define FN_GetAttachment GetAttachment
// #define FN_CRC32_Init CRC32_Init
// #define FN_CRC32_ProcessBuffer CRC32_ProcessBuffer
// #define FN_CRC32_ProcessByte CRC32_ProcessByte
// #define FN_CRC32_Final CRC32_Final
// #define FN_RandomLong RandomLong
// #define FN_RandomFloat RandomFloat
// #define FN_SetView SetView
// #define FN_Time Time
// #define FN_CrosshairAngle CrosshairAngle
// #define FN_LoadFileForMe LoadFileForMe
// #define FN_FreeFile FreeFile
// #define FN_EndSection EndSection
// #define FN_CompareFileTime CompareFileTime
// #define FN_GetGameDir GetGameDir
// #define FN_Cvar_RegisterVariable Cvar_RegisterVariable
// #define FN_FadeClientVolume FadeClientVolume
// #define FN_SetClientMaxspeed SetClientMaxspeed
// #define FN_CreateFakeClient CreateFakeClient
// #define FN_RunPlayerMove RunPlayerMove
// #define FN_NumberOfEntities NumberOfEntities
// #define FN_GetInfoKeyBuffer GetInfoKeyBuffer
// #define FN_InfoKeyValue InfoKeyValue
// #define FN_SetKeyValue SetKeyValue
// #define FN_SetClientKeyValue SetClientKeyValue
// #define FN_IsMapValid IsMapValid
// #define FN_StaticDecal StaticDecal
// #define FN_PrecacheGeneric PrecacheGeneric
// #define FN_GetPlayerUserId GetPlayerUserId
// #define FN_BuildSoundMsg BuildSoundMsg
// #define FN_IsDedicatedServer IsDedicatedServer
// #define FN_CVarGetPointer CVarGetPointer
// #define FN_GetPlayerWONId GetPlayerWONId
// #define FN_Info_RemoveKey Info_RemoveKey
// #define FN_GetPhysicsKeyValue GetPhysicsKeyValue
// #define FN_SetPhysicsKeyValue SetPhysicsKeyValue
// #define FN_GetPhysicsInfoString GetPhysicsInfoString
// #define FN_PrecacheEvent PrecacheEvent
// #define FN_PlaybackEvent PlaybackEvent
// #define FN_SetFatPVS SetFatPVS
// #define FN_SetFatPAS SetFatPAS
// #define FN_CheckVisibility CheckVisibility
// #define FN_DeltaSetField DeltaSetField
// #define FN_DeltaUnsetField DeltaUnsetField
// #define FN_DeltaAddEncoder DeltaAddEncoder
// #define FN_GetCurrentPlayer GetCurrentPlayer
// #define FN_CanSkipPlayer CanSkipPlayer
// #define FN_DeltaFindField DeltaFindField
// #define FN_DeltaSetFieldByIndex DeltaSetFieldByIndex
// #define FN_DeltaUnsetFieldByIndex DeltaUnsetFieldByIndex
// #define FN_SetGroupMask SetGroupMask
// #define FN_engCreateInstancedBaseline engCreateInstancedBaseline
// #define FN_Cvar_DirectSet Cvar_DirectSet
// #define FN_ForceUnmodified ForceUnmodified
// #define FN_GetPlayerStats GetPlayerStats
// #define FN_AddServerCommand AddServerCommand
// #define FN_Voice_GetClientListening Voice_GetClientListening
// #define FN_Voice_SetClientListening Voice_SetClientListening
// #define FN_GetPlayerAuthId GetPlayerAuthId
// - GetEngineAPI_Post functions
// #define FN_PrecacheModel_Post PrecacheModel_Post
// #define FN_PrecacheSound_Post PrecacheSound_Post
#define FN_SetModel_Post SetModel_Post
// #define FN_ModelIndex_Post ModelIndex_Post
// #define FN_ModelFrames_Post ModelFrames_Post
// #define FN_SetSize_Post SetSize_Post
// #define FN_ChangeLevel_Post ChangeLevel_Post
// #define FN_GetSpawnParms_Post GetSpawnParms_Post
// #define FN_SaveSpawnParms_Post SaveSpawnParms_Post
// #define FN_VecToYaw_Post VecToYaw_Post
// #define FN_VecToAngles_Post VecToAngles_Post
// #define FN_MoveToOrigin_Post MoveToOrigin_Post
// #define FN_ChangeYaw_Post ChangeYaw_Post
// #define FN_ChangePitch_Post ChangePitch_Post
// #define FN_FindEntityByString_Post FindEntityByString_Post
// #define FN_GetEntityIllum_Post GetEntityIllum_Post
// #define FN_FindEntityInSphere_Post FindEntityInSphere_Post
// #define FN_FindClientInPVS_Post FindClientInPVS_Post
// #define FN_EntitiesInPVS_Post EntitiesInPVS_Post
// #define FN_MakeVectors_Post MakeVectors_Post
// #define FN_AngleVectors_Post AngleVectors_Post
// #define FN_CreateEntity_Post CreateEntity_Post
// #define FN_RemoveEntity_Post RemoveEntity_Post
// #define FN_CreateNamedEntity_Post CreateNamedEntity_Post
// #define FN_MakeStatic_Post MakeStatic_Post
// #define FN_EntIsOnFloor_Post EntIsOnFloor_Post
// #define FN_DropToFloor_Post DropToFloor_Post
// #define FN_WalkMove_Post WalkMove_Post
// #define FN_SetOrigin_Post SetOrigin_Post
// #define FN_EmitSound_Post EmitSound_Post
// #define FN_EmitAmbientSound_Post EmitAmbientSound_Post
#define FN_TraceLine_Post TraceLine_Post
// #define FN_TraceToss_Post TraceToss_Post
// #define FN_TraceMonsterHull_Post TraceMonsterHull_Post
// #define FN_TraceHull_Post TraceHull_Post
// #define FN_TraceModel_Post TraceModel_Post
// #define FN_TraceTexture_Post TraceTexture_Post
// #define FN_TraceSphere_Post TraceSphere_Post
// #define FN_GetAimVector_Post GetAimVector_Post
// #define FN_ServerCommand_Post ServerCommand_Post
// #define FN_ServerExecute_Post ServerExecute_Post
// #define FN_engClientCommand_Post engClientCommand_Post
// #define FN_ParticleEffect_Post ParticleEffect_Post
// #define FN_LightStyle_Post LightStyle_Post
// #define FN_DecalIndex_Post DecalIndex_Post
// #define FN_PointContents_Post PointContents_Post
#define FN_MessageBegin_Post MessageBegin_Post
#define FN_MessageEnd_Post MessageEnd_Post
#define FN_WriteByte_Post WriteByte_Post
#define FN_WriteChar_Post WriteChar_Post
#define FN_WriteShort_Post WriteShort_Post
#define FN_WriteLong_Post WriteLong_Post
#define FN_WriteAngle_Post WriteAngle_Post
#define FN_WriteCoord_Post WriteCoord_Post
#define FN_WriteString_Post WriteString_Post
#define FN_WriteEntity_Post WriteEntity_Post
// #define FN_CVarRegister_Post CVarRegister_Post
// #define FN_CVarGetFloat_Post CVarGetFloat_Post
// #define FN_CVarGetString_Post CVarGetString_Post
// #define FN_CVarSetFloat_Post CVarSetFloat_Post
// #define FN_CVarSetString_Post CVarSetString_Post
// #define FN_AlertMessage_Post AlertMessage_Post
// #define FN_EngineFprintf_Post EngineFprintf_Post
// #define FN_PvAllocEntPrivateData_Post PvAllocEntPrivateData_Post
// #define FN_PvEntPrivateData_Post PvEntPrivateData_Post
// #define FN_FreeEntPrivateData_Post FreeEntPrivateData_Post
// #define FN_SzFromIndex_Post SzFromIndex_Post
// #define FN_AllocString_Post AllocString_Post
// #define FN_GetVarsOfEnt_Post GetVarsOfEnt_Post
// #define FN_PEntityOfEntOffset_Post PEntityOfEntOffset_Post
// #define FN_EntOffsetOfPEntity_Post EntOffsetOfPEntity_Post
// #define FN_IndexOfEdict_Post IndexOfEdict_Post
// #define FN_PEntityOfEntIndex_Post PEntityOfEntIndex_Post
// #define FN_FindEntityByVars_Post FindEntityByVars_Post
// #define FN_GetModelPtr_Post GetModelPtr_Post
#define FN_RegUserMsg_Post RegUserMsg_Post
// #define FN_AnimationAutomove_Post AnimationAutomove_Post
// #define FN_GetBonePosition_Post GetBonePosition_Post
// #define FN_FunctionFromName_Post FunctionFromName_Post
// #define FN_NameForFunction_Post NameForFunction_Post
// #define FN_ClientPrintf_Post ClientPrintf_Post
// #define FN_ServerPrint_Post ServerPrint_Post
// #define FN_Cmd_Args_Post Cmd_Args_Post
// #define FN_Cmd_Argv_Post Cmd_Argv_Post
// #define FN_Cmd_Argc_Post Cmd_Argc_Post
// #define FN_GetAttachment_Post GetAttachment_Post
// #define FN_CRC32_Init_Post CRC32_Init_Post
// #define FN_CRC32_ProcessBuffer_Post CRC32_ProcessBuffer_Post
// #define FN_CRC32_ProcessByte_Post CRC32_ProcessByte_Post
// #define FN_CRC32_Final_Post CRC32_Final_Post
// #define FN_RandomLong_Post RandomLong_Post
// #define FN_RandomFloat_Post RandomFloat_Post
// #define FN_SetView_Post SetView_Post
// #define FN_Time_Post Time_Post
// #define FN_CrosshairAngle_Post CrosshairAngle_Post
// #define FN_LoadFileForMe_Post LoadFileForMe_Post
// #define FN_FreeFile_Post FreeFile_Post
// #define FN_EndSection_Post EndSection_Post
// #define FN_CompareFileTime_Post CompareFileTime_Post
// #define FN_GetGameDir_Post GetGameDir_Post
// #define FN_Cvar_RegisterVariable_Post Cvar_RegisterVariable_Post
// #define FN_FadeClientVolume_Post FadeClientVolume_Post
// #define FN_SetClientMaxspeed_Post SetClientMaxspeed_Post
// #define FN_CreateFakeClient_Post CreateFakeClient_Post
// #define FN_RunPlayerMove_Post RunPlayerMove_Post
// #define FN_NumberOfEntities_Post NumberOfEntities_Post
// #define FN_GetInfoKeyBuffer_Post GetInfoKeyBuffer_Post
// #define FN_InfoKeyValue_Post InfoKeyValue_Post
// #define FN_SetKeyValue_Post SetKeyValue_Post
// #define FN_SetClientKeyValue_Post SetClientKeyValue_Post
// #define FN_IsMapValid_Post IsMapValid_Post
// #define FN_StaticDecal_Post StaticDecal_Post
// #define FN_PrecacheGeneric_Post PrecacheGeneric_Post
// #define FN_GetPlayerUserId_Post GetPlayerUserId_Post
// #define FN_BuildSoundMsg_Post BuildSoundMsg_Post
// #define FN_IsDedicatedServer_Post IsDedicatedServer_Post
// #define FN_CVarGetPointer_Post CVarGetPointer_Post
// #define FN_GetPlayerWONId_Post GetPlayerWONId_Post
// #define FN_Info_RemoveKey_Post Info_RemoveKey_Post
// #define FN_GetPhysicsKeyValue_Post GetPhysicsKeyValue_Post
// #define FN_SetPhysicsKeyValue_Post SetPhysicsKeyValue_Post
// #define FN_GetPhysicsInfoString_Post GetPhysicsInfoString_Post
// #define FN_PrecacheEvent_Post PrecacheEvent_Post
// #define FN_PlaybackEvent_Post PlaybackEvent_Post
// #define FN_SetFatPVS_Post SetFatPVS_Post
// #define FN_SetFatPAS_Post SetFatPAS_Post
// #define FN_CheckVisibility_Post CheckVisibility_Post
// #define FN_DeltaSetField_Post DeltaSetField_Post
// #define FN_DeltaUnsetField_Post DeltaUnsetField_Post
// #define FN_DeltaAddEncoder_Post DeltaAddEncoder_Post
// #define FN_GetCurrentPlayer_Post GetCurrentPlayer_Post
// #define FN_CanSkipPlayer_Post CanSkipPlayer_Post
// #define FN_DeltaFindField_Post DeltaFindField_Post
// #define FN_DeltaSetFieldByIndex_Post DeltaSetFieldByIndex_Post
// #define FN_DeltaUnsetFieldByIndex_Post DeltaUnsetFieldByIndex_Post
// #define FN_SetGroupMask_Post SetGroupMask_Post
// #define FN_engCreateInstancedBaseline_Post engCreateInstancedBaseline_Post
// #define FN_Cvar_DirectSet_Post Cvar_DirectSet_Post
// #define FN_ForceUnmodified_Post ForceUnmodified_Post
// #define FN_GetPlayerStats_Post GetPlayerStats_Post
// #define FN_AddServerCommand_Post AddServerCommand_Post
// #define FN_Voice_GetClientListening_Post Voice_GetClientListening_Post
// #define FN_Voice_SetClientListening_Post Voice_SetClientListening_Post
// #define FN_GetPlayerAuthId_Post GetPlayerAuthId_Post
// #define FN_OnFreeEntPrivateData OnFreeEntPrivateData
// #define FN_GameShutdown GameShutdown
// #define FN_ShouldCollide ShouldCollide
// #define FN_OnFreeEntPrivateData_Post OnFreeEntPrivateData_Post
// #define FN_GameShutdown_Post GameShutdown_Post
// #define FN_ShouldCollide_Post ShouldCollide_Post
#endif // USE_METAMOD
#endif // __MODULECONFIG_H__

View File

@ -0,0 +1,149 @@
# Microsoft Developer Studio Project File - Name="csstats" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=csstats - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "csstats.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "csstats.mak" CFG="csstats - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "csstats - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "csstats - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "csstats - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "release"
# PROP Intermediate_Dir "release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "csstats_EXPORTS" /YX /FD /c
# ADD CPP /nologo /Zp4 /MT /W3 /GX /O2 /I "..\..\metamod" /I "..\..\sdk\common" /I "..\..\sdk\engine" /I "..\..\sdk\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "csstats_EXPORTS" /D "JIT" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"release/csstats_amxx.dll"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "csstats - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "debug"
# PROP Intermediate_Dir "debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "csstats_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\metamod" /I "..\..\sdk\common" /I "..\..\sdk\engine" /I "..\..\sdk\dlls" /I "..\..\hlsdk\sourcecode\pm_shared" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "csstats_EXPORTS" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"debug/csstats_amxx.dll" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "csstats - Win32 Release"
# Name "csstats - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\amxxmodule.cpp
# End Source File
# Begin Source File
SOURCE=..\CMisc.cpp
# End Source File
# Begin Source File
SOURCE=..\CRank.cpp
# End Source File
# Begin Source File
SOURCE=..\meta_api.cpp
# End Source File
# Begin Source File
SOURCE=..\rank.cpp
# End Source File
# Begin Source File
SOURCE=..\usermsg.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\amxxmodule.h
# End Source File
# Begin Source File
SOURCE=..\CMisc.h
# End Source File
# Begin Source File
SOURCE=..\CRank.h
# End Source File
# Begin Source File
SOURCE=..\moduleconfig.h
# End Source File
# Begin Source File
SOURCE=..\rank.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -0,0 +1,311 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="csstats"
ProjectGUID="{0EEE36AA-5899-48EF-8BBD-DAA65D6F5D35}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\debug"
IntermediateDirectory=".\debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls,..\..\hlsdk\sourcecode\pm_shared"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;csstats_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\debug/csstats.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="debug/csstats_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\debug/csstats_amxx.pdb"
ImportLibrary=".\debug/csstats_amxx.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\debug/csstats.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\release"
IntermediateDirectory=".\release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;csstats_EXPORTS;JIT"
StringPooling="TRUE"
RuntimeLibrary="0"
StructMemberAlignment="3"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\release/csstats.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="release/csstats_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\release/csstats_amxx.pdb"
ImportLibrary=".\release/csstats_amxx.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\release/csstats.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="..\amxxmodule.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\CMisc.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\CRank.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\meta_api.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\rank.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\usermsg.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\amxxmodule.h">
</File>
<File
RelativePath="..\CMisc.h">
</File>
<File
RelativePath="..\CRank.h">
</File>
<File
RelativePath="..\moduleconfig.h">
</File>
<File
RelativePath="..\rank.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

293
dlls/csstats2/csstats/rank.cpp Executable file
View File

@ -0,0 +1,293 @@
#include "amxxmodule.h"
#include "rank.h"
static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int attacker = params[2];
if (attacker<0||attacker>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->attackers[attacker].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
CPlayer::PlayerWeapon* stats = &pPlayer->attackers[attacker];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
if (params[6] && attacker && stats->name )
MF_SetAmxString(amx,params[5],stats->name,params[6]);
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int victim = params[2];
if (victim<0||victim>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->victims[victim].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
CPlayer::PlayerWeapon* stats = &pPlayer->victims[victim];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
if (params[6] && victim && stats->name)
MF_SetAmxString(amx,params[5],stats->name,params[6]);
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param */ // DEC-Weapon (round) stats (end)
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2];
if (weapon<0||weapon>=MAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->weaponsRnd[weapon].shots){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
Stats* stats = &pPlayer->weaponsRnd[weapon];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2];
if (weapon<0||weapon>=MAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->weapons[weapon].shots){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
CPlayer::PlayerWeapon* stats = &pPlayer->weapons[weapon];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
GET_PLAYER_POINTER_I(index)->restartStats();
return 1;
}
static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->rank){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]);
cpStats[0] = pPlayer->life.kills;
cpStats[1] = pPlayer->life.deaths;
cpStats[2] = pPlayer->life.hs;
cpStats[3] = pPlayer->life.tks;
cpStats[4] = pPlayer->life.shots;
cpStats[5] = pPlayer->life.hits;
cpStats[6] = pPlayer->life.damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = pPlayer->life.bodyHits[i];
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]);
cpStats[0] = pPlayer->rank->kills;
cpStats[1] = pPlayer->rank->deaths;
cpStats[2] = pPlayer->rank->hs;
cpStats[3] = pPlayer->rank->tks;
cpStats[4] = pPlayer->rank->shots;
cpStats[5] = pPlayer->rank->hits;
cpStats[6] = pPlayer->rank->damage;
cpStats[7] = pPlayer->rank->getPosition();
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = pPlayer->rank->bodyHits[i];
return pPlayer->rank->getPosition();
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_stats2(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cpStats[0] = pPlayer->rank->bDefusions;
cpStats[1] = pPlayer->rank->bDefused;
cpStats[2] = pPlayer->rank->bPlants;
cpStats[3] = pPlayer->rank->bExplosions;
return pPlayer->rank->getPosition();
}
return 0;
}
static cell AMX_NATIVE_CALL get_stats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1] + 1;
for(RankSystem::iterator a = g_rank.front(); a ;--a){
if ((*a).getPosition() == index) {
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]);
cpStats[0] = (*a).kills;
cpStats[1] = (*a).deaths;
cpStats[2] = (*a).hs;
cpStats[3] = (*a).tks;
cpStats[4] = (*a).shots;
cpStats[5] = (*a).hits;
cpStats[6] = (*a).damage;
cpStats[7] = (*a).getPosition();
MF_SetAmxString(amx,params[4],(*a).getName(),params[5]);
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = (*a).bodyHits[i];
return --a ? index : 0;
}
}
return 0;
}
static cell AMX_NATIVE_CALL get_stats2(AMX *amx, cell *params) /* 3 param */
{
int index = params[1] + 1;
for(RankSystem::iterator a = g_rank.front(); a ;--a){
if ((*a).getPosition() == index) {
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cpStats[0] = (*a).bDefusions;
cpStats[1] = (*a).bDefused;
cpStats[2] = (*a).bPlants;
cpStats[3] = (*a).bExplosions;
return --a ? index : 0;
}
}
return 0;
}
static cell AMX_NATIVE_CALL get_statsnum(AMX *amx, cell *params)
{
return g_rank.getRankNum();
}
AMX_NATIVE_INFO stats_Natives[] = {
{ "get_stats", get_stats},
{ "get_stats2", get_stats2},
{ "get_statsnum", get_statsnum},
{ "get_user_astats", get_user_astats },
{ "get_user_rstats", get_user_rstats },
{ "get_user_lstats", get_user_rstats }, // for backward compatibility
{ "get_user_stats", get_user_stats },
{ "get_user_stats2", get_user_stats2 },
{ "get_user_vstats", get_user_vstats },
{ "get_user_wrstats", get_user_wrstats}, // DEC-Weapon(Round) Stats
{ "get_user_wstats", get_user_wstats},
{ "reset_user_wstats", reset_user_wstats },
///*******************
{ NULL, NULL }
};

84
dlls/csstats2/csstats/rank.h Executable file
View File

@ -0,0 +1,84 @@
#ifndef RANK_H
#define RANK_H
#include "amxxmodule.h"
#include "CMisc.h"
#include "CRank.h"
#define GET_PLAYER_POINTER(e) (&players[ENTINDEX(e)])
#define GET_PLAYER_POINTER_I(i) (&players[i])
#ifndef GETPLAYERAUTHID
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
#endif
extern AMX_NATIVE_INFO stats_Natives[];
struct weaponsVault {
char* name;
short int ammoSlot;
};
extern bool rankBots;
extern cvar_t* csstats_rankbots;
extern cvar_t* csstats_pause;
extern weaponsVault weaponData[MAX_WEAPONS];
typedef void (*funEventCall)(void*);
extern funEventCall modMsgsEnd[MAX_REG_MSGS];
extern funEventCall modMsgs[MAX_REG_MSGS];
extern void (*function)(void*);
extern void (*endfunction)(void*);
extern cvar_t *csstats_maxsize;
extern cvar_t* csstats_rank;
extern cvar_t* csstats_reset;
extern Grenades g_grenades;
extern RankSystem g_rank;
extern CPlayer players[33];
extern CPlayer* mPlayer;
extern int mPlayerIndex;
extern int mState;
extern int gmsgCurWeapon;
extern int gmsgDamage;
extern int gmsgWeaponList;
extern int gmsgResetHUD;
extern int gmsgAmmoX;
extern int gmsgScoreInfo;
extern int gmsgAmmoPickup;
extern int gmsgSendAudio;
extern int gmsgTextMsg;
extern int gmsgBarTime;
void Client_AmmoX(void*);
void Client_CurWeapon(void*);
void Client_Damage(void*);
void Client_WeaponList(void*);
void Client_AmmoPickup(void*);
void Client_ScoreInfo(void*);
void Client_ResetHUD(void*);
void Client_SendAudio(void*);
void Client_TextMsg(void*);
void Client_BarTime(void*);
bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL );
bool isModuleActive();
#endif // RANK_H

195
dlls/csstats2/csstats/usermsg.cpp Executable file
View File

@ -0,0 +1,195 @@
#include "amxxmodule.h"
#include "rank.h"
weaponsVault weaponData[MAX_WEAPONS];
int g_Planter;
int g_Defuser;
void Client_ResetHUD(void* mValue){
if ( mPlayer && mPlayer->IsAlive() )
mPlayer->clearStats = gpGlobals->time + 0.25f;
}
void Client_WeaponList(void* mValue){
static int wpnList;
static int iSlot;
static const char* wpnName;
switch (mState++) {
case 0:
wpnName = (const char*)mValue;
break;
case 1:
iSlot = *(int*)mValue;
break;
case 7:
int iId = *(int*)mValue;
if ( (iId < 0 || iId >= MAX_WEAPONS ) || ( wpnList & (1<<iId) ) )
break;
wpnList |= (1<<iId);
weaponData[iId].ammoSlot = iSlot;
char* wpnPrefix = strstr( wpnName,"weapon_");
if ( wpnPrefix )
{
weaponData[iId].name = wpnPrefix + 7;
if ( strcmp( weaponData[iId].name, "hegrenade" ) == 0 )
weaponData[iId].name += 2;
}
}
}
void Client_Damage(void* mValue){
static int bits;
static int damage;
static int TK;
static int weapon;
static int aim;
static bool ignore;
static CPlayer *pAttacker;
switch (mState++) {
case 1:
damage = *(int*)mValue;
break;
case 2:
bits = *(int*)mValue;
break;
case 3:
if ( ignore = (!mPlayer || !damage || !*(float*)mValue || bits) ) break;
edict_t *enemy;
enemy = mPlayer->pEdict->v.dmg_inflictor;
if ( FNullEnt( enemy ) )
break;
aim = 0;
weapon = 0;
pAttacker = NULL;
if (enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ) {
pAttacker = GET_PLAYER_POINTER(enemy);
aim = pAttacker->aiming;
weapon = pAttacker->current;
pAttacker->saveHit( mPlayer , weapon , damage, aim);
break;
}
if( g_grenades.find(enemy , &pAttacker , &weapon ) )
pAttacker->saveHit( mPlayer , weapon , damage, aim );
break;
case 4:
if ( ignore || mPlayer->IsAlive() )
break;
if ( !pAttacker )
pAttacker = mPlayer;
TK = 0;
if ( (mPlayer->teamId == pAttacker->teamId) && (mPlayer != pAttacker) )
TK = 1;
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TK);
break;
}
}
void Client_CurWeapon(void* mValue){
static int iState;
static int iId;
switch (mState++){
case 0:
iState = *(int*)mValue;
break;
case 1:
if (!iState) break;
iId = *(int*)mValue;
break;
case 2:
if (!mPlayer || !iState ) break;
int iClip = *(int*)mValue;
if ((iClip > -1) && (iClip < mPlayer->weapons[iId].clip))
mPlayer->saveShot(iId);
mPlayer->weapons[iId].clip = iClip;
mPlayer->current = iId;
}
}
void Client_AmmoX(void* mValue){
static int iAmmo;
switch (mState++){
case 0:
iAmmo = *(int*)mValue;
break;
case 1:
if (!mPlayer ) break;
for(int i = 1; i < MAX_WEAPONS ; ++i)
if (iAmmo == weaponData[i].ammoSlot)
mPlayer->weapons[i].ammo = *(int*)mValue;
}
}
void Client_AmmoPickup(void* mValue){
static int iSlot;
switch (mState++){
case 0:
iSlot = *(int*)mValue;
break;
case 1:
if (!mPlayer ) break;
for(int i = 1; i < MAX_WEAPONS ; ++i)
if (weaponData[i].ammoSlot == iSlot)
mPlayer->weapons[i].ammo += *(int*)mValue;
}
}
void Client_ScoreInfo(void* mValue){
static int index;
switch (mState++){
case 0:
index = *(int*)mValue;
break;
case 4:
if ( index > 0 && index <= gpGlobals->maxClients )
GET_PLAYER_POINTER_I( index )->teamId = *(int*)mValue;
}
}
void Client_SendAudio(void* mValue){
static const char* szText;
if ( mState == 1 ){
szText = (const char*)mValue;
if ( !mPlayer && szText[7]=='B' ) {
if ( szText[11]=='P' && g_Planter )
GET_PLAYER_POINTER_I(g_Planter)->saveBPlant();
else if ( szText[11]=='D' && g_Defuser )
GET_PLAYER_POINTER_I(g_Defuser)->saveBDefused();
}
}
mState++;
}
void Client_TextMsg(void* mValue){
static const char* szText;
if ( !mPlayer && mState==1 ){
szText = (const char*)mValue;
if ( szText[1]=='T' && szText[8]=='B' && g_Planter )
GET_PLAYER_POINTER_I(g_Planter)->saveBExplode();
}
mState++;
}
void Client_BarTime(void* mValue){
int iTime = *(int*)mValue;
if ( !iTime || !mPlayer->IsAlive() ) return;
if ( iTime == 3 ){
g_Planter = mPlayerIndex;
g_Defuser = 0;
}
else {
mPlayer->saveBDefusing();
g_Defuser = mPlayerIndex;
}
}

View File

@ -1,14 +1,14 @@
#(C)2004-2005 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson
HLSDK = ../../../hlsdk
MM_ROOT = ../../metamod/metamod
HLSDK = ../hlsdk/SourceCode
MM_ROOT = ../metamod/metamod
### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O2 -funroll-loops -s -pipe -fomit-frame-pointer -fno-strict-aliasing
OPT_FLAGS = -O2 -funroll-loops -s -pipe -fomit-frame-pointer
DEBUG_FLAGS = -g -ggdb3
CPP = gcc-4.1
CPP = gcc
NAME = cstrike
BIN_SUFFIX_32 = amxx_i386.so
@ -21,12 +21,6 @@ LINK =
INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \
-I$(MM_ROOT) -I$(HLSDK)/common
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
ifeq "$(GCC_VERSION)" "4"
OPT_FLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
endif
ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS = $(DEBUG_FLAGS)
@ -35,7 +29,7 @@ else
CFLAGS = $(OPT_FLAGS)
endif
CFLAGS += -DNDEBUG -fPIC -Wall -Wno-non-virtual-dtor -Werror -fno-exceptions -DHAVE_STDINT_H -fno-rtti -static-libgcc
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H -fno-rtti -static-libgcc
ifeq "$(AMD64)" "true"
BINARY = $(NAME)_$(BIN_SUFFIX_64)

View File

@ -2773,7 +2773,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_FindLibrary(NULL, LibType_Class);
MF_AddLibraries(NULL, LibType_Class, NULL);
MF_RemoveLibraries(NULL);
MF_OverrideNatives(NULL, "");
MF_OverrideNatives(NULL);
}
#endif

View File

@ -22,7 +22,7 @@
#ifndef __linux__
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __attribute__((visibility("default")))
#define DLLEXPORT
#define LINUX
#endif
@ -2179,10 +2179,8 @@ typedef void (*PFN_UNREG_AUTH_FUNC) (AUTHORIZEFUNC);
typedef int (*PFN_FINDLIBRARY) (const char * /*name*/, LibType /*type*/);
typedef size_t (*PFN_ADDLIBRARIES) (const char * /*name*/, LibType /*type*/, void * /*parent*/);
typedef size_t (*PFN_REMOVELIBRARIES) (void * /*parent*/);
typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/, const char * /*myname*/);
typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/);
typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/);
typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/);
typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -2255,8 +2253,6 @@ extern PFN_ADDLIBRARIES g_fn_AddLibraries;
extern PFN_REMOVELIBRARIES g_fn_RemoveLibraries;
extern PFN_OVERRIDENATIVES g_fn_OverrideNatives;
extern PFN_GETLOCALINFO g_fn_GetLocalInfo;
extern PFN_AMX_REREGISTER g_fn_AmxReRegister;
extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2324,10 +2320,8 @@ void MF_UnregAuthFunc (AUTHORIZEFUNC fn) { }
int MF_FindLibrary (const char *name, LibType type) { }
size_t MF_AddLibraries (const char *name, LibType type, void *parent) { }
size_t MF_RemoveLibraries (void *parent) { }
void MF_OverrideNatives (AMX_NATIVE_INFO *natives, const char *myname) { }
void MF_OverrideNatives (AMX_NATIVE_INFO *natives) { }
const char * MF_GetLocalInfo (const char *name, const char *def) { }
int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; }
void * MF_RegisterFunctionEx (void *pfn, const char *description) { }
#endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives
@ -2402,8 +2396,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RemoveLibraries g_fn_RemoveLibraries
#define MF_OverrideNatives g_fn_OverrideNatives
#define MF_GetLocalInfo g_fn_GetLocalInfo
#define MF_AmxReRegister g_fn_AmxReRegister
#define MF_RegisterFunctionEx g_fn_RegisterFunctionEx
#ifdef MEMORY_TEST
/*** Memory ***/

View File

@ -218,58 +218,40 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
bool draw_animation = true;
if ((params[0] / sizeof(cell)) >= 3)
{
draw_animation = params[3] ? true : false;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
switch (weapontype)
{
switch (weapontype) {
case CSW_M4A1:
if (params[2] == 1)
{
if (!(*silencemode & M4A1_SILENCED))
{ // want to silence - can't already be silenced
if (params[2] == 1) {
if (!(*silencemode & M4A1_SILENCED)) { // want to silence - can't already be silenced
*silencemode |= M4A1_SILENCED;
// If this weapon has an owner that is a player, play animation for that player.
if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
{
if (UTIL_IsPlayer(amx, pWeapon->v.owner))
pWeapon->v.owner->v.weaponanim = M4A1_ATTACHSILENCEANIM;
}
}
} else if (*silencemode & M4A1_SILENCED) { // want to unsilence - can't already be unsilenced
}
else if (*silencemode & M4A1_SILENCED) { // want to unsilence - can't already be unsilenced
*silencemode &= ~M4A1_SILENCED;
// If this weapon has an owner that is a player, play animation for that player.
if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
{
if (UTIL_IsPlayer(amx, pWeapon->v.owner))
pWeapon->v.owner->v.weaponanim = M4A1_DETACHSILENCEANIM;
}
}
break;
case CSW_USP:
if (params[2] == 1)
{
if (!(*silencemode & USP_SILENCED))
{ // want to silence - can't already be silenced
if (params[2] == 1) {
if (!(*silencemode & USP_SILENCED)) { // want to silence - can't already be silenced
*silencemode |= USP_SILENCED;
// If this weapon has an owner that is a player, play animation for that player.
if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
{
if (UTIL_IsPlayer(amx, pWeapon->v.owner))
pWeapon->v.owner->v.weaponanim = USP_ATTACHSILENCEANIM;
}
}
} else if (*silencemode & USP_SILENCED) { // want to unsilence - can't already be unsilenced
}
else if (*silencemode & USP_SILENCED) { // want to unsilence - can't already be unsilenced
*silencemode &= ~USP_SILENCED;
// If this weapon has an owner that is a player, play animation for that player.
if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
{
if (UTIL_IsPlayer(amx, pWeapon->v.owner))
pWeapon->v.owner->v.weaponanim = USP_DETACHSILENCEANIM;
}
}
break;
default:
@ -489,8 +471,8 @@ static cell AMX_NATIVE_CALL cs_set_user_vip(AMX *amx, cell *params) // cs_set_us
if (updateModel)
{
// Set a random CT model.
CS_Internal_Models CTmodels[5] = {CS_CT_URBAN, CS_CT_GSG9, CS_CT_GIGN, CS_CT_SAS, CZ_CT_SPETSNAZ};
CS_Internal_Models ct_model = CTmodels[RANDOM_LONG(0, 4)];
CS_Internal_Models CTmodels[4] = {CS_CT_URBAN, CS_CT_GSG9, CS_CT_GIGN, CS_CT_SAS};
CS_Internal_Models ct_model = CTmodels[RANDOM_LONG(0, 3)];
*((int *)pPlayer->pvPrivateData + OFFSET_INTERNALMODEL) = ct_model;
// This makes the model get updated right away.
MDLL_ClientUserInfoChanged(pPlayer, GETINFOKEYBUFFER(pPlayer)); // If this causes any problems for WON, do this line only in STEAM builds.
@ -522,18 +504,11 @@ static cell AMX_NATIVE_CALL cs_get_user_team(AMX *amx, cell *params) // cs_get_u
// params[1] = user index
// Valid entity should be within range
cell *model;
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if ((params[0] / sizeof(cell)) >= 2)
{
model = MF_GetAmxAddr(amx, params[2]);
*model = *((int *)pPlayer->pvPrivateData + OFFSET_INTERNALMODEL);
}
return *((int *)pPlayer->pvPrivateData + OFFSET_TEAM);
}
@ -728,27 +703,20 @@ static cell AMX_NATIVE_CALL cs_set_user_defusekit(AMX *amx, cell *params) // cs_
int* defusekit = ((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT);
if (params[2])
{
if (params[2]) {
int colour[3] = {DEFUSER_COLOUR_R, DEFUSER_COLOUR_G, DEFUSER_COLOUR_B};
for (int i = 0; i < 3; i++)
{
for (int i = 0; i < 3; i++) {
if (params[i + 3] != -1)
{
colour[i] = params[i + 3];
}
}
pPlayer->v.body = 1;
char* icon;
if (params[6] != -1)
{
if (params[6] != -1) {
int len;
icon = MF_GetAmxString(amx, params[6], 1, &len);
} else {
icon = "defuser";
}
else
icon = "defuser";
*defusekit |= HAS_DEFUSE_KIT;
MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "StatusIcon", NULL), NULL, pPlayer);
@ -765,7 +733,6 @@ static cell AMX_NATIVE_CALL cs_set_user_defusekit(AMX *amx, cell *params) // cs_
WRITE_BYTE(0); // hide
WRITE_STRING("defuser");
MESSAGE_END();
pPlayer->v.body = 0;
}
/*

View File

@ -260,9 +260,7 @@ enum CS_Internal_Models {
CS_CT_GIGN = 6,
CS_CT_SAS = 7,
CS_T_GUERILLA = 8,
CS_CT_VIP = 9,
CZ_T_MILITIA = 10,
CZ_CT_SPETSNAZ = 11
CS_CT_VIP = 9
};
enum

Some files were not shown because too many files have changed in this diff Show More