DavidGriffith / frotz

Infocom-style interactive fiction player for Unix and DOS (moved to https://gitlab.com/DavidGriffith/frotz)
GNU General Public License v2.0
209 stars 64 forks source link

Fixing restart in games that have zcode in blorb files. #6

Closed welash closed 9 years ago

welash commented 9 years ago

This change fixes restarting in games that are stored in blorb files. It also fixes when you use the verify command on those files. Before this change, using uninvited.zblorb as an example,

>verify
The game file did not verify as intact, and may be corrupt.
>restart
Are you sure you want to restart? y

[** Programm lowomh  d te   fxx -tp  zzzk    jajs  d te  d te   error: b       mj      wlowomh  d te      lowomh  d te   fxx -tp  zzzk    jajs  d te  d te    z g
mmw 

The issue was that the code was using fseek(storyfile, 0, SEEK_SET) to go to the beginning of the file instead of going to the beginning of the zcode segment of the blorb file. Similarly, to find the size of the zcode, in some cases the code would do a fseek(storyfile,0, SEEK_END) and then use ftell and use the result to determine the size of the zcode.

I replaced the use of fseek and ftell with an new os dependent os_storyfile_seek() and os_storyfile_tell() which, for zcode NOT in blorb files, just do fseek and ftell, but if the code IS in a blorb file, will seek relative to the beginning and end of the zcode segment and will report the corresponding position for os_storyfile_tell().

DavidGriffith commented 9 years ago

Thanks. I'll copy this over to the ao-curses branch as well. I think everything is in place for a new point release of Frotz.

welash commented 9 years ago

It looks like I inadvertently added a .gitignore in with my change. I hope that is ok.

DavidGriffith commented 9 years ago

I've been meaning to put that in the main branch, but have just been procrastinating and leaving it for the merge with ao-curses. The one you added is identical to the ao-curses one, so no worries.