I've wanted to make a text based C++ game for a while now, and i've slowly started planning the basics for it now.
One of the things i'd like is some kind of save/load function. So every once in a while, the program will ask the user if he/she wants to save the game, if yes, the program will output a code to a text file.
At the start of the game, the user will then have a choice of loading the last game, and the program will fetch the code and compare it to some hard coded codes that represent the players progress in the game, this is where i got stuck.
My plan was to make my own branch table and then use GoTo statements to jump to the saved location in the game. Something along the lines of this:
And so on...
My question is then: Would this be considered poor programming? I've heard alot about GOTO, and how bad it is. But in this case, it doesn't really produce spaghetti code, actually, i kind of like my save/load function implementation, and i have a hard time figuring out another way of doing it.
One way could be to base the entire game on a linked list, so the first lvl would be in the first node of the list, and so on. And then just traversing through the list until the codes in the save game files matched a certain variable in my list, but i don't like this solution as much as the other one.
What else could i do? And do you think this qualifies as a good place to use GOTO?