For example, in a RPG like Skyrim, you can have a bunch of quests added to your quest log. How would you do this in C++? When you pick up a new quest, or whatever, how would it be written to be added to a list in the log and how can you access that log at any time? Thanks
stringstream stm;
stm<</*anything*/ //ading into string
string a=stm.str() // getting the string
//or..
/*anything*/ x;
stm>>x //extracting formated data from the log
You can do this easier by using a for loop to handle larger quantities of characters:
1 2 3 4
for(unsignedint x = 0; x < 3; x++)
{
str = (str + str2[x]);
}
that code does the same thing as the first. You can also use stringname.size() to get the size of a string. Note that the size returned by it is 1 more than the actual amount of characters in the string. So, when making a for statement, always use the < symbol so that we dont call a character that doesn't exist.
I would guess there is a lot more to it than that. Perhaps the only things that are stored are file locations. I would guess that there would be functions that look like
1 2 3 4 5
Quest::Activate()
{
active = true;
add that NPC there...
}
.
But for this example, every quest would be added to the std::list when you start the game. When a game is loaded, quests are marked as active/complete. I would sort the active quests to the beginning, and the complete ones to the end (leaving the rest in the middle).
Then getting the UI to display the name of the quest would be a matter of going through and loading the quest names until a non-active quest is found.