remove time_t from struct you (trunk only)

There was an issue reported where save files between different
versions of a manufacturer's compiler were incompatible because the time_t
ubirthday field was changed from 32 bits to 64 bits.

32 bit time_t implementations will break at 19:14:07 on  January 18, 2038.
64 bit time_t implementations will break at 23:59:59 on December 31, 3000.

This removes the dependency on the size of time_t from the save file.
The ubirthday field is no longer embedded in struct you.
This also adds two general purpose routines to hacklib.c, one to convert a time
value to a 14 character char representation and the other to convert that
back to time_t. Those are used by the save/restore routines.

This is a savefile breaking change, so editlevel in patchlevel.h was
incremented.
This commit is contained in:
nethack.allison
2007-12-19 03:19:25 +00:00
parent faa3543063
commit d430db0718
15 changed files with 99 additions and 13 deletions

View File

@@ -251,6 +251,7 @@ E NEARDATA anything zeroany; /* init'd and defined in decl.c */
#include "you.h"
E NEARDATA struct you u;
E NEARDATA time_t ubirthday;
#include "onames.h"
#ifndef PM_H /* (pm.h has already been included via youprop.h) */

View File

@@ -850,6 +850,8 @@ E char *FDECL(yymmdd, (time_t));
#endif
E long FDECL(yyyymmdd, (time_t));
E long FDECL(hhmmss, (time_t));
E char *FDECL(yyyymmddhhmmss,(time_t));
E time_t FDECL(time_from_yyyymmddhhmmss, (char *));
E int NDECL(phase_of_the_moon);
E boolean NDECL(friday_13th);
E int NDECL(night);

View File

@@ -13,7 +13,7 @@
* Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files.
*/
#define EDITLEVEL 39
#define EDITLEVEL 40
#define COPYRIGHT_BANNER_A \
"NetHack, Copyright 1985-2007"

View File

@@ -355,8 +355,6 @@ struct you {
#endif
int umortality; /* how many times you died */
int ugrave_arise; /* you die and become something aside from a ghost */
time_t ubirthday; /* real world time when game began */
int weapon_slots; /* unused skill slots */
int skills_advanced; /* # of advances made so far */
xchar skill_record[P_SKILL_LIMIT]; /* skill advancements */