Radfordhound / HedgeLib

A C++ library and collection of tools that aims to make modding games in the Sonic the Hedgehog franchise easier.
MIT License
90 stars 29 forks source link

Loading then saving Colors .orc breaks the game's ability to load transforms #10

Closed SKmaric closed 7 years ago

SKmaric commented 7 years ago

When an original .orc file is loaded and then saved to a new file, the game fails to load the position and rotation data for any objects exported, putting them all at 0,0,0 with no rotation, as pictured:

image

It's possible this may be related to the exporter putting each object's individual transform data immediately after the parameter data, instead of all closer to the end of the file like the original ones. This seems to be fine for creating files from scratch, this issue only seems to occur with loading and saving the official files, regardless of any edits made.

Also worth noting, for the current version of HedgeLib the game would crash once any of the objects came in range, I fixed this by adding writer.FixPadding(4); at line 298 of SOBJ.cs.

thesupersonic16 commented 7 years ago

Oh you found out how to fix the crash? I will give it a try. EDIT: btw line 298 of SOBJ.cs is in ReadObject, Is it meant to be reader.FixPadding(4);?

EDIT 2: writing writer.FixPadding(4); to line 422 of SOBJ.cs seems to fix the crash.

thesupersonic16 commented 7 years ago

Wow it is at 0, 0, 0

github001

thesupersonic16 commented 7 years ago

It seems it needs padding when moving the transforms.

Please test this for me its 12:30AM here.

085f45182b683071163d0cf12f3ead6d0e49e2f1

SKmaric commented 7 years ago

Ah yes, that fixed it. Thanks!

thesupersonic16 commented 7 years ago

cool.

thesupersonic16 commented 7 years ago

I'll update the set editor.

Radfordhound commented 7 years ago

Ah I see what was happening with the transforms. Tbh I'm surprised when I programmed the SOBJ class that I made it write the transform data right after the parameters. Thanks for fixing that!

Have no idea what's going on with the game crashing when there's no padding for string parameters, though. I didn't even know there were any objects with string parameters in colors lol. I had that check there just for LW objects.

thesupersonic16 commented 7 years ago

The best part about this fix is that i found it by mistake. Spent the last 30 mins on constant freezes, I was adding junk into random areas in the SOBJ until it stopped crashing, then i removed some of the junk until it stared crashing, And by doing that I found out that FixPadding seems to stop it from crashing.