]> git.lizzy.rs Git - dragonblocks_alpha.git/blob - src/common/init.c
Improve diagnostics when invoked from incorrect path
[dragonblocks_alpha.git] / src / common / init.c
1 #define _GNU_SOURCE // don't worry, GNU extensions are only used when available
2 #include <dragonnet/init.h>
3 #include <pthread.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <sys/stat.h>
7
8 void dragonblocks_init(int argc)
9 {
10 #ifdef __GLIBC__ // check whether bloat is enabled
11         pthread_setname_np(pthread_self(), "main");
12 #endif // __GLIBC__
13
14         struct stat sb;
15         if (stat(ASSET_PATH, &sb) != 0 || !S_ISDIR(sb.st_mode)) {
16                 fprintf(stderr, "[error] asset directory not found at %s, "
17                         "invoke game from correct path\n", ASSET_PATH);
18                 exit(EXIT_FAILURE);
19         }
20
21         if (argc < 2) {
22                 fprintf(stderr, "[error] missing address\n");
23                 exit(EXIT_FAILURE);
24         }
25
26         dragonnet_init();
27 }