added optimization tweaker
added binary log maxsize support
This commit is contained in:
parent
4bcb0fcb13
commit
2c5520cad0
@ -6,6 +6,7 @@
|
||||
|
||||
BinLog g_BinLog;
|
||||
int g_binlog_level = 0;
|
||||
int g_binlog_maxsize = 0;
|
||||
|
||||
bool BinLog::Open()
|
||||
{
|
||||
@ -61,6 +62,20 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
|
||||
if (!fp)
|
||||
return;
|
||||
|
||||
if (g_binlog_maxsize)
|
||||
{
|
||||
fseek(fp, 0, SEEK_END);
|
||||
if (ftell(fp) > (g_binlog_maxsize * (1024 * 1024)))
|
||||
{
|
||||
fclose(fp);
|
||||
Close();
|
||||
Open();
|
||||
fp = fopen(m_logfile.c_str(), "ab");
|
||||
if (!fp)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char c = static_cast<char>(op);
|
||||
time_t t = time(NULL);
|
||||
float gt = gpGlobals->time;
|
||||
|
@ -69,6 +69,7 @@ private:
|
||||
|
||||
extern BinLog g_BinLog;
|
||||
extern int g_binlog_level;
|
||||
extern int g_binlog_maxsize;
|
||||
|
||||
#endif //BINLOG_ENABLED
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "newmenus.h"
|
||||
#include "natives.h"
|
||||
#include "binlog.h"
|
||||
#include "optimizer.h"
|
||||
|
||||
plugin_info_t Plugin_info =
|
||||
{
|
||||
@ -305,8 +306,13 @@ int C_Spawn(edict_t *pent)
|
||||
LOG_ERROR(PLID, "Binary log failed to open.");
|
||||
}
|
||||
g_binlog_level = atoi(get_localinfo("bin_logging", "17"));
|
||||
g_binlog_maxsize = atoi(get_localinfo("g_binlog_maxsize", "20"));
|
||||
#endif
|
||||
|
||||
g_opt_level = atoi(get_localinfo("optimizer", "7"));
|
||||
if (!g_opt_level)
|
||||
g_opt_level = 7;
|
||||
|
||||
// ###### Load AMX scripts
|
||||
g_plugins.loadPluginsFromFile(get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini"));
|
||||
g_plugins.Finalize();
|
||||
|
@ -267,7 +267,10 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||
#endif
|
||||
}
|
||||
|
||||
if (g_opt_level != 65536)
|
||||
{
|
||||
SetupOptimizer(amx);
|
||||
}
|
||||
|
||||
if ((err = amx_Init(amx, *program)) != AMX_ERR_NONE)
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <string.h>
|
||||
#include "optimizer.h"
|
||||
|
||||
int g_opt_level = 0;
|
||||
|
||||
#define OP_SYSREQ_C 123
|
||||
#define OP_NOP 134
|
||||
#define OP_FLOAT_MUL 138
|
||||
@ -83,13 +85,22 @@ void _Setup_Optimizer_Stage2(AMX *amx, cell *oplist, cell *cip)
|
||||
|
||||
amx->usertags[UT_OPTIMIZER] = (void *)opt;
|
||||
|
||||
if (g_opt_level & 1)
|
||||
{
|
||||
FIND_NATIVE("floatmul", N_Float_Mul);
|
||||
FIND_NATIVE("floatdiv", N_Float_Div);
|
||||
FIND_NATIVE("floatadd", N_Float_Add);
|
||||
FIND_NATIVE("floatsub", N_Float_Sub);
|
||||
}
|
||||
if (g_opt_level & 4)
|
||||
{
|
||||
FIND_NATIVE("float", N_Float_To);
|
||||
FIND_NATIVE("floatround", N_Float_Round);
|
||||
}
|
||||
if (g_opt_level & 2)
|
||||
{
|
||||
FIND_NATIVE("floatcmp", N_Float_Cmp);
|
||||
}
|
||||
//we don't do these yet because of radix stuff >:\
|
||||
//FIND_NATIVE("floatsin", N_Float_Sin);
|
||||
//FIND_NATIVE("floatcos", N_Float_Cos);
|
||||
|
@ -23,4 +23,6 @@ struct optimizer_s
|
||||
|
||||
void SetupOptimizer(AMX *amx);
|
||||
|
||||
extern int g_opt_level;
|
||||
|
||||
#endif //_INCLUDE_AMXMODX_OPTIMIZER_H
|
||||
|
Loading…
Reference in New Issue
Block a user