From f336585d4fe108685ed30594af2c2ee82483b001 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 1 Dec 2005 13:42:28 +0000 Subject: [PATCH] Fixed GCC compatibility for now. Removed ps_locked and replaced with ps_error. Added set_fail_state. Fixed md5_file. --- amxmodx/CPlugin.h | 12 ++++++------ amxmodx/CTask.cpp | 5 ++++- amxmodx/amxmodx.cpp | 24 +++++++++++++++++++++++- amxmodx/meta_api.cpp | 4 ---- amxmodx/sh_list.h | 6 +++++- amxmodx/srvcmd.cpp | 7 ++++++- 6 files changed, 44 insertions(+), 14 deletions(-) diff --git a/amxmodx/CPlugin.h b/amxmodx/CPlugin.h index 57c324c2..7bd7df76 100755 --- a/amxmodx/CPlugin.h +++ b/amxmodx/CPlugin.h @@ -38,12 +38,12 @@ enum { - ps_bad_load, - ps_error, - ps_locked, - ps_paused, - ps_stopped, - ps_running, + ps_bad_load, //Load failed + ps_error, //Erroneous state + ps_locked, //UNUSED + ps_paused, //Plugin is temporarily paused + ps_stopped, //Plugin is ... more temporarily paused + ps_running, //Plugin is running }; class CPluginMngr diff --git a/amxmodx/CTask.cpp b/amxmodx/CTask.cpp index 353838f7..e5f8aee0 100755 --- a/amxmodx/CTask.cpp +++ b/amxmodx/CTask.cpp @@ -87,6 +87,7 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags, m_pParams = temp; } cell *dest = m_pParams; +#if defined WIN32 && !defined __GNUC__ __asm { push esi; @@ -100,7 +101,9 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags, pop edi; pop ecx; }; - //memcpy(m_pParams, pParams, sizeof(cell) * iParamsLen); +#else + memcpy(m_pParams, pParams, sizeof(cell) * iParamsLen); +#endif m_pParams[iParamsLen] = 0; } else { m_iParamLen = 0; diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index cc188658..0d748b3f 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -1085,8 +1085,11 @@ static cell AMX_NATIVE_CALL amx_md5_file(AMX *amx, cell *params) int len = 0; char *str = get_amxstring(amx, params[1], 0, len); char buffer[33]; + char file[255]; - FILE *fp = fopen(str, "rb"); + build_pathname_r(file, sizeof(file)-1, "%s", str); + + FILE *fp = fopen(file, "rb"); if (!fp) { @@ -3593,7 +3596,11 @@ static cell AMX_NATIVE_CALL amx_abort(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_tick_count(AMX *amx, cell *params) { +#if defined WIN32 return GetTickCount(); +#else + return 0; +#endif } static cell AMX_NATIVE_CALL module_exists(AMX *amx, cell *params) @@ -3640,6 +3647,20 @@ static cell AMX_NATIVE_CALL module_exists(AMX *amx, cell *params) return (found ? 1 : 0); } +static cell AMX_NATIVE_CALL set_fail_state(AMX *amx, cell *params) +{ + int len; + char *str = get_amxstring(amx, params[1], 0, len); + + CPluginMngr::CPlugin *pPlugin = g_plugins.findPluginFast(amx); + + pPlugin->setStatus(ps_error); + pPlugin->setError(str); + + //plugin dies once amx_Exec concludes + return 0; +} + AMX_NATIVE_INFO amxmodx_Natives[] = { {"abort", amx_abort}, @@ -3789,6 +3810,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] = {"set_cvar_float", set_cvar_float}, {"set_cvar_num", set_cvar_num}, {"set_cvar_string", set_cvar_string}, + {"set_fail_state", set_fail_state}, {"set_hudmessage", set_hudmessage}, {"set_localinfo", set_localinfo}, {"set_task", set_task}, diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 93d1e917..e73f9b39 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -249,14 +249,10 @@ int C_Spawn(edict_t *pent) // ###### Load lang char file[256]; g_langMngr.LoadCache(build_pathname_r(file, sizeof(file) - 1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data"))); - DWORD stop,start=GetTickCount(); if (!g_langMngr.Load(build_pathname_r(file, sizeof(file) - 1, "%s/languages.dat", get_localinfo("amxmodx_datadir", "addons/amxmodx/data")))) { - LOG_MESSAGE(PLID, "Cache invalidated!"); g_langMngr.InvalidateCache(); } - stop=GetTickCount(); - LOG_MESSAGE(PLID, "CacheDB load time: %d milliseconds", stop-start); // ###### Initialize commands prefixes g_commands.registerPrefix("amx"); diff --git a/amxmodx/sh_list.h b/amxmodx/sh_list.h index aa1f93e3..55d8504d 100644 --- a/amxmodx/sh_list.h +++ b/amxmodx/sh_list.h @@ -153,7 +153,11 @@ public: return m_Head->prev->obj; } private: - typename CStack m_FreeStack; +#if defined __GNUC__ + CStack m_FreeStack; +#else + typename CStack m_FreeStack; +#endif ListNode *m_Head; size_t m_Size; public: diff --git a/amxmodx/srvcmd.cpp b/amxmodx/srvcmd.cpp index 739ba3bd..b61df87b 100755 --- a/amxmodx/srvcmd.cpp +++ b/amxmodx/srvcmd.cpp @@ -58,12 +58,17 @@ void amx_command() a = g_plugins.begin(); + int num = 0; while (a) { + num++; if ((*a).getStatusCode() == ps_bad_load) { //error - print_srvconsole("Load fails: %s\n", (*a).getError()); + print_srvconsole("(%3d) Load fails: %s\n", num, (*a).getError()); + } else if ( (*a).getStatusCode() == ps_error) { + //error + print_srvconsole("(%3d) Error: %s\n", num, (*a).getError()); } ++a; }