mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-09 03:18:25 +00:00
Merge branch 'very_good_yes'
This commit is contained in:
commit
8f0fd02f32
@ -23,7 +23,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#define _shavit_included
|
#define _shavit_included
|
||||||
|
|
||||||
#define SHAVIT_VERSION "2.5.7"
|
#define SHAVIT_VERSION "2.5.7a"
|
||||||
#define STYLE_LIMIT 256
|
#define STYLE_LIMIT 256
|
||||||
#define MAX_ZONES 64
|
#define MAX_ZONES 64
|
||||||
#define MAX_NAME_LENGTH_SQL 32
|
#define MAX_NAME_LENGTH_SQL 32
|
||||||
@ -396,11 +396,12 @@ stock void FormatSeconds(float time, char[] newtime, int newtimesize, bool preci
|
|||||||
float fSeconds = (iRounded % 60) + fTempTime - iRounded;
|
float fSeconds = (iRounded % 60) + fTempTime - iRounded;
|
||||||
|
|
||||||
char sSeconds[8];
|
char sSeconds[8];
|
||||||
FormatEx(sSeconds, 8, precise? "%s%.03f":"%s%.01f", (time < 0.0)? "-":"", fSeconds);
|
FormatEx(sSeconds, 8, precise? "%.03f":"%.01f", fSeconds);
|
||||||
|
|
||||||
if(fTempTime < 60.0)
|
if(fTempTime < 60.0)
|
||||||
{
|
{
|
||||||
strcopy(newtime, newtimesize, sSeconds);
|
strcopy(newtime, newtimesize, sSeconds);
|
||||||
|
FormatEx(newtime, newtimesize, "%s%s", (time < 0.0) ? "-":"", sSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -1517,6 +1518,16 @@ native bool Shavit_ReloadReplay(int style, int track, bool restart, char[] path
|
|||||||
*/
|
*/
|
||||||
native int Shavit_ReloadReplays(bool restart);
|
native int Shavit_ReloadReplays(bool restart);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets time from replay frame that is closest to client.
|
||||||
|
*
|
||||||
|
* @param Client index.
|
||||||
|
* @param Client style.
|
||||||
|
* @param Client track.
|
||||||
|
* @return Replay time.
|
||||||
|
*/
|
||||||
|
native float Shavit_GetClosestReplayTime(int client, int style, int track);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this native to stop the click sound that plays upon chat messages.
|
* Use this native to stop the click sound that plays upon chat messages.
|
||||||
* Call it before each Shavit_PrintToChat().
|
* Call it before each Shavit_PrintToChat().
|
||||||
@ -1731,6 +1742,15 @@ native void Shavit_SetCurrentCheckpoint(int client, int index);
|
|||||||
*/
|
*/
|
||||||
native int Shavit_GetPlayerPreFrame(int client);
|
native int Shavit_GetPlayerPreFrame(int client);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the number of timer preframes in the players current run.
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
*
|
||||||
|
* @return Timer preframe count
|
||||||
|
*/
|
||||||
|
native int Shavit_GetPlayerTimerframe(int client);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets player's preframe length.
|
* Sets player's preframe length.
|
||||||
*
|
*
|
||||||
@ -1751,6 +1771,16 @@ native void Shavit_SetPlayerPreFrame(int client, int PreFrame, int TimerPreFrame
|
|||||||
*/
|
*/
|
||||||
native int Shavit_GetPlayerTimerframe(int client);
|
native int Shavit_GetPlayerTimerframe(int client);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets player's timer preframe length.
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
* @param TimerPreFrame Timer start frame length
|
||||||
|
*
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
native void Shavit_SetPlayerTimerPreFrame(int client, int TimerPreFrame);
|
||||||
|
|
||||||
// same as Shavit_PrintToChat() but loops through the whole server
|
// same as Shavit_PrintToChat() but loops through the whole server
|
||||||
// code stolen from the base halflife.inc file
|
// code stolen from the base halflife.inc file
|
||||||
stock void Shavit_PrintToChatAll(const char[] format, any ...)
|
stock void Shavit_PrintToChatAll(const char[] format, any ...)
|
||||||
@ -1880,6 +1910,7 @@ public void __pl_shavit_SetNTVOptional()
|
|||||||
MarkNativeAsOptional("Shavit_SetCurrentCheckpoint");
|
MarkNativeAsOptional("Shavit_SetCurrentCheckpoint");
|
||||||
MarkNativeAsOptional("Shavit_GetPlayerPreFrame");
|
MarkNativeAsOptional("Shavit_GetPlayerPreFrame");
|
||||||
MarkNativeAsOptional("Shavit_GetPlayerTimerframe");
|
MarkNativeAsOptional("Shavit_GetPlayerTimerframe");
|
||||||
MarkNativeAsOptional("Shavit_SetPlayerPreFrame");
|
MarkNativeAsOptional("Shavit_SetPlayerPreFrame");
|
||||||
|
MarkNativeAsOptional("Shavit_GetClosestReplayTime");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -157,7 +157,6 @@ char gS_Verification[MAXPLAYERS+1][8];
|
|||||||
bool gB_CookiesRetrieved[MAXPLAYERS+1];
|
bool gB_CookiesRetrieved[MAXPLAYERS+1];
|
||||||
float gF_ZoneAiraccelerate[MAXPLAYERS+1];
|
float gF_ZoneAiraccelerate[MAXPLAYERS+1];
|
||||||
float gF_ZoneSpeedLimit[MAXPLAYERS+1];
|
float gF_ZoneSpeedLimit[MAXPLAYERS+1];
|
||||||
int gI_TickCount = 0;
|
|
||||||
|
|
||||||
// flags
|
// flags
|
||||||
int gI_StyleFlag[STYLE_LIMIT];
|
int gI_StyleFlag[STYLE_LIMIT];
|
||||||
@ -1218,7 +1217,7 @@ void VelocityChanges(int data)
|
|||||||
|
|
||||||
if(gA_Timers[client].fTimescale != -1.0)
|
if(gA_Timers[client].fTimescale != -1.0)
|
||||||
{
|
{
|
||||||
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", view_as<float>(gA_StyleSettings[gA_Timers[client].iStyle].fTimescale));
|
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", view_as<float>(gA_Timers[client].fTimescale));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -2731,7 +2730,6 @@ public void PreThinkPost(int client)
|
|||||||
|
|
||||||
public void OnGameFrame()
|
public void OnGameFrame()
|
||||||
{
|
{
|
||||||
gI_TickCount = GetGameTickCount();
|
|
||||||
float frametime = GetGameFrameTime();
|
float frametime = GetGameFrameTime();
|
||||||
|
|
||||||
for(int i = 1; i <= MaxClients; i++)
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
@ -3051,14 +3049,14 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
|
|
||||||
if(bOnGround && !gA_Timers[client].bOnGround)
|
if(bOnGround && !gA_Timers[client].bOnGround)
|
||||||
{
|
{
|
||||||
gA_Timers[client].iLandingTick = gI_TickCount;
|
gA_Timers[client].iLandingTick = tickcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(!bOnGround && gA_Timers[client].bOnGround && gA_Timers[client].bJumped)
|
else if(!bOnGround && gA_Timers[client].bOnGround && gA_Timers[client].bJumped)
|
||||||
{
|
{
|
||||||
int iDifference = (gI_TickCount - gA_Timers[client].iLandingTick);
|
int iDifference = (tickcount - gA_Timers[client].iLandingTick);
|
||||||
|
|
||||||
if(1 <= iDifference <= 8)
|
if(iDifference < 10)
|
||||||
{
|
{
|
||||||
gA_Timers[client].iMeasuredJumps++;
|
gA_Timers[client].iMeasuredJumps++;
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@
|
|||||||
#define HUD2_TRACK (1 << 7)
|
#define HUD2_TRACK (1 << 7)
|
||||||
#define HUD2_SPLITPB (1 << 8)
|
#define HUD2_SPLITPB (1 << 8)
|
||||||
#define HUD2_MAPTIER (1 << 9)
|
#define HUD2_MAPTIER (1 << 9)
|
||||||
|
#define HUD2_TIMEDIFFERENCE (1 << 10)
|
||||||
|
|
||||||
#define HUD_DEFAULT (HUD_MASTER|HUD_CENTER|HUD_ZONEHUD|HUD_OBSERVE|HUD_TOPLEFT|HUD_SYNC|HUD_TIMELEFT|HUD_2DVEL|HUD_SPECTATORS)
|
#define HUD_DEFAULT (HUD_MASTER|HUD_CENTER|HUD_ZONEHUD|HUD_OBSERVE|HUD_TOPLEFT|HUD_SYNC|HUD_TIMELEFT|HUD_2DVEL|HUD_SPECTATORS)
|
||||||
#define HUD_DEFAULT2 0
|
#define HUD_DEFAULT2 0
|
||||||
@ -646,6 +647,10 @@ Action ShowHUDMenu(int client, int item)
|
|||||||
FormatEx(sHudItem, 64, "%T", "HudTimeText", client);
|
FormatEx(sHudItem, 64, "%T", "HudTimeText", client);
|
||||||
menu.AddItem(sInfo, sHudItem);
|
menu.AddItem(sInfo, sHudItem);
|
||||||
|
|
||||||
|
FormatEx(sInfo, 16, "@%d", HUD2_TIMEDIFFERENCE);
|
||||||
|
FormatEx(sHudItem, 64, "%T", "HudTimeDiffText", client);
|
||||||
|
menu.AddItem(sInfo, sHudItem);
|
||||||
|
|
||||||
FormatEx(sInfo, 16, "@%d", HUD2_SPEED);
|
FormatEx(sInfo, 16, "@%d", HUD2_SPEED);
|
||||||
FormatEx(sHudItem, 64, "%T", "HudSpeedText", client);
|
FormatEx(sHudItem, 64, "%T", "HudSpeedText", client);
|
||||||
menu.AddItem(sInfo, sHudItem);
|
menu.AddItem(sInfo, sHudItem);
|
||||||
@ -1057,14 +1062,28 @@ int AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int max
|
|||||||
char sTime[32];
|
char sTime[32];
|
||||||
FormatSeconds(data.fTime, sTime, 32, false);
|
FormatSeconds(data.fTime, sTime, 32, false);
|
||||||
|
|
||||||
|
char sTimeDiff[32];
|
||||||
|
|
||||||
|
if(Shavit_GetReplayFrameCount(data.iStyle, data.iTrack) != 0 && (gI_HUD2Settings[client] & HUD2_TIMEDIFFERENCE) == 0)
|
||||||
|
{
|
||||||
|
float fClosestReplayTime = Shavit_GetClosestReplayTime(data.iTarget, data.iStyle, data.iTrack);
|
||||||
|
|
||||||
|
if(fClosestReplayTime != -1.0)
|
||||||
|
{
|
||||||
|
float fDifference = data.fTime - fClosestReplayTime;
|
||||||
|
FormatSeconds(fDifference, sTimeDiff, 32, false);
|
||||||
|
Format(sTimeDiff, 32, " (%s%s)", (fDifference >= 0.0)? "+":"", sTimeDiff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((gI_HUD2Settings[client] & HUD2_RANK) == 0)
|
if((gI_HUD2Settings[client] & HUD2_RANK) == 0)
|
||||||
{
|
{
|
||||||
FormatEx(sLine, 128, "%T: %s (%d)", "HudTimeText", client, sTime, data.iRank);
|
FormatEx(sLine, 128, "%T: %s%s (%d)", "HudTimeText", client, sTime, sTimeDiff, data.iRank);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FormatEx(sLine, 128, "%T: %s", "HudTimeText", client, sTime);
|
FormatEx(sLine, 128, "%T: %s%s", "HudTimeText", client, sTime, sTimeDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddHUDLine(buffer, maxlen, sLine, iLines);
|
AddHUDLine(buffer, maxlen, sLine, iLines);
|
||||||
@ -1259,15 +1278,29 @@ int AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen)
|
|||||||
|
|
||||||
char sTime[32];
|
char sTime[32];
|
||||||
FormatSeconds(data.fTime, sTime, 32, false);
|
FormatSeconds(data.fTime, sTime, 32, false);
|
||||||
|
|
||||||
|
char sTimeDiff[32];
|
||||||
|
|
||||||
|
if(Shavit_GetReplayFrameCount(data.iStyle, data.iTrack) != 0 && (gI_HUD2Settings[client] & HUD2_TIMEDIFFERENCE) == 0)
|
||||||
|
{
|
||||||
|
float fClosestReplayTime = Shavit_GetClosestReplayTime(data.iTarget, data.iStyle, data.iTrack);
|
||||||
|
|
||||||
|
if(fClosestReplayTime != -1.0)
|
||||||
|
{
|
||||||
|
float fDifference = data.fTime - fClosestReplayTime;
|
||||||
|
FormatSeconds(fDifference, sTimeDiff, 32, false);
|
||||||
|
Format(sTimeDiff, 32, " (%s%s)", (fDifference >= 0.0)? "+":"", sTimeDiff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((gI_HUD2Settings[client] & HUD2_RANK) == 0)
|
if((gI_HUD2Settings[client] & HUD2_RANK) == 0)
|
||||||
{
|
{
|
||||||
FormatEx(sLine, 128, "<span color='#%06X'>%s</span> (#%d)", iColor, sTime, data.iRank);
|
FormatEx(sLine, 128, "<span color='#%06X'>%s%s</span> (#%d)", iColor, sTime, sTimeDiff, data.iRank);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FormatEx(sLine, 128, "<span color='#%06X'>%s</span>", iColor, sTime);
|
FormatEx(sLine, 128, "<span color='#%06X'>%s%s</span>", iColor, sTime, sTimeDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddHUDLine(buffer, maxlen, sLine, iLines);
|
AddHUDLine(buffer, maxlen, sLine, iLines);
|
||||||
@ -1865,4 +1898,4 @@ void PrintCSGOHUDText(int client, const char[] format, any ...)
|
|||||||
pb.AddString("params", NULL_STRING);
|
pb.AddString("params", NULL_STRING);
|
||||||
|
|
||||||
EndMessage();
|
EndMessage();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1257,7 +1257,8 @@ public Action Timer_LoadPersistentData(Handle Timer, any data)
|
|||||||
if(gB_Replay && aData.aFrames != null)
|
if(gB_Replay && aData.aFrames != null)
|
||||||
{
|
{
|
||||||
Shavit_SetReplayData(client, aData.aFrames);
|
Shavit_SetReplayData(client, aData.aFrames);
|
||||||
Shavit_SetPlayerPreFrame(client, aData.iPreFrames, aData.iTimerPreFrames);
|
Shavit_SetPlayerPreFrame(client, aData.iPreFrames);
|
||||||
|
Shavit_SetPlayerTimerPreFrame(client, aData.iTimerPreFrames);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(aData.bPractice)
|
if(aData.bPractice)
|
||||||
@ -2563,7 +2564,8 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Shavit_SetReplayData(client, cpcache.aFrames);
|
Shavit_SetReplayData(client, cpcache.aFrames);
|
||||||
Shavit_SetPlayerPreFrame(client, cpcache.iPreFrames, cpcache.iTimerPreFrames);
|
Shavit_SetPlayerPreFrame(client, cpcache.iPreFrames);
|
||||||
|
Shavit_SetPlayerTimerPreFrame(client, cpcache.iTimerPreFrames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3277,7 +3279,7 @@ public Action NormalSound(int clients[MAXPLAYERS], int &numClients, char sample[
|
|||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StrContains(sample, "physics") != -1 || StrContains(sample, "footsteps") != -1 || StrContains(sample, "land") != -1 || StrContains(sample, "jump") != -1)
|
if(StrContains(sample, "physics/") != -1 || StrContains(sample, "weapons/") != -1 || StrContains(sample, "player/") != -1 || StrContains(sample, "items/") != -1)
|
||||||
{
|
{
|
||||||
if(gCV_BhopSounds.IntValue == 2)
|
if(gCV_BhopSounds.IntValue == 2)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -110,6 +110,7 @@ ArrayList gA_Frames[STYLE_LIMIT][TRACKS_SIZE];
|
|||||||
float gF_StartTick[STYLE_LIMIT];
|
float gF_StartTick[STYLE_LIMIT];
|
||||||
ReplayStatus gRS_ReplayStatus[STYLE_LIMIT];
|
ReplayStatus gRS_ReplayStatus[STYLE_LIMIT];
|
||||||
framecache_t gA_FrameCache[STYLE_LIMIT][TRACKS_SIZE];
|
framecache_t gA_FrameCache[STYLE_LIMIT][TRACKS_SIZE];
|
||||||
|
ArrayList gA_SortedFrames[STYLE_LIMIT][TRACKS_SIZE];
|
||||||
|
|
||||||
bool gB_ForciblyStopped = false;
|
bool gB_ForciblyStopped = false;
|
||||||
Handle gH_ReplayTimers[STYLE_LIMIT];
|
Handle gH_ReplayTimers[STYLE_LIMIT];
|
||||||
@ -210,7 +211,9 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
|||||||
CreateNative("Shavit_SetReplayData", Native_SetReplayData);
|
CreateNative("Shavit_SetReplayData", Native_SetReplayData);
|
||||||
CreateNative("Shavit_GetPlayerPreFrame", Native_GetPreFrame);
|
CreateNative("Shavit_GetPlayerPreFrame", Native_GetPreFrame);
|
||||||
CreateNative("Shavit_SetPlayerPreFrame", Native_SetPreFrame);
|
CreateNative("Shavit_SetPlayerPreFrame", Native_SetPreFrame);
|
||||||
|
CreateNative("Shavit_SetPlayerTimerPreFrame", Native_SetTimerPreFrame);
|
||||||
CreateNative("Shavit_GetPlayerTimerframe", Native_GetTimerFrame);
|
CreateNative("Shavit_GetPlayerTimerframe", Native_GetTimerFrame);
|
||||||
|
CreateNative("Shavit_GetClosestReplayTime", Native_GetClosestReplayTime);
|
||||||
|
|
||||||
// registers library, check "bool LibraryExists(const char[] name)" in order to use with other plugins
|
// registers library, check "bool LibraryExists(const char[] name)" in order to use with other plugins
|
||||||
RegPluginLibrary("shavit-replay");
|
RegPluginLibrary("shavit-replay");
|
||||||
@ -775,11 +778,25 @@ public int Native_SetPreFrame(Handle handler, int numParams)
|
|||||||
{
|
{
|
||||||
int client = GetNativeCell(1);
|
int client = GetNativeCell(1);
|
||||||
int preframes = GetNativeCell(2);
|
int preframes = GetNativeCell(2);
|
||||||
int timerframes = GetNativeCell(3);
|
|
||||||
|
|
||||||
gI_PlayerPrerunFrames[client] = preframes;
|
gI_PlayerPrerunFrames[client] = preframes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Native_SetTimerPreFrame(Handle handler, int numParams)
|
||||||
|
{
|
||||||
|
int client = GetNativeCell(1);
|
||||||
|
int timerframes = GetNativeCell(2);
|
||||||
|
|
||||||
gI_PlayerTimerStartFrames[client] = timerframes;
|
gI_PlayerTimerStartFrames[client] = timerframes;
|
||||||
gI_PlayerPrerunFrames[GetNativeCell(1)] = GetNativeCell(2);
|
}
|
||||||
|
|
||||||
|
public int Native_GetClosestReplayTime(Handle plugin, int numParams)
|
||||||
|
{
|
||||||
|
int client = GetNativeCell(1);
|
||||||
|
int style = GetNativeCell(2);
|
||||||
|
int track = GetNativeCell(3);
|
||||||
|
|
||||||
|
return view_as<int>(GetClosestReplayTime(client, style, track));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Cron(Handle Timer)
|
public Action Cron(Handle Timer)
|
||||||
@ -1113,6 +1130,7 @@ bool LoadCurrentReplayFormat(File file, int version, int style, int track)
|
|||||||
gA_FrameCache[style][track].bNewFormat = true; // not wr-based
|
gA_FrameCache[style][track].bNewFormat = true; // not wr-based
|
||||||
|
|
||||||
delete file;
|
delete file;
|
||||||
|
SortReplayFrames(style, track);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1143,6 +1161,7 @@ bool LoadV2ReplayFormat(File file, int frames, int style, int track)
|
|||||||
strcopy(gA_FrameCache[style][track].sReplayName, MAX_NAME_LENGTH, "invalid");
|
strcopy(gA_FrameCache[style][track].sReplayName, MAX_NAME_LENGTH, "invalid");
|
||||||
|
|
||||||
delete file;
|
delete file;
|
||||||
|
SortReplayFrames(style, track);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1179,6 +1198,7 @@ bool LoadOldReplayFormat(File file, int style, int track)
|
|||||||
strcopy(gA_FrameCache[style][track].sReplayName, MAX_NAME_LENGTH, "invalid");
|
strcopy(gA_FrameCache[style][track].sReplayName, MAX_NAME_LENGTH, "invalid");
|
||||||
|
|
||||||
delete file;
|
delete file;
|
||||||
|
SortReplayFrames(style, track);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1272,12 +1292,14 @@ bool SaveReplay(int style, int track, float time, int steamid, char[] name, int
|
|||||||
|
|
||||||
delete fFile;
|
delete fFile;
|
||||||
|
|
||||||
gA_FrameCache[style][track].iFrameCount = iSize;
|
gA_FrameCache[style][track].iFrameCount = preframes <= 0 ? iSize : iSize - preframes;
|
||||||
gA_FrameCache[style][track].fTime = time;
|
gA_FrameCache[style][track].fTime = time;
|
||||||
gA_FrameCache[style][track].bNewFormat = true;
|
gA_FrameCache[style][track].bNewFormat = true;
|
||||||
strcopy(gA_FrameCache[style][track].sReplayName, MAX_NAME_LENGTH, name);
|
strcopy(gA_FrameCache[style][track].sReplayName, MAX_NAME_LENGTH, name);
|
||||||
gA_FrameCache[style][track].iPreFrames = timerstartframe - preframes;
|
gA_FrameCache[style][track].iPreFrames = timerstartframe - preframes;
|
||||||
|
|
||||||
|
SortReplayFrames(style, track);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1572,6 +1594,7 @@ public void OnClientDisconnect(int client)
|
|||||||
|
|
||||||
if(!IsFakeClient(client))
|
if(!IsFakeClient(client))
|
||||||
{
|
{
|
||||||
|
ClearFrames(client);
|
||||||
RequestFrame(DeleteFrames, client);
|
RequestFrame(DeleteFrames, client);
|
||||||
ClearFrames(client);
|
ClearFrames(client);
|
||||||
|
|
||||||
@ -2164,7 +2187,10 @@ public Action Hook_SayText2(UserMsg msg_id, any msg, const int[] players, int pl
|
|||||||
|
|
||||||
void ClearFrames(int client)
|
void ClearFrames(int client)
|
||||||
{
|
{
|
||||||
gA_PlayerFrames[client].Clear();
|
if(gA_PlayerFrames[client])
|
||||||
|
{
|
||||||
|
gA_PlayerFrames[client].Clear();
|
||||||
|
}
|
||||||
gI_PlayerFrames[client] = 0;
|
gI_PlayerFrames[client] = 0;
|
||||||
gF_NextFrameTime[client] = 0.0;
|
gF_NextFrameTime[client] = 0.0;
|
||||||
gI_PlayerPrerunFrames[client] = 0;
|
gI_PlayerPrerunFrames[client] = 0;
|
||||||
@ -2716,6 +2742,153 @@ void GetReplayName(int style, int track, char[] buffer, int length)
|
|||||||
Shavit_GetWRName(style, buffer, length, track);
|
Shavit_GetWRName(style, buffer, length, track);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GetClosestReplayTime(int client, int style, int track)
|
||||||
|
{
|
||||||
|
int iFramesCount = gA_FrameCache[style][track].iFrameCount;
|
||||||
|
int iClosestFrame;
|
||||||
|
float fReplayPos[3];
|
||||||
|
float fClientPos[3];
|
||||||
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", fClientPos);
|
||||||
|
|
||||||
|
float fMinDist = 100000.0;
|
||||||
|
|
||||||
|
any data[4];
|
||||||
|
int iLength = gA_SortedFrames[style][track].Length;
|
||||||
|
int iPreframes = gA_FrameCache[style][track].iPreFrames;
|
||||||
|
|
||||||
|
// find closest index for X
|
||||||
|
int iClosestSortedIndex = FindClosestIndex(client, fClientPos[0]);
|
||||||
|
|
||||||
|
int firstFrame = iClosestSortedIndex - 1600;
|
||||||
|
if(firstFrame < 0)
|
||||||
|
{
|
||||||
|
firstFrame = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lastFrame = iClosestSortedIndex + 1600;
|
||||||
|
if(lastFrame > iLength - 1)
|
||||||
|
{
|
||||||
|
lastFrame = iLength - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int frame = firstFrame; frame <= lastFrame; frame++)
|
||||||
|
{
|
||||||
|
gA_SortedFrames[style][track].GetArray(frame, data, 4);
|
||||||
|
|
||||||
|
fReplayPos[0] = view_as<float>(data[0]);
|
||||||
|
fReplayPos[1] = view_as<float>(data[1]);
|
||||||
|
fReplayPos[2] = view_as<float>(data[2]);
|
||||||
|
|
||||||
|
float dist = GetVectorDistance(fClientPos, fReplayPos, false);
|
||||||
|
if(dist < fMinDist)
|
||||||
|
{
|
||||||
|
fMinDist = dist;
|
||||||
|
iClosestFrame = view_as<int>(data[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fMinDist > 1000)
|
||||||
|
{
|
||||||
|
return -1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return float(iClosestFrame - iPreframes) / float(iFramesCount - iPreframes) * GetReplayLength(style, track);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SortReplayFrames(int style, int track)
|
||||||
|
{
|
||||||
|
gA_SortedFrames[style][track] = new ArrayList(4);
|
||||||
|
gA_SortedFrames[style][track].Clear();
|
||||||
|
|
||||||
|
any replayData[CELLS_PER_FRAME];
|
||||||
|
any sortedData[4];
|
||||||
|
|
||||||
|
int iPreframes = gA_FrameCache[style][track].iPreFrames;
|
||||||
|
int iSize = gA_Frames[style][track].Length;
|
||||||
|
|
||||||
|
for(int frame = iPreframes; frame < iSize; frame++)
|
||||||
|
{
|
||||||
|
gA_Frames[style][track].GetArray(frame, replayData, CELLS_PER_FRAME);
|
||||||
|
sortedData[0] = view_as<float>(replayData[0]);
|
||||||
|
sortedData[1] = view_as<float>(replayData[1]);
|
||||||
|
sortedData[2] = view_as<float>(replayData[2]);
|
||||||
|
sortedData[3] = frame;
|
||||||
|
|
||||||
|
gA_SortedFrames[style][track].PushArray(sortedData, 4);
|
||||||
|
}
|
||||||
|
SortADTArray(gA_SortedFrames[style][track], Sort_Ascending, Sort_Float);
|
||||||
|
}
|
||||||
|
|
||||||
|
int FindClosestIndex(int client, float target)
|
||||||
|
{
|
||||||
|
int style = Shavit_GetBhopStyle(client);
|
||||||
|
int track = Shavit_GetClientTrack(client);
|
||||||
|
int length = gA_SortedFrames[style][track].Length;
|
||||||
|
|
||||||
|
float posX[3];
|
||||||
|
float posX_comp[3];
|
||||||
|
any data[CELLS_PER_FRAME];
|
||||||
|
any data_comp[CELLS_PER_FRAME];
|
||||||
|
|
||||||
|
// first frame
|
||||||
|
gA_SortedFrames[style][track].GetArray(0, data, CELLS_PER_FRAME);
|
||||||
|
posX[0] = view_as<float>(data[0]);
|
||||||
|
if(target <= posX[0])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// last frame
|
||||||
|
gA_SortedFrames[style][track].GetArray(length - 1, data, CELLS_PER_FRAME);
|
||||||
|
posX[0] = view_as<float>(data[0]);
|
||||||
|
if(target >= posX[0])
|
||||||
|
{
|
||||||
|
return length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// search
|
||||||
|
int i = 0, j = length, mid = 0;
|
||||||
|
while(i < j)
|
||||||
|
{
|
||||||
|
mid = (i + j) / 2;
|
||||||
|
gA_SortedFrames[style][track].GetArray(mid, data, CELLS_PER_FRAME);
|
||||||
|
posX[0] = view_as<float>(data[0]);
|
||||||
|
|
||||||
|
if(posX[0] == target)
|
||||||
|
{
|
||||||
|
return mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(target < posX[0])
|
||||||
|
{
|
||||||
|
gA_SortedFrames[style][track].GetArray(mid - 1, data_comp, CELLS_PER_FRAME);
|
||||||
|
posX_comp[0] = view_as<float>(data_comp[0]);
|
||||||
|
if(mid > 0 && target > posX_comp[0])
|
||||||
|
{
|
||||||
|
return mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
j = mid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gA_SortedFrames[style][track].GetArray(mid + 1, data_comp, CELLS_PER_FRAME);
|
||||||
|
posX_comp[0] = view_as<float>(data_comp[0]);
|
||||||
|
if(mid < length - 1 && target < posX_comp[0])
|
||||||
|
{
|
||||||
|
return mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = mid + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mid;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copies file source to destination
|
* Copies file source to destination
|
||||||
* Based on code of javalia:
|
* Based on code of javalia:
|
||||||
|
|||||||
@ -43,6 +43,10 @@
|
|||||||
{
|
{
|
||||||
"en" "Time"
|
"en" "Time"
|
||||||
}
|
}
|
||||||
|
"HudTimeDiffText"
|
||||||
|
{
|
||||||
|
"en" "Time difference"
|
||||||
|
}
|
||||||
"HudBestText"
|
"HudBestText"
|
||||||
{
|
{
|
||||||
"en" "Best"
|
"en" "Best"
|
||||||
@ -153,6 +157,10 @@
|
|||||||
{
|
{
|
||||||
"en" "Map tier"
|
"en" "Map tier"
|
||||||
}
|
}
|
||||||
|
"HudTimeDifference"
|
||||||
|
{
|
||||||
|
"en" "Time Difference"
|
||||||
|
}
|
||||||
// ---------- Record Bots ---------- //
|
// ---------- Record Bots ---------- //
|
||||||
"ReplayText"
|
"ReplayText"
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user