Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Before this change, the FindArg() function was well suited for finding command-line options that only appear once. It’s very resonable for FindArg() to only support arguments that appear one time because Descent 3 doesn’t have any command-line options that should be specified multiple times. For example, it would be pretty pointless to do something like this: Descent3 -useexedir -useexedir or something like this: Descent3 -aspect 1.0 -aspect 1.6 It does, however, sometimes makes sense to repeat command-line options for other applications. For example, you can specify -e multiple times when running grep [1]: grep -e pattern1 -e pattern2 file.txt The main motivation behind this change is to make it easier to create a future commit. That future commit will add a command-line option named “-additionaldir”. -additionaldir will be similar to grep’s -e flag. In other words, it will make sense to do this: Descent3 -additionaldir /home/user/dir1 -additionaldir /home/user/dir2 Adding a start parameter to FindArg() now will make it easier for that future commit parse the multiple occurrences of -additionaldir. Unfortunately, there is one drawback to this change. In Descent3/args.h, I gave the start parameter a default value of 1. Giving the start parameter a default value allowed me to add the start parameter without having to change most of the calls to the FindArg() function. There was one situation where I had to change how FindArg was called, though. DLLFindArg is a pointer to the FindArg() function. You cannot give function pointers default arguments [2]. As a result, FindArg("-someargument") works, but DLLFindArg("-someargument") does not. Instead, you have to write DLLFindArg("-someargument", 1) which is a little bit annoying. [1]: <https://www.gnu.org/software/grep/manual/html_node/Matching-Control.html> [2]: <https://stackoverflow.com/a/9760710/7593853>
- Loading branch information