From: divverent Date: Wed, 11 Apr 2012 13:34:44 +0000 (+0000) Subject: PRVM_64: make savegames precision-loss-less X-Git-Tag: xonotic-v0.7.0~163 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7a1436391f520ba36288eff409fab6019f7cba37;p=xonotic%2Fdarkplaces.git PRVM_64: make savegames precision-loss-less git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11792 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=da3c5a5aa0e139aa68f51bec4d8c0763a99c908e --- diff --git a/clvm_cmds.c b/clvm_cmds.c index c765ca25..e5cfe011 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -1602,7 +1602,7 @@ static void VM_CL_getplayerkey (prvm_prog_t *prog) { vec3_t origin; Matrix4x4_OriginFromMatrix(&e->render.matrix, origin); - dpsnprintf(t, sizeof(t), "%.9g %.9g %.9g", origin[0], origin[1], origin[2]); + dpsnprintf(t, sizeof(t), VECTOR_LOSSLESS_FORMAT, origin[0], origin[1], origin[2]); } } if(!t[0]) diff --git a/prvm_edict.c b/prvm_edict.c index 4d20f1c1..82392bbf 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -526,10 +526,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, "%.9g", val->_float); + dpsnprintf (line, linelength, FLOAT_LOSSLESS_FORMAT, val->_float); break; case ev_vector: - dpsnprintf (line, linelength, "%.9g %.9g %.9g", val->vector[0], val->vector[1], val->vector[2]); + dpsnprintf (line, linelength, VECTOR_LOSSLESS_FORMAT, val->vector[0], val->vector[1], val->vector[2]); break; default: dpsnprintf (line, linelength, "bad type %i", type); diff --git a/quakedef.h b/quakedef.h index a3ba79f3..acd0a909 100644 --- a/quakedef.h +++ b/quakedef.h @@ -553,8 +553,12 @@ void Sys_Shared_Init(void); #ifdef PRVM_64 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFFFFFFFFFF) // also match "negative zero" doubles of value 0x8000000000000000 +#define FLOAT_LOSSLESS_FORMART "%.17g" +#define VECTOR_LOSSLESS_FORMART "%.17g %.17g %.17g" #else #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFF) // also match "negative zero" floats of value 0x80000000 +#define FLOAT_LOSSLESS_FORMART "%.9g" +#define VECTOR_LOSSLESS_FORMART "%.9g %.9g %.9g" #endif #endif