Register for your free account! | Forgot your password?

You last visited: Today at 01:43

  • Please register to post and access all features, it's quick, easy and FREE!


Conquer private server from scratch

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 323
Conquer private server from scratch

well maybe i'm not the best to write this kind of tutorials but ill proceed because of the lack of tutorials on this subject, we will explain how to get everything up from scratch and not how to setup a server
for sake of simplifying we will split the server to the following main parts
  • Sockets Connection
  • Database Connection
  • Cryptology
  • Packets handling
  • Miscellaneous
conquer server is simply an application that handle connections from clients which sends and receive data, which is why you need the internet connection with other clients also the cryptology part as the packets are always encrypted and then you should handle the data with your server logic to figure out what the client want to do and reply with appropriate respond, and you would always need to verify and store information which why we use the database
what knowledge do you need
  • First of all is programming, I'm not asking you to be expert but atleast being able to design such a big project and be able to fix errors, but trust me the more you know the better you will do, every technique of the language and every options becomes handy at some point
  • Second is Reverse engineering knowledge to be able to get information from the client such as crypto and other useful information but that is not particularly necessary as others have done that job and released it to public (however there is still a missing part which to why we are using loaders, it has not been released by RE experts to limit the number of proxy bots out there that can use clientless feature)
There is already a topics out there on the same subjects which had been released by great members that you must first read before proceeding
[Intermediate] - C# AsyncSockets(Server)
[Intermediate]Server basics
[Guide/FAQ] Lets make a custom source!
Sockets Connection : the following links will ease your life and will save your time searching , if you are familiar with C# sockets you can simply quit this part as all of the C# socket classes looks the same to me (with slightly difference) but i would still recommend you visiting those links
video links:
almost an hr explaining everything in details
a video serise with examples
text links:


msdn links:
Asynchronous Server Socket Example
Using an Asynchronous Client Socket

typically we are using a listener Socket instance after using System.Net System.Net.Sockets, then start defining it's properties
Code:
            _SOC = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _SOC.Bind(new IPEndPoint(IPAddress.Any, Port));
            _SOC.Listen(_backlog);
then by now you may call the begin accept
            _SOC.BeginAccept(new AsyncCallback(AcceptConnectionsCallBack), null);
begin accept is having an internal loop which keeps trying to accept new connections, that's why we are passing a void method with IAsyncResult parameter to be called whenever it receives new connection
now we need one more worker socket to keep receiving data while freeing the listener socket to accept more connections by using the EndAccept method with the IAsyncResult parameter you received for passing the connection to our worker socket and then you can begin recieving once more

Code:
CS.SOC = _SOC.EndAccept(IR);
            CS.Buffer = new byte[Constants.MAXBUFFERSIZE];
            CS.SOC.BeginReceive(CS.Buffer, 0, Constants.MAXBUFFERSIZE, SocketFlags.None, new AsyncCallback(RecieveCallBack), null);
            _SOC.BeginAccept(new AsyncCallback(AcceptConnectionsCallBack), null);
while the RecieveCallBack is a method to invoke whenever it recieves data which is the same idea, looping trying to recieve data and invoking this void method with IAsyncResult parameter
you may always use it's second overload with passing a reference of integer variable to get the socketerror to verify if it was successful
Code:
int size = SOC.EndReceive(IR, out error);
that is briefly a simple example of async socket, but the links i provide you is way more correct and briefly explaining everything

what's left about sockets is having a wrapper class which is used to keep both the socket(connection) and a gameserver/authserver object together so you can figure out whom the data was sent for

at the end you would want to invoke custom methods at accept connection , recv. and end connection for both main sockets you have (game server / auth server) each on it's own port
Database Connection :
most of private servers are using custom classes to access the database and CRUD (Change,Read, Update, Delete) techniques
over here you would find 40 tutorial about mysql and c#
but for a better database connection and more reliable one you may use NHibernate, everyone is recommending it however it's not used frequently as when it comes to mapping inherited/composted classes as it becomes lil more complicated (maybe not lil but yeah it depends on how familiar are you with the xml) where as of what i know generator won't do the trick, enough about nhibernate cuz i personally duno much about it and lets move to
https://docs.google.com/document/d/1...UCU/edit?pli=1
https://docs.google.com/document/d/1...qmc/edit?pli=1
https://docs.google.com/document/d/1...Afc/edit?pli=1

