Download

Child Save Game Object Casts Randomly Fail. Thoughts of where to look?

Hello forums.

I’ve recently come across a weird bug that I would like to find the cause of, even though it will be refactored out at a later date.

Right now, I’ve created an input record system using a custom child of the Save game object: RecordSaveObject. This allows me to hard save player input and replay it. This will eventually be refactored out to utilize a persistent file loaded on a server, so once it is hooked up I dont have to bother with it again. At the start of the level, it randomly chooses one of the Nameslots of the recording child to load, casts to the RecordSaveObject, and continues on its merry way.

The weird thing is, whenever I finally get to the point of loading one of my recorded files, it will randomly fail to cast to the child Save Object after trying to load it. I thought maybe one of the .sav files got corrupted or something; however, having gone through each one individually and debugging, the only conclusion I can come to is that I cannot find any rhyme or reason behind this failure.

Perhaps this would have been easier to keep as a bog-standard SaveGameObject rather than creating a child class.

Only thing I can think of is that the cast fails because you have multiple save objects in there typed to different things.

However.
What you created is essentially an input buffer, correct?
Is there not a better way to save it out?

Debug the fail, and figure out what the failed cast actually was?
Should be as simple as a breakpoint on the cast and monitoring it/proceeding when it returns true…

Hi MostHost,

I guess technically it is an input buffer, but I’m not really using it in a fighting game.

The optimal way that I have found to save it out is to store the structure of everything i want to track to a persistant .csv file since once the connection is made I just have to write to a new column when recording or read when playing back. I just have not gotten that far to finishing that setup for this project so I thought I would do a quick test using .sav files as a test—since I have never tried using this method before.

Regarding debugging, I have gone through it quite a bit and the only point it seems to be failing is only actually loading the name of the .sav file. All of these files are uniquely named/tagged so it can only return the exact string that is the name to be loaded—hence my confusion.

I thought maybe my ad hoc system was generating extra characters or screwing up the name it was supplying to the file to be loaded, but everything works perfectly fine. The point of failure is literally the supplied string which I have verified are all valid and working.

Sounds like maybe it’s a file i/o issue.
Like the file hasn’t yet been created and the handle is invalid by the time it processes at times, but not in others.
(Really kind of just shooting in the dark, but it could help you figure it out nonetheless).