Sign in to follow this  

Player profiles and databases

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

Assume each player has a login name and password (and the ability to create a new name/pw). The only way to play the game is to log into the main server with your name/pw. Also, assume that certain statistics will need to be calculated: # of players, player rank, etc. All of the account information will be stored on the server computer. And lets just be dumb and assume that there is no way to hack the information (yeah, right). What is the best way to organize the database and accounts? I can't find a problem with storing a simple text file for each player with the account name and password. When the player enters his name, attempt to open the file with that name and check the password in the file. Is there any problem with using text files if the player will not be able to see or access them. And instead of searching through all the files, we can save all the accounts into a master file as well. This master file will have the statistics and player ranks. This will be a single server game. What do you guys suggest is the best way to store all the information so that it can be retrieved efficiently?

Share this post


Link to post
Share on other sites
You could do that, but the file io would cost you a bit [which isn't a big deal if you aren't going to be doing it many times over short periods]. You could go the route of the database, but that requires going through all the mess that involves, but it would be worth it if you plan on having a lot of server accesses over short periods. You could also just append a few characters at the end of the user name, and then the password at the end of that, and have it be the filename. like User___Password, and just have the triple underscore be an unusable character combination in the user name. If the file find fails, a login error has occured. Your options are really open to you

Share this post


Link to post
Share on other sites
I would recommend just going right into a (relational) database system using MySQL. If you get any more than a few users, it will quickly turn into a nightmare trying to manage simple text files.

There are C++ wrappers to MySQL to aid you in this. The actions you will be performing are relatively simple, so it shouldn't be a difficult task, even if you have no prior database experience. You will be doing inserts and selects. That's pretty much it.

For example: You have a main table (1) with a list of user account names and passwords. Each of these entries has a link to another table (2), which is an individual user account. Each of (2) contains all the given account's players. (2) can store a given character's information: Player Name, Level, etc... If you ever want to add/remove/edit a field, this system makes it trivial to do so.

Good luck managing this type of linking with simple text files. Also you will not be able to match the efficiency of retrieving entries with your own system - this is what SQL was designed for - relational database management.

Share this post


Link to post
Share on other sites
Quote:
Original post by Doggan
There are C++ wrappers to MySQL to aid you in this.


Sounds good. I'm sure I can find some sites to help me hook this up. Do you know any good sites in particular?

One thing I never understood is how SQL can be so much better. I'm assuming that if I program everything to a 'T' using hash maps, multisets, and whatever, my database code would be able to rival SQL. Is that right?

Share this post


Link to post
Share on other sites
Quote:
Original post by blaze02
Quote:
Original post by Doggan
There are C++ wrappers to MySQL to aid you in this.


Sounds good. I'm sure I can find some sites to help me hook this up. Do you know any good sites in particular?

One thing I never understood is how SQL can be so much better. I'm assuming that if I program everything to a 'T' using hash maps, multisets, and whatever, my database code would be able to rival SQL. Is that right?


Not really. You'll get the basic functionality, but basically everything on MySQL's Top Ten Reasons list, for example, is stuff you'd have to code on your own.

Just to give a basic idea of the complexity, a summary of each point:

1. Scalability and Flexibility
Read as: SQL is to containers as MMORPGS are to text RPGs.

2. High Performance
Read as: They spent a lot of time optimizing this stuff. Stuff is cached, indexed, and generally obsessed over.

3. High Availability
Read as: They spent a lot of time debugging this stuff. Not only that, but if one computer fails, another can take over.

4. Robust Transactional Support
Read as: Even more debugging, plus data consistancy if your computer crashes.

5. Web and Data Warehouse Strengths
Read as: Rehashing the above points.

6. Strong Data Protection
Read as: Encryption and stuff.

7. Comprehensive Application Development
Read as: Works with other stuff, more features.

8. Management Ease
Read as: Reboots itself, easy to install...

9. Open Source Freedom and 24 x 7 Support
Read as: Tech support.

10. Lowest Total Cost of Ownership
Read as: You didn't have to code all the above features yourself, nor pay an arm and a leg.



Sure, if you spent enough time working on it, you could get a database that rivals any other - that's how databases are made in the first place. But, that takes time. And time is money. Which means it's expensive. Which means it's a waste of money/time/energy when somebody else allready spent that money/time/energy.

Share this post


Link to post
Share on other sites
Quote:
Original post by blaze02
One thing I never understood is how SQL can be so much better. I'm assuming that if I program everything to a 'T' using hash maps, multisets, and whatever, my database code would be able to rival SQL. Is that right?


No. A decent SQL implementation solves problems with concurrency, data integrity, memory management and speed, and can handle complex queries with aplomb. Reinventing the wheel to just get a small subset of the features that SQLite would expose to you would take months, most likely, and that's time you should be spending on your game.

Share this post


Link to post
Share on other sites

This topic is 4257 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.

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