]> git.pond.sub.org Git - empserver/blob - src/scripts/nightly/patches/All/emptime.c.patch
Log out player when time per day is exceeded
[empserver] / src / scripts / nightly / patches / All / emptime.c.patch
1 diff --git a/include/emptime.h b/include/emptime.h
2 new file mode 100644
3 index 0000000..a83b29d
4 --- /dev/null
5 +++ b/include/emptime.h
6 @@ -0,0 +1,42 @@
7 +/*
8 + *  Empire - A multi-player, client/server Internet based war game.
9 + *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
10 + *                           Ken Stevens, Steve McClure
11 + *
12 + *  This program is free software; you can redistribute it and/or modify
13 + *  it under the terms of the GNU General Public License as published by
14 + *  the Free Software Foundation; either version 2 of the License, or
15 + *  (at your option) any later version.
16 + *
17 + *  This program is distributed in the hope that it will be useful,
18 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 + *  GNU General Public License for more details.
21 + *
22 + *  You should have received a copy of the GNU General Public License
23 + *  along with this program; if not, write to the Free Software
24 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25 + *
26 + *  ---
27 + *
28 + *  See files README, COPYING and CREDITS in the root of the source
29 + *  tree for related information and legal notices.  It is expected
30 + *  that future projects/authors will amend these files as needed.
31 + *
32 + *  ---
33 + *
34 + *  emptime.h: Time functions for regression testing and
35 + *             replaying journals.
36 + *
37 + *  Known contributors to this file:
38 + *     Ron Koenderink, 2008
39 + */
40 +
41 +#ifndef EMPTIME_H
42 +#define EMPTIME_H
43 +
44 +#include <time.h>
45 +
46 +#define empire_time(expr) emp_time((expr), __FUNCTION__)
47 +extern time_t emp_time(time_t *, const char []);
48 +#endif
49 diff --git a/include/commands.h b/include/commands.h
50 index 594d263..0b22f09 100644
51 --- a/include/commands.h
52 +++ b/include/commands.h
53 @@ -34,6 +34,7 @@
54  #ifndef COMMANDS_H
55  #define COMMANDS_H
56  
57 +#include "emptime.h"
58  #include "file.h"
59  #include "nat.h"
60  #include "player.h"
61 diff --git a/src/lib/commands/buy.c b/src/lib/commands/buy.c
62 index 7e4daf0..6e244cf 100644
63 --- a/src/lib/commands/buy.c
64 +++ b/src/lib/commands/buy.c
65 @@ -170,7 +170,7 @@ buy(void)
66      if (bid > 0.04 + comm.com_price) {
67         comm.com_price = bid;
68         /* Add five minutes to the time if less than 5 minutes */
69 -       time(&now);
70 +       empire_time(&now);
71         if (((MARK_DELAY - (now - comm.com_markettime)) < 300) &&
72             comm.com_maxbidder != player->cnum) {
73             comm.com_markettime += 300;
74 @@ -212,7 +212,7 @@ check_market(void)
75      for (n = 0; getcomm(n, &comm); n++) {
76         if (comm.com_maxbidder == comm.com_owner || comm.com_owner == 0)
77             continue;
78 -       (void)time(&now);
79 +       (void)empire_time(&now);
80         tleft = MARK_DELAY / 3600.0 - (now - comm.com_markettime) / 3600.0;
81         if (tleft < 0)
82             tleft = 0;
83 diff --git a/src/lib/commands/coll.c b/src/lib/commands/coll.c
84 index 3fcb48f..2183d98 100644
85 --- a/src/lib/commands/coll.c
86 +++ b/src/lib/commands/coll.c
87 @@ -71,7 +71,7 @@ coll(void)
88      }
89      /* If we got here, we check to see if it's been defaulted on.  We
90         already know it's owed to this player. */
91 -    owed = loan_owed(&loan, time(&now));
92 +    owed = loan_owed(&loan, empire_time(&now));
93      if (now <= loan.l_duedate) {
94         pr("There has been no default on loan %d\n", arg);
95         return RET_FAIL;
96 @@ -124,7 +124,7 @@ coll(void)
97         caploss(&sect, loan.l_lonee, "that was %s's capital!\n");
98      putsect(&sect);
99      nreport(player->cnum, N_SEIZE_SECT, loan.l_lonee, 1);
100 -    owed = loan_owed(&loan, time(&now));
101 +    owed = loan_owed(&loan, empire_time(&now));
102      if (pay >= owed) {
103         loan.l_status = LS_FREE;
104         loan.l_ldur = 0;
105 @@ -135,7 +135,7 @@ coll(void)
106            xyas(sect.sct_x, sect.sct_y, loan.l_lonee), arg);
107         pr("That loan is now considered repaid.\n");
108      } else {
109 -       (void)time(&loan.l_lastpay);
110 +       (void)empire_time(&loan.l_lastpay);
111         owed -= pay;
112         loan.l_amtdue = (long)owed;
113         pay += loan.l_amtpaid;
114 diff --git a/src/lib/commands/cons.c b/src/lib/commands/cons.c
115 index d67e64e..30d1ca1 100644
116 --- a/src/lib/commands/cons.c
117 +++ b/src/lib/commands/cons.c
118 @@ -229,7 +229,7 @@ loan_accept(struct ltcomstr *ltcp)
119      putnat(lender);
120      player->dolcost -= lp->l_amtdue;
121      lp->l_amtpaid = 0;
122 -    (void)time(&lp->l_lastpay);
123 +    (void)empire_time(&lp->l_lastpay);
124      lp->l_duedate = lp->l_ldur * 86400 + lp->l_lastpay;
125      lp->l_status = LS_SIGNED;
126      if (!putloan(ltcp->num, lp)) {
127 diff --git a/src/lib/commands/dump.c b/src/lib/commands/dump.c
128 index 3ad1f21..fa009f0 100644
129 --- a/src/lib/commands/dump.c
130 +++ b/src/lib/commands/dump.c
131 @@ -241,7 +241,7 @@ dump(void)
132  
133      if (player->god)
134         pr("   ");
135 -    time(&now);
136 +    empire_time(&now);
137      pr("DUMP SECTOR %ld\n", (long)now);
138      if (player->god)
139         pr("own ");
140 diff --git a/src/lib/commands/fina.c b/src/lib/commands/fina.c
141 index a6add31..e458c28 100644
142 --- a/src/lib/commands/fina.c
143 +++ b/src/lib/commands/fina.c
144 @@ -55,7 +55,7 @@ fina(void)
145      }
146      if (!snxtitem(&ni, EF_LOAN, "*", NULL))
147         return RET_SYN;
148 -    (void)time(&now);
149 +    (void)empire_time(&now);
150      pr("\n");
151      pr("             -= Empire Financial Status Report =- \n");
152      pr("                  ");
153 diff --git a/src/lib/commands/flash.c b/src/lib/commands/flash.c
154 index 787e4a4..8517ccb 100644
155 --- a/src/lib/commands/flash.c
156 +++ b/src/lib/commands/flash.c
157 @@ -122,7 +122,7 @@ sendmessage(struct natstr *us, struct natstr *to, char *message, int verbose)
158      int sent = 0;
159      struct natstr *wto;
160  
161 -    time(&now);
162 +    empire_time(&now);
163      tm = localtime(&now);
164      for (other = player_next(0); other != 0; other = player_next(other)) {
165         if (other->state != PS_PLAYING)
166 diff --git a/src/lib/commands/head.c b/src/lib/commands/head.c
167 index 2b1c148..e0ddb7a 100644
168 --- a/src/lib/commands/head.c
169 +++ b/src/lib/commands/head.c
170 @@ -66,7 +66,7 @@ head(void)
171      struct nstr_item nstr;
172      int i, n;
173  
174 -    (void)time(&now);
175 +    (void)empire_time(&now);
176      natp = getnatp(player->cnum);
177      if (player->argp[1] != 0 && *player->argp[1] != 0) {
178         news_per = days(atoi(player->argp[1]));
179 diff --git a/src/lib/commands/ldump.c b/src/lib/commands/ldump.c
180 index 930810f..16dcf0c 100644
181 --- a/src/lib/commands/ldump.c
182 +++ b/src/lib/commands/ldump.c
183 @@ -157,7 +157,7 @@ ldump(void)
184  
185      if (player->god)
186         pr("   ");
187 -    time(&now);
188 +    empire_time(&now);
189      pr("DUMP LAND UNITS %ld\n", (long)now);
190      if (player->god)
191         pr("own ");
192 diff --git a/src/lib/commands/lost.c b/src/lib/commands/lost.c
193 index ad76e59..c302f21 100644
194 --- a/src/lib/commands/lost.c
195 +++ b/src/lib/commands/lost.c
196 @@ -51,7 +51,7 @@ lost(void)
197  
198      prdate();
199      nlost = 0;
200 -    time(&now);
201 +    empire_time(&now);
202      pr("DUMP LOST ITEMS %ld\n", (long)now);
203      if (player->god)
204         pr("owner ");
205 diff --git a/src/lib/commands/mark.c b/src/lib/commands/mark.c
206 index f857444..6ec322d 100644
207 --- a/src/lib/commands/mark.c
208 +++ b/src/lib/commands/mark.c
209 @@ -74,7 +74,7 @@ pr_mark(struct comstr *comm)
210      time_t now;
211      double tleft;
212  
213 -    (void)time(&now);
214 +    (void)empire_time(&now);
215      tleft = MARK_DELAY / 3600.0 - (now - comm->com_markettime) / 3600.0;
216      if (tleft < 0.0)
217         tleft = 0.0;
218 diff --git a/src/lib/commands/ndump.c b/src/lib/commands/ndump.c
219 index 927db4f..d081d13 100644
220 --- a/src/lib/commands/ndump.c
221 +++ b/src/lib/commands/ndump.c
222 @@ -50,7 +50,7 @@ ndump(void)
223      prdate();
224      if (player->god)
225         pr("   ");
226 -    time(&now);
227 +    empire_time(&now);
228      pr("DUMP NUKES %ld\n", (long)now);
229      if (player->god)
230         pr("own ");
231 diff --git a/src/lib/commands/news.c b/src/lib/commands/news.c
232 index 0095170..e365be2 100644
233 --- a/src/lib/commands/news.c
234 +++ b/src/lib/commands/news.c
235 @@ -65,7 +65,7 @@ news(void)
236         return RET_SYN;
237      memset(page_has_news, 0, sizeof(page_has_news));
238      memset(sectors_taken, 0, sizeof(sectors_taken));
239 -    (void)time(&now);
240 +    (void)empire_time(&now);
241      natp = getnatp(player->cnum);
242      then = natp->nat_newstim;
243      if (player->argp[1]) {
244 diff --git a/src/lib/commands/offe.c b/src/lib/commands/offe.c
245 index 01570b5..01c40c6 100644
246 --- a/src/lib/commands/offe.c
247 +++ b/src/lib/commands/offe.c
248 @@ -127,7 +127,7 @@ do_treaty(void)
249         pr("Bad treaty duration.\n");
250         return RET_SYN;
251      }
252 -    (void)time(&now);
253 +    (void)empire_time(&now);
254      snxtitem_all(&nstr, EF_TREATY);
255      while (nxtitem(&nstr, &trty)) {
256         if (trty.trt_status == TS_FREE) {
257 @@ -228,7 +228,7 @@ do_loan(void)
258      loan.l_ldur = MIN(dur, 127);
259      loan.l_amtpaid = 0;
260      loan.l_amtdue = amt;
261 -    (void)time(&loan.l_lastpay);
262 +    (void)empire_time(&loan.l_lastpay);
263      loan.l_duedate = loan.l_ldur * SECS_PER_DAY + loan.l_lastpay;
264      if (!putloan(nstr.cur, &loan)) {
265         logerror("do_loan: can't save loan");
266 diff --git a/src/lib/commands/pdump.c b/src/lib/commands/pdump.c
267 index 48f0f4d..51578b1 100644
268 --- a/src/lib/commands/pdump.c
269 +++ b/src/lib/commands/pdump.c
270 @@ -119,7 +119,7 @@ pdump(void)
271  
272      if (player->god)
273         pr("   ");
274 -    time(&now);
275 +    empire_time(&now);
276      pr("DUMP PLANES %ld\n", (long)now);
277      if (player->god)
278         pr("own ");
279 diff --git a/src/lib/commands/play.c b/src/lib/commands/play.c
280 index a4ab28a..eb5c9f6 100644
281 --- a/src/lib/commands/play.c
282 +++ b/src/lib/commands/play.c
283 @@ -96,7 +96,7 @@ play_list(struct player *joe)
284         }
285      }
286  
287 -    time(&now);
288 +    empire_time(&now);
289      pr("%-9.9s %3d %32.32s %2d:%02d %4lds",
290         cname(joe->cnum),
291         joe->cnum,
292 diff --git a/src/lib/commands/powe.c b/src/lib/commands/powe.c
293 index 2367002..74cf745 100644
294 --- a/src/lib/commands/powe.c
295 +++ b/src/lib/commands/powe.c
296 @@ -87,7 +87,7 @@ powe(void)
297                 pr("\n  power new is disabled, using the last report.\n\n");
298             else {
299                 gen_power(powbuf, save);
300 -               pow_time = time(NULL);
301 +               pow_time = empire_time(NULL);
302                 power_generated = 1;
303             }
304         }
305 diff --git a/src/lib/commands/rea.c b/src/lib/commands/rea.c
306 index 5de2bb2..f9d7c71 100644
307 --- a/src/lib/commands/rea.c
308 +++ b/src/lib/commands/rea.c
309 @@ -76,7 +76,7 @@ rea(void)
310      int readit;
311      int may_delete = 1; /* may messages be deleted? */
312  
313 -    now = time(NULL);
314 +    now = empire_time(NULL);
315  
316      if (*player->argp[0] == 'w') {
317         kind = "announcement";
318 @@ -188,7 +188,7 @@ rea(void)
319                 (void)fflush(telfp);
320                 (void)fseek(telfp, (long)size, SEEK_SET);
321                 size = filelen;
322 -               now = time(NULL);
323 +               now = empire_time(NULL);
324                 goto more;
325             }
326             if (*kind == 'a') {
327 diff --git a/src/lib/commands/repa.c b/src/lib/commands/repa.c
328 index 77a4734..c9b4079 100644
329 --- a/src/lib/commands/repa.c
330 +++ b/src/lib/commands/repa.c
331 @@ -76,7 +76,7 @@ repa(void)
332      if (payment <= 0)
333         return RET_SYN;
334  
335 -    newdue = (long)ceil(loan_owed(&loan, time(&now)) - payment);
336 +    newdue = (long)ceil(loan_owed(&loan, empire_time(&now)) - payment);
337      if (newdue < 0) {
338         pr("You don't owe that much.\n");
339         return RET_FAIL;
340 diff --git a/src/lib/commands/rese.c b/src/lib/commands/rese.c
341 index bfb64d2..7ffcf5d 100644
342 --- a/src/lib/commands/rese.c
343 +++ b/src/lib/commands/rese.c
344 @@ -131,7 +131,7 @@ rese(void)
345         return RET_OK;
346      }
347      comm.com_price = price;
348 -    (void)time(&now);
349 +    (void)empire_time(&now);
350      comm.com_markettime = now;
351      if (!putcomm(number_set, &comm)) {
352         pr("Problems with the commodities file, Call the Deity\n");
353 diff --git a/src/lib/commands/sdump.c b/src/lib/commands/sdump.c
354 index 95899e5..f52bcb9 100644
355 --- a/src/lib/commands/sdump.c
356 +++ b/src/lib/commands/sdump.c
357 @@ -143,7 +143,7 @@ sdump(void)
358  
359      if (player->god)
360         pr("   ");
361 -    time(&now);
362 +    empire_time(&now);
363      pr("DUMP SHIPS %ld\n", (long)now);
364      if (player->god)
365         pr("own ");
366 diff --git a/src/lib/commands/sell.c b/src/lib/commands/sell.c
367 index e6ad4ea..78dd5fc 100644
368 --- a/src/lib/commands/sell.c
369 +++ b/src/lib/commands/sell.c
370 @@ -143,7 +143,7 @@ sell(void)
371             if (comm.com_owner == 0)
372                 break;
373         }
374 -       (void)time(&now);
375 +       (void)empire_time(&now);
376         ef_blank(EF_COMM, ii, &comm);
377         comm.com_type = ip->i_uid;
378         comm.com_owner = player->cnum;
379 diff --git a/src/lib/commands/set.c b/src/lib/commands/set.c
380 index dcda303..e93d7ba 100644
381 --- a/src/lib/commands/set.c
382 +++ b/src/lib/commands/set.c
383 @@ -130,7 +130,7 @@ set(void)
384             trade.trd_owner = player->cnum;
385             trade.trd_unitid = ni.cur;
386             trade.trd_price = price;
387 -           (void)time(&now);
388 +           (void)empire_time(&now);
389             trade.trd_markettime = now;
390             trade.trd_maxbidder = player->cnum;
391             puttrade(id, &trade);
392 diff --git a/src/lib/commands/shark.c b/src/lib/commands/shark.c
393 index ec38b3c..bc4af9a 100644
394 --- a/src/lib/commands/shark.c
395 +++ b/src/lib/commands/shark.c
396 @@ -72,7 +72,7 @@ shark(void)
397         return RET_FAIL;
398      }
399      /* If we got here, we check to see if it's been defaulted on. */
400 -    owed = loan_owed(&loan, time(&now));
401 +    owed = loan_owed(&loan, empire_time(&now));
402      if (now <= loan.l_duedate) {
403         pr("There has been no default on loan %d\n", arg);
404         return RET_FAIL;
405 diff --git a/src/lib/commands/trad.c b/src/lib/commands/trad.c
406 index 5b0af58..e3a440b 100644
407 --- a/src/lib/commands/trad.c
408 +++ b/src/lib/commands/trad.c
409 @@ -97,7 +97,7 @@ trad(void)
410             continue;
411         };
412         pr(" %3d ", ni.cur);
413 -       (void)time(&now);
414 +       (void)empire_time(&now);
415         tleft =
416             TRADE_DELAY / 3600.0 - (now - trade.trd_markettime) / 3600.0;
417         if (tleft < 0.0)
418 @@ -252,7 +252,7 @@ trad(void)
419      }
420      if (bid > trade.trd_price) {
421         /* Add five minutes to the time if less than 5 minutes left. */
422 -       time(&now);
423 +       empire_time(&now);
424         if (((TRADE_DELAY - (now - trade.trd_markettime)) < 300) &&
425             trade.trd_maxbidder != player->cnum)
426             trade.trd_markettime += 300;
427 @@ -306,7 +306,7 @@ check_trade(void)
428         if (trade.trd_owner == trade.trd_maxbidder)
429             continue;
430  
431 -       (void)time(&now);
432 +       (void)empire_time(&now);
433         tleft =
434             TRADE_DELAY / 3600.0 - (now - trade.trd_markettime) / 3600.0;
435         if (tleft < 0.0)
436 diff --git a/src/lib/commands/turn.c b/src/lib/commands/turn.c
437 index 640cef8..d5d9c19 100644
438 --- a/src/lib/commands/turn.c
439 +++ b/src/lib/commands/turn.c
440 @@ -74,7 +74,7 @@ turn(void)
441      else
442         pr("Enter a new message of the day.\n");
443  
444 -    time(&tgm.tel_date);
445 +    empire_time(&tgm.tel_date);
446      tgm.tel_length = getele("The World", msgbuf);
447      if (tgm.tel_length < 0) {
448         pr("Ignored\n");
449 diff --git a/src/lib/commands/upda.c b/src/lib/commands/upda.c
450 index 3ba68a1..0508a63 100644
451 --- a/src/lib/commands/upda.c
452 +++ b/src/lib/commands/upda.c
453 @@ -50,7 +50,7 @@ upda(void)
454      if (updates_disabled())
455         pr("UPDATES ARE DISABLED!\n");
456  
457 -    (void)time(&now);
458 +    (void)empire_time(&now);
459      next = update_time[0];
460      if (next) {
461         pr("\nUpdates occur at times specified by the ETU rates.\n\n");
462 diff --git a/src/lib/commands/vers.c b/src/lib/commands/vers.c
463 index 6e618c0..9e90299 100644
464 --- a/src/lib/commands/vers.c
465 +++ b/src/lib/commands/vers.c
466 @@ -54,7 +54,7 @@ vers(void)
467  {
468      time_t now;
469  
470 -    (void)time(&now);
471 +    (void)empire_time(&now);
472      pr("%s\n\n", version);
473      pr("The following parameters have been set for this game:\n");
474      pr("World size is %d by %d.\n", WORLD_X, WORLD_Y);
475 diff --git a/src/lib/common/file.c b/src/lib/common/file.c
476 index 8b0962f..e289f2f 100644
477 --- a/src/lib/common/file.c
478 +++ b/src/lib/common/file.c
479 @@ -40,6 +40,7 @@
480  #include <sys/stat.h>
481  #include <sys/types.h>
482  #include <unistd.h>
483 +#include "emptime.h"
484  #include "file.h"
485  #include "match.h"
486  #include "misc.h"
487 @@ -424,7 +425,7 @@ do_write(struct empfile *ep, void *buf, int id, int count)
488         return -1;
489  
490      if (ep->flags & EFF_TYPED) {
491 -       now = ep->flags & EFF_NOTIME ? (time_t)-1 : time(NULL);
492 +       now = ep->flags & EFF_NOTIME ? (time_t)-1 : empire_time(NULL);
493         for (i = 0; i < count; i++) {
494             /*
495              * TODO Oopses here could be due to bad data corruption.
496 diff --git a/src/lib/common/game.c b/src/lib/common/game.c
497 index 0800d62..48c5401 100644
498 --- a/src/lib/common/game.c
499 +++ b/src/lib/common/game.c
500 @@ -44,6 +44,7 @@
501  #include <config.h>
502  
503  #include <math.h>
504 +#include "emptime.h"
505  #include "file.h"
506  #include "game.h"
507  #include "optlist.h"
508 @@ -81,7 +82,7 @@ game_note_bsanct(void)
509      struct gamestr *game = getgamep();
510  
511      if (game->game_rt == 0) {
512 -       game->game_rt = time(NULL);
513 +       game->game_rt = empire_time(NULL);
514         putgame();
515      }
516  }
517 @@ -130,7 +131,7 @@ game_tick_tick(void)
518      double dsecs, s_p_etu;
519      int detu;
520  
521 -    dsecs = time(NULL) - game->game_rt;
522 +    dsecs = empire_time(NULL) - game->game_rt;
523      if (CANT_HAPPEN(dsecs < 0))
524         dsecs = 0;
525      s_p_etu = secs_per_etu(game);
526 diff --git a/src/lib/common/wantupd.c b/src/lib/common/wantupd.c
527 index 07c3db0..03e3e0a 100644
528 --- a/src/lib/common/wantupd.c
529 +++ b/src/lib/common/wantupd.c
530 @@ -34,6 +34,7 @@
531  #include <config.h>
532  
533  #include <time.h>
534 +#include "emptime.h"
535  #include "file.h"
536  #include "game.h"
537  #include "misc.h"
538 @@ -102,7 +103,7 @@ demand_check(void)
539  int
540  demandupdatecheck(void)
541  {
542 -    time_t now = time(NULL);
543 +    time_t now = empire_time(NULL);
544  
545      return update_demand == UPD_DEMAND_ASYNC
546         && !updates_disabled()
547 diff --git a/src/lib/common/xdump.c b/src/lib/common/xdump.c
548 index 5d131c9..2ee5f79 100644
549 --- a/src/lib/common/xdump.c
550 +++ b/src/lib/common/xdump.c
551 @@ -77,6 +77,7 @@
552  
553  #include <ctype.h>
554  #include <limits.h>
555 +#include "emptime.h"
556  #include "file.h"
557  #include "nat.h"
558  #include "xdump.h"
559 @@ -263,7 +264,7 @@ xdhdr(struct xdstr *xd, char *name, int meta)
560      } else
561         xd->pr("XDUMP %s%s %ld\n",
562                meta ? "meta " : "",
563 -              name, (long)time(NULL));
564 +              name, (long)empire_time(NULL));
565  }
566  
567  /*
568 diff --git a/src/lib/empthread/lwp.c b/src/lib/empthread/lwp.c
569 index b55f29b..9440a63 100644
570 --- a/src/lib/empthread/lwp.c
571 +++ b/src/lib/empthread/lwp.c
572 @@ -37,6 +37,7 @@
573  #include <signal.h>
574  #include <time.h>
575  #include "empthread.h"
576 +#include "emptime.h"
577  #include "misc.h"
578  
579  /* Flags that were passed to empth_init() */
580 @@ -136,7 +137,7 @@ empth_wait_for_signal(void)
581      for (;;) {
582         err = lwpSigWait(&set, &sig);
583         if (CANT_HAPPEN(err)) {
584 -           time(&now);
585 +           empire_time(&now);
586             lwpSleepUntil(now + 60);
587             continue;
588         }
589 diff --git a/src/lib/empthread/ntthread.c b/src/lib/empthread/ntthread.c
590 index 4056c36..a4c4428 100644
591 --- a/src/lib/empthread/ntthread.c
592 +++ b/src/lib/empthread/ntthread.c
593 @@ -62,6 +62,7 @@
594  #include "unistd.h"
595  #include "misc.h"
596  #include "empthread.h"
597 +#include "emptime.h"
598  #include "prototypes.h"
599  #include "server.h"
600  
601 @@ -637,7 +638,7 @@ empth_wakeup(empth_t *pThread)
602  int
603  empth_sleep(time_t until)
604  {
605 -    long lSec = until - time(0) > 0 ? until - time(0) : 0;
606 +    long lSec = until - empire_time(0) > 0 ? until - empire_time(0) : 0;
607      empth_t *pThread = TlsGetValue(dwTLSIndex);
608      int iReturn = 0;
609  
610 @@ -651,7 +652,7 @@ empth_sleep(time_t until)
611  
612         loc_debug("sleep done. Waiting to run.");
613         loc_RunThisThread(NULL);
614 -    } while (!iReturn && ((lSec = until - time(0)) > 0));
615 +    } while (!iReturn && ((lSec = until - empire_time(0)) > 0));
616  
617      return iReturn;
618  }
619 diff --git a/src/lib/empthread/pthread.c b/src/lib/empthread/pthread.c
620 index 3f56fbc..1a1078c 100644
621 --- a/src/lib/empthread/pthread.c
622 +++ b/src/lib/empthread/pthread.c
623 @@ -53,6 +53,7 @@
624  
625  #include "misc.h"
626  #include "empthread.h"
627 +#include "emptime.h"
628  #include "prototypes.h"
629  
630  #define EMPTH_KILLED  1
631 @@ -378,10 +379,10 @@ empth_sleep(time_t until)
632      struct timeval tv;
633      int res;
634  
635 -    empth_status("going to sleep %ld sec", until - time(0));
636 +    empth_status("going to sleep %ld sec", until - empire_time(0));
637      pthread_mutex_unlock(&mtx_ctxsw);
638      do {
639 -       tv.tv_sec = until - time(NULL);
640 +       tv.tv_sec = until - empire_time(NULL);
641         tv.tv_usec = 0;
642         res = select(0, NULL, NULL, NULL, &tv);
643      } while (res < 0 && ctx->state == 0);
644 diff --git a/src/lib/gen/emptime.c b/src/lib/gen/emptime.c
645 new file mode 100644
646 index 0000000..855de99
647 --- /dev/null
648 +++ b/src/lib/gen/emptime.c
649 @@ -0,0 +1,51 @@
650 +/*
651 + *  Empire - A multi-player, client/server Internet based war game.
652 + *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
653 + *                           Ken Stevens, Steve McClure
654 + *
655 + *  This program is free software; you can redistribute it and/or modify
656 + *  it under the terms of the GNU General Public License as published by
657 + *  the Free Software Foundation; either version 2 of the License, or
658 + *  (at your option) any later version.
659 + *
660 + *  This program is distributed in the hope that it will be useful,
661 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
662 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
663 + *  GNU General Public License for more details.
664 + *
665 + *  You should have received a copy of the GNU General Public License
666 + *  along with this program; if not, write to the Free Software
667 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
668 + *
669 + *  ---
670 + *
671 + *  See files README, COPYING and CREDITS in the root of the source
672 + *  tree for related information and legal notices.  It is expected
673 + *  that future projects/authors will amend these files as needed.
674 + *
675 + *  ---
676 + *
677 + *  emptime.c: Time functions for regression testing and
678 + *             replaying journals.
679 + *
680 + *  Known contributors to this file:
681 + *     Ron Koenderink, 2008
682 + */
683 +
684 +#include <stdio.h>
685 +#include <string.h>
686 +#include "emptime.h"
687 +
688 +time_t
689 +emp_time(time_t * time_ptr, const char function[])
690 +{
691 +    static time_t now = (time_t)100L;
692 +
693 +    if (strcmp(function, "update_main") == 0)
694 +       now += 100L;
695 +
696 +    if (time_ptr != NULL)
697 +       *time_ptr = now;
698 +
699 +    return now;
700 +}
701 diff --git a/src/lib/gen/log.c b/src/lib/gen/log.c
702 index 7f57182..bc78466 100644
703 --- a/src/lib/gen/log.c
704 +++ b/src/lib/gen/log.c
705 @@ -41,6 +41,7 @@
706  #include <sys/stat.h>
707  #include <time.h>
708  #include <unistd.h>
709 +#include "emptime.h"
710  #include "misc.h"
711  #include "optlist.h"
712  #include "player.h"
713 @@ -116,7 +117,7 @@ logerror(char *format, ...)
714      p[1] = 0;
715      fputs(msg, stderr);
716      if (logfd >= 0) {
717 -       time(&now);
718 +       empire_time(&now);
719         memcpy(buf, ctime(&now), ctime_len);
720         buf[ctime_len] = ' ';
721         write(logfd, buf, strlen(buf));
722 diff --git a/src/lib/lwp/sel.c b/src/lib/lwp/sel.c
723 index 2cafa08..988d091 100644
724 --- a/src/lib/lwp/sel.c
725 +++ b/src/lib/lwp/sel.c
726 @@ -39,6 +39,7 @@
727  #include <sys/time.h>
728  #include <time.h>
729  #include <unistd.h>
730 +#include "emptime.h"
731  #include "lwp.h"
732  #include "lwpint.h"
733  #include "prototypes.h"
734 @@ -144,7 +145,7 @@ lwpWakeupSleep(void)
735      struct lwpProc *proc;
736  
737      if (LwpDelayq.head) {
738 -       now = time(NULL);
739 +       now = empire_time(NULL);
740         save.tail = save.head = 0;
741         while (NULL != (proc = lwpGetFirst(&LwpDelayq))) {
742             if (now >= proc->runtime) {
743 @@ -175,7 +176,7 @@ lwpSleepUntil(time_t until)
744      int res;
745  
746      lwpStatus(LwpCurrent, "sleeping for %ld sec",
747 -             (long)(until - time(NULL)));
748 +             (long)(until - empire_time(NULL)));
749      LwpCurrent->runtime = until;
750      if (LwpMaxfd == 0 && LwpDelayq.head == 0) {
751         /* select process is sleeping until first waiter arrives */
752 @@ -219,7 +220,7 @@ lwpSelect(void *arg)
753         tv.tv_sec = 1000000;
754         tv.tv_usec = 0;
755         if (LwpDelayq.head) {
756 -           time(&now);
757 +           empire_time(&now);
758             proc = LwpDelayq.head;
759             for (; proc != 0; proc = proc->next) {
760                 delta = proc->runtime - now;
761 diff --git a/src/lib/player/accept.c b/src/lib/player/accept.c
762 index 3106849..726b5fc 100644
763 --- a/src/lib/player/accept.c
764 +++ b/src/lib/player/accept.c
765 @@ -45,6 +45,7 @@
766  
767  #include "empio.h"
768  #include "empthread.h"
769 +#include "emptime.h"
770  #include "file.h"
771  #include "misc.h"
772  #include "nat.h"
773 @@ -91,7 +92,7 @@ player_new(int s)
774         emp_insque(&lp->queue, &Players);
775         lp->cnum = NATID_BAD;
776         lp->curid = -1;
777 -       time(&lp->curup);
778 +       empire_time(&lp->curup);
779      }
780      return lp;
781  }
782 diff --git a/src/lib/player/player.c b/src/lib/player/player.c
783 index 811e1d4..d08ac40 100644
784 --- a/src/lib/player/player.c
785 +++ b/src/lib/player/player.c
786 @@ -40,6 +40,7 @@
787  #include "com.h"
788  #include "empio.h"
789  #include "empthread.h"
790 +#include "emptime.h"
791  #include "file.h"
792  #include "journal.h"
793  #include "misc.h"
794 @@ -64,7 +65,7 @@ player_main(struct player *p)
795  
796      p->state = PS_PLAYING;
797      player = p;
798 -    time(&player->curup);
799 +    empire_time(&player->curup);
800      update_timeused_login(player->curup);
801      show_motd();
802      if (init_nats() < 0) {
803 @@ -115,7 +116,7 @@ player_main(struct player *p)
804      }
805      /* #*# I put the following line in to prevent server crash -KHS */
806      natp = getnatp(player->cnum);
807 -    time(&natp->nat_last_logout);
808 +    empire_time(&natp->nat_last_logout);
809      putnat(natp);
810      update_timeused(natp->nat_last_logout);
811      enforce_minimum_session_time();
812 @@ -134,7 +135,7 @@ command(void)
813      if (getcommand(player->combuf) < 0)
814         return 0;
815  
816 -    now = time(NULL);
817 +    now = empire_time(NULL);
818      update_timeused(now);
819      natp = getnatp(player->cnum);
820      if ((natp->nat_stat == STAT_ACTIVE || natp->nat_stat == STAT_SANCT)
821 @@ -186,7 +187,7 @@ status(void)
822      if (!(old_nstat & MONEY) && (player->nstat & MONEY))
823         pr("You are no longer broke!\n");
824  
825 -    time(&player->curup);
826 +    empire_time(&player->curup);
827      update_timeused(player->curup);
828      if ((natp->nat_stat == STAT_ACTIVE || natp->nat_stat == STAT_SANCT)
829         && natp->nat_timeused > m_m_p_d * 60) {
830 diff --git a/src/lib/player/recvclient.c b/src/lib/player/recvclient.c
831 index ab4ef69..8934189 100644
832 --- a/src/lib/player/recvclient.c
833 +++ b/src/lib/player/recvclient.c
834 @@ -35,6 +35,7 @@
835  #include <config.h>
836  
837  #include "empio.h"
838 +#include "emptime.h"
839  #include "journal.h"
840  #include "player.h"
841  #include "prototypes.h"
842 @@ -102,7 +103,7 @@ recvclient(char *cmd, int size)
843              * check errors; oops once, then slow it down drastically.
844              */
845             CANT_HAPPEN(player->recvfail == 256);
846 -           empth_sleep(time(NULL) + 60);
847 +           empth_sleep(empire_time(NULL) + 60);
848         }
849         return player->eof ? -1 : -2;
850      }
851 diff --git a/src/lib/subs/disloan.c b/src/lib/subs/disloan.c
852 index 9a6c670..9d7b6ba 100644
853 --- a/src/lib/subs/disloan.c
854 +++ b/src/lib/subs/disloan.c
855 @@ -46,6 +46,7 @@
856  
857  #include <config.h>
858  
859 +#include "emptime.h"
860  #include "file.h"
861  #include "loan.h"
862  #include "nat.h"
863 @@ -64,7 +65,7 @@ disloan(int n, struct lonstr *loan)
864         return 0;
865      if (loan->l_loner != player->cnum && loan->l_lonee != player->cnum)
866         return 0;
867 -    (void)time(&now);
868 +    (void)empire_time(&now);
869      pr("\nLoan #%d from %s to", n, cname(loan->l_loner));
870      pr(" %s\n", cname(loan->l_lonee));
871      if (loan->l_status == LS_PROPOSED) {
872 diff --git a/src/lib/subs/distrea.c b/src/lib/subs/distrea.c
873 index bfb182c..45f80ae 100644
874 --- a/src/lib/subs/distrea.c
875 +++ b/src/lib/subs/distrea.c
876 @@ -33,6 +33,7 @@
877  
878  #include <config.h>
879  
880 +#include "emptime.h"
881  #include "file.h"
882  #include "nat.h"
883  #include "player.h"
884 @@ -51,7 +52,7 @@ distrea(int n, struct trtstr *tp)
885      if (tp->trt_cna != player->cnum &&
886         tp->trt_cnb != player->cnum && !player->god)
887         return 0;
888 -    (void)time(&now);
889 +    (void)empire_time(&now);
890      if (now > tp->trt_exp) {
891         tp->trt_status = TS_FREE;
892         if (!puttre(n, tp)) {
893 diff --git a/src/lib/subs/journal.c b/src/lib/subs/journal.c
894 index 4f553c5..c8bb70c 100644
895 --- a/src/lib/subs/journal.c
896 +++ b/src/lib/subs/journal.c
897 @@ -57,6 +57,7 @@
898  #include <time.h>
899  #include "misc.h"
900  #include "empthread.h"
901 +#include "emptime.h"
902  #include "journal.h"
903  #include "optlist.h"
904  #include "player.h"
905 @@ -83,7 +84,7 @@ journal_entry(char *fmt, ...)
906      unsigned char *p;
907  
908      if (journal) {
909 -       time(&now);
910 +       empire_time(&now);
911         fprintf(journal, "%.24s %10.10s ",
912                 ctime(&now), empth_name(empth_self()));
913  
914 diff --git a/src/lib/subs/lostsub.c b/src/lib/subs/lostsub.c
915 index 2d0d046..8b2ea25 100644
916 --- a/src/lib/subs/lostsub.c
917 +++ b/src/lib/subs/lostsub.c
918 @@ -34,6 +34,7 @@
919  
920  #include <config.h>
921  
922 +#include "emptime.h"
923  #include "file.h"
924  #include "lost.h"
925  #include "misc.h"
926 @@ -124,7 +125,7 @@ findlost(short type, natid owner, short id, coord x, coord y, int free)
927  void
928  delete_old_lostitems(void)
929  {
930 -    time_t expiry_time = time(NULL) - hours(lost_keep_hours);
931 +    time_t expiry_time = empire_time(NULL) - hours(lost_keep_hours);
932      struct loststr lost;
933      int i;
934  
935 diff --git a/src/lib/subs/nreport.c b/src/lib/subs/nreport.c
936 index 2e83326..5600a5a 100644
937 --- a/src/lib/subs/nreport.c
938 +++ b/src/lib/subs/nreport.c
939 @@ -36,6 +36,7 @@
940  
941  #include <config.h>
942  
943 +#include "emptime.h"
944  #include "file.h"
945  #include "nat.h"
946  #include "news.h"
947 @@ -96,7 +97,7 @@ delete_old_news(void)
948      struct nwsstr news;
949  
950      /* skip over expired news */
951 -    expiry_time = time(NULL) - days(news_keep_days);
952 +    expiry_time = empire_time(NULL) - days(news_keep_days);
953      for (i = 0; getnews(i, &news); i++) {
954         if (news.nws_vrb == 0 || news.nws_when >= expiry_time)
955             break;
956 @@ -156,7 +157,7 @@ ncache(int actor, int event, int victim, int times)
957      int i;
958      int oldslot;
959      time_t oldtime;
960 -    time_t now = time(NULL);
961 +    time_t now = empire_time(NULL);
962  
963      oldslot = -1;
964      oldtime = 0x7fffffff;
965 diff --git a/src/lib/subs/pr.c b/src/lib/subs/pr.c
966 index 628d831..44f03f0 100644
967 --- a/src/lib/subs/pr.c
968 +++ b/src/lib/subs/pr.c
969 @@ -55,6 +55,7 @@
970  #include <stdlib.h>
971  #include "com.h"
972  #include "empio.h"
973 +#include "emptime.h"
974  #include "file.h"
975  #include "misc.h"
976  #include "nat.h"
977 @@ -193,7 +194,7 @@ pr_wall(char *format, ...)
978      struct player *p;
979      va_list ap;
980  
981 -    time(&now);
982 +    empire_time(&now);
983      tm = localtime(&now);
984      n = sprintf(buf, "BROADCAST from %s @ %02d:%02d: ",
985                 getnatp(0)->nat_cnam, tm->tm_hour, tm->tm_min);
986 @@ -374,7 +375,7 @@ prmptrd(char *prompt, char *buf, int size)
987      pr_id(player, C_FLUSH, "%s\n", prompt);
988      if ((r = recvclient(buf, size)) < 0)
989         return r;
990 -    time(&player->curup);
991 +    empire_time(&player->curup);
992      if (*buf == 0)
993         return 1;
994      if (player->flags & PF_UTF8)
995 @@ -403,7 +404,7 @@ uprmptrd(char *prompt, char *buf, int size)
996      pr_id(player, C_FLUSH, "%s\n", prompt);
997      if ((r = recvclient(buf, size)) < 0)
998         return r;
999 -    time(&player->curup);
1000 +    empire_time(&player->curup);
1001      if (*buf == 0)
1002         return 1;
1003      if (player->flags & PF_UTF8)
1004 @@ -419,7 +420,7 @@ prdate(void)
1005  {
1006      time_t now;
1007  
1008 -    (void)time(&now);
1009 +    (void)empire_time(&now);
1010      pr(ctime(&now));
1011  }
1012  
1013 @@ -479,7 +480,7 @@ PRdate(natid cn)
1014  {
1015      time_t now;
1016  
1017 -    (void)time(&now);
1018 +    (void)empire_time(&now);
1019      PR(cn, ctime(&now));
1020  }
1021  
1022 diff --git a/src/lib/subs/show.c b/src/lib/subs/show.c
1023 index ac3125b..afb0e81 100644
1024 --- a/src/lib/subs/show.c
1025 +++ b/src/lib/subs/show.c
1026 @@ -42,6 +42,7 @@
1027  #endif
1028  
1029  #include <math.h>
1030 +#include "emptime.h"
1031  #include "file.h"
1032  #include "game.h"
1033  #include "item.h"
1034 @@ -616,7 +617,7 @@ show_updates(int n)
1035      int demand = 0;
1036      int i;
1037  
1038 -    pr("%s, Turn %d, ETU %d\n", fmttime2822(time(NULL)),
1039 +    pr("%s, Turn %d, ETU %d\n", fmttime2822(empire_time(NULL)),
1040         game->game_turn, game->game_tick);
1041  
1042      if (update_time[0]) {
1043 diff --git a/src/lib/subs/trechk.c b/src/lib/subs/trechk.c
1044 index e77e2b0..84a78d1 100644
1045 --- a/src/lib/subs/trechk.c
1046 +++ b/src/lib/subs/trechk.c
1047 @@ -41,6 +41,7 @@
1048  
1049  #include <config.h>
1050  
1051 +#include "emptime.h"
1052  #include "file.h"
1053  #include "nat.h"
1054  #include "news.h"
1055 @@ -65,7 +66,7 @@ trechk(natid actor, natid victim, int provision)
1056  
1057      if (!opt_TREATIES)
1058         return 1;
1059 -    (void)time(&now);
1060 +    (void)empire_time(&now);
1061      broken = 0;
1062      applied = 0;
1063      for (cn = 0; cn < MAXNOC; cn++)
1064 diff --git a/src/lib/subs/wu.c b/src/lib/subs/wu.c
1065 index 5bcce21..c45d024 100644
1066 --- a/src/lib/subs/wu.c
1067 +++ b/src/lib/subs/wu.c
1068 @@ -37,6 +37,7 @@
1069  #include <stdarg.h>
1070  #include <sys/uio.h>
1071  #include <unistd.h>
1072 +#include "emptime.h"
1073  #include "file.h"
1074  #include "misc.h"
1075  #include "nat.h"
1076 @@ -143,7 +144,7 @@ typed_wu(natid from, natid to, char *message, int type)
1077      }
1078      memset(&tel, 0, sizeof(tel));
1079      tel.tel_from = from;
1080 -    (void)time(&tel.tel_date);
1081 +    (void)empire_time(&tel.tel_date);
1082      len = strlen(message);
1083      if (CANT_HAPPEN(len > MAXTELSIZE)) {
1084         len = MAXTELSIZE;
1085 diff --git a/src/lib/update/anno.c b/src/lib/update/anno.c
1086 index f07d441..1daf258 100644
1087 --- a/src/lib/update/anno.c
1088 +++ b/src/lib/update/anno.c
1089 @@ -41,6 +41,7 @@
1090  #endif
1091  #include <stdio.h>
1092  #include <time.h>
1093 +#include "emptime.h"
1094  #include "tel.h"
1095  #include "update.h"
1096  
1097 @@ -60,7 +61,7 @@ delete_old_announcements(void)
1098      if (anno_keep_days < 0)
1099         return;
1100  
1101 -    time(&now);
1102 +    empire_time(&now);
1103      old = now - days(anno_keep_days);
1104      logerror("Deleting annos older than %s", ctime(&old));
1105  
1106 diff --git a/src/lib/update/main.c b/src/lib/update/main.c
1107 index 32fa059..3ac6ce5 100644
1108 --- a/src/lib/update/main.c
1109 +++ b/src/lib/update/main.c
1110 @@ -38,6 +38,7 @@
1111  
1112  #include "budg.h"
1113  #include "empthread.h"
1114 +#include "emptime.h"
1115  #include "game.h"
1116  #include "journal.h"
1117  #include "player.h"
1118 @@ -64,7 +65,7 @@ update_main(void)
1119      struct natstr *np;
1120  
1121      logerror("production update (%d etus)", etu);
1122 -    game_record_update(time(NULL));
1123 +    game_record_update(empire_time(NULL));
1124      journal_update(etu);
1125  
1126      /* First, make sure all mobility is updated correctly. */
1127 diff --git a/src/lib/update/mobility.c b/src/lib/update/mobility.c
1128 index 95a81aa..674e999 100644
1129 --- a/src/lib/update/mobility.c
1130 +++ b/src/lib/update/mobility.c
1131 @@ -35,6 +35,7 @@
1132  
1133  #include <config.h>
1134  
1135 +#include "emptime.h"
1136  #include "game.h"
1137  #include "land.h"
1138  #include "plane.h"
1139 @@ -130,7 +131,7 @@ mob_sect(void)
1140      int n, etus;
1141      time_t now;
1142  
1143 -    time(&now);
1144 +    empire_time(&now);
1145      for (n = 0; NULL != (sp = getsectid(n)); n++) {
1146         sp->sct_timestamp = now;
1147         if (opt_MOB_ACCESS)
1148 @@ -167,7 +168,7 @@ mob_ship(void)
1149      int n, etus;
1150      time_t now;
1151  
1152 -    time(&now);
1153 +    empire_time(&now);
1154      for (n = 0; NULL != (sp = getshipp(n)); n++) {
1155         sp->shp_timestamp = now;
1156         if (opt_MOB_ACCESS)
1157 @@ -202,7 +203,7 @@ mob_land(void)
1158      int n, etus;
1159      time_t now;
1160  
1161 -    time(&now);
1162 +    empire_time(&now);
1163      for (n = 0; NULL != (lp = getlandp(n)); n++) {
1164         lp->lnd_timestamp = now;
1165         if (opt_MOB_ACCESS)
1166 @@ -251,7 +252,7 @@ mob_plane(void)
1167      int n, etus;
1168      time_t now;
1169  
1170 -    time(&now);
1171 +    empire_time(&now);
1172      for (n = 0; NULL != (pp = getplanep(n)); n++) {
1173         pp->pln_timestamp = now;
1174         if (opt_MOB_ACCESS)
1175 diff --git a/src/server/main.c b/src/server/main.c
1176 index 1f66f98..c887868 100644
1177 --- a/src/server/main.c
1178 +++ b/src/server/main.c
1179 @@ -54,6 +54,7 @@
1180  
1181  #include "empio.h"
1182  #include "empthread.h"
1183 +#include "emptime.h"
1184  #include "file.h"
1185  #include "journal.h"
1186  #include "land.h"
1187 @@ -148,7 +149,7 @@ main(int argc, char **argv)
1188  #endif
1189      char *config_file = NULL;
1190      int op, idx, sig;
1191 -    unsigned seed = time(NULL);
1192 +    unsigned seed = empire_time(NULL);
1193  
1194      oops_handler = ignore;
1195  
1196 diff --git a/src/server/marketup.c b/src/server/marketup.c
1197 index 925c844..f684909 100644
1198 --- a/src/server/marketup.c
1199 +++ b/src/server/marketup.c
1200 @@ -35,6 +35,7 @@
1201  #include <config.h>
1202  
1203  #include "empthread.h"
1204 +#include "emptime.h"
1205  #include "file.h"
1206  #include "optlist.h"
1207  #include "player.h"
1208 @@ -52,7 +53,7 @@ market_update(void *unused)
1209      player->god = 1;
1210  
1211      for (;;) {
1212 -       time(&now);
1213 +       empire_time(&now);
1214         check_market();
1215         check_trade();
1216         now += 300;             /* Every 5 minutes */
1217 diff --git a/src/server/shutdown.c b/src/server/shutdown.c
1218 index 0bf3290..0ad337b 100644
1219 --- a/src/server/shutdown.c
1220 +++ b/src/server/shutdown.c
1221 @@ -36,6 +36,7 @@
1222  
1223  #include <time.h>
1224  #include "empthread.h"
1225 +#include "emptime.h"
1226  #include "file.h"
1227  #include "nat.h"
1228  #include "prototypes.h"
1229 @@ -94,7 +95,7 @@ shutdown_sequence(void *unused)
1230  
1231      while (shutdown_pending > 0) {
1232         --shutdown_pending;
1233 -       time(&now);
1234 +       empire_time(&now);
1235         if (shutdown_pending <= 1440) { /* one day */
1236             if (shutdown_pending == 0) {
1237                 shutdwn(0);
1238 diff --git a/src/server/update.c b/src/server/update.c
1239 index 28cb077..0521f6f 100644
1240 --- a/src/server/update.c
1241 +++ b/src/server/update.c
1242 @@ -42,6 +42,7 @@
1243  #endif
1244  #include <time.h>
1245  #include "empthread.h"
1246 +#include "emptime.h"
1247  #include "game.h"
1248  #include "misc.h"
1249  #include "optlist.h"
1250 @@ -70,7 +71,7 @@ update_init(void)
1251      struct player *dp;
1252      int stacksize;
1253  
1254 -    update_schedule_anchor = (time(NULL) + 59) / 60 * 60;
1255 +    update_schedule_anchor = (empire_time(NULL) + 59) / 60 * 60;
1256      if (update_get_schedule() < 0)
1257         exit(1);
1258  
1259 @@ -98,7 +99,7 @@ update_init(void)
1260  static int
1261  update_get_schedule(void)
1262  {
1263 -    time_t now = time(NULL);
1264 +    time_t now = empire_time(NULL);
1265  
1266      if (read_schedule(schedulefil, update_time,
1267                       sizeof(update_time) / sizeof(*update_time),
1268 @@ -136,10 +137,10 @@ update_sched(void *unused)
1269         } else {
1270             logerror("No update scheduled");
1271             /* want to sleep forever, but empthread doesn't provide that */
1272 -           while (empth_sleep(time(NULL) + (60 * 60 * 24)) >= 0) ;
1273 +           while (empth_sleep(empire_time(NULL) + (60 * 60 * 24)) >= 0) ;
1274         }
1275  
1276 -       now = time(NULL);
1277 +       now = empire_time(NULL);
1278         if (next_update != 0 && now >= next_update) {
1279             /* scheduled update time reached */
1280             if (now >= next_update + 60)
1281 diff --git a/src/util/empsched.c b/src/util/empsched.c
1282 index 1ac1cdc..d51694c 100644
1283 --- a/src/util/empsched.c
1284 +++ b/src/util/empsched.c
1285 @@ -36,6 +36,7 @@
1286  #include <unistd.h>
1287  #include <stdio.h>
1288  #include <time.h>
1289 +#include "emptime.h"
1290  #include "optlist.h"
1291  #include "prototypes.h"
1292  #include "version.h"
1293 @@ -102,7 +103,7 @@ main(int argc, char *argv[])
1294      else
1295         in_file = argv[optind];
1296  
1297 -    anchor = (time(NULL) + 59) / 60 * 60;
1298 +    anchor = (empire_time(NULL) + 59) / 60 * 60;
1299      if (read_schedule(in_file, sched, n + 1, 0, anchor) < 0)
1300         exit(1);
1301  
1302 diff --git a/src/util/fairland.c b/src/util/fairland.c
1303 index 77a5a53..ffdc5c5 100644
1304 --- a/src/util/fairland.c
1305 +++ b/src/util/fairland.c
1306 @@ -70,6 +70,7 @@ static int quiet = 0;
1307  #include <stdarg.h>
1308  #include <stdio.h>
1309  #include <unistd.h>
1310 +#include "emptime.h"
1311  #include "file.h"
1312  #include "misc.h"
1313  #include "nat.h"
1314 @@ -183,7 +184,7 @@ main(int argc, char *argv[])
1315      int i = 0;
1316  
1317      program_name = argv[0];
1318 -    rnd_seed = time(NULL);
1319 +    rnd_seed = empire_time(NULL);
1320  
1321      while ((opt = getopt(argc, argv, "ae:hioqR:s:v")) != EOF) {
1322         switch (opt) {