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.)?

9 Years
Discussion Span
Last Post by Rajith Cherian

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.