[Release] Extremely basic (but working/bugless) C# Source

01/19/2009 22:47 InfamousNoone#1
This pretty much has a very finite amount of stuff done in it. Specifically this is pretty much all thats in it.

If your serious about trying to develop a server in C#, I suggest looking at this. There's a DLL also included (check the "bin" folder) which will need to be added as a reference. SocketNetwork.dll pretty much handles the socket-system and encryptions for you it is not packed or obfuscated if you would like to decompile it and take a look at it, be my guest.

I included a folder with the database also which is the dumped version of cq_npc.sql, if anyone would like me to post my cq (sql) database dumper to inis let me know.

The source is completely flatfile. I will be providing no support in explaining how things work, how to add things and etc, etc. Your on your own for that.

At the moment, the source is 100% "safe-code" which means no pointer usage.

Revision 1:
[Only registered and activated users can see links. Click Here To Register...]

Revision 2:
[Only registered and activated users can see links. Click Here To Register...]

Revision 3:
[Only registered and activated users can see links. Click Here To Register...]
- Rev3 Implements Equipment, but does not save it!
- Rev3 Does not contain a database, read the "Notes" section below!
- MUST READ FOR REV3! - [Only registered and activated users can see links. Click Here To Register...]

PS:
This is for the old encryption, patch 5017, not 5018+ :P.

Utilities
[Only registered and activated users can see links. Click Here To Register...]

[Only registered and activated users can see links. Click Here To Register...]

Notes For Rev3 (and above)

You'll need to create a folder in the compiled folder where your .exe comes out, for instance if it comes out in "...\debug\" you need to make a folder called "...\debug\database".

The database folder should contain a folder called "Items" produced with my "itemtype dat dumper" and a "cq_npc" folder produced by my "cq_database dumper".

It should also contain a empty folder called "Inventory" (as characters save this will be filled).

It should also contain a folder called "Misc" which has the files; "Archer.ini", "Trojan.ini", "Taoist.ini", and "Warrior.ini" in it, this can be obtained from downloading rev2, or rev1 Thanks to CoEMU for this, dunno where they got it from, got it from their oooolllld source from ages ago :)

Lastly, there should be a folder called "Accounts" which can be obtained from rev1, or rev2. The full layout of the file can be obtained by logging in once, and then out (letting the server save the file).

You need to create accounts manually at this time :P


*Edit by Kinshi*
Database: [Only registered and activated users can see links. Click Here To Register...]
01/19/2009 22:51 InfamousNoone#2
Quote:
Originally Posted by Djago160 View Post
Unexpected...
It's from the crypts of those lonely days when I have a blackout, my internet is being gay, or reflecting on my old HCO source :)

Only difference is, I included what I learned of the last year in this source; the beauty of interfaces and multiple interface inheritance in C#. Aside from pointers that it, the beauty of pointer logic > multiple inheritance (...of interfaces of course).
01/20/2009 11:24 Beta Limit#3
Just have one question and u can call me an idiot all you like i dont mind - How do i make a new account?
01/20/2009 12:07 _Emme_#4
Quote:
Originally Posted by Beta Limit View Post
Just have one question and u can call me an idiot all you like i dont mind - How do i make a new account?
Should be fairly easy to find..
Anyways, go here:
ConquerServer_Basic\bin\Debug\Database\Accounts\
You will see the account "test", just copy that file and make a new one, change the name test to BetaLimit for example, and change the information inside.
01/20/2009 21:50 InfamousNoone#5
Seeing as I have about 6 days off I might end up working on it again and releasing a version with more shit done.

As for creating characters, do what Emme said; but make sure you add one to the UID (make sure two players UIDs are never the same).
01/20/2009 22:01 Beta Limit#6
Quote:
Originally Posted by InfamousNoone View Post
Seeing as I have about 6 days off I might end up working on it again and releasing a version with more shit done.

As for creating characters, do what Emme said; but make sure you add one to the UID (make sure two players UIDs are never the same).
Nice one Hybrid look forward to it. So far i have added a few things to the console Display and thats about it.
01/20/2009 23:16 InfamousNoone#7
Here's walking/running:

Code:
// \Networking\Packets\Ground Movement Packet.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConquerServer_Basic
{
    /// <summary>
    /// You know, walking and running (can be used for monster-movement aswell).
    /// </summary>
    public class GroundMovementPacket : IClassPacket
    {
        private byte[] Packet;

        public GroundMovementPacket(bool CreateInstance)
        {
            if (CreateInstance)
            {
                Packet = new byte[12];
                PacketBuilder.WriteUInt32(12, Packet, 0);
                PacketBuilder.WriteUInt32(1005, Packet, 2);
            }
        }
        public byte[] Serialize()
        {
            return Packet; 
        }
        public void Deserialize(byte[] Bytes)
        {
            Packet = Bytes;
        }

        public uint UID
        {
            get { return BitConverter.ToUInt32(Packet, 4); }
            set { PacketBuilder.WriteUInt32(value, Packet, 4); }
        }
        public ConquerAngle Direction
        {
            get { return (ConquerAngle)(Packet[8] % 8); }
            set { Packet[5] = (byte)value; }
        }
        public bool IsRunning
        {
            get { return (Packet[9] == 1); }
            set { Packet[9] = (byte)(value ? 1 : 0); }
        }
    }
}
Code:
// \Networking\Packet Processor.cs -- Edit
        public static void PlayerGroundMovment(GameClient Client, GroundMovementPacket Packet)
        {
            Client.SendScreen(Packet, true);
            Client.Entity.Move(Packet.Direction);
            Client.Screen.Reload(false, null);
        }

