152 Commits

Author SHA1 Message Date
dd211e7a0b Tagged 0.20-RC7 2006-07-20 04:30:50 +00:00
8761791473 language file sync 2004-10-29 04:40:21 +00:00
6697b7b1d3 new amxxsc compiles 2004-10-29 04:29:02 +00:00
3c9a47aae3 New compilation of libsc251 2004-10-29 04:22:45 +00:00
d1675c82b5 fixed a language format error 2004-10-29 02:17:58 +00:00
b40643950d added some runtime checks 2004-10-29 02:15:01 +00:00
ff5b1dd7cc Changed error output format 2004-10-29 01:49:00 +00:00
3587483fa6 LogError() now can log native function names. 2004-10-29 00:21:44 +00:00
c9c26b869c added more checks 2004-10-28 20:48:00 +00:00
8f18856e91 Fixed SetView (by always hooking Spawn and precaching the needed dummy model rpgrocket.mdl) 2004-10-27 19:06:43 +00:00
ddfba00791 Fixed 2004-10-25 23:08:06 +00:00
c6eaa97391 oops :( 2004-10-25 23:01:28 +00:00
5eb095b514 Added native get_user_msgname(msgid, name[], len); 2004-10-25 23:00:16 +00:00
4e0bfe161e fixing SAWCE'S error 2004-10-25 17:06:24 +00:00
0e681d9bd4 replaced get_weaponname with xmod_get_wpnname 2004-10-25 11:16:02 +00:00
3d1162ecd9 client_ forwards will now work with kill command 2004-10-25 11:05:59 +00:00
3414cd7ce7 fixed pev bug.. 2004-10-24 21:03:12 +00:00
66386cca59 Fixed entity_set_byte 2004-10-24 15:41:25 +00:00
75396c753c Fixed sounds playing while connecting 2004-10-24 01:32:59 +00:00
4edd77faee Crash bug fix from Damaged Soul 2004-10-24 01:11:41 +00:00
91db6c7398 More pointless fixes from karlos 2004-10-24 01:09:07 +00:00
46390b83ac minor fix.. 2004-10-20 15:55:59 +00:00
89eda75b1f Touch it and die, bail. 2004-10-20 14:24:54 +00:00
f14808e009 Updated SDK
Fixed client_built forward...
2004-10-20 14:24:03 +00:00
b569ea3c3f Fixed bug where message_begin could not send MSG_PAS_R and MSG_PVS_R (reliable versions) messages. Reported by Damaged Soul 2004-10-20 14:16:46 +00:00
f595be47dc Fixed errors reportde by karlos 2004-10-18 21:00:25 +00:00
ee3404fea0 removed "is_alive" check from ResetHUD function 2004-10-16 22:22:54 +00:00
61fc7da654 fixed last hit bug and problems with c4 damage 2004-10-16 17:03:53 +00:00
14c3930b3d Damnit, bail 2004-10-16 14:26:11 +00:00
3efa25a5fb Fixed entity_set_edict 2004-10-14 08:15:41 +00:00
c29a7d34e5 Renamed cs_get_weapon_type -> cs_get_weapon_id 2004-10-14 06:09:01 +00:00
daa873d8ed Damaged Soul's map cycle file fix 2004-10-12 21:34:57 +00:00
c09de969eb Sawces icons 2004-10-12 21:23:38 +00:00
b0dd18580c fixed native prepend 2004-10-11 17:20:19 +00:00
32deaa261f fixed weapon name bug in player status 2004-10-09 21:06:11 +00:00
3a8e103faf Added custommenuitems.cfg to standard cfg files.
menufront.sma executes this file on plugin loa, adding the specified menu items to amxmodmenu.
2004-10-09 10:13:16 +00:00
f4b1c9f78a Added server command "amx_addmenuitem <menu text> <menu command> <access flags> <plugin name>":
Server admins can add menu items to amxmodmenu from plugins that do not (yet) do this on their own.
2004-10-09 09:50:33 +00:00
618759f390 Menu items boundary checking... 2004-10-09 09:32:56 +00:00
ced5d6ff57 added lang_phrase 2004-10-08 19:45:38 +00:00
db4041114f Fixed a bug in amx_client_languages
Added lang_phrase
2004-10-08 19:26:26 +00:00
b52d77e8bf Fixed big bug in executeForwards where float parameters were skipped and the stack might be messed up
(thanks to BAILOPAN)
2004-10-08 19:18:41 +00:00
940b0be4b9 Don't ask 2 2004-10-08 08:59:04 +00:00
75f49e78b0 Don't ask 2004-10-08 08:53:27 +00:00
f06359e38f Reworked to add AddMenuItem() 2004-10-08 08:37:27 +00:00
2733adbb49 Added AddMenuItem 2004-10-08 08:36:54 +00:00
fc4d8f183b const parameter in callfunc_push_str 2004-10-08 08:29:53 +00:00
ea70c77dd8 enabled emitsound_post function (knife shot fix, Damaged Soul ) 2004-10-07 08:58:01 +00:00
301a69aacb Synced translation files 2004-10-07 08:31:48 +00:00
92eda7c214 *** empty log message *** 2004-10-06 18:43:26 +00:00
4800ab292c Added stupid forwards 2004-10-06 17:57:57 +00:00
34cfce33a1 fixed /stats menu bug ( Damaged Soul ) and added selfkill check in miscstats 2004-10-06 15:47:04 +00:00
fec17424fb updated to October 2004-10-05 20:16:50 +00:00
264dd7a10d Fixed error outputs for CLang 2004-10-05 19:29:35 +00:00
6cef4eab4f *** empty log message *** 2004-10-05 19:02:15 +00:00
f4ada32ec2 Changed module comments (Damaged Soul) 2004-10-05 18:59:23 +00:00
bff8c3cdcf updated to csx 2004-10-05 16:20:03 +00:00
3b670333de Fixed result always refused even if admin accepted vote result. 2004-10-05 11:16:27 +00:00
eb36757ef1 Fixed menu not displaying on/off status for scout, mp5, ak47. 2004-10-05 10:01:04 +00:00
054b1f8868 *** empty log message *** 2004-10-05 09:22:14 +00:00
23234fad0b Added regex module 2004-10-05 08:53:51 +00:00
74dca8b6ef Fixed some bugs 2004-10-05 08:51:57 +00:00
2a187988f6 fixed project 2004-10-05 08:35:05 +00:00
d1ee9ee9ba *** empty log message *** 2004-10-05 08:33:31 +00:00
380f560fa4 Finalized (not tested!) 2004-10-05 08:32:23 +00:00
d9b6fa1f93 Initial import of regex stuff 2004-10-05 08:31:42 +00:00
8a57648b87 AMD64 support 2004-10-05 08:13:55 +00:00
80b8591295 Fixed a few bugs, added makefile 2004-10-05 08:04:13 +00:00
f94aa52974 Switched includes (bigballer) 2004-10-05 07:41:14 +00:00
ef8ad4a894 *** empty log message *** 2004-10-05 07:18:09 +00:00
41b6f6bd4a Initial import (untested!) 2004-10-05 07:17:49 +00:00
9e8f380121 changed is_valid_ent 2004-10-05 00:45:15 +00:00
39070081d1 fixed empty log message on debug trace 2004-10-04 22:56:36 +00:00
00d8ffe503 Fixed a debug trace output 2004-10-04 20:36:21 +00:00
4ef8530bba removed 2004-10-04 20:34:43 +00:00
77aa0f4f8e Fixed bad error checking routine 2004-10-04 20:32:26 +00:00
766246648d Fixed runtime error bugs 2004-10-04 20:10:27 +00:00
7963eb1cde added ms.net projs 2004-10-04 12:39:03 +00:00
02d8b2c523 Added makefile 2004-10-04 08:15:06 +00:00
227fb0411e Moved to other dirs 2004-10-04 08:11:28 +00:00
027ae6dc7e *** empty log message *** 2004-10-04 08:09:52 +00:00
334905e16e new configuration files for CSX 2004-10-04 08:08:18 +00:00
e3fad723b8 New CSX 2004-10-04 08:04:50 +00:00
5e52c45968 New SDK + debugging engine 2004-10-04 08:00:32 +00:00
e3a2a2bc17 Merged CSX versions 2004-10-04 07:30:39 +00:00
18b75cb07c Updated a bunch of SDKs and moved the rest to the new debugging system. 2004-10-04 06:14:30 +00:00
4e1c5a3e02 *** empty log message *** 2004-10-04 05:51:48 +00:00
5db290890f Fixed debugging stuff 2004-10-04 05:51:27 +00:00
b9c83aa4a2 Reworked SDK LogError() to include module names
improved debugging output
2004-10-04 05:50:28 +00:00
bb12f71137 made worldspawn a valid ent 2004-10-03 23:21:54 +00:00
0a3911231b made worldspawn a valid ent 2004-10-03 22:49:29 +00:00
846ef95c58 Added debugging engine 2004-10-03 22:33:55 +00:00
601bb30b7e Added debugging engine 2004-10-03 21:54:27 +00:00
9728b79c33 Fixed configuration error 2004-10-03 21:44:48 +00:00
90baf98057 Added debugging engine 2004-10-03 21:43:03 +00:00
8ad6437dd8 Added debugging engine 2004-10-03 21:33:09 +00:00
02bf904467 Added debugging support 2004-10-03 21:10:10 +00:00
62e4bbcfe9 Added new debug mode to fun module, also cleaned up error checking code 2004-10-03 20:19:47 +00:00
fc15ac1f41 Added debugging engine 2004-10-03 20:00:23 +00:00
01770f0e5b Fixed possible problem where a file handle could stay open on memory allocation failure 2004-10-03 17:04:29 +00:00
87ff81a499 Added important comment 2004-10-03 17:03:14 +00:00
981f41aee0 Fixed problem where file handles could possible stay open 2004-10-03 16:55:12 +00:00
605ca152c2 Fixed 2 possible crashbugs 2004-10-03 16:49:09 +00:00
0fc8f0b489 fixed bug in create pwup function 2004-10-03 11:07:49 +00:00
c511d80da7 Added delay to map changes 2004-10-03 07:33:49 +00:00
8304fc143c Increased a format buffer 2004-10-03 07:19:35 +00:00
f3cfd31668 Added AlertMessage to fakemeta 2004-10-03 07:04:08 +00:00
ef90960121 Fixed ADMIN_ALL bug 2004-10-03 06:23:25 +00:00
3700b8b39f Fixed bomb count bug 2004-10-03 06:08:09 +00:00
b83f2f5257 - Fixed bug where metamod was reporting "Could not find memloc for cvar xx" when modules registered cvars (fix by ghost_of_evilspy) 2004-10-02 08:18:54 +00:00
06f61cf92a Added more debugging info to case where CForwardMngr::m_PreparedArrays is >= (max params num) 2004-10-02 08:11:33 +00:00
5a5ff6d8ea Fixed parameter type in FN_PvAllocEntPrivateData (from long to int32) 2004-10-01 08:52:25 +00:00
bbe2626fd1 :gyar: a couple minor improvements :attack:
Global pointer for function tables
Better support for compiling under Cygwin gcc

:avast:
2004-09-30 06:18:23 +00:00
d5646ae238 update .. 2004-09-29 17:43:25 +00:00
df43d897df Fioxed call_think:
if (!is_ent_valid(iEnt)) {
		EngineError(amx, "Invalid Entity %d", iEnt);
		return 0;
	}

was

	if (is_ent_valid(iEnt)) {
		EngineError(amx, "Invalid Entity %d", iEnt);
		return 0;
	}
2004-09-29 06:17:44 +00:00
687a0f23da Added MSG_ONE_UNRELIABLE 2004-09-28 17:29:22 +00:00
aa0dc4dbaf Fixed a few issues (Damaged Soul) 2004-09-28 07:29:48 +00:00
de399c54c6 Fixed ML_NOTFOUND(LANG) 2004-09-28 07:18:51 +00:00
58d522e4c3 Fixed typo 2004-09-28 04:59:21 +00:00
3b90cca5bd Fixed user_slap for NS 2004-09-28 02:44:26 +00:00
b7c9cfeea4 Changed touch paramters on give item 2004-09-27 21:52:41 +00:00
4fcad51d25 updated to use amx_show_activity in hud messages 2004-09-27 17:43:40 +00:00
c2a2fc7dbe Added forward parameters overrun check in prepareArray 2004-09-27 14:33:50 +00:00
3f0d3c257a Increased maximal number of forward parameters 2004-09-27 14:33:20 +00:00
ecc07d4b45 Fixed some small mistakes. 2004-09-27 13:45:13 +00:00
8da965552b TK offset for AMD64 added. 2004-09-27 13:28:51 +00:00
cfe36dea52 Added 2 of 3 new offsets for amd64 2004-09-27 10:54:41 +00:00
c16eab09ec Fixed a typo 2004-09-27 09:53:56 +00:00
d07cc0424d Fixed a typo 2004-09-27 06:09:59 +00:00
c669efd609 New stuff in cstrike module:
cs_get_user_driving()
cs_set_user_tked()
cs_get_user_tked

Also cs_?et_user_deaths() offset updated.

Thanks to Damaged Soul for these.
2004-09-26 13:02:22 +00:00
c3151b312a Fixed (and slightly tweaked) make_deathmsg (jtp10181) 2004-09-26 00:43:43 +00:00
3fc3ece5b0 Added cs_get_weapon_type(index) 2004-09-25 23:24:34 +00:00
6887dfef16 CS: buyzone offset update to 235 2004-09-24 21:13:07 +00:00
867e7615ae stupid bug go squish 2004-09-24 19:36:24 +00:00
5157be6e3d Updated offset for VIP: to 209 2004-09-24 05:21:39 +00:00
82ca25b231 wow... =/ 2004-09-23 21:00:43 +00:00
a555f9b3f0 Fixed message blocks (jtp10181) 2004-09-23 20:59:26 +00:00
c1a6ce2565 Fixed typo (ktrain) 2004-09-22 23:27:55 +00:00
8874666109 removed extraneous functions (jtp10181) 2004-09-21 23:33:29 +00:00
5233be593f added dod_set_user_kills 2004-09-21 21:25:30 +00:00
0f38a24555 added dod classes 2004-09-21 20:51:29 +00:00
8d06f80eeb fixed some bugs in weapon stats functions 2004-09-21 18:04:22 +00:00
0983698d2e fixed motd 2004-09-21 17:48:48 +00:00
dde43b6e0d Fixed CVARs not registering properly (hullu) 2004-09-21 15:49:36 +00:00
4382158b88 *** empty log message *** 2004-09-21 15:45:08 +00:00
ba69d73785 Fixed alphanumeric bug (theprog) 2004-09-21 05:20:18 +00:00
be3d078d5a added is_amd64_server 2004-09-21 02:40:30 +00:00
b8ca4586ad fix from fsfod 2004-09-20 22:17:14 +00:00
25750d2f05 Changes incorporated into base package 2004-09-20 17:58:48 +00:00
423a467a70 Added new maps in beta5 2004-09-20 10:23:47 +00:00
d6e18a3e97 Better comments for unstuck 2004-09-20 09:57:48 +00:00
a6d5d89209 Commented out unstuck plugin 2004-09-20 09:56:05 +00:00
16b35006bd Removed "id" from amx_ban for new format. 2004-09-20 09:36:28 +00:00
193 changed files with 11348 additions and 5227 deletions

View File

@ -494,7 +494,8 @@ cell executeForwards(int id, ...)
REAL tmp = (REAL)va_arg(argptr, double); // floats get converted to doubles
params[i] = *(cell*)&tmp;
}
params[i] = (cell)va_arg(argptr, cell);
else
params[i] = (cell)va_arg(argptr, cell);
}
va_end(argptr);
return g_forwards.executeForwards(id, params);
@ -502,10 +503,20 @@ cell executeForwards(int id, ...)
cell CForwardMngr::prepareArray(void *ptr, unsigned int size, ForwardArrayElemType type, bool copyBack)
{
if (m_TmpArraysNum >= FORWARD_MAX_PARAMS)
{
#ifdef MEMORY_TEST
m_validateAllAllocUnits();
#endif // MEMORY_TEST
AMXXLOG_Log("[AMXX] Forwards with more than 32 parameters are not supported (tried to prepare array # %d).", m_TmpArraysNum + 1);
m_TmpArraysNum = 0;
return -1;
}
m_TmpArrays[m_TmpArraysNum].ptr = ptr;
m_TmpArrays[m_TmpArraysNum].size = size;
m_TmpArrays[m_TmpArraysNum].type = type;
m_TmpArrays[m_TmpArraysNum].copyBack = copyBack;
return m_TmpArraysNum++;
}

View File

