-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
verify command line options #650
verify command line options #650
Conversation
src/m_argv.c
Outdated
if (CheckParamsWithArgs(i)) | ||
{ | ||
// -file and -warp may have multiple arguments | ||
if (!strcasecmp(myargv[i], "-file") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does -deh
also take multiple args?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-warp
can take one or two arguments, depending on the version. Not sure if we should check everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, "do it right or don't do it". 😁 Honestly, I'd expect command line checking code to detect that -warp 1 2 3 4 5
cannot be right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, "do it right or don't do it".
Yes, that's the question 😄 How do you like this approach, is it worth finishing it?
There is also -recordfrom
which only takes two arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW with docgen
we can also generate code for --help
options list, or maybe even help <option>
messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will also need to check the validity of the parameter passed to e.g. the -complevel
argument, else this whole checking procedure won't make too much sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should check the validity of -complevel
and other arguments in the game code, such as the -file
argument if the path/file is not found. There is 36 options with arguments and most of them silently ignore wrong input.
kraflab/dsda-doom@74a25a5 maybe some food for thought, an approach in dsda-doom (I see this as a more important precursor, but checking if they are used is easy to add on top). |
Interesting, thanks. Looks like PrBoom+'s complevel is the only option that allows a negative integer as an argument? I want to use the |
There may be other stuff that takes |
Ha, I didn't know that and implemented it differently. As for memory overflows, I think they are only positive, at least in the Choco code we copied, it is |
src/d_main.c
Outdated
} | ||
else | ||
{ | ||
I_Error("Wrong -episode parameter '%s', should be 1-4", myargv[p+1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we have any episode from 0 to 9 now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, in Woof we even support episodes 0-99.
@fabiangreffrath BTW -warp 9999
doesn't currently work, only -warp 99 99
. Not sure how to validate -warp
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay as it is. No algorithm can know if -warp 999
means to warp to E99M9 or E9M99. 😉
This should emulate Vanilla behaviour: --- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -1209,10 +1209,11 @@ void P_SpawnMapThing (mapthing_t* mthing)
return;
// killough 11/98: simplify
- if (gameskill == sk_baby || gameskill == sk_easy ?
+ if ((gameskill == sk_none && demo_version < 203) ||
+ (gameskill == sk_baby || gameskill == sk_easy ?
!(mthing->options & MTF_EASY) :
gameskill == sk_hard || gameskill == sk_nightmare ?
- !(mthing->options & MTF_HARD) : !(mthing->options & MTF_NORMAL))
+ !(mthing->options & MTF_HARD) : !(mthing->options & MTF_NORMAL)))
return;
// [crispy] support MUSINFO lump (dynamic music changing)
|
Though, even Pr+ doesn't emulate this. But then the parameter help string needs to be adjusted. |
We need to emulate it as we support Choco netgame so there is a possibility of desync. Interesting that |
kraflab/dsda-doom#116 if you're curious how that went🥵 |
I think Woof's motto is to preserve as much code as possible, so I take the simpler approach 😄 We have 82 options, but there are a few undocumented secret ones. |
man/docgen
Outdated
|
||
result += " " * (indent - len(result)) | ||
|
||
result += textwrap.fill(self.text, width = (90 - indent), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabiangreffrath Should we wrap help text for console output? Maybe we should write shorter help lines instead 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help text should fit into one console line ideally. Do you have an example of a help text line that doesn't fit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops missed your answer.
This is about a response to the -help
command. I just generate our CMDLINE documentation, but with selected categories and parameters. So we have a lot of long lines here with multiple sentences: help.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I like this very much! However, 90 chars is too long for a terminal, e.g. MSYS2's mintty defaults to 80x24. To achieve this, I think we shouldn't cut down the help strings. I very much prefer them to be real sentences and actually helpful. Could you tune it so that each line is broken after at most 80 chars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, 80 columns is the standard, but I have noticed that many modern applications do not respect it.
Anyway, my English is bad, so I'll just let the Python textwrap
library do its job 😄
src/i_system.c
Outdated
{ | ||
I_Error("Invalid parameter '%s' for -setmem, " | ||
"valid values are dos622, dos71, dosbox " | ||
"or memory offset.", myargv[p]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not an offset is it? I think it's up to 10 bytes of data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I'll correct it.
|
||
for t in targets: | ||
# no video and obscure category | ||
if t != c["video"] and t != c["obscure"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no video?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have a video option important enough to include in the -help
output. However, I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, the most important options already have their switches in the menu.
src/d_main.c
Outdated
startmap = 1; | ||
autostart = true; | ||
startepisode = M_ParmArgToInt(p); | ||
if (startepisode >= 0 && startepisode <= 99) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still unconditionally restricting episode to be > 0:
Lines 2982 to 2983 in d8a068c
if (episode < 1) | |
episode = 1; |
So, is this ready for merging now? |
Yes, it's ready. |
Inspired by this issue: coelckers/prboom-plus#515
I'm using
docgen
to generate a list of command line options to check.