Skip to content

Commit

Permalink
drop support for sourcemod 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
rtldg committed Apr 23, 2024
1 parent 5814a7c commit 16a927c
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 135 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
sm-version: [ '1.10', '1.11' ] #, '1.12'
sm-version: [ '1.11' ] #, '1.12'

name: "Build SM ${{ matrix.sm-version }}"
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup SP
uses: rumblefrog/setup-sp@master
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
done
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bhoptimer-${{ github.head_ref || github.ref_name }}-sm${{ matrix.sm-version }}-${{ env.GITHUB_SHA_SHORT }}
path: |
Expand All @@ -64,12 +64,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

- name: Archive artifacts
shell: bash
run: find * -maxdepth 0 -type d -exec zip -rq {}.zip {} \;

- uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ Includes a records system, map zones (start/end marks etc), bonuses, HUD with us

# Requirements:
* Steam version of Counter-Strike: Source, Counter-Strike: Global Offensive, or Team Fortress 2.
* [Metamod:Source](https://www.sourcemm.net/downloads.php?branch=stable) and [SourceMod](https://www.sourcemod.net/downloads.php?branch=stable) 1.10 or higher ([1.10](https://www.sourcemod.net/downloads.php?branch=1.10-dev&all=1), [1.11](https://www.sourcemod.net/downloads.php?branch=1.11-dev&all=1), [1.12](https://www.sourcemod.net/downloads.php?branch=1.12-dev&all=1)).
* [Metamod:Source](https://www.sourcemm.net/downloads.php?branch=stable) and [SourceMod](https://www.sourcemod.net/downloads.php?branch=stable) 1.11 or higher.
* A MySQL database (preferably locally hosted) if your database is likely to grow big, or if you want to use the rankings plugin. MySQL server version of 5.5.5 or above (MariaDB equivalent works too) is required.
* [DHooks](https://github.com/peace-maker/DHooks2/releases) (included with SourceMod 1.11 and higher).

# Optional requirements, for the best experience:
* [eventqueuefix](https://github.com/hermansimensen/eventqueue-fix)
Expand Down
43 changes: 0 additions & 43 deletions addons/sourcemod/scripting/include/shavit/core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -486,49 +486,6 @@ stock float GetAngleDiff(float current, float previous)
return diff - 360.0 * RoundToFloor((diff + 180.0) / 360.0);
}

// Steam names are `char[32+1];`. Source engine names are `char[32];` (MAX_PLAYER_NAME_LENGTH).
// This means Source engine names can end up with an invalid unicode sequence at the end.
// This will remove the unicode codepoint if necessary.
/*
Sourcemod 1.11 will strip the invalid codepoint internally (some relevant links below) but it'd still be nice to just retrive the client's `name` convar so we get the full thing or maybe even grab it from whatever SteamGameServer api stuff makes it available if possible.
https://github.com/alliedmodders/sourcemod/pull/545
https://github.com/alliedmodders/sourcemod/issues/1315
https://github.com/alliedmodders/sourcemod/pull/1544
*/
stock void SanerGetClientName(int client, char[] name)
{
static EngineVersion ev = Engine_Unknown;

if (ev == Engine_Unknown)
{
ev = GetEngineVersion();
}

GetClientName(client, name, 32+1);

// CSGO doesn't have this problem because `MAX_PLAYER_NAME_LENGTH` is 128...
if (ev == Engine_CSGO)
{
return;
}

int len = strlen(name);

if (len == 31)
{
for (int i = 0; i < 3; i++)
{
static int masks[3] = {0xC0, 0xE0, 0xF0};

if ((name[len-i-1] & masks[i]) >= masks[i])
{
name[len-i-1] = 0;
return;
}
}
}
}

// https://forums.alliedmods.net/showthread.php?t=216841
// Trims display string to specified max possible length, and appends "..." if initial string exceeds that length
stock void TrimDisplayString(const char[] str, char[] outstr, int outstrlen, int max_allowed_length)
Expand Down
47 changes: 0 additions & 47 deletions addons/sourcemod/scripting/include/shavit/steamid-stocks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@
#endif
#define _steamid_stocks_included

#if SOURCEMOD_V_MAJOR > 1 || SOURCEMOD_V_MINOR >= 11
#else
static KeyValues kv = null;
static bool hasi64 = false;

native int Int64ToString(const int num[2], char[] str, int maxlength);
native int StringToInt64(const char[] str, int result[2], int nBase=10);
#endif


// Retrieves accountid from STEAM_X:Y:Z, [U:1:123], and 765xxxxxxxxxxxxxx
stock int SteamIDToAccountID(const char[] sInput)
Expand Down Expand Up @@ -95,50 +86,12 @@ stock void AccountIDToSteamID3(int accountid, char[] buf, int buflen)

stock void SteamID64ToString(const int num[2], char[] buf, int buflen)
{
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR >= 11
Int64ToString(num, buf, buflen);
#else
if (kv == null)
{
if (!hasi64)
hasi64 = GetFeatureStatus(FeatureType_Native, "Int64ToString") == FeatureStatus_Available;

if (hasi64)
{
Int64ToString(num, buf, buflen);
return;
}

kv = new KeyValues("fuck sourcemod");
}

kv.SetUInt64(NULL_STRING, num);
kv.GetString(NULL_STRING, buf, buflen);
#endif
}

stock int SteamID64ToAccountID(const char[] steamid64)
{
int num[2];
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR >= 11
StringToInt64(steamid64, num);
#else
if (kv == null)
{
if (!hasi64)
hasi64 = GetFeatureStatus(FeatureType_Native, "StringToInt64") == FeatureStatus_Available;

if (hasi64)
{
StringToInt64(steamid64, num);
return num[0];
}

kv = new KeyValues("fuck sourcemod");
}

kv.SetString(NULL_STRING, steamid64);
kv.GetUInt64(NULL_STRING, num);
#endif
return num[0];
}
4 changes: 1 addition & 3 deletions addons/sourcemod/scripting/include/shavit/style-settings.sp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ float GetStyleSettingFloat(int style, char[] key)

public any Native_HasStyleSetting(Handle handler, int numParams)
{
// TODO: replace with sm 1.11 StringMap.ContainsKey
int style = GetNativeCell(1);

char sKey[SS_KEY_SZ];
Expand All @@ -559,8 +558,7 @@ public any Native_HasStyleSetting(Handle handler, int numParams)

bool HasStyleSetting(int style, char[] key)
{
int value[1];
return gSM_StyleKeys[style].GetArray(key, value, 1);
return gSM_StyleKeys[style].ContainsKey(key);
}

bool SetStyleSetting(int style, const char[] key, const char[] value, bool replace=true)
Expand Down
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/shavit-chat.sp
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ void PreviewChat(int client, int rank)
Format(sTextFormatting, MAXLENGTH_BUFFER, "\x01%s", sTextFormatting);

char sOriginalName[MAXLENGTH_NAME];
SanerGetClientName(client, sOriginalName);
GetClientName(client, sOriginalName, sizeof(sOriginalName));

// remove control characters
for(int i = 0; i < sizeof(gS_ControlCharacters); i++)
Expand Down Expand Up @@ -1375,7 +1375,7 @@ void FormatChat(int client, char[] buffer, int size)
ReplaceString(buffer, size, "{wrs}", temp);
}

SanerGetClientName(client, temp);
GetClientName(client, temp, sizeof(temp));
ReplaceString(buffer, size, "{name}", temp);
}

Expand Down Expand Up @@ -1567,7 +1567,7 @@ public int Native_GetPlainChatrank(Handle handler, int numParams)
char sName[MAX_NAME_LENGTH];
if (includename /* || iChatRank == -1*/)
{
SanerGetClientName(client, sName);
GetClientName(client, sName, sizeof(sName));
}

ReplaceString(buf, sizeof(buf), "{name}", sName);
Expand Down
8 changes: 1 addition & 7 deletions addons/sourcemod/scripting/shavit-core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ bool gB_Protobuf = false;
// hook stuff
DynamicHook gH_AcceptInput; // used for hooking player_speedmod's AcceptInput
DynamicHook gH_TeleportDhook = null;
#if I_WANT_SM_1_11_THINGS
Address gI_TF2PreventBunnyJumpingAddr = Address_Null;
#endif

// database handle
Database gH_SQL = null;
Expand Down Expand Up @@ -553,7 +551,6 @@ void LoadDHooks()
}
else if (gEV_Type == Engine_TF2 && !gB_Linux)
{
#if I_WANT_SM_1_11_THINGS
gI_TF2PreventBunnyJumpingAddr = gamedataConf.GetMemSig("CTFGameMovement::PreventBunnyJumping");

if (gI_TF2PreventBunnyJumpingAddr == Address_Null)
Expand All @@ -565,7 +562,6 @@ void LoadDHooks()
// Write the original JNZ byte but with updateMemAccess=true so we don't repeatedly page-protect it later.
StoreToAddress(gI_TF2PreventBunnyJumpingAddr, 0x75, NumberType_Int8, true);
}
#endif
}

