[v4267]CoEmu - My Source

06/02/2012 22:49 I don't have a username#1
This is not the CoEmu by Andy. This is my custom source. It's still under development and as of now the auth is only finished.

Why did I call it CoEmu then?
I like the name and basically it means Co Emulator.

It's running on patch 4267 (Will run fine with a 4274 client).
It has support for multiple game-servers as well.
It uses MSSQL for database.

I have quite a lot of ideas with the source, but you'll see later on ;).

I'll be posting the database once I've finished the login sequence (Should be able to in about a day or so.)

Revision 1:

Added a database manager for sql,working like following:
INSERT
Code:
Exception sqlException;
                    // Inserting an account with the name "NewAccount" and the password "1234"
                    if ((sqlException = new CoEmu.Database.DBManager("Accounts", CoEmu.Database.DBCommandType.INSERT, connectionString)
                   .AddParam("AccountName", System.Data.SqlDbType.VarChar, "NewAccount")
                    .AddParam("AccountPass", System.Data.SqlDbType.VarChar, "1234")
                   .AddParam("AccountBanned", System.Data.SqlDbType.TinyInt, 0)
                   .Execute()) != null)
                        Console.WriteLine(sqlException.ToString());
UPDATE
Code:
Exception sqlException;
                    // Updating the password of "NewAccount" to 1337
                    if ((sqlException = new CoEmu.Database.DBManager("Accounts", CoEmu.Database.DBCommandType.UPDATE, connectionString)
                   .AddParam("AccountPass", System.Data.SqlDbType.VarChar, "1337")
                   .AddWhere("AccountName", System.Data.SqlDbType.VarChar, "NewAccount")
                   .Execute()) != null)
                        Console.WriteLine(sqlException.ToString());
SELECT
Code:
Exception sqlException;
                    // Selecting "NewAccount" and printing its data out
                    CoEmu.Database.DBCollection coll = new CoEmu.Database.DBManager("Accounts", CoEmu.Database.DBCommandType.SELECT, connectionString)
                    .AddParam("AccountID", System.Data.SqlDbType.Int)
                    .AddParam("AccountName", System.Data.SqlDbType.VarChar)
                    .AddParam("AccountPass", System.Data.SqlDbType.VarChar)
                    .AddParam("AccountBanned", System.Data.SqlDbType.TinyInt)
                    .AddWhere("AccountName", System.Data.SqlDbType.VarChar, "NewAccount")
                    .ExecuteReader(out sqlException);
                    if (sqlException != null)
                        Console.WriteLine(sqlException.ToString());
                    else if (coll.HasItems())
                    {
                        Console.WriteLine("{0} : {1}", coll["AccountID"].Column, (uint)coll["AccountID"]);
                        Console.WriteLine("{0} : {1}", coll["AccountName"].Column, (string)coll["AccountName"]);
                        Console.WriteLine("{0} : {1}", coll["AccountPass"].Column, (string)coll["AccountPass"]);
                        Console.WriteLine("{0} : {1}", coll["AccountBanned"].Column, (byte)coll["AccountBanned"]);
                    }
DELETE
Code:
Exception sqlException;
                    // Deleting "NewAccount"
                    if ((sqlException = new CoEmu.Database.DBManager("Accounts", CoEmu.Database.DBCommandType.DELETE, connectionString)
                   .AddWhere("AccountName", System.Data.SqlDbType.VarChar, "NewAccount")
                   .Execute()) != null)
                        Console.WriteLine(sqlException.ToString());
Feedback would be appreciated a lot, because then I would be able to know what I could do better and what errors there is, tho not much coded atm. then there is more to come.
06/02/2012 23:11 tkblackbelt#2
Nice job keep us posted on the progress. It seems a lot of people are deving for the older patches now.
06/02/2012 23:24 I don't have a username#3
Quote:
Originally Posted by tkblackbelt View Post
Nice job keep us posted on the progress. It seems a lot of people are deving for the older patches now.
I was working on another source at same patch some time ago, but wasn't really that good IMO, so I thought I'd just make a new :P

Thanks tho :)
06/03/2012 19:18 Micro_Mouse#4
Will be studying this source revision by revision, thanks!(:
06/03/2012 19:51 _DreadNought_#5
Looking good sexy. (In the most homo way possible!)
06/03/2012 22:16 Zeroxelli#6
Rather interesting way of programming (the way you write things out.) I do like it. One thing I'll say is, though not many packets need be parsed in the AuthServer (as there aren't many auth packets to begin with), it may still be cleaner to have a separate file and class for packet parsing. It's moreso a matter of personal preference, so it's up to you. And also, when you access a variable of a packet, you read from the buffer every time. Even though you're using pointers, this practice in the gameserver could slow things down, and in some cases where the memory of your dedicated server is not protected, could result in buffer overflows or access violations. It's "safer" in most cases to just assign the values to variables when you first read the packet into it's own class/struct. Just keep in mind that, with a lot of servers, unlike your computer their memory is NOT protected and can at times become corrupted when leaving the server running for a long period of time. I've run into this problem with two hosts in the past, but was able to solve it simply by restarting the server one every two weeks or so. It may not be the case for you, but it's still something to keep in mind. (As well as speed concerns if you've got hundreds of users online at one time, but that's almost never the case with pservers.)

Edit: Also, in case someone says "oh men it saves memory space to read every time instead of assigning multiple variables which take up memory space." No. If you utilize garbage collection, and/or design your programs correctly, the variables don't stay in the memory after they're used.
06/03/2012 22:28 I don't have a username#7
That's why you clean up your memory and always dispose streams etc. lol and there is 2 packets to handle at auth, but as I got a seperate auth for the game-server, that makes 3 :P

Updated a few things, that's gonna be different in revision 2, like switching out the sql things with the ones shown in OP.
06/03/2012 22:59 Zeroxelli#8
Quote:
Originally Posted by I don't have a username View Post
That's why you clean up your memory and always dispose streams etc. lol and there is 2 packets to handle at auth, but as I got a seperate auth for the game-server, that makes 3 :P

Updated a few things, that's gonna be different in revision 2, like switching out the sql things with the ones shown in OP.
Of course, but the memory on other machines isn't always safe. One corrupt bit in the memory could screw everything up, and that's why you have to be so careful with unsafe code when hosting your server.
06/03/2012 23:32 I don't have a username#9
Not really that much in this case.
06/04/2012 07:01 S U P E R B A D#10
good job. i love you and you have nice titties
06/04/2012 09:50 Korvacs#11
Quote:
Originally Posted by Zeroxelli View Post
Of course, but the memory on other machines isn't always safe. One corrupt bit in the memory could screw everything up, and that's why you have to be so careful with unsafe code when hosting your server.
Typically if your hosting your server on a VPS or a dedicated server, then that memory will be ECC memory and isnt susceptible to single bit corruption.
06/04/2012 10:40 Zeroxelli#12
Quote:
Originally Posted by Korvacs View Post
Typically if your hosting your server on a VPS or a dedicated server, then that memory will be ECC memory and isnt susceptible to single bit corruption.
Assuming the host is "typical", of course.
06/04/2012 10:47 Korvacs#13
Quote:
Originally Posted by Zeroxelli View Post
Assuming the host is "typical", of course.
A host couldnt really call themselves a professional hosting company if they didnt use ECC, if we can afford to use it at work they can afford to use it on their hundreds/thousands of servers.
06/04/2012 11:37 I don't have a username#14
If corrupt memory is a problem, why even host such thing?
06/04/2012 12:14 ragab2#15
this source have weapon 135 and make Commandos for players