sourcemod 1.13 upgrade. moved all plugins from steamworks to ripext. added smjanson and asyncsocket.inc an extra time so its easier to find. updated plugins that would not compile with 1.13

This commit is contained in:
jenz
2026-09-22 01:55:09 +02:00
parent 789b8ebef9
commit 2947bef434
17 changed files with 2131 additions and 462 deletions
@@ -6,7 +6,7 @@
//
//====================================================================================================
#include <sourcemod>
#include <SteamWorks>
#include <ripext>
#include <unloze>
#include <UNLOZE.secret> //#define UNLOZE_APIKEY here
#include <cstrike>
@@ -131,68 +131,71 @@ public void OnClientAuthorized(int client, const char[] sSteamID32)
FormatEx(sRequest, sizeof(sRequest), "https://unloze.com/api/private_api.php?api_key=%s&steam_id=%s", UNLOZE_APIKEY, sSteamID64);
int iSerial = GetClientSerial(client);
Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET, sRequest);
if (!hRequest ||
!SteamWorks_SetHTTPCallbacks(hRequest, OnClientAuthorized_OnTransferComplete) ||
!SteamWorks_SetHTTPRequestContextValue(hRequest, iSerial) ||
!SteamWorks_SendHTTPRequest(hRequest))
{
delete hRequest;
}
char sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof(sPath), "data/unloze_forum_%d.tmp", iSerial);
HTTPRequest hRequest = new HTTPRequest(sRequest);
hRequest.DownloadFile(sPath, OnClientAuthorized_OnDownloaded, iSerial);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
// Purpose: ripexts HTTPResponse only exposes the body as decoded JSON, unlike
// SteamWorks' GetHTTPResponseBodyCallback which handed back a plain char[].
// Rather than change private_api.php's response format, we use
// HTTPRequest.DownloadFile() to write the raw "GROUP\r\nNAME" body to a temp
// file and parse it back exactly like the original SteamWorks version did.
//----------------------------------------------------------------------------------------------------
public int OnClientAuthorized_OnTransferComplete(Handle hRequest, bool bFailure, bool bSuccessful, EHTTPStatusCode eStatusCode, int iSerial)
public void OnClientAuthorized_OnDownloaded(HTTPStatus status, any iSerial)
{
char sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof(sPath), "data/unloze_forum_%d.tmp", iSerial);
int client = GetClientFromSerial(iSerial);
if (!client) //Player disconnected.
{
delete hRequest;
return 0;
DeleteFile(sPath);
return;
}
if (bFailure || !bSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
if (status != HTTPStatus_OK)
{
DeleteFile(sPath);
G_bResponseFailed[client] = true;
if (G_bPreAdminChecked[client])
NotifyPostAdminCheck(client);
delete hRequest;
return 0;
return;
}
SteamWorks_GetHTTPResponseBodyCallback(hRequest, OnClientAuthorized_OnTransferResponse, iSerial);
return 0;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int OnClientAuthorized_OnTransferResponse(char[] sData, int iSerial)
{
char splitData[2][32];
char sGroup[64], sName[32];
sGroup[0] = '\0';
sName[0] = '\0';
int client = GetClientFromSerial(iSerial);
if (!client) //Player disconnected.
return 0;
TrimString(sData);
StripQuotes(sData);
LogMessage("reached sData with status 200: %s", sData);
ExplodeString(sData, "\r\n", splitData, 2, sizeof(splitData[]));
if(strlen(splitData[1]) > 0)
strcopy(G_sName[client], sizeof(G_sName[]), splitData[1]);
if(!StrEqual(splitData[0], "NOGROUP"))
File hFile = OpenFile(sPath, "r");
if (hFile != null)
{
strcopy(G_sGroup[client], sizeof(G_sGroup[]), splitData[0]);
hFile.ReadLine(sGroup, sizeof(sGroup));
hFile.ReadLine(sName, sizeof(sName));
delete hFile;
}
DeleteFile(sPath);
TrimString(sGroup);
StripQuotes(sGroup);
TrimString(sName);
StripQuotes(sName);
LogMessage("reached sData with status 200: %s", sGroup);
if (strlen(sName) > 0)
strcopy(G_sName[client], sizeof(G_sName[]), sName);
if (!StrEqual(sGroup, "NOGROUP"))
{
strcopy(G_sGroup[client], sizeof(G_sGroup[]), sGroup);
G_bResponsePassed[client] = true;
@@ -201,7 +204,6 @@ public int OnClientAuthorized_OnTransferResponse(char[] sData, int iSerial)
}
else
G_bResponseFailed[client] = true; //users with just a forum name did not pass the VIP check! so the response "failed" (but we store their forum name for later!)
return 0;
}
//----------------------------------------------------------------------------------------------------
@@ -263,7 +265,7 @@ public int Native_GetClientForumName(Handle plugin, int numParams)
{
int len = GetNativeCell(2);
int client = GetNativeCell(1);
SetNativeString(2, G_sName[client], len+1);
return 0;
}
@@ -295,40 +297,39 @@ public int Native_AsyncHasSteamIDReservedSlot(Handle plugin, int numParams)
hDataPack.WriteCell(plugin);
hDataPack.WriteCell(data);
Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET, sRequest);
if (!hRequest ||
!SteamWorks_SetHTTPCallbacks(hRequest, Native_AsyncHasSteamIDReservedSlot_OnTransferComplete) ||
!SteamWorks_SetHTTPRequestContextValue(hRequest, hDataPack) ||
!SteamWorks_SendHTTPRequest(hRequest))
{
delete hRequest;
}
// The DataPack handle value is unique among currently-open handles, so it
// doubles as a collision-free key for the temp file this specific
// in-flight request will use.
char sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof(sPath), "data/unloze_reslot_%d.tmp", view_as<int>(hDataPack));
HTTPRequest hRequest = new HTTPRequest(sRequest);
hRequest.DownloadFile(sPath, Native_AsyncHasSteamIDReservedSlot_OnDownloaded, hDataPack);
return 0;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
// Purpose: same DownloadFile-to-tempfile approach as OnClientAuthorized_OnDownloaded
// above - keeps private_api.php's raw "GROUP\r\nNAME" text response untouched.
//----------------------------------------------------------------------------------------------------
public int Native_AsyncHasSteamIDReservedSlot_OnTransferComplete(Handle hRequest, bool bFailure, bool bSuccessful, EHTTPStatusCode eStatusCode, DataPack hDataPack)
public void Native_AsyncHasSteamIDReservedSlot_OnDownloaded(HTTPStatus status, DataPack hDataPack)
{
if (bFailure || !bSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
char sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof(sPath), "data/unloze_reslot_%d.tmp", view_as<int>(hDataPack));
char sData[32] = "NOGROUP";
if (status == HTTPStatus_OK)
{
char sData[32] = "NOGROUP";
Native_AsyncHasSteamIDReservedSlot_OnTransferResponse(sData, hDataPack);
delete hRequest;
return 0;
File hFile = OpenFile(sPath, "r");
if (hFile != null)
{
hFile.ReadLine(sData, sizeof(sData));
delete hFile;
}
}
DeleteFile(sPath);
SteamWorks_GetHTTPResponseBodyCallback(hRequest, Native_AsyncHasSteamIDReservedSlot_OnTransferResponse, hDataPack);
return 0;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int Native_AsyncHasSteamIDReservedSlot_OnTransferResponse(char[] sData, DataPack hDataPack)
{
hDataPack.Reset();
char sSteamID32[32];
@@ -347,7 +348,7 @@ public int Native_AsyncHasSteamIDReservedSlot_OnTransferResponse(char[] sData, D
TrimString(sData);
StripQuotes(sData);
SplitString(sData, "\r\n", splitData, sizeof(splitData));
int result;
@@ -363,7 +364,6 @@ public int Native_AsyncHasSteamIDReservedSlot_OnTransferResponse(char[] sData, D
Call_Finish();
delete hDataPack;
return 0;
}
//----------------------------------------------------------------------------------------------------