@ -46,7 +46,7 @@
#ifndef FORWARD_H
#define FORWARD_H
const int FORWARD_MAX_PARAMS = 16;
const int FORWARD_MAX_PARAMS = 32;
enum ForwardExecType
{

View File

@ -498,7 +498,7 @@ int CLangMngr::GetKeyEntry(String &key)
}
#define CHECK_PTR(ptr, start, bufsize) if ((ptr) - (start) >= (bufsize)) { \
AMXXLOG_Log("[AMXX] Buffer overflow in formatting (line %d, \"%s\")", amx->curline, g_plugins.findPluginFast(amx)->getName()); \
LogError(amx, AMX_ERR_STACKERR, "Buffer overflow in string formatting"); \
outbuf[0] = 0; \
len = 0; \
return outbuf; }
@ -509,7 +509,7 @@ int CLangMngr::GetKeyEntry(String &key)
{ \
strcpy(outbuf, ""); \
len = 0; \
AMXXLOG_Log("[AMXX] Plugin did not format a string correctly (parameter %d (total %d), line %d, \"%s\")", parm, paramCount, amx->curline, g_plugins.findPluginFast(amx)->getName()); \
LogError(amx, AMX_ERR_PARAMS, "String formatted incorrectly - parameter %d (total %d)", parm, paramCount); \
return outbuf; \
}
@ -536,7 +536,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
// Handle player ids (1-32) and server language
if (*pAmxLangName == LANG_PLAYER) // LANG_PLAYER
{
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
{
cpLangName = g_vault.get("server_language");
} else {
@ -545,7 +545,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
} else if (*pAmxLangName == LANG_SERVER) { // LANG_SERVER
cpLangName = g_vault.get("server_language");
} else if (*pAmxLangName >= 1 && *pAmxLangName <= 32) { // Direct Client Id
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
{
cpLangName = g_vault.get("server_language");
} else {
@ -957,7 +957,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
return 0;
}
MD5 md5;
md5.update(fp);
md5.update(fp); // closes for us
md5.finalize();
char md5buffer[33];
md5.hex_digest(md5buffer);

View File

@ -153,9 +153,11 @@ void LogEventsMngr::executeLogEvents()
{
int err;
bool valid;
for(CLogEvent* a = logevents[ logArgc ]; a ; a = a->next){
for(CLogEvent* a = logevents[ logArgc ]; a ; a = a->next)
{
valid = true;
for( CLogEvent::LogCond* b = a->filters; b ; b = b->next){
for( CLogEvent::LogCond* b = a->filters; b ; b = b->next)
{
valid = false;
for( CLogEvent::LogCondEle* c = b->list; c ; c = c->next) {
if ( c->cmp->compareCondition( logArgs[b->argnum] ) == 0 ){
@ -163,27 +165,15 @@ void LogEventsMngr::executeLogEvents()
break;
}
}
if (!valid) break;
if (!valid)
break;
}
#ifdef ENABLEEXEPTIONS
try
if (valid)
{
#endif
if (valid){
if ((err = amx_Exec(a->plugin->getAMX(), NULL , a->func , 0)) != AMX_ERR_NONE)
LogError(a->plugin->getAMX(), err, "");
}
#ifdef ENABLEEXEPTIONS
if ((err = amx_Exec(a->plugin->getAMX(), NULL , a->func , 0)) != AMX_ERR_NONE)
LogError(a->plugin->getAMX(), err, "");
}
catch( ... )
{
AMXXLOG_Log( "[AMXX] fatal error at log forward function execution");
}
#endif
}
}

View File

@ -428,6 +428,7 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
AMX_HEADER *hdr;
AMX_FUNCSTUB *func;
AMX_NATIVE f;
int i =0;
assert(amx!=NULL);
hdr=(AMX_HEADER *)amx->base;
@ -437,6 +438,7 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
assert(index>=0 && index<(cell)NUMENTRIES(hdr,natives,libraries));
func=GETENTRY(hdr,natives,index);
f=(AMX_NATIVE)func->address;
amx->userdata[2] = (char *)GETENTRYNAME(hdr, func);
assert(f!=NULL);
/* now that we have found the function, patch the program so that any
@ -606,6 +608,7 @@ static int amx_BrowseRelocate(AMX *amx)
} else {
amx->userdata[0] = 0;
amx->userdata[1] = 0;
amx->userdata[2] = 0;
}
#if defined __GNUC__ || defined ASM32 || defined JIT && !defined __64BIT__

View File

@ -351,6 +351,15 @@ static cell AMX_NATIVE_CALL is_linux_server(AMX *amx, cell *params)
#endif
}
static cell AMX_NATIVE_CALL is_amd64_server(AMX *amx, cell *params)
{
#if SMALL_CELL_SIZE==64
return 1;
#else
return 0;
#endif
}
static cell AMX_NATIVE_CALL is_jit_enabled(AMX *amx, cell *params) // PM: Useless ;P
{
#ifdef JIT
@ -1203,6 +1212,7 @@ static cell AMX_NATIVE_CALL message_begin(AMX *amx, cell *params) /* 4 param */
MESSAGE_BEGIN( params[1], params[2],NULL );
break;
case MSG_PVS: case MSG_PAS:
case MSG_PVS_R: case MSG_PAS_R:
if (numparam < 3) {
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
@ -1213,12 +1223,13 @@ static cell AMX_NATIVE_CALL message_begin(AMX *amx, cell *params) /* 4 param */
vecOrigin[2] = *(cpOrigin+2);
MESSAGE_BEGIN( params[1], params[2] , vecOrigin );
break;
case MSG_ONE_UNRELIABLE:
case MSG_ONE:
if (numparam < 4) {
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
MESSAGE_BEGIN( MSG_ONE, params[2], NULL, INDEXENT(params[4]) );
MESSAGE_BEGIN( params[1], params[2], NULL, INDEXENT(params[4]) );
break;
}
@ -1667,6 +1678,16 @@ static cell AMX_NATIVE_CALL get_user_msgid(AMX *amx, cell *params) /* 1 param */
return GET_USER_MSG_ID(PLID, sptemp , NULL );
}
static cell AMX_NATIVE_CALL get_user_msgname(AMX *amx, cell *params) /* get_user_msgname(msg, str[], len) = 3 params */
{
const char* STRING = GET_USER_MSG_NAME(PLID, params[1], NULL);
if (STRING)
return set_amxstring(amx, params[2], STRING, params[3]);
// Comes here if GET_USER_MSG_NAME failed (ie, invalid msg id)
return 0;
}
static cell AMX_NATIVE_CALL set_task(AMX *amx, cell *params) /* 2 param */
{
@ -1740,7 +1761,11 @@ static cell AMX_NATIVE_CALL register_cvar(AMX *amx, cell *params) /* 3 param */
g_cvars.put( cvar );
if ( CVAR_GET_POINTER(temp) == 0 )
CVAR_REGISTER( cvar->getCvar() );
{
static cvar_t cvar_reg_helper;
cvar_reg_helper = *(cvar->getCvar());
CVAR_REGISTER( &cvar_reg_helper );
}
CVAR_SET_STRING( temp ,get_amxstring(amx,params[2],1,i));
return 1;
@ -2666,6 +2691,35 @@ cell AMX_NATIVE_CALL require_module(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL lang_phrase(AMX *amx, cell *params)
{
int len = 0;
int iLang = params[1];
const char *cpLangName=NULL;
// Handle player ids (1-32) and server language
if (iLang == LANG_SERVER) { // LANG_SERVER
cpLangName = g_vault.get("server_language");
} else if (iLang >= 1 && iLang <= 32) { // Direct Client Id
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
{
cpLangName = g_vault.get("server_language");
} else {
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(iLang)->pEdict, "lang");
}
}
if (!cpLangName || strlen(cpLangName) < 1)
cpLangName = "en";
const char *str = get_amxstring(amx, params[2], 0, len);
const char *dat = g_langMngr.GetDef(cpLangName, str);
set_amxstring(amx, params[3], dat?dat:"ML_LNOTFOUND", params[4]);
return 1;
}
AMX_NATIVE_INFO amxmod_Natives[] = {
{ "client_cmd", client_cmd },
{ "client_print", client_print },
@ -2716,6 +2770,7 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
{ "get_user_ip", get_user_ip },
{ "get_user_menu", get_user_menu},
{ "get_user_msgid", get_user_msgid},
{ "get_user_msgname", get_user_msgname},
{ "get_user_name", get_user_name },
{ "get_user_origin", get_user_origin},
{ "get_user_ping", get_user_ping },
@ -2731,6 +2786,7 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
{ "get_xvar_num", get_xvar_num },
{ "is_dedicated_server",is_dedicated_server },
{ "is_linux_server", is_linux_server },
{ "is_amd64_server", is_amd64_server },
{ "is_jit_enabled", is_jit_enabled },
{ "is_user_authorized", is_user_authorized },
{ "is_map_valid", is_map_valid },
@ -2824,5 +2880,6 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
{ "md5", amx_md5 },
{ "md5_file", amx_md5_file },
{ "plugin_flags", plugin_flags},
{ "lang_phrase", lang_phrase},
{ NULL, NULL }
};

View File

@ -64,7 +64,7 @@ void CLog::CloseFile()
if (fp)
{
fclose(fp);
fopen(m_LogFile.c_str(), "a+");
fp = fopen(m_LogFile.c_str(), "a+");
// get time
time_t td;
@ -106,8 +106,11 @@ void CLog::CreateNewFile()
ALERT(at_logged, "[AMXX] Unexpected fatal logging error. AMXX Logging disabled.\n");
SET_LOCALINFO("amxx_logging", "0");
}
fprintf(fp, "AMX Mod X log file started (file \"%s/L%02d%02d%03d.log\") (version \"%s\")\n", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i, AMX_VERSION);
fclose(fp);
else
{
fprintf(fp, "AMX Mod X log file started (file \"%s/L%02d%02d%03d.log\") (version \"%s\")\n", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i, AMX_VERSION);
fclose(fp);
}
}
void CLog::UseFile(const String &fileName)

View File

@ -2344,6 +2344,14 @@ CFakeMeta::CFakeMetaPlugin::~CFakeMetaPlugin()
}
}
// ghost_of_evilspy's "could not find memloc for cvar" fix
void FakeMeta_New_CVarRegister(cvar_t *pCVar)
{
static cvar_t tmpvar;
tmpvar = *pCVar;
CVAR_REGISTER(&tmpvar);
}
int CFakeMeta::CFakeMetaPlugin::Query(mutil_funcs_t *pMetaUtilFuncs)
{
// Load the library
@ -2390,7 +2398,13 @@ int CFakeMeta::CFakeMetaPlugin::Query(mutil_funcs_t *pMetaUtilFuncs)
m_Status = PL_BADFILE;
return 0;
}
giveEngFuncsFn(&g_engfuncs, gpGlobals);
// ghost_of_evilspy's "Could not find memloc for cvar" fix
static enginefuncs_t fakemeta_engfuncs;
memcpy(&fakemeta_engfuncs, &g_engfuncs, sizeof(enginefuncs_t));
// Override cvar register to our own function
fakemeta_engfuncs.pfnCVarRegister = FakeMeta_New_CVarRegister;
giveEngFuncsFn(&fakemeta_engfuncs, gpGlobals);
if (queryFn(META_INTERFACE_VERSION, &m_Info, pMetaUtilFuncs) != 1)
{

View File

@ -57,6 +57,23 @@
CVector<FILE *> FileList;
class AutoFilePtr
{
FILE *m_FP;
public:
AutoFilePtr(FILE *fp) : m_FP(fp)
{ }
~AutoFilePtr()
{
if (m_FP)
fclose(m_FP);
}
operator FILE* ()
{
return m_FP;
}
};
static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
{
#ifdef __GNUC__
@ -228,41 +245,44 @@ static cell AMX_NATIVE_CALL file_exists(AMX *amx, cell *params) /* 1 param */
static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
{
int iLen;
char* sFile = get_amxstring(amx,params[1],0,iLen);
FILE* fp = fopen(build_pathname("%s",sFile),"r");
if ( fp != NULL) {
if ( params[0] < 2 || params[2] == 0 ){
fseek(fp,0,SEEK_END);
int size = ftell(fp);
fclose(fp);
return size;
}
else if ( params[2] == 1 ){
int a = 0,lines = 0;
while( a != EOF ){
++lines;
while ( (a = fgetc(fp)) != '\n' && a != EOF )
;
}
//int a, b = '\n';
//while( (a = fgetc(fp)) != EOF ){
// if ( a == '\n')
// ++lines;
// b = a;
//}
//if ( b != '\n' )
// ++lines;
return lines;
}
else if ( params[2] == 2 ){
fseek(fp,-1,SEEK_END);
if ( fgetc(fp) == '\n' )
return 1;
return 0;
}
}
return -1;
int iLen;
char* sFile = get_amxstring(amx,params[1],0,iLen);
AutoFilePtr fp(fopen(build_pathname("%s",sFile),"r"));
if ( fp != NULL)
{
if ( params[0] < 2 || params[2] == 0 )
{
fseek(fp,0,SEEK_END);
int size = ftell(fp);
return size;
}
else if ( params[2] == 1 )
{
int a = 0,lines = 0;
while( a != EOF )
{
++lines;
while ( (a = fgetc(fp)) != '\n' && a != EOF )
;
}
//int a, b = '\n';
//while( (a = fgetc(fp)) != EOF ){
// if ( a == '\n')
// ++lines;
// b = a;
//}
//if ( b != '\n' )
// ++lines;
return lines;
}
else if ( params[2] == 2 ){
fseek(fp,-1,SEEK_END);
if ( fgetc(fp) == '\n' )
return 1;
return 0;
}
}
return -1;
}
//ported from Sanji's file access module by BAILOPAN
@ -454,7 +474,7 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
int len;
char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
long size;
FILE *fp = fopen(file, "rb");
AutoFilePtr fp(fopen(file, "rb"));
if (fp) {
fseek(fp, 0, SEEK_END);
size = ftell(fp);

View File

@ -281,7 +281,7 @@ int C_Spawn( edict_t *pent ) {
FF_ClientPutInServer = registerForward("client_putinserver", ET_IGNORE, FP_CELL, FP_DONE);
FF_PluginCfg = registerForward("plugin_cfg", ET_IGNORE, FP_DONE);
FF_PluginPrecache = registerForward("plugin_precache", ET_IGNORE, FP_DONE);
FF_PluginLog = registerForward("plugin_log", ET_IGNORE, FP_DONE);
FF_PluginLog = registerForward("plugin_log", ET_STOP, FP_DONE);
FF_PluginEnd = registerForward("plugin_end", ET_IGNORE, FP_DONE);
FF_InconsistentFile = registerForward("inconsistent_file", ET_STOP, FP_CELL, FP_STRING, FP_STRINGEX, FP_DONE);
FF_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_DONE);
@ -985,7 +985,9 @@ void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
g_logevents.parseLogString( );
if (g_logevents.logEventsExist())
g_logevents.executeLogEvents( );
executeForwards(FF_PluginLog);
cell retVal = executeForwards(FF_PluginLog);
if (retVal)
RETURN_META(MRES_HANDLED);
}
RETURN_META(MRES_IGNORED);

View File

@ -616,7 +616,11 @@ int loadModules(const char* filename)
CModule* cc = new CModule( path.c_str() );
if ( cc == 0 ) return loaded;
if ( cc == 0 )
{
fclose(fp);
return loaded;
}
cc->queryModule();
@ -1162,7 +1166,13 @@ void GenericError(AMX *amx, int err, int line, char buf[], const char *file)
{
sprintf(buf, "Run time error %d on line %d (%s \"%s\").", err, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
} else {
sprintf(buf, "Run time error %d (%s) on line %d (%s \"%s\").", err, geterr, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
if (err == AMX_ERR_NATIVE && amx->userdata[2])
{
geterr = (char *)(amx->userdata[2]);
sprintf(buf, "Native error in \"%s\" on line %d (%s \"%s\").", geterr, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
} else {
sprintf(buf, "Run time error %d (%s) on line %d (%s \"%s\").", err, geterr, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
}
}
}
}
@ -1185,8 +1195,21 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
if (!dbg || !(dbg->tail))
{
GenericError(amx, err, amx->curline, buf, NULL);
AMXXLOG_Log("[AMXX] %s %s", buf, vbuf);
if (dbg && amx->curfile < dbg->numFiles && amx->curfile >= 0)
{
GenericError(amx, err, amx->curline, buf, dbg->files[amx->curfile]);
} else {
GenericError(amx, err, amx->curline, buf, NULL);
}
AMXXLOG_Log("[AMXX] %s", buf);
if (*vbuf)
{
AMXXLOG_Log("%s", vbuf);
}
if (!dbg)
{
AMXXLOG_Log("[AMXX] To enable debug mode, add \" debug\" after the plugin name in plugins.ini (without quotes).");
}
} else {
AMX_TRACE *t = dbg->tail;
AMX_DEBUGCALL tracer = (AMX_DEBUGCALL)(amx->userdata[1]);
@ -1194,19 +1217,20 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
cell line = amx->curline;
cell file = amx->curfile;
int i = 0;
if (file >= dbg->numFiles || file < 0)
{
GenericError(amx, err, line, buf, NULL);
} else {
GenericError(amx, err, line, buf, dbg->files[file]);
}
GenericError(amx, err, line, buf, NULL);
AMXXLOG_Log("[AMXX] %s", buf);
if (*vbuf)
{
AMXXLOG_Log("[AMXX] %s", vbuf);
AMXXLOG_Log("%s", vbuf);
}
AMXXLOG_Log("[AMXX] Debug Trace =>");
//log the error right away
if (file >= dbg->numFiles || file < 0)
{
AMXXLOG_Log("[AMXX] [%d] Line %d, File \"%s\"", i++, line, g_plugins.findPluginFast(amx)->getName());
} else {
AMXXLOG_Log("[AMXX] [%d] Line %d, File \"%s\"", i++, line, dbg->files[file]);
}
while (t != NULL)
{
line = t->line;

View File

@ -316,7 +316,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="odbc32.lib odbccp32.lib ..\jit\jits.lib ..\zlib\zlib.lib"
AdditionalDependencies="..\jit\jits.obj ..\zlib\zlib.lib"
OutputFile="jitdebug/amxmodx_mm.dll"
Version="0.1"
LinkIncremental="1"

View File

@ -45,6 +45,16 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2439,7 +2454,7 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogError;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
@ -2529,7 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogError, PFN_LOG_ERROR);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2636,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1990,7 +1990,7 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogError;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
@ -2106,7 +2106,7 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
#define MF_LogError g_fn_LogError
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward

View File

@ -14,4 +14,4 @@
"Kick player" "amx_kick #%userid%" "b" "u"
"Slay player" "amx_slay #%userid%" "bd" "u"
"Slap with 1 dmg." "amx_slap #%userid% 1" "bd" "u"
"Ban for 5 minutes" "amx_ban #%userid% id 5" "b" "u"
"Ban for 5 minutes" "amx_ban #%userid% 5" "b" "u"

View File

@ -50,14 +50,20 @@ fun_amxx.dll
;sockets_amxx_i386.so
;sockets_amxx.dll
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
; ----------------------------------------------------------
; Counter-Strike - adds functions specific to Counter-Strike
; ----------------------------------------------------------
;cstrike_amxx_i386.so
;cstrike_amxx.dll
; ------------------------------------------------
; CS Stats - adds functionality for CS statistical
; ------------------------------------------------
;csstats_amxx_i386.so
;csstats_amxx.dll
; -----------------------------------------------------
; CSX - adds functionality for CS statistics and events
; -----------------------------------------------------
;csx_amxx_i386.so
;csx_amxx.dll

View File

@ -35,9 +35,9 @@ statscfg.amxx ; allows to manage stats plugins via menu and commands
; Counter-Strike
;restmenu.amxx ; restrict weapons menu
;statsx.amxx ; stats on death or round end (CSStats Module required!)
;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 (CSStats Module required!)
;stats_logging.amxx ; weapons stats logging (CSX Module required!)
; Custom - Add 3rd party plugins here

13
configs/custommenuitems.cfg Executable file
View File

@ -0,0 +1,13 @@
// Here you can add menu items from any plugin to Menus Front-End plugin, aka "amxmodmenu".
//
// Usage: "amx_addmenuitem <menu text> <menu command> <access flags> <plugin name>"
//
// <menu text>: This is the text displayed in the menu itself for this item.
// <menu command>: This is the client command used to access the menu.
// <access flags>: Specify what access flags admins must have to use this menu item. (Check users.ini for access flags.)
// <plugin name>: This must be the _exact_ (though case insensitive) name of the plugin which holds the menu command. (Use "amxx plugins" in server console, plugin names are listed in Name column.)
//
// Example: (be sure to use quotes around parameters with spaces!)
//
// amx_addmenuitem "Weapon Arena" "weaponarena_menu" "hu" "Weapon Arena"

View File

@ -50,6 +50,12 @@ fun_amxx.dll
;sockets_amxx_i386.so
;sockets_amxx.dll
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
; --------------------------------------------------
; Day of Defeat Fun - adds functions specific to DoD
; --------------------------------------------------

View File

@ -49,3 +49,9 @@ fun_amxx.dll
; --------------------------------
;sockets_amxx_i386.so
;sockets_amxx.dll
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll

View File

@ -4,23 +4,26 @@
; Add in your mod's maps here
co_angst
ns_caged
ns_hera
ns_metal
ns_caged
co_sava
co_angst
ns_hera
ns_lost
ns_nothing
co_faceoff
ns_mineshaft
co_daimos
ns_bast
ns_origin
co_kestrel
ns_tanith
ns_nancy
ns_veil
co_core
co_ulysses
ns_eclipse
co_pulse
ns_ayumi
ns_agora
co_ulysses
ns_altair

View File

@ -50,6 +50,12 @@
;sockets_amxx_i386.so
;sockets_amxx.dll
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
; -----------------
; Natural Selection
; -----------------

View File

@ -35,6 +35,6 @@ pausecfg.amxx ; allows to pause and unpause some plugins
; NS Specific plugins
idlekicker.amxx ; kicks idle players
nscommands.amxx ; extra commands for Natural-Selection
unstuck.amxx ; Allows players to free themselves if they get stuck in the map (req engine & ns modules)
;unstuck.amxx ; Free stuck players (engine & ns modules required!)
; Custom - Add 3rd party plugins here

View File

@ -50,6 +50,12 @@ fun_amxx.dll
;sockets_amxx_i386.so
;sockets_amxx.dll
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
; ------------------------------------------------------------------
; Team Fortress Classic X - adds functions and stats specific to TFC
; ------------------------------------------------------------------

View File

@ -3,7 +3,7 @@ amxx_logdir addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini
mxx_plugins addons/amxmodx/configs/plugins.ini
amxx_plugins addons/amxmodx/configs/plugins.ini
amxx_pluginsdir addons/amxmodx/plugins
amxx_modulesdir addons/amxmodx/modules
amxx_vault addons/amxmodx/data/vault.ini

View File

@ -50,6 +50,12 @@ fun_amxx.dll
;sockets_amxx_i386.so
;sockets_amxx.dll
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
; -----------------------------------------------------------
; The Specialists X - adds functions and stats specific to TS
; -----------------------------------------------------------

View File

@ -45,6 +45,16 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2439,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2453,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2525,6 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2560,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2572,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2629,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2649,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2664,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1986,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2026,6 +2033,7 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2045,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2059,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2094,11 +2106,14 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2108,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2133,7 +2149,7 @@ void MF_Log(const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format;
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -37,11 +37,7 @@
bool UTIL_IsPlayer(AMX* amx, edict_t* pPlayer) {
bool player = false;
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if (strcmp(STRING(pPlayer->v.classname), "player") == 0)
player = true;
@ -74,20 +70,10 @@ static cell AMX_NATIVE_CALL cs_set_user_money(AMX *amx, cell *params) // cs_set_
// params[3] = flash money?
// Check index
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
// Give money
*((int *)pPlayer->pvPrivateData + OFFSET_CSMONEY) = params[2];
@ -107,20 +93,10 @@ static cell AMX_NATIVE_CALL cs_get_user_money(AMX *amx, cell *params) // cs_get_
// params[1] = user
// Check index
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
// Return money
return *((int *)pPlayer->pvPrivateData + OFFSET_CSMONEY);
@ -132,20 +108,10 @@ static cell AMX_NATIVE_CALL cs_get_user_deaths(AMX *amx, cell *params) // cs_get
// params[1] = user
// Check index
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return *((int *)pPlayer->pvPrivateData + OFFSET_CSDEATHS);
}
@ -157,20 +123,10 @@ static cell AMX_NATIVE_CALL cs_set_user_deaths(AMX *amx, cell *params) // cs_set
// params[2] = new deaths
// Check index
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
// Set deaths
*((int *)pPlayer->pvPrivateData + OFFSET_CSDEATHS) = params[2];
@ -193,24 +149,14 @@ static cell AMX_NATIVE_CALL cs_get_hostage_id(AMX *amx, cell *params) // cs_get_
// params[1] = hostage entity index
// Valid entity should be within range
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_ENTITY(params[1]);
// Make into class pointer
edict_t *pEdict = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pEdict)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pEdict = GETEDICT(params[1]);
// Make sure this is a hostage.
if (strcmp(STRING(pEdict->v.classname), "hostage_entity") != 0) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pEdict->v.classname));
return 0;
}
@ -224,21 +170,11 @@ static cell AMX_NATIVE_CALL cs_get_weapon_silenced(AMX *amx, cell *params) // cs
// params[1] = weapon index
// Valid entity should be within range
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
switch (weapontype) {
@ -254,6 +190,20 @@ static cell AMX_NATIVE_CALL cs_get_weapon_silenced(AMX *amx, cell *params) // cs
return 0;
}
static cell AMX_NATIVE_CALL cs_get_weapon_id(AMX *amx, cell *params) // cs_get_weapon_id(index); = 1 param
{
// Get weapon type. Corresponds to CSW_*
// params[1] = weapon index
// Valid entity should be within range
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
return *((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
}
static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs_set_weapon_silenced(index, silence = 1); = 2 params
{
// Silence/unsilence gun. Does only work on M4A1 and USP.
@ -261,21 +211,11 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs
// params[2] = 1, and we silence the gun, 0 and we unsilence gun.
// Valid entity should be within range
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
@ -325,21 +265,11 @@ static cell AMX_NATIVE_CALL cs_get_weapon_burstmode(AMX *amx, cell *params) // c
// params[1] = weapon index
// Valid entity should be within range
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int* firemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
switch (weapontype) {
@ -362,21 +292,11 @@ static cell AMX_NATIVE_CALL cs_set_weapon_burstmode(AMX *amx, cell *params) // c
// params[2] = 1, and we set burstmode, 0 and we unset it.
// Valid entity should be within range
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int* firemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
@ -432,20 +352,10 @@ static cell AMX_NATIVE_CALL cs_get_user_vip(AMX *amx, cell *params) // cs_get_us
// params[1] = user index
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if ( *((int *)pPlayer->pvPrivateData + OFFSET_VIP) & PLAYER_IS_VIP )
return 1;
@ -460,20 +370,10 @@ static cell AMX_NATIVE_CALL cs_set_user_vip(AMX *amx, cell *params) // cs_set_us
// params[2] = if 1, activate vip, else deactivate vip.
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if (params[2] == 1) {
// Set to "be" vip.
@ -522,20 +422,10 @@ 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
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return *((int *)pPlayer->pvPrivateData + OFFSET_TEAM);
}
@ -548,20 +438,10 @@ static cell AMX_NATIVE_CALL cs_set_user_team(AMX *amx, cell *params) // cs_set_u
// params[3] = model = 0
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
int model = params[3];
@ -589,7 +469,8 @@ static cell AMX_NATIVE_CALL cs_set_user_team(AMX *amx, cell *params) // cs_set_u
strcpy(teaminfo, "SPECTATOR");
break;
default:
sprintf(teaminfo, "TEAM_%d", params[2]);
int team_nr = (int)params[2];
sprintf(teaminfo, "TEAM_%i", team_nr);
}
MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "TeamInfo", NULL));
WRITE_BYTE(params[1]);
@ -605,20 +486,10 @@ static cell AMX_NATIVE_CALL cs_get_user_inside_buyzone(AMX *amx, cell *params) /
// params[1] = user index
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return (int)*((int *)pPlayer->pvPrivateData + OFFSET_BUYZONE); // This offset is 0 when outside, 1 when inside.
}
@ -629,20 +500,10 @@ static cell AMX_NATIVE_CALL cs_get_user_plant(AMX *amx, cell *params) // cs_get_
// params[1] = user index
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if ((int)*((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT) & CAN_PLANT_BOMB)
return 1;
@ -658,20 +519,10 @@ static cell AMX_NATIVE_CALL cs_set_user_plant(AMX *amx, cell *params) // cs_set_
// params[3] = show bomb icon?
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
int* plantskill = ((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT);
@ -714,20 +565,10 @@ static cell AMX_NATIVE_CALL cs_get_user_defusekit(AMX *amx, cell *params) // cs_
// params[1] = user index
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if ((int)*((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT) & HAS_DEFUSE_KIT)
return 1;
@ -747,20 +588,10 @@ static cell AMX_NATIVE_CALL cs_set_user_defusekit(AMX *amx, cell *params) // cs_
// params[7] = flash = 0
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
int* defusekit = ((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT);
@ -822,20 +653,10 @@ static cell AMX_NATIVE_CALL cs_get_user_backpackammo(AMX *amx, cell *params) //
// params[2] = weapon, as in CSW_*
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
int offset;
@ -897,7 +718,7 @@ static cell AMX_NATIVE_CALL cs_get_user_backpackammo(AMX *amx, cell *params) //
offset = OFFSET_C4_AMMO;
break;
default:
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", params[2]);
return 0;
}
@ -914,20 +735,10 @@ static cell AMX_NATIVE_CALL cs_set_user_backpackammo(AMX *amx, cell *params) //
// params[3] = new amount
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
int offset;
@ -989,7 +800,7 @@ static cell AMX_NATIVE_CALL cs_set_user_backpackammo(AMX *amx, cell *params) //
offset = OFFSET_C4_AMMO;
break;
default:
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", params[2]);
return 0;
}
@ -1004,20 +815,10 @@ static cell AMX_NATIVE_CALL cs_get_user_nvg(AMX *amx, cell *params) // cs_get_us
// params[1] = user index
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if ((int)*((int *)pPlayer->pvPrivateData + OFFSET_NVGOGGLES) & HAS_NVGOGGLES)
return 1;
@ -1032,20 +833,10 @@ static cell AMX_NATIVE_CALL cs_set_user_nvg(AMX *amx, cell *params) // cs_set_us
// params[2] = 1 = give, 0 = remove
// Valid entity should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
int* defusekit = ((int *)pPlayer->pvPrivateData + OFFSET_NVGOGGLES);
@ -1073,20 +864,9 @@ static cell AMX_NATIVE_CALL cs_get_user_model(AMX *amx, cell *params) // cs_get_
// params[3] = max length to set
// Valid player index should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return MF_SetAmxString(amx, params[2], GETCLIENTKEYVALUE(GETINFOKEYBUFFER(pPlayer), "model"), params[3]);
}
@ -1098,23 +878,13 @@ static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params) // cs_set_
// params[2] = model
// Valid player index should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t* pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t* pPlayer = MF_GetPlayerEdict(params[1]);
if (params[2] == -1) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid model %d", params[2]);
return 0;
}
@ -1137,20 +907,10 @@ static cell AMX_NATIVE_CALL cs_reset_user_model(AMX *amx, cell *params) // cs_re
// params[1] = user index
// Valid player index should be within range
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t* pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t* pPlayer = MF_GetPlayerEdict(params[1]);
g_players[params[1]].SetModelled(false);
@ -1165,24 +925,14 @@ static cell AMX_NATIVE_CALL cs_get_hostage_follow(AMX *amx, cell *params) // cs_
// params[1] = hostage index
// Valid index should be within range
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t* pHostage = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pHostage)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make sure this is a hostage.
if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pHostage->v.classname));
return 0;
}
@ -1198,7 +948,7 @@ static cell AMX_NATIVE_CALL cs_get_hostage_follow(AMX *amx, cell *params) // cs_
edict_t* pEntity = (edict_t*)following;
if (FNullEnt(pEntity)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown error finding hostage parameter");
return 0;
}
@ -1212,24 +962,14 @@ static cell AMX_NATIVE_CALL cs_set_hostage_follow(AMX *amx, cell *params) // cs_
// params[2] = index to follow, if -1 then set hostage to not follow anything
// Valid index should be within range
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t* pHostage = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pHostage)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make sure this is a hostage.
if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pHostage->v.classname));
return 0;
}
@ -1245,20 +985,10 @@ static cell AMX_NATIVE_CALL cs_set_hostage_follow(AMX *amx, cell *params) // cs_
}
// Valid index should be within range
if (params[2] < 1 || params[2] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_ENTITY(params[2]);
// Make into edict pointer
edict_t* pEntity = INDEXENT(params[2]);
// Check entity validity
if (FNullEnt(pEntity)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t* pEntity = GETEDICT(params[2]);
#if !defined __amd64__
*((int *)pHostage->pvPrivateData + OFFSET_HOSTAGEFOLLOW) = (int)pEntity;
@ -1274,21 +1004,11 @@ static cell AMX_NATIVE_CALL cs_get_weapon_ammo(AMX *amx, cell *params) // cs_get
// params[1] = weapon index
// Valid entity should be within range
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return *((int *)pWeapon->pvPrivateData + OFFSET_CLIPAMMO);
}
@ -1299,21 +1019,11 @@ static cell AMX_NATIVE_CALL cs_set_weapon_ammo(AMX *amx, cell *params) // cs_set
// params[2] = newammo
// Valid entity should be within range
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
*((int *)pWeapon->pvPrivateData + OFFSET_CLIPAMMO) = params[2];
return 1;
@ -1325,14 +1035,10 @@ static cell AMX_NATIVE_CALL cs_get_user_hasprimary(AMX *amx, cell *params) // cs
// params[1] = user index
// Check player
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = INDEXENT(params[1]);
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return *((int *)pPlayer->pvPrivateData + OFFSET_PRIMARYWEAPON);
}
@ -1351,6 +1057,104 @@ static cell AMX_NATIVE_CALL cs_set_no_knives(AMX *amx, cell *params) // cs_set_n
return 1;
}
// Damaged Soul
static cell AMX_NATIVE_CALL cs_get_user_tked(AMX *amx, cell *params) // cs_get_user_tked(index); = 1 param
{
// Return 1 if user has committed a team killing)
// params[1] = user index
// Check player
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return *((int *)pPlayer->pvPrivateData + OFFSET_TK);
}
// Damaged Soul
static cell AMX_NATIVE_CALL cs_set_user_tked(AMX *amx, cell *params) // cs_set_user_tked(index, tk = 1, subtract = 1); = 2 arguments
{
// Sets whether or not player has committed a TK.
// params[1] = user
// params[2] = 1: player has TKed, 0: player hasn't TKed
// params[3] = number of frags to subtract
// Check index
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if (params[2]) {
*((int *)pPlayer->pvPrivateData + OFFSET_TK) = 1;
} else {
*((int *)pPlayer->pvPrivateData + OFFSET_TK) = 0;
}
if (params[3]) {
pPlayer->v.frags = pPlayer->v.frags - params[3];
MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "ScoreInfo", NULL));
WRITE_BYTE(params[1]); // user index
WRITE_SHORT((int)pPlayer->v.frags); // frags
WRITE_SHORT(*((int *)pPlayer->pvPrivateData + OFFSET_CSDEATHS)); // deaths
WRITE_SHORT(0); // ?
WRITE_SHORT(*((int *)pPlayer->pvPrivateData + OFFSET_TEAM)); // team
MESSAGE_END();
}
return 1;
}
static cell AMX_NATIVE_CALL cs_get_user_driving(AMX *amx, cell *params) // cs_get_user_driving(index); = 1 param
{
// Returns different values depending on if user is driving a value - and if so at what speed.
// 0: no driving
// 1: driving, but standing still
// 2-4: different positive speeds
// 5: negative speed (backing)
// params[1] = user index
// Check player
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
// If player driving, return 1, if not, return 0
return *((int *)pPlayer->pvPrivateData + OFFSET_ISDRIVING);
}
static cell AMX_NATIVE_CALL cs_get_user_stationary(AMX *amx, cell *params) // cs_get_user_stationary(index); = 1 param
{
// Returns 1 if client is using a stationary guns (maybe also other stuff)
// Check player
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
// If player driving, return 1, if not, return 0
#if !defined __amd64__
return *((int *)pPlayer->pvPrivateData + OFFSET_STATIONARY);
#else
// The 32 bit server return 0 and 1 by itself from this offset, but the amd64 server has 2 and 3 respectively
// Doing a simple checking of these defined constants here, and mapping to 0 and 1, to keep our plugin authors sane.
// If an unexpected value is encountered, this will be logged.
if (AMD64_STATIONARY_NO == *((int *)pPlayer->pvPrivateData + OFFSET_STATIONARY))
return 0;
else if (AMD64_STATIONARY_YES == *((int *)pPlayer->pvPrivateData + OFFSET_STATIONARY))
return 1;
else {
MF_LogError(amx, AMX_ERR_NATIVE, "Unexpected value at offset. Please report this to development team @ www.amxmodx.org!");
return 0;
}
#endif
}
AMX_NATIVE_INFO cstrike_Exports[] = {
{"cs_set_user_money", cs_set_user_money},
{"cs_get_user_money", cs_get_user_money},
@ -1384,6 +1188,11 @@ AMX_NATIVE_INFO cstrike_Exports[] = {
{"cs_get_user_hasprim", cs_get_user_hasprimary},
{"cs_get_no_knives", cs_get_no_knives},
{"cs_set_no_knives", cs_set_no_knives},
{"cs_get_weapon_id", cs_get_weapon_id},
{"cs_get_user_tked", cs_get_user_tked},
{"cs_set_user_tked", cs_set_user_tked},
{"cs_get_user_driving", cs_get_user_driving},
{"cs_get_user_stationary", cs_get_user_stationary},
//------------------- <-- max 19 characters!
{NULL, NULL}
};

View File

@ -52,14 +52,18 @@
// "player" entities
#if !defined __amd64__
// 32 bit offsets here
#define OFFSET_TEAM 114 + EXTRAOFFSET
#define OFFSET_CSMONEY 115 + EXTRAOFFSET
#define OFFSET_PRIMARYWEAPON 116 + EXTRAOFFSET
#define OFFSET_INTERNALMODEL 126 + EXTRAOFFSET
#define OFFSET_NVGOGGLES 129 + EXTRAOFFSET
#define OFFSET_DEFUSE_PLANT 193 + EXTRAOFFSET
#define OFFSET_VIP 215 + EXTRAOFFSET
#define OFFSET_BUYZONE 241 + EXTRAOFFSET
#define OFFSET_VIP 209 + EXTRAOFFSET
#define OFFSET_TK 216 + EXTRAOFFSET // 040926
#define OFFSET_BUYZONE 235 + EXTRAOFFSET
#define OFFSET_ISDRIVING 350 + EXTRAOFFSET // 040926
#define OFFSET_STATIONARY 362 + EXTRAOFFSET // 040927 (363 works also!)
#define OFFSET_AWM_AMMO 382 + EXTRAOFFSET
#define OFFSET_SCOUT_AMMO 383 + EXTRAOFFSET
@ -76,7 +80,7 @@
#define OFFSET_SMOKE_AMMO 394 + EXTRAOFFSET
#define OFFSET_C4_AMMO 395 + EXTRAOFFSET
#define OFFSET_CSDEATHS 449 + EXTRAOFFSET
#define OFFSET_CSDEATHS 444 + EXTRAOFFSET // 040926
// "weapon_*" entities
#define OFFSET_WEAPONTYPE 43 + EXTRAOFFSET
#define OFFSET_CLIPAMMO 51 + EXTRAOFFSET
@ -85,6 +89,7 @@
#define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET
#define OFFSET_HOSTAGEID 487 + EXTRAOFFSET
#else
// Amd64 offsets here
#define OFFSET_TEAM 139 + EXTRAOFFSET // +25
#define OFFSET_CSMONEY 140 + EXTRAOFFSET // +25
#define OFFSET_PRIMARYWEAPON 141 + EXTRAOFFSET // +25
@ -92,7 +97,10 @@
#define OFFSET_NVGOGGLES 155 + EXTRAOFFSET // +26
#define OFFSET_DEFUSE_PLANT 219 + EXTRAOFFSET // +26
#define OFFSET_VIP 242 + EXTRAOFFSET // +27
#define OFFSET_TK 249 + EXTRAOFFSET // +33 040927
#define OFFSET_BUYZONE 268 + EXTRAOFFSET // +27
#define OFFSET_ISDRIVING 386 + EXTRAOFFSET // 040927
#define OFFSET_STATIONARY 400 + EXTRAOFFSET // 040927 (401 works also)
#define OFFSET_AWM_AMMO 426 + EXTRAOFFSET // +44
#define OFFSET_SCOUT_AMMO 427 + EXTRAOFFSET // +44
@ -109,13 +117,13 @@
#define OFFSET_SMOKE_AMMO 438 + EXTRAOFFSET // +44
#define OFFSET_C4_AMMO 439 + EXTRAOFFSET // +44
#define OFFSET_CSDEATHS 493 + EXTRAOFFSET // +44
#define OFFSET_CSDEATHS 493 + EXTRAOFFSET // +49
// "weapon_*" entities
#define OFFSET_WEAPONTYPE 57 + EXTRAOFFSET // +14
#define OFFSET_CLIPAMMO 65 + EXTRAOFFSET // +14
#define OFFSET_SILENCER_FIREMODE 88 + EXTRAOFFSET // +14
// "hostage_entity" entities
#define OFFSET_HOSTAGEFOLLOW 51 + EXTRAOFFSET // +21, long=51, int=107! (must use the long* offset becuase pointers on amd64 are stored the size of longs, 8 bytes, instead of the usual int 4 bytes.)
#define OFFSET_HOSTAGEFOLLOW 51 + EXTRAOFFSET // +21, long=51, int=107! (must use the long* offset because pointers on amd64 are stored the size of longs, 8 bytes, instead of the usual int 4 bytes.)
#define OFFSET_HOSTAGEID 516 + EXTRAOFFSET // +29
#endif
@ -184,6 +192,9 @@
#define SCOREATTRIB_BOMB 2 // t only
#define SCOREATTRIB_VIP 4 // ct only
#define AMD64_STATIONARY_NO 2
#define AMD64_STATIONARY_YES 3
enum CS_Internal_Models {
CS_DONTCHANGE = 0,
CS_CT_URBAN = 1,
@ -202,3 +213,46 @@ CCstrikePlayer g_players[33];
bool g_precachedknife = false;
bool g_noknives = false;
// Globals above
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))

