Jump to content
  • Advertisement
Sign in to follow this  
Demx

Online Rpg Database

This topic is 2584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, im making a simple rpg using a Server, client and a MySql database .

every second the client renders 20 frames and if a key is pressed it updates the database of the new position

while ( 1 ) {

handle events

move player if a key is pressed

if postition of player has changed write new position to database

}

the problem is i think the database is put under too much stress for updating the position evey 50-75 ms


Is there another way to update the positions ?

thx

Share this post


Link to post
Share on other sites
Advertisement
in general, the game server is what handles the real-time updates, and the database is used for long-term persistence of data. For example, the database proper doesn't need to hold the current position, but it would be used to store the player's position at time of log-off.

Share this post


Link to post
Share on other sites
Obviously you don't want to let your client access the database directly, since that will cause all kinds of potential security problems.

You might want to let the client be authoritative on position, since if movement has to go through the server before it's displayed on the client, it will feel very laggy. Whenever the player (client) moves, just let him send a "my position is x,y,z" to the server. As Ravyne points out, you don't need to save the position every time it changes, but you still need to save it on a certain interval. These database writes can be batched for all clients, for better performance. It's not enough to only save the position on log-out, since then information will be lost if the server crashes. A save interval of 5-10 seconds will probably work fine.

Note that this is just for position. For more important updates like "player looted Sword of Doom" you want to save it to the database immediately. Players tend to get grumpy if their epic gear disappears.

If you're scared that people will hack the client and cheat with the position (they will if your game becomes popular), you probably want to do some "sanity" checks of the positioning data on the server.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!