How to validate player positions?

Started by
12 comments, last by ozak 14 years, 2 months ago
Hi I created a 2d stickman top down view game similar to the dual stick fighters that are seen on xbox live indie games and other platforms. I have all the players moving around and they can shoot bullets. How do I validate the player positions for all the players on the server side? The game is created in flash and is currently uses sockets for all the connected players to connect to the java socket server. I created an array to hold all of the positions and I have each player sending their positions to the server and the array is updating as each player send his or her position. the problem that I know of, 1. players can decompile the flash and find out how to send invalid x and y positions so the game breaks and people jump around and hack themselves around the screen. How do I validate all the player positions so that each player can move around and all other clients are in sync and unable to hack their position? ricky
Advertisement
Don't send positions from client to server, instead send inputs from client to server and positions from the server to the client.
yes, now I can imagine how that makes perfect sense. but how would the server side code look?

do you have or know of a tutorial that illustrates how the server would handle such logic?

ricky
Presumably, the exact same way the game does, minus all the GUI logic.
I trust exceptions about as far as I can throw them.
Ok, i'm thinking that each connected player should have a boolean value stored on the server for each direction that they can move on the screen. for instance when the boolean flag for the player's moveLeft is true, the player X position should -= the player speed for example.

On the client, i can make a request to the server to turn on a players moveLeft when the key is held down on the keyboard and turn it off when the key is released.

does this sound like it's good logic for the player movement?
Just check to see if the character can move in that direction, when the player sends the "moveleft" command. Your program (And programmer) should not expend any unnecessary effort.
Just keep al your game logic on the server. Player presses a key to move right, command is send to server that player wants to move right, server updates game world, new positions of all objects on screen are sent back to player. The player can mess up the client all he wants, but it won't affect the game state on the server and the for the rest of the players.
Ok, I created a map to move around in on my client. How does the server know the location of the maximum edges of my player map?

ricky
The server will need to have the map as well.
The server should also create and hold the map. The clients should only receive copies and updates.

The client sends player commands and receives and handles visual data. That's it. Anything else should be on the server.

This topic is closed to new replies.

Advertisement