public static void Init() { ConcurrentDictionary <uint, ushort[]> dimensions = new ConcurrentDictionary <uint, ushort[]>(); string[] dimensionData = System.IO.File.ReadAllLines("C:/db/mapdimensions.dat"); foreach (string md in dimensionData) { string[] mdd = md.Split(' '); ushort Width = ushort.Parse(mdd[1]); ushort Height = ushort.Parse(mdd[2]); ushort[] dim = new ushort[2] { Width, Height }; dimensions.TryAdd(uint.Parse(mdd[0]), dim); } Database.Database DB = new Database.Database("C:/db/maps.s3db"); System.Data.DataTable DT = DB.GetDataTable("SELECT `UniqueID`, `Type` FROM `maptypes`"); for (int i = 0; i < DT.Rows.Count; i++) { System.Data.DataRow dr = DT.Rows[i]; Mapping.Map M = new Map(); M.UniqueID = Convert.ToUInt32(dr.ItemArray[0]); M.Type = Convert.ToUInt32(dr.ItemArray[1]); if (!M.LoadDMap()) { ushort[] dims; if (dimensions.TryGetValue(M.Type, out dims)) { M.Width = dims[0]; M.Height = dims[1]; } else { M.Width = 1300; M.Height = 1300; } M.Coords = new byte[M.Height, M.Width]; for (short ix = 0; ix < M.Height; ix++) { for (short iy = 0; iy < M.Width; iy++) { M.Coords[ix, iy] = (byte)Enums.MapPointType.Empty; } } } Kernel.Maps.TryAdd(M.UniqueID, M); } DB.Dispose(); dimensions.Clear(); }
public static void Init() { ConcurrentDictionary<uint, ushort[]> dimensions = new ConcurrentDictionary<uint, ushort[]>(); string[] dimensionData = System.IO.File.ReadAllLines("C:/db/mapdimensions.dat"); foreach (string md in dimensionData) { string[] mdd = md.Split(' '); ushort Width = ushort.Parse(mdd[1]); ushort Height = ushort.Parse(mdd[2]); ushort[] dim = new ushort[2] { Width, Height }; dimensions.TryAdd(uint.Parse(mdd[0]), dim); } Database.Database DB = new Database.Database("C:/db/maps.s3db"); System.Data.DataTable DT = DB.GetDataTable("SELECT `UniqueID`, `Type` FROM `maptypes`"); for (int i = 0; i < DT.Rows.Count; i++) { System.Data.DataRow dr = DT.Rows[i]; Mapping.Map M = new Map(); M.UniqueID = Convert.ToUInt32(dr.ItemArray[0]); M.Type = Convert.ToUInt32(dr.ItemArray[1]); if (!M.LoadDMap()) { ushort[] dims; if (dimensions.TryGetValue(M.Type, out dims)) { M.Width = dims[0]; M.Height = dims[1]; } else { M.Width = 1300; M.Height = 1300; } M.Coords = new byte[M.Height, M.Width]; for (short ix = 0; ix < M.Height; ix++) for (short iy = 0; iy < M.Width; iy++) M.Coords[ix, iy] = (byte)Enums.MapPointType.Empty; } Kernel.Maps.TryAdd(M.UniqueID, M); } DB.Dispose(); dimensions.Clear(); }