[go: up one dir, main page]

Skip to content

Commit

Permalink
don't re-load data in SaveMapTime yet
Browse files Browse the repository at this point in the history
  • Loading branch information
tslashd committed Dec 24, 2023
1 parent da28151 commit 8b6b2e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/ST-Events/TriggerStartTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ internal HookResult OnTriggerStartTouch(DynamicHook handler)
player.Stats.PB[0].RunTime = player.Timer.Ticks; // Reload the run_time for the HUD and also assign for the DB query
player.Stats.PB[0].SaveMapTime(player, DB, CurrentMap.ID); // Save the MapTime PB data
player.Stats.LoadMapTimesData(player.Profile.ID, CurrentMap.ID, DB); // Load the MapTime PB data again (will refresh the MapTime ID for the Checkpoints query)
player.Stats.PB[0].SaveCurrentRunCheckpoints(player, DB); // Save the Checkpoints PB data
player.Stats.PB[0].LoadCheckpointsForRun(DB); // Reload checkpoints for the run - we should really have this in `SaveMapTime` as well but we don't re-load PB data inside there so we need to do it here
}

#if DEBUG
Expand Down
7 changes: 5 additions & 2 deletions src/ST-Player/PlayerStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public void LoadCheckpointsForRun(TimerDatabase DB)

/// <summary>
/// Saves the `CurrentRunCheckpoints` dictionary to the database
/// We need the correct `this.ID` to be populated before calling this method otherwise Query will fail
/// </summary>
public void SaveCurrentRunCheckpoints(Player player, TimerDatabase DB) // To-do: Transactions? Player sometimes rubberbands for a bit here
{
Expand Down Expand Up @@ -248,6 +249,7 @@ public void LoadCheckpointsForRun(TimerDatabase DB)

/// <summary>
/// Saves the player's run to the database and reloads the data for the player.
/// NOTE: Not re-loading any data at this point as we need `LoadMapTimesData` to be called from here as well, otherwise we may not have the `this.ID` populated
/// </summary>
public void SaveMapTime(Player player, TimerDatabase DB, int mapId) // To-do: make `CurrentMap.ID` accessible without passing it as a parameter?
{
Expand All @@ -263,8 +265,9 @@ public void SaveMapTime(Player player, TimerDatabase DB, int mapId) // To-do: ma
throw new Exception($"CS2 Surf ERROR >> internal class PersonalBest -> SaveMapTime -> Failed to insert/update player run in database. Player: {player.Profile.Name} ({player.Profile.SteamID})");
updatePlayerRunTask.Dispose();

this.SaveCurrentRunCheckpoints(player, DB); // Save checkpoints for this run
this.LoadCheckpointsForRun(DB); // Re-Load checkpoints for this run
// Will have to LoadMapTimesData right here as well to get the ID of the run we just inserted
// this.SaveCurrentRunCheckpoints(player, DB); // Save checkpoints for this run
// this.LoadCheckpointsForRun(DB); // Re-Load checkpoints for this run
}
}

Expand Down

0 comments on commit 8b6b2e6

Please sign in to comment.