LoadPhysicsUntouch(gamedataConf);
Expand Down Expand Up @@ -2760,7 +2756,7 @@ public void OnClientAuthorized(int client, const char[] auth)
}

char sName[MAX_NAME_LENGTH];
SanerGetClientName(client, sName);
GetClientName(client, sName, sizeof(sName));
ReplaceString(sName, MAX_NAME_LENGTH, "#", "?"); // to avoid this: https://user-images.githubusercontent.com/3672466/28637962-0d324952-724c-11e7-8b27-15ff021f0a59.png

int iLength = ((strlen(sName) * 2) + 1);
Expand Down Expand Up @@ -3085,15 +3081,13 @@ public MRESReturn DHook_ProcessMovement(Handle hParams)
int client = DHookGetParam(hParams, 1);
gI_ClientProcessingMovement = client;

#if I_WANT_SM_1_11_THINGS
if (gI_TF2PreventBunnyJumpingAddr != Address_Null)
{
if (GetStyleSettingBool(gA_Timers[client].bsStyle, "bunnyhopping"))
StoreToAddress(gI_TF2PreventBunnyJumpingAddr, 0xEB, NumberType_Int8, false); // jmp
else
StoreToAddress(gI_TF2PreventBunnyJumpingAddr, 0x75, NumberType_Int8, false); // jnz
}
#endif

