[Development]Public Source!

04/13/2010 16:45 ImFlamedCOD#1
This topic is for TwilightCO's 5017 server. You can find updates , news, pictures and idea all through out this thread. This is a thread where you can put my skills to the test with your ideas!

Currently Working On Satatus:
Attacking - I'm working on base for the attack processor and calculations
Mobs - MobAI (need i say more) and mob spawing

Currently Finished:
Auth Server - Auth server is complete with ban and ip checks along with brute force protection.
Jumping - Jumping was fixed has perfect calculations again.
Talking - Finished
Whisper - Finished
NPC - NPC system finished just need to add dialog
More to be added later*

*Ill add more as i move on , This source is coded in c# 2010 check it out its an amazing edition to help your development.
04/13/2010 17:07 zTREME#2
Goodluck with hte project.
04/13/2010 17:08 ImFlamedCOD#3
No problem its going smoothly right now. The database tho is a pain hahaha.
04/13/2010 19:21 ~Yuki~#4
Count me in. Im not that good at codin but im also bored and i think i coulda do basics if ur looking for help, if not then meh...

btw: Patch 4351 would be cool
04/13/2010 19:29 Kiyono#5
4351 would be good, no potency crap and CPs as alternative currency.
04/13/2010 20:27 Øblivion#6
Quote:
Originally Posted by ImFlamedCOD View Post
Ok guys i got bored and since today is my day off I have been working on Hybrid Bugless release's source. I have told some people who have pm'ed that I was going to release the source. So far here are the details of how far I am.

Progress:
Database - MySQL - 10% roughly it takes awhile to add everything by hand!
Login Server - 80% Done going to add in ip ban checks and such.
Game Server - 10% Done , got to add mobs , and basic attacking soon.
Comands - 10% Done going to add debug commands so when on the server you can asses problems.

Update #1:
Started Working on mobs. They spawn and can die!.


This is where you guys come in. This is going to be a public source, the database will be MySQL that won't change. What I need from you guys now are things like this:
What Version? e.g:5017 , 4267.4353 : 5018+ is out of the question!
What Kind of Packets? By this i mean use a packet builder, use pointer ed packets , use packet structures?
What ever you think I need to add ill add.

I was never good at making new topic's so bear with me. Any questions please feel free to ask and i will reply shortly.
Hm this seems very interesting
Good luck i'm gonna use this if you release it i like hybrids source
04/13/2010 20:57 Kiyono#7
So how are you gonna distribute the source? svn?
04/14/2010 02:29 LetterX#8
For the DB, here are some examples...don't use them (like copy+paste, change shit around, or take parts from it), just use them as a guide...as this was when I was playing around and using the way CoEmu v2 did the DB:

LoadChar Example
Code:
public static bool LoadChar(GameClient Client)//new character load (mysql)
        {
            bool res = false;
            try
            {
                MySqlCommand cmd = new MySqlCommand("SELECT * FROM `characters` WHERE `UID` = \"" + Client.Identifier + "\"", DBConnect.Connection());
                MySqlDataReader DaRe = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (DaRe.Read())
                {
                    Client.Entity.UID = Convert.ToUInt32(DaRe["UID"]);

                    if (Client.Entity.UID == Client.Identifier)
                    {
                        res = true;
                        Client.Entity.Name = Convert.ToString(DaRe["Name"]);
                        Client.Spouse = Convert.ToString(DaRe["Spouse"]);
                        Client.Entity.MapID = Convert.ToUInt16(DaRe["MapID"]);
                        Client.Entity.X = Convert.ToUInt16(DaRe["MapX"]);
                        Client.Entity.Y = Convert.ToUInt16(DaRe["MapY"]);
                        Client.Entity.Model = Convert.ToUInt16(DaRe["Model"]);
                        Client.Job = Convert.ToByte(DaRe["Job"]);
                        Client.Entity.Reborn = Convert.ToUInt16(DaRe["Reborn"]);
                        if (Client.Entity.Reborn > 0)
                        {
                            Client.StatPoints = Convert.ToUInt16(DaRe["StatPoints"]);
                            Client.Spirit = Convert.ToUInt16(DaRe["Spirit"]);
                            Client.Strength = Convert.ToUInt16(DaRe["Strength"]);
                            Client.Vitality = Convert.ToUInt16(DaRe["Vitality"]);
                            Client.Agility = Convert.ToUInt16(DaRe["Agility"]);
                        }
                        else
                        {
                            GetStats(Client);
                        }
                        Client.Entity.Level = Convert.ToByte(DaRe["Level"]);
                        Client.Silvers = Convert.ToInt32(DaRe["Silvers"]);
                        Client.ConquerPoints = Convert.ToInt32(DaRe["CPs"]);
                        Client.Experience = Convert.ToUInt16(DaRe["Experience"]);
                        Client.Entity.HairStyle = Convert.ToUInt16(DaRe["Hairstyle"]);
                        Client.Entity.Hitpoints = Convert.ToInt32(DaRe["HitPoints"]);
                        Client.Staff = Convert.ToInt16(DaRe["Staff"]);
                        Client.NewChar = Convert.ToInt16(DaRe["NewChar"]);
                    }
                    //LoadItems(Client);
                    //LoadInventory(Client);
                }
                DaRe.Close();
                cmd.Dispose();

            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.ToString());
            }
            return res;
        }
