[REQUEST] Scratch Emu

06/22/2011 19:46 andreimusc#1
HI, I would like to introduce myself: my name is Andrew i am 16 years old from Romania, and i think that is all you have to know about me!

Now, I would like to ask someone, who knows a bit of a programming language like C# or C++(because in this topic i think it is not VB case) to make a guide on how to make a sro EMULATOR from scratch!
PLEASE DONT DISAGREE ME IN THE VERY BEGINNING!
I just want something that covers the basics of the programming language in the EMU that is made...
I want something not exactly very simple(because i am not an idiot i guess , duuh -.-), but eventually easy to understand!

And please, I want someone that is in grade to answer me, and please don't troll, this is the last thing i want to T.T . I just want some simple answers like:
YES, it is [Only registered and activated users can see links. Click Here To Register...] bla bla blah
NO, it isn't
or.. No, but i will look up to find a guide, or to make one!

PEACE! XOXO
06/22/2011 20:34 bootdisk#2
Echo server in any language is how you start one from scratch.
Just send the first packet as 0x5000 when you got a connection with the flag 1 and that's it.

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

About SRO server development there is a hugggeeeee thread about it [Only registered and activated users can see links. Click Here To Register...]. I think pushedx, lyzerk and Shadowz75 are the most valuable post in there... there was a time in which it was all active by replies from everyone.
06/22/2011 20:43 andreimusc#3
Thank you Bootdisk, this is a very good suggestion, and I consider it as a short(not small) walkthrough ^.^! I please the admins not to close it, because I want to hear some more suggestions
06/23/2011 00:21 kevin_owner#4
I agree with bootdisk and a little example of this echo server which i created a few days ago would look like this in for example C#:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.IO;

namespace Silkroad_Login_Server_Example
{
	class Program
	{
		static void Main(string[] args)
		{
			TcpListener ServerSocket = new TcpListener(15779);
			ServerSocket.Start();
			Console.WriteLine("Server Started");

			Socket Client = ServerSocket.AcceptSocket();
			Console.WriteLine("Client Connected");

			// Assambling the first packet. (Much easier if you use the packet writer
			// from csremu or srevolution. I also ripped this from srevolution.
			MemoryStream MS = new MemoryStream();
			BinaryWriter BW = new BinaryWriter(MS);
			BW.Write((short)1);
			BW.Write((short)0x5000);
			BW.Write((short)0);
			BW.Write((byte)1);
			BW.Close();

			// Send the packet to the client
			Client.Send(MS.GetBuffer(), 7, SocketFlags.None);

			// This loop is the main packet loop this one can process all the pakcets from the client
			while (true)
			{
				try
				{
					// Buffer to store the received packet
					byte[] RecvBuf = new byte[4096];

					// This function is blocking so it only continues once you receive a packet.
					int RecvBytes = Client.Receive(RecvBuf);

					// This displays the packet on the console.
					for (int i = 0; i < RecvBytes; i++)
					{
						Console.Write("{0:X2} ",RecvBuf[i]);
					}
					Console.Write("\n");
				}
				// Little exception catcher since it throws and exception if the connection got closed
				catch (SocketException SE)
				{
					Console.WriteLine(SE.Message);
					break;
				}
			}
			Console.ReadKey();
		}
	}
}
This code isn't very well designed but I wanted to keep it as short as possible. As you can see I'm using the binairywriter to assemble the packet.
You can see it as an array which you send over the network.
Building this packet in C++ could look like this:
Code:
char Buffer[4096];
*(short*)&Buffer[0] = 1;
*(short*)&Buffer[2] = 0x5000;
*(short*)&Buffer[4] = 0;
*(char*)&Buffer[5] = 1;
Probably the best way to start is learning a programming language till you're comfortable with it and then you can start using sockets and threaded things.

But to get an idea of what you need to do with an emulator is just to simulate a packet but there is a lot of logic behind it so it is very difficult to create a nice and stable one.

And I can give you one good advice. Don't start too soon with adding features. Sure it's nice too see things working but if you take things slow so your emulator will also be more stable. and creating a solid base would also be a good advice. like the client handling cause you probably want a few players online at the same emulator so you need up to date info trough your whole emulator.

How is started with this stuff was a lot of browsing trough other people's sources. sourceforge or assembla or full of emulator projects for mmo's.

I hope this helps you a bit
06/23/2011 01:09 andreimusc#5
I thank you all for this responses, and i also appreciate the fastness that you respond^^!
Ow and Kevin_owner, may the God be with you, that code helped me very much!
I also wait for another responds, Peace!
06/23/2011 21:03 evolution007#6
i want to ask too. is there any sro emulator written in c++ open-source?
06/23/2011 21:10 vorosmihaly#7
Quote:
Originally Posted by evolution007 View Post
i want to ask too. is there any sro emulator written in c++ open-source?
sremu & sremu2(I don't know how it's going,last time there were only just config loading and such..^^) as far as I know..

Ontopic:
I think you should really check out pushedx's c# silkroadsecurity for ideas for packet handling and security,etc,and you could also use it as a "starting point" with some modifications ..^^