View File

@ -118,6 +118,8 @@
TargetEnvironment="1"
TypeLibraryName=".\Release/cstrike.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
@ -212,6 +214,9 @@
RelativePath=".\moduleconfig.h">
</File>
</Filter>
<File
RelativePath="..\plugins\include\cstrike.inc">
</File>
</Files>
<Globals>
</Globals>

View File

@ -1,61 +0,0 @@
#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]);

View File

@ -1,515 +0,0 @@
/* AMX Mod X
* Misc. Stats Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
#include <amxmodx>
public MultiKill
public MultiKillSound
public BombPlanting
public BombDefusing
public BombPlanted
public BombDefused
public BombFailed
public BombPickUp
public BombDrop
public BombCountVoice
public BombCountDef
public BombReached
public ItalyBonusKill
public EnemyRemaining
public LastMan
public KnifeKill
public KnifeKillSound
public GrenadeKill
public GrenadeSuicide
public HeadShotKill
public HeadShotKillSound
public RoundCounterSound
public RoundCounter
public KillingStreak
public KillingStreakSound
public DoubleKill
public DoubleKillSound
public PlayerName
public FirstBloodSound
new g_streakKills[33][2]
new g_multiKills[33][2]
new g_C4Timer
new g_Defusing
new g_Planter
new Float:g_LastOmg
new g_LastAnnounce
new g_roundCount
new Float:g_doubleKill
new g_doubleKillId
new g_friend[33]
new g_firstBlood
new g_MultiKillMsg[7][] = {
"Multi-Kill! %s^n%L %d kills (%d hs)",
"Ultra-Kill!!! %s^n%L %d kills (%d hs)",
"%s IS ON A KILLING SPREE!!!^n%L %d kills (%d hs)",
"RAMPAGE!!! %s^n%L %d kills (%d hs)" ,
"%s IS UNSTOPPABLE!!!^n%L %d kills (%d hs)",
"%s IS A MONSTER!^n%L %d kills (%d hs)",
"%s IS GODLIKE!!!!^n%L %d kills (%d hs)"
}
new g_Sounds[7][] = {
"multikill",
"ultrakill",
"killingspree",
"rampage",
"unstoppable",
"monsterkill",
"godlike"
}
new g_KillingMsg[7][] = {
"%s: Multi-Kill!",
"%s: Ultra-Kill!!!",
"%s IS ON A KILLING SPREE!!!",
"%s: RAMPAGE!!!",
"%s IS UNSTOPPABLE!!!",
"%s IS A MONSTER!",
"%s IS GODLIKE!!!"
}
new g_KinfeMsg[4][] = {
"KNIFE_MSG_1",
"KNIFE_MSG_2",
"KNIFE_MSG_3",
"KNIFE_MSG_4"
}
new g_LastMessages[4][] = {
"LAST_MSG_1",
"LAST_MSG_2",
"LAST_MSG_3",
"LAST_MSG_4"
}
new g_HeMessages[4][] = {
"HE_MSG_1",
"HE_MSG_2",
"HE_MSG_3",
"HE_MSG_4"
}
new g_SHeMessages[4][] = {
"SHE_MSG_1",
"SHE_MSG_2",
"SHE_MSG_3",
"SHE_MSG_4"
}
new g_HeadShots[7][] = {
"HS_MSG_1",
"HS_MSG_2",
"HS_MSG_3",
"HS_MSG_4",
"HS_MSG_5",
"HS_MSG_6",
"HS_MSG_7"
}
new g_teamsNames[4][] = {
"TERRORIST",
"CT",
"TERRORISTS",
"CTS"
}
public plugin_init() {
register_plugin("CS Misc. Stats",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("miscstats.txt")
register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
register_event("RoundTime", "eNewRound", "bc")
register_event("StatusValue","setTeam","be","1=1")
register_event("StatusValue","showStatus","be","1=2","2!0")
register_event("StatusValue","hideStatus","be","1=1","2=0")
new mapname[32]
get_mapname(mapname,31)
if (equali(mapname,"de_",3)||equali(mapname,"csde_",5)) {
register_event("StatusIcon", "eGotBomb", "be", "1=1", "1=2", "2=c4")
register_event("TextMsg", "eBombPickUp", "bc", "2&#Got_bomb")
register_event("TextMsg", "eBombDrop", "bc", "2&#Game_bomb_d")
}
else if ( equali( mapname , "cs_italy" ) ) {
register_event( "23" , "chickenKill", "a" , "1=108" , /*"12=106",*/ "15=4" )
register_event( "23" , "radioKill", "a" , "1=108" , /*"12=294",*/ "15=2" )
}
}
public plugin_cfg() {
new g_addStast[] = "amx_statscfg add ^"%s^" %s"
server_cmd(g_addStast,"MultiKill","MultiKill")
server_cmd(g_addStast,"MultiKillSound","MultiKillSound")
server_cmd(g_addStast,"Bomb Planting","BombPlanting")
server_cmd(g_addStast,"Bomb Defusing","BombDefusing")
server_cmd(g_addStast,"Bomb Planted","BombPlanted")
server_cmd(g_addStast,"Bomb Defuse Succ.","BombDefused")
server_cmd(g_addStast,"Bomb Def. Failure","BombFailed")
server_cmd(g_addStast,"Bomb PickUp","BombPickUp")
server_cmd(g_addStast,"Bomb Drop","BombDrop")
server_cmd(g_addStast,"Bomb Count Down","BombCountVoice")
server_cmd(g_addStast,"Bomb Count Down (def)","BombCountDef")
server_cmd(g_addStast,"Bomb Site Reached","BombReached")
server_cmd(g_addStast,"Italy Bonus Kill","ItalyBonusKill")
server_cmd(g_addStast,"Last Man","LastMan")
server_cmd(g_addStast,"Knife Kill","KnifeKill")
server_cmd(g_addStast,"Knife Kill Sound","KnifeKillSound")
server_cmd(g_addStast,"Grenade Kill","GrenadeKill")
server_cmd(g_addStast,"Grenade Suicide","GrenadeSuicide")
server_cmd(g_addStast,"HeadShot Kill","HeadShotKill")
server_cmd(g_addStast,"HeadShot Kill Sound","HeadShotKillSound")
server_cmd(g_addStast,"Round Counter","RoundCounter")
server_cmd(g_addStast,"Round Counter Sound","RoundCounterSound")
server_cmd(g_addStast,"Killing Streak","KillingStreak")
server_cmd(g_addStast,"Killing Streak Sound","KillingStreakSound")
server_cmd(g_addStast,"Enemy Remaining","EnemyRemaining")
server_cmd(g_addStast,"Double Kill","DoubleKill")
server_cmd(g_addStast,"Double Kill Sound","DoubleKillSound")
server_cmd(g_addStast,"Player Name","PlayerName")
server_cmd(g_addStast,"First Blood Sound","FirstBloodSound")
}
public client_putinserver(id)
g_multiKills[id] = g_streakKills[ id ] = { 0 , 0 }
public client_death(killer,victim,wpnindex,hitplace,TK) {
new headshot = ( hitplace == HIT_HEAD ) ? 1:0
if ( g_firstBlood ) {
g_firstBlood = 0
if ( FirstBloodSound ) client_cmd(0,"spk misc/firstblood")
}
if ( (KillingStreak || KillingStreakSound) && !TK ) {
g_streakKills[ killer ][ 0 ]++
g_streakKills[ killer ][ 1 ] = 0
g_streakKills[ victim ][ 1 ]++
g_streakKills[ victim ][ 0 ] = 0
new a = g_streakKills[ killer ][ 0 ] - 3
if ( (a > -1) && !( a % 2 ) ) {
new name[32]
get_user_name( killer , name , 31 )
if ( (a >>= 1) > 6 ) a = 6
if ( KillingStreak ){
set_hudmessage(0, 100, 255, 0.05, 0.55, 2, 0.02, 6.0, 0.01, 0.1, 3)
show_hudmessage(0,g_KillingMsg[ a ], name )
}
if ( KillingStreakSound ) client_cmd( 0, "spk misc/%s", g_Sounds[ a ] )
}
}
if ( MultiKill || MultiKillSound ) {
if (killer && !TK ) {
g_multiKills[killer][0]++
g_multiKills[killer][1] += headshot
new param[2]
param[0] = killer
param[1] = g_multiKills[killer][0]
set_task( 4.0 + float( param[1] ) ,"checkKills",0,param,2)
}
}
if ( EnemyRemaining ) {
new ppl[32], pplnum
new team = get_user_team( victim ) - 1
get_players(ppl,pplnum,"e", g_teamsNames[1 - team] )
if (pplnum) {
new eppl[32], epplnum
get_players(eppl,epplnum,"ae",g_teamsNames[team])
if (epplnum) {
new message[128],team_name[32]
set_hudmessage(255,255,255,0.02,0.85,2, 0.05, 0.1, 0.02, 3.0, 3)
for(new a=0; a<pplnum; ++a){
format(team_name,31,"%L",ppl[a],(epplnum==1)?g_teamsNames[team]:g_teamsNames[team+2])
format(message,127,"%L",ppl[a],"REMAINING",epplnum,team_name)
show_hudmessage(ppl[a],message)
}
}
}
}
if ( LastMan ) {
new cts[32], ts[32], ctsnum, tsnum
get_players(cts,ctsnum,"ae", g_teamsNames[1] )
get_players(ts,tsnum,"ae", g_teamsNames[0] )
if ( ctsnum == 1 && tsnum == 1 ) {
new ctname[32], tname[32]
get_user_name(cts[0],ctname,31)
get_user_name(ts[0],tname,31)
set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"%s vs. %s",ctname,tname)
client_cmd(0,"spk misc/maytheforce")
}
else if ( !g_LastAnnounce ) {
new oposite = 0, team = 0
if ( ctsnum == 1 && tsnum > 1 ) {
g_LastAnnounce = cts[0]
oposite = tsnum
team = 0
}
else if ( tsnum == 1 && ctsnum > 1 ) {
g_LastAnnounce = ts[0]
oposite = ctsnum
team = 1
}
if (g_LastAnnounce) {
new name[32]
get_user_name(g_LastAnnounce,name,31)
set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"%s (%d HP) vs. %d %s%s: %L",name,
get_user_health(g_LastAnnounce),oposite,
g_teamsNames[team],(oposite==1)?"":"S",LANG_PLAYER,g_LastMessages[ random_num(0,3) ] )
client_cmd(g_LastAnnounce,"spk misc/oneandonly")
}
}
}
if ( wpnindex == 29 && ( KnifeKill || KnifeKillSound ) ) {
if ( KnifeKill ) {
new killer_name[32],victim_name[32]
get_user_name(killer,killer_name,31)
get_user_name(victim,victim_name,31)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0,"%L",LANG_PLAYER,g_KinfeMsg[ random_num(0,3) ],killer_name,victim_name)
}
if ( KnifeKillSound ) client_cmd(0,"spk misc/humiliation")
}
if ( wpnindex == 4 && (GrenadeKill || GrenadeSuicide) ) {
new killer_name[32],victim_name[32]
get_user_name(killer,killer_name,32)
get_user_name(victim,victim_name,32)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1)
if ( killer != victim ) {
if ( GrenadeKill ) show_hudmessage(0,"%L",LANG_PLAYER,g_HeMessages[ random_num(0,3)],killer_name,victim_name)
}
else if ( GrenadeSuicide ) show_hudmessage(0,"%L",LANG_PLAYER,g_SHeMessages[ random_num(0,3) ],victim_name)
}
if ( headshot && (HeadShotKill || HeadShotKillSound) ) {
if ( HeadShotKill ) {
new killer_name[32], victim_name[32], weapon_name[32], message[128], players[32], pnum
get_weaponname(wpnindex,weapon_name,31)
get_user_name(killer,killer_name,31)
get_user_name(victim,victim_name,31)
get_players(players,pnum,"c")
for (new i=0;i<pnum;i++) {
format( message, 127, "%L",players[i],g_HeadShots[ random_num(0,6) ] )
replace( message, 127 , "$vn", victim_name )
replace( message, 127 , "$wn", weapon_name )
replace( message, 127 , "$kn", killer_name )
set_hudmessage(100, 100, 255, -1.0, 0.29, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(players[i],message )
}
}
if ( HeadShotKillSound ) {
client_cmd(killer,"spk misc/headshot")
client_cmd(victim,"spk misc/headshot")
}
}
if ( DoubleKill || DoubleKillSound ) {
new Float:nowtime = get_gametime()
if ( g_doubleKill == nowtime && g_doubleKillId == killer ) {
if ( DoubleKill ) {
new name[32]
get_user_name( killer , name , 31 )
set_hudmessage(255, 0, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"%L",LANG_PLAYER,"DOUBLE_KILL",name )
}
if ( DoubleKillSound ) client_cmd(0,"spk misc/doublekill")
}
g_doubleKill = nowtime
g_doubleKillId = killer
}
}
public hideStatus(id) {
if ( PlayerName ) {
set_hudmessage(0,0,0,0.0,0.0,0, 0.0, 0.01, 0.0, 0.0, 4)
show_hudmessage(id,"")
}
}
public setTeam(id)
g_friend[id] = read_data(2)
public showStatus(id) {
if ( PlayerName ) {
new name[32],pid = read_data(2)
get_user_name(pid,name,31)
new color1 = 0,color2 = 0
if ( get_user_team(pid)==1 )
color1 = 255
else
color2 = 255
if (g_friend[id]==1) { // friend
new clip, ammo, wpnid = get_user_weapon(pid,clip,ammo)
new wpnname[32]
get_weaponname(wpnid,wpnname,31)
set_hudmessage(color1,50,color2,-1.0,0.60,1, 0.01, 3.0, 0.01, 0.01, 4)
show_hudmessage(id,"%s -- %d HP / %d AP / %s",name,
get_user_health(pid),get_user_armor(pid),wpnname[7])
}
else {
set_hudmessage(color1,50,color2,-1.0,0.60,1, 0.01, 3.0, 0.01, 0.01, 4)
show_hudmessage(id,name)
}
}
}
public eNewRound()
if ( read_data(1) == floatround(get_cvar_float("mp_roundtime") * 60.0) ) {
g_firstBlood = 1
g_C4Timer = 0
++g_roundCount
if ( RoundCounter ) {
set_hudmessage(200, 0, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0, "%L", LANG_PLAYER, "PREPARE_FIGHT", g_roundCount )
}
if ( RoundCounterSound ) client_cmd( 0 , "spk misc/prepare" )
if ( KillingStreak ) {
new appl[32],ppl, i
get_players(appl,ppl, "ac" )
for (new a = 0; a < ppl; ++a) {
i = appl[ a ]
if ( g_streakKills[ i ][ 0 ] >= 2 )
client_print( i , print_chat , "* %L", i, "KILLED_ROW", g_streakKills[ i ][ 0 ] )
else if ( g_streakKills[ i ][ 1 ] >= 2 )
client_print( i , print_chat , "* %L", i, "DIED_ROUNDS", g_streakKills[ i ][ 1 ] )
}
}
}
public eRestart() {
eEndRound()
g_roundCount = 0
g_firstBlood = 1
}
public eEndRound() {
g_C4Timer = -2
g_LastOmg = 0.0
remove_task(8038)
g_LastAnnounce = 0
}
public checkKills(param[]) {
new id = param[0]
new a = param[1]
if (a == g_multiKills[id][0]) {
a -= 3
if ( a > -1 ) {
if ( MultiKill ) {
new name[32]
get_user_name(id,name,31)
set_hudmessage(255, 0, 100, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2)
if ( a > 6 ) a = 6
show_hudmessage(0,g_MultiKillMsg[a],name,LANG_PLAYER,"WITH",g_multiKills[id][0],g_multiKills[id][1])
}
if ( MultiKillSound ) client_cmd(0,"spk misc/%s",g_Sounds[a])
}
g_multiKills[id] = { 0,0 }
}
}
public chickenKill()
if ( ItalyBonusKill ) announceEvent( 0 , "KILLED_CHICKEN" )
public radioKill() {
if ( ItalyBonusKill ) announceEvent( 0 , "BLEW_RADIO" )
}
announceEvent( id, message[] ) {
new name[32]
get_user_name(id, name , 31)
set_hudmessage(255, 100, 50, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0,"%L",LANG_PLAYER,message,name)
}
public eBombPickUp(id)
if (BombPickUp) announceEvent(id , "PICKED_BOMB")
public eBombDrop()
if (BombDrop) announceEvent(g_Planter , "DROPPED_BOMB")
public eGotBomb(id) {
g_Planter = id
if ( BombReached && read_data(1)==2 && g_LastOmg<get_gametime()) {
g_LastOmg = get_gametime() + 15.0
announceEvent(g_Planter, "REACHED_TARGET" )
}
}
public bombTimer() {
if (--g_C4Timer > 0) {
if (BombCountVoice) {
if (g_C4Timer == 30 || g_C4Timer == 20) {
new temp[48]
num_to_word(g_C4Timer,temp,47)
client_cmd(0,"spk ^"vox/%s seconds until explosion^"",temp)
}
else if (g_C4Timer < 11) {
new temp[48]
num_to_word(g_C4Timer,temp,47)
client_cmd(0,"spk ^"vox/%s^"",temp)
}
}
if (BombCountDef && g_Defusing) client_print(g_Defusing,print_center,"%d",g_C4Timer)
}
else remove_task(8038)
}
public bomb_planted(planter){
g_Defusing = 0
if (BombPlanted) announceEvent(planter, "SET_UP_BOMB" )
g_C4Timer = get_cvar_num("mp_c4timer")
set_task(1.0,"bombTimer",8038,"",0,"b")
}
public bomb_planting(planter)
if (BombPlanting) announceEvent(planter, "PLANT_BOMB" )
public bomb_defusing(defuser){
if (BombDefusing) announceEvent(defuser, "DEFUSING_BOMB" )
g_Defusing = defuser
}
public bomb_defused(defuser)
if (BombDefused) announceEvent(defuser, "DEFUSED_BOMB" )
public bomb_explode(planter,defuser)
if (BombFailed && defuser) announceEvent(defuser , "FAILED_DEFU" )
public plugin_modules()
{
require_module("csx")
}

