Adds configuration system. (#125)

This commit is contained in:
Kamron Batman 2020-05-02 16:44:05 -07:00 • committed by GitHub
parent 2b4a6e1de1
commit 5b01754e3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 409 additions and 420 deletions

View file

@ -130,24 +130,17 @@ namespace Server
{
Console.WriteLine("failed");
if (!Core.Service)
{
Console.WriteLine("Error: Type '{0}' was not found. Delete all of those types? (y/n)", typeName);
Console.WriteLine("Error: Type '{0}' was not found. Delete all of those types? (y/n)", typeName);
if (Console.ReadKey(true).Key == ConsoleKey.Y)
{
types.Add(null);
Console.Write("World: Loading...");
continue;
}
Console.WriteLine("Types will not be deleted. An exception will be thrown.");
}
else
if (Console.ReadKey(true).Key == ConsoleKey.Y)
{
Console.WriteLine("Error: Type '{0}' was not found.", typeName);
types.Add(null);
Console.Write("World: Loading...");
continue;
}
Console.WriteLine("Types will not be deleted. An exception will be thrown.");
throw new Exception($"Bad type '{typeName}'");
}
@ -454,46 +447,39 @@ namespace Server
Console.WriteLine(" - Type: {0}", failedType);
Console.WriteLine(" - Serial: {0}", failedSerial);
if (!Core.Service)
Console.WriteLine("Delete the object? (y/n)");
if (Console.ReadKey(true).Key == ConsoleKey.Y)
{
Console.WriteLine("Delete the object? (y/n)");
if (Console.ReadKey(true).Key == ConsoleKey.Y)
if (failedType != typeof(BaseGuild))
{
if (failedType != typeof(BaseGuild))
Console.WriteLine("Delete all objects of that type? (y/n)");
if (Console.ReadKey(true).Key == ConsoleKey.Y)
{
Console.WriteLine("Delete all objects of that type? (y/n)");
if (Console.ReadKey(true).Key == ConsoleKey.Y)
{
if (failedMobiles)
for (var i = 0; i < mobiles.Count;)
if (mobiles[i].TypeID == failedTypeID)
mobiles.RemoveAt(i);
else
++i;
else if (failedItems)
for (var i = 0; i < items.Count;)
if (items[i].TypeID == failedTypeID)
items.RemoveAt(i);
else
++i;
}
if (failedMobiles)
for (var i = 0; i < mobiles.Count;)
if (mobiles[i].TypeID == failedTypeID)
mobiles.RemoveAt(i);
else
++i;
else if (failedItems)
for (var i = 0; i < items.Count;)
if (items[i].TypeID == failedTypeID)
items.RemoveAt(i);
else
++i;
}
SaveIndex(mobiles, MobileIndexPath);
SaveIndex(items, ItemIndexPath);
SaveIndex(guilds, GuildIndexPath);
}
Console.WriteLine("After pressing return an exception will be thrown and the server will terminate.");
Console.ReadLine();
}
else
{
Console.WriteLine("An exception will be thrown and the server will terminate.");
SaveIndex(mobiles, MobileIndexPath);
SaveIndex(items, ItemIndexPath);
SaveIndex(guilds, GuildIndexPath);
}
Console.WriteLine("After pressing return an exception will be thrown and the server will terminate.");
Console.ReadLine();
throw new Exception(
$"Load failed (items={failedItems}, mobiles={failedMobiles}, guilds={failedGuilds}, type={failedType}, serial={failedSerial})",
failed);