// Causes client to do zone touching in movement instead of server frames.
// From https://github.com/rumourA/End-Touch-Fix
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/shavit-hud.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,7 @@ void UpdateSpectatorList(int client, Panel panel, bool &draw)
break;
}

SanerGetClientName(iSpectatorClients[i], sName);
GetClientName(iSpectatorClients[i], sName, sizeof(sName));
ReplaceString(sName, sizeof(sName), "#", "?");
TrimDisplayString(sName, sName, sizeof(sName), gCV_SpecNameSymbolLength.IntValue);

Expand Down Expand Up @@ -2407,7 +2407,7 @@ void UpdateKeyHint(int client)
break;
}

SanerGetClientName(iSpectatorClients[i], sName);
GetClientName(iSpectatorClients[i], sName, sizeof(sName));
ReplaceString(sName, sizeof(sName), "#", "?");
TrimDisplayString(sName, sName, sizeof(sName), gCV_SpecNameSymbolLength.IntValue);
Format(sMessage, 256, "%s\n%s", sMessage, sName);
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/shavit-mapchooser.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,7 @@ void Nominate(int client, const char mapname[PLATFORM_MAX_PATH])
g_aNominateList.PushString(mapname);
g_cNominatedMap[client] = mapname;
char name[MAX_NAME_LENGTH];
SanerGetClientName(client, name);
GetClientName(client, name, sizeof(name));

