Handle players in online games.

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
xsocom
Posts: 80
Joined: Thu Sep 13, 2007 8:34 am

Handle players in online games.

Post by xsocom »

Hello, I have some questions about how to handle clients / players in an online game, Will try to tell me briefly about how I have done it right now.

What I have is an array that can store clients, when a new client connects, it adds to the arrays as usual, then when a player login it check so login is valid and binds the loginID from the userdata base to the client that has the same socket.

Then, when you want to manage clients, such as a movement.

Then when a client sends "I want to move" it check the socket which sent the package and look for it in the array and retunerar userPID, if it find that ID then the server knows that it will send to this socket, is this is a good way to handle Players? server side, or do you have any better suggestions?

Thank you very much
xsocom
Posts: 80
Joined: Thu Sep 13, 2007 8:34 am

Post by xsocom »

What I mean with this is, How can the server know what client that send the command for movement? I must get the socket for the current player sending the movement packet then get the pID from that current socket right? Or is it done in an ohter way?

Thanks
Lambda
Posts: 126
Joined: Wed Feb 27, 2008 3:00 pm
Location: Spain, Huelva
Contact:

Post by Lambda »

the best way is compare the sockets
Image
xsocom
Posts: 80
Joined: Thu Sep 13, 2007 8:34 am

Post by xsocom »

Okay perfect, that is what I do right now and hope it is a good way.

I will lay out the game here in a few days and hope someone has little time over to test it and report bugs if any found, Im going to test the server so it works as it should.

Thank you very much!
xsocom
Posts: 80
Joined: Thu Sep 13, 2007 8:34 am

Post by xsocom »

I also have another question about how the best way is to deal with "Enter World" and when other players that join the world.

Right now, my concept is like this, when a "new player" has logged in send a "list" of all the characters in the database that have the same PID as login PID, then list them on the client, then the player select one of them and then send the selected user_id to the server, then check the server for this PID match any of characters. if it does then send the info about this character and switch to the "InGame" and add it to the client InViewList, then when a new player connects and login it will be added to his InRangeList if the new current players is inrange of me. Is this a good way to deal with players in the game world itself? To avoid to update the players outside InViewListen etc, also they get deleted when they get outside of the range.

Hope you understand what I mean

Thank you!
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: Handle players in online games.

Post by rogerborg »

[Moved to Game Programming as it's not Irrlicht related]
xsocom wrote:Then when a client sends "I want to move" it check the socket which sent the package and look for it in the array and retunerar userPID, if it find that ID then the server knows that it will send to this socket, is this is a good way to handle Players?
Yes, that's fine. You have to map the network address to a player. Whether you do it with an actual map, or a list, array or whatever is entirely up to you.

Just be careful what you mean by a "socket".

TCP sockets are connection oriented, but a single UDP socket on your server will generally receive packets from all clients. In this case, you want to use the source address in the recvfrom() to identify the client. Unfortunately, source addresses can be spoofed, so it's not 100% reliable.

A decent network library like Raknet will abstract this for you. I'd recommend going with that rather than writing your own socket handling code.

I can't really (with my Lunchtime Brain) follow your question about the "enter world" condition. I'd suggest that you arrange it as a flowchart or similar diagram.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
xsocom
Posts: 80
Joined: Thu Sep 13, 2007 8:34 am

Post by xsocom »

Ok thanks for your answer, Im using enet for this and TCP sockets.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Enet and TCP sockets?
The Enet FAQ wrote:Isn't ENet just re-inventing TCP?! What's the point?
In a perfect world, that would be true. But as many have found, using TCP either in lieu of or in conjunction with UDP can lead to all kinds of nightmares. TCP is a good, solid protocol, however it simply isn't up to the task of real-time games. Too much of TCP's implementation dictates a policy that isn't practical for games. If you want to use TCP, then do so -- this library is for people that either don't want to use TCP or have tried and ended up being discouraged with the performance.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
xsocom
Posts: 80
Joined: Thu Sep 13, 2007 8:34 am

Post by xsocom »

Oh crap... So enet is bad using TCP sockets? ... oh well I will change then to raknet.. But raknet cost right? and does it have any limits when not Purchased?

Thanks.
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Go read the license, mate. It only costs if you make a commercial game with it AND the creator of the lib. supports in all way and forms just building the app. first THEN paying for it if you like it. Furthermore, if I remember correctly, it's 100$ and up (for support or things like that, I think), so if you aim for a commercial game but think a networking lib. of 100$ is too much, you're way out of league. If not, go for it, use it, enjoy.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Enet and Raknet both use UDP only.

Enet is a decent library; I've used it myself. Raknet is more fully featured though, and comes with a lot of examples.

Raknet is free to use for non-commercial projects.

If you go on to make a commercial release, then and only then are you asked to contribute to Raknet's authors.

I think that "Choose what to pay based on what you can afford by the value RakNet has brought to your development." is about the fairest pricing that I've ever seen. The minimum commercial license price is $100. Since that's about one hour of a contractor's time, it's astonishing value for money, and remember: you're only asked to pay if its helped you to succeed.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Image
xsocom
Posts: 80
Joined: Thu Sep 13, 2007 8:34 am

Post by xsocom »

Thanks all for your replys.

Well Im doing an orpg so I prefer TCP, So any idea on what sort of network libary I can use for that if enet and raknet both use only UDP.

Also read this:

http://www.gamedev.net/features/reviews ... ductid=220

Freeware License (free) - 31 client connections, Unlimited freeware distribution.
Shareware License ($99) - Unlimited connections, commercial distribution (electronic only)
Commercial License ($1995) - Unlimited connections, unlimited distribution, full source code

though. Namely, your data isn't guaranteed to get there, and if it does get there, your chunks of data are not guaranteed to be in the same order that they were sent. Thankfully, RakNet takes care of those problems at a deeper level than you're going to be working at, so you can just forget the disadvantages and enjoy sending chunks of data around at your leisure.

So this mean's its limited to 31 connections? and UDP based so some packets maybe get lost? or does it fix that and resend the packet that dident got recved by client?

And Im not doing an commercial game, Just for learning.

So an fast and easy question, will this be a good choice for a Online RPG Game?

Thanks.
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

I have working ReplicaManager here.

It works and I'm happy with it. I really don't care about penis size at the moment because we're both studying it. Don't get too excited about specs and stats, because the reason is simple: You. Me. Are. n00bs.

If you keep shuffling here to there and back, that will not get you anywhere.

Just a suggestion, get your feet wet on Raknet first.
Image
xsocom
Posts: 80
Joined: Thu Sep 13, 2007 8:34 am

Post by xsocom »

Well not the answer Im looking for and you can feel free to call me noob I dont care at all.

I just wanted to know if raknet is a good choise for a Online Game.

Cheers.
Post Reply