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

03/29/2012 23:46 Kiyono#331
Quote:
Originally Posted by PKDemon View Post
i know this is an old post but can anyone re-upload as meagupload links dont work anymore ?
[Only registered and activated users can see links. Click Here To Register...]
09/11/2012 02:51 jitus2#332
Hi,
Today, this source it is still good to learn?
by what I learned C#, and I want to know if I can use to create my server.
and also, someone could guide,i do not know how to connect the database at the source
and what client take??
Thank a lot all, and sorry for my bad english.
09/11/2012 07:11 .Ryu#333
Quote:
Originally Posted by jitus2 View Post
Hi,
Today, this source it is still good to learn?
by what I learned C#, and I want to know if I can use to create my server.
and also, someone could guide,i do not know how to connect the database at the source
and what client take??
Thank a lot all, and sorry for my bad english.
The source is targeted a 5017 and setting it up is easy you just open Program.cs and scroll down a little bit and you will see a IP there change it to yours build then debug and your good to go
09/11/2012 11:39 manager2#334
Quote:
Originally Posted by .Ryu View Post
The source is targeted a 5017 and setting it up is easy you just open Program.cs and scroll down a little bit and you will see a IP there change it to yours build then debug and your good to go
Not the most informative for a newbie.

Download the source, and a Conquer client version 5017, Extract the source into a folder and then open up the project is an IDE (Such as Visual studio or C# Express) double click on Program.cs in soultion explorer (Tools->Soultion Explorer) If you can't see it and then look through the code for some sort of IP, I'll be around somewhere called "void Authserver_receive" or something similar.

Once changed, Up the top of the IDE around the top-center there should be a green arrow thing, Click that, it will build(save and compile) the edited project and then start it up in debug mode.
09/11/2012 16:47 jitus2#335
Hi,
Thank you both.
I was in the project, and I put the location of the database, now and I put the location of the: Database Loaded. For ip, I put it in program.cs, can you check if this is the correct location, because it still does not work :(


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

NOTA:
In the server.dat
I have also put the address IP hamachi.

NOTA2:
I have another problem
Now, when I try,
it makes me:

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

I need your help please :(
Thank all :)
Cordially.
09/11/2012 21:04 .Ryu#336
Quote:
Originally Posted by jitus2 View Post
Hi,
Thank you both.
Use ConquerLoader if your not already [Only registered and activated users can see links. Click Here To Register...]
09/11/2012 23:04 jitus2#337
I try with your link, it always arrives not connect :-(
Did you check if I put IP adress the right place?
Thank you!
NOTA:
it works now!!! :D
I solved the problem.
Just, here: authSocket.Port = 9958;
Replaced by 9959 (Same number as "LoaderSet" )
Thank!
I am now ready to learn :D
I took V3, is it good?
09/12/2012 13:36 ragab2#338
can any one upload source on mediafire or other links please
09/12/2012 14:03 jitus2#339
Here:
[Only registered and activated users can see links. Click Here To Register...]
say thank you to Kiyono
09/12/2012 15:38 ragab2#340
how i run this please and thanks for helping
10/06/2012 20:39 jitus2#341
Quote:
Originally Posted by punkmak2 View Post
Here we go.


Portals Implementation.

1) Create a new Class file in the folder Interfaces called "IPortals.cs"

2) Replace all the code in newly created file IPortals.cs with the code below.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConquerServer_Basic
{
    public interface IPortal
    {
        ushort CurrentMapID { get; set; }
        ushort CurrentX { get; set; }
        ushort CurrentY { get; set; }
        ushort DestinationMapID { get; set; }
        ushort DestinationX { get; set; }
        ushort DestinationY { get; set; }
    }

    public class Portal : IPortal
    {
        private ushort _CurrentMapID;
        private ushort _CurrentX;
        private ushort _CurrentY;
        private ushort _DestinationMapID;
        private ushort _DestinationX;
        private ushort _DestinationY;

        public Portal()
        {
        }

        public Portal(ushort CurrentMapID, ushort CurrentX, ushort CurrentY, ushort DestinationMapID, ushort DestinationX, ushort DestinationY)
        {
            _CurrentMapID = CurrentMapID;
            _CurrentX = CurrentX;
            _CurrentY = CurrentY;
            _DestinationMapID = DestinationMapID;
            _DestinationX = DestinationX;
            _DestinationY = DestinationY;
        }

        public ushort CurrentMapID
        {
            get
            {
                return _CurrentMapID;
            }

            set
            {
                _CurrentMapID = value;
            }
        }
        public ushort CurrentX
        {
            get
            {
                return _CurrentX;
            }

            set
            {
                _CurrentX = value;
            }
        }
        public ushort CurrentY
        {
            get
            {
                return _CurrentY;
            }

            set
            {
                _CurrentY = value;
            }
        }
        public ushort DestinationMapID
        {
            get
            {
                return _DestinationMapID;
            }

            set
            {
                _DestinationMapID = value;
            }
        }
        public ushort DestinationX
        {
            get
            {
                return _DestinationX;
            }

            set
            {
                _DestinationX = value;
            }
        }
        public ushort DestinationY
        {
            get
            {
                return _DestinationY;
            }

            set
            {
                _DestinationY = value;
            }
        }
    }
}

3) In Database/Database.cs add the following code.
Code:
public static void LoadPortals()
        {
            string[] Portals = File.ReadAllLines(DatabasePath + @"\Misc\Portals.ini");
            for (int i = 0; i < Portals.Length; i++)
            {
                string[] Portal = Portals[i].Split(' ');

                IPortal portal = new Portal();
                portal.CurrentX = Convert.ToUInt16(Portal[0]);
                portal.CurrentY = Convert.ToUInt16(Portal[1]);
                portal.CurrentMapID = Convert.ToUInt16(Portal[2]);
                portal.DestinationX = Convert.ToUInt16(Portal[3]);
                portal.DestinationY = Convert.ToUInt16(Portal[4]);
                portal.DestinationMapID = Convert.ToUInt16(Portal[5]);

                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);
                else
                    Console.WriteLine(portal.CurrentX.ToString() + " " + portal.CurrentY.ToString() + " " + portal.CurrentMapID.ToString());
            }
            Console.WriteLine("Portals Loaded");
        }
