Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Work-in-progress Gunz Emulator

Status
Not open for further replies.
Extreme Coder - Delphi
Loyal Member
Joined
Sep 8, 2007
Messages
1,381
Reaction score
39
Does this mean we can add sotry mode to GunZ :)?
 
Experienced Elementalist
Joined
Mar 15, 2009
Messages
219
Reaction score
39
Shameless bump + double post. New version up. See the first post.
 
DRGunZ 2 Creator
Loyal Member
Joined
Jan 21, 2007
Messages
4,493
Reaction score
161
lol, everything gets delayed by real life.
some advice : Abandon your life, it sucks. You will get alot more done.
OR get one of those jobs where you work at your own time and pace at your own home. Which means you can work on it any time you like.

Thanks for the update though.
 
Experienced Elementalist
Joined
Mar 15, 2009
Messages
219
Reaction score
39
lol, everything gets delayed by real life.
some advice : Abandon your life, it sucks. You will get alot more done.
OR get one of those jobs where you work at your own time and pace at your own home. Which means you can work on it any time you like.

Thanks for the update though.

Great advice. I'm totally gonna abandon my life for the internet now. Never thought of that.

And don't expect updates today. Going to a kickass concert tonight so I won't be working on this until tomorrow. I did get a Sourceforge project approved though, I'll try to get the SVN and whatnot set up tomorrow.
 
Extreme Coder - Delphi
Loyal Member
Joined
Sep 8, 2007
Messages
1,381
Reaction score
39
downloaded the source, just wondering how u know all of this O___O, its freakin awesome =D
 
Praise the Sun!
Loyal Member
Joined
Dec 4, 2007
Messages
2,502
Reaction score
986
Lol. Well we picked C# for a few reasons.

1) It's an open-source project, so this is made with the community in mind. A lot of people in the Gunz community seem to know or are learning C#. That's also why we were very thorough with the documentation, comments, etc.

2) Gunz servers don't seem to need very many resources at all, so the overhead from making it in a .NET language seems like it'd probably be negligible. I could be wrong, we'll see. But this is seeming like the case to me.

3) It's got a lot of stuff already built into the language, so it speeds up development time, in my opinion at least. I'm decent with C++ but not fluent enough to attempt something like this, nor do I have a big enough ego to try to code it without the proper experience in C++.

But thanks for the comment, I appreciate it.

I understand and respect the decision, it's just that I don't like .NET.
 
Junior Spellweaver
Joined
Dec 30, 2006
Messages
124
Reaction score
0
Seeing as I prefer Java over C# just because, does C# or the .NET platform in general implement any sort of JIT compiling or inline code? If so I guess the speed problem wouldn't be too bad for a server, so long as resources are managed appropriately.
 
Junior Spellweaver
Joined
Apr 12, 2009
Messages
104
Reaction score
10
Very interesting, I shall keep a close watch on this emulator to see how it is doing.

I could also develop tools to edit however you decide to setup the file structure.
 
DRGunZ 2 Creator
Loyal Member
Joined
Jan 21, 2007
Messages
4,493
Reaction score
161
thanks for the update. And good luck still :p
 
Extreme Coder - Delphi
Loyal Member
Joined
Sep 8, 2007
Messages
1,381
Reaction score
39
is there a Team Cat, Team Dog, what other teams are there :)?
 
Joined
Sep 10, 2007
Messages
970
Reaction score
815
Might I recommend you use a SVN for easier updating and noticing? Also, are you using the original GunzDB so people can just simply move over to this when they want to? /me goest back to his new emulator.
 
Experienced Elementalist
Joined
Mar 15, 2009
Messages
219
Reaction score
39
There's a custom DB included with the package.
 
Skilled Illusionist
Joined
Nov 11, 2008
Messages
388
Reaction score
42
Two questions,
First,
How are you going to write the login packets ? Could you have like ijji, a login page on the website and code the login to a .dll.
Second,
Who are all thease teams ?
Team Lion, Team Zebra, I've never heard of them, you just all appeared. Are you old MAIET staff ?
Just I've never seen you around and when you come along you're like the best.
 
Experienced Elementalist
Joined
Mar 15, 2009
Messages
219
Reaction score
39
Nova™;4919073 said:
Two questions,
First,
How are you going to write the login packets ? Could you have like ijji, a login page on the website and code the login to a .dll.
Second,
Who are all thease teams ?
Team Lion, Team Zebra, I've never heard of them, you just all appeared. Are you old MAIET staff ?
Just I've never seen you around and when you come along you're like the best.

I dunno who Team Lion is, I have a feeling it's just a troll or something lol. Notice the obvious play on words referring to my name. As far as my team goes, we're not affiliated with MAIET lol, just some high school kids who wanna code something cool. You've probably seen all of us around the forums already, we're not new to the scene. But we'd rather not say who we are, at least not at this point.