Cryptology : TQ cryptology is already public (most of it required to go), Reverse Engineering experts could always find there way at the client and find the signature of the encrypting/decrypting, you may even use client methods with a copy past at c++ inline asm with slightly editing and you will end up with perfectly valid method
other than that there is 2 more ways, first is leeching it from some trinity edition with openssl or second to use CptSky dll which is what i recommend
if you would love to dig deeper i would recommend you the following
lena tutorials
you would maybe quit 2 times, first at the pe header and import tables at tutorial 3, as it's really a big load of information to digest at once and it's kinda "dry" at this subject, that's where you may need to do more searching on google (there is lots of tutorials on this subject) and for saving your time
here is a really nice tiny book from ARTeam that would really help you out at the pe header and structure
and the second quit is at unpacking/unprotecting as it requires a perfect understanding for system stack to be able to do your very first manual unpacking
here is what really helped me out (it's for x64 but it's the same for x32)
for more about RE you may also have a look at
there is tons of tutorials out there, you would need tons of information and even more practice, i would suggest downloading a sit rip of tuts4you (it's provided you tons of research papers and tutorials, also load of keygenme/crackme which some of them are real good
i won't lie but it takes months to be able to be able to dig in conquer executable, that's why i think it's okay to skip this part if you are not really interested
back on the track

Packets handling :
packet handling requires packet sniffing to figure out what the server actually does with client packets on original tq servers to be able to copy the same logic
lets say you would want to implement the mentor reward system
you use some packet sniffer and found that client send a packet of type say 1234, you would first try to do something like
Code:
switch(packet_type)
{
       case 1234:
            {
                break;
            }
}
then you found that server replies with some packet contains some values
go to the game and find what this values represent, maybe at offset 6 you get the exp, offset 10 you get the +1 stones, ...
so you would make a full structure, create class and then compose that packet the client needs with information from the database
i think you got the idea
Miscellaneous :
  • about the server design, you would need to have something like player object with all members you need (read and write to the database and modified by the client actions) a player having money, you get the amount on login from the database and the client may edit it by buying some item, then you save it back to the database and to have such organized project you would want to compose/inherit any entity have a position of map,x,y so for sake of organization and being able to inherit other classes from it (such as players , monsters and npcs) a poor design would be having a ushort of x,y,map for players and another one for monsters and another one for npcs, instead we could simply inherit them all with those members of lets call it coords class ,i personally having an entity and advanced entity, where entity is child of coords and having basic entity (most common between everything ex. mesh), then advanced entity for monsters and players where it's child of entity where it contains maybe hitpoints , mana , attack and defence ... and so on ,with the following convention, the most common then less common and so on, so you would have to only inherit just one simple class to get all properties you need and having your very own properties at your class without all common properties
  • at some point i was also confused to use an instance of some class (kinda composition) or inheriting and i've found is a / has a convention is doing the trick
    however it might be confusing
    player is not a coords, player has a coords , where it's better here to use inheritance than composition to access it directly player.x not player.coords.x
    but i've made my very own convention about this subject, if you need more than one property use instance, if you only need one use inheritance
  • also an example of a bad design could be trinity interfaces which you have to write the methods at every single class that is inherited from this interface, instead i've had a middle classes inheriting from interfaces the common methods and the real classes are inheriting this middle class so you avoid rewriting methods all over again and still be able to use them all as interface object
  • another example of bad design is having maybe 300 property/variable at the gameserver class instead of having ONE property ex. player inherited from more classes to make everything organized
you may agree or disagree about the design but most important is to have a design that doesn't eat memory up with nice ping and smooth algorithms
at the end i wish that gave you more information about what a server is and how to create one, please leave your comments if you want me to correct/edit/add something also any questions is welcomed



go for it is offline  
Thanks
3 Users
Old   #2
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,591
Received Thanks: 824
Why do you capitalize the whole variable name?

And tbh. this is too messy.


Super Aids is offline  
Old   #3
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 323
Quote:
Originally Posted by Super Aids View Post
Why do you capitalize the whole variable name?

And tbh. this is too messy.
yeah im not so in naming convention, and could you be more specific about what you mean with messy ?
go for it is offline  
Old   #4
 
elite*gold: 0
Join Date: Dec 2012
Posts: 606
Received Thanks: 66
C# is a wonderful language, and thank you very much for your time and this thread is one of the best i seen all this time, +1 for that.

the other thing i would like to see in the future is we start making source with other language.

conquer is rly good way of teaching basic programming, helping to understand how database work and even more,

so i was hoping in the future you start making a low version project but with other language,

i will say

Python,
c
VB

Python is such a wonderful language and easy to learn,same with vb, vb is easier then c#, idk about c,but my point is i think the community of conquer is not growing that much because people dot wane learn c# coz its not good for starting i guess?

for me c# was not a good language for starting because it was not that easy, but with python i am hoping to create a server fully in python in a year or so, just to test my skills and i know its not good idea making it on fully python.

So if you are going to you know make guides or idk start building co on a easy language for the people who have 0% knowledge about coding then i will offer you my help as much as i can.

but ones again than you soo much for this thread,
for me from this thread the useful part was Sockets Connection coz i never understand how they work.


LordGragen. is offline  
Old   #5
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,591
Received Thanks: 824
Quote:
Originally Posted by go for it View Post
yeah im not so in naming convention, and could you be more specific about what you mean with messy ?
That you're not really explaining how to write a server from scratch, but just the general knowledge you need, but not really how the whole server should be designed in term of project design etc.
Super Aids is offline  
Old   #6
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 323
Quote:
Originally Posted by Super Aids View Post
That you're not really explaining how to write a server from scratch, but just the general knowledge you need, but not really how the whole server should be designed in term of project design etc.
well is there someone else before had mentioned how to code a server in form of codes with snippets and code blocks ?
i was to continue explaining some ****** trinity edit since the socket until the handling but im not having enough time for now so i've just released this part and delaying the rest for next weekend, plus im currently stucked at the general data packet that is being sent at the login which to why i kinda didn't release everything i wrote
go for it is offline  
Old   #7
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,591
Received Thanks: 824
Game logic.
Super Aids is offline  
Old   #8
 
elite*gold: 0
Join Date: Mar 2005
Posts: 1,306
Received Thanks: 1,360
Conquer is a really BAD way to learn programming, there code structuring and convention are really messy, thus if your learning your learning the messy way. Like i say to all who want to learn, start with something simple. i.e Calculator app, second maybe a basic tcp chat system. 3rd Play with interfaces and inheritence. 3th, you can now start thinking about a basic server.
Ultimation is offline  
Old   #9
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,591
Received Thanks: 824
Quote:
Originally Posted by Ultimation View Post
Conquer is a really BAD way to learn programming, there code structuring and convention are really messy, thus if your learning your learning the messy way. Like i say to all who want to learn, start with something simple. i.e Calculator app, second maybe a basic tcp chat system. 3rd Play with interfaces and inheritence. 3th, you can now start thinking about a basic server.
This ^

To be honest the way I learned how to program a server for Conquer was through game programming by writing my own online games.
Super Aids is offline  
Old   #10
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 323
Quote:
Originally Posted by Super Aids View Post
This ^

To be honest the way I learned how to program a server for Conquer was through game programming by writing my own online games.

Quote:
Originally Posted by Ultimation View Post
Conquer is a really BAD way to learn programming, there code structuring and convention are really messy, thus if your learning your learning the messy way. Like i say to all who want to learn, start with something simple. i.e Calculator app, second maybe a basic tcp chat system. 3rd Play with interfaces and inheritence. 3th, you can now start thinking about a basic server.
well i kinda disagree about being a good or bad way for learning programming as programming is programming and it doesn't matter where you start as long as you know what it takes to write a source and if what you know is enough or not

maybe it won't be effective or well designed and organized, maybe some stuff will be hard coded but at the end who is learning programming throw conquer for the right reason will last and who learning it for wrong reason won't

but yes you got a point, the more i learn at programming the more i figure out how stupid i was
go for it is offline  
Old   #11
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,591
Received Thanks: 824
It does matter. TQ's logic is ****** up.


Super Aids is offline  
Reply



« Previous Thread | Next Thread »

Similar Threads
[help] Private server from scratch
Hello guys ... first, sorry for annoying .. :), am the eldest and my little brother need me to make a server to play with his friends and be...
1 Replies - CO2 PServer - Discussions / Questions
Conquer Programmer Need Help for Conquer Private Server Bot Check
Could You please Help me to block this anti bot check by General Conquer onlinePrivate Server its really annoy's me when this system check appear's...
22 Replies - CO2 Programming
What is the average time to Build a server from scratch & if with some reference
I want to know what is the average time to create a server from scratch and what it would be if somethings from scratch and some others using any...
13 Replies - CO2 PServer - Discussions / Questions
[Building] Server From Scratch...
First i know well about c# not expert but i can understand things out Second what i am intended to do using albetros source but building it block...
21 Replies - CO2 PServer - Discussions / Questions
Need help starting conquer form scratch
hey i dident play co in a really long time and i dont really got any chars im downloading client while i make this topic. whats a good way to get...
1 Replies - CO2 Main - Discussions / Questions



All times are GMT +2. The time now is 01:43.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.