Jump to content
  • Advertisement
Sign in to follow this  
Selacius

[.net] Downloadable RPG + Global Database

This topic is 4040 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

Im thinking of converting my PHP RPG to a C# windows form program. I am just curious what would be the most effective and efficient way to setup the databases. Currently the PHP version uses MYSQL. I was considering having the user uplink to the database when the program is initially run, and update the database when the program is exited. The only problem is, due to the nature of the game, the user needs to be connected to the database at all times.

Share this post


Link to post
Share on other sites
Advertisement
1. Build a remoting server which publishes a simple method that gets the data and keeps it in memory.
2. The remoting server app will only save the data of each client in the database when the client closes.
3. ...profit?


[Edit for clarity]

RPG Server DB

| ---load My data-----> | |
| | ---gimme his data----> |
| | <--there you go------- |
| <--your data--------- | |
| ---changes----------> | |
| ---changes----------> | |
| ---changes----------> | |
| ---changes----------> | |
| ---I'm going away---> | |
| | ---Save his data----> |

Share this post


Link to post
Share on other sites
I would like to do it that way, but there are certain aspects where the player needs to be in constant access to the database. I could in those situations just open the connection and keep it open for as long as necessary I guess.

Share this post


Link to post
Share on other sites
Quote:
Original post by Selacius
I would like to do it that way, but there are certain aspects where the player needs to be in constant access to the database.

Could you describe an example of such a situation?

[edit: (in case that sounded rude)]
The server never closes the connection, so it could send the player a response to any query, however in most cases this is not necessary. That's why I asked for the example.
[/edit]

[Edited by - Zanshibumi on May 24, 2007 6:57:47 AM]

Share this post


Link to post
Share on other sites
The battle system is turn based, so after every turn a row in a table is updated in the database. These values include the current tick, enemies current hp left, the enemies max hp, etc. The reason for this is a prevention measure so that if a player closes the window, or tries to get out of the battle, the next time they attempt to fight something, they get placed back into their previous battle. So there is no way for them to run without getting punished.

Basically why I ask which would be the best method to go about so i don't have to continually access the database is for speed. I find when I access the database now its quite laggy and takes a while for things to load and be displayed.

Share this post


Link to post
Share on other sites
Do you really need to use a database for this? I would think using a file would be much quicker and easier. If they close the window, simply save the gamestate as it exists. You could even keep the file open and write to it as needed.

Share this post


Link to post
Share on other sites
Quote:
Original post by Selacius
[...]The reason for this is a prevention measure so that if a player closes the window[...]

In the structure I suggested, the player has no access whatsoever to the application that's keeping the game's data. If he closes his window, the server waits a bit (1 hour for example) and then saves the data in the database and deletes it from memory.
When the player reconnects, if the server still has the data it sends it instantly, else it loads it from the DB and sends it.


Retaking the diagram:

RPG Server DB

| -Hi. Load My data---> | |
| | ---gimme his data----> |
| | <----his data--------- |
| <--your data--------- | |
| --tick, hp1, hp2----> | |
| --tick, hp1, hp2----> | |
| --tick, hp1, hp2----> | |
| --tick, hp1, hp2----> | |
... | |
disconnected | |
| |
| ---tick, hp1, hp2---> |
| <--data saved-------- |
| |
| -Hi. Load My data---> | |
| | ---gimme his data----> |
| | <---tick, hp1, hp2---- |
| <--tick, hp1, hp2---- | |


Share this post


Link to post
Share on other sites
Quote:
Original post by Machaira
Do you really need to use a database for this? I would think using a file would be much quicker and easier. If they close the window, simply save the gamestate as it exists. You could even keep the file open and write to it as needed.

For a hundred users, with their login info, current stats, last saved situation, etc... I'd use a database.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zanshibumi
Quote:
Original post by Machaira
Do you really need to use a database for this? I would think using a file would be much quicker and easier. If they close the window, simply save the gamestate as it exists. You could even keep the file open and write to it as needed.

For a hundred users, with their login info, current stats, last saved situation, etc... I'd use a database.


Didn't see this mentioned anywhere.

Share this post


Link to post
Share on other sites
Quote:
Original post by Machaira
Didn't see this mentioned anywhere.

Correct.

- I assumed it's a web game because of PHP.
- I assumed it would be directed towards at least a hundred players because he mentions it's a game (not B2B).
- I assumed it would need to save stats from this: "These values include the current tick, enemies current hp left, the enemies max hp, etc"
- I assumed it would need some kind of login procedure because the reentry procedure he mentions would need some way of identifying the player who disconnected previously.

But it's true that just by being wrong in the "he uses PHP wo it must be a web game" I'd be wrong in most of the rest.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!