Online Multiplayer Development

Feel like posting Off Topic? Do it here.

Moderator: MaxCoderz Staff

User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Online Multiplayer Development

Post by thegamefreak0134 »

In order to further my programming experience, I want to create an online multiplayer game, similar to a MMORPG. Although I doubt it will go anywhere (this is for practice with server side stuff and for the "so I can say I did this" factor) I would be happy to have two people be able to log on and walk around in the same 2D map.

I am completely new to the subject, and have looked at some various tutorials that completely overwhelm with info. I need stuff in smaller packets of information.

I have a server which I have full ftp access to (and a remote friend/programmer with fill access, its in his house) that I plan to use for testing purposes. With that in mind, what can you tell me about how to begin coding the server and client side software? I idealy want this to be something that will play in a browser, but if I need to make something standalone to begin with (So I can test locally) I can. I really just want to get the concepts down do I can design a reasonable engine.

If someone could either point out or link to some resources concerning developing online multiplayer of any kind (Preferably using C++ where possible) it would be extremely helpful. I know I'm taking on a huge task here, but I need the experience in this kind of thing.

Thanks for any info you have. Please do not discourage. If you tell me I can't do this, you're right. I don't intend to. I just want to make the engine, really. I'll let the rest of my programming team handle finishing the rest. (^_^)

-thegamefreak
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

well, what I would do is having a file on the server with the number of players and that many structs containing (atleast) their position, have every client add 1 to the number of players when logging in, and adding their struct to the end of the file. To display all those players, just loop 'number_of_players' times through the coordinates list while drawing them at that place. If you like larger maps (when there are different area's) you could have a "current_area" field and while drawing ignore all those not in your area.

There is probebly more to it and I bet I made a mistake in this short text (atleast 1) but it might get you thinking in the *right* direction.. It's not that I ever made an MMORPG, I just wrote what sounded logical to me...
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Online Multiplayer Development

Post by benryves »

thegamefreak0134 wrote:In order to further my programming experience, I want to create an online multiplayer game, similar to a MMORPG.
And the warning bells go off. :) Why is it that everybody wants to write a MMORPG, of all games?

Make up your mind as to what you want to do. :) A game running in a browser uses a rather different set of techniques to a game running as a standalone application. I'd recommend the latter, for starters.

I'd recommend looking into the System.Net.Sockets namespace for your basic communications. If you look in MSDN, you will be able to find all sorts of sample programs that set up clients and servers that swap data between eachother. Socket Code Examples.
User avatar
hop
Extreme Poster
Posts: 378
Joined: Sat 09 Dec, 2006 3:42 pm

Post by hop »

2 options:
- real time
- turn based

Real time:
- Java applet.

Turn based:
- AJAX ("fast", pretty, might need some web/web2 experience) or Javascript talking to the server through an invisible iframe (slow, ugly, easy).

In both cases you put a webservice or script on the server side. Java or .NET webservice needs a nice server set up, php has less features but needs less hardwares and configurations. PHP is cruise control for cool, but not for job or safe and secure server.

Also, simple/example client-server system diagram (web1.0 client side. everything server side applies to all client-server systems):
http://62.195.169.118/linked%20forum%20 ... agram1.png
User avatar
anykey
Extreme Poster
Posts: 420
Joined: Mon 31 Jan, 2005 3:36 am
Location: In the matrix
Contact:

Post by anykey »

Standalone applications make things easier...no dealing with the usual pains of web development!
I know absolutely NOTHING about server-side, and only a little bit about client-side (mainly http-related stuff).
If this works out for you, I might adapt some of the techniques for my own stuff.
I think, therefore iMac
Image
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

And the warning bells go off. Smile Why is it that everybody wants to write a MMORPG, of all games?
Because I want to be well-experienced in all fields. I figured this type of layout would simply be the easiest to play with, as you would simply log in, have your friend with whom you are testing log in, and there you both are. And if someone else decides to join (invited or un-invited) there they are too.

Anywho, I know server side stuff is going to be a pain in the banana, so I want to get it over with already.

I will look into the presented material. I'm assuming that your server side application would basically accept a list of commands, and then run some stuff ever so often to keep the game maintained. Something to the effect of, you send a command with login info, and the server checks its records and then logs you into the world, following with a reply sent to the client signaling the start of the game engine with the specified player data and map positions and such.

Then I assume you would keep everything going by (1) Sending a request for other-player data from the server, (2) Procesing this data and displaying characters on the world around you, (3) Checking player movement in the client and sending that movement data to the server, which has the side effect of updating you on everyone else's client side when they request. You would handle items and stats in a similar fashion, although you would request for "item at location x" rather than "use this item" so you couldn't easily hoodwink the server. Finally, the server would take care of things like random monsters, NPC data, and checking to see if players have been idle for a long time (no requests or update for a set time, like 15 seconds, which should be well enough time to detect a dropout) and things of that nature.

All of this would have to be packaged in a nice command architecture. You would send a command (in the form of packets, I assume?) to the server with 1 byte representing the command, 2 bytes representing the length of the data, and the rest being the data. (Or perhaps always send a set ammount of data for commands, and save some bandwidth.) The server always sends a reply, which consists of a "command" byte indicating the type of reply, a length byte, since this data can vary, and the actual data for the game. If for some reason the client did not recieve confirmation of a command, or did not recieve requested data, the request for data would simply be requested again. (A timestamp of sorts could be used to let the server know if the request had been recieved already, as a signal to simply send the reply again without actually changing anything.)

