Fixed JIT line op problem
This commit is contained in:
parent
3010241fbd
commit
079a3e8bcd
@ -34,10 +34,10 @@
|
||||
#include "CForward.h"
|
||||
#include "CFile.h"
|
||||
|
||||
CPluginMngr::CPlugin* CPluginMngr::loadPlugin(const char* path, const char* name, char* error) {
|
||||
CPluginMngr::CPlugin* CPluginMngr::loadPlugin(const char* path, const char* name, char* error, int debug) {
|
||||
CPlugin** a = &head;
|
||||
while( *a ) a = &(*a)->next;
|
||||
*a = new CPlugin( pCounter++ ,path,name,error);
|
||||
*a = new CPlugin( pCounter++ ,path,name,error, debug);
|
||||
return *error ? 0 : *a;
|
||||
}
|
||||
|
||||
@ -59,17 +59,27 @@ int CPluginMngr::loadPluginsFromFile( const char* filename )
|
||||
}
|
||||
|
||||
// Find now folder
|
||||
char pluginName[256], line[256], error[256];
|
||||
char pluginName[256], line[256], error[256], debug[256];
|
||||
int debugFlag = 0;
|
||||
const char *pluginsDir = get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins");
|
||||
|
||||
|
||||
while ( fp.getline(line , 255 ) )
|
||||
{
|
||||
*pluginName = 0;
|
||||
sscanf(line,"%s",pluginName);
|
||||
*debug = 0;
|
||||
debugFlag = 0;
|
||||
sscanf(line,"%s %s",pluginName, debug);
|
||||
if (!isalnum(*pluginName)) continue;
|
||||
|
||||
#ifdef JIT
|
||||
if (isalnum(*debug) && strcmp(debug, "debug") == 0)
|
||||
{
|
||||
debugFlag = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
CPlugin* plugin = loadPlugin( pluginsDir , pluginName , error );
|
||||
CPlugin* plugin = loadPlugin( pluginsDir , pluginName , error, debugFlag);
|
||||
|
||||
if (!plugin)
|
||||
AMXXLOG_Log("[AMXX] %s (plugin \"%s\")", error, pluginName );
|
||||
@ -128,14 +138,14 @@ const char* CPluginMngr::CPlugin::getStatus() const {
|
||||
return "error";
|
||||
}
|
||||
|
||||
CPluginMngr::CPlugin::CPlugin(int i, const char* p,const char* n, char* e) : name(n), title(n) {
|
||||
CPluginMngr::CPlugin::CPlugin(int i, const char* p,const char* n, char* e, int d) : name(n), title(n) {
|
||||
const char* unk = "unknown";
|
||||
title.assign(unk);
|
||||
author.assign(unk);
|
||||
version.assign(unk);
|
||||
char* path = build_pathname("%s/%s",p,n);
|
||||
code = 0;
|
||||
int err = load_amxscript(&amx,&code,path,e );
|
||||
int err = load_amxscript(&amx,&code,path,e, d);
|
||||
if ( err == AMX_ERR_NONE ) status = ps_running;
|
||||
else status = ps_bad_load;
|
||||
amx.userdata[3] = this;
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
int status;
|
||||
CPlugin* next;
|
||||
int id;
|
||||
CPlugin(int i , const char* p,const char* n, char* e);
|
||||
CPlugin(int i , const char* p,const char* n, char* e, int d);
|
||||
~CPlugin( );
|
||||
|
||||
public:
|
||||
@ -104,7 +104,7 @@ public:
|
||||
|
||||
// Interface
|
||||
|
||||
CPlugin* loadPlugin(const char* path, const char* name, char* error);
|
||||
CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug);
|
||||
void unloadPlugin( CPlugin** a );
|
||||
int loadPluginsFromFile( const char* filename );
|
||||
CPlugin* findPluginFast(AMX *amx);
|
||||
|
@ -293,6 +293,7 @@ enum {
|
||||
#define AMX_FLAG_COMPACT 0x04 /* compact encoding */
|
||||
#define AMX_FLAG_BIGENDIAN 0x08 /* big endian encoding */
|
||||
#define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking */
|
||||
#define AMX_FLAG_LINEOPS 0x20 /* line ops are parsed by the JIT [loadtime only flag] */
|
||||
#define AMX_FLAG_BROWSE 0x4000 /* browsing/relocating or executing */
|
||||
#define AMX_FLAG_RELOC 0x8000 /* jump/call addresses relocated */
|
||||
|
||||
|
@ -242,7 +242,7 @@ AMX* get_amxscript(int, void**,const char**);
|
||||
const char* get_amxscriptname(AMX* amx);
|
||||
char* get_amxstring(AMX *amx,cell amx_addr,int id,int& len);
|
||||
int amxstring_len(cell* cstr);
|
||||
int load_amxscript(AMX* amx, void** program, const char* path, char error[64]);
|
||||
int load_amxscript(AMX* amx, void** program, const char* path, char error[64], int debug);
|
||||
int set_amxnatives(AMX* amx,char error[64]);
|
||||
int set_amxstring(AMX *amx,cell amx_addr,const char *source,int max);
|
||||
int unload_amxscript(AMX* amx,void** program);
|
||||
|
@ -104,6 +104,7 @@ int g_srvindex;
|
||||
|
||||
cvar_t init_amxmodx_version = {"amxmodx_version", "", FCVAR_SERVER | FCVAR_SPONLY};
|
||||
cvar_t init_amxmodx_modules = {"amxmodx_modules", "", FCVAR_SPONLY};
|
||||
cvar_t init_amxmodx_debug = {"amx_debug", "", FCVAR_SPONLY};
|
||||
cvar_t* amxmodx_version = NULL;
|
||||
cvar_t* amxmodx_modules = NULL;
|
||||
cvar_t* hostname = NULL;
|
||||
@ -1033,6 +1034,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
||||
gpGamedllFuncs=pGamedllFuncs;
|
||||
CVAR_REGISTER(&init_amxmodx_version);
|
||||
CVAR_REGISTER(&init_amxmodx_modules);
|
||||
CVAR_REGISTER(&init_amxmodx_debug);
|
||||
amxmodx_version = CVAR_GET_POINTER(init_amxmodx_version.name);
|
||||
REG_SVR_COMMAND("amxx",amx_command);
|
||||
|
||||
|
@ -88,7 +88,7 @@ void free_amxmemory(void **ptr)
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
int load_amxscript(AMX *amx, void **program, const char *filename, char error[64])
|
||||
int load_amxscript(AMX *amx, void **program, const char *filename, char error[64], int debug)
|
||||
{
|
||||
*error = 0;
|
||||
CAmxxReader reader(filename, SMALL_CELL_SIZE / 8);
|
||||
@ -149,6 +149,14 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||
return (amx->error = AMX_ERR_FORMAT);
|
||||
}
|
||||
|
||||
#ifdef JIT
|
||||
if ( ((int)CVAR_GET_FLOAT("amx_debug") == 2 || (debug && (int)CVAR_GET_FLOAT("amx_debug"))) )
|
||||
{
|
||||
//automatic debug mode
|
||||
hdr->flags |= AMX_FLAG_LINEOPS;
|
||||
}
|
||||
#endif
|
||||
|
||||
int err;
|
||||
memset(amx, 0, sizeof(*amx));
|
||||
if ((err = amx_Init( amx, *program )) != AMX_ERR_NONE)
|
||||
@ -157,7 +165,6 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||
return (amx->error = AMX_ERR_INIT);
|
||||
}
|
||||
|
||||
|
||||
#ifdef JIT
|
||||
void *np = new char[ amx->code_size ];
|
||||
void *rt = new char[ amx->reloc_size ];
|
||||
|
@ -144,7 +144,7 @@ struct pfnmodule_engine_g {
|
||||
const char* (*pfnget_amxscriptname)(AMX* amx); // amx
|
||||
char* (*pfnget_amxstring)(AMX*,cell,int, int&); // amx, src, buffer (0-3), len
|
||||
void (*pfnget_modname)(char*); // modname
|
||||
int (*pfnload_amxscript)(AMX*, void**, const char*, char[64]); // amx, code, path, error info
|
||||
int (*pfnload_amxscript)(AMX*, void**, const char*, char[64], int); // amx, code, path, error info
|
||||
void (*pfnprint_console)(char*, ...); // format, ....
|
||||
void (*pfnreport_error)(int code, char*, ... );
|
||||
int (*pfnset_amxnatives)(AMX*,char[64]); // amx, error info
|
||||
|
Loading…
Reference in New Issue
Block a user