// goes in the switch for PacketProcessor.Process()
                case 1005:
                    {
                        GroundMovementPacket cPacket = new GroundMovementPacket(false);
                        cPacket.Deserialize(Packet);
                        PlayerGroundMovment(Client, cPacket);
                        break;
                    }
Your job! Implementing the Move function to the class IEntity.
Hint:
It modifies the properties Facing (with the parameter received for the Direction), X, and Y, take a look in other sources and see how they do it if you can't figure it out.
01/21/2009 01:13 InfamousNoone#8
Quote:
Originally Posted by unknownone View Post
Sparkie suggests revision control. I could contribute to this in good ways :)
Feel free to anyone to post code relating to this source and help others; but I suggest when releasing anything code related, don't give it all away, let them work out some of it from themselves.

If I release more, I'll mark revisions on it (the rar file).
01/21/2009 12:29 _Emme_#9
Mmk.
First, define the chat packet which is 1004.
Search for:
Jump = 133,
Under, add:
Chat = 1004,


Good.


Now go to the packet processor, and add a new case for chat. This is how mine looks like with a little help from Haydz



Quote:
case DataPacket.Chat:
{
MessagePacket Msg = new MessagePacket(Packet);
Command.Commands(Msg.Message, Client);
break;
}
Then go into MessagePackets.cs and add this by the message packets:
Quote:
public MessagePacket(byte[] Buffer)
{
Deserialize(Buffer);
}

Now, create a new .cs file called Command. In there, create a void/bool ( I prefer bool ) and do like this:

Quote:
public bool Commands(string Msg,GameClient Client)
{
}
Now you will have to do a string[] to split up, well do that by urself , im not releasing everything. Heres an example of a command:

Quote:
if (Cmd[0] == "/dc")
Client.Socket.Disconnect();
Enjoy, and press thanks!
01/21/2009 16:12 InfamousNoone#10
Emme, chatting is not a sub-type of packet (you make it seem as if it's a sub-type of the DataPacket) therefore you should just have
case 1004:
01/21/2009 17:58 InfamousNoone#11
[Only registered and activated users can see links. Click Here To Register...]
01/21/2009 20:46 HellCo#12
Quote:
Originally Posted by InfamousNoone View Post
[Only registered and activated users can see links. Click Here To Register...]

hey bro, was just wondering with config.ini is ? :P i aint changed any info and it says Database loader 0.0
01/21/2009 22:54 punkmak2#13
Thought i'd help add to the server the basic Chat handling code.
Atm it only supports Chat and Whisper.
Correct me if I'm wrong in anyway. Because that's why were here to LEARN and contribute where we can :).

*Code not yet tested*

PacketProcessor.cs
Process add:
Code:
case 1004:
                    {
                        MessagePacket cPacket = new MessagePacket();
                        cPacket.Deserialize(Packet);
                        PlayerChat(Client, cPacket);
                        break;
                    }

PacketProcessor.cs
add:
Code:
public static void PlayerChat(GameClient Client, MessagePacket Packet)
        {
            switch (Packet.ChatType)
            {
                case 2000: //Talk
                    {
                        foreach (GameClient pClient in Kernel.Clients)
                        {
                            if (pClient.Identifier != Client.Identifier)
                            {
                                if (pClient.Entity.MapID == Client.Entity.MapID)
                                {
                                    if (Kernel.GetDistance(pClient.Entity.X, pClient.Entity.Y, Client.Entity.X, Client.Entity.Y) <= 16)
                                    {
                                        pClient.Send(Packet.Serialize());
                                    }
                                }
                            }
                        }
                        break;
                    }
                case 2001: //Whisper
                    {
                        foreach (GameClient pClient in Kernel.Clients)
                        {
                            if (pClient.Identifier != Client.Identifier)
                            {
                                if (pClient.Entity.Name == Packet._To)
                                {
                                    pClient.Send(Packet.Serialize());
                                }
                            }
                        }
                        break;
                    }
                default: break;
            }
        }
                    }
Message Packet.cs
MessagePacket add:
Code:
public MessagePacket()
        {
        }
01/21/2009 23:24 InfamousNoone#14
Client.SendScreen(packet, false);

instead of looping through all them clients...
01/21/2009 23:48 Beta Limit#15
Hmm wont let me login two accounts from the same computer

EDIT: Can log two in but if they are in within 20 spaces the client just closes