summaryrefslogtreecommitdiff
path: root/clld.c
diff options
context:
space:
mode:
Diffstat (limited to 'clld.c')
-rw-r--r--clld.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/clld.c b/clld.c
index 6d6d3a0..0556bdd 100644
--- a/clld.c
+++ b/clld.c
@@ -7,6 +7,7 @@
* Created: September 27, 2019 @ 09:25PM
*/
+#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -27,15 +28,21 @@ int postype = -1;
/* Level of verbosity. */
int verbose = 0;
+/* Options string. */
+const char *opts = "c:v:h";
+
static int usage() {
printf(
"clld Version MFIYA.\n"
"Usage: clld [options]\n"
"Options:\n"
- " -c<type> Force the collision type to be\n"
- " the specified type (THM=0, AABB=1, PPX=2).\n"
+ " -c[type] Force the collision type to be\n"
+ " the specified type (THM=0, AABB=1).\n"
" -v[level] Sets the verbosity level (0-3).\n"
+ " -h What do you fucking think it does.\n"
+ " Anyways, it brings up this cool help\n"
+ " message.\n"
);
return 0;
}
@@ -90,6 +97,49 @@ int main(int argc, char **argv) {
unsigned int flp : 1;
};
+ int c;
+ /* Enable custom error messages, and optional arguments/ */
+ opterr = 0;
+ /* Get options. */
+ while ((c = getopt(argc, argv, opts)) != -1) {
+ switch(c) {
+ case 'c':
+ colltype = atoi(optarg);
+ break;
+ case 'v':
+ verbose = atoi(optarg);
+ break;
+ case 'h':
+ usage();
+ return 2;
+ case '?':
+ if (isprint(optopt)) {
+ if (optopt == 'c') {
+ fprintf(stderr, "Setting colltype to default.\n");
+ colltype = -1;
+ break;
+ } else if (optopt == 'v') {
+ fprintf(stderr, "Enabling single level verbosity.\n");
+ verbose = 1;
+ break;
+ } else {
+ fprintf(stderr
+ , "The option that you have typed in, which in this case\n"
+ "is -%c, does not exist.\n"
+ "Try looking at the help message, or RTFM, next time.\n"
+ , optopt);
+ }
+ } else {
+ fprintf(stderr
+ , "What the fuck are you trying to type in, a binary blob?\n"
+ "Because of this, clld will exit, so, stop acting like a\n"
+ "jackass.\n");
+ }
+ return -1;
+ default: ;
+ }
+ }
+
/* Create the Cursor, and the Floor */
struct colis cursor;
struct colis floor;
@@ -142,7 +192,7 @@ int main(int argc, char **argv) {
for (unsigned int i = 0; i <tmp.w; i++) {
char *tmptok = strtok((i == 0) ? buf : NULL,",");
tmptok = (tmptok == NULL) ? strtok(NULL,"\n") : tmptok;
- tmp.heightmap[i] = (uint8_t *)((atoi(tmptok) <= tmp.h) ? atoi(tmptok) : tmp.h);
+ tmp.heightmap[i] = (uint8_t)((atoi(tmptok) <= tmp.h) ? atoi(tmptok) : tmp.h);
hmpeak = (atoi(tmptok)+1 >= hmpeak) ? atoi(tmptok)+1 : hmpeak;
}