marcel303 / keen

Keen Dreams port using SDL
GNU General Public License v2.0
28 stars 2 forks source link

Segfault when starting new game #11

Closed tdecker91 closed 5 years ago

tdecker91 commented 5 years ago

Trying to build and run on OSX High Sierra. I installed sdl and cmake using brew. Generated the makefile with cmake, and used make to build the executable. I placed the executable in a folder containing the shareware version of the DOS game. The game starts up and looks fine until trying to select new game in easy, medium or hard.

Upon starting a new game the console shows this error. malloc: *** error for object 0x7fb4f983bc00: incorrect checksum for freed object - object was probably modified after being freed.

It seems to happen after trying to access a property on shape retrieved with this line. https://github.com/marcel303/keen/blob/master/kd_play.c#L1061

Any ideas?

fragmental commented 5 years ago

Could be some sort of conflict with the game files. You can try it with the game files hosted here . The zip file contains two copies of the files(I don't know why) but afaik, they're identical so either should work. There are a number of unnecessary files as well, but I'm not 100% sure what is necessary and what isn't.

Another less possibility is that a file or folder that needs to be writable is read only.

If it's anything else, @marcel303 is likely the only one who can help.

tdecker91 commented 5 years ago

@fragmental Thanks! Yeah it works perfect with those other game files. I tried with a few different copies I could find online, not sure what the difference is. Glad it's working now though.

marcel303 commented 5 years ago

@tdecker91 The code is very picky about which version of the game it likes and which it doesn't. @fragmental thank you for helping out here. :-) Actually it's possible to run other versions of the game too, but you will need corresponding "KDR" files.

The KDR files are like indices for the game's data files. Think of directory structures, which list the files and offsets for where to find them, inside the game's data archive files. Actually instead of files they are called 'chunks' in the code. But the concept is the same. The Keen series of games embed these indices inside the executables, for faster/more efficient lookups. Of course, these indices are different for different versions of the game.

The CMake script contains a custom build action to create c/h files from the files inside the 'static' folder. These files are then compiled and linked with the executable. It is, however, possible to replace these files given another version of the game. The big question here is, where do you get the matching KDR files? To this, I do not know the answer! So we're stuck with one version of the game for now..

I also added support for overriding the KDR files on the command line. If you add /? to the command line you will see all of the various command line options. I hope this helps.. !

tdecker91 commented 5 years ago

@marcel303 Thanks for the quick detailed response! That helps a lot. I should've read the readme better to see that you specifically used version 1.13 :)