diff options
| author | Michael <[email protected]> | 2017-02-09 18:32:48 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-09 18:32:48 -0500 |
| commit | c544e4081d53bcd888c8fce459c7e02f8516f5a8 (patch) | |
| tree | d654358830f21f28d417665d1a2d7946f0620efb /ShiftOS.Server/Program.cs | |
| parent | 86f204ee49fefc6dd92f7b02248a3dddb1fca400 (diff) | |
| download | shiftos_thereturn-c544e4081d53bcd888c8fce459c7e02f8516f5a8.tar.gz shiftos_thereturn-c544e4081d53bcd888c8fce459c7e02f8516f5a8.tar.bz2 shiftos_thereturn-c544e4081d53bcd888c8fce459c7e02f8516f5a8.zip | |
Dramatic shop optimizations.
Diffstat (limited to 'ShiftOS.Server/Program.cs')
| -rw-r--r-- | ShiftOS.Server/Program.cs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 9ac5702..bdcf10e 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -444,11 +444,45 @@ Contents: })); break; + case "shop_getitems": + var shopName = args["shopname"] as string; + Shop tempShop = null; + foreach(var item in JsonConvert.DeserializeObject<List<Shop>>(File.ReadAllText("shops.json"))) + { + if(item.Name == shopName) + { + tempShop = item; + } + } + + if(tempShop != null) + foreach(var item in tempShop.Items) + { + server.DispatchTo(new Guid(msg.GUID), new NetObject("item", new ServerMessage + { + Name = "shop_additem", + GUID = "server", + Contents = JsonConvert.SerializeObject(new + { + shop = shopName, + itemdata = item + }) + })); + } + + break; case "shop_getall": List<Shop> shops = new List<Shop>(); if (File.Exists("shops.json")) shops = JsonConvert.DeserializeObject<List<Shop>>(File.ReadAllText("shops.json")); - + //Purge all items in all shops temporarily. + //This is to save on network bandwidth as it will take a long time to send everyone's shops down if we don't purge the stock. + //And with high bandwidth usage, we may end up DOSing our clients when too many people upload too many things. + //Furthermore, this'll make the MUD Control Centre seem faster... + for (int i = 0; i <= shops.Count; i++) + { + shops[i].Items = new List<ShopItem>(); + } server.DispatchTo(new Guid(msg.GUID), new NetObject("ladouceur", new ServerMessage { Name = "shop_all", |
