/// <summary> /// Reads a MapHeader from a ROM /// </summary> /// <param name="reader">BinaryReader to read data from</param> /// <param name="mapTable">Offset of the MapTable in the ROM (MapBankTable)</param> /// <param name="bankNumber">Bank number to read</param> /// <param name="mapNumber">Map number to read</param> /// <returns>MapHeader imported from the stream object</returns> public static MapHeader HeaderFromStream(BinaryReader reader, long mapTable, byte bankNumber, byte mapNumber) { MapHeader header; reader.BaseStream.Seek(mapTable + (4 * bankNumber), SeekOrigin.Begin); reader.BaseStream.Seek((reader.ReadUInt32() & 0x1FFFFFF) + (4 * mapNumber), SeekOrigin.Begin); reader.BaseStream.Seek(reader.ReadUInt32() & 0x1FFFFFF, SeekOrigin.Begin); uint mapFooterOffset = reader.ReadUInt32(); uint eventOffset = reader.ReadUInt32(); uint levelScriptOffset = reader.ReadUInt32(); uint connectionOffset = reader.ReadUInt32(); header = new MapHeader() { Music = reader.ReadUInt16(), Index = reader.ReadUInt16(), Name = reader.ReadByte(), Flash = reader.ReadByte(), Weather = reader.ReadByte(), Type = reader.ReadByte(), Unknown = reader.ReadUInt16(), ShowName = reader.ReadByte(), BattleStyle = reader.ReadByte() }; string mapBasePrefix = "m_" + bankNumber.ToString() + "_" + mapNumber.ToString() + "_"; header.Footer = FooterFromReader(reader, mapFooterOffset, mapBasePrefix); header.Events = EventsFromReader(reader, eventOffset, mapBasePrefix); header.Connections = ConnectionsFromReader(reader, connectionOffset); header.MapScripts = LevelScriptsFromReader(reader, levelScriptOffset, mapBasePrefix); return(header); }
private void ImportMapMenuButton_Click(object sender, RoutedEventArgs e) { SaveProjectAs(lastSaveLocation); if (lastSaveLocation == null) { MessageBox.Show("Please save your project before importing data!", "Error importing", MessageBoxButton.OK, MessageBoxImage.Error); return; } ImportDialogModel data = new ImportDialogModel("", 0, 0, 0); ImportDialogWindow importDialogWindow = new ImportDialogWindow(data); importDialogWindow.Owner = this; bool result = (bool)importDialogWindow.ShowDialog(); if (result) { //TODO import //TODO warn when map replacement try { MapHeader importedData = AgbImport.HeaderFromStream(new BinaryReader(File.OpenRead(data.ROMPath)), data.Offset, data.Bank, data.Map); } catch (Exception ex) { MessageBox.Show("Error importing: " + ex.Message, "Import error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
/// <see cref="IScenarioManagerBC.OpenScenario"/> public void OpenScenario(string filename) { if (this.activeScenario != null) { throw new InvalidOperationException("Another scenario is currently active!"); } if (filename == null) { throw new ArgumentNullException("fileName"); } byte[] mapBytes = File.ReadAllBytes(filename); MapHeader mapHeader = this.mapLoader.LoadMapHeader(mapBytes); IMapAccess map = this.mapLoader.LoadMap(this.tilesetManager.GetTileSet(mapHeader.TilesetName), mapBytes); this.pathfinder.Initialize(new MapWalkabilityReader(map), MAX_MOVING_ENTITY_SIZE); this.activeScenario = this.scenarioLoader.LoadScenario(map, mapBytes); this.RegisterFactoryMethods(); if (this.ActiveScenarioChanged != null) { this.ActiveScenarioChanged(this.activeScenario); } }
public void AddMap(MapHeader header) { lock(syncroot) { this.maps.Add(header.MapName, header); } }
/// <see cref="IMapLoader.LoadMapHeader"/> public MapHeader LoadMapHeader(byte[] data) { if (!this.initThreadStarted) { throw new InvalidOperationException("Component has not yet been started!"); } this.initThread.Join(); if (data == null) { throw new ArgumentNullException("data"); } int offset = 0; while (offset < data.Length) { int parsedBytes; RCPackage package = RCPackage.Parse(data, offset, data.Length - offset, out parsedBytes); if (package == null || !package.IsCommitted) { throw new MapException("Syntax error!"); } offset += parsedBytes; if (package.PackageFormat.ID == MapFileFormat.MAP_HEADER) { return(MapHeader.FromPackage(package)); } } throw new MapException("Map header information not found!"); }
/// <summary> /// Parsing method for map input /// </summary> /// <param name="opts"></param> /// <returns></returns> public static int ParseMap(Options opts) { String outPath = opts.OutputPath; List <string> inputFiles = opts.InputFiles; MapHeader mapHeaderBuilder = new MapHeader(); try { //Append all maps into this single StringBuilder's String StringBuilder b = new StringBuilder(); foreach (String inputFile in inputFiles) { MapHeader mapHeader; // First try to import try { mapHeader = mapHeaderBuilder.ImportFromFile(inputFile); } catch (IOException ioex) { Console.Error.WriteLine("IOError for file '" + inputFile + "'"); throw ioex; }catch (Exception ex) { Console.Error.WriteLine("Error at parsing map input file '" + inputFile + "'"); throw ex; } try { // Try to convert String baseSymbol = opts.baseSymbol; if (baseSymbol == null) { baseSymbol = Path.GetFileNameWithoutExtension(inputFile); } b.Append(MapCompiler.MapToString(mapHeader, baseSymbol)); } catch (Exception ex) { Console.Error.WriteLine("Error at converting map '" + inputFile + "':"); throw ex; } } try { // Export all files File.WriteAllText(outPath, b.ToString()); }catch (Exception ex) { Console.Error.WriteLine("Error at exporting file '" + outPath + "':"); throw ex; } return(0); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); return(1); } }
public static MapHeader LoadHeader(string path, int2 headerlessSliceDims, long headerlessOffset, Type headerlessType) { lock (Sync) { return(MapHeader.ReadFromFile(path, headerlessSliceDims, headerlessOffset, headerlessType)); } }
public bool LoadMap(String fileName) { // Open the file as a new stream _stream = new FileStream(fileName, FileMode.Open); // Make sure the filesize is larger than the header chunk FileInfo f = new FileInfo(fileName); Header = new MapHeader(); if (f.Length < Header.ChunkSize()) { throw new Exception("Not a valid map file!"); } // Load header and tag table header LoadMapPortion(Header); LoadMapPortion(Tables = new TableManager(Header, this)); // Close the stream _stream.Close(); IsLoaded = true; return(true); }
private void spawnHeaderComboBox_IndexChanged(object sender, EventArgs e) { ushort headerNumber = ushort.Parse(spawnHeaderComboBox.SelectedItem.ToString().Split()[0]); MapHeader currentHeader = MapHeader.LoadFromARM9(headerNumber); Matrix headerMatrix = new Matrix(currentHeader.matrixID); matrixxUpDown.Maximum = headerMatrix.maps.GetLength(1) - 1; matrixyUpDown.Maximum = headerMatrix.maps.GetLength(0) - 1; switch (RomInfo.gameVersion) { case "D": case "P": locationNameLBL.Text = locations.messages[((HeaderDP)currentHeader).locationName]; break; case "Plat": locationNameLBL.Text = locations.messages[((HeaderPt)currentHeader).locationName]; break; case "HG": case "SS": locationNameLBL.Text = locations.messages[((HeaderHGSS)currentHeader).locationName]; break; } }
public BoxNetTrain(string modelName, Options options) { InitializeComponent(); ModelName = modelName; Options = options; TextHeader.Text = "Retrain " + ModelName; TextNewName.Text = ModelName + "_2"; int CorpusSize = 0; if (Directory.Exists(System.IO.Path.Combine(Environment.CurrentDirectory, "boxnet2training"))) { foreach (var fileName in Directory.EnumerateFiles(System.IO.Path.Combine(Environment.CurrentDirectory, "boxnet2training"), "*.tif")) { MapHeader Header = MapHeader.ReadFromFile(fileName); CorpusSize += Header.Dimensions.Z / 3; } } CheckCorpus.Content = $" Also use {CorpusSize} micrographs in\n {System.IO.Path.Combine(Environment.CurrentDirectory, "boxnettraining")}"; if (CorpusSize == 0) { CheckCorpus.IsChecked = false; CheckCorpus.IsEnabled = false; } }
public override void Initalize(MapHeader mapHeader) { // World Map if (!MapLoaded) { if (mapHeader.MaxElevation > 0) { MaxHeight = mapHeader.MaxElevation; MinHeight = mapHeader.MinElevation; } else { MaxHeight = 100; MinHeight = 0; } LoadMap(); South = MapUtil.Deg2Rad(-83.0); North = MapUtil.Deg2Rad(83.0); // South = MapUtil.Deg2Rad(-85.0); // North = MapUtil.Deg2Rad(85.0); West = MapUtil.Deg2Rad(-180.0); East = MapUtil.Deg2Rad(180.0); ymin = MercY(South); ymax = MercY(North); xFactor = Width / (East - West); yFactor = Depth / (ymax - ymin); GridSize = mapHeader.GridSize; MapLoaded = true; } }
private void Button_Click(object sender, RoutedEventArgs e) { //Test code, please ignore OpenFileDialog fileDialog = new OpenFileDialog(); if (fileDialog.ShowDialog() == true) { //open file dialog to open the map Stream str = File.Open(fileDialog.FileName, FileMode.Open); //Get the header MapHeader mh = HeaderReader.ReadHeader(str); ///Break out the sections of the file in order to avoid seeks and shit /// //First get the debug section. What the f**k is this for anyways? int debug_offset = (int)mh.section_offsets[0] + (int)mh.section_bounds[0].offset; int debug_size = (int)mh.section_bounds[0].size; byte[] debug_section = new byte[debug_size]; if (str.Position != debug_offset) { str.Seek(debug_offset, SeekOrigin.Begin); } str.Read(debug_section, 0, debug_size); //Then get the resources section. Images and models maybe? and strings probably! int resource_offset = (int)mh.section_offsets[1] + (int)mh.section_bounds[1].offset; int resource_size = (int)mh.section_bounds[1].size; byte[] resource_section = new byte[resource_size]; if (str.Position != resource_offset) { str.Seek(resource_offset, SeekOrigin.Begin); } str.Read(resource_section, 0, resource_size); //Get the actual tags int tag_offset = (int)mh.section_offsets[2] + (int)mh.section_bounds[2].offset; int tag_size = (int)mh.section_bounds[2].size; byte[] tag_section = new byte[tag_size]; long pos = str.Position; if (str.Position != tag_offset) { str.Seek(tag_offset, SeekOrigin.Begin); } str.Read(tag_section, 0, tag_size); //Lastly get the localization data //But I dont need it now so f**k it ConsoleOutput.AppendText("Read in the map file!\n"); } }
static void Main(string[] args) { BinaryReader reader = new BinaryReader(new FileStream(@"D:\onedrive\Hacking\Romhacking\Ressources\Feuerrot\Pokemon Feuerrot (D).gba", FileMode.Open, FileAccess.Read)); MapHeader header = AgbImport.HeaderFromStream(reader, 0x3525CC, 3, 0); header.ExportToFile(header, "test.header"); MapHeader importedHeader = header.ImportFromFile("test.header"); }
private void tsbtnDebugLoadMap_Click(object sender, EventArgs e) { if (!RTH_Imports.IsConnected) { return; } uint HeaderAddress = 0x547700; string connectInfo = tslblDebugStatus.Text; try { tslblDebugStatus.Text = "[Loading Debug Map...]"; byte[] data = new byte[2048]; data = (byte[])RTH_Imports.Peek(HeaderAddress, (uint)data.Length); MapHeader LoadedMap = new MapHeader(data); string[] filePaths = Directory.GetFiles(Globals.Prefs.pathMapsFolder, "*.map"); tslblDebugStatus.Text = "[Comparing Maps...]"; foreach (string filename in filePaths) { // Load file and read header FileStream fs = new FileStream(filename, FileMode.Open); byte[] headerData = new byte[2048]; fs.Read(headerData, 0, 2048); fs.Close(); // Compare file to debug header if (LoadedMap.Compare(new MapHeader(headerData)) == 0) { // Found our MAP!! YES!! Load It!! TryLoadMapForm(filename); return; } } System.Windows.Forms.MessageBox.Show("No matching map found!" + "\nType: " + LoadedMap.MapType + "\nName: " + LoadedMap.MapName + "\nScenario Name: " + LoadedMap.ScenarioName); } catch (Exception ex) { if (ex.Message == "No xbox processes loaded.") { Globals.Global.ShowErrorMsg("Halo 2 not loaded", ex); } else { Globals.Global.ShowErrorMsg("Load map failed!", ex); } } finally { tslblDebugStatus.Text = connectInfo; } }
public void TileCount() { MapHeader mapHeader = new MapHeader(); mapHeader.lgWidthInTiles = 5; mapHeader.heightInTiles = 32; Assert.AreEqual(32u * 32u, mapHeader.TileCount()); }
public MapHeaderCache(DateTime LastWriteTime, string ScriptFunc, string ScriptModule, string Time, bool NoLogout) { this.Data = new MapHeader(); this.LastWriteTime = LastWriteTime; this.Data.ScriptFunc = ScriptFunc; this.Data.ScriptModule = ScriptModule; this.Data.Time = Time; this.Data.NoLogOut = NoLogout; }
private string OCIOChunk(MapHeader info, string fname) { return($@" - !<Look> name: {GetValidFilename($"{info.GetName().ToUpperInvariant()}_{teResourceGUID.Index(info.MapGUID):X}")} process_space: linear transform: !<GroupTransform> children: - !<FileTransform> {{src: {fname}.spi3d, interpolation: linear}}"); }
static void Main(string[] args) { Options opt = new Options(); if (CommandLine.Parser.Default.ParseArguments(args, opt)) { long mapTable = opt.MapTable.ToLong(CultureInfo.InvariantCulture); long nameTable = opt.NameTable.ToLong(CultureInfo.InvariantCulture); bool error = false; FileStream fs = null; try { if (!Directory.Exists(opt.OutputFolder)) { Directory.CreateDirectory(opt.OutputFolder); } fs = new FileStream(opt.InputFile, FileMode.Open, FileAccess.Read); using (BinaryReader br = new BinaryReader(fs)) { fs = null; MapHeader header = null; if (opt.ExportMap) { header = AgbImport.HeaderFromStream(br, mapTable, opt.BankNumber, opt.MapNumber); header.ExportToFile(header, opt.OutputFolder + "/" + opt.BankNumber.ToString("D2") + "_" + opt.MapNumber.ToString("D2") + ".mapheader"); //TODO serialize } if (opt.ExportTileset) { header = header ?? AgbImport.HeaderFromStream(br, mapTable, opt.BankNumber, opt.MapNumber); if (!Directory.Exists(opt.OutputFolder + "/tileset")) { Directory.CreateDirectory(opt.OutputFolder + "/tileset"); } Tuple <Tileset, Tileset> sets = AgbImport.TilesetsFromStream(br, header, opt.OutputFolder + "/tileset"); sets.Item1.ExportToFile(sets.Item1, opt.OutputFolder + "/tileset/tileset_" + header.Footer.FirstTilesetInternal.ToString("X8") + ".tileset"); sets.Item2.ExportToFile(sets.Item2, opt.OutputFolder + "/tileset/tileset_" + header.Footer.SecondTilesetInternal.ToString("X8") + ".tileset"); //TODO import tileset //TODO serialize } } } catch (Exception ex) { Console.Error.WriteLine("error: {0}", ex.Message); error = true; } finally { if (fs != null) { fs.Dispose(); } } } //Console.ReadKey(); }
public IEnumerable<World> GetWorlds(Uri location) { if(!location.IsFile) throw new ArgumentException("World location must be a file on the local system."); else if(!new FileInfo(location.LocalPath).Exists) throw new FileNotFoundException("The world file was not found."); List<World> worlds = new List<World>(); XmlDocument doc = new XmlDocument(); doc.Load(location.LocalPath); XmlNodeList worldNodesParent = doc.GetElementsByTagName("Worlds"); foreach(XmlNode worldNodes in worldNodesParent) { foreach(XmlNode worldNode in worldNodes) { World world = new World(worldNode.Attributes.GetNamedItem("Name").InnerText); foreach(XmlNode node in worldNode.ChildNodes) { if(node.Name == "MapLoc") { /* Load the map header from an XML node */ string mapname = string.Empty; string mappath = string.Empty; int x = 0, y = 0; foreach(XmlNode cnode in node.ChildNodes) { if(cnode.Name == "Name") mapname = cnode.InnerText; else if(cnode.Name == "Uri") mappath = cnode.InnerText; else if(cnode.Name == "X") x = Convert.ToInt32(cnode.InnerText); else if(cnode.Name == "Y") y = Convert.ToInt32(cnode.InnerText); } MapHeader header = new MapHeader(mapname, new MapPoint(x, y), mappath); world.AddMap(header); } } worlds.Add(world); } } return worlds; }
/// <summary> /// Compares certain features of two maps to see how similar they are /// </summary> /// <param name="map"></param> /// <returns>0 = identical, 10 = very different</returns> public int Compare(MapHeader map) { int temp = 0; temp += (fileSize != map.fileSize) ? 3 : 0; temp += (mapType != map.mapType) ? 3 : 0; temp += (mapName != map.mapName) ? 1 : 0; temp += (scenarioName != map.scenarioName) ? 2 : 0; temp += (signature != map.signature) ? 1 : 0; return(temp); }
public void VersionTagValid() { MapHeader mapHeader = new MapHeader(); Assert.IsTrue(mapHeader.VersionTagValid()); mapHeader.versionTag = MapHeader.MinMapVersion + 1; Assert.IsTrue(mapHeader.VersionTagValid()); mapHeader.versionTag = MapHeader.MinMapVersion - 1; Assert.IsFalse(mapHeader.VersionTagValid()); }
/// <summary> /// Creates an assembly string of a given mapheader instance /// </summary> /// <param name="mapHeader"></param> /// <returns></returns> public static string MapToString(MapHeader mapHeader, string baseSymbol) { StringBuilder b = new StringBuilder(); b.Append("@ Map Assembly created by map2agb at "); b.Append(DateTime.Now.ToString()); b.Append(Environment.NewLine); // Append the MapHeader structure b.Append(MapHeaderToString(mapHeader, baseSymbol)); b.Append(Environment.NewLine); return(b.ToString()); }
internal override void SetMapHeader() { DataFromLine = 2; AddressPreFixs.Add("VendorAddress"); MapHeader.AddField("VendorId", 1); MapHeader.AddField("VendorName", 2); MapHeader.AddField("VendorAddress1", 3); MapHeader.AddField("VendorAddress2", 4); MapHeader.AddField("VendorAddress3", 5); MapHeader.AddField("VendorCity", 6); MapHeader.AddField("VendorState", 7); MapHeader.AddField("VendorZip", 8); MapHeader.AddField("VendorPhone", 9); }
public static MapHeader ReadMapHeader(this SCMap scMap) { MapHeader mapHeader = new MapHeader(); mapHeader.containerName = scMap.ReadString(4); mapHeader.int0 = scMap.ReadInt(); mapHeader.int1 = scMap.ReadInt(); mapHeader.int2 = scMap.ReadInt(); mapHeader.mapSize = scMap.ReadVector2(); mapHeader.int3 = scMap.ReadInt(); mapHeader.sh4 = scMap.ReadShort(); mapHeader.preview = scMap.ReadDDS(); mapHeader.version = scMap.ReadInt(); return(mapHeader); }
public static Image LoadMap(string path, int2 headerlessSliceDims, long headerlessOffset, Type headerlessType, int layer = -1) { lock (Sync) { MapHeader Header = LoadHeader(path, headerlessSliceDims, headerlessOffset, headerlessType); float[][] Data; Data = IOHelper.ReadMapFloat(path, headerlessSliceDims, headerlessOffset, headerlessType, layer); return(new Image(Data, new int3(Header.Dimensions.X, Header.Dimensions.Y, layer < 0 ? Header.Dimensions.Z : 1), false, false)); } }
internal override void SetMapHeader() { MapOverflow = new MapOverflow("VOID VOID VOID VOID VOID VOID", 75, false); BreakPageLine = 81; AddressPreFixs.Add("FreeFormAddress"); MapHeader.AddField("PaymentNumber", 73, 57, 8); MapHeader.AddField("PaymentDate", 73, 38, 10); MapHeader.AddField("PaymentAmount", 73, 66, 13); MapHeader.AddField("PayeeId", 81, 12, 8); MapHeader.AddField("FreeFormAddress1", 75, 12, 35); MapHeader.AddField("FreeFormAddress2", 76, 12, 50); MapHeader.AddField("FreeFormAddress3", 77, 12, 50); MapHeader.AddField("FreeFormAddress4", 78, 12, 50); MapHeader.AddField("FreeFormAddress5", 79, 12, 50); }
public override void SetMapHeader() { //throw new NotImplementedException(); DataFromLine = 2; AddressPreFixs.Add("VendorAddress"); MapHeader.AddField("VendorId", 1); MapHeader.AddField("VendorName", 2); MapHeader.AddField("VendorAddress1", 3); MapHeader.AddField("VendorAddress2", 4); MapHeader.AddField("VendorAddress3", 5); MapHeader.AddField("VendorCity", 6); MapHeader.AddField("VendorState", 7); MapHeader.AddField("VendorZip", 8); MapHeader.AddField("VendorPhone", 9); }
/// <summary> /// Compile the map instance. /// </summary> /// <param name="fileName">Output file name</param> /// <param name="header">Map header to be included</param> public void Compile(string fileName, MapHeader header) { FOCommon.Utils.Log("Compiling " + fileName + " using preset '" + Config.CurrentPreset + "'."); Preset p = PresetsManager.GetPreset(Config.CurrentPreset); if (p == null) { FOCommon.Utils.Log("Error: preset '" + Config.CurrentPreset + "' not found."); throw new CompilerException("internal: preset '" + Config.CurrentPreset + "' not found"); } FOMap m = new FOMap(); m.Header = header; header.MaxHexX = (ushort)(2 * Config.BigTileEdgeSize * Width); header.MaxHexY = (ushort)(2 * Config.BigTileEdgeSize * Height); header.Version = 4; header.WorkHexX = (ushort)(header.MaxHexX / 2); header.WorkHexY = (ushort)(header.MaxHexY / 2); // tiles for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { compileTile(m, p, x, y); } } // scrollblockers if (scrollBlockers.Count > 3) { for (int i = 2; i < scrollBlockers.Count; i++) { Pair <int, int> from = scrollBlockers[i - 1]; Pair <int, int> to = scrollBlockers[i]; LineTracer.TraceHex(new ScrollblockersPlacer(from, to, this, m)); } LineTracer.TraceHex(new ScrollblockersPlacer(scrollBlockers[scrollBlockers.Count - 1], scrollBlockers[1], this, m)); } FOMapParser parser = new FOMapParser(fileName); parser.Map = m; parser.Save(); FOCommon.Utils.Log("Compilation successful."); }
public Dictionary <teResourceGUID, MapHeader> GetMaps() { Dictionary <teResourceGUID, MapHeader> @return = new Dictionary <teResourceGUID, MapHeader>(); foreach (teResourceGUID key in TrackedFiles[0x9F]) { MapHeader map = GetMap(key); if (map == null) { continue; } @return[key] = map; } return(@return); }
public DialogTomoMatch(TiltSeries[] series, string pathTemplate, Options options) { InitializeComponent(); Series = series; PathTemplate = pathTemplate; Options = options; DataContext = Options; TextTemplateName.Value = Helper.PathToNameWithExtension(pathTemplate); MapHeader Header = MapHeader.ReadFromFile(pathTemplate); if (Math.Abs(Header.PixelSize.X - 1f) > 1e-6f) { Options.Tasks.TomoMatchTemplatePixel = (decimal)Header.PixelSize.X; } }
public void SaveToFile(string path, bool olt = false) { if (olt) { var oltMapHeader = new MapHeader(); *(oltMapHeader.Ctm) = 0x43; *(oltMapHeader.Ctm + 1) = 0x54; *(oltMapHeader.Ctm + 2) = 0x4D; oltMapHeader.Version_hi = 1; oltMapHeader.Version_lo = 0; MapFactory.SaveToFile(path, oltMapHeader, Entries, true); } else { MapFactory.SaveToFile(path, mapHeader, Entries); } }
public static List <Replay> ParseReplay(string filePath) { Console.Out.WriteLine($"Processing file: {Path.GetFileName(filePath)}"); List <Replay> replays = new List <Replay>(); var buffer = (Memory <byte>)File.ReadAllBytes(filePath); if (buffer.Length == 0) { return(replays); } foreach (var(filename, b64Str) in ProcessAtoms(buffer)) // hash, payload, settinghash? { byte[] bytes = Convert.FromBase64String(b64Str[1]); // string hex = BitConverter.ToString(bytes); var replayInfo = new Mp4Replay(); replayInfo.Parse(bytes); var heroStu = STUHelper.GetInstance <STUHero>(replayInfo.Header.HeroGuid); var hero = new Hero(heroStu); var unlocks = new ProgressionUnlocks(heroStu); var skins = unlocks.GetUnlocksOfType(UnlockType.Skin); var skinTheme = skins.FirstOrDefault(skin => ((STUUnlock_SkinTheme)skin.STU)?.m_skinTheme == replayInfo.Header.SkinGuid); ulong mapHeaderGuid = (replayInfo.Header.MapGuid & ~0xFFFFFFFF00000000ul) | 0x0790000000000000ul; var mapData = new MapHeader(mapHeaderGuid); var replay = new Replay { Title = filename, Hero = hero.Name, Map = mapData.Name, Skin = skinTheme?.Name ?? "Unknown", RecordedAt = $"{DateTimeOffset.FromUnixTimeSeconds(replayInfo.Header.Timestamp).ToLocalTime()}", HighlightType = $"{replayInfo.Header.Type:G}", Quality = $"{replayInfo.Header.QualityPct}% ({(ReplayQuality)replayInfo.Header.QualityPct})", FilePath = filePath }; replays.Add(replay); } return(replays); }
/// <summary> /// Compile the map instance. /// </summary> /// <param name="fileName">Output file name</param> /// <param name="header">Map header to be included</param> public void Compile(string fileName, MapHeader header) { FOCommon.Utils.Log("Compiling " + fileName + " using preset '" + Config.CurrentPreset + "'."); Preset p = PresetsManager.GetPreset(Config.CurrentPreset); if (p == null) { FOCommon.Utils.Log("Error: preset '" + Config.CurrentPreset + "' not found."); throw new CompilerException("internal: preset '" + Config.CurrentPreset + "' not found"); } FOMap m = new FOMap(); m.Header = header; header.MaxHexX = (ushort)(2 * Config.BigTileEdgeSize * Width); header.MaxHexY = (ushort)(2 * Config.BigTileEdgeSize * Height); header.Version = 4; header.WorkHexX = (ushort)(header.MaxHexX / 2); header.WorkHexY = (ushort)(header.MaxHexY / 2); // tiles for(int y = 0; y < Height; y++) for (int x = 0; x < Width; x++) compileTile(m, p, x, y); // scrollblockers if (scrollBlockers.Count > 3) { for (int i = 2; i < scrollBlockers.Count; i++) { Pair<int, int> from = scrollBlockers[i-1]; Pair<int, int> to = scrollBlockers[i]; LineTracer.TraceHex(new ScrollblockersPlacer(from, to, this, m)); } LineTracer.TraceHex(new ScrollblockersPlacer(scrollBlockers[scrollBlockers.Count - 1], scrollBlockers[1], this, m)); } FOMapParser parser = new FOMapParser(fileName); parser.Map = m; parser.Save(); FOCommon.Utils.Log("Compilation successful."); }
public frmHeaderEditor( MapHeader header ) { if( header == null ) throw new ArgumentNullException( "header" ); InitializeComponent(); this.txtVersion.Text = header.Version + ""; this.txtSizeW.Text = header.MaxHexX + ""; this.txtSizeH.Text = header.MaxHexY + ""; if( header.ScriptModule != "-" && header.ScriptFunc != "-" ) { this.txtModule.Text = header.ScriptModule; this.txtFunction.Text = header.ScriptFunc; this.checkScripted.Checked = true; } if( header.NoLogOut ) this.checkNoLogout.Checked = true; this.checkScripted_CheckedChanged( null, null ); string[] _DayColor = { header.DayColor0, header.DayColor1, header.DayColor2, header.DayColor3 }; int idx = 0; foreach( string color in _DayColor ) { string _color = color; while( _color.Contains( " " ) ) { _color = _color.Replace( " ", " " ); } this.dayColor[idx++] = Utils.GetColor( _color.Trim(), ' ' ); } this.UpdateDayColorCells(); this.Header = header; }
public static void SetCurrentMap(Map map) { if (map == null) throw new ArgumentNullException("map"); GameInstance.Engine.WorldManager.ClearWorlds(); MapEditorManager.CurrentMap = map; MapHeader header = new MapHeader(map.Name, new MapPoint(0, 0), string.Empty); header.Map = map; World world = new World("Default"); world.AddMap(header); GameInstance.Engine.WorldManager.AddWorld(world); var camera = GameInstance.Engine.SceneProvider.Cameras.GetItems().FirstOrDefault().Value; if (camera != null) { camera.CenterOriginOnPoint(0, 0); camera.CurrentMap = header; } ActionManager.Reset(); }
//this is used to draw a map at 0,0 incase we use a custom rendertarget public static void DrawMapLocal(SpriteBatch spriteBatch, MapHeader header) { Check.NullArgument (spriteBatch, "spriteBatch"); Check.NullArgument (header, "header"); TileEngine.DrawLayerMapLocal(spriteBatch, header, MapLayers.UnderLayer); TileEngine.DrawLayerMapLocal(spriteBatch, header, MapLayers.BaseLayer); TileEngine.DrawLayerMapLocal(spriteBatch, header, MapLayers.MiddleLayer); TileEngine.DrawLayerMapLocal(spriteBatch, header, MapLayers.TopLayer); }
public static void DrawLayerMapLocal(SpriteBatch spriteBatch, MapHeader header, MapLayers layer) { Check.NullArgument (spriteBatch, "spriteBatch"); Check.NullArgument (header, "header"); Map currentMap = header.Map; ScreenPoint camOffset = TileEngine.Camera.Offset(); ScreenPoint tileSize = currentMap.TileSize; for (int y = 0; y < currentMap.MapSize.Y; y++) { for (int x = 0; x < currentMap.MapSize.X; x++) { ScreenPoint pos = new MapPoint(x, y).ToScreenPoint(); Rectangle des = pos.ToRect(tileSize.ToPoint()); Rectangle sourceRectangle = currentMap.GetLayerSourceRect(new MapPoint(x, y), layer); if (sourceRectangle.IsEmpty) continue; spriteBatch.Draw(currentMap.Texture, des, sourceRectangle, Color.White); } } }
private void DrawLayerMap(SpriteBatch spriteBatch, BaseCamera camera, MapLayers layer, MapHeader header, Color tint) { Check.NullArgument(spriteBatch, "spriteBatch"); Check.NullArgument(header, "header"); Map currentMap = header.Map; ScreenPoint camOffset = ScreenPoint.Zero;// camera.Offset; int tileSize = currentMap.TileSize; for (int y = 0; y < currentMap.MapSize.Y; y++) { for (int x = 0; x < currentMap.MapSize.X; x++) { ScreenPoint pos = new MapPoint(x, y).ToScreenPoint() + camOffset + header.MapLocation.ToScreenPoint(); Rectangle des = new Rectangle(pos.IntX, pos.IntY, tileSize, tileSize); MapPoint point = new MapPoint(x, y); if (!camera.CheckIsVisible(des)) continue; // Opaque only and not opaque var opacity = currentMap.GetLayerValue(point, MapLayers.OpaqueLayer); if (opacity >= 1) { var info = new Rectangle() { X = pos.IntX, Y = pos.IntY, Width = tileSize, Height = tileSize }; if(!this.lastfoginfos.Contains(info)) this.lastfoginfos.Add(info); } Rectangle sourceRectangle = currentMap.GetLayerSourceRect(point, layer); if (sourceRectangle.IsEmpty) continue; spriteBatch.Draw(currentMap.Texture, des, sourceRectangle, tint); } } }
public IEnumerable<IMapEvent> GetMapsEvents(string worldname, MapHeader mapheader, MapPoint globalposition) { MapPoint pos = globalposition - mapheader.MapLocation; // If the globalposition is not located in the mapheader if(pos.X < 0 || pos.Y < 0 || pos.X > mapheader.Map.MapSize.X || pos.Y > mapheader.Map.MapSize.Y) { // Find globally MapHeader header = this.context.WorldManager.GetWorld (worldname).GetLocalMapFromPoint (globalposition); MapPoint localpos = globalposition - header.MapLocation; // Ensure no crash if(!this.events.ContainsKey (header.MapName)) this.events.Add (header.MapName, new List<IMapEvent> ()); return this.events[header.MapName].Where (m => m.Rectangle.Contains ((localpos).ToPoint ())); } else { if(!this.events.ContainsKey (mapheader.MapName)) return new List<IMapEvent> (); // Ensure no crash if(!this.events.ContainsKey (mapheader.MapName)) this.events.Add (mapheader.MapName, new List<IMapEvent> ()); return this.events[mapheader.MapName].Where (m => m.Rectangle.Contains ((pos).ToPoint ())); } }
public void Load(XmlNode worldNode, IMapProvider mapprovider, MapEventManager mapmanager) { foreach (XmlNode node in worldNode.ChildNodes) { if (node.Name == "DefaultSpawn") { this.DefaultSpawn = node.InnerText; } else if (node.Name == "MapLoc") { /* Load the map header from an XML node */ MapHeader header = new MapHeader(); header.MapProvider = new XMLMapProvider(); header.MapManager = mapmanager; int x = 0, y = 0; foreach(XmlNode cnode in node.ChildNodes) { if(cnode.Name == "Name") header.MapName = cnode.InnerText; else if(cnode.Name == "FilePath") header.MapFileLocation = Path.Combine(Environment.CurrentDirectory, "Maps\\" + cnode.InnerText); else if(cnode.Name == "X") x = Convert.ToInt32(cnode.InnerText); else if(cnode.Name == "Y") y = Convert.ToInt32(cnode.InnerText); } header.MapLocation = new MapPoint(x, y); this.MapList.Add(header.MapName, header); } } var worldName = worldNode.Attributes.GetNamedItem("Name"); this.Name = worldName.InnerText; CalcWorldSize(); }
/// <summary> /// Compares certain features of two maps to see how similar they are /// </summary> /// <param name="map"></param> /// <returns>0 = identical, 10 = very different</returns> public int Compare(MapHeader map) { int temp = 0; temp += (fileSize != map.fileSize) ? 3 : 0; temp += (mapType != map.mapType) ? 3 : 0; temp += (mapName != map.mapName) ? 1 : 0; temp += (scenarioName != map.scenarioName) ? 2 : 0; temp += (signature != map.signature) ? 1 : 0; return temp; }
private void tsbtnDebugLoadMap_Click(object sender, EventArgs e) { if (!RTH_Imports.IsConnected) return; uint HeaderAddress = 0x547700; string connectInfo = tslblDebugStatus.Text; try { tslblDebugStatus.Text = "[Loading Debug Map...]"; byte[] data = new byte[2048]; data = (byte[])RTH_Imports.Peek(HeaderAddress, (uint)data.Length); MapHeader LoadedMap = new MapHeader(data); string[] filePaths = Directory.GetFiles(Globals.Prefs.pathMapsFolder, "*.map"); tslblDebugStatus.Text = "[Comparing Maps...]"; foreach (string filename in filePaths) { // Load file and read header FileStream fs = new FileStream(filename, FileMode.Open); byte[] headerData = new byte[2048]; fs.Read(headerData, 0, 2048); fs.Close(); // Compare file to debug header if (LoadedMap.Compare(new MapHeader(headerData)) == 0) { // Found our MAP!! YES!! Load It!! TryLoadMapForm(filename); return; } } System.Windows.Forms.MessageBox.Show("No matching map found!" + "\nType: " + LoadedMap.MapType + "\nName: " + LoadedMap.MapName + "\nScenario Name: " + LoadedMap.ScenarioName); } catch (Exception ex) { if (ex.Message == "No xbox processes loaded.") Globals.Global.ShowErrorMsg("Halo 2 not loaded", ex); else Globals.Global.ShowErrorMsg("Load map failed!", ex); } finally { tslblDebugStatus.Text = connectInfo; } }
public static void DrawLayerMap(SpriteBatch spriteBatch, MapHeader header, MapLayers layer) { Check.NullArgument (spriteBatch, "spriteBatch"); DrawLayerMap(spriteBatch, header, layer, Color.White); }