public Args(Args other) { args = other.args; pos = other.pos; }
static void Main(string[] stringargs) { Args args = new Args(stringargs); int repeatdelay = 0; while (true) // read optional args { string opt = (args.Left > 0) ? args[0] : null; if (opt != null) { if (opt.Equals("-keyrepeat", StringComparison.InvariantCultureIgnoreCase)) { repeatdelay = -1; args.Remove(); } else if (opt.Equals("-repeat", StringComparison.InvariantCultureIgnoreCase) && args.Left >= 1) { args.Remove(); if (!int.TryParse(args.Next, out repeatdelay)) { Console.WriteLine("Bad repeat delay\n"); return; } } else { break; } } else { break; } } if (args.Left < 2) { Help(); return; } string arg1 = args.Next; string arg2 = args.Next; // must have 2 at least. if (arg1.Equals("EDDBSTARS", StringComparison.InvariantCultureIgnoreCase)) { EDDBLog(arg2, "\"Star\"", "\"spectral_class\"", "Star class "); } else if (arg1.Equals("EDDBPLANETS", StringComparison.InvariantCultureIgnoreCase)) { EDDBLog(arg2, "\"Planet\"", "\"type_name\"", "Planet class"); } else if (arg1.Equals("EDDBSTARNAMES", StringComparison.InvariantCultureIgnoreCase)) { EDDBLog(arg2, "\"Star\"", "\"name\"", "Star Name"); } else if (arg1.Equals("voicerecon", StringComparison.InvariantCultureIgnoreCase)) { Bindings(arg2); } else if (arg1.Equals("devicemappings", StringComparison.InvariantCultureIgnoreCase)) { DeviceMappings(arg2); } else if (arg1.Equals("Phoneme", StringComparison.InvariantCultureIgnoreCase)) { if (args.Left >= 1) { Phoneme(arg2, args.Next); } } else { JournalEntry(arg1, arg2, args, repeatdelay); } }
static void JournalEntry(string filename, string cmdrname, Args argsentry, int repeatdelay) { if (argsentry.Left == 0) { Help(); Console.WriteLine("** Minimum 3 parameters of filename, cmdrname, journalentrytype"); return; } int repeatcount = 0; while (true) { Args args = new Args(argsentry); string writetype = args.Next; // min 3 Random rnd = new Random(); string lineout = null; //quick writer if (writetype.Equals("FSD", StringComparison.InvariantCultureIgnoreCase)) { lineout = FSDJump(args, repeatcount); } else if (writetype.Equals("FSDTravel", StringComparison.InvariantCultureIgnoreCase)) { lineout = FSDTravel(args); } else if (writetype.Equals("LOC", StringComparison.InvariantCultureIgnoreCase)) { lineout = Loc(args); } else if (writetype.Equals("Interdiction", StringComparison.InvariantCultureIgnoreCase)) { lineout = Interdiction(args); } else if (writetype.Equals("Docked", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + "\"event\":\"Docked\", " + "\"StationName\":\"Jameson Memorial\", " + "\"StationType\":\"Orbis\", \"StarSystem\":\"Shinrarta Dezhra\", \"Faction\":\"The Pilots Federation\", \"Allegiance\":\"Independent\", \"Economy\":\"$economy_HighTech;\", \"Economy_Localised\":\"High tech\", \"Government\":\"$government_Democracy;\", \"Government_Localised\":\"Democracy\", \"Security\":\"$SYSTEM_SECURITY_high;\", \"Security_Localised\":\"High Security\" }"; } else if (writetype.Equals("Undocked", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + "\"event\":\"Undocked\", " + "\"StationName\":\"Jameson Memorial\",\"StationType\":\"Orbis\" }"; } else if (writetype.Equals("Liftoff", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + "\"event\":\"Liftoff\", " + "\"Latitude\":7.141173, \"Longitude\":95.256424 }"; } else if (writetype.Equals("Touchdown", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + "\"event\":\"Touchdown\", " + "\"Latitude\":7.141173, \"Longitude\":95.256424 }"; } else if (writetype.Equals("CommitCrime", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + "\"event\":\"CommitCrime\", \"CrimeType\":\"collidedAtSpeedInNoFireZone\", \"Faction\":\"Revolutionary Party of Ciguri\", \"Fine\":100 }"; } else if (writetype.Equals("MissionCompleted", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "MissionCompleted") + F("Faction", "whooo") + F("Name", "Mission_massacre") + F("MissingID", "29292") + F("Reward", "82272") + " \"CommodityReward\":[ { \"Name\": \"CoolingHoses\", \"Count\": 4 } ] }"; } else if (writetype.Equals("MissionCompleted2", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "MissionCompleted") + F("Faction", "whooo") + F("Name", "Mission_massacre") + F("MissingID", "29292") + F("Reward", "82272") + " \"CommodityReward\":[ { \"Name\": \"CoolingHoses\", \"Count\": 4 } , { \"Name\": \"Fish\", \"Count\": 10 } ] }"; } else if (writetype.Equals("MiningRefined", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "MiningRefined") + FF("Type", "Gold") + " }"; } else if (writetype.Equals("EngineerCraft", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "EngineerCraft") + F("Engineer", "Robert") + F("Blueprint", "FSD_LongRange") + F("Level", "5") + "\"Ingredients\":{ \"magneticemittercoil\":1, \"arsenic\":1, \"chemicalmanipulators\":1, \"dataminedwake\":1 } }"; } else if (writetype.Equals("NavBeaconScan", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "NavBeaconScan") + FF("NumBodies", "3") + " }"; } else if (writetype.Equals("ScanPlanet", StringComparison.InvariantCultureIgnoreCase) && args.Left >= 1) { lineout = "{ " + TimeStamp() + F("event", "Scan") + "\"BodyName\":\"" + args.Next + "x" + repeatcount + "\", \"DistanceFromArrivalLS\":639.245483, \"TidalLock\":true, \"TerraformState\":\"\", \"PlanetClass\":\"Metal rich body\", \"Atmosphere\":\"\", \"AtmosphereType\":\"None\", \"Volcanism\":\"rocky magma volcanism\", \"MassEM\":0.010663, \"Radius\":1163226.500000, \"SurfaceGravity\":3.140944, \"SurfaceTemperature\":1068.794067, \"SurfacePressure\":0.000000, \"Landable\":true, \"Materials\":[ { \"Name\":\"iron\", \"Percent\":36.824127 }, { \"Name\":\"nickel\", \"Percent\":27.852226 }, { \"Name\":\"chromium\", \"Percent\":16.561033 }, { \"Name\":\"zinc\", \"Percent\":10.007420 }, { \"Name\":\"selenium\", \"Percent\":2.584032 }, { \"Name\":\"tin\", \"Percent\":2.449526 }, { \"Name\":\"molybdenum\", \"Percent\":2.404594 }, { \"Name\":\"technetium\", \"Percent\":1.317050 } ], \"SemiMajorAxis\":1532780800.000000, \"Eccentricity\":0.000842, \"OrbitalInclination\":-1.609496, \"Periapsis\":179.381393, \"OrbitalPeriod\":162753.062500, \"RotationPeriod\":162754.531250, \"AxialTilt\":0.033219 }"; } else if (writetype.Equals("ScanStar", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "Scan") + "\"BodyName\":\"Merope A" + repeatcount + "\", \"DistanceFromArrivalLS\":0.000000, \"StarType\":\"B\", \"StellarMass\":8.597656, \"Radius\":2854249728.000000, \"AbsoluteMagnitude\":1.023468, \"Age_MY\":182, \"SurfaceTemperature\":23810.000000, \"Luminosity\":\"IV\", \"SemiMajorAxis\":12404761034752.000000, \"Eccentricity\":0.160601, \"OrbitalInclination\":18.126791, \"Periapsis\":49.512009, \"OrbitalPeriod\":54231617536.000000, \"RotationPeriod\":110414.359375, \"AxialTilt\":0.000000 }"; } else if (writetype.Equals("ScanEarth", StringComparison.InvariantCultureIgnoreCase)) { int rn = rnd.Next(10); lineout = "{ " + TimeStamp() + F("event", "Scan") + "\"BodyName\":\"Merope " + rn + "\", \"DistanceFromArrivalLS\":901.789856, \"TidalLock\":false, \"TerraformState\":\"Terraformed\", \"PlanetClass\":\"Earthlike body\", \"Atmosphere\":\"\", \"AtmosphereType\":\"EarthLike\", \"AtmosphereComposition\":[ { \"Name\":\"Nitrogen\", \"Percent\":92.386833 }, { \"Name\":\"Oxygen\", \"Percent\":7.265749 }, { \"Name\":\"Water\", \"Percent\":0.312345 } ], \"Volcanism\":\"\", \"MassEM\":0.840000, \"Radius\":5821451.000000, \"SurfaceGravity\":9.879300, \"SurfaceTemperature\":316.457062, \"SurfacePressure\":209183.453125, \"Landable\":false, \"SemiMajorAxis\":264788426752.000000, \"Eccentricity\":0.021031, \"OrbitalInclination\":13.604733, \"Periapsis\":73.138206, \"OrbitalPeriod\":62498732.000000, \"RotationPeriod\":58967.023438, \"AxialTilt\":-0.175809 }"; } else if (writetype.Equals("AFMURepairs", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "AfmuRepairs") + "\"Module\":\"$modularcargobaydoor_name;\", \"Module_Localised\":\"Cargo Hatch\", \"FullyRepaired\":true, \"Health\":1.000000 }"; } else if (writetype.Equals("SellShipOnRebuy", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "SellShipOnRebuy") + "\"ShipType\":\"Dolphin\", \"System\":\"Shinrarta Dezhra\", \"SellShipId\":4, \"ShipPrice\":4110183 }"; } else if (writetype.Equals("SearchAndRescue", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "SearchAndRescue") + "\"Name\":\"Fred\", \"Count\":50, \"Reward\":4110183 }"; } else if (writetype.Equals("MissionRedirected", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "MissionRedirected") + "\"MissionID\": 65367315, \"NewDestinationStation\": \"Metcalf Orbital\", \"OldDestinationStation\": \"Cuffey Orbital\", \"NewDestinationSystem\": \"Cemiess\", \"OldDestinationSystem\": \"Vequess\" }"; } else if (writetype.Equals("RepairDrone", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "RepairDrone") + "\"HullRepaired\": 0.23, \"CockpitRepaired\": 0.1, \"CorrosionRepaired\": 0.5 }"; } else if (writetype.Equals("CommunityGoal", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "CommunityGoal") + "\"CurrentGoals\":[ { \"CGID\":726, \"Title\":\"Alliance Research Initiative - Trade\", \"SystemName\":\"Kaushpoos\", \"MarketName\":\"Neville Horizons\", \"Expiry\":\"2017-08-17T14:58:14Z\", \"IsComplete\":false, \"CurrentTotal\":10062, \"PlayerContribution\":562, \"NumContributors\":101, \"TopRankSize\":10, \"PlayerInTopRank\":false, \"TierReached\":\"Tier 1\", \"PlayerPercentileBand\":50, \"Bonus\":200000 } ] }"; } else if (writetype.Equals("MusicNormal", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "Music") + FF("MusicTrack", "NoTrack") + " }"; } else if (writetype.Equals("MusicSysMap", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "Music") + FF("MusicTrack", "SystemMap") + " }"; } else if (writetype.Equals("MusicGalMap", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "Music") + FF("MusicTrack", "GalaxyMap") + " }"; } else if (writetype.Equals("Friends", StringComparison.InvariantCultureIgnoreCase) && args.Left >= 1) { lineout = "{ " + TimeStamp() + F("event", "Friends") + F("Status", "Online") + FF("Name", args.Next) + " }"; } else if (writetype.Equals("FuelScoop", StringComparison.InvariantCultureIgnoreCase) && args.Left >= 2) { string scoop = args.Next; string total = args.Next; lineout = "{ " + TimeStamp() + F("event", "FuelScoop") + F("Scooped", scoop) + FF("Total", total) + " }"; } else if (writetype.Equals("JetConeBoost", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "JetConeBoost") + FF("BoostValue", "1.5") + " }"; } else if (writetype.Equals("FighterDestroyed", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + FF("event", "FighterDestroyed") + " }"; } else if (writetype.Equals("FighterRebuilt", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "FighterRebuilt") + FF("Loadout", "Fred") + " }"; } else if (writetype.Equals("NpcCrewPaidWage", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "NpcCrewPaidWage") + F("NpcCrewId", 1921) + FF("Amount", 10292) + " }"; } else if (writetype.Equals("NpcCrewRank", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "NpcCrewRank") + F("NpcCrewId", 1921) + FF("RankCombat", 4) + " }"; } else if (writetype.Equals("LaunchDrone", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "LaunchDrone") + FF("Type", "FuelTransfer") + " }"; } else if (writetype.Equals("Market", StringComparison.InvariantCultureIgnoreCase)) { lineout = Market(Path.GetDirectoryName(filename), args.Next); } else if (writetype.Equals("ModuleInfo", StringComparison.InvariantCultureIgnoreCase)) { lineout = ModuleInfo(Path.GetDirectoryName(filename), args.Next); } else if (writetype.Equals("Outfitting", StringComparison.InvariantCultureIgnoreCase)) { lineout = Outfitting(Path.GetDirectoryName(filename), args.Next); } else if (writetype.Equals("Shipyard", StringComparison.InvariantCultureIgnoreCase)) { lineout = Shipyard(Path.GetDirectoryName(filename), args.Next); } else if (writetype.Equals("PowerPlay", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "PowerPlay") + F("Power", "Fred") + F("Rank", 10) + F("Merits", 10) + F("Votes", 2) + FF("TimePledged", 433024) + " }"; } else if (writetype.Equals("UnderAttack", StringComparison.InvariantCultureIgnoreCase)) { lineout = "{ " + TimeStamp() + F("event", "UnderAttack") + FF("Target", "Fighter") + " }"; } else { Help(); Console.WriteLine("** Unrecognised journal type"); break; } if (lineout != null) { if (!File.Exists(filename)) { using (Stream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { using (StreamWriter sr = new StreamWriter(fs)) { string line = "{ " + TimeStamp() + "\"event\":\"Fileheader\", \"part\":1, \"language\":\"English\\\\UK\", \"gameversion\":\"2.2 (Beta 2)\", \"build\":\"r121783/r0 \" }"; sr.WriteLine(line); Console.WriteLine(line); string line2 = "{ " + TimeStamp() + "\"event\":\"LoadGame\", \"Commander\":\"" + cmdrname + "\", \"Ship\":\"Anaconda\", \"ShipID\":14, \"GameMode\":\"Open\", \"Credits\":18670609, \"Loan\":0 }"; sr.WriteLine(line2); Console.WriteLine(line2); } } } Write(filename, lineout); } else { break; } if (repeatdelay == -1) { ConsoleKeyInfo k = Console.ReadKey(); if (k.Key == ConsoleKey.Escape) { break; } } else if (repeatdelay > 0) { System.Threading.Thread.Sleep(repeatdelay); if (Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Escape) { break; } } else { break; } repeatcount++; } }