public static void Init() { if (!File.Exists(Config.PathItemPid)) { Message.Show("Can't find ITEMPID.H", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, true); Environment.Exit(0); return; } DefineParser defineParser = new DefineParser(); if (!defineParser.ReadDefines(Config.PathItemPid)) { Utils.HandleParseError(defineParser.Error, Config.PathItemPid); return; } foreach (KeyValuePair <string, int> kvp in defineParser.Defines) { Items.Add(new Item(kvp.Value, kvp.Key)); } Utils.Log("Found " + Items.Count + " PIDs in ITEMPID.H"); IsInitialized = true; }
private void LoadCrTypeDefines() { if (!File.Exists(Config.PathScriptsDir + "_basetypes.fos")) { return; } DefineParser CrTypeParser = new DefineParser(); if (!CrTypeParser.ReadDefines(Config.PathScriptsDir + "_basetypes.fos")) { Utils.HandleParseError(CrTypeParser.Error, Config.PathScriptsDir + "_basetypes.fos"); } CrTypeDefines = CrTypeParser.Defines; }
private void ReadAllDefines() { //defines.ReadAllDefines( Overseer.Config.PathScriptsFolder+Overseer.Config.Defines ); //clientDefines.ReadAllDefines( Overseer.Config.PathScriptsFolder+Overseer.Config.PathClientDefines ); mapperDefines.ReadDefines(Overseer.Config.PathScriptsFolder + Overseer.Config.PathMapperDefines); npcPids.ReadDefines(Overseer.Config.PathScriptsFolder + Overseer.Config.PathNpcPid); itemPids.ReadDefines(Overseer.Config.PathScriptsFolder + Overseer.Config.PathItemPid); if (!mapperDefines.Defines.TryGetValue("MAP_OBJECT_CRITTER", out objectCritter) || !mapperDefines.Defines.TryGetValue("MAP_OBJECT_ITEM", out objectItem) || !mapperDefines.Defines.TryGetValue("MAP_OBJECT_SCENERY", out objectScenery)) { MessageBox.Show(this, "Missing MAP_OBJECT_* defines in " + Overseer.Config.PathMapperDefines + ", cannot continue", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); Close(); return; } }
private void bwMaps_DoWork(object sender, DoWorkEventArgs e) { DefineParser WorldMapHeaderData = new DefineParser(); if (!WorldMapHeaderData.ReadDefines(@Config.PathWorldmapHeader)) { Utils.HandleParseError(WorldMapHeaderData.Error, @Config.PathWorldmapHeader); } worldmap = new WorldMap(Config.PathWorldMap, Config.PathWorldMapCompiled, new WorldMapFormat(WorldMapHeaderData)); worldmap.Parse(); //worldmap = new WorldMap("worldmap_sdk.fowm", "worldmap_sdk.focwm", new SDKWorldMapFormat(WorldMapHeaderData)); bwMaps.ReportProgress(52); this.BeginInvoke((MethodInvoker) delegate { pctWorldMap.Refresh(); locationEditorToolStripMenuItem.Enabled = true; mapdataEditorToolStripMenuItem.Enabled = true; }); Utils.Log("Loaded maps and location data."); bwMaps.ReportProgress(100); }
public static bool LoadDefines(Config Cfg) { ClearLists(); DefineParser defines = new DefineParser(); string CurrentLine = ""; string CurrentFile = ""; if (!defines.ReadDefines(@Cfg.PathDefines)) { Message.Show("Can't find " + Cfg.PathDefines, MessageBoxButtons.OK, MessageBoxIcon.Error, true); return(false); } try { Defines = defines.Defines; ItemPid.Add("", 0); // none WeaponPerks.Add("", 0); CurrentFile = "_defines.fos"; // Read stuff from parsed defines from _defines.fos foreach (KeyValuePair <string, int> kvp in Defines) { CurrentLine = kvp.Key; if (kvp.Key.StartsWith("ITEM_TYPE_")) { ItemTypes.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 10) : kvp.Key), kvp.Value); } if (kvp.Key.StartsWith("CALIBER_")) { Calibers.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 8) : kvp.Key), kvp.Value); } if (kvp.Key.StartsWith("WEAPON_PERK_")) { WeaponPerks.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 12) : kvp.Key), kvp.Value); } if (kvp.Key.StartsWith("DAMAGE_")) { DamageTypes.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 7) : kvp.Key), kvp.Value); } } if (!File.Exists(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "DefineNames.lst")) { Message.Show("Can't find DefinesNames.lst", MessageBoxButtons.OK, MessageBoxIcon.Error, true); return(false); } List <String> Lines = new List <String>(File.ReadAllLines(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "DefineNames.lst", Encoding.UTF8)); bool PAnim1 = false; bool PAnim2 = false; bool PSkills = false; int BaseNum = 0; char[] Sep = { ' ', '\t' }; CurrentFile = "DefineNames.lst"; foreach (String Line in Lines) { CurrentLine = Line; if (Line.Length == 0 || Line[0] == '#') { continue; } if (Line[0] == '*') { PAnim1 = false; PAnim2 = false; PSkills = false; BaseNum = Int32.Parse(Line.Remove(0, 1)); } if (Line.Length < 6) { continue; } string[] Parts = Line.Split(Sep, StringSplitOptions.RemoveEmptyEntries); if (PAnim1) { Anim1.Add(Parts[1], BaseNum + Int32.Parse(Parts[0])); } if (PAnim2) { Anim2.Add(Parts[1], BaseNum + Int32.Parse(Parts[0])); } if (PSkills) { Skills.Add(Parts[1], BaseNum + Int32.Parse(Parts[0])); } if (Line.Contains("---ANIM1---")) { PAnim1 = true; } else if (Line.Contains("---ANIM2---")) { PAnim2 = true; } else if (Line.Contains("---SKILLS---")) { PSkills = true; } } if (!File.Exists(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "ItemNames.lst")) { Message.Show("Can't find ItemNames.lst", MessageBoxButtons.OK, MessageBoxIcon.Error, true); return(false); } CurrentFile = "ItemNames.lst"; Lines = new List <String>(File.ReadAllLines(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "ItemNames.lst", Encoding.UTF8)); foreach (String Line in Lines) { CurrentLine = Line; if (Line.Length < 4) { continue; } string[] Parts = Line.Split(Sep, StringSplitOptions.RemoveEmptyEntries); if (ItemPid.ContainsKey(Parts[1])) { ItemPid[Parts[1]] = Int32.Parse(Parts[0]); } else { ItemPid.Add(Parts[1], Int32.Parse(Parts[0])); } } } catch (IndexOutOfRangeException) { Message.Show("Error while parsing line '" + CurrentLine + "' in " + CurrentFile, MessageBoxButtons.OK, MessageBoxIcon.Error, true); } return(true); }