mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-16 17:04:44 +01:00
check if character level is valid
This commit is contained in:
@@ -171,8 +171,6 @@ namespace nksrv.Utils
|
|||||||
Instance = new CoreInfo();
|
Instance = new CoreInfo();
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
Logger.Info("Loaded db");
|
|
||||||
|
|
||||||
|
|
||||||
var j = JsonConvert.DeserializeObject<CoreInfo>(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/db.json"));
|
var j = JsonConvert.DeserializeObject<CoreInfo>(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/db.json"));
|
||||||
if (j != null)
|
if (j != null)
|
||||||
@@ -215,12 +213,32 @@ namespace nksrv.Utils
|
|||||||
Console.WriteLine("Database update completed");
|
Console.WriteLine("Database update completed");
|
||||||
}
|
}
|
||||||
Save();
|
Save();
|
||||||
|
|
||||||
|
ValidateDb();
|
||||||
|
Logger.Info("Loaded db");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception("Failed to read configuration json file");
|
throw new Exception("Failed to read configuration json file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ValidateDb()
|
||||||
|
{
|
||||||
|
// check if character level is valid
|
||||||
|
foreach (var item in Instance.Users)
|
||||||
|
{
|
||||||
|
foreach (var c in item.Characters)
|
||||||
|
{
|
||||||
|
if (c.Level > 1000)
|
||||||
|
{
|
||||||
|
Logger.Warn($"Warning: Character level for character {c.Tid} cannot be above 1000, setting to 1000");
|
||||||
|
c.Level = 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static User? GetUser(ulong id)
|
public static User? GetUser(ulong id)
|
||||||
{
|
{
|
||||||
return Instance.Users.Where(x => x.ID == id).FirstOrDefault();
|
return Instance.Users.Where(x => x.ID == id).FirstOrDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user