From 568602ab49b78842bfa832273c574eb9b901c62a Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 30 Oct 2021 17:04:18 +0200 Subject: [PATCH] Support starting maps with '-' from commandline, fix #757 like ./quake2 +map sgc9-1 the problem was that everything from '-' to the next '+' (which starts a command) was skipped; the intention of that (original Quake2) code probably was to allow skipping something like "-datadir bla", though Quake2 never supported arguments starting with '-' (until *we* added -datadir and -portable); maybe that's a leftover from Quake1. Anyway, the more correct way (that allows '-' in filenames) is to check for a space before '-': so `quake2 +map base1 -portable` still works, and now `quake2 +map sgc9-1` works as well --- src/common/cmdparser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/cmdparser.c b/src/common/cmdparser.c index 30462227..0190b23b 100644 --- a/src/common/cmdparser.c +++ b/src/common/cmdparser.c @@ -341,7 +341,7 @@ Cbuf_AddLateCommands(void) { i++; - for (j = i; (text[j] != '+') && (text[j] != '-') && (text[j] != 0); j++) + for (j = i; (text[j] != '+') && !(text[j] == '-' && text[j-1] == ' ') && (text[j] != 0); j++) { }