LoadPortals
Code:
public static void LoadPortals()//new way to load portals (mysql)
        {
            MySqlCommand cmd = new MySqlCommand("SELECT * FROM `portals`", DBConnect.Connection());
            MySqlDataReader DaRe = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DaRe.Read())
            {
                IPortal portal = new Portal();
                portal.CurrentX = Convert.ToUInt16(DaRe["StartX"]);
                portal.CurrentY = Convert.ToUInt16(DaRe["StartY"]);
                portal.CurrentMapID = Convert.ToUInt16(DaRe["StartMap"]);
                portal.DestinationX = Convert.ToUInt16(DaRe["EndX"]);
                portal.DestinationY = Convert.ToUInt16(DaRe["EndY"]);
                portal.DestinationMapID = Convert.ToUInt16(DaRe["EndMap"]);
                if (!Kernel.Portals.ContainsKey(portal.CurrentX.ToString() + portal.CurrentY.ToString() + portal.CurrentMapID.ToString()))
                    Kernel.Portals.Add(portal.CurrentX.ToString() + portal.CurrentY.ToString() + portal.CurrentMapID.ToString(), portal);
            }
            DaRe.Close();
            Console.WriteLine("[Game] Database - Portals loaded.");
        }
LoadNPCs
Code:
public static void LoadNPCs()
        {
            MySqlCommand cmd = new MySqlCommand("SELECT * FROM `cq_npc`", DBConnect.Connection());
            MySqlDataReader DaRe = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DaRe.Read())
            {
                INpc npc = new NpcSpawnPacket();
                npc.UID = Convert.ToUInt32(DaRe["id"]);
                npc.X = Convert.ToUInt16(DaRe["cellx"]);
                npc.Y = Convert.ToUInt16(DaRe["celly"]);
                npc.MapID = Convert.ToUInt16(DaRe["mapid"]);
                npc.Type = Convert.ToUInt16(DaRe["lookface"]);
                npc.Facing = (ConquerAngle)Convert.ToUInt16(DaRe["type"]);
                npc.StatusFlag = Convert.ToUInt16(DaRe["sort"]);

                GetNpcDictionary:
                Dictionary<uint, INpc> npcs;
                if (Kernel.Npcs.TryGetValue(npc.MapID, out npcs))
                {
                    npcs.Add(npc.UID, npc);
                }
                else
                {
                    npcs = new Dictionary<uint, INpc>();
                    Kernel.Npcs.Add(npc.MapID, npcs);
                    goto GetNpcDictionary;
                }
            }
            DaRe.Close();
            //FOR CONSOLE DISPLAY
            Console.WriteLine("[Game] Database - NPCs Loaded.");
        }
Account Password Check
Code:
public static bool AccountValid(AuthClient Client, ref uint UID)//NEW Auth Login (using MySQL)
        {
            string Password;
            UID = 0;
            MySqlCommand cmd = new MySqlCommand("SELECT * FROM `accounts` WHERE `AccountID` = \"" + Client.Username + "\"", DBConnect.Connection());
            MySqlDataReader DaRe = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DaRe.Read())
            {
                Password = (DaRe["Password"].ToString());
                Console.WriteLine("[Auth] Incoming acc: \"{0}\" w/ the pass: \"{1}\" has connected.", Client.Username, Client.Password);
                //Above is only useful IF server has the password decryption on it (and is using it).

                if (Password.Equals(Client.Password, StringComparison.CurrentCultureIgnoreCase))
                {
                    UID = Convert.ToUInt32(DaRe["UID"]);
                }
            }
            DaRe.Close();
            return (UID != 0);
        }
edit: Ye, this was from a while ago...looks so nooby nao compared to what I prefer to do D:
04/14/2010 02:59 ImFlamedCOD#9
Code:
public static void SaveCharacter(GameClient Client)
        {
        

            MySqlCommand DataAdapter = new MySqlCommand("UPDATE `Characters` Set `Spouse` = \"" + Client.Spouse + 
            "\", `Name` = \"" + Client.Entity.Name +
            "\", `Money` = \"" + Client.Money +
            "\", `Model` = \"" + Client.Entity.Model +
            "\", `ConquerPoints` = \"" + Client.ConquerPoints +
            "\", `Job` = \"" + Client.Job +
            "\", `Strength` = \"" + Client.Strength +
            "\", `Agility` = \"" + Client.Agility +
            "\", `Spirit` = \"" + Client.Spirit +
            "\", `Vitality` = \"" + Client.Vitality +
            "\", `Hitpoints` = \"" + Client.Entity.Hitpoints +
            "\", `Mana` = \"" + Client.Mana +
            "\", `Level` = \"" + Client.Entity.Level +
            "\", `Hairstyle` = \"" + Client.Entity.HairStyle +
            "\", `MapID` = \"" + Client.Entity.MapID +
            "\", `X` = \"" + Client.Entity.X +
            "\", `Y` = \"" + Client.Entity.Y +
            "\", `RebornCount` = \"" + Client.Entity.Reborn +
            "\" WHERE `UID` = \"" + Client.Identifier + "\"", DatabaseConnection);

            SaveFriends(Client);
            SaveInventory(Client);
            SaveEquipment(Client);

            try
            {
                DataAdapter.ExecuteNonQuery();
            }
            catch
            {
            }
        }
