From eb74fa6eecabdd1103f6c2fe9cff844ab72addd0 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 23 Jun 2024 17:17:54 -0400 Subject: [PATCH] Fix region data loading to prevent deletion of telehub spawnpoints Signed-off-by: UbitUmarov --- OpenSim/Data/PGSQL/PGSQLSimulationData.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs index b0b4639db1..a743cc835b 100755 --- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs +++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs @@ -896,7 +896,7 @@ namespace OpenSim.Data.PGSQL public RegionSettings LoadRegionSettings(UUID regionUUID) { string sql = @"select * from regionsettings where ""regionUUID"" = :regionUUID"; - RegionSettings regionSettings; + RegionSettings regionSettings = null; using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) { @@ -908,10 +908,13 @@ namespace OpenSim.Data.PGSQL { regionSettings = BuildRegionSettings(reader); regionSettings.OnSave += StoreRegionSettings; - - return regionSettings; } } + if (regionSettings != null) + { + LoadSpawnPoints(regionSettings); + return regionSettings; + } } //If we reach this point then there are new region settings for that region @@ -1970,14 +1973,14 @@ namespace OpenSim.Data.PGSQL conn.Open(); using (NpgsqlDataReader reader = cmd.ExecuteReader()) { - if (reader.Read()) + while (reader.Read()) { - SpawnPoint sp = new SpawnPoint(); - - sp.Yaw = (float)reader["Yaw"]; - sp.Pitch = (float)reader["Pitch"]; - sp.Distance = (float)reader["Distance"]; - + var sp = new SpawnPoint + { + Yaw = Convert.ToSingle(reader["Yaw"]), + Pitch = Convert.ToSingle(reader["Pitch"]), + Distance = Convert.ToSingle(reader["Distance"]) + }; rs.AddSpawnPoint(sp); } }