Write fp values to saved games with enough precision.

That is, enough precision to uniquely identify the fp values. No drifts!
This commit is contained in:
Bill Currie 2013-01-08 18:50:44 +09:00
parent d6bb5bec86
commit b096a0242e
2 changed files with 6 additions and 5 deletions

View file

@ -97,16 +97,16 @@ PR_UglyValueString (progs_t *pr, etype_t type, pr_type_t *val)
dstring_copystr (line, "void");
break;
case ev_float:
dsprintf (line, "%f", val->float_var);
dsprintf (line, "%.8e", val->float_var);
break;
case ev_integer:
dsprintf (line, "%d", val->integer_var);
break;
case ev_vector:
dsprintf (line, "%f %f %f", VectorExpand (val->vector_var));
dsprintf (line, "%.8e %.8e %.8e", VectorExpand (val->vector_var));
break;
case ev_quat:
dsprintf (line, "%f %f %f %f", QuatExpand (val->quat_var));
dsprintf (line, "%.8e %.8e %.8e %.8e", QuatExpand (val->quat_var));
break;
default:
dsprintf (line, "bad type %i", type);

View file

@ -398,7 +398,7 @@ spawn_parms_array (void)
const char *parm;
for (i = 0; i < NUM_SPAWN_PARMS; i++) {
parm = va ("%f", svs.clients->spawn_parms[i]);
parm = va ("%.8e", svs.clients->spawn_parms[i]);
PL_A_AddObject (parms, PL_NewString (parm));
}
return parms;
@ -447,7 +447,8 @@ game_dict (void)
PL_D_AddObject (game, "current_skill",
PL_NewString (va ("%d", current_skill)));
PL_D_AddObject (game, "name", PL_NewString (sv.name));
PL_D_AddObject (game, "time", PL_NewString (va ("%f", sv.time)));
// sv.time is a double, so it gets 16 digits after the .
PL_D_AddObject (game, "time", PL_NewString (va ("%.16e", sv.time)));
PL_D_AddObject (game, "lightstyles", lightstyles_array ());
PL_D_AddObject (game, "globals", ED_GlobalsDict (&sv_pr_state));
PL_D_AddObject (game, "entities", entities_array ());