Code:
 public static bool LoadCharacter(GameClient Client)
        {
            MySqlDataAdapter DataAdapter = null;
            System.Data.DataSet DSet = new System.Data.DataSet();

            try
            {
                DataAdapter = new MySqlDataAdapter("SELECT * FROM `Characters` WHERE `UID` = \"" + Client.Identifier + "\"", DatabaseConnection);
            }
            catch
            {
                return false;
            }

            DataAdapter.Fill(DSet, "Characters");

            if (DSet.Tables["Characters"].Rows.Count > 0)
            {
                System.Data.DataRow DR = DSet.Tables["Characters"].Rows[0];

                Client.Entity.Level = Convert.ToByte(DR["Level"]);
                Client.Entity.Name = Convert.ToString(DR["Name"]);
                Client.Money = Convert.ToInt32(DR["Money"]); ;
                Client.Entity.Model = Convert.ToUInt32(DR["Model"]);
                Client.ConquerPoints = Convert.ToInt32(DR["ConquerPoints"]);
                Client.Job = Convert.ToByte(DR["Job"]);
                Client.Spouse = Convert.ToString(DR["Spouse"]);
                Client.Entity.Reborn = Convert.ToByte(DR["RebornCount"]);
                Client.Entity.Level = Convert.ToByte(DR["Level"]);
                if (Client.Entity.Reborn > 0)
                {
                    Client.Strength = Convert.ToUInt16(DR["Strength"]);
                    Client.Agility = Convert.ToUInt16(DR["Agility"]);
                    Client.Spirit = Convert.ToUInt16(DR["Spirit"]);
                    Client.Vitality = Convert.ToUInt16(DR["Vitality"]);
                }
                else
                {
                    GetStats(Client);
                }
                Client.Entity.Hitpoints = Convert.ToInt32(DR["Hitpoints"]);
                Client.Mana = Convert.ToUInt16(DR["Mana"]);
                Client.Entity.HairStyle = Convert.ToUInt16(DR["Hairstyle"]);
                Client.Entity.MapID = Convert.ToUInt16(DR["MapID"]);
                Client.Entity.X = Convert.ToUInt16(DR["X"]);
                Client.Entity.Y = Convert.ToUInt16(DR["Y"]);

                LoadFriends(Client);
                LoadInventory(Client);
                LoadEquipment(Client);

                return true;
            }

            return false;
        }
That is how i do it
As tempting as it is , i have already wrote the mysql system. It would be distributed via my private mega upload account or via something else. I personally do not like SVN never did. I would just rar it every time.

I could do what ever patch you guys wanted: 4351 and 5017. I need to ask what you guys like. I could do different versions of it. Im looking at week for a release tho. Im off work till Friday. So I might release something then if not im looking at next Friday for a release.
04/14/2010 05:41 cdzhahonjin#10
4351 patch is my favourite!!
04/14/2010 05:51 .Guru#11
i'm agreeing with yuki and cdzha... on patch. 4351 sounds best to me, as i have not been able to fully run a 4351 source w/o error on my computer. bug me on msn, i may be able to provide a hand. -proto
04/14/2010 06:11 lostsolder05#12
can no one in this thread properly use mysql? LetterX has got the rite idea though, lol.

i also say 4358.
04/14/2010 10:54 _Emme_#13
Just use SubSonic if you going to go with MySQL database, I prefer it very very much!


Quote:
public static bool CheckLogin(AuthClient Client)
{
AccountCollection accounts = new AccountCollection();
accounts.LoadAndCloseReader(Account.FetchByParamet er("Username", Client.Username));
if (accounts.Count > 0)
{
if (accounts[0].Password == Client.Password)
{
Client.LoginType = (LoginType)accounts[0].LoginType;
Client.ID = (uint)accounts[0].AccountID;
}
}
}

That's all of the code you would have to write, rest of the code, the classes for example (Account, AccountCollection etc are generated automatically).

I recommend it, if you need help with implementing it to this server I'd be glad to help.:)
04/15/2010 04:51 cdzhahonjin#14
Quote:
Originally Posted by EmmeTheCoder View Post
Just use SubSonic if you going to go with MySQL database, I prefer it very very much!





That's all of the code you would have to write, rest of the code, the classes for example (Account, AccountCollection etc are generated automatically).

I recommend it, if you need help with implementing it to this server I'd be glad to help.:)
That sounds interesting to me... Can I contact you through PM or email? Or you may send me your email address through PM. Thanks in advance.
04/15/2010 23:30 _Emme_#15
Quote:
Originally Posted by cdzhahonjin View Post
That sounds interesting to me... Can I contact you through PM or email? Or you may send me your email address through PM. Thanks in advance.
Go ahead:)