spheredev / neosphere

A lightweight game engine and development platform using JavaScript for game coding, based on the original Sphere engine by Chad Austin but with a redesigned, modern API and brand-new command-line development tools.
http://www.spheredev.org/
Other
105 stars 15 forks source link

Allow usage of JSON game manifests with names other than game.json #304

Open postcasio opened 5 years ago

postcasio commented 5 years ago

While any .sgm file can be used, the check for JSON manifests hardcodes game.json as the filename. Calling spherun other.json will produce no errors, and immediately exit. It should instead attempt to load other.json as a game manifest, and print an error if it's not valid.

fatcerberus commented 4 years ago

While any .sgm file can be used

This gave me pause and got me to double-check the code. It turns out the game-loading code is a bit weird and double-pronged. While you are correct insofar as spherun will accept any .sgm file on the command line and use that to establish the game's root directory: https://github.com/fatcerberus/minisphere/blob/master/src/minisphere/game.c#L133

...when it comes time to actually load the game, it's still hard-coded to load only @/game.sgm: https://github.com/fatcerberus/minisphere/blob/master/src/minisphere/game.c#L196

So even if you point it at something like foobar.sgm, it will only use its path to establish a root for @/ and then return to its regularly scheduled programming. If neither game.json nor game.sgm exist in the same directory, it will error.