From fb96d3511cb79866c96bf587ab6ec158b2405b31 Mon Sep 17 00:00:00 2001 From: Shachar Date: Wed, 13 Mar 2024 12:08:46 +0200 Subject: [PATCH] Fixed an error on map start --- src/ST-Map/Map.cs | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/ST-Map/Map.cs b/src/ST-Map/Map.cs index 8155bac..e217ae3 100644 --- a/src/ST-Map/Map.cs +++ b/src/ST-Map/Map.cs @@ -298,19 +298,20 @@ GROUP BY MapTimes.type this.ConnectedMapTimes.Clear(); while (mapWrData.Read()) { - if (mapWrData.GetInt32("type") > 0) + if (mapWrData.GetInt32("type") == 1) { - this.BonusWR[mapWrData.GetInt32("type")][style].ID = mapWrData.GetInt32("id"); // WR ID for the Map and Style combo - this.BonusWR[mapWrData.GetInt32("type")][style].Ticks = mapWrData.GetInt32("run_time"); // Fastest run time (WR) for the Map and Style combo - this.BonusWR[mapWrData.GetInt32("type")][style].Type = mapWrData.GetInt32("type"); // Bonus type (0 = map, 1+ = bonus index) - this.BonusWR[mapWrData.GetInt32("type")][style].StartVelX = mapWrData.GetFloat("start_vel_x"); // Fastest run start velocity X for the Map and Style combo - this.BonusWR[mapWrData.GetInt32("type")][style].StartVelY = mapWrData.GetFloat("start_vel_y"); // Fastest run start velocity Y for the Map and Style combo - this.BonusWR[mapWrData.GetInt32("type")][style].StartVelZ = mapWrData.GetFloat("start_vel_z"); // Fastest run start velocity Z for the Map and Style combo - this.BonusWR[mapWrData.GetInt32("type")][style].EndVelX = mapWrData.GetFloat("end_vel_x"); // Fastest run end velocity X for the Map and Style combo - this.BonusWR[mapWrData.GetInt32("type")][style].EndVelY = mapWrData.GetFloat("end_vel_y"); // Fastest run end velocity Y for the Map and Style combo - this.BonusWR[mapWrData.GetInt32("type")][style].EndVelZ = mapWrData.GetFloat("end_vel_z"); // Fastest run end velocity Z for the Map and Style combo - this.BonusWR[mapWrData.GetInt32("type")][style].RunDate = mapWrData.GetInt32("run_date"); // Fastest run date for the Map and Style combo - this.BonusWR[mapWrData.GetInt32("type")][style].Name = mapWrData.GetString("name"); // Fastest run player name for the Map and Style combo + int bonusNum = mapWrData.GetInt32("stage") - 1; + this.BonusWR[bonusNum][style].ID = mapWrData.GetInt32("id"); // WR ID for the Map and Style combo + this.BonusWR[bonusNum][style].Ticks = mapWrData.GetInt32("run_time"); // Fastest run time (WR) for the Map and Style combo + this.BonusWR[bonusNum][style].Type = mapWrData.GetInt32("type"); // Bonus type (0 = map, 1+ = bonus index) + this.BonusWR[bonusNum][style].StartVelX = mapWrData.GetFloat("start_vel_x"); // Fastest run start velocity X for the Map and Style combo + this.BonusWR[bonusNum][style].StartVelY = mapWrData.GetFloat("start_vel_y"); // Fastest run start velocity Y for the Map and Style combo + this.BonusWR[bonusNum][style].StartVelZ = mapWrData.GetFloat("start_vel_z"); // Fastest run start velocity Z for the Map and Style combo + this.BonusWR[bonusNum][style].EndVelX = mapWrData.GetFloat("end_vel_x"); // Fastest run end velocity X for the Map and Style combo + this.BonusWR[bonusNum][style].EndVelY = mapWrData.GetFloat("end_vel_y"); // Fastest run end velocity Y for the Map and Style combo + this.BonusWR[bonusNum][style].EndVelZ = mapWrData.GetFloat("end_vel_z"); // Fastest run end velocity Z for the Map and Style combo + this.BonusWR[bonusNum][style].RunDate = mapWrData.GetInt32("run_date"); // Fastest run date for the Map and Style combo + this.BonusWR[bonusNum][style].Name = mapWrData.GetString("name"); // Fastest run player name for the Map and Style combo } else @@ -335,7 +336,7 @@ GROUP BY MapTimes.type // Count completions Task completionStats = DB.Query($@" - SELECT MapTimes.type, COUNT(*) as count + SELECT MapTimes.type, MapTimes.stage, COUNT(*) as count FROM MapTimes WHERE MapTimes.map_id = {this.ID} GROUP BY type; @@ -346,12 +347,14 @@ FROM MapTimes { while (completionStatsResult.Read()) { - if (completionStatsResult.GetInt32("type") > 0) + if (completionStatsResult.GetInt32("type") == 1) { // To-do: bonus completion counts - this.BonusCompletions[completionStatsResult.GetInt32("type")][style] = completionStatsResult.GetInt32("count"); + this.BonusCompletions[completionStatsResult.GetInt32("stage")][style] = completionStatsResult.GetInt32("count"); } + // Add stage completions + else { // Total completions for the map and style - this should maybe be added to PersonalBest class @@ -362,7 +365,8 @@ FROM MapTimes completionStatsResult.Close(); // Get map world record checkpoints - if (this.MapCompletions[style] != 0) + System.Console.WriteLine("Testy Test 2 ====================="); + if (this.MapCompletions.ContainsKey(style) && this.MapCompletions[style] != 0) { Task cpReader = DB.Query($"SELECT * FROM `Checkpoints` WHERE `maptime_id` = {this.WR[style].ID};"); MySqlDataReader cpWrData = cpReader.Result;