File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313
1414#define USAGE_MESSAGE "Usage: raycaster [-h] [-c] mapname\n"
1515#define DESCRIPTION_MESSAGE "Runs the raycaster, loading the specified map file.\n"
16+ #define NO_MAP_MESSAGE "Must specify a map file to load!\n"
1617
1718float min (float v1 , float v2 ) {
1819 return v1 < v2 ? v1 : v2 ;
@@ -22,12 +23,12 @@ int main(int argc, char* argv[]) {
2223 // Argument handling
2324 if (argc <= 1 ) {
2425 fprintf (stderr , USAGE_MESSAGE );
25- fprintf (stderr , "Must specify a map file to load!\n" );
26+ fprintf (stderr , NO_MAP_MESSAGE );
2627
2728 return EXIT_FAILURE ;
2829 }
2930
30- const char * map_name ;
31+ const char * map_name = NULL ;
3132 bool uncapped = false;
3233 for (int i = 1 ; i < argc ; i ++ ) {
3334 if (strncmp (argv [i ], "-h" , 2 ) == 0 ) {
@@ -40,6 +41,12 @@ int main(int argc, char* argv[]) {
4041 map_name = argv [i ];
4142 }
4243 }
44+ if (map_name == NULL ) {
45+ fprintf (stderr , USAGE_MESSAGE );
46+ fprintf (stderr , NO_MAP_MESSAGE );
47+
48+ return EXIT_FAILURE ;
49+ }
4350
4451 // Tell the window to use vsync when capping fps and work on high DPI displays
4552 if (uncapped ) {
You can’t perform that action at this time.
0 commit comments