From: Cloudwalk Date: Fri, 30 Jul 2021 18:04:52 +0000 (-0400) Subject: qdefs: Define separate FLOAT_ and DOUBLE_ versions of lossless format and true for... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fe7a27c1f9ee6904eddecd54f0fcae461806d43c;p=xonotic%2Fdarkplaces.git qdefs: Define separate FLOAT_ and DOUBLE_ versions of lossless format and true for int. Define PRVM_ prefixed aliases for either --- diff --git a/progs.h b/progs.h index 79b5fc79..466521a7 100644 --- 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 diff --git a/prvm_edict.c b/prvm_edict.c index 78bcdabc..ea839275 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -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); diff --git a/prvm_execprogram.h b/prvm_execprogram.h index 988e913a..d9331426 100644 --- a/prvm_execprogram.h +++ b/prvm_execprogram.h @@ -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 c0e4c14e..fb942a45 100644 --- a/qdefs.h +++ b/qdefs.h @@ -195,18 +195,10 @@ #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