Skip to content

Commit 4faa2b5

Browse files
committed
replay bot name
1 parent 4fe1c9e commit 4faa2b5

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/ST-Map/Map.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,13 @@ public bool IsInZone(Vector zoneOrigin, float zoneCollisionRadius, Vector spawnO
231231
internal void GetMapRecordAndTotals(TimerDatabase DB, int style = 0 ) // To-do: Implement styles
232232
{
233233
// Get map world records
234-
Task<MySqlDataReader> reader = DB.Query($"SELECT * FROM `MapTimes` WHERE `map_id` = {this.ID} AND `style` = {style} ORDER BY `run_time` ASC;");
234+
Task<MySqlDataReader> reader = DB.Query($@"
235+
SELECT MapTimes.*, Player.name
236+
FROM MapTimes
237+
JOIN Player ON MapTimes.player_id = Player.id
238+
WHERE MapTimes.map_id = {this.ID} AND MapTimes.style = {style}
239+
ORDER BY MapTimes.run_time ASC;
240+
");
235241
MySqlDataReader mapWrData = reader.Result;
236242
int totalRows = 0;
237243

@@ -252,6 +258,7 @@ internal void GetMapRecordAndTotals(TimerDatabase DB, int style = 0 ) // To-do:
252258
this.WR[style].EndVelY = mapWrData.GetFloat("end_vel_y"); // Fastest run end velocity Y for the Map and Style combo
253259
this.WR[style].EndVelZ = mapWrData.GetFloat("end_vel_z"); // Fastest run end velocity Z for the Map and Style combo
254260
this.WR[style].RunDate = mapWrData.GetInt32("run_date"); // Fastest run date for the Map and Style combo
261+
this.WR[style].Name = mapWrData.GetString("name"); // Fastest run player name for the Map and Style combo
255262
}
256263
totalRows++;
257264
}

src/ST-Player/PlayerHUD.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void Display()
8888
}
8989
else if (_player.CurrMap.WR[style].ID != -1)
9090
{
91-
rankModule = FormatHUDElementHTML("Rank", $"N/A/{_player.CurrMap.TotalCompletions}", "#7882dd");
91+
rankModule = FormatHUDElementHTML("Rank", $"-/{_player.CurrMap.TotalCompletions}", "#7882dd");
9292
}
9393
// PB & WR Modules
9494
string pbModule = FormatHUDElementHTML("PB", _player.Stats.PB[style].Ticks > 0 ? FormatTime(_player.Stats.PB[style].Ticks) : "N/A", "#7882dd"); // IMPLEMENT IN PlayerStats // To-do: make Style (currently 0) be dynamic
@@ -104,8 +104,12 @@ public void Display()
104104
{
105105
if (_player.CurrMap.ReplayBot.Controller?.Pawn.SerialNum == _player.Controller.ObserverPawn.Value!.ObserverServices!.ObserverTarget.SerialNum)
106106
{
107+
// Replay HUD Modules
108+
string replayModule = $"{FormatHUDElementHTML("", "REPLAY", "red", "large")}";
109+
string nameModule = FormatHUDElementHTML($"{_player.CurrMap.WR[_player.Timer.Style].Name}", $"{FormatTime(_player.CurrMap.WR[_player.Timer.Style].Ticks)}", "#ffd500");
107110
string elapsed_ticks = FormatHUDElementHTML("Tick", $"{_player.CurrMap.ReplayBot.CurrentFrameTick}/{_player.CurrMap.ReplayBot.Frames.Count}", "#7882dd");
108-
string hud = $"{FormatHUDElementHTML("", "REPLAY", "red", "large")}<br>{elapsed_ticks}";
111+
string hud = $"{replayModule}<br>{elapsed_ticks}<br>{nameModule}";
112+
109113
_player.Controller.PrintToCenterHtml(hud);
110114
}
111115
}

src/ST-Player/PlayerStats/PersonalBest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ internal class PersonalBest
1616
public float EndVelY { get; set; }
1717
public float EndVelZ { get; set; }
1818
public int RunDate { get; set; }
19+
public string Name { get; set; } = ""; // This is used only for WRs
1920
// Add other properties as needed
2021

2122
// Constructor

src/ST-Player/Replay/ReplayPlayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private void FormatBotName(Map current_map)
125125

126126
SchemaString<CBasePlayerController> bot_name = new SchemaString<CBasePlayerController>(this.Controller, "m_iszPlayerName");
127127
// Revisit, FORMAT CORECTLLY
128-
bot_name.Set($"[WR] {PlayerHUD.FormatTime(current_map.WR[0].Ticks)}");
128+
bot_name.Set($"[WR] {current_map.WR[0].Name} | {PlayerHUD.FormatTime(current_map.WR[0].Ticks)}");
129129
Utilities.SetStateChanged(this.Controller, "CBasePlayerController", "m_iszPlayerName");
130130
}
131131
}

0 commit comments

Comments
 (0)