4) In Server Base Code/Kernel.cs add a new Dictionary to the Kernel class.
Code:
public static Dictionary<string, IPortal> Portals = new Dictionary<string, IPortal>();
5) In Program.cs, in the class Main() under Database.LoadDatabase(); add.
Code:
Database.LoadPortals();
6) In Networking/Packets/Data Packet.cs add a new const ushort.
Code:
Portal = 85,
7) In Networking/PacketProcessor.cs in the void Process, under the case 1010 add.
Code:
case DataPacket.Portal:
                                Portal(Client, cPacket);
                                break;
8) In Networking/PacketProcessor.cs add the following code to the PacketProcessor class.
Code:
public static void Portal(GameClient Client, DataPacket Packet)
        {
            ushort portal_X = (ushort)(Packet.dwParam & 0xFFFF);
            ushort portal_Y = (ushort)(Packet.dwParam >> 16);

            string portal_ID = portal_X.ToString() + portal_Y.ToString() + Client.Entity.MapID.ToString();

            if (Kernel.Portals.ContainsKey(portal_ID))
            {
                Console.WriteLine("Portal {0}, {1}, {2}", portal_X, portal_Y, Client.Entity.MapID);

                if (Kernel.GetDistance(portal_X, portal_Y, Client.Entity.X, Client.Entity.Y) <= 1)
                {
                    Packet.ID = DataPacket.SetLocation;
                    Packet.UID = Client.Entity.UID;
                    Packet.dwParam = Kernel.Portals[portal_ID].DestinationMapID;
                    Packet.wParam1 = Kernel.Portals[portal_ID].DestinationX;
                    Packet.wParam2 = Kernel.Portals[portal_ID].DestinationY;

                    Client.Entity.MapID = Kernel.Portals[portal_ID].DestinationMapID;
                    Client.Entity.X = Kernel.Portals[portal_ID].DestinationX;
                    Client.Entity.Y = Kernel.Portals[portal_ID].DestinationY;

                    Client.Send(Packet);

                    Client.Screen.Reload(true,
                    delegate(IBaseEntity Sender, IBaseEntity Caller)
                    {
                        if (Caller.EntityFlag == EntityFlag.Player &&
                            Sender.EntityFlag == EntityFlag.Player)
                        {
                            GameClient __Client = Caller.Owner as GameClient;
                            __Client.Send(Client.Entity.SpawnPacket);
                        }
                        return 0;
                    }
                );
                }
                else
                    Client.Socket.Disconnect(); // INVALID_PORTAL (No Such Portal)


            }
            else
            {
                Console.WriteLine("Invailed Portal {0}, {1}, {2}", portal_X, portal_Y, Client.Entity.MapID);
                Client.Socket.Disconnect(); // INVALID_PORTAL (No Such Portal)
            }
        }
9) Finally you'll need the portal database. Download the Portals.rar that I've included and place it into Database/Misc
Hi,
I have a problem, I added the following code, and finally I have two errors:
[Only registered and activated users can see links. Click Here To Register...]
And:
[Only registered and activated users can see links. Click Here To Register...]
Thank for the help :)
10/06/2012 20:47 _DreadNought_#342
Please post the screenshot error messages into English. Thanks.
10/06/2012 21:06 CptSky#343
Quote:
Originally Posted by _DreadNought_ View Post
Please post the screenshot error messages into English. Thanks.
1. The namespace «ConquerServer_Basic» already contains a definition for «Portal».
2. The name «cPacket» doesn't exist in the current context.
10/08/2012 16:59 jitus2#344
Help please...
two errors after added code portal :(
1. The namespace «ConquerServer_Basic» already contains a definition for «Portal».
2. The name «cPacket» doesn't exist in the current context.
10/08/2012 17:27 CptSky#345
Quote:
Originally Posted by jitus2 View Post
Help please...
two errors after added code portal :(
1. The namespace «ConquerServer_Basic» already contains a definition for «Portal».
2. The name «cPacket» doesn't exist in the current context.
Tu considères pas que les erreurs sont assez explicites ?

La classe « Portal » est déjà définie dans le projet (sachant qu'il n'y a qu'un seul nom d'espace). Donc, logiquement, tu as ajouté le code pour les portails, mais, tu n'as pas remplacé/enlevé l'ancien.

Le nom « cPacket » n'existe pas. Il te manque quelque chose... Cherche un peu, ça devrait pas être trop compliqué.

-----

Common, the errors aren't enough explicit ?

The class "Portal" is already defined in the project (knowing that there is only one namespace). So, logically, you added the code for the portals, but, you didn't replace/remove the old one.

The name "cPacket" doesn't exist. Something is missing. Search a bit, and you should find how to fix it... It's not complicated...