View File

@ -1,44 +0,0 @@
[en]
WITH = with
KNIFE_MSG_1 = %s sliced and diced %s
KNIFE_MSG_2 = %s pulled out knife and gutted %s
KNIFE_MSG_3 = %s sneaks carefully behind and knifed %s
KNIFE_MSG_4 = %s knived %s
LAST_MSG_1 = Now all depend on you!
LAST_MSG_2 = I hope you still have a healthpack.
LAST_MSG_3 = All your teammates were killed. Good luck!
LAST_MSG_4 = Now you are alone. Have fun!
HE_MSG_1 = %s sends a little gift to %s
HE_MSG_2 = %s throws a small present to %s
HE_MSG_3 = %s made a precision throw to %s
HE_MSG_4 = %s got a big explosion for %s
SHE_MSG_1 = %s detonated himself with a grenade
SHE_MSG_2 = %s trys the effect of an HE Grenade
SHE_MSG_3 = %s swallows grenades whole!
SHE_MSG_4 = %s explodes!
HS_MSG_1 = $kn killed $vn with a well^nplaced shot to the head!
HS_MSG_2 = $kn removed $vn's^nhead with the $wn
HS_MSG_3 = $kn turned $vn's head^ninto pudding with the $wn
HS_MSG_4 = $vn got pwned by $kn
HS_MSG_5 = $vn's head has been^nturned into red jello
HS_MSG_6 = $kn has superb aim with the $wn,^nas $vn well knows.
HS_MSG_7 = $vn's head stayed in $kn's^ncrosshairs a bit too long...
DOUBLE_KILL = Wow! %s made a double kill!!!
PREPARE_FIGHT = Prepare to FIGHT!^nRound %d
KILLED_ROW = You've killed %d in a row so far
DIED_ROUNDS = Careful! You've died %d rounds in a row now...
KILLED_CHICKEN = Somebody killed a chicken!!!
BLEW_RADIO = Somebody blew up the radio!!!
REACHED_TARGET = Omg! %s reached the target!
PLANT_BOMB = %s is planting the bomb!
DEFUSING_BOMB = %s is defusing the bomb...
SET_UP_BOMB = %s set us up the bomb!!!
DEFUSED_BOMB = %s defused the bomb!
FAILED_DEFU = %s failed to defuse the bomb...
PICKED_BOMB = %s picked up the bomb...
DROPPED_BOMB = %s dropped the bomb!!!
CT = CT
CTS = CTS
TERRORIST = TERRORIST
TERRORISTS = TERRORISTS
REMAINING = %d %s Remaining...

File diff suppressed because it is too large Load Diff

178
dlls/csx/source/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 = "csx_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`;

View File

