multiple syntax updates to adjust for 1.11.0.6946 SM build

This commit is contained in:
jenz 2023-08-29 18:11:52 +02:00
parent 69f859f2ea
commit c00a625910
6 changed files with 195 additions and 15 deletions

View File

@ -55,7 +55,8 @@ public void OnPluginEnd()
public Action OnRoundEnd(Handle event, const char[] name, bool dontBroadcast) public Action OnRoundEnd(Handle event, const char[] name, bool dontBroadcast)
{ {
perform_resets(); perform_resets();
return Plugin_Handled;
} }
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast) public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
@ -77,7 +78,8 @@ public void perform_resets()
public Action reset_round_switch(Handle timer, any data) public Action reset_round_switch(Handle timer, any data)
{ {
round_switch = false; round_switch = false;
return Plugin_Handled;
} }
stock bool IsValidClient(int client) stock bool IsValidClient(int client)
@ -212,7 +214,7 @@ public Action update_mimic_coords(Handle timer, any data)
return Plugin_Continue; return Plugin_Continue;
} }
public float get_power_distance(int target_player, float [3]pos) public float get_power_distance(int target_player, float pos[3])
{ {
float vec[3]; float vec[3];
GetClientAbsOrigin(target_player, vec); GetClientAbsOrigin(target_player, vec);

View File

@ -202,7 +202,7 @@ enum SocketOption {
*/ */
typeset SocketConnectCB typeset SocketConnectCB
{ {
function void(Handle socket, any arg); function void(Handle socket, int arg);
}; };
/** /**
@ -218,7 +218,7 @@ typeset SocketConnectCB
*/ */
typeset SocketIncomingCB typeset SocketIncomingCB
{ {
function void(Handle socket, Handle newSocket, const char remoteIP[], char remotePort, any arg); function void(Handle socket, Handle newSocket, const char remoteIP[64], char remotePort, any arg);
}; };
/** /**
@ -237,7 +237,7 @@ typeset SocketIncomingCB
*/ */
typeset SocketReceiveCB typeset SocketReceiveCB
{ {
function void(Handle socket, const char receiveData[], const int dataSize, any arg); function void(Handle socket, char receiveData[3500], int dataSize, int arg);
}; };
/** /**
@ -263,7 +263,7 @@ typeset SocketSendqueueEmptyCB
*/ */
typeset SocketDisconnectCB typeset SocketDisconnectCB
{ {
function void(Handle socket, any arg); function void(Handle socket, int arg);
}; };
/** /**
@ -333,7 +333,8 @@ native bool SocketBind(Handle socket, const char[] hostname, char port);
* @param cell_t port The port to connect to. * @param cell_t port The port to connect to.
* @noreturn * @noreturn
*/ */
native void SocketConnect(Handle socket, SocketConnectCB cfunc, SocketReceiveCB rfunc, SocketDisconnectCB dfunc, const char[] hostname, char port); //native void SocketConnect(Handle socket, SocketConnectCB cfunc, SocketReceiveCB rfunc, SocketDisconnectCB dfunc, char[] hostname , int port);
native void SocketConnect(Handle socket, SocketConnectCB cfunc, SocketReceiveCB rfunc, SocketDisconnectCB dfunc, char[] hostname, char port);
/** /**
* Disconnects a socket * Disconnects a socket

View File

@ -389,6 +389,7 @@ public Action Command_TopTime(int client, int args)
} }
menu.ExitButton = true; menu.ExitButton = true;
menu.Display(client, 0); menu.Display(client, 0);
return Plugin_Handled;
} }
public Action Command_Time(int client, int args) public Action Command_Time(int client, int args)
@ -516,9 +517,10 @@ public void SQL_OnQueryCompletedTime(Database db, DBResultSet results, const cha
public int Handler_Menu(Menu menu, MenuAction action, int param1, int param2) public int Handler_Menu(Menu menu, MenuAction action, int param1, int param2)
{ {
switch(action) switch(action)
{ {
case MenuAction_Select, MenuAction_Cancel: case MenuAction_Select, MenuAction_Cancel:
delete menu; delete menu;
} }
return 0;
} }

View File

@ -128,4 +128,5 @@ public int Handler_Menu(Menu menu, MenuAction action, int param1, int param2)
case MenuAction_Select, MenuAction_Cancel: case MenuAction_Select, MenuAction_Cancel:
delete menu; delete menu;
} }
return 0;
} }

View File

@ -152,7 +152,7 @@ public Action re_open_motd(Handle hTimer, int Serial)
int client; int client;
if ((client = GetClientFromSerial(Serial)) == 0) if ((client = GetClientFromSerial(Serial)) == 0)
{ {
return; return Plugin_Handled;
} }
if (IsValidClient(client)) if (IsValidClient(client))
{ {
@ -165,6 +165,7 @@ public Action re_open_motd(Handle hTimer, int Serial)
CloseHandle(panel); CloseHandle(panel);
CreateTimer(5.0, SQL_Select_fingerprints, GetClientSerial(client)); CreateTimer(5.0, SQL_Select_fingerprints, GetClientSerial(client));
} }
return Plugin_Handled;
} }
public Action SQL_Select_fingerprints(Handle hTimer, int Serial) public Action SQL_Select_fingerprints(Handle hTimer, int Serial)
@ -172,7 +173,7 @@ public Action SQL_Select_fingerprints(Handle hTimer, int Serial)
int client; int client;
if ((client = GetClientFromSerial(Serial)) == 0) if ((client = GetClientFromSerial(Serial)) == 0)
{ {
return; return Plugin_Handled;
} }
if (IsValidClient(client)) if (IsValidClient(client))
{ {
@ -185,6 +186,7 @@ public Action SQL_Select_fingerprints(Handle hTimer, int Serial)
//PrintToChatAll("sQuery: %s", sQuery); //PrintToChatAll("sQuery: %s", sQuery);
g_dDatabase.Query(SQL_FindFingerPrints, sQuery, GetClientSerial(client), DBPrio_Low); g_dDatabase.Query(SQL_FindFingerPrints, sQuery, GetClientSerial(client), DBPrio_Low);
} }
return Plugin_Handled;
} }
public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] error, int Serial) public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] error, int Serial)

View File

@ -0,0 +1,172 @@
#define PLUGIN_VERSION "1.1"
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
public Plugin myinfo =
{
name = "[ANY] [Debugger] Valve Profiler",
description = "Measures per-plugin performance and provides a log with various counters",
author = "Alex Dragokas",
version = PLUGIN_VERSION,
url = "https://github.com/dragokas/"
};
/*
Commands:
- sm_debug - Start / stop vprof debug tracing
Logfile:
- addons/sourcemod/logs/profiler__<DATE>_<TIME>.log
For details of implementation see also:
https://github.com/alliedmodders/sourcemod/issues/1162
*/
const float LOG_MAX_WAITTIME = 60.0;
const float LOG_CHECK_INTERVAL = 5.0;
char g_PathPrefix[PLATFORM_MAX_PATH],
g_PathOrig[PLATFORM_MAX_PATH],
g_PathProfilerLog[PLATFORM_MAX_PATH],
g_PathCosole[] = "console.log";
ConVar g_CVarLogFile;
Handle g_hTimer;
bool g_bL4D2;
int g_ptrFile;
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
g_bL4D2 = (GetEngineVersion() == Engine_Left4Dead2);
return APLRes_Success;
}
public void OnPluginStart()
{
CreateConVar("sm_prof_version", PLUGIN_VERSION, "Plugin Version", FCVAR_NOTIFY | FCVAR_DONTRECORD);
g_CVarLogFile = FindConVar("con_logfile");
RegAdminCmd("sm_debug", Cmd_Debug, ADMFLAG_ROOT, "Start / stop the valve profiler");
BuildPath(Path_SM, g_PathPrefix, sizeof(g_PathPrefix), "logs/profiler_");
}
public void OnConfigsExecuted()
{
g_CVarLogFile.GetString(g_PathOrig, sizeof(g_PathOrig));
}
public Action Cmd_Debug(int client, int args)
{
static bool start;
char sTime[32];
if( !start )
{
delete g_hTimer;
FormatTime(sTime, sizeof(sTime), "%F_%H-%M-%S", GetTime());
FormatEx(g_PathProfilerLog, sizeof(g_PathProfilerLog), "%s_%s.log", g_PathPrefix, sTime);
if( g_bL4D2 )
{
g_ptrFile = FileSize(g_PathCosole);
}
else {
SetCvarSilent(g_CVarLogFile, g_PathProfilerLog);
}
ReplyToCommand(client, "\x04[START]\x05 Profiler is started...");
ServerCommand("vprof_on");
ServerExecute();
RequestFrame(OnFrameDelay);
}
else
{
ServerCommand("sm prof stop vprof");
ServerCommand("sm prof dump vprof");
ServerCommand("vprof_off");
ReplyToCommand(client, "\x04[STOP]\x05 Saving profiler log to: %s", g_PathProfilerLog);
// Profiler needs some time for analysis
if( g_bL4D2 )
{
// L4D2 has bugged con_logfile: https://github.com/ValveSoftware/Source-1-Games/issues/3601
g_hTimer = CreateTimer(LOG_CHECK_INTERVAL, Timer_MirrorLog, 1);
}
else {
g_hTimer = CreateTimer(LOG_MAX_WAITTIME, Timer_RestoreCvar);
}
}
start = !start;
return Plugin_Handled;
}
public void OnFrameDelay()
{
ServerCommand("sm prof start vprof");
}
void SetCvarSilent(ConVar cvar, char[] value)
{
int flags = cvar.Flags;
cvar.Flags &= ~ FCVAR_NOTIFY;
cvar.SetString(value);
cvar.Flags = flags;
}
public Action Timer_RestoreCvar(Handle timer)
{
SetCvarSilent(g_CVarLogFile, g_PathOrig);
g_hTimer = null;
return Plugin_Handled;
}
public Action Timer_MirrorLog(Handle timer, int init)
{
static float sec;
if( init ) sec = 0.0;
sec += LOG_CHECK_INTERVAL;
if( sec > LOG_MAX_WAITTIME )
{
g_hTimer = null;
return Plugin_Handled;
}
if( FileSize(g_PathCosole) != g_ptrFile )
{
File hr = OpenFile(g_PathCosole, "rb");
if( !hr )
{
LogError("Cannot open file: %s", g_PathCosole);
g_hTimer = null;
return Plugin_Handled;
}
if( g_ptrFile != -1 )
{
hr.Seek(g_ptrFile, SEEK_SET);
}
File hw = OpenFile(g_PathProfilerLog, "ab");
if( hw )
{
static int bytesRead, buff[1024];
while( !hr.EndOfFile() )
{
bytesRead = hr.Read(buff, sizeof(buff), 1);
hw.Write(buff, bytesRead, 1);
}
delete hw;
}
g_ptrFile = hr.Position;
delete hr;
}
g_hTimer = CreateTimer(LOG_CHECK_INTERVAL, Timer_MirrorLog, 0);
return Plugin_Handled;
}