mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-09 03:18:25 +00:00
Fixed segmented CPs and made !save match !cp's save behavior.
This commit is contained in:
parent
a584082fd7
commit
5a933fd135
@ -53,7 +53,7 @@ enum CheckpointsCache
|
|||||||
iCPClassname,
|
iCPClassname,
|
||||||
ArrayList:aCPFrames,
|
ArrayList:aCPFrames,
|
||||||
bool:bCPSegmented,
|
bool:bCPSegmented,
|
||||||
bool:bCPSpectated,
|
iCPSerial,
|
||||||
iCPGroundEntity,
|
iCPGroundEntity,
|
||||||
PCPCACHE_SIZE
|
PCPCACHE_SIZE
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ public void OnPluginStart()
|
|||||||
RegConsoleCmd("sm_cp", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
|
RegConsoleCmd("sm_cp", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
|
||||||
RegConsoleCmd("sm_checkpoint", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
|
RegConsoleCmd("sm_checkpoint", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
|
||||||
RegConsoleCmd("sm_checkpoints", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
|
RegConsoleCmd("sm_checkpoints", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
|
||||||
RegConsoleCmd("sm_save", Command_Save, "Saves checkpoint. Usage: sm_save [number]");
|
RegConsoleCmd("sm_save", Command_Save, "Saves checkpoint.");
|
||||||
RegConsoleCmd("sm_tele", Command_Tele, "Teleports to checkpoint. Usage: sm_tele [number]");
|
RegConsoleCmd("sm_tele", Command_Tele, "Teleports to checkpoint. Usage: sm_tele [number]");
|
||||||
gH_CheckpointsCookie = RegClientCookie("shavit_checkpoints", "Checkpoints settings", CookieAccess_Protected);
|
gH_CheckpointsCookie = RegClientCookie("shavit_checkpoints", "Checkpoints settings", CookieAccess_Protected);
|
||||||
gSM_Checkpoints = new StringMap();
|
gSM_Checkpoints = new StringMap();
|
||||||
@ -1516,9 +1516,9 @@ public Action Command_Save(int client, int args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int iMaxCPs = GetMaxCPs(client);
|
int iMaxCPs = GetMaxCPs(client);
|
||||||
bool bSegmented = CanSegment(client);
|
bool bSegmenting = CanSegment(client);
|
||||||
|
|
||||||
if(!gB_Checkpoints && !bSegmented)
|
if(!gB_Checkpoints && !bSegmenting)
|
||||||
{
|
{
|
||||||
Shavit_PrintToChat(client, "%T", "FeatureDisabled", client, gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText]);
|
Shavit_PrintToChat(client, "%T", "FeatureDisabled", client, gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText]);
|
||||||
|
|
||||||
@ -1527,34 +1527,33 @@ public Action Command_Save(int client, int args)
|
|||||||
|
|
||||||
int index = gI_CheckpointsCache[client][iCheckpoints] + 1;
|
int index = gI_CheckpointsCache[client][iCheckpoints] + 1;
|
||||||
|
|
||||||
if(args > 0)
|
|
||||||
{
|
|
||||||
char[] arg = new char[4];
|
|
||||||
GetCmdArg(1, arg, 4);
|
|
||||||
|
|
||||||
int parsed = StringToInt(arg);
|
|
||||||
|
|
||||||
if(0 < parsed <= iMaxCPs)
|
|
||||||
{
|
|
||||||
index = (parsed - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(index > iMaxCPs)
|
if(index > iMaxCPs)
|
||||||
{
|
{
|
||||||
index = iMaxCPs;
|
index = iMaxCPs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SaveCheckpoint(client, index, false))
|
bool bOverflow = gI_CheckpointsCache[client][iCheckpoints] >= iMaxCPs;
|
||||||
{
|
|
||||||
gI_CheckpointsCache[client][iCurrentCheckpoint] = index;
|
|
||||||
|
|
||||||
if(index < iMaxCPs)
|
if(!bSegmenting)
|
||||||
{
|
{
|
||||||
gI_CheckpointsCache[client][iCheckpoints]++;
|
if(bOverflow)
|
||||||
|
{
|
||||||
|
Shavit_PrintToChat(client, "%T", "MiscCheckpointsOverflow", client, index, gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
|
||||||
|
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shavit_PrintToChat(client, "%T", "MiscCheckpointsSaved", client, index, gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
|
if(SaveCheckpoint(client, index))
|
||||||
|
{
|
||||||
|
gI_CheckpointsCache[client][iCurrentCheckpoint] = ++gI_CheckpointsCache[client][iCheckpoints];
|
||||||
|
Shavit_PrintToChat(client, "%T", "MiscCheckpointsSaved", client, gI_CheckpointsCache[client][iCurrentCheckpoint], gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(SaveCheckpoint(client, index, bOverflow))
|
||||||
|
{
|
||||||
|
gI_CheckpointsCache[client][iCurrentCheckpoint] = (bOverflow)? iMaxCPs:++gI_CheckpointsCache[client][iCheckpoints];
|
||||||
|
Shavit_PrintToChat(client, "%T", "MiscCheckpointsSaved", client, gI_CheckpointsCache[client][iCurrentCheckpoint], gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
@ -1914,7 +1913,7 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
|
|||||||
cpcache[bCPSegmented] = false;
|
cpcache[bCPSegmented] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpcache[bCPSpectated] = (client != target || bCPSegmented); // spoof a segmented cp to avoid abuse(? my brain is melting rn)
|
cpcache[iCPSerial] = GetClientSerial(target);
|
||||||
|
|
||||||
if(overflow)
|
if(overflow)
|
||||||
{
|
{
|
||||||
@ -1992,7 +1991,7 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)
|
|||||||
Shavit_StopTimer(client);
|
Shavit_StopTimer(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!cpcache[bCPSegmented] || cpcache[bCPSpectated])
|
if(!cpcache[bCPSegmented] || GetClientSerial(client) != cpcache[iCPSerial])
|
||||||
{
|
{
|
||||||
Shavit_SetPracticeMode(client, true, !bInStart);
|
Shavit_SetPracticeMode(client, true, !bInStart);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,6 +83,10 @@
|
|||||||
"#format" "{1:d},{2:s},{3:s}"
|
"#format" "{1:d},{2:s},{3:s}"
|
||||||
"en" "Checkpoint {1} is {2}empty{3}."
|
"en" "Checkpoint {1} is {2}empty{3}."
|
||||||
}
|
}
|
||||||
|
"MiscCheckpointsOverflow"
|
||||||
|
{
|
||||||
|
"en" "Unable to save due to checkpoint overflow."
|
||||||
|
}
|
||||||
"MiscSegmentedCommand"
|
"MiscSegmentedCommand"
|
||||||
{
|
{
|
||||||
"#format" "{1:s},{2:s}"
|
"#format" "{1:s},{2:s}"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user