public static void StartTheServer() { try { Console.ForegroundColor = ConsoleColor.Green; zoneServer.Monsters = new List <NonPlayerCharacterClass>(); zoneServer.Vendors = new List <VendingMachine>(); zoneServer.Doors = new List <Doors>(); using (SqlWrapper sqltester = new SqlWrapper()) { if (sqltester.SQLCheck() != SqlWrapper.DBCheckCodes.DBC_ok) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Database setup not correct"); Console.WriteLine("Error: #" + sqltester.lasterrorcode + " - " + sqltester.lasterrormessage); Console.WriteLine("Please press Enter to exit."); Console.ReadLine(); Process.GetCurrentProcess().Kill(); } sqltester.CheckDBs(); } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Loaded {0} items", ItemHandler.CacheAllItems()); Console.WriteLine("Loaded {0} nanos", NanoHandler.CacheAllNanos()); Console.WriteLine("Loaded {0} spawns", NonPlayerCharacterHandler.CacheAllFromDB()); Console.WriteLine("Loaded {0} vendors", VendorHandler.CacheAllFromDB()); Console.WriteLine("Loaded {0} teleports", DoorHandler.CacheAllFromDB()); Console.WriteLine("Loaded {0} statels", Statels.CacheAllStatels()); LootHandler.CacheAllFromDB(); Tradeskill.CacheItemNames(); csc.AddScriptMembers(); csc.CallMethod("Init", null); ThreadMgr.Start(); zoneServer.Start(); Console.ResetColor(); } catch (MySqlException e) { Console.WriteLine("MySql Error. Server Cannot Start"); Console.WriteLine("Exception: " + e.Message); string current = DateTime.Now.ToString("HH:mm:ss"); StreamWriter logfile = File.AppendText("ZoneEngineLog.txt"); logfile.WriteLine(current + " " + e.Source + " MySql Error. Server Cannot Start"); logfile.WriteLine(current + " " + e.Source + " Exception: " + e.Message); logfile.Close(); zoneServer.Stop(); ThreadMgr.Stop(); Process.GetCurrentProcess().Kill(); } }
public override void ExecuteCommand(Client client, Identity target, string[] args) { int itemid = Int32.Parse(args[1]); AONanos it = NanoHandler.GetNano(itemid); if (it == null) { client.SendChatText("No Nano with id " + itemid + " found."); return; } client.SendChatText("Nano Debug Info for Nano " + itemid); client.SendChatText("Attack values:"); foreach (AOItemAttribute at in it.Attack) { client.SendChatText("Type: " + at.Stat + " Value: " + at.Value); } client.SendChatText("Defense values:"); foreach (AOItemAttribute at in it.Defend) { client.SendChatText("Type: " + at.Stat + " Value: " + at.Value); } client.SendChatText("Item Attributes:"); foreach (AOItemAttribute at in it.Stats) { client.SendChatText("Type: " + at.Stat + " Value: " + at.Value); } client.SendChatText("Events/Functions:"); foreach (AOEvents ev in it.Events) { client.SendChatText("Eventtype: " + ev.EventType); foreach (AOFunctions fu in ev.Functions) { client.SendChatText(" Functionnumber: " + fu.FunctionType); foreach (object arg in fu.Arguments.Values) { client.SendChatText(" Argument: " + arg); } foreach (AORequirements aor in fu.Requirements) { client.SendChatText( " Reqs: " + aor.Statnumber + " " + aor.Operator + " " + aor.Value + " " + aor.ChildOperator); } } } }
/// <summary> /// </summary> public static void StartTheServer() { try { Console.ForegroundColor = ConsoleColor.Green; // Log off all characters // TODO: make it playfield dependent Misc.CheckDatabase(); Misc.LogOffAll(); /* TODO: Readd the things, Algorithman * zoneServer.Monsters = new List<NonPlayerCharacterClass>(); * zoneServer.Vendors = new List<VendingMachine>(); * zoneServer.Doors = new List<Doors>(); * * using (SqlWrapper sqltester = new SqlWrapper()) * { * if (sqltester.SQLCheck() != SqlWrapper.DBCheckCodes.DBC_ok) * { * Console.ForegroundColor = ConsoleColor.Red; * Console.WriteLine("Database setup not correct"); * Console.WriteLine("Error: #" + sqltester.lasterrorcode + " - " + sqltester.lasterrormessage); * Console.WriteLine("Please press Enter to exit."); * Console.ReadLine(); * Process.GetCurrentProcess().Kill(); * } * sqltester.CheckDBs(); * } */ Console.ForegroundColor = ConsoleColor.Green; /* TODO: Readd when necessary classes are done again */ Console.WriteLine("Loaded {0} items", ItemLoader.CacheAllItems()); Console.WriteLine("Loaded {0} nanos", NanoHandler.CacheAllNanos()); // Console.WriteLine("Creaated {0} playfields", zoneServer.CreatePlayfields()); /* * Console.WriteLine("Loaded {0} spawns", NonPlayerCharacterHandler.CacheAllFromDB()); * Console.WriteLine("Loaded {0} vendors", VendorHandler.CacheAllFromDB()); * Console.WriteLine("Loaded {0} teleports", DoorHandler.CacheAllFromDB()); * Console.WriteLine("Loaded {0} statels", Statels.CacheAllStatels()); */ /* Same as above * LootHandler.CacheAllFromDB(); * Tradeskill.CacheItemNames(); */ csc.AddScriptMembers(); csc.CallMethod("Init", null); zoneServer.Start(true, false); Console.ResetColor(); } catch (MySqlException e) { Console.WriteLine("MySql Error. Server Cannot Start"); Console.WriteLine("Exception: " + e.Message); string current = DateTime.Now.ToString("HH:mm:ss"); StreamWriter logfile = File.AppendText("ZoneEngineLog.txt"); logfile.WriteLine(current + " " + e.Source + " MySql Error. Server Cannot Start"); logfile.WriteLine(current + " " + e.Source + " Exception: " + e.Message); logfile.Close(); zoneServer.Stop(); Process.GetCurrentProcess().Kill(); } }
/// <summary> /// The main. /// </summary> /// <param name="args"> /// The args. /// </param> private static void Main(string[] args) { Console.WriteLine("**********************************************************************"); Console.WriteLine("** **"); Console.WriteLine("** AO Item and Nano Extractor/Serializer v0.85beta **"); Console.WriteLine("** **"); Console.WriteLine("**********************************************************************"); Console.WriteLine(); string AOPath = string.Empty; bool foundAO = false; Console.WriteLine("Enter exit to close program"); while (!foundAO) { if (File.Exists("config.txt")) { TextReader tr = new StreamReader("config.txt"); AOPath = tr.ReadLine(); tr.Close(); } foundAO = false; Console.Write("Please enter your AO Install Path [" + AOPath + "]:"); string temp = Console.ReadLine(); if (temp != string.Empty) { AOPath = temp; } if (temp.ToLower() == "exit") { return; } if (!Directory.Exists(AOPath)) { continue; } try { extractor = new Extractor(AOPath); TextWriter tw2 = new StreamWriter("config.txt", false, Encoding.GetEncoding("windows-1252")); tw2.WriteLine(AOPath); tw2.Close(); foundAO = true; Console.WriteLine("Found AO Database on " + AOPath); } catch (Exception) { foundAO = false; } // Try to add cd_image\data\db if (!foundAO) { try { AOPath = Path.Combine(AOPath, "cd_image\\data\\db"); extractor = new Extractor(AOPath); TextWriter tw2 = new StreamWriter("config.txt", false, Encoding.GetEncoding("windows-1252")); tw2.WriteLine(AOPath); tw2.Close(); foundAO = true; Console.WriteLine("Found AO Database on " + AOPath); } catch (Exception) { foundAO = false; } } } TextWriter tw = new StreamWriter("itemnames.sql", false, Encoding.GetEncoding("windows-1252")); tw.WriteLine("DROP TABLE IF EXISTS `itemnames`;"); tw.WriteLine("CREATE TABLE `itemnames` ("); tw.WriteLine(" `AOID` int(10) NOT NULL,"); tw.WriteLine(" `Name` varchar(250) NOT NULL,"); tw.WriteLine(" PRIMARY KEY (`AOID`)"); tw.WriteLine(") ENGINE=MyIsam DEFAULT CHARSET=latin1;"); tw.WriteLine(); tw.Close(); Console.WriteLine("Number of Items to extract: " + extractor.GetRecordInstances(0xF4254).Length); // ITEM RECORD TYPE Console.WriteLine("Number of Nanos to extract: " + extractor.GetRecordInstances(0xFDE85).Length); // NANO RECORD TYPE // Console.WriteLine(extractor.GetRecordInstances(0xF4241).Length); // Playfields // Console.WriteLine(extractor.GetRecordInstances(0xF4266).Length); // Nano Strains // Console.WriteLine(extractor.GetRecordInstances(0xF4264).Length); // Perks // GetData(@"D:\c#\extractor serializer\data\items\",0xf4254); // GetData(@"D:\c#\extractor serializer\data\nanos\",0xfde85); // GetData(@"D:\c#\extractor serializer\data\playfields\",0xf4241); // GetData(@"D:\c#\extractor serializer\data\nanostrains\",0xf4266); // GetData(@"D:\c#\extractor serializer\data\perks\",0xf4264); var np = new NewParser(); var rawItemList = new List <AOItem>(); var rawNanoList = new List <AONanos>(); foreach (int recnum in extractor.GetRecordInstances(0xFDE85)) { rawNanoList.Add(np.ParseNano(0xFDE85, recnum, extractor.GetRecordData(0xFDE85, recnum), "temp.sql")); } File.Delete("temp.sql"); Console.WriteLine(); Console.WriteLine("Nanos extracted: " + rawNanoList.Count); List <string> ItemNamesSql = new List <string>(); foreach (int recnum in extractor.GetRecordInstances(0xF4254)) { rawItemList.Add(np.ParseItem(0xF4254, recnum, extractor.GetRecordData(0xF4254, recnum), ItemNamesSql)); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Compacting itemnames.sql"); TextWriter itnsql = new StreamWriter("itemnames.sql", true, Encoding.GetEncoding("windows-1252")); while (ItemNamesSql.Count > 0) { int count = 0; string toWrite = string.Empty; while ((count < 20) && (ItemNamesSql.Count > 0)) { if (toWrite.Length > 0) { toWrite += ","; } toWrite += ItemNamesSql[0]; ItemNamesSql.RemoveAt(0); count++; } if (toWrite != string.Empty) { itnsql.WriteLine("INSERT INTO itemnames VALUES " + toWrite + ";"); } } itnsql.Close(); // SerializationContext.Default.Serializers.Register(new AOFunctionArgumentsSerializer()); Console.WriteLine(); Console.WriteLine("Items extracted: " + rawItemList.Count); Console.WriteLine(); Console.WriteLine("Creating serialized nano data file - please wait"); Stream sf = new FileStream("nanos.dat", FileMode.Create); var ds = new ZOutputStream(sf, zlibConst.Z_BEST_COMPRESSION); var sm = new MemoryStream(); MessagePackSerializer <List <AONanos> > bf = MessagePackSerializer.Create <List <AONanos> >(); var nanoList2 = new List <AONanos>(); int maxnum = 5000; byte[] buffer = BitConverter.GetBytes(maxnum); sm.Write(buffer, 0, buffer.Length); foreach (AONanos nanos in rawNanoList) { nanoList2.Add(nanos); if (nanoList2.Count == maxnum) { bf.Pack(sm, nanoList2); sm.Flush(); nanoList2.Clear(); } } bf.Pack(sm, nanoList2); sm.Seek(0, SeekOrigin.Begin); CopyStream(sm, ds); sm.Close(); ds.Close(); Console.WriteLine(); Console.WriteLine("Checking Nanos..."); Console.WriteLine(); NanoHandler.CacheAllNanos("nanos.dat"); Console.WriteLine(); Console.WriteLine("Nanos: " + NanoHandler.NanoList.Count + " successfully converted"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Creating serialized item data file - please wait"); sf = new FileStream("items.dat", FileMode.Create); ds = new ZOutputStream(sf, zlibConst.Z_BEST_COMPRESSION); sm = new MemoryStream(); MessagePackSerializer <List <AOItem> > bf2 = MessagePackSerializer.Create <List <AOItem> >(); List <AOItem> items = new List <AOItem>(); maxnum = 5000; buffer = BitConverter.GetBytes(maxnum); sm.Write(buffer, 0, buffer.Length); foreach (AOItem it in rawItemList) { items.Add(it); if (items.Count == maxnum) { bf2.Pack(sm, items); sm.Flush(); items.Clear(); } } bf2.Pack(sm, items); sm.Seek(0, SeekOrigin.Begin); CopyStream(sm, ds); sm.Close(); ds.Close(); Console.WriteLine(); Console.WriteLine("Checking Items..."); Console.WriteLine(); ItemHandler.CacheAllItems("items.dat"); Console.WriteLine("Items: " + ItemHandler.ItemList.Count + " successfully converted"); Console.WriteLine(); Console.WriteLine("Further Instructions:"); Console.WriteLine("- Copy items.dat and nanos.dat into your CellAO folder and overwrite."); Console.WriteLine("- Apply itemnames.sql to your database"); Console.WriteLine("Press Enter to exit and have fun with CellAO"); Console.ReadLine(); }