Fix-up changes.
This commit is contained in:
parent
2ee078bada
commit
86598d3582
|
@ -34,6 +34,9 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <new>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "amxxmodule.h"
|
||||
|
||||
/************* METAMOD SUPPORT *************/
|
||||
|
@ -2469,6 +2472,12 @@ PFN_AMX_ALLOT g_fn_AmxAllot;
|
|||
PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
||||
PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
||||
PFN_UNLOAD_AMXSCRIPT g_fn_UnloadAmxScript;
|
||||
PFN_REAL_TO_CELL g_fn_RealToCell;
|
||||
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;
|
||||
|
||||
// *** Exports ***
|
||||
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
||||
{
|
||||
|
@ -2536,6 +2545,9 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||
REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES);
|
||||
REQFUNC("RaiseAmxError", g_fn_RaiseAmxError, PFN_RAISE_AMXERROR);
|
||||
REQFUNC("RegisterForward", g_fn_RegisterForward, PFN_REGISTER_FORWARD);
|
||||
REQFUNC("RegisterSPForward", g_fn_RegisterSPForward, PFN_REGISTER_SPFORWARD);
|
||||
REQFUNC("RegisterSPForwardByName", g_fn_RegisterSPForwardByName, PFN_REGISTER_SPFORWARD_BYNAME);
|
||||
REQFUNC("UnregisterSPForward", g_fn_UnregisterSPForward, PFN_UNREGISTER_SPFORWARD);
|
||||
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
|
||||
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
|
||||
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
|
||||
|
@ -2566,6 +2578,9 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
||||
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
||||
|
||||
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
||||
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
||||
|
||||
#ifdef FN_AMXX_ATTACH
|
||||
FN_AMXX_ATTACH();
|
||||
#endif // FN_AMXX_ATACH
|
||||
|
@ -2593,8 +2608,6 @@ C_DLLEXPORT int AMXX_PluginsLoaded()
|
|||
// Advanced MF functions
|
||||
void MF_Log(const char *fmt, ...)
|
||||
{
|
||||
ASSERT(g_fn_Log);
|
||||
|
||||
// :TODO: Overflow possible here
|
||||
char msg[3072];
|
||||
va_list arglst;
|
||||
|
@ -2609,7 +2622,7 @@ void MF_Log(const char *fmt, ...)
|
|||
#ifdef _DEBUG
|
||||
// validate macros
|
||||
// Makes sure compiler reports errors when macros are invalid
|
||||
void ValidateMacros()
|
||||
void ValidateMacros_DontCallThis_Smiley()
|
||||
{
|
||||
MF_BuildPathname("str", "str", 0);
|
||||
MF_FormatAmxString(NULL, 0, 0, NULL);
|
||||
|
@ -2655,6 +2668,9 @@ void ValidateMacros()
|
|||
MF_AmxAllot(0, 0, 0, 0);
|
||||
MF_LoadAmxScript(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);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -106,21 +106,17 @@ struct amxx_module_info_s
|
|||
|
||||
|
||||
|
||||
#if defined BIT16
|
||||
#define SMALL_CELL_SIZE 16 /* for backward compatibility */
|
||||
#endif
|
||||
#if !defined SMALL_CELL_SIZE
|
||||
#define SMALL_CELL_SIZE 32 /* by default, use 32-bit cells */
|
||||
#endif
|
||||
#if SMALL_CELL_SIZE==16
|
||||
typedef uint16_t ucell;
|
||||
typedef int16_t cell;
|
||||
#elif SMALL_CELL_SIZE==32
|
||||
#if SMALL_CELL_SIZE==32
|
||||
typedef uint32_t ucell;
|
||||
typedef int32_t cell;
|
||||
typedef float REAL;
|
||||
#elif SMALL_CELL_SIZE==64
|
||||
typedef uint64_t ucell;
|
||||
typedef int64_t cell;
|
||||
typedef double REAL;
|
||||
#else
|
||||
#error Unsupported cell size (SMALL_CELL_SIZE)
|
||||
#endif
|
||||
|
@ -244,32 +240,6 @@ enum {
|
|||
AMX_ERR_DOMAIN, /* domain error, expression result does not fit in range */
|
||||
};
|
||||
|
||||
/* for native functions that use floating point parameters, the following
|
||||
* two macros are convenient for casting a "cell" into a "float" type _without_
|
||||
* changing the bit pattern
|
||||
*/
|
||||
#if SMALL_CELL_SIZE==32
|
||||
inline cell amx_ftoc(float f)
|
||||
{
|
||||
return *(cell*)&f;
|
||||
}
|
||||
inline float amx_ctof(cell c)
|
||||
{
|
||||
return *(float*)&c;
|
||||
}
|
||||
#elif SMALL_CELL_SIZE==64
|
||||
inline cell amx_ftoc(double f)
|
||||
{
|
||||
return *(cell*)&f;
|
||||
}
|
||||
inline double amx_ctof(cell c)
|
||||
{
|
||||
return *(double*)&c;
|
||||
}
|
||||
#else
|
||||
#error Unsupported cell size
|
||||
#endif
|
||||
|
||||
|
||||
// ***** declare functions *****
|
||||
|
||||
|
@ -1979,6 +1949,11 @@ typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_ad
|
|||
typedef int (*PFN_AMX_FINDPUBLIC) (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_UNLOAD_AMXSCRIPT) (AMX* /*amx*/,void** /*code*/);
|
||||
typedef cell (*PFN_REAL_TO_CELL) (REAL /*x*/);
|
||||
typedef REAL (*PFN_CELL_TO_REAL) (cell /*x*/);
|
||||
typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*params*/);
|
||||
typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/);
|
||||
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
|
||||
|
||||
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
||||
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
||||
|
@ -2019,6 +1994,17 @@ extern PFN_IS_PLAYER_CONNECTING g_fn_IsPlayerConnecting;
|
|||
extern PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
||||
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||
extern PFN_AMX_EXEC g_fn_AmxExec;
|
||||
extern PFN_AMX_EXECV g_fn_AmxExecv;
|
||||
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
||||
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
||||
extern PFN_UNLOAD_AMXSCRIPT g_fn_UnloadAmxScript;
|
||||
extern PFN_REAL_TO_CELL g_fn_RealToCell;
|
||||
extern PFN_CELL_TO_REAL g_fn_CellToReal;
|
||||
extern PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward;
|
||||
extern PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName;
|
||||
extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
|
||||
|
||||
#ifdef MAY_NEVER_BE_DEFINED
|
||||
// Function prototypes for intellisense and similar systems
|
||||
|
@ -2062,6 +2048,11 @@ int MF_IsPlayerConnecting (int id) { }
|
|||
int MF_IsPlayerHLTV (int id) { }
|
||||
int MF_GetPlayerArmor (int id) { }
|
||||
int MF_GetPlayerHealth (int id) { }
|
||||
REAL amx_ctof (cell x) { }
|
||||
cell amx_ftoc (float x) { }
|
||||
int MF_RegisterSPForwardByName (AMX * amx, const char *str, ...) { }
|
||||
int MF_RegisterSPForward (AMX * amx, int func, ...) { }
|
||||
void MF_UnregisterSPForward (int id) { }
|
||||
#endif // MAY_NEVER_BE_DEFINED
|
||||
|
||||
#define MF_AddNatives g_fn_AddNatives
|
||||
|
@ -2109,6 +2100,11 @@ void MF_Log(const char *fmt, ...);
|
|||
#define MF_AmxAllot g_fn_AmxAllot
|
||||
#define MF_LoadAmxScript g_fn_LoadAmxScript
|
||||
#define MF_UnloadAmxScript g_fn_UnloadAmxScript
|
||||
#define amx_ctof g_fn_CellToReal
|
||||
#define amx_ftoc g_fn_RealToCell
|
||||
#define MF_RegisterSPForwardByName g_fn_RegisterSPForwardByName
|
||||
#define MF_RegisterSPForward g_fn_RegisterSPForward
|
||||
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
|
||||
|
||||
/*** Memory ***/
|
||||
void *operator new(size_t reportedSize);
|
||||
|
|
|
@ -430,7 +430,7 @@ static cell AMX_NATIVE_CALL set_user_maxspeed(AMX *amx, cell *params) // set_use
|
|||
// params[1] = index
|
||||
// params[2] = speed (should be -1.0 if not specified) (JGHG: unspecified parameters seems to always be -1.0!)
|
||||
|
||||
float fNewSpeed = *(float *)((void *)¶ms[2]);
|
||||
REAL fNewSpeed = amx_ctof(params[2]);
|
||||
|
||||
// Check index
|
||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
||||
|
@ -447,7 +447,6 @@ static cell AMX_NATIVE_CALL set_user_maxspeed(AMX *amx, cell *params) // set_use
|
|||
return 0;
|
||||
}
|
||||
|
||||
//pPlayer->v.maxspeed = ; // JGHG: Gotta love the way to get floats from parameters :-P
|
||||
SETCLIENTMAXSPEED(pPlayer, fNewSpeed);
|
||||
pPlayer->v.maxspeed = fNewSpeed;
|
||||
|
||||
|
@ -474,7 +473,7 @@ static cell AMX_NATIVE_CALL get_user_maxspeed(AMX *amx, cell *params) // Float:g
|
|||
return 0;
|
||||
}
|
||||
|
||||
return *(cell*)((void *)&(pPlayer->v.maxspeed)); // The way to return floats... (sigh)
|
||||
return amx_ftoc(pPlayer->v.maxspeed);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_user_gravity(AMX *amx, cell *params) // set_user_gravity(index, Float:gravity = 1.0) = 2 arguments
|
||||
|
@ -497,7 +496,7 @@ static cell AMX_NATIVE_CALL set_user_gravity(AMX *amx, cell *params) // set_user
|
|||
return 0;
|
||||
}
|
||||
|
||||
pPlayer->v.gravity = *(float *)((void *)¶ms[2]); // JGHG: Gotta love the way to get floats from parameters :-P
|
||||
pPlayer->v.gravity = amx_ctof(params[2]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -522,7 +521,7 @@ static cell AMX_NATIVE_CALL get_user_gravity(AMX *amx, cell *params) // Float:ge
|
|||
return 0;
|
||||
}
|
||||
|
||||
return *(cell*)((void *)&(pPlayer->v.gravity)); // The way to return floats... (sigh)
|
||||
return amx_ftoc(pPlayer->v.gravity);
|
||||
}
|
||||
|
||||
/*static cell AMX_NATIVE_CALL set_hitzones(AMX *amx, cell *params) // set_hitzones(body = 255) = 1 argument
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
* version.
|
||||
*/
|
||||
|
||||
#include <extdll.h>
|
||||
#include <meta_api.h>
|
||||
#include "amxxmodule.h"
|
||||
|
||||
// Fun-specific defines below
|
||||
|
|
Loading…
Reference in New Issue
Block a user