• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

patch投げ用


Commit MetaInfo

Revisionca836324a1540c6dc76f7e3ecc212bf66fc1d36e (tree)
Time2016-02-10 22:21:32
AuthorSHIRAKATA Kentaro <argrath@ub32...>
CommiterSHIRAKATA Kentaro

Log Message

fix C360-19

Change Summary

Incremental Difference

--- a/include/you.h
+++ b/include/you.h
@@ -68,10 +68,11 @@ struct u_achieve {
6868 };
6969
7070 struct u_realtime {
71- long
72- realtime; /* actual playing time up until the last restore, seconds */
73- time_t restored; /* time the game was started or restored */
74- time_t endtime;
71+ long realtime; /* accumulated playing time in seconds */
72+ time_t start_timing; /* time game was started or restored or 'realtime'
73+ was last updated (savegamestate for checkpoint) */
74+ time_t finish_time; /* end of 'realtime' interval: time of save or
75+ end of game; used for topten/logfile/xlogfile */
7576 };
7677
7778 /* KMH, conduct --
--- a/src/allmain.c
+++ b/src/allmain.c
@@ -587,18 +587,13 @@ newgame()
587587 com_pager(1);
588588 }
589589
590+ urealtime.realtime = 0L;
591+ urealtime.start_timing = getnow();
590592 #ifdef INSURANCE
591593 save_currentstate();
592594 #endif
593595 program_state.something_worth_saving++; /* useful data now exists */
594596
595- urealtime.realtime = 0L;
596-#if defined(BSD) && !defined(POSIX_TYPES)
597- (void) time((long *) &urealtime.restored);
598-#else
599- (void) time(&urealtime.restored);
600-#endif
601-
602597 /* Success! */
603598 welcome(TRUE);
604599 return;
--- a/src/end.c
+++ b/src/end.c
@@ -951,8 +951,8 @@ int how;
951951 /* remember time of death here instead of having bones, rip, and
952952 topten figure it out separately and possibly getting different
953953 time or even day if player is slow responding to --More-- */
954- endtime = getnow();
955- urealtime.realtime += (long) (endtime - urealtime.restored);
954+ urealtime.finish_time = endtime = getnow();
955+ urealtime.realtime += (long) (endtime - urealtime.start_timing);
956956
957957 /* Sometimes you die on the first move. Life's not fair.
958958 * On those rare occasions you get hosed immediately, go out
--- a/src/restore.c
+++ b/src/restore.c
@@ -568,13 +568,10 @@ unsigned int *stuckid, *steedid;
568568 foo = time_from_yyyymmddhhmmss(timebuf);
569569
570570 ReadTimebuf(ubirthday);
571- mread(fd, &urealtime.realtime, sizeof(urealtime.realtime));
572- ReadTimebuf(urealtime.restored);
573-#if defined(BSD) && !defined(POSIX_TYPES)
574- (void) time((long *) &urealtime.restored);
575-#else
576- (void) time(&urealtime.restored);
577-#endif
571+ mread(fd, &urealtime.realtime, sizeof urealtime.realtime);
572+ ReadTimebuf(urealtime.start_timing); /** [not used] **/
573+ /* current time is the time to use for next urealtime.realtime update */
574+ urealtime.start_timing = getnow();
578575
579576 set_uasmon();
580577 #ifdef CLIPPING
--- a/src/save.c
+++ b/src/save.c
@@ -289,12 +289,15 @@ register int fd, mode;
289289 #ifdef SYSFLAGS
290290 bwrite(fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
291291 #endif
292- urealtime.realtime += (long) (getnow() - urealtime.restored);
292+ urealtime.finish_time = getnow();
293+ urealtime.realtime += (long) (urealtime.finish_time
294+ - urealtime.start_timing);
293295 bwrite(fd, (genericptr_t) &u, sizeof(struct you));
294296 bwrite(fd, yyyymmddhhmmss(ubirthday), 14);
295- bwrite(fd, (genericptr_t) &urealtime.realtime,
296- sizeof(urealtime.realtime));
297- bwrite(fd, yyyymmddhhmmss(urealtime.restored), 14);
297+ bwrite(fd, (genericptr_t) &urealtime.realtime, sizeof urealtime.realtime);
298+ bwrite(fd, yyyymmddhhmmss(urealtime.start_timing), 14); /** Why? **/
299+ /* this is the value to use for the next update of urealtime.realtime */
300+ urealtime.start_timing = urealtime.finish_time;
298301 save_killers(fd, mode);
299302
300303 /* must come before migrating_objs and migrating_mons are freed */
--- a/src/topten.c
+++ b/src/topten.c
@@ -330,8 +330,8 @@ struct toptenentry *tt;
330330 Fprintf(rfile, "%cconduct=0x%lx%cturns=%ld%cachieve=0x%lx", XLOG_SEP,
331331 encodeconduct(), XLOG_SEP, moves, XLOG_SEP, encodeachieve());
332332 Fprintf(rfile, "%crealtime=%ld%cstarttime=%ld%cendtime=%ld", XLOG_SEP,
333- (long) urealtime.realtime, XLOG_SEP, (long) ubirthday, XLOG_SEP,
334- (long) urealtime.endtime);
333+ (long) urealtime.realtime, XLOG_SEP,
334+ (long) ubirthday, XLOG_SEP, (long) urealtime.finish_time);
335335 Fprintf(rfile, "%cgender0=%s%calign0=%s", XLOG_SEP,
336336 genders[flags.initgend].filecode, XLOG_SEP,
337337 aligns[1 - u.ualignbase[A_ORIGINAL]].filecode);
@@ -516,7 +516,6 @@ time_t when;
516516 t0->birthdate = yyyymmdd(ubirthday);
517517 t0->deathdate = yyyymmdd(when);
518518 t0->tt_next = 0;
519- urealtime.endtime = when;
520519 #ifdef UPDATE_RECORD_IN_PLACE
521520 t0->fpos = -1L;
522521 #endif