View Full Version : Saving shatters all windows...
DrLex
06-16-2003, 01:04 PM
Has anyone else noticed that when restoring a saved game, all the glass walls and windows in the level are broken? You can see this happening by saving while in front of a glass wall. When restoring, you'll see the windows break spontaneously... Probably a problem in the save routines, or does it only happen in the OSX port?
Flaose
06-17-2003, 11:13 PM
Are you sure you didn't break the window before you saved? Because I seem to remember the game loading all the windows, then shattering the ones you'd already broken.
DrLex
06-18-2003, 10:16 AM
Nope, all windows break, even the ones in rooms I didn't enter yet before saving... You should try it, e.g. in the large secret room in the first level of the commercial version, or the glass wall in the first level of the shareware version.
DrLex
06-21-2003, 06:46 PM
Fixed!
It was indeed a problem specific to big endian machines. I'll save you the details and just post the fixed piece of code from LoadMaskedWalls() in rt_door.c, the comments speak for themselves:
</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> for (i=0;i<maskednum;i++)
{
// Yet another endianness problem: the flags are stored in different byte
// order depending on the platform. This is bad, but I guess not many people
// will exchange game files anyway.
// Worse is that the original code here checked for the first byte of each
// flag, which only makes sense on little endian platforms. This can be
// fixed elegantly by using bit masks.
word flags; // used to be a byte
mw=maskobjlist[i];
size=sizeof(mw->flags);
memcpy(&flags,bufptr,size);
bufptr+=size;
if ((flags&0x00FF)!=(mw->flags&0x00FF)) // only check the 8 LSBs.
UpdateMaskedWall(i);
if (mw->flags&MW_SWITCHON)
mw->toptexture--;
} [/code]</blockquote><font size="2" face="Verdana, Arial">This also fixes a dirty practice in the original code: a char was declared but then an int was memcopy'd into it.
vBulletin® v3.8.0 Beta 3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.