Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void loadGameState(string fName) {
- std::ifstream MyFile("Saves/" + fName);
- string line;
- //TIMESTAMP
- getline(MyFile, line);
- std::cout << "Timestamp of save: " + line << std::endl;
- //CURRENT ROOM
- getline(MyFile, line);
- for(Room* iter: Room::rooms){
- string key = iter->getName()->data();
- if (key.compare(0, ' ', line) == 0) {
- currentState->goTo(iter);
- }
- }
- //INVENTORY
- getline(MyFile, line);
- string intermediate;
- std::stringstream temp(line);
- State::inventory.clear();
- while (std::getline(temp, intermediate, ',')) {
- for (GameObject* iter: objList) {
- if (intermediate.compare(0, ' ', iter->getKey()) == 0) {
- std::cout << intermediate + " Here" << std::endl;
- State::inventory.push_back(iter);
- }
- }
- }
- //ROOM OBJECTS
- string strName;
- string strList;
- while (!MyFile.eof()) {
- getline(MyFile, strName);
- getline(MyFile, strList);
- std::vector<string> tokens;
- std::stringstream store(strList);
- while (std::getline(store, intermediate, ',')) {
- for (Room *x: Room::rooms) {
- if (strName.compare(0, ' ', *x->getName()) == 0) {
- for (GameObject *y: objList) {
- if (y->getKey().compare(0, ' ', intermediate) == 0) {
- *x->addObject(y);
- }
- }
- }
- }
- }
- }
- MyFile.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement