Seemingly broke a game save.

Vertu · 556

Vertu

  • Full Member
  • ***
    • Posts: 215
Seemingly broke a game save.
on: February 03, 2022, 06:23:16 pm
I.... As someone getting involved with coding.. I am beyond awe struck at how this could of happened.
I somehow via unknown means in a very specific instance SPECIFICLY deleted 99% of the units in the map on Gameload. The surviving units very closely resemble positions of all units in my first save of the map EXCEPT THE TERRAIN IS THE SAME AS FROM MY LATEST SAVE. At first this made me think I somehow loaded my first save of the map without having any save file not up-to-date until I saw the terrain, unit properties, and CPacks all perfectly up-to-date.

Mean while the save's icon picture is identical to my last save and shows over 2,000 units (estimate, there are over 1,250 units as that is the last UID I was using before this mess happened), CPacks are perfectly up to date (although the only V-Shield that wasn't deleted has one of it's objects offset by exactly 2 cells upwards). Yet on loading in, is almost empty of units and is nothing like the save image.

The only instance of any instability was some kind of invisible crazonium that didn't exist yet was still blocking connections in a very specific location. Ever since the map got nearly cleansed of it's units, this invisible crazonium is also missing though I think a reload would of removed it too. (This all happened after making a save then loading it shortly after making that save which then brought me to this, it was a long session but I have done longer).

Where once there was over 2,000 units there are now exactly 35 with a UID no larger than 59 (except a random V-Rod with a UID of 827 which I tried looking into to see if any of my scripts caused this.. Can't find any and I recompiled the scripts NUMEROUS TIMES BEFORE THIS HAPPENED. No Script updates happened before a recompile. They were all perfectly up-to-date and have ran at least once before saving and reloading, this is what I meant by "in a very specific instance").

The most unusual part of all of this is how seemingly EVERYTHING was deleted EXCEPT very specific units all of which are in familiar positions I recall being the unit positions saved in the first save of the map. The only unit that I believe to not be included in this is the random V-Rod with a UID of 827 and all units with a UID<60 that are missing. Also this is general, they aren't exactly in the same position but are only off by less than 3 cells in any vector at most.

Notes:
(click to show/hide)

I can provide files and images (though I don't know how to do images here) if desired.
Any advice would be heavily appreciated and I apologize if this problem really is one of my scripts going crazy. I did my best to find out myself and it seems heavily unlikely.

Also for anyone who plays my VPAC maps, the next VPAC map has been delayed because that VPAC map is this very save.

Life isn't fair because we say it isn't. Not because it is unfair. In fact, it is so fair we want to say it isn't and do.


Karsten75

  • Hero Member
  • *****
    • Posts: 7307
Re: Seemingly broke a game save.
Reply #1 on: February 04, 2022, 08:24:27 am
Unfortunately, a corrupted save will not divulge much information other than that it is corrupted.

If you still have the log file, that might give us some insight as to whether the game had an issue, If the log file is clean, it most likkly can be attributed to the wide and undefined category of "user error". Unfortunately, every time the game starts, the log file is cycled and overwritten. So the log file will only be relevant for the previous and current invocation of the game.

The log files can be found using the instructions here: https://knucklecracker.com/forums/index.php?topic=34722.0

and are titled, respectively,

player.log and
player-prev.log.


However, it appears on my system that player-prev.log is not current, so it may not hold true that you will have a record of any but the most recent invocation of the game.

Edit:

It is for this reason (the importance and transient nature of the log files) that I have written a batch front-end to start the game. In this batch front-end, I cycle the log file over many more iterations.


Code: [Select]
@Echo OFF 
pushd %appdata%
CD ..\LocalLow\Knuckle Cracker\Creeper World 4
IF EXIST "Player10.log" ERASE  "Player10.log"
IF EXIST "Player09.log" RENAME "Player09.log" "Player10.log"
IF EXIST "Player08.log" RENAME "Player08.log" "Player09.log"
IF EXIST "Player07.log" RENAME "Player07.log" "Player08.log"
IF EXIST "Player06.log" RENAME "Player06.log" "Player07.log"
IF EXIST "Player05.log" RENAME "Player05.log" "Player06.log"
IF EXIST "Player04.log" RENAME "Player04.log" "Player05.log"
IF EXIST "Player03.log" RENAME "Player03.log" "Player04.log"
IF EXIST "Player02.log" RENAME "Player02.log" "Player03.log"
IF EXIST "Player01.log" RENAME "Player01.log" "Player02.log"
IF EXIST "Player.log"   RENAME "Player.log"   "Player01.log"
popd
start steam://rungameid/848480
EXIT /B



« Last Edit: February 04, 2022, 08:45:33 am by Karsten75 »

'If you want to live a happy life, tie it to a goal, not to people or things.'

Albert Einstein
(1879-1955)


knucracker

  • Administrator
  • *****
    • Posts: 11793
Re: Seemingly broke a game save.
Reply #2 on: February 04, 2022, 08:44:07 am
Yep, the log file might show an exception.  If it does, that would say what happened.  Other than that, there isn't a whole lot that can be done.  I can say that if the unit ID's 'reset' that would have been a problem really early in the save for some reason.  That value is saved and loaded really early so for the 'current' unit uid to not get saved would require some sort of very fundamental issue during the save.

The best advice I can offer is to save backup copies of any complex map (use the slots, or do an occasion finalize).  I do this before any sort of 'large' map edits.  That way if there is a problem, or I goof something up, or I overwrite a save, etc... I can get back to something earlier.  That said, I've not had or know of any issues in the current version of the game during save.  But... who knows...  especially with complex maps with scripts, etc.



Vertu

  • Full Member
  • ***
    • Posts: 215
Re: Seemingly broke a game save.
Reply #3 on: February 04, 2022, 10:06:22 am
I followed the paths provided and copy and pasted the player log and output log. Hope it's what you need.
If an "easy" solution or cause can't be found I will start removing CPacks via-files.
Also fun fact, removed CPacks removed via the CPack manager in-level don't actually remove them from the level's file. They remain in the file of the map. I have a CPack in the files that isn't in the CPack manager of the level and explains why I need to override CPacks even when I removed their outdated version in the CPack manager of the map.

Player log:
(click to show/hide)

Output log:
(click to show/hide)

Life isn't fair because we say it isn't. Not because it is unfair. In fact, it is so fair we want to say it isn't and do.


knucracker

  • Administrator
  • *****
    • Posts: 11793
Re: Seemingly broke a game save.
Reply #4 on: February 04, 2022, 12:38:42 pm
Do you still have the player-prev.log?  That's the one that is likely to contain the error (if either does, depending on how often you have restarted  the map since the error with the map).  The output.log is just an old file from the original version of the game.  Unity switched from output.log to player.log in an updated version I switched to over the last year.
« Last Edit: February 04, 2022, 12:49:21 pm by knucracker »



Vertu

  • Full Member
  • ***
    • Posts: 215
Re: Seemingly broke a game save.
Reply #5 on: February 04, 2022, 12:45:53 pm
Player-prev.log:
(click to show/hide)

Life isn't fair because we say it isn't. Not because it is unfair. In fact, it is so fair we want to say it isn't and do.


knucracker

  • Administrator
  • *****
    • Posts: 11793
Re: Seemingly broke a game save.
Reply #6 on: February 04, 2022, 12:51:38 pm
That's what I was afraid of.  It's basically empty too.  You've probably restarted more than once since the problem, so the exceptions (if any) are lost to the great bit bucket in the sky.
The only thing left to try is to try loading the problematic save, then take a look at the player.log to see if it has a problem on load.  It's possible the error is during the load, not the save.  If so, there would be an exception in the log right after you try to load the saved game



Karsten75

  • Hero Member
  • *****
    • Posts: 7307
Re: Seemingly broke a game save.
Reply #7 on: February 04, 2022, 01:38:35 pm

Also fun fact, removed CPacks removed via the CPack manager in-level don't actually remove them from the level's file. They remain in the file of the map. I have a CPack in the files that isn't in the CPack manager of the level and explains why I need to override CPacks even when I removed their outdated version in the CPack manager of the map.

Please, next time you attach a log file, use the "Attachments and other options" drop-down below the text input window.

And this may serve to clear some of your confusion around where a CPACK and the associated scripts reside on disk during various phases of map development: https://knucklecracker.com/wiki/doku.php?id=4rpl:overview#working_with_cpacks

'If you want to live a happy life, tie it to a goal, not to people or things.'

Albert Einstein
(1879-1955)


Vertu

  • Full Member
  • ***
    • Posts: 215
Re: Seemingly broke a game save.
Reply #8 on: February 04, 2022, 01:45:23 pm
Here you go, I noticed how now it has "unloaded unused assets" at the end compared to 0 unused assets.

Life isn't fair because we say it isn't. Not because it is unfair. In fact, it is so fair we want to say it isn't and do.


Karsten75

  • Hero Member
  • *****
    • Posts: 7307
Re: Seemingly broke a game save.
Reply #9 on: February 04, 2022, 02:48:01 pm
Here you go, I noticed how now it has "unloaded unused assets" at the end compared to 0 unused assets.

Now upload the save file for the game you were playing as well.

'If you want to live a happy life, tie it to a goal, not to people or things.'

Albert Einstein
(1879-1955)


Vertu

  • Full Member
  • ***
    • Posts: 215
Re: Seemingly broke a game save.
Reply #10 on: February 04, 2022, 02:53:59 pm
This should be the main save. I do make backups but since nothing went wrong at the end of the editing session I updated the backups.

Life isn't fair because we say it isn't. Not because it is unfair. In fact, it is so fair we want to say it isn't and do.


knucracker

  • Administrator
  • *****
    • Posts: 11793
Re: Seemingly broke a game save.
Reply #11 on: February 04, 2022, 03:40:17 pm
Ok, there is an exception during load.  When I take a look, the exception is coming when trying to load units that have been saved with one set of children than differs from the 'definition' of the unit.  Something like this could maybe happen when there are instances of a cmod unit on the map, then the unit definition is changed, or a different cpack is loaded, then the game is saved before any of the existing units on the map are 'updated' to match the new cmod definition.

I've added some code into the game to protect against throwing the exception (for a future beta build).  I've then taken your save and re-saved it so the units match their definitions.  That save is attached and should load for you.  That may get some of your work back. 

Now, there were several problematic units in the save and I don't know if they are loaded totally correctly or not.  It looks like the definition of the units were changed to have extra children components, but the saved versions didn't have those extra (1 or more) children.



Vertu

  • Full Member
  • ***
    • Posts: 215
Re: Seemingly broke a game save.
Reply #12 on: February 04, 2022, 03:44:04 pm
Ok, there is an exception during load.  When I take a look, the exception is coming when trying to load units that have been saved with one set of children than differs from the 'definition' of the unit.  Something like this could maybe happen when there are instances of a cmod unit on the map, then the unit definition is changed, or a different cpack is loaded, then the game is saved before any of the existing units on the map are 'updated' to match the new cmod definition.

I've added some code into the game to protect against throwing the exception (for a future beta build).  I've then taken your save and re-saved it so the units match their definitions.  That save is attached and should load for you.  That may get some of your work back. 

Now, there were several problematic units in the save and I don't know if they are loaded totally correctly or not.  It looks like the definition of the units were changed to have extra children components, but the saved versions didn't have those extra (1 or more) children.
Then I believe what caused this was, I found a trash object for my V-Shields that was doing nothing but increasing the amount of objects needing to be loaded. I changed this before saving by mistake and then save to then update unit instances because that button can cause some disruption.. Which it did.
Thank you very much I will be sure to be more careful when editing objects in units and be sure to save BEFORE doing such edits. Never knew this could happen to such a degree.
Thank you for your time.

-Edit-
I was perfectly able to load the save after updating to the file provided.
Also after taking a very close look at the V-Shield units, they all no longer have that object.
« Last Edit: February 04, 2022, 03:50:18 pm by Vertu »

Life isn't fair because we say it isn't. Not because it is unfair. In fact, it is so fair we want to say it isn't and do.