Do I have the basic idea down? This is all just brainstorming as I type, I've been thinking about this kind of engine for a while now. I would have to work a bit to keep my database working nicely, but it should be at least possible to do something. Heck, if I could get a chat system up going this way I would be happy...

-gamefreak
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
Liazon
Calc Guru
Posts: 962
Joined: Thu 27 Oct, 2005 8:28 pm

Re: Online Multiplayer Development

Post by Liazon »

benryves wrote:Why is it that everybody wants to write a MMORPG, of all games?
And of course you could make a heck of a lot of money if you get a really good one going ^^
Image Image Image
User avatar
hop
Extreme Poster
Posts: 378
Joined: Sat 09 Dec, 2006 3:42 pm

Post by hop »

Do I have the basic idea down?
What you said about the connection is true enough, for an application.

2 corrections toe the rest:
1) Don't focus the coding/engine on the player character. The PC is simply yet-another-creature in the game world and the only thing that makes it different for the code is that there's commands from an external source linked to it instead of AI events. All you have to do is leave the PC's out of the AI control list and connect input commands to the creature ID of the player's character.
2) No coding is a pain if you know what you're working on. Plan, design, manage.

The connection is however completely different in x/html based client-server systems, because then you don't have socket control and all you can do is send http requests to the server or xml through ajax. You can still sort of send "commands" but technically they're actually "requests" for actions. Especially since it's an MMORPG so you double-check all the "commands" to see if they're really correct and allowed.

http://server.org/?id=4&action=move&x=1&y=0

You can see how this requires an immensly different security management from requests send over a tcp or udp protocol you can make as obscure as you want and that can only be red by packet sniffers and such. And even with a more obscure connection you want to double-check every single player input the server recieves.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

thegamefreak0134 wrote:
And the warning bells go off. Smile Why is it that everybody wants to write a MMORPG, of all games?
Because I want to be well-experienced in all fields. I figured this type of layout would simply be the easiest to play with, as you would simply log in, have your friend with whom you are testing log in, and there you both are.
You could start by writing an instant messenger program. :) That has all the usual client/server mess to work out, after all.
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

uuuh. i would like to write a instant messenger :D maybe an instant z80 coder :P extreme programming ftw!
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

kv83 wrote:uuuh. i would like to write a instant messenger :D maybe an instant z80 coder :P extreme programming ftw!
Are we on the same page here? I think not...
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

You could start by writing an instant messenger program. Smile That has all the usual client/server mess to work out, after all.
Hmm.. Not a bad thought. Actually, at this point I'd be happy to get the thing to log in, or create accounts. I can build anything from it once I have the basic idea down...

OK. Actual intent and purpose (and any form of security) aside, I need to get something running on a server, and I need to write a client program that can somehow or another communicate with this server-side program. I intend to do both of these things in C, because I am just generally more experienced in it than anything else.

What I need are the basic steps for doing so. I plan to be running some form of a linux server (can someone point out the best linux version I should download to do this?) so all of my networking methods and things need to reflect that. If someone can help me get to a system of sending and recieving either packets or "requests" as you put it back and forth, and listening to and comprehending incoming requests, then I have something I can go with.

I have no real issues with the language concepts of C (or most other things for that matter) but I have never dealved into the networking side of it at all. I am going to set up a dummy server to test things and stuff out with.

The articles posted looked really helpful as a reference, but I need something in more of a tutorial form. Perhaps I should google it (which I will do of course) but if you know of something tutorial wise that can get me up and running quickly, please let me know. Thanks again!

-thegamefreak
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

thegamefreak0134 wrote:The articles posted looked really helpful as a reference, but I need something in more of a tutorial form.
Assuming you're referring to the MSDN docs I posted, those are effectively tutorials in the form of heavily-documented source code for setting up socket communications. However, they are .NET-specific (which rules out C - but not Linux, as you can run .NET apps under Linux). I can't help you on the C front, sorry.
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

No prob. I have more info though.

The server I know is running some form of linux, and is using apache as its webserver. Now ideally, my RPG server would run alongside apache, correct?

I also assume that since you use a certain port for the web (HTML) that I would need to specify a specific port for my server, and have the client access the server through that port? (Something to that effect anyway)

If not (if you have to install through apache) I may have issues... This is going to be some thick reading for a while. (Sigh)... coding is so hard, yet so fun, but still, (sigh)...

-thegamefreak
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

thegamefreak0134 wrote:I also assume that since you use a certain port for the web (HTML) that I would need to specify a specific port for my server, and have the client access the server through that port? (Something to that effect anyway)
HTML is a markup language used to describe the layout of web pages. The protocol used to transfer them is HTTP, which (as you mentioned) typically uses port 80. Here's a nice list. You'd write your server to listen to connections on a specific port number, and would have nothing to do with Apache.

Windows has a command-line utility, telnet.exe, (as well as a graphical client, hypertrm.exe) that can be used to connect to servers and communicate with them on a low level. Open a command window, and type in "telnet discworld.imaginary.com" and you'll have access to a nice MUD game. :) Alternatively, type in "telnet apache.org 80" and you can talk directly to an Apache server (type in junk, press return and you'll get an error page in HTML).
Post Reply