Skip to content

Commit

Permalink
Merge pull request #637 from shavitush/very_good_yes
Browse files Browse the repository at this point in the history
Some polishing (2.1.2)
  • Loading branch information
shavitush authored May 7, 2018
2 parents fda9d81 + 7b3e615 commit a5c6894
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 65 deletions.
4 changes: 2 additions & 2 deletions addons/sourcemod/configs/shavit-styles.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"block_d" "0" // Block +moveright (D).
"block_use" "0" // Block +use (E).
"force_hsw" "0" // Force half-sideways gameplay. 1 for regular HSW and 2 for surf-HSW.
"block_pleft" "0" // Block +left (requires shavit_core_blockleftright 1).
"block_pright" "0" // Block +right (requires shavit_core_blockleftright 1).
"block_pleft" "0" // Block +left. 2 to stop timer.
"block_pright" "0" // Block +right. 2 to stop timer.
"block_pstrafe" "0" // Prevent button inconsistencies (including +pstrafe). May have false positives when players lag. Will prevent some strafe hacks too. Set this to 2 to also stop the timer.
// Feature excluding
Expand Down
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/include/shavit.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#endif
#define _shavit_included

#define SHAVIT_VERSION "2.1.1"
#define SHAVIT_VERSION "2.1.2"
#define STYLE_LIMIT 256
#define MAX_ZONES 64

Expand Down Expand Up @@ -106,8 +106,8 @@ enum
bBlockD,
bBlockUse,
iForceHSW,
bBlockPLeft,
bBlockPRight,
iBlockPLeft,
iBlockPRight,
iBlockPStrafe,
bUnranked,
bNoReplay,
Expand Down
70 changes: 40 additions & 30 deletions addons/sourcemod/scripting/shavit-core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public Action Command_AutoBhop(int client, int args)
IntToString(view_as<int>(gB_Auto[client]), sAutoBhop, 4);
SetClientCookie(client, gH_AutoBhopCookie, sAutoBhop);

UpdateAutoBhop(client);
UpdateStyleSettings(client);

return Plugin_Handled;
}
Expand Down Expand Up @@ -700,9 +700,7 @@ void CallOnStyleChanged(int client, int oldstyle, int newstyle, bool manual)

gI_Style[client] = newstyle;

UpdateAutoBhop(client);
UpdateAiraccelerate(client);
UpdateBunnyhopping(client);
UpdateStyleSettings(client);
}

