]> git.lizzy.rs Git - dragonblocks_alpha.git/blobdiff - src/common/init.c
Improve diagnostics when invoked from incorrect path
[dragonblocks_alpha.git] / src / common / init.c
diff --git a/src/common/init.c b/src/common/init.c
new file mode 100644 (file)
index 0000000..2be0bea
--- /dev/null
@@ -0,0 +1,27 @@
+#define _GNU_SOURCE // don't worry, GNU extensions are only used when available
+#include <dragonnet/init.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+void dragonblocks_init(int argc)
+{
+#ifdef __GLIBC__ // check whether bloat is enabled
+       pthread_setname_np(pthread_self(), "main");
+#endif // __GLIBC__
+
+       struct stat sb;
+       if (stat(ASSET_PATH, &sb) != 0 || !S_ISDIR(sb.st_mode)) {
+               fprintf(stderr, "[error] asset directory not found at %s, "
+                       "invoke game from correct path\n", ASSET_PATH);
+               exit(EXIT_FAILURE);
+       }
+
+       if (argc < 2) {
+               fprintf(stderr, "[error] missing address\n");
+               exit(EXIT_FAILURE);
+       }
+
+       dragonnet_init();
+}