summaryrefslogtreecommitdiff
path: root/clld.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2019-09-28 15:52:41 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2019-09-28 15:52:41 -0400
commit7e13ed9e280faa0a5267a9e2a76ad57a26941dab (patch)
tree9298dcc3ea77814ba34e1e814bd6bd15164c0db9 /clld.c
Initial Commit.
Diffstat (limited to 'clld.c')
-rw-r--r--clld.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/clld.c b/clld.c
new file mode 100644
index 0000000..70e111d
--- /dev/null
+++ b/clld.c
@@ -0,0 +1,106 @@
+/*
+ * Main Program file.
+ *
+ * Platform: Anything with a C compiler.
+ * Author: mr b0nk 500 <b0nk@mrb0nk500.xyz>
+ * Notes: Who would even use this kind of collision checker?
+ * Created: September 27, 2019 @ 09:25PM
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* Collision type */
+int colltype = -1;
+
+/* Position type */
+int postype = -1;
+
+/* Level of verbosity. */
+int verbose = 0;
+
+
+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 (0-2).\n"
+ " -p<type> Force the position type to be\n"
+ " the specified type (0-2).\n"
+ " -v[level] Sets the verbosity level (0-3).\n"
+ );
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ struct pos {
+ int x;
+ int y;
+ int z;
+ double fx;
+ double fy;
+ double fz;
+ };
+ struct pos cursor;
+ struct pos floor;
+ struct pos tmp;
+
+ char *buf = NULL;
+ size_t size;
+
+ getline(&buf, &size, stdin);
+ if (postype == -1)
+ postype = atoi(strtok(buf, "\n"));
+
+ buf = NULL;
+ getline(&buf, &size, stdin);
+
+ if (colltype == -1)
+ colltype = atoi(strtok(buf, "\n"));
+
+ printf("%i\n%i\n", postype, colltype);
+ for (int i = 0; i <= 1; i++) {
+ char *tmp2;
+ buf = NULL;
+ getline(&buf, &size, stdin);
+ if (strchr(buf, '.') != NULL) {
+ tmp.fx = atof(strtok(buf,","));
+ tmp.fy = atof(strtok(NULL,","));
+ tmp2 = strtok(NULL, "\n");
+ if (tmp2 == NULL)
+ tmp.fz = atof(strtok(NULL,"\0"));
+ else
+ tmp.fz = atof(tmp2);
+ if (!i) {
+ cursor = tmp;
+ printf ("%07.06f, %07.06f, %07.06f\n", cursor.fx, cursor.fy, cursor.fz);
+ } else {
+ floor = tmp;
+ printf ("%07.06f, %07.06f, %07.06f\n", floor.fx, floor.fy, floor.fz);
+ }
+ } else {
+ tmp.x = atoi(strtok(buf,","));
+ tmp.y = atoi(strtok(NULL,","));
+ tmp2 = strtok(NULL, "\n");
+ if (tmp2 == NULL)
+ tmp.z = atoi(strtok(NULL, "\0"));
+ else
+ tmp.z = atoi(tmp2);
+ if (!i) {
+ cursor = tmp;
+ printf ("%i, %i, %i\n", cursor.x, cursor.y, cursor.z);
+ } else {
+ floor = tmp;
+ printf ("%i, %i, %i\n", floor.x, floor.y, floor.z);
+ }
+ }
+ }
+
+ free(buf);
+ fflush(stdout);
+ return 0;
+}