void ChangeClientStyle(int client, int style, bool manual)
Expand Down Expand Up @@ -1034,6 +1032,14 @@ public int Native_StopChatSound(Handle handler, int numParams)
public int Native_PrintToChat(Handle handler, int numParams)
{
int client = GetNativeCell(1);

if(!IsClientInGame(client))
{
gB_StopChatSound = false;

return;
}

static int iWritten = 0; // useless?

char[] sBuffer = new char[300];
Expand Down Expand Up @@ -1317,7 +1323,7 @@ public void OnClientDisconnect(int client)

public void OnClientCookiesCached(int client)
{
if(IsFakeClient(client))
if(IsFakeClient(client) || !IsClientInGame(client))
{
return;
}
Expand All @@ -1336,22 +1342,25 @@ public void OnClientCookiesCached(int client)
if(gB_StyleCookies && gH_StyleCookie != null)
{
GetClientCookie(client, gH_StyleCookie, sCookie, 4);
style = StringToInt(sCookie);
int newstyle = StringToInt(sCookie);

if(0 <= newstyle < gI_Styles)
{
style = newstyle;
}
}

int newstyle = (style >= 0 && style < gI_Styles)? style:gI_DefaultStyle;

if(Shavit_HasStyleAccess(client, newstyle))
if(Shavit_HasStyleAccess(client, style))
{
CallOnStyleChanged(client, gI_Style[client], newstyle, false);
CallOnStyleChanged(client, gI_Style[client], style, false);
}
}

public void OnClientPutInServer(int client)
{
StopTimer(client);

if(IsClientConnected(client) && IsFakeClient(client))
if(!IsClientConnected(client) || IsFakeClient(client))
{
return;
}
Expand All @@ -1362,6 +1371,7 @@ public void OnClientPutInServer(int client)
gB_PracticeMode[client] = false;
gI_SHSW_FirstCombination[client] = -1;
gI_Track[client] = 0;
gI_Style[client] = 0;

if(AreClientCookiesCached(client))
{
Expand Down Expand Up @@ -1490,8 +1500,8 @@ bool LoadStyles()
gA_StyleSettings[i][bBlockD] = view_as<bool>(kv.GetNum("block_d", 0));
gA_StyleSettings[i][bBlockUse] = view_as<bool>(kv.GetNum("block_use", 0));
gA_StyleSettings[i][iForceHSW] = kv.GetNum("force_hsw", 0);
gA_StyleSettings[i][bBlockPLeft] = view_as<bool>(kv.GetNum("block_pleft", 0));
gA_StyleSettings[i][bBlockPRight] = view_as<bool>(kv.GetNum("block_pright", 0));
gA_StyleSettings[i][iBlockPLeft] = kv.GetNum("block_pleft", 0);
gA_StyleSettings[i][iBlockPRight] = kv.GetNum("block_pright", 0);
gA_StyleSettings[i][iBlockPStrafe] = kv.GetNum("block_pstrafe", 0);
gA_StyleSettings[i][bUnranked] = view_as<bool>(kv.GetNum("unranked", 0));
gA_StyleSettings[i][bNoReplay] = view_as<bool>(kv.GetNum("noreplay", 0));
Expand Down Expand Up @@ -1913,14 +1923,19 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3

if(gB_TimerEnabled[client] && !gB_ClientPaused[client])
{
char[] sCheatDetected = new char[64];

// +left/right block
if(!gB_Zones || (!bInStart && ((gA_StyleSettings[gI_Style[client]][bBlockPLeft] &&
(buttons & IN_LEFT) > 0) || (gA_StyleSettings[gI_Style[client]][bBlockPRight] && (buttons & IN_RIGHT) > 0))))
if(!gB_Zones || (!bInStart && ((gA_StyleSettings[gI_Style[client]][iBlockPLeft] > 0 &&
(buttons & IN_LEFT) > 0) || (gA_StyleSettings[gI_Style[client]][iBlockPRight] > 0 && (buttons & IN_RIGHT) > 0))))
{
FormatEx(sCheatDetected, 64, "%T", "LeftRightCheat", client);
StopTimer_Cheat(client, sCheatDetected);
vel[0] = 0.0;
vel[1] = 0.0;

if(gA_StyleSettings[gI_Style[client]][iBlockPRight] >= 2)
{
char[] sCheatDetected = new char[64];
FormatEx(sCheatDetected, 64, "%T", "LeftRightCheat", client);
StopTimer_Cheat(client, sCheatDetected);
}
}

// +strafe block
Expand All @@ -1932,6 +1947,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
{
if(gA_StyleSettings[gI_Style[client]][iBlockPStrafe] >= 2)
{
char[] sCheatDetected = new char[64];
FormatEx(sCheatDetected, 64, "%T", "Inconsistencies", client);
StopTimer_Cheat(client, sCheatDetected);
}
Expand Down Expand Up @@ -2242,25 +2258,19 @@ void StopTimer_Cheat(int client, const char[] message)
Shavit_PrintToChat(client, "%T", "CheatTimerStop", client, gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText], message);
}

void UpdateAutoBhop(int client)
void UpdateStyleSettings(int client)
{
if(sv_autobunnyhopping != null)
{
sv_autobunnyhopping.ReplicateToClient(client, (gA_StyleSettings[gI_Style[client]][bAutobhop] && gB_Auto[client])? "1":"0");
}
}

void UpdateAiraccelerate(int client)
{
char[] sAiraccelerate = new char[8];
FloatToString(gA_StyleSettings[gI_Style[client]][fAiraccelerate], sAiraccelerate, 8);
sv_airaccelerate.ReplicateToClient(client, sAiraccelerate);
}

void UpdateBunnyhopping(int client)
{
if(sv_enablebunnyhopping != null)
{
sv_enablebunnyhopping.ReplicateToClient(client, (gA_StyleSettings[gI_Style[client]][bEnableBunnyhopping])? "1":"0");
}

char[] sAiraccelerate = new char[8];
FloatToString(gA_StyleSettings[gI_Style[client]][fAiraccelerate], sAiraccelerate, 8);
sv_airaccelerate.ReplicateToClient(client, sAiraccelerate);
}
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/shavit-misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ public void Shavit_OnStyleChanged(int client, int oldstyle, int newstyle, int tr
{
gI_Style[client] = newstyle;

if(StrContains(gS_StyleStrings[oldstyle][sSpecialString], "segments") == -1 &&
StrContains(gS_StyleStrings[newstyle][sSpecialString], "segments") != -1)
if(StrContains(gS_StyleStrings[newstyle][sSpecialString], "segments") != -1)
{
OpenCheckpointsMenu(client, 0);
Shavit_PrintToChat(client, "%T", "MiscSegmentedCommand", client, gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
Expand Down Expand Up @@ -2729,6 +2728,7 @@ void SaveState(int client)

if(gB_Replay)
{
delete gA_SaveFrames[client];
gA_SaveFrames[client] = Shavit_GetReplayData(client);
}

Expand Down
37 changes: 9 additions & 28 deletions addons/sourcemod/scripting/shavit-replay.sp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ bool gB_ForciblyStopped = false;
bool gB_Button[MAXPLAYERS+1];
int gI_PlayerFrames[MAXPLAYERS+1];
ArrayList gA_PlayerFrames[MAXPLAYERS+1];
bool gB_Record[MAXPLAYERS+1];
int gI_Track[MAXPLAYERS+1];

bool gB_Late = false;
Expand Down Expand Up @@ -442,11 +441,6 @@ public int Native_SetReplayData(Handle handler, int numParams)
delete frames;

gI_PlayerFrames[client] = gA_PlayerFrames[client].Length;

if(gI_PlayerFrames[client] > 0)
{
gB_Record[client] = true;
}
}

public int Native_GetReplayData(Handle handler, int numParams)
Expand Down Expand Up @@ -1325,7 +1319,6 @@ public void OnClientDisconnect(int client)
public Action Shavit_OnStart(int client)
{
ClearFrames(client);
gB_Record[client] = true;

return Plugin_Continue;
}
Expand All @@ -1349,8 +1342,6 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
return;
}

gB_Record[client] = false;

bool newformat = view_as<bool>(gA_FrameCache[style][track][2]);
float length = GetReplayLength(style, track);

Expand Down Expand Up @@ -1425,26 +1416,16 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
ClearFrames(client);
}

public void Shavit_OnPause(int client)
{
gB_Record[client] = false;
}

public void Shavit_OnResume(int client)
{
gB_Record[client] = true;
}

void ModifyFlags(int &flags, int flag, bool add)
void ApplyFlags(int &flags1, int flags2, int flag)
{
if(add)
if((flags2 & flag) > 0)
{
flags |= flag;
flags1 |= flag;
}

else
{
flags &= flag;
flags2 &= ~flag;
}
}

Expand Down Expand Up @@ -1571,10 +1552,10 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
int iReplayFlags = gA_Frames[style][track].Get(gI_ReplayTick[style], 6);
int iEntityFlags = GetEntityFlags(client);

ModifyFlags(iEntityFlags, FL_ONGROUND, (iReplayFlags & FL_ONGROUND) > 0);
ModifyFlags(iEntityFlags, FL_PARTIALGROUND, (iReplayFlags & FL_PARTIALGROUND) > 0);
ModifyFlags(iEntityFlags, FL_INWATER, (iReplayFlags & FL_INWATER) > 0);
ModifyFlags(iEntityFlags, FL_SWIM, (iReplayFlags & FL_SWIM) > 0);
ApplyFlags(iEntityFlags, iReplayFlags, FL_ONGROUND);
ApplyFlags(iEntityFlags, iReplayFlags, FL_PARTIALGROUND);
ApplyFlags(iEntityFlags, iReplayFlags, FL_INWATER);
ApplyFlags(iEntityFlags, iReplayFlags, FL_SWIM);

SetEntityFlags(client, iEntityFlags);

Expand Down Expand Up @@ -1619,7 +1600,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
}
}

else if(gB_Record[client] && ReplayEnabled(Shavit_GetBhopStyle(client)) && Shavit_GetTimerStatus(client) == Timer_Running)
else if(Shavit_GetTimerStatus(client) == Timer_Running && ReplayEnabled(Shavit_GetBhopStyle(client)) && Shavit_GetTimerStatus(client) == Timer_Running)
{
gA_PlayerFrames[client].Resize(gI_PlayerFrames[client] + 1);

Expand Down

0 comments on commit a5c6894

Please sign in to comment.