Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

Game crashes after loading saved games #96

Closed
wzdev-ci opened this issue Oct 6, 2008 · 13 comments
Closed

Game crashes after loading saved games #96

wzdev-ci opened this issue Oct 6, 2008 · 13 comments

Comments

@wzdev-ci
Copy link
Contributor

wzdev-ci commented Oct 6, 2008

keyword_crash keyword_mac keyword_save resolution_fixed type_bug | by bearda


Using the latest trunk code on a Mac OS X machine (10.5.3, G4 mac mini).

Loading a saved game results in a crash most of the time with the following error on console:

error : [dirDiff] dirDiff: result out of range
error : [dirDiff] Assert in Warzone: /Users/freddie/Documents/Programming/Warzone2.1/macosx/../src/move.c:252 (retval >=0 && retval <=180), last script event: 'N/A'
Assertion failed: (retval >=0 && retval <=180), function dirDiff, file /Users/freddie/Documents/Programming/Warzone2.1/macosx/../src/move.c, line 252.
Abort trap

Further investigation suggests that the bumpDir element of many saved droids has an invalid value (not 0-360), causing the assertion in move.c to fail. Inserting checks when bumpDir is read from the filesystem to make sure it falls in a valid range and resetting it to 0 if it doesn't seems to avoid the assert fail but doesn't explain why the bad values are being read in the first place.


Issue migrated from trac:96 at 2022-04-15 17:44:07 -0700

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Oct 7, 2008

Kreuvf commented


What is 'a saved game'? A save-game created with the same version?

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Oct 7, 2008

EvilGuru commented


It could be an endian issue. Needs further investigation (Ideally done by someone with a PPC Mac).

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Oct 7, 2008

bearda commented


Yes, saving with the same version results in bad bumpDir values. Almost all my saved games that weren't generated between levels (when the stat page pops up) have the same problem, it isn't one or two specific saves. I tried saving my game, going to the main menu, then immediately loading the save I had just created and had my debug print spewing bad bumpDir values before resetting them to 0.

When I have a minute I'll try converting some of the bad values I get back to little-endian and see if they fall into the 0-360 range. I have two PPC Macs (one mini and one iBook, both G4s) available if anyone wants me to test something. The mini is the only one set up to actually build the code at the moment, though, so it's where I've done all my testing so far.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 4, 2008

Giel changed blocking which not transferred by tractive

@wzdev-ci
Copy link
Contributor Author

anonymous changed blockedby which not transferred by tractive

@wzdev-ci
Copy link
Contributor Author

anonymous commented


I've come to realize my problem in #177 is definitely exactly the same as described here. My bad for double-posting a bug. Not sure if there is a way to merge these or something...

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 27, 2008

Giel commented


Replying to Warzone2100/old-trac-import#96 (comment:5):

I've come to realize my problem in #177 is definitely exactly the same as described here. My bad for double-posting a bug. Not sure if there is a way to merge these or something...

I closed #177 marking it as a duplicate. As for merging there's no need really, as we can always follow the links...

@wzdev-ci
Copy link
Contributor Author

mathew.eis@... commented


It appears that, at least on the PPC platform, bumpDir is being swapped twice. What takes place is roughly as follows:

// Saved droid is loaded...

move.c:6424      memcpy(psSaveDroid, pFileData, sizeOfSaveDroid);

// bumpDir is swapped...

move.c:6490      endian_sword(&psSaveDroid->sMove.bumpDir);

// Call function to create actual droid from saved droid

move.c:6525      psDroid = buildDroidFromSaveDroid(psSaveDroid, version);

// Call function to copy move data into actual droid from saved droid

move.c:5977      LoadDroidMoveControl(psDroid, psSaveDroid);

// bumpDir is swapped again!?

move.c:5699      psDroid->sMove.bumpDir      = PHYSFS_swapSLE16(psSaveDroid->sMove.bumpDir);

Possibly this is a bug in the way that LoadDroidMoveControl is set up... A rough examination makes it appear that all the byte swapping code should be removed from LoadDroidMoveControl, since it already was done in move.c:6481-6497 - not sure how this would affect x86 platforms though.

@wzdev-ci
Copy link
Contributor Author

mathew.eis@... commented


The above referenced file should be game.c, not move.c

@wzdev-ci
Copy link
Contributor Author

Giel changed resolution from `` to fixed

@wzdev-ci
Copy link
Contributor Author

Giel changed status from new to closed

@wzdev-ci
Copy link
Contributor Author

Giel commented


(In [6512]) * Do not perform endian swapping twice when loading, as it'll undo the first swap

  • Make saving and loading of move controls symmetric

This should fix #96, #127 and #177

@wzdev-ci
Copy link
Contributor Author

Giel commented


(In [6513]) Merged revision [6512] into the 2.1 branch via svnmerge from trunk

........
[6512] | muggenhor | 2008-12-28 15:31:54 +0100 (zo, 28 dec 2008) | 5 lines

  • Do not perform endian swapping twice when loading, as it'll undo the first swap
  • Make saving and loading of move controls symmetric

This should fix #96, #127 and #177
........

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant