dungeon_crawler

diff prototype/src/cfg.cc @ 25:527fede30057

- fixed sphere rendering (PointLight::draw) - added config argument options - fixed macosx compilation
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 25 Aug 2012 02:16:08 +0300
parents 5c41e6fcb300
children 6d71dd4760f9
line diff
     1.1 --- a/prototype/src/cfg.cc	Thu Aug 23 18:03:11 2012 +0300
     1.2 +++ b/prototype/src/cfg.cc	Sat Aug 25 02:16:08 2012 +0300
     1.3 @@ -17,29 +17,33 @@
     1.4  bool Config::parse_args(int argc, char **argv)
     1.5  {
     1.6  	for(int i=1; i<argc; i++) {
     1.7 -		if(strcmp(argv[i], "-s") == 0) {
     1.8 -			if(sscanf(argv[++i], "%dx%d", &width, &height) != 2) {
     1.9 -				fprintf(stderr, "-s must be followed by <width>x<height>\n");
    1.10 +		if(argv[i][0] == '-') {
    1.11 +			if(strcmp(argv[i], "-s") == 0) {
    1.12 +				if(sscanf(argv[++i], "%dx%d", &width, &height) != 2) {
    1.13 +					fprintf(stderr, "-s must be followed by <width>x<height>\n");
    1.14 +					return false;
    1.15 +				}
    1.16 +			} else if(strcmp(argv[i], "-stereo") == 0) {
    1.17 +				stereo = true;
    1.18 +			} else if(strcmp(argv[i], "-level") == 0) {
    1.19 +				level_file = argv[++i];
    1.20 +			} else if(strcmp(argv[i], "-tileset") == 0) {
    1.21 +				tileset_file = argv[++i];
    1.22 +			} else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
    1.23 +				printf("Usage: %s [options]\n", argv[0]);
    1.24 +				printf("  -s WxH              window size (resolution)\n");
    1.25 +				printf("  -level <filename>   specify which level file to load\n");
    1.26 +				printf("  -tileset <filename> specify which tileset to use\n");
    1.27 +				printf("  -stereo             enable stereoscopic rendering\n");
    1.28 +				printf("  -h/-help            print usage information and exit\n");
    1.29 +				exit(0);
    1.30 +
    1.31 +			} else {
    1.32 +				fprintf(stderr, "unrecognized option: %s\n", argv[i]);
    1.33  				return false;
    1.34  			}
    1.35 -		} else if(strcmp(argv[i], "-stereo") == 0) {
    1.36 -			stereo = true;
    1.37 -		} else if(strcmp(argv[i], "-level") == 0) {
    1.38 -			level_file = argv[++i];
    1.39 -		} else if(strcmp(argv[i], "-tileset") == 0) {
    1.40 -			tileset_file = argv[++i];
    1.41 -		} else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
    1.42 -			printf("Usage: %s [options]\n", argv[0]);
    1.43 -			printf("  -s WxH              window size (resolution)\n");
    1.44 -			printf("  -level <filename>   specify which level file to load\n");
    1.45 -			printf("  -tileset <filename> specify which tileset to use\n");
    1.46 -			printf("  -stereo             enable stereoscopic rendering\n");
    1.47 -			printf("  -h/-help            print usage information and exit\n");
    1.48 -			exit(0);
    1.49 -
    1.50  		} else {
    1.51 -			fprintf(stderr, "unrecognized argument: %s\n", argv[i]);
    1.52 -			return false;
    1.53 +			level_file = argv[i];
    1.54  		}
    1.55  	}
    1.56  	return true;