From ab73e36a15bc426f4edeec13b8d44e8dffacd522 Mon Sep 17 00:00:00 2001 From: rtldg <55846624+rtldg@users.noreply.github.com> Date: Sun, 8 May 2022 19:35:07 +0000 Subject: [PATCH] czones: use same settings for all bonuses & let more types be editable --- .../scripting/include/shavit/core.inc | 8 +- addons/sourcemod/scripting/shavit-zones.sp | 81 +++++++++++++------ .../translations/shavit-common.phrases.txt | 4 + 3 files changed, 63 insertions(+), 30 deletions(-) diff --git a/addons/sourcemod/scripting/include/shavit/core.inc b/addons/sourcemod/scripting/include/shavit/core.inc index b71c0bb9..7dab9d25 100644 --- a/addons/sourcemod/scripting/include/shavit/core.inc +++ b/addons/sourcemod/scripting/include/shavit/core.inc @@ -433,17 +433,17 @@ stock bool GuessBestMapName(ArrayList maps, const char input[PLATFORM_MAX_PATH], return false; } -stock void GetTrackName(int client, int track, char[] output, int size) +stock void GetTrackName(int client, int track, char[] output, int size, bool include_bonus_num=true) { if (track == Track_Main) { FormatEx(output, size, "%T", "Track_Main", client); } - else if (track >= Track_Bonus) + else if (Track_Bonus <= track < TRACKS_SIZE) { - FormatEx(output, size, "%T", "Track_Bonus", client, track); + FormatEx(output, size, "%T", include_bonus_num ? "Track_Bonus" : "Track_Bonus_NoNum", client, track); } - else //if (track < Track_Main) + else { FormatEx(output, size, "%T", "Track_Unknown", client); } diff --git a/addons/sourcemod/scripting/shavit-zones.sp b/addons/sourcemod/scripting/shavit-zones.sp index 3a79de01..d9aa2dec 100644 --- a/addons/sourcemod/scripting/shavit-zones.sp +++ b/addons/sourcemod/scripting/shavit-zones.sp @@ -182,6 +182,7 @@ float gF_StartAng[MAXPLAYERS+1][TRACKS_SIZE][3]; bool gB_Eventqueuefix = false; bool gB_ReplayRecorder = false; +#define CZONE_VER 'b' // custom zone stuff Cookie gH_CustomZoneCookie = null; int gI_ZoneDisplayType[MAXPLAYERS+1][ZONETYPES_SIZE][TRACKS_SIZE]; @@ -332,9 +333,9 @@ public void OnPluginStart() gCV_BoxOffset.AddChangeHook(OnConVarChanged); Convar.AutoExecConfig(); - + LoadDHooks(); - + // misc cvars sv_gravity = FindConVar("sv_gravity"); @@ -389,14 +390,14 @@ public void OnPluginEnd() void LoadDHooks() { Handle hGameData = LoadGameConfigFile("shavit.games"); - + if (hGameData == null) { SetFailState("Failed to load shavit gamedata"); } - + LoadPhysicsUntouch(hGameData); - + if (gEV_Type == Engine_CSGO) { StartPrepSDKCall(SDKCall_Entity); @@ -405,40 +406,40 @@ void LoadDHooks() { StartPrepSDKCall(SDKCall_Static); } - + if (!PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "PhysicsRemoveTouchedList")) { SetFailState("Failed to find \"PhysicsRemoveTouchedList\" signature!"); } - + if (gEV_Type != Engine_CSGO) { PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer); } - + gH_PhysicsRemoveTouchedList = EndPrepSDKCall(); - + if (!gH_PhysicsRemoveTouchedList) { SetFailState("Failed to create sdkcall to \"PhysicsRemoveTouchedList\"!"); } - + delete hGameData; - + hGameData = LoadGameConfigFile("sdktools.games"); if (hGameData == null) { SetFailState("Failed to load sdktools gamedata"); } - + int iOffset = GameConfGetOffset(hGameData, "Teleport"); if (iOffset == -1) { SetFailState("Couldn't get the offset for \"Teleport\"!"); } - + gH_TeleportDhook = new DynamicHook(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity); - + gH_TeleportDhook.AddParam(HookParamType_VectorPtr); gH_TeleportDhook.AddParam(HookParamType_VectorPtr); gH_TeleportDhook.AddParam(HookParamType_VectorPtr); @@ -446,7 +447,7 @@ void LoadDHooks() { gH_TeleportDhook.AddParam(HookParamType_Bool); } - + delete hGameData; } @@ -1016,7 +1017,7 @@ public void OnMapEnd() public void OnClientPutInServer(int client) { gI_LatestTeleportTick[client] = 0; - + if (!IsFakeClient(client) && gH_TeleportDhook != null) { gH_TeleportDhook.HookEntity(Hook_Pre, client, DHooks_OnTeleport); @@ -1608,17 +1609,29 @@ public void OnClientCookiesCached(int client) gH_DrawAllZonesCookie.Get(client, setting, sizeof(setting)); gB_DrawAllZones[client] = view_as(StringToInt(setting)); - char czone[1 + 2*2*TRACKS_SIZE + 1]; // version + ((start + end) * 2 chars * tracks) + NUL terminator + char czone[100]; // #define MAX_VALUE_LENGTH 100 gH_CustomZoneCookie.Get(client, czone, sizeof(czone)); - if (czone[0] == 'a') // "version number" + char ver = czone[0]; + + if (ver == 'a' || ver == 'b') // "version number" { + // a = [1 + 2*2*TRACKS_SIZE + 1]; // version + ((start + end) * 2 chars * tracks) + NUL terminator + // b = [1 + ZONETYPES_SIZE*2*2 + 1] // version + (ZONETYPES_SIZE * 2 chars * (main+bonus)) + NUL terminator + int p = 1; char c; while ((c = czone[p++]) != 0) { int track = c & 0xf; +#if CZONE_VER == 'b' + if (track > Track_Bonus) + { + ++p; + continue; + } +#endif int type = (c >> 4) & 1; gI_ZoneDisplayType[client][type][track] = (c >> 5) & 3; c = czone[p++]; @@ -2475,16 +2488,22 @@ void OpenCustomZoneMenu(int client, int pos=0) menu.SetTitle("%T", "CustomZone_MainMenuTitle", client); // Only start zone and end zone are customizable imo, why do you even want to customize the zones that arent often used/seen??? +#if CZONE_VER == 'b' + for (int i = 0; i <= Track_Bonus; i++) + { + for (int j = 0; j < ZONETYPES_SIZE; j++) +#else for (int i = 0; i < TRACKS_SIZE; i++) { for (int j = 0; j <= Zone_End; j++) +#endif { - if (gA_ZoneSettings[j][0].bVisible) + if (j != Zone_CustomSpawn)// && gA_ZoneSettings[j][i].bVisible) { char info[8]; FormatEx(info, sizeof(info), "%i;%i", i, j); char trackName[32], zoneName[32], display[64]; - GetTrackName(client, i, trackName, sizeof(trackName)); + GetTrackName(client, i, trackName, sizeof(trackName), !(CZONE_VER == 'b')); GetZoneName(client, j, zoneName, sizeof(zoneName)); FormatEx(display, sizeof(display), "%s - %s", trackName, zoneName); @@ -2581,16 +2600,22 @@ void OpenSubCustomZoneMenu(int client, int track, int zoneType) void HandleCustomZoneCookie(int client) { - char buf[1 + 2*2*TRACKS_SIZE + 1]; // version + ((start + end) * 2 chars * tracks) + NUL terminator + char buf[100]; // #define MAX_VALUE_LENGTH 100 int p = 0; +#if CZONE_VER == 'b' + for (int type = Zone_Start; type < ZONETYPES_SIZE; type++) + { + for (int track = Track_Main; track <= Track_Bonus; track++) +#else for (int type = Zone_Start; type <= Zone_End; type++) { for (int track = Track_Main; track < TRACKS_SIZE; track++) +#endif { if (gI_ZoneDisplayType[client][type][track] || gI_ZoneColor[client][type][track] || gI_ZoneWidth[client][type][track]) { - if (!p) buf[p++] = 'a'; // "version number" + if (!p) buf[p++] = CZONE_VER; // highest bit (0x80) set so we don't get a zero byte terminating the cookie early buf[p++] = 0x80 | (gI_ZoneDisplayType[client][type][track] << 5) | (type << 4) | track; buf[p++] = 0x80 | (gI_ZoneWidth[client][type][track] << 4) | gI_ZoneColor[client][type][track]; @@ -3924,6 +3949,10 @@ void DrawZone(float points[8][3], int color[4], float life, float width, bool fl 0.1, 0.5, 2.0, 8.0 }; +#if CZONE_VER == 'b' + track = (track > Track_Bonus) ? Track_Bonus : Track_Main; +#endif + int clients[MAXPLAYERS+1]; int count = 0; @@ -4343,12 +4372,12 @@ public MRESReturn DHooks_OnTeleport(int pThis, DHookParam hParams) { return MRES_Ignored; } - + if (!hParams.IsNull(1)) { gI_LatestTeleportTick[pThis] = GetGameTickCount(); } - + return MRES_Ignored; } @@ -4493,7 +4522,7 @@ public void TouchPost(int entity, int other) { static int tick_served[MAXPLAYERS + 1]; int curr_tick = GetGameTickCount(); - + // GAMMACASE: This prevents further abuses related to external events being ran after you teleport from the trigger, with events setup, outside the start zone into the start zone. // This accounts for the io events that might be set inside the start zone trigger in OnStartTouch and wont reset them! // Logic behind this code is that all events in this chain are not instantly fired, so checking if there were teleport from the outside of a start zone in last couple of ticks @@ -4520,7 +4549,7 @@ public void TouchPost(int entity, int other) tick_served[other] = 0; } } - + if (GetEntPropEnt(other, Prop_Send, "m_hGroundEntity") == -1 && !Shavit_GetStyleSettingBool(Shavit_GetBhopStyle(other), "startinair")) { return; diff --git a/addons/sourcemod/translations/shavit-common.phrases.txt b/addons/sourcemod/translations/shavit-common.phrases.txt index ab369de3..d05e1d41 100644 --- a/addons/sourcemod/translations/shavit-common.phrases.txt +++ b/addons/sourcemod/translations/shavit-common.phrases.txt @@ -18,6 +18,10 @@ "#format" "{1:d}" "en" "Bonus {1}" } + "Track_Bonus_NoNum" + { + "en" "Bonus" + } // ---------- Commands ---------- // "NoCommandAccess" {