mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 18:02:16 +00:00
Save deletion (server)
This commit is contained in:
parent
eb4c65f192
commit
dcc9d72046
4 changed files with 112 additions and 17 deletions
|
@ -85,12 +85,19 @@ namespace ShiftOS.Server
|
|||
}
|
||||
catch
|
||||
{
|
||||
Program.server.DispatchTo(new Guid(guid), new NetObject("error", new ServerMessage
|
||||
try
|
||||
{
|
||||
Name = "Error",
|
||||
GUID = "Server",
|
||||
Contents = JsonConvert.SerializeObject(new MudException("Command parse error"))
|
||||
}));
|
||||
Program.server.DispatchTo(new Guid(guid), new NetObject("error", new ServerMessage
|
||||
{
|
||||
Name = "Error",
|
||||
GUID = "Server",
|
||||
Contents = JsonConvert.SerializeObject(new MudException("Command parse error"))
|
||||
}));
|
||||
}
|
||||
catch
|
||||
{
|
||||
//fuck.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -166,7 +166,49 @@ namespace ShiftOS.Server
|
|||
};
|
||||
var task = ChatBackend.StartDiscordBots();
|
||||
task.Wait();
|
||||
}
|
||||
|
||||
while (server.IsOnline)
|
||||
{
|
||||
Console.Write("> ");
|
||||
string cmd = Console.ReadLine();
|
||||
try
|
||||
{
|
||||
if (cmd.ToLower().StartsWith("decrypt "))
|
||||
{
|
||||
string username = cmd.Remove(0, 8);
|
||||
if (File.Exists("saves/" + username + ".save"))
|
||||
{
|
||||
Console.WriteLine(ReadEncFile("saves/" + username + ".save"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Save not found.");
|
||||
}
|
||||
}
|
||||
else if (cmd == "purge_all_bad_saves")
|
||||
{
|
||||
foreach(var f in Directory.GetFiles("saves"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Testing " + f + "...");
|
||||
ReadEncFile(f);
|
||||
Console.WriteLine("OK");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Not OK. Deleting.");
|
||||
File.Delete(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadEncFile(string fPath)
|
||||
{
|
||||
|
|
|
@ -139,6 +139,27 @@ namespace ShiftOS.Server
|
|||
catch { }
|
||||
}
|
||||
|
||||
[MudRequest("delete_save", typeof(ClientSave))]
|
||||
public static void DeleteSave(string guid, object contents)
|
||||
{
|
||||
var cSave = contents as ClientSave;
|
||||
|
||||
foreach(var saveFile in Directory.GetFiles("saves"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var save = JsonConvert.DeserializeObject<Save>(ReadEncFile(saveFile));
|
||||
if(save.Username == cSave.Username && save.Password == cSave.Password)
|
||||
{
|
||||
File.Delete(saveFile);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MudRequest("usr_givecp", typeof(Dictionary<string, object>))]
|
||||
public static void GiveCodepoints(string guid, object contents)
|
||||
{
|
||||
|
|
|
@ -22,13 +22,21 @@ namespace ShiftOS.Server
|
|||
shopList = JsonConvert.DeserializeObject<List<Shop>>(File.ReadAllText("shops.json"));
|
||||
|
||||
var username = args["username"] as string;
|
||||
var updateShop = JsonConvert.DeserializeObject<Shop>(contents as string);
|
||||
var updateShop = args["shop"] as Shop;
|
||||
|
||||
for (int i = 0; i < shopList.Count; i++)
|
||||
{
|
||||
if (shopList[i].Owner == username)
|
||||
if (shopList[i] == null)
|
||||
{
|
||||
shopList[i] = updateShop;
|
||||
shopList.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shopList[i].Owner == username)
|
||||
{
|
||||
shopList[i] = updateShop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,10 +57,13 @@ namespace ShiftOS.Server
|
|||
|
||||
foreach (var shop in shopFile)
|
||||
{
|
||||
if (shop.Name == newShop.Name)
|
||||
if (shop != null)
|
||||
{
|
||||
Program.ClientDispatcher.DispatchTo("shop_taken", guid, "");
|
||||
return;
|
||||
if (shop.Name == newShop.Name)
|
||||
{
|
||||
Program.ClientDispatcher.DispatchTo("shop_taken", guid, "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,9 +87,12 @@ namespace ShiftOS.Server
|
|||
|
||||
foreach (var shop in allshops)
|
||||
{
|
||||
if (shop.Owner == args["username"] as string)
|
||||
if (shop != null)
|
||||
{
|
||||
res = 1;
|
||||
if (shop.Owner == args["username"] as string)
|
||||
{
|
||||
res = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,9 +107,12 @@ namespace ShiftOS.Server
|
|||
Shop tempShop = null;
|
||||
foreach (var item in JsonConvert.DeserializeObject<List<Shop>>(File.ReadAllText("shops.json")))
|
||||
{
|
||||
if (item.Name == shopName)
|
||||
if (item != null)
|
||||
{
|
||||
tempShop = item;
|
||||
if (item.Name == shopName)
|
||||
{
|
||||
tempShop = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +141,15 @@ namespace ShiftOS.Server
|
|||
//Furthermore, this'll make the MUD Control Centre seem faster...
|
||||
for (int i = 0; i < shops.Count; i++)
|
||||
{
|
||||
shops[i].Items = new List<ShopItem>();
|
||||
if (shops[i] == null)
|
||||
{
|
||||
shops.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
shops[i].Items = new List<ShopItem>();
|
||||
}
|
||||
}
|
||||
Program.ClientDispatcher.DispatchTo("shop_all", guid, shops);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue