SpiritQuaddicted / reQuiem

reQuiem is a custom OpenGL Quake engine for Windows and Linux. It's designed for maximum compatibility with all things Quake - past, present and future. It's fast, reliable, and easy to configure. In short: it fixes what was broken, improves what needed improving, and leaves the rest alone. It was developed by jdhack.
GNU General Public License v2.0
17 stars 2 forks source link

support spaces in command-line args #20

Closed neogeographica closed 10 years ago

neogeographica commented 10 years ago

On modern Windows systems, any arg that is a path value is somewhat likely to have spaces in it.

Linux and SDL builds for Quake tend to handle these correctly, but various non-SDL Windows builds don't really. Let's fix it here!

The main change is in WinMain in sys_win.c, to make sure we interpret the argument tokens from the command line correctly. See the code comments for more details.


COM_InitArgv in common.c needs an ancillary change, to properly show arguments-with-spaces in the constructed "cmdline" console variable. From a user's POV this is muuuch less interesting than the main change, since the cmdline variable is just an informative thing (and rarely used I think). But getting it right is somewhat tricky.

The problem looks like this:

I settled on an approach that is not super-crossplatform-elegant but which has minimal churn to the existing code:


I've been using this with the Windows build... works fine, populates the cmdline var as expected. Example screenshot here from a launch using a basedir path that contains spaces:

e1m3_000

The Linux build compiles and starts, but I don't have a graphical Linux environment yet that can run reQuiem (it fails with XF86DGANoDirectVideoMode). So you'll probably want to sanity-test this on Linux still. Or wait until I can. :-) Maybe there's a way to get my CentOS VM (VMware Fusion) capable of running this.

neogeographica commented 10 years ago

I managed to run it in a Linux VM using the -nodga switch.

e1m3_000

neogeographica commented 10 years ago

I notice that on the Linux side, it doesn't remove the executable name from the "cmdline" value. This is pre-existing behavior, not part of my change. Is there a reason for the difference there between the Windows and Linux behaviors?

I don't know if other Linux Quake engines behave the same way.

neogeographica commented 10 years ago

Yep QuakeSpasm shows the executable name/path in its "cmdline" value on Linux too. But not on Windows.

I guess this pull shouldn't change that behavior. It can be tackled in a different pull if it becomes a desired change.

There's some discussion of "cmdline" here: http://forums.inside3d.com/viewtopic.php?f=3&t=4546

... which kind of gets into why the exe might be hidden ("DON'T LOOK AT MY PATHS"), but the same argument would apply to the Linux side if so. Not to mention -basedir args etc. So I dunno.

SpiritQuaddicted commented 10 years ago

sorry that I forgot about these old pull requests, merging all the things now. this sounds like a nice fix, thanks!