protected void LoadMap(string embeddedResource, MapType type) { if (embeddedResource == null) { return; } var stream = typeof(RealmManager).Assembly.GetManifestResourceStream(embeddedResource); if (stream == null) { throw new ArgumentException("Resource not found", nameof(embeddedResource)); } switch (type) { case MapType.Wmap: FromWorldMap(stream); break; case MapType.Json: FromWorldMap(new MemoryStream(Json2Wmap.Convert(Manager, new StreamReader(stream).ReadToEnd()))); break; default: throw new ArgumentException("Invalid MapType"); } }
protected void LoadMap(string embeddedResource, MapType type) { if (embeddedResource == null) { return; } string mapType = type == MapType.Json ? "json" : "wmap"; string resource = embeddedResource.Replace($".{mapType}", ""); var stream = typeof(RealmManager).Assembly.GetManifestResourceStream($"gameserver.realm.world.maps.{mapType}.{resource}.{mapType}"); if (stream == null) { throw new ArgumentException($"{mapType.ToUpper()} map resource " + nameof(resource) + " not found!"); } switch (type) { case MapType.Wmap: FromWorldMap(stream); break; case MapType.Json: FromWorldMap(new MemoryStream(Json2Wmap.Convert(Manager.GameData, new StreamReader(stream).ReadToEnd()))); break; default: throw new ArgumentException("Invalid MapType"); } }
public void FromJsonStream(Stream dat) { byte[] data = {}; dat.Read(data, 0, (int)dat.Length); var json = Encoding.ASCII.GetString(data); var wmap = Json2Wmap.Convert(json); FromWorldMap(new MemoryStream(wmap)); } //not working
public ExportedMap(string json, string n) { js = json; name = n; Name = n; Background = 0; AllowTeleport = true; base.FromWorldMap(new MemoryStream(Json2Wmap.Convert(json))); }
public void LoadJson(string json) { if (!JsonLoaded) { FromWorldMap(new MemoryStream(Json2Wmap.Convert(Manager.Resources.GameData, json))); JsonLoaded = true; } InitShops(); }
public XMLWorld(DungeonDesc desc) { this.d = desc; string json = new WebClient().DownloadString(desc.Json); Name = desc.Name; Background = desc.Background; AllowTeleport = desc.AllowTeleport; base.FromWorldMap(new MemoryStream(Json2Wmap.Convert(json))); }
public void FromJsonMap(string file) { if (File.Exists(file)) { var wmap = Json2Wmap.Convert(File.ReadAllText(file)); FromWorldMap(new MemoryStream(wmap)); } else { throw new FileNotFoundException("Json file not found!", file); } }
protected void LoadFromJson(string embeddedResource) { if (embeddedResource == null) { return; } var stream = typeof(RealmManager).Assembly.GetManifestResourceStream(embeddedResource); if (stream == null) { throw new ArgumentException("Resource not found", nameof(embeddedResource)); } FromWorldMap(new MemoryStream(Json2Wmap.Convert(Manager.GameData, new StreamReader(stream).ReadToEnd()))); }
public unsafe void LoadJson(void *world, string embeddedResource, IntPoint *pos, void *wmap) { if (embeddedResource == null) { return; } string resource = embeddedResource.Replace(".jm", ""); Stream stream = typeof(RealmManager).Assembly.GetManifestResourceStream("gameserver.realm.mapsetpiece.maps." + resource + ".jm"); if (stream == null) { throw new ArgumentException("JSON map resource " + nameof(resource) + " not found!"); } FromWorldMap(new MemoryStream(Json2Wmap.Convert((GCHandle.FromIntPtr(new IntPtr(world)).Target as World).Manager.GameData, new StreamReader(stream).ReadToEnd())), world, pos, wmap); }
public WorldData(string dir, XmlData gameData) { Dictionary <string, ProtoWorld> worlds; Data = new ReadOnlyDictionary <string, ProtoWorld>( worlds = new Dictionary <string, ProtoWorld>()); // load up worlds string basePath = Path.GetFullPath(dir); var jwFiles = Directory.EnumerateFiles(basePath, "*.jw", SearchOption.TopDirectoryOnly).ToArray(); for (var i = 0; i < jwFiles.Length; i++) { Log.InfoFormat("Initializing world data: " + Path.GetFileName(jwFiles[i]) + " {0}/{1}...", i + 1, jwFiles.Length); var jw = File.ReadAllText(jwFiles[i]); var world = JsonConvert.DeserializeObject <ProtoWorld>(jw); if (world.maps == null) { var jm = File.ReadAllText(jwFiles[i].Substring(0, jwFiles[i].Length - 1) + "m"); world.wmap = new byte[1][]; world.wmap[0] = Json2Wmap.Convert(gameData, jm); worlds.Add(world.name, world); continue; } world.wmap = new byte[world.maps.Length][]; var di = Directory.GetParent(jwFiles[i]); for (var j = 0; j < world.maps.Length; j++) { var mapFile = Path.Combine(di.FullName, world.maps[j]); if (world.maps[j].EndsWith(".wmap")) { world.wmap[j] = File.ReadAllBytes(mapFile); } else { var jm = File.ReadAllText(mapFile); world.wmap[j] = Json2Wmap.Convert(gameData, jm); } } worlds.Add(world.name, world); } }
protected void LoadMap(string embeddedResource, MapType type) { Stream stream = null; if (embeddedResource == null) { return; } if (embeddedResource == "nexus.dll") { stream = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + "\\nexus.dll").GetManifestResourceStream("Nexus.map.nexus.jm"); if (stream == null) { throw new ArgumentException("Resource not found", nameof(embeddedResource)); } } else { stream = typeof(RealmManager).Assembly.GetManifestResourceStream(embeddedResource); if (stream == null) { throw new ArgumentException("Resource not found", nameof(embeddedResource)); } } switch (type) { case MapType.Wmap: FromWorldMap(stream); break; case MapType.Json: FromWorldMap(new MemoryStream(Json2Wmap.Convert(Manager, new StreamReader(stream).ReadToEnd()))); break; default: throw new ArgumentException("Invalid MapType"); } }
protected void LoadMap(string json) { FromWorldMap(new MemoryStream(Json2Wmap.Convert(Manager, json))); }
public void LoadJson(string json) { FromWorldMap(new MemoryStream(Json2Wmap.Convert(Manager.GameData, json))); }
protected void LoadMap(string json) { FromWorldMap(new MemoryStream(Json2Wmap.Convert(GameServer.Manager.GameData, json))); }
public void LoadJson(string json) { js = json; FromWorldMap(new MemoryStream(Json2Wmap.Convert(json))); }
public void LoadJson(string json) { SetMusic(""); FromWorldMap(new MemoryStream(Json2Wmap.Convert(Manager, json))); }