]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
qdefs: Define separate FLOAT_ and DOUBLE_ versions of lossless format and true for...
authorCloudwalk <cloudwalk009@gmail.com>
Fri, 30 Jul 2021 18:04:52 +0000 (14:04 -0400)
committerCloudwalk <cloudwalk009@gmail.com>
Fri, 30 Jul 2021 18:04:52 +0000 (14:04 -0400)
progs.h
prvm_edict.c
prvm_execprogram.h
qdefs.h

diff --git a/progs.h b/progs.h
index 79b5fc791c5e7ecbb7c3e3bb40c75640b1984b73..466521a7530cdc1cc3cd1f7e9b6a53e073c7c65b 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -21,10 +21,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef PROGS_H
 #define PROGS_H
 #include "pr_comp.h"                   // defs shared with qcc
+#include "qtypes.h"
+
 
 #define ENTITYGRIDAREAS 16
 #define MAX_ENTITYCLUSTERS 16
 
+#ifdef PRVM_64
+#define PRVM_FLOAT_IS_TRUE_FOR_INT(x) DOUBLE_IS_TRUE_FOR_INT(x)
+#define PRVM_FLOAT_LOSSLESS_FORMAT DOUBLE_LOSSLESS_FORMAT
+#define PRVM_VECTOR_LOSSLESS_FORMAT DOUBLE_VECTOR_LOSSLESS_FORMAT
+#else
+#define PRVM_FLOAT_IS_TRUE_FOR_INT(x) FLOAT_IS_TRUE_FOR_INT(x)
+#define PRVM_FLOAT_LOSSLESS_FORMAT FLOAT_LOSSLESS_FORMAT
+#define PRVM_VECTOR_LOSSLESS_FORMAT FLOAT_VECTOR_LOSSLESS_FORMAT
+#endif
+
 #ifdef USEODE
 #define        GEOMTYPE_NONE      -1
 #define        GEOMTYPE_SOLID      0
index 78bcdabcc5dcbf3cfce9a7384136290ff8d74326..ea8392751e9760f2aff73c0881557e1f7c608557 100644 (file)
@@ -474,11 +474,11 @@ static char *PRVM_ValueString (prvm_prog_t *prog, etype_t type, prvm_eval_t *val
                break;
        case ev_float:
                // LadyHavoc: changed from %5.1f to %10.4f
-               dpsnprintf (line, linelength, FLOAT_LOSSLESS_FORMAT, val->_float);
+               dpsnprintf (line, linelength, PRVM_FLOAT_LOSSLESS_FORMAT, val->_float);
                break;
        case ev_vector:
                // LadyHavoc: changed from %5.1f to %10.4f
-               dpsnprintf (line, linelength, "'" VECTOR_LOSSLESS_FORMAT "'", val->vector[0], val->vector[1], val->vector[2]);
+               dpsnprintf (line, linelength, "'" PRVM_VECTOR_LOSSLESS_FORMAT "'", val->vector[0], val->vector[1], val->vector[2]);
                break;
        case ev_pointer:
                dpsnprintf (line, linelength, "pointer");
@@ -567,10 +567,10 @@ char *PRVM_UglyValueString (prvm_prog_t *prog, etype_t type, prvm_eval_t *val, c
                dpsnprintf (line, linelength, "void");
                break;
        case ev_float:
-               dpsnprintf (line, linelength, FLOAT_LOSSLESS_FORMAT, val->_float);
+               dpsnprintf (line, linelength, PRVM_FLOAT_LOSSLESS_FORMAT, val->_float);
                break;
        case ev_vector:
-               dpsnprintf (line, linelength, VECTOR_LOSSLESS_FORMAT, val->vector[0], val->vector[1], val->vector[2]);
+               dpsnprintf (line, linelength, PRVM_VECTOR_LOSSLESS_FORMAT, val->vector[0], val->vector[1], val->vector[2]);
                break;
        default:
                dpsnprintf (line, linelength, "bad type %i", type);
index 988e913a7b2b525692f5cc1e0b27e496744e6063..d9331426cf6e11ee873bf8ab3f34af3f19d6270e 100644 (file)
@@ -404,13 +404,13 @@ int i;
                                OPC->_float = OPA->_float < OPB->_float;
                                DISPATCH_OPCODE();
                        HANDLE_OPCODE(OP_AND):
-                               OPC->_float = FLOAT_IS_TRUE_FOR_INT(OPA->_int) && FLOAT_IS_TRUE_FOR_INT(OPB->_int); // TODO change this back to float, and add AND_I to be used by fteqcc for anything not a float
+                               OPC->_float = PRVM_FLOAT_IS_TRUE_FOR_INT(OPA->_int) && PRVM_FLOAT_IS_TRUE_FOR_INT(OPB->_int); // TODO change this back to float, and add AND_I to be used by fteqcc for anything not a float
                                DISPATCH_OPCODE();
                        HANDLE_OPCODE(OP_OR):
-                               OPC->_float = FLOAT_IS_TRUE_FOR_INT(OPA->_int) || FLOAT_IS_TRUE_FOR_INT(OPB->_int); // TODO change this back to float, and add OR_I to be used by fteqcc for anything not a float
+                               OPC->_float = PRVM_FLOAT_IS_TRUE_FOR_INT(OPA->_int) || PRVM_FLOAT_IS_TRUE_FOR_INT(OPB->_int); // TODO change this back to float, and add OR_I to be used by fteqcc for anything not a float
                                DISPATCH_OPCODE();
                        HANDLE_OPCODE(OP_NOT_F):
-                               OPC->_float = !FLOAT_IS_TRUE_FOR_INT(OPA->_int);
+                               OPC->_float = !PRVM_FLOAT_IS_TRUE_FOR_INT(OPA->_int);
                                DISPATCH_OPCODE();
                        HANDLE_OPCODE(OP_NOT_V):
                                OPC->_float = !OPA->vector[0] && !OPA->vector[1] && !OPA->vector[2];
diff --git a/qdefs.h b/qdefs.h
index c0e4c14ec5932eba5bdfc234777d44d5958254be..fb942a4543126e6a99c0986e49946967d329d0f5 100644 (file)
--- a/qdefs.h
+++ b/qdefs.h
 #define DOUBLE_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFFFFFFFFFF) // also match "negative zero" doubles of value 0x8000000000000000
 #define DOUBLE_LOSSLESS_FORMAT "%.17g"
 #define DOUBLE_VECTOR_LOSSLESS_FORMAT "%.17g %.17g %.17g"
+
 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFF) // also match "negative zero" floats of value 0x80000000
 #define FLOAT_LOSSLESS_FORMAT "%.9g"
 #define FLOAT_VECTOR_LOSSLESS_FORMAT "%.9g %.9g %.9g"
-#ifdef PRVM_64
-#define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFFFFFFFFFF) // also match "negative zero" doubles of value 0x8000000000000000
-#define FLOAT_LOSSLESS_FORMAT "%.17g"
-#define VECTOR_LOSSLESS_FORMAT "%.17g %.17g %.17g"
-#else
-#define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFF) // also match "negative zero" floats of value 0x80000000
-#define FLOAT_LOSSLESS_FORMAT "%.9g"
-#define VECTOR_LOSSLESS_FORMAT "%.9g %.9g %.9g"
-#endif
 
 // originally this was _MSC_VER
 // but here we want to test the system libc, which on win32 is borked, and NOT the compiler