As far as the ijji stuff goes, that's a long-term goal but as of now we're just working with the July 2007 client that everyone's already familiar with. Once we get a gamemode or two working then we're going to look into switching over to the ijji client for development.

could u comment out most of the code so, that we can understand better (this doesnt go to phail772 -__-)

Uhm, no. This is meant for developers and the code itself is easy enough to read and is already amply commented and documented as it is. If you can't comprehend it at this stage, then emulator development is obviously not something you're ready for, honestly.
 
Junior Spellweaver
Joined
Apr 12, 2009
Messages
104
Reaction score
10
If the developers can't understand source like this, they are probably not very fit to be developers.

Understanding this source requires knowledge of C# syntax and that is it.
With that knowledge you can easily see that certain areas construct packets, handle clients, and threading. You don't need to understand the packet formats because when this is fully implemented, a.k.a. when you said they'd be using it, all of the packet formats will be implemented and don't need to be modified.
 
Joined
Sep 10, 2007
Messages
970
Reaction score
815
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace MatchServer
{
    class Match
    {
        public static void MatchResponseLogin(Client pClient, Packet cPacket)
        {
            string username = null;
            string password = null;
            int version = 0;
            int crc = 0;
            int eCount = 0;
            int eSize = 0;

            if (!cPacket.Read(ref username) ||
                !cPacket.Read(ref password) ||
                !cPacket.Read(ref version) ||
                !cPacket.Read(ref crc) ||
                !cPacket.Read(ref eCount, ref eSize))
            {
                pClient.Log(LogType.Error, "User: {0}. Pass: {1}. Version: {2}. CRC: {3}. Count: {4}. Size: {5}", username, password, version, crc, eCount, eSize);
                pClient.Disconnect();
            }
            Result result = Result.Accepted;
            SqlConnection sql = new SqlConnection(Program.SQLString);
            sql.Open();

            SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead);
            SqlCommand cmd = new SqlCommand("EXEC [dbo].spGetLoginInfo @UserID", sql,trans);
            cmd.Parameters.AddWithValue("@UserID", username);
            
            SqlDataReader sqlData = cmd.ExecuteReader();
            if (!sqlData.Read())
                result = Result.WrongPassword;
            else
            {
                pClient.AccountID = Convert.ToInt32(sqlData["AID"]);

                SqlCommand sqlcmd = new SqlCommand("SELECT * FROM Account WHERE AID=@AID", sql,trans);
                sqlcmd.Parameters.AddWithValue("@AID", pClient.AccountID);

                SqlDataReader sDR = sqlcmd.ExecuteReader();
                if (!sDR.Read())
                    result = Result.WrongPassword;

                else
                {
                    pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]);
                    if (!password.Equals(sqlData["Password"]))
                        result = Result.WrongPassword;
                    else if (pClient.UGradeID == 253 || pClient.UGradeID == 105)
                        result = Result.Banned;
                    else
                        pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]);
                }
            }

            Packet packet = new Packet(OpCode.MatchResponseLogin, PacketEncryption.Encrypted, pClient.PacketCount);
            packet.Write((int)result);
            packet.Write("Viral Server");
            packet.Write((byte)1);
            packet.Write(username);
            packet.Write(pClient.UGradeID);
            packet.Write((byte)0);
            packet.Write(pClient.ClientID);
            packet.Write(1, 20);
            packet.WriteSkip(20);

            pClient.Send(packet);
            pClient.Register(OpCode.MatchRequestCharList, MatchResponseAccountCharList);

        }

        public static void MatchResponseAccountCharList(Client pClient, Packet pPacket)
        {
            Int32 eSize, eCount;
            eSize = eCount = 0;

            byte[] rand = new byte[20];

            if (!pPacket.Read(ref eSize, ref eCount) ||
                !pPacket.Read(ref rand, 0, 20))
            {
                pClient.Disconnect();
            }

            Packet cPacket = new Packet(OpCode.MatchResponseCharList, PacketEncryption.Encrypted, pClient.PacketCount);
            using (SqlConnection sql = new SqlConnection(Program.SQLString))
            {
                sql.Open();
                SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead);
                SqlCommand cmd = new SqlCommand("SELECT COUNT(*) AS count FROM Character WHERE AID=@AID", sql,trans);
                cmd.Parameters.AddWithValue("@AID", pClient.AccountID);

                cPacket.Write(34, Convert.ToInt32(cmd.ExecuteScalar()));

                cmd = new SqlCommand("SELECT TOP 4 Name,Level FROM Character WHERE AID=@AID ORDER BY Name ASC", sql,trans);
                cmd.Parameters.AddWithValue("@AID", pClient.AccountID);

                SqlDataReader sdR = cmd.ExecuteReader();
                
                byte index = 0;

                while (sdR.Read())
                {
                    cPacket.Write(Convert.ToString("Name"),32);
                    cPacket.Write(index++);
                    cPacket.Write(Convert.ToByte("Level"));
                }

            }

            pClient.Send(cPacket);
        }
    }
}

