Hey. Right now in my game (online) I'm using std::vectors to store player info.

Should I continue to use them (I hate having to loop thru them each time to find a player) or should I use MySQL to hold player information (like map their on, nickname, id, position, etc.)?

Recommended Answers

All 4 Replies

Do you need the information if the player stops and wants to restart again later ? If yes then you will have to save the information in the vector somewhere and if you have MySql available already then that's a good place to put it. You could also just store it in simple files.

Well, it really doesn't matter.

I don't like doing for(int i=0;i < players.size();i++) { if(players.at(i).id == p_id) { ... } } , I was thinking just use SQL to do SELECT * FROM players WHERE id = '<p_id>' and stuff.
(but; I store the players socket inside the vector, so I guess I'd still need to store id/socket in them.)

I have MySQL installed, but I don't have the C/C++ headers or library. Where do I get those, anyway?

you can download them from mysql site. I think its called MySql++

>> I don't like doing ...
calling mysql select is going to be a lot slower than doing the vecto stuff. If speed is important to you then don't do many selects.

Hey hacker9801

You could also take a look at SQLite. Its very fast and be easily integrated with C++

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.