private void saveSpawnButton_Click(object sender, EventArgs e) { var saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = saveFileDialog.Filter = "Map files (*.map)|*.map"; var result = saveFileDialog.ShowDialog(); if (result == DialogResult.OK) { var writer = new SpawnWriter(Spawns); writer.Save(saveFileDialog.FileName); } }
/// <summary> /// The actual file conversion method. /// </summary> /// <param name="premiumPath"></param> static void ConvertSingleFile(string premiumPath) { if (File.Exists(premiumPath)) { Console.WriteLine("Now reading from '{0}'...", premiumPath); Console.WriteLine(); using (var streamReader = new StreamReader(premiumPath)) { var line = string.Empty; var mapFileInfo = new FileInfo(premiumPath); var spawnDefs = new List <SpawnDefinition>(); while ((line = streamReader.ReadLine()) != null) { if (Helpers.IgnoreLine(line)) { continue; } Console.WriteLine("Converting '{0}'", line); var splitData = line.Split('|'); if (!Helpers.HasObjectsToSpawn(splitData)) { Console.WriteLine("WARNING: Line '{0}' has no spawn data, skipping...", line); } else { /* * Here's the rough format of the various .map files across distros, with a couple of sample entries to better visualize. * Array indexes are above the colum names * * 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 *|typename |s1 |s2 |s3 |s4 |s5 | x | y | z | map | mindelay maxdelay homerange spawnrange spawnid maxcount | maxcount1 | maxcount2 | maxcount3 | maxcount4 | maxcount5 *|Herbalist| | | | | |1685|2985|0 |1 |5 |10 |20 |10 |1 |2 |0 |0 |0 |0 |0 *|Ratmanmage||||| |5850|219 |-3 |2 |5 |10 |20 |10 |1 |1 |0 |0 |0 |0 |0 * */ var spawnDef = new SpawnDefinition(); Helpers.AddSpawnTypesToDefinition(splitData, spawnDef); if (spawnDef.Mobiles.Count > 6) { Console.WriteLine("WARNING: '{0}' currently defines more than 6 mobiles!", line); } spawnDef.SpawnerName = mapFileInfo.Name + "_" + splitData[1]; spawnDef.X = splitData[7]; spawnDef.Y = splitData[8]; spawnDef.MapId = splitData[10]; spawnDef.MinTime = splitData[11]; spawnDef.MaxTime = splitData[12]; spawnDef.Team = "0"; // Hardcoded for now, not sure what this does spawnDef.NPCCount = splitData[16]; spawnDef.HomeRange = splitData[13]; spawnDef.BringToHome = false; // This is a field for Spawn. spawnDefs.Add(spawnDef); } } Console.WriteLine(""); Console.WriteLine("Done parsing '{0}', {1} spawners converted.", mapFileInfo.Name, spawnDefs.Count); var convertedMapFile = "converted_" + mapFileInfo.Name; Console.WriteLine("Now generating '{0}'...", convertedMapFile); var spawnWriter = new SpawnWriter(); Helpers.Write(spawnDefs, convertedMapFile); Console.WriteLine("'{0}' created successfully!", convertedMapFile); } } else { Console.WriteLine("Error: file doesn't exist!"); } }