Mine that I did in half an hour last night.
 
Experienced Elementalist
Joined
Mar 15, 2009
Messages
219
Reaction score
39
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
 
namespace MatchServer
{
    class Match
    {
        public static void MatchResponseLogin(Client pClient, Packet cPacket)
        {
            string username = null;
            string password = null;
            int version = 0;
            int crc = 0;
            int eCount = 0;
            int eSize = 0;
 
            if (!cPacket.Read(ref username) ||
                !cPacket.Read(ref password) ||
                !cPacket.Read(ref version) ||
                !cPacket.Read(ref crc) ||
                !cPacket.Read(ref eCount, ref eSize))
            {
                pClient.Log(LogType.Error, "User: {0}. Pass: {1}. Version: {2}. CRC: {3}. Count: {4}. Size: {5}", username, password, version, crc, eCount, eSize);
                pClient.Disconnect();
            }
            Result result = Result.Accepted;
            SqlConnection sql = new SqlConnection(Program.SQLString);
            sql.Open();
 
            SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead);
            SqlCommand cmd = new SqlCommand("EXEC [dbo].spGetLoginInfo @UserID", sql,trans);
            cmd.Parameters.AddWithValue("@UserID", username);
 
            SqlDataReader sqlData = cmd.ExecuteReader();
            if (!sqlData.Read())
                result = Result.WrongPassword;
            else
            {
                pClient.AccountID = Convert.ToInt32(sqlData["AID"]);
 
                SqlCommand sqlcmd = new SqlCommand("SELECT * FROM Account WHERE AID=@AID", sql,trans);
                sqlcmd.Parameters.AddWithValue("@AID", pClient.AccountID);
 
                SqlDataReader sDR = sqlcmd.ExecuteReader();
                if (!sDR.Read())
                    result = Result.WrongPassword;
 
                else
                {
                    pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]);
                    if (!password.Equals(sqlData["Password"]))
                        result = Result.WrongPassword;
                    else if (pClient.UGradeID == 253 || pClient.UGradeID == 105)
                        result = Result.Banned;
                    else
                        pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]);
                }
            }
 
            Packet packet = new Packet(OpCode.MatchResponseLogin, PacketEncryption.Encrypted, pClient.PacketCount);
            packet.Write((int)result);
            packet.Write("Viral Server");
            packet.Write((byte)1);
            packet.Write(username);
            packet.Write(pClient.UGradeID);
            packet.Write((byte)0);
            packet.Write(pClient.ClientID);
            packet.Write(1, 20);
            packet.WriteSkip(20);
 
            pClient.Send(packet);
            pClient.Register(OpCode.MatchRequestCharList, MatchResponseAccountCharList);
 
        }
 
        public static void MatchResponseAccountCharList(Client pClient, Packet pPacket)
        {
            Int32 eSize, eCount;
            eSize = eCount = 0;
 
            byte[] rand = new byte[20];
 
            if (!pPacket.Read(ref eSize, ref eCount) ||
                !pPacket.Read(ref rand, 0, 20))
            {
                pClient.Disconnect();
            }
 
            Packet cPacket = new Packet(OpCode.MatchResponseCharList, PacketEncryption.Encrypted, pClient.PacketCount);
            using (SqlConnection sql = new SqlConnection(Program.SQLString))
            {
                sql.Open();
                SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead);
                SqlCommand cmd = new SqlCommand("SELECT COUNT(*) AS count FROM Character WHERE AID=@AID", sql,trans);
                cmd.Parameters.AddWithValue("@AID", pClient.AccountID);
 
                cPacket.Write(34, Convert.ToInt32(cmd.ExecuteScalar()));
 
                cmd = new SqlCommand("SELECT TOP 4 Name,Level FROM Character WHERE AID=@AID ORDER BY Name ASC", sql,trans);
                cmd.Parameters.AddWithValue("@AID", pClient.AccountID);
 
                SqlDataReader sdR = cmd.ExecuteReader();
 
                byte index = 0;
 
                while (sdR.Read())
                {
                    cPacket.Write(Convert.ToString("Name"),32);
                    cPacket.Write(index++);
                    cPacket.Write(Convert.ToByte("Level"));
                }
 
            }
 
            pClient.Send(cPacket);
        }
    }
}

