]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - exec.c
Use $(PREFIX)
[xonotic/gmqcc.git] / exec.c
diff --git a/exec.c b/exec.c
index 82cd3d7efff1c556e64c957bb93bb1fa92d5e3b3..101901d86c24fff8d5a61fe132d808b489e17e90 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -51,7 +51,7 @@ static void qcvmerror(qc_program *prog, const char *fmt, ...)
     putchar('\n');
 }
 
-qc_program* prog_load(const char *filename)
+qc_program* prog_load(const char *filename, bool skipversion)
 {
     qc_program   *prog;
     prog_header   header;
@@ -66,7 +66,7 @@ qc_program* prog_load(const char *filename)
         return NULL;
     }
 
-    if (header.version != 6) {
+    if (!skipversion && header.version != 6) {
         loaderror("header says this is a version %i progs, we need version 6\n", header.version);
         file_close(file);
         return NULL;
@@ -609,10 +609,16 @@ const char *type_name[TYPE_COUNT] = {
     "field",
     "function",
     "pointer",
-#if 0
     "integer",
-#endif
-    "variant"
+
+    "variant",
+
+    "struct",
+    "union",
+    "array",
+
+    "nil",
+    "noexpr"
 };
 
 typedef struct {
@@ -1074,7 +1080,7 @@ int main(int argc, char **argv)
         exit(1);
     }
 
-    prog = prog_load(progsfile);
+    prog = prog_load(progsfile, noexec);
     if (!prog) {
         printf("failed to load program '%s'\n", progsfile);
         exit(1);
@@ -1276,15 +1282,21 @@ while (1) {
                           OPA->vector[2]*OPB->vector[2];
             break;
         case INSTR_MUL_FV:
-            OPC->vector[0] = OPA->_float * OPB->vector[0];
-            OPC->vector[1] = OPA->_float * OPB->vector[1];
-            OPC->vector[2] = OPA->_float * OPB->vector[2];
+        {
+            qcfloat f = OPA->_float;
+            OPC->vector[0] = f * OPB->vector[0];
+            OPC->vector[1] = f * OPB->vector[1];
+            OPC->vector[2] = f * OPB->vector[2];
             break;
+        }
         case INSTR_MUL_VF:
-            OPC->vector[0] = OPB->_float * OPA->vector[0];
-            OPC->vector[1] = OPB->_float * OPA->vector[1];
-            OPC->vector[2] = OPB->_float * OPA->vector[2];
+        {
+            qcfloat f = OPB->_float;
+            OPC->vector[0] = f * OPA->vector[0];
+            OPC->vector[1] = f * OPA->vector[1];
+            OPC->vector[2] = f * OPA->vector[2];
             break;
+        }
         case INSTR_DIV_F:
             if (OPB->_float != 0.0f)
                 OPC->_float = OPA->_float / OPB->_float;
@@ -1390,9 +1402,10 @@ while (1) {
                 goto cleanup;
             }
             ed = prog_getedict(prog, OPA->edict);
-            OPC->ivector[0] = ((qcany*)( ((qcint*)ed) + OPB->_int ))->ivector[0];
-            OPC->ivector[1] = ((qcany*)( ((qcint*)ed) + OPB->_int ))->ivector[1];
-            OPC->ivector[2] = ((qcany*)( ((qcint*)ed) + OPB->_int ))->ivector[2];
+            ptr = (qcany*)( ((qcint*)ed) + OPB->_int );
+            OPC->ivector[0] = ptr->ivector[0];
+            OPC->ivector[1] = ptr->ivector[1];
+            OPC->ivector[2] = ptr->ivector[2];
             break;
 
         case INSTR_ADDRESS: