![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "types.h"#include "api.h"#include "getargs.h"
Include dependency graph for getargs.cpp:Go to the source code of this file.
Functions | |
| int | getargs (int argc, char **argv, argoptions *opt) |
| int | getparm (int argc, char **argv, int num, argoptions *opt) |
| void | initoptions (argoptions *opt) |
| void | printusage (char **argv) |
| int | useoptions (argoptions *opt, SceneHandle scene) |
| int getargs | ( | int | argc, |
| char ** | argv, | ||
| argoptions * | opt | ||
| ) |
Definition at line 149 of file getargs.cpp.
References argoptions::filename, argoptions::foundfilename, getparm(), initoptions(), and printusage().
Referenced by main_init_parts().
{
int i, rc, unknowncnt;
if (opt == NULL)
return -1;
initoptions(opt);
if (argc < 2) {
printusage(argv);
#ifndef DEFAULT_MODELFILE
return -1;
#else
return 0;
#endif//DEFAULT_MODELFILE
}
i = 1;
unknowncnt = 0;
while (i < argc) {
if (argv[i][0] == '-' || argv[i][0] == '+') {
rc = getparm(argc, argv, i, opt);
if (rc != -1) {
i += rc;
}
else {
printusage(argv);
return -1;
}
}
else {
unknowncnt++;
if (unknowncnt > 1) {
fprintf(stderr, "Too many model file names found!\n");
printusage(argv);
return -1;
}
else {
strcpy(opt->filename, argv[i]);
opt->foundfilename = 1;
i++;
}
}
}
if (opt->foundfilename == -1) {
fprintf(stderr, "Missing model file name!\n");
printusage(argv);
return -1;
}
return 0;
}
| int getparm | ( | int | argc, |
| char ** | argv, | ||
| int | num, | ||
| argoptions * | opt | ||
| ) |
Definition at line 122 of file getargs.cpp.
References argoptions::boundmode, argoptions::boundthresh, argoptions::displaymode, RT_BOUNDING_DISABLED, RT_DISPLAY_DISABLED, and RT_DISPLAY_ENABLED.
Referenced by getargs().
{
if (!strcmp(argv[num], "+D")) {
/* turn video on */
opt->displaymode = RT_DISPLAY_ENABLED;
return 1;
}
if (!strcmp(argv[num], "-D")) {
/* turn video off */
opt->displaymode = RT_DISPLAY_DISABLED;
return 1;
}
if (!strcmp(argv[num], "-nobounding")) {
/* disable automatic spatial subdivision optimizations */
opt->boundmode = RT_BOUNDING_DISABLED;
return 1;
}
if (!strcmp(argv[num], "-boundthresh")) {
/* set automatic bounding threshold control value */
sscanf(argv[num + 1], "%d", &opt->boundthresh);
return 2;
}
/* unknown parameter setting */
fprintf(stderr, "Unrecognized parameter/option flag: %s\n", argv[num]);
return -1;
}
| void initoptions | ( | argoptions * | opt | ) |
Definition at line 82 of file getargs.cpp.
References argoptions::antialiasing, argoptions::boundmode, argoptions::boundthresh, argoptions::displaymode, argoptions::foundfilename, argoptions::usecamfile, argoptions::useoutfilename, and argoptions::verbosemode.
Referenced by getargs().
{
memset(opt, 0, sizeof(argoptions));
opt->foundfilename = -1;
opt->useoutfilename = -1;
opt->verbosemode = -1;
opt->antialiasing = -1;
opt->displaymode = -1;
opt->boundmode = -1;
opt->boundthresh = -1;
opt->usecamfile = -1;
}
| void printusage | ( | char ** | argv | ) |
Definition at line 65 of file getargs.cpp.
Referenced by getargs().
{
fprintf(stderr, "Usage: \n");
fprintf(stderr, " %s modelfile [options] \n", argv[0]);
fprintf(stderr, "\n");
fprintf(stderr, "Model file formats supported:\n");
fprintf(stderr, " filename.dat -- The model files originated with this package.\n");
fprintf(stderr, " filaname.ac -- AC3D model files.\n");
fprintf(stderr, " filename.nff -- The NFF scene format used by Eric Haines' SPD.\n");
fprintf(stderr, "\n");
fprintf(stderr, "Valid options: (** denotes default behaviour)\n");
fprintf(stderr, " +D enable run-time display updating (if build supports it) **\n");
fprintf(stderr, " -D disable run-time display updating\n");
fprintf(stderr, " -nobounding\n");
fprintf(stderr, " -boundthresh XXX (** default threshold is 25)\n");
fprintf(stderr, "\n");
}
| int useoptions | ( | argoptions * | opt, |
| SceneHandle | scene | ||
| ) |
Definition at line 94 of file getargs.cpp.
References argoptions::antialiasing, argoptions::boundmode, argoptions::boundthresh, argoptions::displaymode, argoptions::outfilename, rt_boundmode(), rt_boundthresh(), rt_displaymode(), rt_outputfile(), rt_verbose(), argoptions::useoutfilename, and argoptions::verbosemode.
Referenced by main_init_parts().
{
if (opt->useoutfilename == 1) {
rt_outputfile(scene, opt->outfilename);
}
if (opt->verbosemode == 1) {
rt_verbose(scene, 1);
}
if (opt->antialiasing != -1) {
/* need new api code for this */
}
if (opt->displaymode != -1) {
rt_displaymode(scene, opt->displaymode);
}
if (opt->boundmode != -1) {
rt_boundmode(scene, opt->boundmode);
}
if (opt->boundthresh != -1) {
rt_boundthresh(scene, opt->boundthresh);
}
return 0;
}
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.