Announcement

Collapse
No announcement yet.

Save game overwrite only works once?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by ClockworkOcean View Post

    Ok, if you're using the save game variable like that, of course it's fine. I meant don't just use it instead of the save game, only occaisionally write it back.

    It looks pretty logical to me, what's the problem?

    EDIT: Sorry ignore that question, I re-read your stuff...

    EDIT2: I think it's because your load save game event doesn't set the save game variable?
    Ohhhhh yeah lemme try and correct that and see what happens.

    Comment


      #17
      ACK! Now it's back to spawning blank scenes. Only if I move pieces around though. If I open the level and then close it immediately it saves and loads fine. No longer having a problem with the variable failing to validate though.

      Comment


        #18
        Originally posted by ClockworkOcean View Post

        Ok, if you're using the save game variable like that, of course it's fine. I meant don't just use it instead of the save game, only occaisionally write it back.

        It looks pretty logical to me, what's the problem?

        EDIT: Sorry ignore that question, I re-read your stuff...

        EDIT2: I think it's because your load save game event doesn't set the save game variable?
        Sorry forgot to quote you on that last one. I think it's where I am trying to set the variable. I need to sort out where in the load script to reset the save variable.

        Comment


          #19
          Originally posted by 3Daoist View Post

          Sorry forgot to quote you on that last one. I think it's where I am trying to set the variable. I need to sort out where in the load script to reset the save variable.
          There's no mystery. Just make sure you have the variable when everything starts, and update it and save the game when anything changes

          Comment


            #20
            Originally posted by ClockworkOcean View Post

            There's no mystery. Just make sure you have the variable when everything starts, and update it and save the game when anything changes
            Ok. I've gone back through and sort of optimized and condensed everything into one event and one function that handles all the save/load logic. I am back to a scenario in which the game correctly saves the initial puzzle layout and loads it correctly when quitting the game and restarting but it is failing to update the save with the new data when a puzzle piece gets moved. That USED to work at one point. So I'm missing something. There is an initial check to see if this is an event begin play scenario and if it is then it runs the doessaveexist check. If it's not then it's supposed to skip right to the save the game logic (for updating when the pieces move). So it seems the event begin play logic works ok but the skipping to the save for updating is missing something?
            Click image for larger version  Name:	DoesSaveExist.jpg Views:	0 Size:	224.0 KB ID:	1771739
            Click image for larger version  Name:	Save.jpg Views:	0 Size:	154.7 KB ID:	1771740
            I didn't bother putting the loading scripts in since they appear to work fine as long as the save gets updated properly.

            *Edit I just noticed I had hooked up the savegametoslot node to the loop body. I switched it back to the completed on the foreachloop. Didn't fix my problem but doesn't flash the savegamecompleted print sting a hundred times anymore.

            *Edit 2 I just noticed from watching the save file in the explorer window that the save file size goes up by 10KB every time I move a puzzle piece. So... it's somehow stacking the save data and building it up over and over instead of overwriting it?
            Last edited by 3Daoist; 06-05-2020, 02:09 PM.

            Comment


              #21
              Originally posted by 3Daoist View Post

              Ok. I've gone back through and sort of optimized and condensed everything into one event and one function that handles all the save/load logic. I am back to a scenario in which the game correctly saves the initial puzzle layout and loads it correctly when quitting the game and restarting but it is failing to update the save with the new data when a puzzle piece gets moved. That USED to work at one point. So I'm missing something. There is an initial check to see if this is an event begin play scenario and if it is then it runs the doessaveexist check. If it's not then it's supposed to skip right to the save the game logic (for updating when the pieces move). So it seems the event begin play logic works ok but the skipping to the save for updating is missing something?
              Click image for larger version Name:	DoesSaveExist.jpg Views:	0 Size:	224.0 KB ID:	1771739
              Click image for larger version Name:	Save.jpg Views:	0 Size:	154.7 KB ID:	1771740
              I didn't bother putting the loading scripts in since they appear to work fine as long as the save gets updated properly.

              *Edit I just noticed I had hooked up the savegametoslot node to the loop body. I switched it back to the completed on the foreachloop. Didn't fix my problem but doesn't flash the savegamecompleted print sting a hundred times anymore.

              *Edit 2 I just noticed from watching the save file in the explorer window that the save file size goes up by 10KB every time I move a puzzle piece. So... it's somehow stacking the save data and building it up over and over instead of overwriting it?
              *Edit 3 Ok now I sorted out the growing file size problem. I needed to clear the array of structs before using the add to array for each new save operation. Now the file size doesn't grow every time I move a piece. Still having an issue where saving and loading after moving a piece or two means it loads a blank screen.

              Comment


                #22
                Originally posted by 3Daoist View Post

                Ok. I've gone back through and sort of optimized and condensed everything into one event and one function that handles all the save/load logic. I am back to a scenario in which the game correctly saves the initial puzzle layout and loads it correctly when quitting the game and restarting but it is failing to update the save with the new data when a puzzle piece gets moved. That USED to work at one point. So I'm missing something. There is an initial check to see if this is an event begin play scenario and if it is then it runs the doessaveexist check. If it's not then it's supposed to skip right to the save the game logic (for updating when the pieces move). So it seems the event begin play logic works ok but the skipping to the save for updating is missing something?
                Click image for larger version Name:	DoesSaveExist.jpg Views:	0 Size:	224.0 KB ID:	1771739
                Click image for larger version Name:	Save.jpg Views:	0 Size:	154.7 KB ID:	1771740
                I didn't bother putting the loading scripts in since they appear to work fine as long as the save gets updated properly.

                *Edit I just noticed I had hooked up the savegametoslot node to the loop body. I switched it back to the completed on the foreachloop. Didn't fix my problem but doesn't flash the savegamecompleted print sting a hundred times anymore.

                *Edit 2 I just noticed from watching the save file in the explorer window that the save file size goes up by 10KB every time I move a puzzle piece. So... it's somehow stacking the save data and building it up over and over instead of overwriting it?
                Ok, I see something that may be the problem. You just adding and adding to the array of pieces in the save game. It should only contain once lot of pieces, I think your adding all the pieces to the array every time. This is what I was saying about how to write to the save game. Remember I said:

                To read do this:

                just read

                But, to write, do this:

                read, update, write back.

                Your write isn't reading first. So you're just putting an array in there every time. It should be getting the array in it's current state, just changing the bit that needs changing ( not much ), and then writing it back.

                If you can give me a list of your variables and types, I'll show you how I would write the save if you like...

                EDIT: In fact just tell me the structure of the puzzle array, I think that's the main part.

                Do all the other things ( like image, scale, rotation ) change during the game, or are they just defined once?
                Last edited by ClockworkOcean; 06-05-2020, 02:39 PM.

                Comment


                  #23
                  Originally posted by ClockworkOcean View Post

                  Ok, I see something that may be the problem. You just adding and adding to the array of pieces in the save game. It should only contain once lot of pieces, I think your adding all the pieces to the array every time. This is what I was saying about how to write to the save game. Remember I said:

                  To read do this:

                  just read

                  But, to write, do this:

                  read, update, write back.

                  Your write isn't reading first. So you're just putting an array in there every time. It should be getting the array in it's current state, just changing the bit that needs changing ( not much ), and then writing it back.

                  If you can give me a list of your variables and types, I'll show you how I would write the save if you like...

                  EDIT: In fact just tell me the structure of the puzzle array, I think that's the main part.

                  Do all the other things ( like image, scale, rotation ) change during the game, or are they just defined once?
                  Awesome thanks. Here's the relevant data that needs to save.

                  Each puzzle piece is a blueprint with a base name of P0. Each piece has a struct with variables for position, orientation, which model is currently applied, and snapping marker info for each edge of the piece.
                  There are also variables being saved about the overall state of the game. There's a boolean for whether or not piece rotation is enabled, a couple of integers for puzzle creation about how many rows and how many columns, which image the puzzle is chopped up from, and the scale of the puzzle.

                  So the savegame blueprint currently has an array of structs for each piece's struct variables.And then the other game state variables as well.

                  I still have to set up the parenting info to get saved, like when pieces snap together it spawns a "snapgroup" blueprint and then parents the pieces to that new actor. So I've started setting up some save data for that but I cut it out of the current blueprint for the moment until I can nail down the other stuff and get it saving consistently.

                  Let me know if that's enough info or if I left something out.

                  Comment


                    #24
                    Originally posted by 3Daoist View Post

                    Awesome thanks. Here's the relevant data that needs to save.

                    Each puzzle piece is a blueprint with a base name of P0. Each piece has a struct with variables for position, orientation, which model is currently applied, and snapping marker info for each edge of the piece.
                    There are also variables being saved about the overall state of the game. There's a boolean for whether or not piece rotation is enabled, a couple of integers for puzzle creation about how many rows and how many columns, which image the puzzle is chopped up from, and the scale of the puzzle.

                    So the savegame blueprint currently has an array of structs for each piece's struct variables.And then the other game state variables as well.

                    I still have to set up the parenting info to get saved, like when pieces snap together it spawns a "snapgroup" blueprint and then parents the pieces to that new actor. So I've started setting up some save data for that but I cut it out of the current blueprint for the moment until I can nail down the other stuff and get it saving consistently.

                    Let me know if that's enough info or if I left something out.
                    Ok, here's my totally ficticious copy of your save game process. It's not meant to be real, it just shows how to use a save game.

                    First of all, somewhere central, you can figure out the name of the save game, and put it in the game instance. The game instance looks just like a save game, but it only exists for the duration of play. You can get at it from everywhere, so it's a good place to put stuff like the name of the game.

                    Then, a puzzle piece, on begin play, can say:

                    Click image for larger version  Name:	begin play.JPG Views:	0 Size:	71.6 KB ID:	1773165

                    When it's placed:

                    Click image for larger version  Name:	is placed.JPG Views:	0 Size:	189.8 KB ID:	1773166

                    and when it's removed:

                    Click image for larger version  Name:	is removed.JPG Views:	0 Size:	143.8 KB ID:	1773167

                    So, in my head I thought maybe you gave each piece an ID ( 0 - 20 etc ), and that was it's place in the struct array. It might not be, doesn't matter, the point is you need to be able to put pieces in the save game array and take them out again.

                    The main point is how the update happens. Notice that any time something of note happens ( placing a piece / removing a piece ... ) the save game gets loaded the bit that's relevant gets updated and it gets written back. Bang, end of story. No problems figuring out when to update the save game. It happens the moment something saveable happens.

                    Does it make sense?

                    If you want me to be more particular, I need to see you data structures and understand what they do. But maybe you're getting the idea?

                    EDIT: And I know you have lots of other code attached to these custom events, that's why we put all this stuff in macros. So there's just one node to sort out the save game, and then we can concentrate of the game logic.

                    Comment


                      #25
                      Originally posted by ClockworkOcean View Post

                      Ok, here's my totally ficticious copy of your save game process. It's not meant to be real, it just shows how to use a save game.

                      First of all, somewhere central, you can figure out the name of the save game, and put it in the game instance. The game instance looks just like a save game, but it only exists for the duration of play. You can get at it from everywhere, so it's a good place to put stuff like the name of the game.

                      Then, a puzzle piece, on begin play, can say:

                      Click image for larger version Name:	begin play.JPG Views:	0 Size:	71.6 KB ID:	1773165

                      When it's placed:

                      Click image for larger version Name:	is placed.JPG Views:	0 Size:	189.8 KB ID:	1773166

                      and when it's removed:

                      Click image for larger version Name:	is removed.JPG Views:	0 Size:	143.8 KB ID:	1773167

                      So, in my head I thought maybe you gave each piece an ID ( 0 - 20 etc ), and that was it's place in the struct array. It might not be, doesn't matter, the point is you need to be able to put pieces in the save game array and take them out again.

                      The main point is how the update happens. Notice that any time something of note happens ( placing a piece / removing a piece ... ) the save game gets loaded the bit that's relevant gets updated and it gets written back. Bang, end of story. No problems figuring out when to update the save game. It happens the moment something saveable happens.

                      Does it make sense?

                      If you want me to be more particular, I need to see you data structures and understand what they do. But maybe you're getting the idea?

                      EDIT: And I know you have lots of other code attached to these custom events, that's why we put all this stuff in macros. So there's just one node to sort out the save game, and then we can concentrate of the game logic.
                      Ok. I've focused in more on the problem. I think it's something to do with my game instance and I'm forgetting to update or get a variable from there. I suspect this because if I am running the game with a fresh blank save (haven't quit and loaded once yet on this save game) then it saves and loads just fine and it even updates the save when I move pieces around and then loads just fine again the first time. It's only when I move pieces around then load again that it fails and looks like the pieces are there in the outliner window but don't show up in the game viewport.
                      So if I don't move any pieces I can save/load/quit repeatedly with no problems. If I DO move any pieces around I can save and quit once and it will work but only as long as it's the first instance of running the game on that particular save game slot.

                      Comment


                        #26
                        Originally posted by 3Daoist View Post

                        Ok. I've focused in more on the problem. I think it's something to do with my game instance and I'm forgetting to update or get a variable from there. I suspect this because if I am running the game with a fresh blank save (haven't quit and loaded once yet on this save game) then it saves and loads just fine and it even updates the save when I move pieces around and then loads just fine again the first time. It's only when I move pieces around then load again that it fails and looks like the pieces are there in the outliner window but don't show up in the game viewport.
                        So if I don't move any pieces I can save/load/quit repeatedly with no problems. If I DO move any pieces around I can save and quit once and it will work but only as long as it's the first instance of running the game on that particular save game slot.
                        I have no idea I'm afraid. The only thing I can say is make a minimal package out of your project and give me a link and I'll take a look...

                        Comment


                          #27
                          Originally posted by ClockworkOcean View Post

                          I have no idea I'm afraid. The only thing I can say is make a minimal package out of your project and give me a link and I'll take a look...
                          I got it working!

                          I'll show you the final working blueprint:
                          Click image for larger version