PrintToChatAll("%s%t", g_cPrefix, "Map Nominated", name, mapname);
}
Expand Down Expand Up @@ -1914,7 +1914,7 @@ int CheckRTV(int client = 0)

if(client != 0)
{
SanerGetClientName(client, name);
GetClientName(client, name, sizeof(name));
}
if(needed > 0)
{
Expand Down
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/shavit-misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ public Action Timer_Advertisement(Handle timer)
}

char sName[MAX_NAME_LENGTH];
SanerGetClientName(i, sName);
GetClientName(i, sName, sizeof(sName));
char sTempTempMessage[256];
sTempTempMessage = sTempMessage;
ReplaceString(sTempTempMessage, 256, "{name}", sName);
Expand Down Expand Up @@ -1762,7 +1762,7 @@ public Action Command_ToggleAdverts(int client, int args)
public Action Command_PrintAdverts(int client, int args)
{
char sName[MAX_NAME_LENGTH];
SanerGetClientName(client, sName);
GetClientName(client, sName, sizeof(sName));

for (int i = 0; i < gA_Advertisements.Length; i++)
{
Expand Down Expand Up @@ -1820,7 +1820,7 @@ public Action Command_Teleport(int client, int args)
IntToString(GetClientSerial(i), serial, 16);

char sName[MAX_NAME_LENGTH];
SanerGetClientName(i, sName);
GetClientName(i, sName, sizeof(sName));

menu.AddItem(serial, sName);
}
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/shavit-replay-recorder.sp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void DoReplaySaverCallbacks(int iSteamID, int client, int style, float time, int
}

char sName[MAX_NAME_LENGTH];
SanerGetClientName(client, sName);
GetClientName(client, sName, sizeof(sName));
ReplaceString(sName, MAX_NAME_LENGTH, "#", "?");

int postframes = gI_PlayerFrames[client] - gI_PlayerFinishFrame[client];
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/shavit-stats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ public Action Command_MapsDoneLeft(int client, int args)

if (iSteamID == 0)
{
SanerGetClientName(target, gS_TargetName[client]);
GetClientName(target, gS_TargetName[client], sizeof(gS_TargetName[client]));
iSteamID = GetSteamAccountID(target);
}

Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/shavit-wr.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2585,7 +2585,7 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
IntToString(iSteamID, sSteamID, sizeof(sSteamID));

char sName[32+1];
SanerGetClientName(client, sName);
GetClientName(client, sName, sizeof(sName));
ReplaceString(sName, sizeof(sName), "#", "?");
gSM_WRNames.SetString(sSteamID, sName, true);

Expand Down
17 changes: 2 additions & 15 deletions addons/sourcemod/scripting/shavit-zones.sp
Original file line number Diff line number Diff line change
Expand Up @@ -4526,23 +4526,10 @@ void InsertZone(int client)
}

DataPack pack = new DataPack();
// TODO Sourcemod 1.11 pack.WriteCellArray
MyWriteCellArray(pack, c, sizeof(c));
pack.WriteCellArray(c, sizeof(c));
QueryLog(gH_SQL, SQL_InsertZone_Callback, sQuery, pack);
}

void MyWriteCellArray(DataPack pack, any[] array, int size)
{
for (int i = 0; i < size; i++)
pack.WriteCell(array[i]);
}

void MyReadCellArray(DataPack pack, any[] array, int size)
{
for (int i = 0; i < size; i++)
array[i] = pack.ReadCell();
}

bool MyArrayEquals(any[] a, any[] b, int size)
{
for (int i = 0; i < size; i++)
Expand All @@ -4555,7 +4542,7 @@ public void SQL_InsertZone_Callback(Database db, DBResultSet results, const char
{
zone_cache_t cache;
pack.Reset();
MyReadCellArray(pack, cache, sizeof(cache));
pack.ReadCellArray(cache, sizeof(cache));
delete pack;

if (results == null)
Expand Down

0 comments on commit 16a927c

Please sign in to comment.