Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 19:37

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



ConquerServer_v2 Problem with converting to MySQL

Discussion on ConquerServer_v2 Problem with converting to MySQL within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1

 
Kiyono's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 3,296
Received Thanks: 925
ConquerServer_v2 Problem with converting to MySQL

//edit Different question

Will using MySQL done in the way below (randomly starting new readers in the same void) be bad?
Code:
MySqlCommand command3 = new MySqlCommand(MySqlCommandType.SELECT);
            command3.Select("cq_generator");
            MySqlReader reader3 = new MySqlReader(command3);
            num = 0;
            uint SpawnID = 0;
            List<uint> UsedMaps = new List<uint>();
            List<uint> SpawnIDs = new List<uint>();
            // Monster Spawns (cq_generator)
            while (reader3.Read())
            {
                uint tMapID = reader3.ReadUInt32("mapid");
                if (UsedMaps.Contains(tMapID))
                    continue;

                if (tMapID == MapID.TrainingGrounds.Id || tMapID == 1219 || tMapID == 1052 || tMapID == 4025 || tMapID == 4024 || tMapID == 4023 || tMapID == 4022 || tMapID == 4021)
                    continue;

                UsedMaps.Add(tMapID);
                MobCollection Linker = new MobCollection(tMapID, 5000);
                if (Kernel.DMaps.TryGetValue(tMapID, out Linker.DMap))
                    Linker.DMap.Mobs = Linker;

                MySqlCommand command4 = new MySqlCommand(MySqlCommandType.SELECT);
                command4.Select("cq_generator");
                MySqlReader reader4 = new MySqlReader(command4);

                while (reader4.Read())
                {
                    if (reader4.ReadUInt32("mapid") == tMapID)
                    {
                        SpawnID = reader4.ReadUInt32("id");
                        while (!SpawnIDs.Contains(SpawnID))
                        {
                            MonsterSpawn Spawn = new MonsterSpawn();
                            Spawn.CollectionOwner = Linker;
                            uint ID = reader4.ReadUInt32("npctype");

                            if (!MonsterFamilies.TryGetValue(ID, out Spawn.Family))
                            {
                                continue;
                            }
                            Spawn.SpawnX = reader4.ReadUInt16("bound_x");
                            Spawn.SpawnY = reader4.ReadUInt16("bound_y");
                            Spawn.MaxSpawnX = (ushort)(Spawn.SpawnX + reader4.ReadUInt16("bound_cx"));
                            Spawn.MaxSpawnY = (ushort)(Spawn.SpawnY + reader4.ReadUInt16("bound_cy"));
                            Spawn.MapID = tMapID;
                            Spawn.SpawnCount = reader4.ReadByte("max_per_gen");
                            Linker.AddSpawn(Spawn);
                            SpawnIDs.Add(SpawnID);
                        }
                    }
                }
                num += Linker.FinalizeCollection();
            }
            MonsterSpawn.StartSingleChildAI();
            Console.WriteLine("\tLoaded {0} Monsters.",
Albetros' MySQL system btw.

//edit In case the person reading this doesn't know, ConquerServer_v2 is the 5135 source that Hybrid released; aka, Project Manifest.
Kiyono is offline  
Old 01/09/2012, 00:38   #2

 
Kiyono's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 3,296
Received Thanks: 925
Too be honest; it'd be faster for you to download the source and check it then to wait for me to figure out what part the mobspawn code is.

//edit I think that I know why it doesn't work. In the original code, it creates 1 mobcollection per map while in my code it keeps recreating the collection. This explains why it loads the monsters while they don't appear on the map; they are simply not part of the collection. Also more or less explains why only 1 mob gets spawned; it's the last mob in the table, in other words the last time the collection gets recreated.

//edit Behold; the most roundabout and probably most shitty way to do it:
Code:
MySqlCommand command3 = new MySqlCommand(MySqlCommandType.SELECT);
            command3.Select("cq_generator");
            MySqlReader reader3 = new MySqlReader(command3);
            num = 0;
            uint SpawnID = 0;
            List<uint> UsedMaps = new List<uint>();
            List<uint> SpawnIDs = new List<uint>();
            // Monster Spawns (cq_generator)
            while (reader3.Read())
            {
                uint tMapID = reader3.ReadUInt32("mapid");
                if (UsedMaps.Contains(tMapID))
                    continue;

                if (tMapID == MapID.TrainingGrounds.Id || tMapID == 1219 || tMapID == 1052 || tMapID == 4025 || tMapID == 4024 || tMapID == 4023 || tMapID == 4022 || tMapID == 4021)
                    continue;

                UsedMaps.Add(tMapID);
                MobCollection Linker = new MobCollection(tMapID, 5000);
                if (Kernel.DMaps.TryGetValue(tMapID, out Linker.DMap))
                    Linker.DMap.Mobs = Linker;

                MySqlCommand command4 = new MySqlCommand(MySqlCommandType.SELECT);
                command4.Select("cq_generator");
                MySqlReader reader4 = new MySqlReader(command4);

                while (reader4.Read())
                {
                    if (reader4.ReadUInt32("mapid") == tMapID)
                    {
                        SpawnID = reader4.ReadUInt32("id");
                        while (!SpawnIDs.Contains(SpawnID))
                        {
                            MonsterSpawn Spawn = new MonsterSpawn();
                            Spawn.CollectionOwner = Linker;
                            uint ID = reader4.ReadUInt32("npctype");

                            if (!MonsterFamilies.TryGetValue(ID, out Spawn.Family))
                            {
                                continue;
                            }
                            Spawn.SpawnX = reader4.ReadUInt16("bound_x");
                            Spawn.SpawnY = reader4.ReadUInt16("bound_y");
                            Spawn.MaxSpawnX = (ushort)(Spawn.SpawnX + reader4.ReadUInt16("bound_cx"));
                            Spawn.MaxSpawnY = (ushort)(Spawn.SpawnY + reader4.ReadUInt16("bound_cy"));
                            Spawn.MapID = tMapID;
                            Spawn.SpawnCount = reader4.ReadByte("max_per_gen");
                            Linker.AddSpawn(Spawn);
                            SpawnIDs.Add(SpawnID);
                        }
                    }
                }
                num += Linker.FinalizeCollection();
            }
            MonsterSpawn.StartSingleChildAI();
            Console.WriteLine("\tLoaded {0} Monsters.", num);
        }
