Fixed GCC compatibility for now.

Removed ps_locked and replaced with ps_error.
Added set_fail_state.
Fixed md5_file.
This commit is contained in:
David Anderson 2005-12-01 13:42:28 +00:00
parent 80fdb2cdb2
commit f336585d4f
6 changed files with 44 additions and 14 deletions

View File

@ -38,12 +38,12 @@
enum enum
{ {
ps_bad_load, ps_bad_load, //Load failed
ps_error, ps_error, //Erroneous state
ps_locked, ps_locked, //UNUSED
ps_paused, ps_paused, //Plugin is temporarily paused
ps_stopped, ps_stopped, //Plugin is ... more temporarily paused
ps_running, ps_running, //Plugin is running
}; };
class CPluginMngr class CPluginMngr

View File

@ -87,6 +87,7 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags,
m_pParams = temp; m_pParams = temp;
} }
cell *dest = m_pParams; cell *dest = m_pParams;
#if defined WIN32 && !defined __GNUC__
__asm __asm
{ {
push esi; push esi;
@ -100,7 +101,9 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags,
pop edi; pop edi;
pop ecx; pop ecx;
}; };
//memcpy(m_pParams, pParams, sizeof(cell) * iParamsLen); #else
memcpy(m_pParams, pParams, sizeof(cell) * iParamsLen);
#endif
m_pParams[iParamsLen] = 0; m_pParams[iParamsLen] = 0;
} else { } else {
m_iParamLen = 0; m_iParamLen = 0;

View File

@ -1085,8 +1085,11 @@ static cell AMX_NATIVE_CALL amx_md5_file(AMX *amx, cell *params)
int len = 0; int len = 0;
char *str = get_amxstring(amx, params[1], 0, len); char *str = get_amxstring(amx, params[1], 0, len);
char buffer[33]; 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) 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) static cell AMX_NATIVE_CALL get_tick_count(AMX *amx, cell *params)
{ {
#if defined WIN32
return GetTickCount(); return GetTickCount();
#else
return 0;
#endif
} }
static cell AMX_NATIVE_CALL module_exists(AMX *amx, cell *params) 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); 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[] = AMX_NATIVE_INFO amxmodx_Natives[] =
{ {
{"abort", amx_abort}, {"abort", amx_abort},
@ -3789,6 +3810,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"set_cvar_float", set_cvar_float}, {"set_cvar_float", set_cvar_float},
{"set_cvar_num", set_cvar_num}, {"set_cvar_num", set_cvar_num},
{"set_cvar_string", set_cvar_string}, {"set_cvar_string", set_cvar_string},
{"set_fail_state", set_fail_state},
{"set_hudmessage", set_hudmessage}, {"set_hudmessage", set_hudmessage},
{"set_localinfo", set_localinfo}, {"set_localinfo", set_localinfo},
{"set_task", set_task}, {"set_task", set_task},

View File

@ -249,14 +249,10 @@ int C_Spawn(edict_t *pent)
// ###### Load lang // ###### Load lang
char file[256]; char file[256];
g_langMngr.LoadCache(build_pathname_r(file, sizeof(file) - 1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data"))); 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")))) 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(); g_langMngr.InvalidateCache();
} }
stop=GetTickCount();
LOG_MESSAGE(PLID, "CacheDB load time: %d milliseconds", stop-start);
// ###### Initialize commands prefixes // ###### Initialize commands prefixes
g_commands.registerPrefix("amx"); g_commands.registerPrefix("amx");

View File

@ -153,7 +153,11 @@ public:
return m_Head->prev->obj; return m_Head->prev->obj;
} }
private: private:
typename CStack<ListNode *> m_FreeStack; #if defined __GNUC__
CStack<List::ListNode *> m_FreeStack;
#else
typename CStack<List::ListNode *> m_FreeStack;
#endif
ListNode *m_Head; ListNode *m_Head;
size_t m_Size; size_t m_Size;
public: public:

View File

@ -58,12 +58,17 @@ void amx_command()
a = g_plugins.begin(); a = g_plugins.begin();
int num = 0;
while (a) while (a)
{ {
num++;
if ((*a).getStatusCode() == ps_bad_load) if ((*a).getStatusCode() == ps_bad_load)
{ {
//error //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; ++a;
} }