Sign in to follow this  
WarrenW

Question on passing player positions

Recommended Posts

Hi Everyone, I'm experimenting with writing a possible 2D scrolling MMO game in VB6. I made a small beta version where people with the client app can move their character side to side and will be updated on all other client's screen also. I do this by sending to the server my new X position and the server relays it to everyone with the character number and the X position. This is great for not so many connected users. But say you have 10,000 users online, passing your position to everyone is not needed. The X position is not actually the screen position - it is the position of the whole scrolling game area that goes from 0 to 1,000 right now. Each 1 is a place they move to. What I would like to do is only send the new position of a user to others that are within range from them. I can make an array that holds the users X positions and just loop through and pass it to players within a certain range on each side. But for everyone to loop through the array constantly seems like alot. Can anyone think of an alternative to how to pass positions to only players within your area in the game? All I'm doing is passing text in the game. The client app has all of the graphics on it already. Thanks Warren

Share this post


Link to post
Share on other sites
Looping through an array like that is not a big deal. You don't have to do it every frame, just when you send movement updates. If you want even more efficiency, you can sort the list by how close people are, and only go far enough down the list until you reach the first person who is too distant. When people move you can bubble them up or down the list as needed.

Share this post


Link to post
Share on other sites
I'm just wondering if its just easier to send out your new position to everyone instead of running code to determine who to send it to on the server.

I have a choice of either:

Send your new position to everyone
or
Loop through an array to determine who to send it to and then send to those

The text that would be sent would be no longer than 15 characters long so what do you think?

Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by WarrenW
I'm just wondering if its just easier to send out your new position to everyone instead of running code to determine who to send it to on the server.

I have a choice of either:

Send your new position to everyone
or
Loop through an array to determine who to send it to and then send to those

The text that would be sent would be no longer than 15 characters long so what do you think?

Thanks


When you have 15 clients in game it is not big deal. But when you have 100 clients, messages size will exponentially grow. (14 clients *15 byte) or (100 clients * 15 byte), and when you have more clients you have more chance that more players will move at once. Lets say 10 players move at once. that is 10*(100-10)clients*15 bytes = 13500 bytes + you will have enemies = more data.
Anyway 15 characters are not really 15 characters of data, it depends what are you using. TCP/IP takes more data than UDP, and HTTPS will wrap data with encryption.
For example I have client that uses HTTPS and when I send 10 byte of data, actually around 4K of data are sent/received.

So you need to decide which player will receive what data, and if two players are to far away from each other then don't bother sending data that isn't important to player.


Share this post


Link to post
Share on other sites
Hopefully the number of players that are within range is less that 50. The thing I am trying to determine is - is it better to just send to everyone or go through the array to determine who to send to. Use more use more bandwidth or more calculation time per movement? Its only 15 characters being sent to each person - I'm not grouping all of the data to send at once to each person. Each individual move is sent out.

And I am using the winsock control with VB6 for TCP. I need constant connection from each user so thats why I'm using TCP. I'm not sure how to use the https. I have a main central server on a machine where everyone will connect with their client and all data is transmitted via tcp method. Can I use another method and always have users connected to the server so I know who is online, etc.?

Any help will be appreciated!

Warren

Share this post


Link to post
Share on other sites
I think you should determine to whom you want to send what data. I think nowdays computers power is over network speed, because processors are very fast.
Beside TCP you can use UDP connection also.
check: UDP
There is some text pro and contra for UDP and TCP

Share this post


Link to post
Share on other sites
Thanks Streamer! I just went to that page and read about it. I've definately head of UDP but never had a reason to look into it. For what I'm trying to do, UDP may be the way to go.

I'll have to look for some code examples for VB6 using UDP. I know with TCP I have constant connections so I know who is online, etc. I have to see if I can do this with UDP. If there is no constant connection, how does it send a message to everyone? Or is there always a connection from the client to the server?

You gave me a good head start with this!

Warren

Share this post


Link to post
Share on other sites
Quote:
Original post by WarrenW

I'll have to look for some code examples for VB6 using UDP. I know with TCP I have constant connections so I know who is online, etc. I have to see if I can do this with UDP. If there is no constant connection, how does it send a message to everyone? Or is there always a connection from the client to the server?

Warren


Yes you have constant connection with it.

Share this post


Link to post
Share on other sites
Your question isn't really one of TCP versus UDP, it's designing your protocol. Here's something to consider. If you send every movement update to every client, then ever client knows where ever other player is. Now lets say one player wants to annoy another. With some simple hacks, they can now find out EXACTLY where any player is at any time.

AND, if you're trusting your clients to tell you where they are, they could 'teleport' right to that players position whenever they'd like.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this