Mine that I did in half an hour last night.

Uhm. Alright >_> I already got logging in and the character list working, it's in the public revision in the first post. We're working on the lobby stuff right now.
 
Junior Spellweaver
Joined
Apr 12, 2009
Messages
104
Reaction score
10
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace MatchServer
{
    class Match
    {
        public static void MatchResponseLogin(Client pClient, Packet cPacket)
        {
            string username = null;
            string password = null;
            int version = 0;
            int crc = 0;
            int eCount = 0;
            int eSize = 0;

            if (!cPacket.Read(ref username) ||
                !cPacket.Read(ref password) ||
                !cPacket.Read(ref version) ||
                !cPacket.Read(ref crc) ||
                !cPacket.Read(ref eCount, ref eSize))
            {
                pClient.Log(LogType.Error, "User: {0}. Pass: {1}. Version: {2}. CRC: {3}. Count: {4}. Size: {5}", username, password, version, crc, eCount, eSize);
                pClient.Disconnect();
            }
            Result result = Result.Accepted;
            SqlConnection sql = new SqlConnection(Program.SQLString);
            sql.Open();

            SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead);
            SqlCommand cmd = new SqlCommand("EXEC [dbo].spGetLoginInfo @UserID", sql,trans);
            cmd.Parameters.AddWithValue("@UserID", username);
            
            SqlDataReader sqlData = cmd.ExecuteReader();
            if (!sqlData.Read())
                result = Result.WrongPassword;
            else
            {
                pClient.AccountID = Convert.ToInt32(sqlData["AID"]);

                SqlCommand sqlcmd = new SqlCommand("SELECT * FROM Account WHERE AID=@AID", sql,trans);
                sqlcmd.Parameters.AddWithValue("@AID", pClient.AccountID);

                SqlDataReader sDR = sqlcmd.ExecuteReader();
                if (!sDR.Read())
                    result = Result.WrongPassword;

                else
                {
                    pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]);
                    if (!password.Equals(sqlData["Password"]))
                        result = Result.WrongPassword;
                    else if (pClient.UGradeID == 253 || pClient.UGradeID == 105)
                        result = Result.Banned;
                    else
                        pClient.UGradeID = Convert.ToByte(sDR["UGradeID"]);
                }
            }

            Packet packet = new Packet(OpCode.MatchResponseLogin, PacketEncryption.Encrypted, pClient.PacketCount);
            packet.Write((int)result);
            packet.Write("Viral Server");
            packet.Write((byte)1);
            packet.Write(username);
            packet.Write(pClient.UGradeID);
            packet.Write((byte)0);
            packet.Write(pClient.ClientID);
            packet.Write(1, 20);
            packet.WriteSkip(20);

            pClient.Send(packet);
            pClient.Register(OpCode.MatchRequestCharList, MatchResponseAccountCharList);

        }

        public static void MatchResponseAccountCharList(Client pClient, Packet pPacket)
        {
            Int32 eSize, eCount;
            eSize = eCount = 0;

            byte[] rand = new byte[20];

            if (!pPacket.Read(ref eSize, ref eCount) ||
                !pPacket.Read(ref rand, 0, 20))
            {
                pClient.Disconnect();
            }

            Packet cPacket = new Packet(OpCode.MatchResponseCharList, PacketEncryption.Encrypted, pClient.PacketCount);
            using (SqlConnection sql = new SqlConnection(Program.SQLString))
            {
                sql.Open();
                SqlTransaction trans = sql.BeginTransaction(IsolationLevel.RepeatableRead);
                SqlCommand cmd = new SqlCommand("SELECT COUNT(*) AS count FROM Character WHERE AID=@AID", sql,trans);
                cmd.Parameters.AddWithValue("@AID", pClient.AccountID);

                cPacket.Write(34, Convert.ToInt32(cmd.ExecuteScalar()));

                cmd = new SqlCommand("SELECT TOP 4 Name,Level FROM Character WHERE AID=@AID ORDER BY Name ASC", sql,trans);
                cmd.Parameters.AddWithValue("@AID", pClient.AccountID);

                SqlDataReader sdR = cmd.ExecuteReader();
                
                byte index = 0;

                while (sdR.Read())
                {
                    cPacket.Write(Convert.ToString("Name"),32);
                    cPacket.Write(index++);
                    cPacket.Write(Convert.ToByte("Level"));
                }

            }

            pClient.Send(cPacket);
        }
    }
}

Mine that I did in half an hour last night.

Does that implement any sort of safe SQL functionality by using the AddWithValue at all? Or did you just not implement any sort of safety with it at the time you created it?
 
Status
Not open for further replies.
Back
Top