Little cleanup (#461)
* Remove FAKEMETA leftovers * Move "require_module" native to where it belongs * Remove broken AMX module support * Remove useless natives * Remove "alloc_amxmemory" and "free_amxmemory" functions * Remove "strip_name" function * Clean engine a bit * Export "GiveFnptrsToDll" (Windows) (Core) * memcpy -> ke::SafeStrcpy * Export GiveFnptrsToDll in modules * Update msvc project files
This commit is contained in:
committed by
Vincent Herbet
parent
d2e736b10a
commit
d6e71c8f4f
@ -2312,86 +2312,10 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// linux prototype
|
||||
C_DLLEXPORT void GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) {
|
||||
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
// MSVC: Simulate __stdcall calling convention
|
||||
C_DLLEXPORT __declspec(naked) void GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
|
||||
C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
|
||||
{
|
||||
__asm // Prolog
|
||||
{
|
||||
// Save ebp
|
||||
push ebp
|
||||
// Set stack frame pointer
|
||||
mov ebp, esp
|
||||
// Allocate space for local variables
|
||||
// The MSVC compiler gives us the needed size in __LOCAL_SIZE.
|
||||
sub esp, __LOCAL_SIZE
|
||||
// Push registers
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
}
|
||||
#else // _MSC_VER
|
||||
#ifdef __GNUC__
|
||||
// GCC can also work with this
|
||||
C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
|
||||
{
|
||||
#else // __GNUC__
|
||||
// compiler not known
|
||||
#error There is no support (yet) for your compiler. Please use MSVC or GCC compilers or contact the AMX Mod X dev team.
|
||||
#endif // __GNUC__
|
||||
#endif // _MSC_VER
|
||||
#endif // __linux__
|
||||
|
||||
// ** Function core <--
|
||||
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
|
||||
gpGlobals = pGlobals;
|
||||
// NOTE! Have to call logging function _after_ copying into g_engfuncs, so
|
||||
// that g_engfuncs.pfnAlertMessage() can be resolved properly, heh. :)
|
||||
// UTIL_LogPrintf("[%s] dev: called: GiveFnptrsToDll\n", Plugin_info.logtag);
|
||||
// --> ** Function core
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Epilog
|
||||
if (sizeof(int*) == 8)
|
||||
{ // 64 bit
|
||||
__asm
|
||||
{
|
||||
// Pop registers
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
// Restore stack frame pointer
|
||||
mov esp, ebp
|
||||
// Restore ebp
|
||||
pop ebp
|
||||
// 2 * sizeof(int*) = 16 on 64 bit
|
||||
ret 16
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // 32 bit
|
||||
__asm
|
||||
{
|
||||
// Pop registers
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
// Restore stack frame pointer
|
||||
mov esp, ebp
|
||||
// Restore ebp
|
||||
pop ebp
|
||||
// 2 * sizeof(int*) = 8 on 32 bit
|
||||
ret 8
|
||||
}
|
||||
}
|
||||
#endif // #ifdef _MSC_VER
|
||||
}
|
||||
|
||||
#endif // #ifdef USE_METAMOD
|
||||
|
Reference in New Issue
Block a user