Name:	SaveWorking.jpg
Views:	35
Size:	318.5 KB
ID:	1774079
                          So everything is basically the same on the other ends. The check for savegame and all that logic I didn't touch since last time but now I've got it split into an initial save where the game state variables are set and then an update save where just the piece specific variables are updated. I was a little scared to try that cause I was thinking that without resaving those game state variables each time that they would somehow get overwritten because I kept imagining that the savegame file gets erased and written brand new each time you save to slot. Seems like it just updates the relevant variables without erasing the other ones though which is awesome. Anyway... removing that chunk of code about the game state variables in the saveupdate logic suddenly fixed everything.
                          ​​​​​​​Thanks again for all your help.

                          Comment


                            #28
                            Originally posted by 3Daoist View Post

                            I got it working!

                            I'll show you the final working blueprint:
                            Click image for larger version

Name:	SaveWorking.jpg
Views:	35
Size:	318.5 KB
ID:	1774079
                            So everything is basically the same on the other ends. The check for savegame and all that logic I didn't touch since last time but now I've got it split into an initial save where the game state variables are set and then an update save where just the piece specific variables are updated. I was a little scared to try that cause I was thinking that without resaving those game state variables each time that they would somehow get overwritten because I kept imagining that the savegame file gets erased and written brand new each time you save to slot. Seems like it just updates the relevant variables without erasing the other ones though which is awesome. Anyway... removing that chunk of code about the game state variables in the saveupdate logic suddenly fixed everything.
                            ​​​​​​​Thanks again for all your help.
                            Hoorah!

                            Comment

                            Working...
                            X