But it works, lol
Kiyono is offline  
Old 01/10/2012, 01:48   #3
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
I'd like to mention I've never really been proud of my monster system in any of my sources and don't think I really did as well as a job implementing them as I possibly could have. I'd highly recommend recoding the entire system if you ever get a chance.
InfamousNoone is offline  
Old 01/10/2012, 16:09   #4

 
Kiyono's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 3,296
Received Thanks: 925
Ok, question changed, check OP.
Kiyono is offline  
Reply


Similar Threads Similar Threads
[5017] Client disappearing problem ConquerServer_v2
12/27/2011 - CO2 Private Server - 0 Replies
//edit nevermind, tried it again and it suddenly worked.
[PROBLEM]:[Root]:Mysql:[...]/tmp/mysql.sock
10/22/2011 - Metin2 Private Server - 3 Replies
Hallo Community habe jetzt seit ein Paar Tagen einen Fehler Namens: failed, retrying in 5 secondsmysql_real_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Screen: http://img809.imageshack.us/img809/9805/helpg.png
Converting flat-file to MySQL (ini to MySQL) - How?
09/13/2011 - CO2 Programming - 3 Replies
The question says it all. Using LOTF is a real joy for me because I understand it real well. The only problem is I like to use my PHP skills and I don't know/think I can have it read data like it would from a MySQL database by using .ini databases. How would I go about re-writing the database to save/load by using MySQL? Is it as simple as copying another sources way of save/loading?
Does someone knows how to code NPCs in ConquerServer_v2??
06/09/2011 - CO2 Private Server - 6 Replies
i downloaded conquerserver_v2 and i set it up,but i want to learn to code NPC in it and i need an example for it .Can someone help me?:(
[Help]Problem with logging in after converting into ini.
01/19/2009 - CO2 Private Server - 5 Replies
Hi guys, Emme helped me halfway through with converting LOTF into ini and I finished the rest myself. When I logged in, I made my character and then when I re-logged in, my client closed. Here's the error on the console: http://i42.tinypic.com/4g5emv.jpg Emme or anyone out there please help me! :( #Edit FIXED IT



All times are GMT +1. The time now is 19:39.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.