@ -45,6 +45,16 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2439,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2453,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2525,6 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2560,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2572,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2629,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2649,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2664,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1986,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2026,6 +2033,7 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2045,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2059,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2094,11 +2106,14 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2108,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2133,7 +2149,7 @@ void MF_Log(const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format;
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -110,6 +110,18 @@ const char* get_localinfo( const char* name , const char* def = 0 )
return b;
}
void ClientKill(edict_t *pEntity){
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if ( !pPlayer->IsAlive())
RETURN_META(MRES_IGNORED);
MF_ExecuteForward( iFDamage,pPlayer->index , pPlayer->index , 0, 0, 0, 0 );
pPlayer->saveKill(pPlayer,0,0,0);
MF_ExecuteForward( iFDeath,pPlayer->index, pPlayer->index, 0, 0, 0 );
RETURN_META(MRES_IGNORED);
}
void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){
rankBots = (int)csstats_rankbots->value ? true:false;

View File

@ -6,7 +6,7 @@
// Module info
#define MODULE_NAME "CSX"
#define MODULE_VERSION "0.20"
#define MODULE_AUTHOR "AMXx Dev Team"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org/"
#define MODULE_LOGTAG "CSX"
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
@ -70,7 +70,7 @@
// #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_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 */
@ -332,7 +332,7 @@
// #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_EmitSound_Post EmitSound_Post
// #define FN_EmitAmbientSound_Post EmitAmbientSound_Post
#define FN_TraceLine_Post TraceLine_Post
// #define FN_TraceToss_Post TraceToss_Post

21
dlls/csx/source/msvc/csx.sln Executable file
View File

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csx", "csx.vcproj", "{1DC4A99A-F23F-4AAE-881C-79D157C91155}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{1DC4A99A-F23F-4AAE-881C-79D157C91155}.Debug.ActiveCfg = Debug|Win32
{1DC4A99A-F23F-4AAE-881C-79D157C91155}.Debug.Build.0 = Debug|Win32
{1DC4A99A-F23F-4AAE-881C-79D157C91155}.Release.ActiveCfg = Release|Win32
{1DC4A99A-F23F-4AAE-881C-79D157C91155}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

311
dlls/csx/source/msvc/csx.vcproj Executable file
View File

@ -0,0 +1,311 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="csx"
ProjectGUID="{1DC4A99A-F23F-4AAE-881C-79D157C91155}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<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;csx_EXPORTS;JIT"
StringPooling="TRUE"
RuntimeLibrary="0"
StructMemberAlignment="3"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\release/csx.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="release/csx_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\release/csx_amxx.pdb"
ImportLibrary=".\release/csx_amxx.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\release/csx.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>
<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;csx_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\debug/csx.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/csx_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\debug/csx_amxx.pdb"
ImportLibrary=".\debug/csx_amxx.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\debug/csx.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>
</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="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\CMisc.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\CRank.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\meta_api.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\rank.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\usermsg.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
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>

View File

@ -7,15 +7,9 @@
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;
}
CHECK_PLAYERRANGE(index);
int attacker = params[2];
if (attacker<0||attacker>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYERRANGE(attacker);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->attackers[attacker].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -40,15 +34,9 @@ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param *
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;
}
CHECK_PLAYERRANGE(index);
int victim = params[2];
if (victim<0||victim>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYERRANGE(victim);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->victims[victim].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -73,13 +61,10 @@ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param *
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;
}
CHECK_PLAYERRANGE(index);
int weapon = params[2];
if (weapon<0||weapon>=MAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
if (weapon<0||weapon>=MAX_WEAPONS+MAX_CWEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -104,13 +89,10 @@ static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param
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;
}
CHECK_PLAYERRANGE(index);
int weapon = params[2];
if (weapon<0||weapon>=MAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
if (weapon<0||weapon>=MAX_WEAPONS+MAX_CWEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -135,10 +117,7 @@ static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param *
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;
}
CHECK_PLAYER(index);
GET_PLAYER_POINTER_I(index)->restartStats();
return 1;
}
@ -146,10 +125,7 @@ static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param
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;
}
CHECK_PLAYERRANGE(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->rank){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -171,10 +147,7 @@ static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param *
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;
}
CHECK_PLAYERRANGE(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -200,10 +173,7 @@ static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
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;
}
CHECK_PLAYERRANGE(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -297,32 +267,25 @@ static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,melee
static cell AMX_NATIVE_CALL custom_wpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
int weapon = params[1];
if ( weapon < MAX_WEAPONS || weapon >= MAX_WEAPONS+MAX_CWEAPONS || !weaponData[weapon].used ){ // only for custom weapons
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
return 0;
}
int att = params[2];
if (att<1||att>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYERRANGE(att);
int vic = params[3];
if (vic<1||vic>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYERRANGE(vic);
int dmg = params[4];
if ( dmg<1 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid damage %d", dmg);
return 0;
}
int aim = params[5];
if ( aim < 0 || aim > 7 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim);
return 0;
}
@ -349,15 +312,11 @@ static cell AMX_NATIVE_CALL custom_wpn_dmg(AMX *amx, cell *params){ // wid,att,v
static cell AMX_NATIVE_CALL custom_wpn_shot(AMX *amx, cell *params){ // player,wid
int index = params[2];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYERRANGE(index);
int weapon = params[1];
if ( weapon < MAX_WEAPONS || weapon >= MAX_WEAPONS+MAX_CWEAPONS || !weaponData[weapon].used ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
return 0;
}
@ -370,8 +329,7 @@ static cell AMX_NATIVE_CALL custom_wpn_shot(AMX *amx, cell *params){ // player,w
static cell AMX_NATIVE_CALL get_wpnname(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>=MAX_WEAPONS+MAX_CWEAPONS ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]);
@ -380,8 +338,7 @@ static cell AMX_NATIVE_CALL get_wpnname(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_wpnlogname(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>=MAX_WEAPONS+MAX_CWEAPONS ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].logname,params[3]);
@ -390,8 +347,7 @@ static cell AMX_NATIVE_CALL get_wpnlogname(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL is_melee(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>=MAX_WEAPONS+MAX_CWEAPONS ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
return 0;
}
if ( id == 29 )
@ -433,7 +389,7 @@ AMX_NATIVE_INFO stats_Natives[] = {
{ "xmod_get_stats_size", get_stats_size },
//***************************************
{ "get_weaponname", get_wpnname },
//{ "get_weaponname", get_wpnname },
///*******************
{ NULL, NULL }

View File

@ -1,6 +1,3 @@
#ifndef RANK_H
#define RANK_H
@ -99,6 +96,56 @@ void Client_BarTime(void*);
bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL );
bool isModuleActive();
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_PLAYERRANGE(x) \
if (x > gpGlobals->maxClients || x < 0) \
{ \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
#endif // RANK_H

View File

@ -9,8 +9,9 @@ int weapon;
int aim;
CPlayer *pAttacker;
void Client_ResetHUD(void* mValue){
if ( mPlayer && mPlayer->IsAlive() )
if ( mPlayer )
mPlayer->clearStats = gpGlobals->time + 0.25f;
}

View File

@ -34,10 +34,7 @@
static cell AMX_NATIVE_CALL set_player_stamina(AMX *amx, cell *params){ // id,(re)set,min,max
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index)
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( params[2] ){ // 0 set , 1 reset
@ -49,12 +46,12 @@ static cell AMX_NATIVE_CALL set_player_stamina(AMX *amx, cell *params){ // id,(r
int min = params[3];
if ( min<0 || min>100 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid minimum stamina %d", min);
return 0;
}
int max = params[4];
if ( max<min || max>100 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid maximum stamina %d", max);
return 0;
}
if ( pPlayer->ingame ){
@ -68,10 +65,7 @@ static cell AMX_NATIVE_CALL set_player_stamina(AMX *amx, cell *params){ // id,(r
static cell AMX_NATIVE_CALL nade_set_fuse(AMX *amx, cell *params){ // id,(re)set,time,type
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( params[2] ){ // 0 set , 1 reset
@ -82,7 +76,7 @@ static cell AMX_NATIVE_CALL nade_set_fuse(AMX *amx, cell *params){ // id,(re)set
float fFuse = *(float *)((void *)&params[3]);
if ( fFuse<0.1 || fFuse>20.0 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid fuse %f", fFuse);
return 0;
}
@ -97,30 +91,10 @@ static cell AMX_NATIVE_CALL nade_set_fuse(AMX *amx, cell *params){ // id,(re)set
return 0;
}
static cell AMX_NATIVE_CALL dod_get_wpninfo(AMX *amx, cell *params){ // id
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);
//weapon_data_t wdata;
//mm_DispatchThink(pPlayer->pEdict);
//mm_GetWeaponData(pPlayer->pEdict,&wdata);
//MF_PrintSrvConsole("%d \n",wdata.iuser1);
return 1;
}
AMX_NATIVE_INFO base_Natives[] = {
{ "dod_set_stamina", set_player_stamina },
{ "dod_set_fuse", nade_set_fuse },
{ "dod_get_wpninfo", dod_get_wpninfo },
///*******************
{ NULL, NULL }
};

View File

@ -34,10 +34,7 @@
static cell AMX_NATIVE_CALL set_user_class(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index)
int iClass = params[2];
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -59,13 +56,10 @@ static cell AMX_NATIVE_CALL set_user_class(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL set_user_team(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
int iTeam = params[2];
if ( iTeam<1 || iTeam>3 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid team id %d", iTeam);
return 0;
}
@ -101,10 +95,7 @@ static cell AMX_NATIVE_CALL set_user_team(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_nextclass(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->ingame ){
@ -116,10 +107,7 @@ static cell AMX_NATIVE_CALL get_user_nextclass(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL is_randomclass(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->ingame ){
@ -130,23 +118,17 @@ static cell AMX_NATIVE_CALL is_randomclass(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_deaths(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
return *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_DEATHS );
}
return 0;
return -1;
}
static cell AMX_NATIVE_CALL set_user_deaths(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
*( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_DEATHS ) = params[2];
@ -166,10 +148,7 @@ static cell AMX_NATIVE_CALL set_user_deaths(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL set_user_score(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
@ -190,12 +169,42 @@ static cell AMX_NATIVE_CALL set_user_score(AMX *amx, cell *params){
return 1;
}
static cell AMX_NATIVE_CALL set_user_frags(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
pPlayer->pEdict->v.frags = (float)params[2];
if ( params[3]){
//ScoreShort message
MESSAGE_BEGIN(MSG_ALL,gmsgScoreShort);
WRITE_BYTE(pPlayer->index);
WRITE_SHORT( *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_SCORE ) );
WRITE_SHORT((int)pPlayer->pEdict->v.frags);
WRITE_SHORT( *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_DEATHS ) );
WRITE_BYTE(1);
MESSAGE_END();
}
}
return 1;
}
static cell AMX_NATIVE_CALL get_user_frags(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
return (int)pPlayer->pEdict->v.frags;
return -1;
}
static cell AMX_NATIVE_CALL set_user_teamname(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -213,10 +222,7 @@ static cell AMX_NATIVE_CALL set_user_teamname(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_teamname(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -234,10 +240,7 @@ static cell AMX_NATIVE_CALL get_user_teamname(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL is_weapon_deployed(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
if ( *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_WDEPLOY) == 1 )
@ -249,10 +252,7 @@ static cell AMX_NATIVE_CALL is_weapon_deployed(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL set_user_ammo(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( !pPlayer->ingame )
@ -356,10 +356,7 @@ static cell AMX_NATIVE_CALL set_user_ammo(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_ammo(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( !pPlayer->ingame )
@ -445,10 +442,7 @@ static cell AMX_NATIVE_CALL get_user_ammo(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL test_pd(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
int type = params[2];
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
@ -487,6 +481,9 @@ AMX_NATIVE_INFO pd_Natives[] = {
{ "dod_get_user_ammo", get_user_ammo },
{ "dod_set_user_ammo", set_user_ammo },
{ "dod_get_user_kills", get_user_frags },
{ "dod_set_user_kills", set_user_frags },
{ "dod_test_pd", test_pd },
///*******************
{ NULL, NULL }

View File

@ -45,6 +45,16 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2439,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2453,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2525,6 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2560,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2572,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2629,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2649,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2664,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1986,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2026,6 +2033,7 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2045,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2059,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2094,11 +2106,14 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2108,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2133,7 +2149,7 @@ void MF_Log(const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format;
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -58,6 +58,49 @@ extern CPlayer* mPlayer;
edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName);
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
#endif // DODFUN_H

View File

@ -35,7 +35,7 @@
static cell AMX_NATIVE_CALL get_weapon_name(AMX *amx, cell *params){ // from id to name 3 params id, name, len
int id = params[1];
if (id<0 || id>=DODMAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]);
@ -67,7 +67,7 @@ static cell AMX_NATIVE_CALL wpnlog_to_id(AMX *amx, cell *params){ // from log to
static cell AMX_NATIVE_CALL get_weapon_logname(AMX *amx, cell *params){ // from id to log
int id = params[1];
if (id<0 || id>=DODMAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].logname,params[3]);
@ -76,7 +76,7 @@ static cell AMX_NATIVE_CALL get_weapon_logname(AMX *amx, cell *params){ // from
static cell AMX_NATIVE_CALL is_melee(AMX *amx, cell *params){
int id = params[1];
if (id<0 || id>=DODMAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
return 0;
}
return weaponData[id].melee;
@ -97,10 +97,7 @@ static cell AMX_NATIVE_CALL get_team_score(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_score(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return -1;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
return pPlayer->savedScore;
@ -109,10 +106,7 @@ static cell AMX_NATIVE_CALL get_user_score(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_class(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
return pPlayer->pEdict->v.playerclass;
@ -121,10 +115,7 @@ static cell AMX_NATIVE_CALL get_user_class(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL user_kill(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame && pPlayer->IsAlive() ){
@ -147,7 +138,7 @@ static cell AMX_NATIVE_CALL get_map_info(AMX *amx, cell *params){
return g_map.detect_axis_paras;
break;
default:
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid map info id %d", params[1]);
break;
}
return -1;
@ -155,10 +146,7 @@ static cell AMX_NATIVE_CALL get_map_info(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_pronestate(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
return pPlayer->pEdict->v.iuser3;
@ -168,10 +156,7 @@ static cell AMX_NATIVE_CALL get_user_pronestate(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
int wpn = pPlayer->current;
@ -190,30 +175,31 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
#ifdef FORWARD_OLD_SYSTEM
int iFunctionIndex;
int err;
switch( params[1] ){
case 0:
if( MF_AmxFindPublic(amx, "client_damage", &iFunctionIndex) == AMX_ERR_NONE )
if( (err=MF_AmxFindPublic(amx, "client_damage", &iFunctionIndex)) == AMX_ERR_NONE )
g_damage_info.put( amx , iFunctionIndex );
else
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, err, "client_damage not found");
return 0;
break;
case 1:
if( MF_AmxFindPublic(amx, "client_death", &iFunctionIndex) == AMX_ERR_NONE )
if( (err=MF_AmxFindPublic(amx, "client_death", &iFunctionIndex)) == AMX_ERR_NONE )
g_death_info.put( amx , iFunctionIndex );
else
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, err, "client_Death not found");
return 0;
break;
case 2:
if( MF_AmxFindPublic(amx, "client_score", &iFunctionIndex) == AMX_ERR_NONE )
if( (err=MF_AmxFindPublic(amx, "client_score", &iFunctionIndex)) == AMX_ERR_NONE )
g_score_info.put( amx , iFunctionIndex );
else
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, err, "client_score not found");
return 0;
break;
default:
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid forward id %d", params[2]);
return 0;
}
#endif
@ -248,31 +234,25 @@ static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logna
static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
int weapon = params[1];
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){ // only for custom weapons
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon);
return 0;
}
int att = params[2];
if (att<1||att>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[2]);
int vic = params[3];
if (vic<1||vic>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[3]);
int dmg = params[4];
if ( dmg<1 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid damage %d", dmg);
return 0;
}
int aim = params[5];
if ( aim < 0 || aim > 7 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim);
return 0;
}
@ -305,22 +285,18 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg
#else
MF_ExecuteForward( iFDeath,pAtt->index, pVic->index, weapon, aim, TA );
#endif
return 1;
}
static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid
int index = params[2];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
int weapon = params[1];
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon);
return 0;
}
@ -348,10 +324,7 @@ static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL dod_get_user_team(AMX *amx, cell *params){ // player,wid
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
return pPlayer->pEdict->v.team;
@ -360,10 +333,7 @@ static cell AMX_NATIVE_CALL dod_get_user_team(AMX *amx, cell *params){ // player
static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params){ // player,wid
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
int iTeam = pPlayer->pEdict->v.team;

View File

@ -35,15 +35,9 @@
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;
}
CHECK_PLAYERRANGE(index);
int attacker = params[2];
if (attacker<0||attacker>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYERRANGE(attacker);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->attackers[attacker].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -68,15 +62,9 @@ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param *
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;
}
CHECK_PLAYERRANGE(index);
int victim = params[2];
if (victim<0||victim>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYERRANGE(victim);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->victims[victim].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -101,13 +89,10 @@ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param *
static cell AMX_NATIVE_CALL get_user_wlstats(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;
}
CHECK_PLAYERRANGE(index);
int weapon = params[2];
if (weapon<0||weapon>=DODMAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -133,13 +118,10 @@ static cell AMX_NATIVE_CALL get_user_wlstats(AMX *amx, cell *params) /* 4 param
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;
}
CHECK_PLAYERRANGE(index)
int weapon = params[2];
if (weapon<0||weapon>=DODMAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -165,13 +147,10 @@ static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param
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;
}
CHECK_PLAYERRANGE(index)
int weapon = params[2];
if (weapon<0||weapon>=DODMAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -197,10 +176,7 @@ static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param *
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;
}
CHECK_PLAYERRANGE(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
pPlayer->restartStats();
return 1;
@ -209,10 +185,7 @@ static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param
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;
}
CHECK_PLAYERRANGE(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->ingame ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -237,10 +210,7 @@ static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
static cell AMX_NATIVE_CALL get_user_lstats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYERRANGE(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -263,10 +233,7 @@ static cell AMX_NATIVE_CALL get_user_lstats(AMX *amx, cell *params) /* 3 param *
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;
}
CHECK_PLAYERRANGE(index)
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);

View File

@ -45,6 +45,16 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2439,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2453,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2525,6 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2560,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2572,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2629,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2649,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2664,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1986,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2026,6 +2033,7 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2045,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2059,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2094,11 +2106,14 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2108,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2133,7 +2149,7 @@ void MF_Log(const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format;
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -111,6 +111,54 @@ bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL );
bool isModuleActive();
edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName);
#endif // DODX_H
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_PLAYERRANGE(x) \
if (x > gpGlobals->maxClients || x < 0) \
{ \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
#endif // DODX_H

View File

@ -11,17 +11,6 @@ int AmxStringToEngine(AMX *amx, cell param, int &len)
return ALLOC_STRING(szString);
}
void EngineError(AMX *amx, char *fmt, ...)
{
va_list p;
va_start(p, fmt);
char errbuf[512];
vsprintf(errbuf, fmt, p);
va_end(p);
MF_Log("%s (\"%s\", line %d)", errbuf, MF_GetScriptName(MF_FindScriptByAmx(amx)), amx->curline);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
}
void ClearHooks()
{
register unsigned int i = 0;
@ -101,8 +90,8 @@ void OnPluginsLoaded()
g_pFunctionTable->pfnPlayerPostThink=PlayerPostThink_Post;
g_pFunctionTable->pfnSpawn=NULL; // "pfn_spawn"
if (CheckForPublic("pfn_spawn"))
g_pFunctionTable->pfnSpawn=Spawn;
//if (CheckForPublic("pfn_spawn")) // JGHG: I commented this if out because we always need the Spawn to precache the rocket mdl used with SetView native
g_pFunctionTable->pfnSpawn=Spawn;
g_pFunctionTable->pfnClientKill=NULL; // "client_kill"
if (CheckForPublic("client_kill"))
@ -240,7 +229,7 @@ void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
Msg.clear();
register int i = 0, j = 0;
for (i=0; i<256; i++) {
for (j=0; j<msgHooks[i].size(); j++)
for (j=0; j<(int)msgHooks[i].size(); j++)
if (msgHooks[i].at(j) != -1)
MF_UnregisterSPForward(msgHooks[i].at(j));
msgHooks[i].clear();

View File

@ -32,8 +32,6 @@
* Description: AMX Mod X Module Interface Functions
*/
#include <string.h>
#include <new>
#include <stdarg.h>
@ -53,6 +51,9 @@ DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
@ -2207,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2224,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2451,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2465,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2489,6 +2496,11 @@ PFN_CELL_TO_REAL g_fn_CellToReal;
PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward;
PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName;
PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format;
// *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2532,6 +2544,9 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
// Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2539,7 +2554,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("FindAmxScriptByName", g_fn_FindAmxScriptByName, PFN_FIND_AMXSCRIPT_BYNAME);
REQFUNC("LoadAmxScript", g_fn_LoadAmxScript, PFN_LOAD_AMXSCRIPT);
REQFUNC("UnloadAmxScript", g_fn_UnloadAmxScript, PFN_UNLOAD_AMXSCRIPT);
REQFUNC("GetAmxScriptName", g_fn_GetAmxScriptName, PFN_GET_AMXSCRIPTNAME);
REQFUNC("GetAmxScriptName", g_fn_GetAmxScriptName, PFN_GET_AMXSCRIPTNAME);
// String / mem in amx scripts support
REQFUNC("SetAmxString", g_fn_SetAmxString, PFN_SET_AMXSTRING);
@ -2553,6 +2568,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("amx_Execv", g_fn_AmxExecv, PFN_AMX_EXECV);
REQFUNC("amx_FindPublic", g_fn_AmxFindPublic, PFN_AMX_FINDPUBLIC);
REQFUNC("amx_Allot", g_fn_AmxAllot, PFN_AMX_ALLOT);
REQFUNC("amx_FindNative", g_fn_AmxFindNative, PFN_AMX_FINDNATIVE);
// Natives / Forwards
REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES);
@ -2564,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2576,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2585,6 +2603,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("IsPlayerHLTV", g_fn_IsPlayerHLTV, PFN_IS_PLAYER_HLTV);
REQFUNC("GetPlayerArmor", g_fn_GetPlayerArmor, PFN_GET_PLAYER_ARMOR);
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
// Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
@ -2631,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2651,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2666,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);
@ -2679,11 +2715,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_AmxExecv(0, 0, 0, 0, 0);
MF_AmxFindPublic(0, 0, 0);
MF_AmxAllot(0, 0, 0, 0);
MF_LoadAmxScript(0, 0, 0, 0);
MF_LoadAmxScript(0, 0, 0, 0, 0);
MF_UnloadAmxScript(0, 0);
MF_RegisterSPForward(0, 0, 0, 0, 0, 0);
MF_RegisterSPForwardByName(0, 0, 0, 0, 0, 0);
MF_UnregisterSPForward(0);
MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0);
MF_Format("", 4, "str");
}
#endif

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1944,6 +1948,12 @@ typedef int (*PFN_IS_PLAYER_CONNECTING) (int /*id*/);
typedef int (*PFN_IS_PLAYER_HLTV) (int /*id*/);
typedef int (*PFN_GET_PLAYER_ARMOR) (int /*id*/);
typedef int (*PFN_GET_PLAYER_HEALTH) (int /*id*/);
#ifdef USE_METAMOD
typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#else
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#endif
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const size_t /*size*/);
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
@ -1955,7 +1965,7 @@ typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*in
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
typedef int (*PFN_AMX_FINDNATIVE) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
typedef int (*PFN_LOAD_AMXSCRIPT) (AMX* /*amx*/, void** /*code*/, const char* /*path*/, char[64] /*error info*/);
typedef int (*PFN_LOAD_AMXSCRIPT) (AMX* /*amx*/, void** /*code*/, const char* /*path*/, char[64] /*error info*/, int /* debug */);
typedef int (*PFN_UNLOAD_AMXSCRIPT) (AMX* /*amx*/,void** /*code*/);
typedef cell (*PFN_REAL_TO_CELL) (REAL /*x*/);
typedef REAL (*PFN_CELL_TO_REAL) (cell /*x*/);
@ -1963,6 +1973,7 @@ typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*pa
typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/);
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -1979,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2017,6 +2031,9 @@ extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
extern PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2036,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2050,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2066,6 +2087,8 @@ int MF_RegisterSPForwardByName (AMX * amx, const char *str, ...) { }
int MF_RegisterSPForward (AMX * amx, int func, ...) { }
void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { }
#endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives
@ -2083,11 +2106,14 @@ int MF_GetPlayerFlags (int id) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2097,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2121,6 +2148,8 @@ void MF_Log(const char *fmt, ...);
#define MF_RegisterSPForward g_fn_RegisterSPForward
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -105,10 +105,7 @@ static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params)
cell *vRet = MF_GetAmxAddr(amx, params[3]);
Vector vVector = Vector(0, 0, 0);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -329,8 +326,8 @@ static cell AMX_NATIVE_CALL set_speak(AMX *amx, cell *params) {
int iIndex = params[1];
int iNewSpeakFlags = params[2];
if (iIndex> gpGlobals->maxClients || !is_ent_valid(iIndex)) {
EngineError(amx, "Invalid player %d", iIndex);
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
return 0;
}
@ -342,8 +339,8 @@ static cell AMX_NATIVE_CALL set_speak(AMX *amx, cell *params) {
static cell AMX_NATIVE_CALL get_speak(AMX *amx, cell *params) {
int iIndex = params[1];
if (!is_ent_valid(iIndex) || iIndex > gpGlobals->maxClients) {
EngineError(amx, "Invalid player %d", iIndex);
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
return 0;
}
@ -369,10 +366,7 @@ static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params)
{
int iEnt = params[1];
if (FNullEnt(iEnt) || iEnt < 1 || iEnt > gpGlobals->maxClients) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *e = INDEXENT2(iEnt);
@ -387,10 +381,7 @@ static cell AMX_NATIVE_CALL drop_to_floor(AMX *amx, cell *params)
{
int iEnt = params[1];
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *e = INDEXENT2(iEnt);
@ -413,15 +404,12 @@ static cell AMX_NATIVE_CALL attach_view(AMX *amx, cell *params)
int iIndex = params[1];
int iTargetIndex = params[2];
if (iIndex > gpGlobals->maxClients || !is_ent_valid(iIndex)) {
EngineError(amx, "Invalid player %d", iIndex);
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
return 0;
}
if (!is_ent_valid(iTargetIndex)) {
EngineError(amx, "Invalid Entity %d", iIndex);
return 0;
}
CHECK_ENTITY(iIndex);
SET_VIEW(INDEXENT2(iIndex), INDEXENT2(iTargetIndex));
@ -435,8 +423,8 @@ static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) {
int iIndex = params[1];
int iCameraType = params[2];
if (iIndex > gpGlobals->maxClients || !is_ent_valid(iIndex)) {
EngineError(amx, "Invalid player %d", iIndex);
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
return 0;
}

View File

@ -13,8 +13,6 @@
#include "entity.h"
#include "gpglobals.h"
//#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; }
extern DLL_FUNCTIONS *g_pFunctionTable;
extern DLL_FUNCTIONS *g_pFunctionTable_Post;
extern enginefuncs_t *g_pengfuncsTable;
@ -170,8 +168,6 @@ inline edict_t* INDEXENT2( int iEdictNum )
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
}
void EngineError(AMX *amx, char *fmt, ...);
int Spawn(edict_t *pEntity);
void ChangeLevel(char* s1, char* s2);
void PlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
@ -184,7 +180,23 @@ void PlayerPostThink_Post(edict_t *pEntity);
void pfnTouch(edict_t *pToucher, edict_t *pTouched);
void Think(edict_t *pent);
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { EngineError(amx, "Invalid entity %d", x); return 0; }
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
extern bool g_inKeyValue;
extern KeyValueData *g_pkvd;

View File

@ -5,14 +5,18 @@ int is_ent_valid(int iEnt)
if (iEnt < 1 || iEnt > gpGlobals->maxEntities)
return 0;
if (iEnt >= 1 && iEnt <= gpGlobals->maxClients)
if (iEnt <= gpGlobals->maxClients)
{
if (!MF_IsPlayerIngame(iEnt))
{
return 0;
edict_t *pEnt = INDEXENT2(iEnt);
if (FNullEnt(pEnt))
return 0;
}
} else {
if (FNullEnt(INDEXENT(iEnt)))
{
return 0;
}
}
return 1;
}
@ -26,10 +30,8 @@ static cell AMX_NATIVE_CALL entity_range(AMX *amx, cell *params)
int idxa = params[1];
int idxb = params[2];
if (!is_ent_valid(idxa) || !is_ent_valid(idxb)) {
EngineError(amx, "Invalid Entity");
return 0;
}
CHECK_ENTITY(idxa);
CHECK_ENTITY(idxb);
edict_t *pEntA = INDEXENT2(idxa);
edict_t *pEntB = INDEXENT2(idxb);
@ -47,10 +49,7 @@ static cell AMX_NATIVE_CALL call_think(AMX *amx, cell *params)
{
int iEnt = params[1];
if (is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -65,10 +64,8 @@ static cell AMX_NATIVE_CALL fake_touch(AMX *amx, cell *params)
int iPtr = params[1];
int iPtd = params[2];
if (!is_ent_valid(iPtr) || !is_ent_valid(iPtd)) {
EngineError(amx, "Invalid Entity");
return 0;
}
CHECK_ENTITY(iPtr);
CHECK_ENTITY(iPtd);
edict_t *pToucher = INDEXENT2(iPtr);
edict_t *pTouched = INDEXENT2(iPtd);
@ -83,10 +80,8 @@ static cell AMX_NATIVE_CALL force_use(AMX *amx, cell *params)
int iPtr = params[1];
int iPtd = params[2];
if (!is_ent_valid(iPtr) || !is_ent_valid(iPtd)) {
EngineError(amx, "Invalid Entity");
return 0;
}
CHECK_ENTITY(iPtr);
CHECK_ENTITY(iPtd);
edict_t *pUser = INDEXENT2(iPtr);
edict_t *pUsed = INDEXENT2(iPtd);
@ -139,10 +134,7 @@ static cell AMX_NATIVE_CALL DispatchKeyValue(AMX *amx, cell *params)
if (count == 3) {
cell *cVal = MF_GetAmxAddr(amx, params[1]);
int iValue = *cVal;
if (!is_ent_valid(iValue)) {
EngineError(amx, "Invalid Entity %d", iValue);
return 0;
}
CHECK_ENTITY(iValue);
edict_t *pEntity = INDEXENT2(iValue);
KeyValueData kvd;
int iLength=0;
@ -172,10 +164,7 @@ static cell AMX_NATIVE_CALL DispatchKeyValue(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_keyvalue(AMX *amx, cell *params)
{
int idx = params[1];
if (!is_ent_valid(idx)) {
EngineError(amx, "Invalid Entity %d", idx);
return 0;
}
CHECK_ENTITY(idx);
edict_t *pEntity = INDEXENT2(idx);
char *test = INFO_KEY_BUFFER(pEntity);
int iLength=0;
@ -202,10 +191,7 @@ static cell AMX_NATIVE_CALL DispatchSpawn(AMX *amx, cell *params)
{
int iEnt = params[1];
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -224,10 +210,7 @@ static cell AMX_NATIVE_CALL entity_get_float(AMX *amx, cell *params)
int idx = params[2];
REAL fVal = 0;
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -358,10 +341,7 @@ static cell AMX_NATIVE_CALL entity_set_float(AMX *amx, cell *params)
int idx = params[2];
REAL fVal = amx_ctof(params[3]);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -492,10 +472,7 @@ static cell AMX_NATIVE_CALL entity_get_int(AMX *amx, cell *params)
int idx = params[2];
int iRetValue = 0;
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -613,7 +590,7 @@ static cell AMX_NATIVE_CALL entity_get_int(AMX *amx, cell *params)
iRetValue = pEnt->v.deadflag;
break;
default:
EngineError(amx, "Invalid property %d", iEnt);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid property %d", idx);
return 0;
break;
}
@ -627,10 +604,7 @@ static cell AMX_NATIVE_CALL entity_set_int(AMX *amx, cell *params)
int idx = params[2];
int iNewValue = params[3];
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -762,10 +736,7 @@ static cell AMX_NATIVE_CALL entity_get_vector(AMX *amx, cell *params)
cell *vRet = MF_GetAmxAddr(amx, params[3]);
Vector vRetValue = Vector(0, 0, 0);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -858,10 +829,7 @@ static cell AMX_NATIVE_CALL entity_set_vector(AMX *amx, cell *params)
int idx = params[2];
cell *vAmx = MF_GetAmxAddr(amx, params[3]);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
REAL fX = amx_ctof(vAmx[0]);
REAL fY = amx_ctof(vAmx[1]);
@ -955,10 +923,7 @@ static cell AMX_NATIVE_CALL entity_get_string(AMX *amx, cell *params)
int iszString = 0;
const char *szRet = NULL;
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -1020,10 +985,7 @@ static cell AMX_NATIVE_CALL entity_set_string(AMX *amx, cell *params)
int iLen;
int iszString = AmxStringToEngine(amx, params[3], iLen);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -1082,10 +1044,7 @@ static cell AMX_NATIVE_CALL entity_get_edict(AMX *amx, cell *params)
int idx = params[2];
edict_t *pRet;
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -1141,10 +1100,9 @@ static cell AMX_NATIVE_CALL entity_set_edict(AMX *amx, cell *params)
int idx = params[2];
int iSetEnt = params[3];
if (!is_ent_valid(iEnt) || !is_ent_valid(iSetEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
if (iSetEnt != 0)
CHECK_ENTITY(iSetEnt);
edict_t *pEnt = INDEXENT2(iEnt);
edict_t *pSetEnt = INDEXENT2(iSetEnt);
@ -1198,10 +1156,7 @@ static cell AMX_NATIVE_CALL entity_get_byte(AMX *amx, cell *params)
int idx = params[2];
int iRetValue = 0;
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -1239,10 +1194,7 @@ static cell AMX_NATIVE_CALL entity_set_byte(AMX *amx, cell *params)
int idx = params[2];
int iNewValue = params[3];
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
if(iNewValue > 255)
iNewValue = 255;
@ -1254,22 +1206,22 @@ static cell AMX_NATIVE_CALL entity_set_byte(AMX *amx, cell *params)
switch (idx)
{
case controller1:
pEnt->v.controller[1] = iNewValue;
pEnt->v.controller[0] = iNewValue;
break;
case controller2:
pEnt->v.controller[2] = iNewValue;
pEnt->v.controller[1] = iNewValue;
break;
case controller3:
pEnt->v.controller[3] = iNewValue;
pEnt->v.controller[2] = iNewValue;
break;
case controller4:
pEnt->v.controller[4] = iNewValue;
pEnt->v.controller[3] = iNewValue;
break;
case blending1:
pEnt->v.blending[1] = iNewValue;
pEnt->v.blending[0] = iNewValue;
break;
case blending2:
pEnt->v.blending[2] = iNewValue;
pEnt->v.blending[1] = iNewValue;
break;
default:
return 0;
@ -1283,10 +1235,7 @@ static cell AMX_NATIVE_CALL entity_set_origin(AMX *amx, cell *params)
{
int iEnt = params[1];
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
cell *vVector = MF_GetAmxAddr(amx, params[2]);
@ -1305,10 +1254,7 @@ static cell AMX_NATIVE_CALL entity_set_model(AMX *amx, cell *params)
{
int iEnt = params[1];
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
int iLen;
@ -1327,10 +1273,7 @@ static cell AMX_NATIVE_CALL entity_set_size(AMX *amx, cell *params)
{
int iEnt = params[1];
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
@ -1411,10 +1354,7 @@ static cell AMX_NATIVE_CALL find_sphere_class(AMX *amx, cell *params) // find_sp
vec3_t vecOrigin;
if (params[1] > 0) {
if (!is_ent_valid(params[1])) {
EngineError(amx, "Invalid Entity %d", params[1]);
return 0;
}
CHECK_ENTITY(params[1]);
edict_t* pEntity = INDEXENT2(params[1]);
vecOrigin = pEntity->v.origin;
@ -1522,10 +1462,7 @@ static cell AMX_NATIVE_CALL find_ent_by_owner(AMX *amx, cell *params) // native
int iEnt = params[1];
int oEnt = params[3];
// Check index to start searching at, 0 must be possible for iEnt.
if (!is_ent_valid(oEnt)) {
EngineError(amx, "Invalid Entity");
return 0;
}
CHECK_ENTITY(oEnt);
edict_t *pEnt = INDEXENT2(iEnt);
edict_t *entOwner = INDEXENT2(oEnt);
@ -1560,10 +1497,7 @@ static cell AMX_NATIVE_CALL get_grenade_id(AMX *amx, cell *params) /* 4 param *
int index = params[1];
char* szModel;
if (!is_ent_valid(index)) {
EngineError(amx, "Invalid Entity %d", index);
return 0;
}
CHECK_ENTITY(index);
edict_t* pentFind = INDEXENT2(params[4]);
edict_t* pentOwner = INDEXENT2(index);

View File

@ -20,6 +20,7 @@ CVector<EntClass *> Thinks;
CVector<Touch *> Touches;
KeyValueData *g_pkvd;
bool g_inKeyValue=false;
bool g_precachedStuff = false;
int fstrcmp(const char *s1, const char *s2)
{
@ -37,6 +38,11 @@ int fstrcmp(const char *s1, const char *s2)
}
int Spawn(edict_t *pEntity) {
if (!g_precachedStuff) {
// Used for SetView, added by JGHG
int returnValue = PRECACHE_MODEL("models/rpgrocket.mdl");
g_precachedStuff = true;
}
if (SpawnForward != -1) {
int retVal = 0;
int id = ENTINDEX(pEntity);

View File

@ -2,7 +2,6 @@
CVector<argMsg*> Msg;
CVector<int> msgHooks[256];
//int msgHooks[256] = {0};
int msgBlocks[256] = {0};
int msgDest;
int msgType;
@ -94,6 +93,7 @@ void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
{
if (msgBlocks[msg_type]) {
inblock = true;
msgType = msg_type;
RETURN_META(MRES_SUPERCEDE);
} else if (msgHooks[msg_type].size()) {
inhook = true;
@ -458,12 +458,20 @@ static cell AMX_NATIVE_CALL get_msg_origin(AMX *amx, cell *params)
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
vec3_t vRet = (Vector)msgOrigin;
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
cAddr[0] = amx_ftoc(vRet.x);
cAddr[1] = amx_ftoc(vRet.y);
cAddr[2] = amx_ftoc(vRet.z);
if (msgDest >= MSG_PVS && msgDest <= MSG_PAS_R)
{
vec3_t vRet = (Vector)msgOrigin;
cAddr[0] = amx_ftoc(vRet.x);
cAddr[1] = amx_ftoc(vRet.y);
cAddr[2] = amx_ftoc(vRet.z);
} else {
cAddr[0] = 0;
cAddr[1] = 0;
cAddr[2] = 0;
}
return 1;
}

View File

@ -219,8 +219,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
default:
MF_Log("Unknown dllfunc entry.");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown dllfunc entry %d", type);
return 0;
}
}

View File

@ -963,7 +963,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
(*g_engfuncs.pfnSetClientKeyValue)(index,(*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT2(index)),temp,temp2);
return 1;
default:
LOG_CONSOLE(PLID,"[NS2AMX] Unknown engfunc type provided.");
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown engfunc type %d", type);
return 0;
}
}

View File

@ -19,8 +19,27 @@ inline edict_t* INDEXENT2( int iEdictNum )
else
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
}
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; }
#ifdef DONT_TOUCH_THIS_AGAIN_BAIL
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#endif
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; }
extern AMX_NATIVE_INFO engfunc_natives[];
extern AMX_NATIVE_INFO dllfunc_natives[];
extern AMX_NATIVE_INFO pev_natives[];

View File

@ -111,6 +111,28 @@ void TraceLine_post(const float *v1, const float *v2, int fNoMonsters, edict_t *
RETURN_META(MRES_IGNORED);
}
void AlertMessage(ALERT_TYPE atype, char *szFmt, ...)
{
static char buf[2048];
va_list ap;
va_start(ap, szFmt);
vsprintf(buf, szFmt, ap);
va_end(ap);
FM_ENG_HANDLE(FM_AlertMessage, (Engine[FM_AlertMessage].at(i), atype, buf));
RETURN_META(mswi(lastFmRes));
}
void AlertMessage_post(ALERT_TYPE atype, char *szFmt, ...)
{
static char buf[2048];
va_list ap;
va_start(ap, szFmt);
vsprintf(buf, szFmt, ap);
va_end(ap);
FM_ENG_HANDLE(FM_AlertMessage, (Engine[FM_AlertMessage].at(i), atype, buf));
RETURN_META(MRES_IGNORED);
}
// pfnModelIndex
SIMPLE_INT_HOOK_CONSTSTRING(ModelIndex);
@ -448,7 +470,7 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
int func = params[1];
// You originally had both post coming from params[2] AND the function name. I've moved post to 3.
int post = params[3];
if (func > FM_AllowLagCompensation || func < 1)
if (func >= FM_LAST_DONT_USE_ME || func < 1)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
@ -872,7 +894,10 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
ENGHOOK(IsMapValid);
break;
case FM_AlertMessage:
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_STRING, FP_DONE);
ENGHOOK(AlertMessage);
break;
/*
* Begin of DLLFuncs

View File

@ -1,7 +1,7 @@
#ifndef _INCLUDE_FORWARD_H
#define _INCLUDE_FORWARD_H
#define ENGFUNC_NUM 108
#define ENGFUNC_NUM 118
#define FMV_STRING 1
#define FMV_FLOAT 2
@ -13,6 +13,7 @@
#define FMRES_OVERRIDE 3
enum {
FM_FIRST_DONT_USE_ME = 0,
FM_PrecacheModel = 1, // done
FM_PrecacheSound, // done
FM_SetModel, // done
@ -148,6 +149,8 @@ enum {
// Create baselines for certain "unplaced" items.
FM_CreateInstancedBaselines, // done
FM_AllowLagCompensation, // done
FM_AlertMessage,
FM_LAST_DONT_USE_ME,
};
extern CVector<int> Engine[];

View File

@ -4,20 +4,23 @@
static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
{
int index=params[1];
#ifdef DONT_TOUCH_THIS_AGAIN_BAIL
if (index >= 1 && index <= gpGlobals->maxClients)
{
if (!MF_IsPlayerIngame(index))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not in game", index);
return 0;
}
} else {
if (index > gpGlobals->maxEntities || index < 1)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", index);
return 0;
}
}
#endif
CHECK_ENTITY(index);
edict_t *pPlayer = INDEXENT2(index);
int returntype = *params/sizeof(cell);
int valuetype=0;
@ -36,6 +39,8 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
valuetype=VALUETYPE_BYTE;
else if (iSwitch > pev_string_start && iSwitch < pev_string_end)
valuetype=VALUETYPE_STRING;
else if (iSwitch > pev_edict_start && iSwitch < pev_edict_end)
valuetype=VALUETYPE_EDICT;
if (iSwitch > pev_int_start && iSwitch < pev_int_end)
{
valuetype=VALUETYPE_INT;
@ -501,8 +506,7 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
{
return (int)fReturn;
}
MF_Log("Invalid return valuetype for pev().");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return valuetype for pev().");
return 0;
}
else if (returntype == RETURNTYPE_FLOAT)
@ -552,8 +556,7 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
return 1;
}
}
MF_Log("Invalid return valuetype for pev().");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return valuetype for pev().");
}
else if (returntype == RETURNTYPE_STRING)
{
@ -610,8 +613,7 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
return 1;
}
}
MF_Log("Invalid return valuetype for pev().");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return valuetype for pev().");
}
return 0;
}
@ -623,7 +625,6 @@ static cell AMX_NATIVE_CALL amx_set_pev(AMX *amx, cell *params)
CHECK_ENTITY(index);
edict_t *pPlayer = INDEXENT2(index);
int iSwitch = params[2];
cell *blah = MF_GetAmxAddr(amx,params[3]);
if (iSwitch > pev_int_start && iSwitch < pev_int_end)
{
@ -918,37 +919,38 @@ static cell AMX_NATIVE_CALL amx_set_pev(AMX *amx, cell *params)
}
else if (iSwitch > pev_edict_start && iSwitch < pev_edict_end)
{
int iValue = blah[0];
switch (iSwitch)
{
case chain:
pPlayer->v.chain = INDEXENT2(params[3]);
pPlayer->v.chain = INDEXENT2(iValue);
return 1;
case dmg_inflictor:
pPlayer->v.dmg_inflictor = INDEXENT2(params[3]);
pPlayer->v.dmg_inflictor = INDEXENT2(iValue);
return 1;
case enemy:
pPlayer->v.enemy = INDEXENT2(params[3]);
pPlayer->v.enemy = INDEXENT2(iValue);
return 1;
case aiment:
pPlayer->v.aiment = INDEXENT2(params[3]);
pPlayer->v.aiment = INDEXENT2(iValue);
return 1;
case owner:
pPlayer->v.owner = INDEXENT2(params[3]);
pPlayer->v.owner = INDEXENT2(iValue);
return 1;
case groundentity:
pPlayer->v.groundentity = INDEXENT2(params[3]);
pPlayer->v.groundentity = INDEXENT2(iValue);
return 1;
case euser1:
pPlayer->v.euser1 = INDEXENT2(params[3]);
pPlayer->v.euser1 = INDEXENT2(iValue);
return 1;
case euser2:
pPlayer->v.euser2 = INDEXENT2(params[3]);
pPlayer->v.euser2 = INDEXENT2(iValue);
return 1;
case euser3:
pPlayer->v.euser3 = INDEXENT2(params[3]);
pPlayer->v.euser3 = INDEXENT2(iValue);
return 1;
case euser4:
pPlayer->v.euser4 = INDEXENT2(params[3]);
pPlayer->v.euser4 = INDEXENT2(iValue);
return 1;
default:
return 0;

View File

@ -39,20 +39,22 @@
#include <stdio.h>
#include "amxxmodule.h"
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
/************* METAMOD SUPPORT *************/
#ifdef USE_METAMOD
enginefuncs_t g_engfuncs;
DLL_FUNCTIONS *gameDLLFunc;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2122,7 +2124,6 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
// Mark down the pointer to this mod's function tables...
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2141,7 +2142,6 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
// Mark down the pointer to this mod's function tables...
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,7 +2165,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
// Mark down the pointer to this mod's function tables...
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2184,7 +2183,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
// Mark down the pointer to this mod's function tables...
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
@ -2210,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2227,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2454,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2468,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2492,6 +2496,11 @@ PFN_CELL_TO_REAL g_fn_CellToReal;
PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward;
PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName;
PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format;
// *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2535,6 +2544,9 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
// Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2542,6 +2554,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("FindAmxScriptByName", g_fn_FindAmxScriptByName, PFN_FIND_AMXSCRIPT_BYNAME);
REQFUNC("LoadAmxScript", g_fn_LoadAmxScript, PFN_LOAD_AMXSCRIPT);
REQFUNC("UnloadAmxScript", g_fn_UnloadAmxScript, PFN_UNLOAD_AMXSCRIPT);
REQFUNC("GetAmxScriptName", g_fn_GetAmxScriptName, PFN_GET_AMXSCRIPTNAME);
// String / mem in amx scripts support
REQFUNC("SetAmxString", g_fn_SetAmxString, PFN_SET_AMXSTRING);
@ -2555,6 +2568,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("amx_Execv", g_fn_AmxExecv, PFN_AMX_EXECV);
REQFUNC("amx_FindPublic", g_fn_AmxFindPublic, PFN_AMX_FINDPUBLIC);
REQFUNC("amx_Allot", g_fn_AmxAllot, PFN_AMX_ALLOT);
REQFUNC("amx_FindNative", g_fn_AmxFindNative, PFN_AMX_FINDNATIVE);
// Natives / Forwards
REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES);
@ -2566,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2578,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2587,6 +2603,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("IsPlayerHLTV", g_fn_IsPlayerHLTV, PFN_IS_PLAYER_HLTV);
REQFUNC("GetPlayerArmor", g_fn_GetPlayerArmor, PFN_GET_PLAYER_ARMOR);
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
// Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
@ -2633,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2653,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2668,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);
@ -2686,6 +2720,9 @@ void ValidateMacros_DontCallThis_Smiley()
MF_RegisterSPForward(0, 0, 0, 0, 0, 0);
MF_RegisterSPForwardByName(0, 0, 0, 0, 0, 0);
MF_UnregisterSPForward(0);
MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0);
MF_Format("", 4, "str");
}
#endif
@ -2802,7 +2839,7 @@ void *operator new(size_t reportedSize)
return ptr;
// allocation failed
return NULL;
}
void *operator new[](size_t reportedSize)
@ -2815,7 +2852,7 @@ void *operator new[](size_t reportedSize)
return ptr;
// allocation failed
return NULL;
}
// Microsoft memory tracking operators
@ -2829,7 +2866,7 @@ void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine)
return ptr;
// allocation failed
return NULL;
}
void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine)
{
@ -2841,7 +2878,7 @@ void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine
return ptr;
// allocation failed
return NULL;
}
void operator delete(void *reportedAddress)
@ -2893,6 +2930,7 @@ void operator delete[](void *reportedAddress)
#include <extdll.h>
#include "sdk_util.h"
#include <cbase.h>
#include <string.h> // for strncpy(), etc
@ -2929,4 +2967,76 @@ void UTIL_LogPrintf( char *fmt, ... )
}
void UTIL_HudMessage(CBaseEntity *pEntity, const hudtextparms_t &textparms,
const char *pMessage)
{
if ( !pEntity )
return;
MESSAGE_BEGIN( MSG_ONE, SVC_TEMPENTITY, NULL, ENT(pEntity->pev) );
WRITE_BYTE( TE_TEXTMESSAGE );
WRITE_BYTE( textparms.channel & 0xFF );
WRITE_SHORT( FixedSigned16( textparms.x, 1<<13 ) );
WRITE_SHORT( FixedSigned16( textparms.y, 1<<13 ) );
WRITE_BYTE( textparms.effect );
WRITE_BYTE( textparms.r1 );
WRITE_BYTE( textparms.g1 );
WRITE_BYTE( textparms.b1 );
WRITE_BYTE( textparms.a1 );
WRITE_BYTE( textparms.r2 );
WRITE_BYTE( textparms.g2 );
WRITE_BYTE( textparms.b2 );
WRITE_BYTE( textparms.a2 );
WRITE_SHORT( FixedUnsigned16( textparms.fadeinTime, 1<<8 ) );
WRITE_SHORT( FixedUnsigned16( textparms.fadeoutTime, 1<<8 ) );
WRITE_SHORT( FixedUnsigned16( textparms.holdTime, 1<<8 ) );
if ( textparms.effect == 2 )
WRITE_SHORT( FixedUnsigned16( textparms.fxTime, 1<<8 ) );
if ( strlen( pMessage ) < 512 )
{
WRITE_STRING( pMessage );
}
else
{
char tmp[512];
strncpy( tmp, pMessage, 511 );
tmp[511] = 0;
WRITE_STRING( tmp );
}
MESSAGE_END();
}
short FixedSigned16( float value, float scale )
{
int output;
output = (int) (value * scale);
if ( output > 32767 )
output = 32767;
if ( output < -32768 )
output = -32768;
return (short)output;
}
unsigned short FixedUnsigned16( float value, float scale )
{
int output;
output = (int) (value * scale);
if ( output < 0 )
output = 0;
if ( output > 0xFFFF )
output = 0xFFFF;
return (unsigned short)output;
}
#endif // USE_METAMOD

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1944,6 +1948,12 @@ typedef int (*PFN_IS_PLAYER_CONNECTING) (int /*id*/);
typedef int (*PFN_IS_PLAYER_HLTV) (int /*id*/);
typedef int (*PFN_GET_PLAYER_ARMOR) (int /*id*/);
typedef int (*PFN_GET_PLAYER_HEALTH) (int /*id*/);
#ifdef USE_METAMOD
typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#else
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#endif
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const size_t /*size*/);
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
@ -1963,6 +1973,7 @@ typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*pa
typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/);
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -1979,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2017,6 +2031,9 @@ extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
extern PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2036,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2050,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2066,6 +2087,8 @@ int MF_RegisterSPForwardByName (AMX * amx, const char *str, ...) { }
int MF_RegisterSPForward (AMX * amx, int func, ...) { }
void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { }
#endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives
@ -2083,11 +2106,14 @@ int MF_GetPlayerFlags (int id) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2097,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2121,6 +2148,8 @@ void MF_Log(const char *fmt, ...);
#define MF_RegisterSPForward g_fn_RegisterSPForward
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -45,6 +45,16 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2439,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2453,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2525,6 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2560,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2572,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2629,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2649,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2664,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1986,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2026,6 +2033,7 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2045,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2059,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2094,11 +2106,14 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2108,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2133,7 +2149,7 @@ void MF_Log(const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format;
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -47,20 +47,11 @@
// params[2] = argument2 <--- use the ones in params[n] directly, to save some time.
// Check receiver and sender validity. <--- Check ents, maybe need to do this better and more proper later?
if (params[1] < 1 || params[1] > gpGlobals->maxClients
|| params[2] < 1 || params[2] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE); <--- Call this, it will end up as RUN TIME ERROR 10 in server console.
return 0; <--- Standard return 0 with run time errors? (note in small only 0 returns false, everything else returns true)
}
CHECK_PLAYER(params[1])
CHECK_PLAYER(params[2])
// Get * pointer.
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) { <--- Test this pointer this way, return 0...
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); <--- Players require a different function than INDEXENT because of an HLSDK bug
return 1 <--- If native succeeded, return 1, if the native isn't supposed to return a specific value.
Note: Should be able to do: if (thenative()) and it should return false when it fails, and true when succeeds... is -1 treated as false, or is 0 a must?
@ -98,12 +89,8 @@ static cell AMX_NATIVE_CALL get_client_listening(AMX *amx, cell *params) // get_
// params[2] = sender
// Check receiver and sender validity.
if (params[1] < 1 || params[1] > gpGlobals->maxClients
|| params[2] < 1 || params[2] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
CHECK_PLAYER(params[2]);
// GET- AND SETCLIENTLISTENING returns "qboolean", an int, probably 0 or 1...
return GETCLIENTLISTENING(params[1], params[2]);
@ -117,12 +104,8 @@ static cell AMX_NATIVE_CALL set_client_listening(AMX *amx, cell *params) // set_
// params[3] = listen
// Check receiver and sender validity.
if (params[1] < 1 || params[1] > gpGlobals->maxClients
|| params[2] < 1 || params[2] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
CHECK_PLAYER(params[2]);
// Make a check on params[3] here later, and call run time error when it's wrong.
// To do: find out the possible values to set (0, 1?)
@ -138,19 +121,10 @@ static cell AMX_NATIVE_CALL set_user_godmode(AMX *amx, cell *params) // set_user
// params[2] = godmode = 0
// Check index.
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Get player pointer.
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if (params[2] == 1) {
// Enable godmode
@ -170,19 +144,10 @@ static cell AMX_NATIVE_CALL get_user_godmode(AMX *amx, cell *params) // get_user
// params[1] = index
// Check index.
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Get player pointer.
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
int godmode = 0;
@ -203,20 +168,10 @@ static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params) // native give_ite
// params[2] = item...
// Check index.
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Get player pointer.
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
// Create item entity pointer
edict_t *pItemEntity;
@ -239,8 +194,8 @@ static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params) // native give_ite
// Create the entity, returns to pointer
pItemEntity = CREATE_NAMED_ENTITY(item);
if(FNullEnt(pItemEntity)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
if (FNullEnt(pItemEntity)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Item \"%s\" failed to create", szItem);
return 0;
}
@ -278,18 +233,9 @@ static cell AMX_NATIVE_CALL spawn(AMX *amx, cell *params) // spawn(id) = 1 param
// Spawns an entity, this can be a user/player -> spawns at spawnpoints, or created entities seems to need this as a final "kick" into the game? :-)
// params[1] = entity to spawn
if (params[1] < 1 || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pEnt = INDEXENT(params[1]);
CHECK_ENTITY(params[1]);
// Check entity validity
if (FNullEnt(pEnt)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pEnt = GETEDICT(params[1]);
MDLL_Spawn(pEnt);
@ -303,19 +249,10 @@ static cell AMX_NATIVE_CALL set_user_health(AMX *amx, cell *params) // set_user_
// params[2] = health
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
// Kill if health too low.
if (params[2] > 0)
@ -333,19 +270,10 @@ static cell AMX_NATIVE_CALL set_user_frags(AMX *amx, cell *params) // set_user_f
// params[2] = frags
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
pPlayer->v.frags = params[2];
@ -359,19 +287,10 @@ static cell AMX_NATIVE_CALL set_user_armor(AMX *amx, cell *params) // set_user_a
// params[2] = armor
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
pPlayer->v.armorvalue = params[2];
@ -385,19 +304,10 @@ static cell AMX_NATIVE_CALL set_user_origin(AMX *amx, cell *params) // set_user_
// params[2] = origin
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
cell *newVectorCell = MF_GetAmxAddr(amx, params[2]);
@ -419,19 +329,10 @@ static cell AMX_NATIVE_CALL set_user_rendering(AMX *amx, cell *params) // set_us
// params[7] = amount
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
pPlayer->v.renderfx = params[2];
Vector newVector = Vector(float(params[3]), float(params[4]), float(params[5]));
@ -452,19 +353,10 @@ static cell AMX_NATIVE_CALL set_user_maxspeed(AMX *amx, cell *params) // set_use
REAL fNewSpeed = amx_ctof(params[2]);
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
SETCLIENTMAXSPEED(pPlayer, fNewSpeed);
pPlayer->v.maxspeed = fNewSpeed;
@ -478,19 +370,10 @@ static cell AMX_NATIVE_CALL get_user_maxspeed(AMX *amx, cell *params) // Float:g
// params[1] = index
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return amx_ftoc(pPlayer->v.maxspeed);
}
@ -501,19 +384,10 @@ static cell AMX_NATIVE_CALL set_user_gravity(AMX *amx, cell *params) // set_user
// params[1] = index
// params[2] = gravity (=-1.0)
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
pPlayer->v.gravity = amx_ctof(params[2]);
@ -526,19 +400,10 @@ static cell AMX_NATIVE_CALL get_user_gravity(AMX *amx, cell *params) // Float:ge
// params[1] = index
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return amx_ftoc(pPlayer->v.gravity);
}
@ -571,10 +436,7 @@ static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params) // set_use
else {
if (shooter == 0) {
// "All" shooters, target (gettingHit) should be existing player id
if (gettingHit < 1 || gettingHit > gpGlobals->maxClients) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(gettingHit);
// Where can gettingHit get hit by all?
g_zones_getHit[gettingHit] = hitzones;
}
@ -596,27 +458,12 @@ static cell AMX_NATIVE_CALL get_user_hitzones(AMX *amx, cell *params) // get_use
int gettingHit = params[2];
if (shooter) {
if (FNullEnt(shooter)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(shooter);
return g_zones_toHit[shooter];
}
else {
if (!gettingHit) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
else {
if (FNullEnt(gettingHit)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
else {
return g_zones_getHit[gettingHit];
}
}
CHECK_PLAYER(gettingHit);
return g_zones_getHit[gettingHit];
}
}
@ -627,20 +474,10 @@ static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params) // set_user_
// params[2] = no clip or not...
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check validity.
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if (params[2] == 1)
pPlayer->v.movetype = MOVETYPE_NOCLIP;
@ -656,20 +493,10 @@ static cell AMX_NATIVE_CALL get_user_noclip(AMX *amx, cell *params) // get_user_
// params[1] = index
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check validity.
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return pPlayer->v.movetype == MOVETYPE_NOCLIP;
}
@ -683,20 +510,10 @@ static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params) // set_us
// params[2] = 0 = normal footstep sound, 1 = silent slippers
// Check index
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = INDEXENT(params[1]);
// Check validity.
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if (params[2]) {
pPlayer->v.flTimeStepSound = 999;
@ -712,13 +529,9 @@ static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params) // set_us
// SidLuke
static cell AMX_NATIVE_CALL strip_user_weapons(AMX *amx, cell *params) { // index
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
CHECK_PLAYER(params[1]);
edict_t* pPlayer = INDEXENT(params[1]);
edict_t* pPlayer = MF_GetPlayerEdict(params[1]);
string_t item = MAKE_STRING("trigger_once");
edict_t *pent = CREATE_NAMED_ENTITY( item );

View File

@ -60,3 +60,35 @@ bool g_ResetHUDbool;
edict_t* g_edict;
//bool g_bot[33]; // is user bot? <--- removed, only needed with akimbot
// Globals above
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))

Binary file not shown.

View File

@ -29,7 +29,7 @@
// Do native functions init here (MF_AddNatives)
#define FN_AMXX_ATTACH OnAmxxAttach
// AMXX dettach
#define FN_AMXX_DETTACH OnAmxxDettach
#define FN_AMXX_DETACH OnAmxxDetach
// All plugins loaded
// Do forward functions init here (MF_RegisterForward)
// #define FN_AMXX_PLUGINSLOADED OnPluginsLoaded

View File

@ -45,6 +45,16 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2439,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2453,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2479,7 +2498,9 @@ PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName;
PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format;
// *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2523,7 +2544,9 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
// Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2557,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2569,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2579,6 +2604,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerArmor", g_fn_GetPlayerArmor, PFN_GET_PLAYER_ARMOR);
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
// Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
@ -2625,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2645,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2660,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);
@ -2673,16 +2715,17 @@ void ValidateMacros_DontCallThis_Smiley()
MF_AmxExecv(0, 0, 0, 0, 0);
MF_AmxFindPublic(0, 0, 0);
MF_AmxAllot(0, 0, 0, 0);
MF_LoadAmxScript(0, 0, 0, 0);
MF_LoadAmxScript(0, 0, 0, 0, 0);
MF_UnloadAmxScript(0, 0);
MF_RegisterSPForward(0, 0, 0, 0, 0, 0);
MF_RegisterSPForwardByName(0, 0, 0, 0, 0, 0);
MF_UnregisterSPForward(0);
MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0);
MF_Format("", 4, "str");
}
#endif
#ifdef MEMORY_TEST
/************* MEMORY *************/
// undef all defined macros
#undef new
@ -2796,7 +2839,7 @@ void *operator new(size_t reportedSize)
return ptr;
// allocation failed
throw std::bad_alloc();
return NULL;
}
void *operator new[](size_t reportedSize)
@ -2809,7 +2852,7 @@ void *operator new[](size_t reportedSize)
return ptr;
// allocation failed
throw std::bad_alloc();
return NULL;
}
// Microsoft memory tracking operators
@ -2823,7 +2866,7 @@ void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine)
return ptr;
// allocation failed
throw std::bad_alloc();
return NULL;
}
void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine)
{
@ -2835,7 +2878,7 @@ void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine
return ptr;
// allocation failed
throw std::bad_alloc();
return NULL;
}
void operator delete(void *reportedAddress)
@ -2854,8 +2897,6 @@ void operator delete[](void *reportedAddress)
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
}
#endif //MEMORY_TEST
/************* stuff from dlls/util.cpp *************/
// must come here because cbase.h declares it's own operator new

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1944,6 +1948,12 @@ typedef int (*PFN_IS_PLAYER_CONNECTING) (int /*id*/);
typedef int (*PFN_IS_PLAYER_HLTV) (int /*id*/);
typedef int (*PFN_GET_PLAYER_ARMOR) (int /*id*/);
typedef int (*PFN_GET_PLAYER_HEALTH) (int /*id*/);
#ifdef USE_METAMOD
typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#else
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#endif
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const size_t /*size*/);
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
@ -1963,6 +1973,7 @@ typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*pa
typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/);
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -1979,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2017,6 +2031,9 @@ extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
extern PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2036,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2050,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2066,6 +2087,8 @@ int MF_RegisterSPForwardByName (AMX * amx, const char *str, ...) { }
int MF_RegisterSPForward (AMX * amx, int func, ...) { }
void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { }
#endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives
@ -2083,11 +2106,14 @@ int MF_GetPlayerFlags (int id) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2097,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2121,8 +2148,8 @@ void MF_Log(const char *fmt, ...);
#define MF_RegisterSPForward g_fn_RegisterSPForward
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#ifdef MEMORY_TEST
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);
@ -2167,6 +2194,4 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
#endif //MEMORY_TEST
#endif // #ifndef __AMXXMODULE_H__

View File

@ -72,7 +72,7 @@ static cell AMX_NATIVE_CALL sql_connect(AMX *amx, cell *params) // 6 param
i = 0;
if (!strlen(host) || !strlen(user) || !strlen(dbname)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter supplied");
return -1;
}
@ -116,7 +116,7 @@ static cell AMX_NATIVE_CALL sql_error(AMX *amx, cell *params) // 3 params
unsigned int id = params[1]-1;
if (id >= DBList.size() || DBList[id]->isFree)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid connection %d", id);
return 0;
}
@ -146,8 +146,7 @@ static cell AMX_NATIVE_CALL sql_query(AMX *amx, cell *params) // 2 params
unsigned int id = params[1]-1;
if (id >= DBList.size() || DBList[id]->isFree) {
MF_Log("Invalid Database Handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid Database Handle %d", id);
return -1;
}
@ -170,8 +169,7 @@ static cell AMX_NATIVE_CALL sql_nextrow(AMX *amx, cell *params) // 1 param
if (id >= Results.size() || Results[id]->isFree)
{
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
return 0;
}
@ -188,8 +186,7 @@ static cell AMX_NATIVE_CALL sql_close(AMX *amx, cell *params) // 1 param
{
unsigned int id = params[1]-1;
if (id >= DBList.size() || DBList[id]->isFree) {
MF_Log("Invalid Database Handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid Database Handle %d", id);
return 0;
}
@ -210,8 +207,7 @@ static cell AMX_NATIVE_CALL sql_getfield(AMX *amx, cell *params) // 2-4 params
if (id >= Results.size() || Results[id]->isFree)
{
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
return 0;
}
@ -221,7 +217,7 @@ static cell AMX_NATIVE_CALL sql_getfield(AMX *amx, cell *params) // 2-4 params
const char *field = Result->GetField(id);
if (field == NULL)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column %d", id);
return 0;
}
@ -255,8 +251,7 @@ static cell AMX_NATIVE_CALL sql_getresult(AMX *amx, cell *params) // 4 params
if (id >= Results.size() || Results[id]->isFree)
{
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
return 0;
}
@ -268,7 +263,7 @@ static cell AMX_NATIVE_CALL sql_getresult(AMX *amx, cell *params) // 4 params
const char *field = Result->GetField(id);
if (field == NULL)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column \"%s\"", column);
return 0;
}
@ -298,8 +293,7 @@ static cell AMX_NATIVE_CALL sql_free_result(AMX *amx, cell *params)
if (id >= Results.size() || Results[id]->isFree)
{
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
return 0;
}
@ -316,8 +310,7 @@ static cell AMX_NATIVE_CALL sql_num_rows(AMX *amx, cell *params)
if (id >= Results.size() || Results[id]->isFree)
{
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
return 0;
}

View File

@ -318,7 +318,7 @@ static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params)
gpGamedllFuncs->dllapi_table->pfnSpawn(object); // emulate spawn
object->v.flags |= FL_ONGROUND; // make it think it's touched the ground
gpGamedllFuncs->dllapi_table->pfnThink(object); //
gpGamedllFuncs->dllapi_table->pfnTouch(player,object); // give it to the player
gpGamedllFuncs->dllapi_table->pfnTouch(object,player); // give it to the player
return 1;
}
@ -370,10 +370,93 @@ static cell AMX_NATIVE_CALL ns_user_kill(AMX *amx, cell *params)
return 0;
}
#define ANGLEVECTORS (*g_engfuncs.pfnAngleVectors)
static cell AMX_NATIVE_CALL ns_user_slap(AMX *amx, cell *params) /* 2 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients)
return 0;
int power = abs((int)params[2]);
edict_t *e=INDEXENT2(index);
if (e->v.iuser3 == 2 /* Commander class*/)
return 0;
if (MF_IsPlayerIngame(index) && MF_IsPlayerAlive(index)) {
if (e->v.health <= power) {
float bef = e->v.frags;
/*MDLL_ClientKill(pPlayer->pEdict);*/
edict_t *pEntity = CREATE_NAMED_ENTITY(MAKE_STRING("trigger_hurt"));
if (pEntity)
{
KeyValueData kvd;
kvd.szClassName="trigger_hurt";
kvd.szKeyName="classname";
kvd.szValue="trigger_hurt";
kvd.fHandled=0;
MDLL_KeyValue(pEntity,&kvd);
kvd.szClassName="trigger_hurt";
kvd.szKeyName="dmg";
kvd.szValue="20000.0";
kvd.fHandled=0;
MDLL_KeyValue(pEntity,&kvd);
kvd.szClassName="trigger_hurt";
kvd.szKeyName="damagetype";
kvd.szValue="1";
kvd.fHandled=0;
MDLL_KeyValue(pEntity,&kvd);
kvd.szClassName="trigger_hurt";
kvd.szKeyName="origin";
kvd.szValue="8192 8192 8192";
kvd.fHandled=0;
MDLL_KeyValue(pEntity,&kvd);
MDLL_Spawn(pEntity);
pEntity->v.classname=MAKE_STRING("slap");
MDLL_Touch(pEntity,e);
REMOVE_ENTITY(pEntity);
}
e->v.frags = bef;
}
else {
edict_t *pEdict = e;
int numparam = *params/sizeof(cell);
if (numparam<3 || params[3]) {
pEdict->v.velocity.x += RANDOM_LONG(-600,600);
pEdict->v.velocity.y += RANDOM_LONG(-180,180);
pEdict->v.velocity.z += RANDOM_LONG(100,200);
}
else {
vec3_t v_forward, v_right;
vec3_t vang = pEdict->v.angles;
float fang[3];
fang[0] = vang.x;
fang[1] = vang.y;
fang[2] = vang.z;
ANGLEVECTORS( fang, v_forward, v_right, NULL );
pEdict->v.velocity = pEdict->v.velocity + v_forward * 220 + Vector(0,0,200);
}
pEdict->v.punchangle.x = RANDOM_LONG(-10,10);
pEdict->v.punchangle.y = RANDOM_LONG(-10,10);
pEdict->v.health -= power;
int armor = (int)pEdict->v.armorvalue;
armor -= power;
if (armor < 0) armor = 0;
pEdict->v.armorvalue = armor;
pEdict->v.dmg_inflictor = pEdict;
static const char *bit_sound[3] = {
"weapons/cbar_hitbod1.wav",
"weapons/cbar_hitbod2.wav",
"weapons/cbar_hitbod3.wav" };
EMIT_SOUND_DYN2(pEdict, CHAN_VOICE, bit_sound[RANDOM_LONG(0,2)], 1.0, ATTN_NORM, 0, PITCH_NORM);
}
return 1;
}
return 0;
}
AMX_NATIVE_INFO ns_misc_natives[] = {
///////////////////
{ "user_kill", ns_user_kill },
{ "user_slap", ns_user_slap },
{ "ns_get_build", ns_get_build },

View File

@ -45,6 +45,16 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2439,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2453,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2525,6 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2560,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2572,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2629,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2649,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2664,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1986,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2026,6 +2033,7 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2045,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2059,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2094,11 +2106,14 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2108,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2133,7 +2149,7 @@ void MF_Log(const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format;
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -9,6 +9,8 @@ CSpawn ns_spawnpoints;
CPlayer g_player[33];
edict_t *player_edicts[33];
BOOL CheckForPublic(const char *publicname);
int gmsgHudText2=0;
int ChangeclassForward = -1;
int BuiltForward = -1;
@ -35,13 +37,25 @@ void OnPluginsLoaded()
iscombat=FALSE;
char mapname[255];
strcpy(mapname,STRING(gpGlobals->mapname));
if ((mapname[0]=='c' || mapname[0]=='C') && (mapname[1]=='o' || mapname[0]=='O') && mapname[2]=='_')
if ((mapname[0]=='c' || mapname[0]=='C') && (mapname[1]=='o' || mapname[1]=='O') && mapname[2]=='_')
iscombat=TRUE;
ChangeclassForward = MF_RegisterForward("client_changeclass", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
// No sense in this if it's combat..
if (!iscombat)
BuiltForward = MF_RegisterForward("client_built", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
if (!iscombat) {
if (CheckForPublic("client_built")) {
BuiltForward = MF_RegisterForward("client_built", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
g_pengfuncsTable_Post->pfnAlertMessage=AlertMessage_Post;
g_pengfuncsTable->pfnCreateNamedEntity=CreateNamedEntity;
} else {
g_pengfuncsTable_Post->pfnAlertMessage=NULL;
g_pengfuncsTable->pfnCreateNamedEntity=NULL;
}
} else {
// no need for these hooks in co
g_pengfuncsTable_Post->pfnAlertMessage=NULL;
g_pengfuncsTable->pfnCreateNamedEntity=NULL;
}
SpawnForward = MF_RegisterForward("client_spawn",ET_IGNORE,FP_CELL/*id*/,FP_DONE);
TeamForward = MF_RegisterForward("client_changeteam",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*new team*/,FP_CELL/*old team*/,FP_DONE);
}
@ -120,7 +134,7 @@ void PlayerPostThink_Post(edict_t *pEntity)
// name<CID><AUTHID><TEAM> changed role to "class" -- client_changeclass
void AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
{
if (atype != at_logged || iscombat)
if (atype != at_logged)
RETURN_META(MRES_IGNORED);
va_list LogArg;
char *sz, *message;
@ -275,8 +289,9 @@ void AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
iForward = 1;
}
// ns2amx_built.execute(index,iCreateEntityIndex,iForward,iType);
if (BuiltForward != -1)
MF_ExecuteForward(BuiltForward, index, iCreateEntityIndex, iForward, iType);
if (BuiltForward != -1) {
MF_ExecuteForward(BuiltForward, index, FStrEq((const char *)szParm[3],"type \"weapon_mine\"") ? 0 : iCreateEntityIndex, iForward, iType);
}
iCreateEntityIndex=0;
}
}
@ -450,3 +465,24 @@ edict_t *UTIL_FindEntityByString(edict_t *pentStart, const char *szKeyword, cons
return pentEntity;
return NULL;
}
BOOL CheckForPublic(const char *publicname)
{
AMX* amx;
char blah[64];
strncpy(blah,publicname,63);
int iFunctionIndex;
int i=0;
// Loop through all running scripts
while((amx=MF_GetScriptAmx(i++))!=NULL)
{
// Scan for public
if (MF_AmxFindPublic(amx, blah, &iFunctionIndex) == AMX_ERR_NONE)
{
// Public was found.
return TRUE;
}
}
return FALSE; // no public found in any loaded script
}

View File

@ -179,7 +179,7 @@
// #define FN_AngleVectors AngleVectors
// #define FN_CreateEntity CreateEntity
// #define FN_RemoveEntity RemoveEntity
// #define FN_CreateNamedEntity CreateNamedEntity
#define FN_CreateNamedEntity CreateNamedEntity
// #define FN_MakeStatic MakeStatic
// #define FN_EntIsOnFloor EntIsOnFloor
// #define FN_DropToFloor DropToFloor

View File

@ -10,6 +10,14 @@
#include "CSpawn.h"
#include "utilfunctions.h"
extern DLL_FUNCTIONS *g_pFunctionTable;
extern DLL_FUNCTIONS *g_pFunctionTable_Post;
extern enginefuncs_t *g_pengfuncsTable;
extern enginefuncs_t *g_pengfuncsTable_Post;
extern NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
extern NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
extern CSpawn ns_spawnpoints;

Binary file not shown.

View File

@ -45,6 +45,16 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2439,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2453,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2525,6 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2560,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2572,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2629,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2649,11 +2683,14 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2664,6 +2701,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1932,8 +1935,9 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1986,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2026,6 +2033,7 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2045,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2059,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2094,11 +2106,14 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2108,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2133,7 +2149,7 @@ void MF_Log(const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format;
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -215,7 +215,7 @@ static cell AMX_NATIVE_CALL sql_getfield(AMX *amx, cell *params) // 2-4 params
const char *field = Result->GetField(params[2]-1);
if (field == NULL)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column %d", params[2]);
return 0;
}
@ -261,7 +261,7 @@ static cell AMX_NATIVE_CALL sql_getresult(AMX *amx, cell *params) // 4 params
const char *field = Result->GetField(column);
if (field == NULL)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column \"%s\"", field);
return 0;
}
@ -317,8 +317,7 @@ static cell AMX_NATIVE_CALL sql_num_rows(AMX *amx, cell *params)
if (id >= Results.size() || Results[id]->isFree)
{
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
return 0;
}

114
dlls/regex/CRegEx.cpp Executable file
View File

@ -0,0 +1,114 @@
#include "pcre.h"
#include "CRegEx.h"
#include <string.h>
#include "amxxmodule.h"
RegEx::RegEx()
{
mErrorOffset = 0;
mError = NULL;
re = NULL;
mFree = true;
subject = NULL;
mSubStrings = 0;
}
void RegEx::Clear()
{
mErrorOffset = 0;
mError = NULL;
if (re)
pcre_free(re);
re = NULL;
mFree = true;
if (subject)
delete [] subject;
subject = NULL;
mSubStrings = 0;
}
RegEx::~RegEx()
{
Clear();
}
bool RegEx::isFree(bool set, bool val)
{
if (set)
{
mFree = val;
return true;
} else {
return mFree;
}
}
int RegEx::Compile(const char *pattern)
{
int errno;
if (!mFree)
Clear();
re = pcre_compile(pattern, 0, &mError, &mErrorOffset, NULL);
if (re == NULL)
{
return 0;
}
mFree = false;
return 1;
}
int RegEx::Match(const char *str)
{
int rc = 0;
if (mFree || re == NULL)
return -1;
//save str
subject = new char[strlen(str)+1];
strcpy(subject, str);
rc = pcre_exec(re, NULL, subject, (int)strlen(subject), 0, 0, ovector, 30);
if (rc < 0)
{
if (rc == PCRE_ERROR_NOMATCH)
{
return 0;
} else {
mErrorOffset = rc;
return -1;
}
}
mSubStrings = rc;
return 1;
}
const char *RegEx::GetSubstring(int s, char buffer[], int max)
{
int i = 0;
if (s >= mSubStrings || s < 0)
return NULL;
char *substr_a = subject + ovector[2*s];
int substr_l = ovector[2*s+1] - ovector[2*s];
for (i = 0; i<substr_l; i++)
{
if (i >= max)
break;
buffer[i] = substr_a[i];
}
buffer[i] = '\0';
return buffer;
}

27
dlls/regex/CRegEx.h Executable file
View File

@ -0,0 +1,27 @@
#ifndef _INCLUDE_CREGEX_H
#define _INCLUDE_CREGEX_H
class RegEx
{
public:
RegEx();
~RegEx();
bool isFree(bool set=false, bool val=false);
void Clear();
int Compile(const char *pattern);
int Match(const char *str);
const char *GetSubstring(int s, char buffer[], int max);
public:
int mErrorOffset;
const char *mError;
int mSubStrings;
private:
pcre *re;
bool mFree;
int ovector[30];
char *subject;
};
#endif //_INCLUDE_CREGEX_H

444
dlls/regex/CVector.h Executable file
View File

@ -0,0 +1,444 @@
/* AMX Mod X
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
#ifndef __CVECTOR_H__
#define __CVECTOR_H__
#include <assert.h>
// Vector
template <class T> class CVector
{
bool Grow()
{
// automatic grow
size_t newSize = m_Size * 2;
if (newSize == 0)
newSize = 8; // a good init value
T *newData = new T[newSize];
if (!newData)
return false;
if (m_Data)
{
memcpy(newData, m_Data, m_Size * sizeof(T));
delete [] m_Data;
}
m_Data = newData;
m_Size = newSize;
return true;
}
bool GrowIfNeeded()
{
if (m_CurrentUsedSize >= m_Size)
return Grow();
else
return true;
}
bool ChangeSize(size_t size)
{
// change size
if (size == m_Size)
return true;
T *newData = new T[size];
if (!newData)
return false;
if (m_Data)
{
memcpy(newData, m_Data, (m_Size < size) ? (m_Size * sizeof(T)) : (size * sizeof(T)));
delete [] m_Data;
}
if (m_Size < size)
m_CurrentSize = size;
m_Data = newData;
m_Size = size;
return true;
}
void FreeMemIfPossible()
{
}
protected:
T *m_Data;
size_t m_Size;
size_t m_CurrentUsedSize;
size_t m_CurrentSize;
public:
class iterator
{
protected:
T *m_Ptr;
public:
// constructors / destructors
iterator()
{
m_Ptr = NULL;
}
iterator(T * ptr)
{
m_Ptr = ptr;
}
// member functions
T * base()
{
return m_Ptr;
}
const T * base() const
{
return m_Ptr;
}
// operators
T & operator*()
{
return *m_Ptr;
}
T * operator->()
{
return m_Ptr;
}
iterator & operator++() // preincrement
{
++m_Ptr;
return (*this);
}
iterator operator++(int) // postincrement
{
iterator tmp = *this;
++m_Ptr;
return tmp;
}
iterator & operator--() // predecrement
{
--m_Ptr;
return (*this);
}
iterator operator--(int) // postdecrememnt
{
iterator tmp = *this;
--m_Ptr;
return tmp;
}
bool operator==(T * right) const
{
return (m_Ptr == right);
}
bool operator==(const iterator & right) const
{
return (m_Ptr == right.m_Ptr);
}
bool operator!=(T * right) const
{
return (m_Ptr != right);
}
bool operator!=(const iterator & right) const
{
return (m_Ptr != right.m_Ptr);
}
iterator & operator+=(size_t offset)
{
m_Ptr += offset;
return (*this);
}
iterator & operator-=(size_t offset)
{
m_Ptr += offset;
return (*this);
}
iterator operator+(size_t offset) const
{
iterator tmp(*this);
tmp.m_Ptr += offset;
return tmp;
}
iterator operator-(size_t offset) const
{
iterator tmp(*this);
tmp.m_Ptr += offset;
return tmp;
}
T & operator[](size_t offset)
{
return (*(*this + offset));
}
const T & operator[](size_t offset) const
{
return (*(*this + offset));
}
bool operator<(const iterator & right) const
{
return m_Ptr < right.m_Ptr;
}
bool operator>(const iterator & right) const
{
return m_Ptr > right.m_Ptr;
}
bool operator<=(const iterator & right) const
{
return m_Ptr <= right.m_Ptr;
}
bool operator>=(const iterator & right) const
{
return m_Ptr >= right.m_Ptr;
}
size_t operator-(const iterator & right) const
{
return m_Ptr - right.m_Ptr;
}
};
// constructors / destructors
CVector<T>()
{
m_Size = 0;
m_CurrentUsedSize = 0;
m_Data = NULL;
}
CVector<T>(const CVector<T> & other)
{
// copy data
m_Data = new T [other.m_Size];
m_Size = other.m_Size;
m_CurrentUsedSize = other.m_CurrentUsedSize;
memcpy(m_Data, other.m_Data, m_CurrentUsedSize * sizeof(T));
}
~CVector<T>()
{
clear();
}
// interface
size_t size() const
{
return m_CurrentUsedSize;
}
size_t capacity() const
{
return m_Size;
}
iterator begin()
{
return iterator(m_Data);
}
iterator end()
{
return iterator(m_Data + m_CurrentUsedSize);
}
iterator iterAt(size_t pos)
{
if (pos > m_CurrentUsedSize)
assert(0);
return iterator(m_Data + pos);
}
bool reserve(size_t newSize)
{
return ChangeSize(newSize);
}
bool push_back(const T & elem)
{
++m_CurrentUsedSize;
if (!GrowIfNeeded())
{
--m_CurrentUsedSize;
return false;
}
m_Data[m_CurrentUsedSize - 1] = elem;
return true;
}
void pop_back()
{
--m_CurrentUsedSize;
if (m_CurrentUsedSize < 0)
m_CurrentUsedSize = 0;
// :TODO: free memory sometimes
}
bool resize(size_t newSize)
{
if (!ChangeSize(newSize))
return false;
FreeMemIfPossible();
return true;
}
bool empty() const
{
return (m_CurrentUsedSize == 0);
}
T & at(size_t pos)
{
if (pos > m_CurrentUsedSize)
{
assert(0);
}
return m_Data[pos];
}
const T & at(size_t pos) const
{
if (pos > m_CurrentUsedSize)
{
assert(0);
}
return m_Data[pos];
}
T & operator[](size_t pos)
{
return at(pos);
}
const T & operator[](size_t pos) const
{
return at(pos);
}
T & front()
{
if (m_CurrentUsedSize < 1)
{
assert(0);
}
return m_Data[0];
}
const T & front() const
{
if (m_CurrentUsedSize < 1)
{
assert(0);
}
return m_Data[0];
}
T & back()
{
if (m_CurrentUsedSize < 1)
{
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}
const T & back() const
{
if (m_CurrentUsedSize < 1)
{
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}
bool insert(iterator where, const T & value)
{
// we have to insert before
// if it is begin, don't decrement
if (where != m_Data)
--where;
// validate iter
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
return false;
++m_CurrentUsedSize;
if (!GrowIfNeeded())
{
--m_CurrentUsedSize;
return false;
}
memmove(where.base() + 1, where.base(), m_CurrentUsedSize - (where - m_Data));
memcpy(where.base(), &value, sizeof(T));
return true;
}
void erase(iterator where)
{
// validate iter
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
return false;
if (m_CurrentUsedSize > 1)
{
// move
memmove(where.base(), where.base() + 1, m_CurrentUsedSize - 1);
}
--m_CurrentUsedSize;
// :TODO: free memory sometimes
}
void clear()
{
m_Size = 0;
m_CurrentUsedSize = 0;
delete [] m_Data;
m_Data = NULL;
}
};
#endif // __CVECTOR_H__

185
dlls/regex/Makefile.pl Executable file
View File

@ -0,0 +1,185 @@
#!/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 = "regex_amxx";
$sdk = "../../hlsdk/SourceCode";
$mm = "../../metamod/metamod";
$gccf = "gcc";
$pcreposix = "/usr/local/lib/libpcreposix.a";
$pcre = "/usr/local/lib/libpcre.a";
@CPP_SOURCE_FILES = ("CRegEx.cpp", "module.cpp", "amxxmodule.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\"";
$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);
}
push(@LINK, $pcre);
push(@LINK, $pcreposix);
if (!(-d $outdir))
{
mkdir($outdir);
}
$inc = $OPTIONS{"include"};
$cflags .= " -fno-exceptions";
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($file))[9];
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
$gcc = "$gccf $cflags -fPIC -shared -ldl -lm @LINK -o $outdir/$bin";
print "$gcc\n";
`$gcc`;

3042
dlls/regex/amxxmodule.cpp Executable file

File diff suppressed because it is too large Load Diff

2197
dlls/regex/amxxmodule.h Executable file

File diff suppressed because it is too large Load Diff

BIN
dlls/regex/lib_win/pcre.lib Executable file

Binary file not shown.

BIN
dlls/regex/lib_win/pcreposix.lib Executable file

Binary file not shown.

128
dlls/regex/module.cpp Executable file
View File

@ -0,0 +1,128 @@
#include <string.h>
#include "pcre.h"
#include "amxxmodule.h"
#include "CVector.h"
#include "CRegEx.h"
#include "module.h"
CVector<RegEx *> PEL;
int GetPEL()
{
for (int i=0; i<(int)PEL.size(); i++)
{
if (PEL[i]->isFree())
return i;
}
RegEx *x = new RegEx();
PEL.push_back(x);
return (int)PEL.size() - 1;
}
static cell AMX_NATIVE_CALL regex_match(AMX *amx, cell *params)
{
int len;
const char *str = MF_GetAmxString(amx, params[1], 0, &len);
const char *regex = MF_GetAmxString(amx, params[2], 1, &len);
int id = GetPEL();
RegEx *x = PEL[id];
if (x->Compile(regex) == 0)
{
cell *eOff = MF_GetAmxAddr(amx, params[3]);
const char *err = x->mError;
*eOff = x->mErrorOffset;
MF_SetAmxString(amx, params[4], err?err:"unknown", params[5]);
return -1;
}
int e = x->Match(str);
if (e == -1)
{
/* there was a match error. destroy this and move on. */
cell *res = MF_GetAmxAddr(amx, params[3]);
*res = x->mErrorOffset;
x->Clear();
return -2;
} else if (e == 0) {
cell *res = MF_GetAmxAddr(amx, params[3]);
*res = 0;
x->Clear();
return 0;
} else {
cell *res = MF_GetAmxAddr(amx, params[3]);
*res = x->mSubStrings;
}
return id+1;
}
static cell AMX_NATIVE_CALL regex_substr(AMX *amx, cell *params)
{
int id = params[1]-1;
if (id >= (int)PEL.size() || id < 0 || PEL[id]->isFree())
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
return 0;
}
RegEx *x = PEL[id];
//good idea? probably not.
static char buffer[4096];
const char *ret = x->GetSubstring(params[2], buffer, 4095);
if (ret == NULL)
return 0;
MF_SetAmxString(amx, params[3], ret, params[4]);
return 1;
}
static cell AMX_NATIVE_CALL regex_free(AMX *amx, cell *params)
{
cell *c = MF_GetAmxAddr(amx, params[1]);
int id = *c;
*c = 0;
id -= 1;
if (id >= (int)PEL.size() || id < 0 || PEL[id]->isFree())
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
return 0;
}
RegEx *x = PEL[id];
x->Clear();
return 1;
}
AMX_NATIVE_INFO regex_Natives[] = {
{"regex_match", regex_match},
{"regex_substr", regex_substr},
{"regex_free", regex_free},
{NULL, NULL},
};
void OnAmxxAttach()
{
MF_AddNatives(regex_Natives);
}
void OnAmxxDetach()
{
for (int i = 0; i<(int)PEL.size(); i++)
{
if (PEL[i])
{
delete PEL[i];
PEL[i] = 0;
}
}
PEL.clear();
}

10
dlls/regex/module.h Executable file
View File

@ -0,0 +1,10 @@
/* (C)2004 David "BAILOPAN" anderosn
* Licensed under the GNU General Public License, version 2
*/
#ifndef _INCLUDE_REGEX_H
#define _INCLUDE_REGEX_H
#endif //_INCLUDE_REGEX_H

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