/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* ---
*
* update.c: Update scheduler
- *
+ *
* Known contributors to this file:
* Dave Pare, 1994
* Steve McClure, 1996
static int update_get_schedule(void);
static void update_sched(void *);
static void update_run(void);
-static int run_hook(char *cmd, char *name);
void
update_init(void)
} else {
logerror("No update scheduled");
/* want to sleep forever, but empthread doesn't provide that */
- while (empth_sleep(60 * 60 * 24) >= 0) ;
+ while (empth_sleep(time(NULL) + (60 * 60 * 24)) >= 0) ;
}
now = time(NULL);
{
struct player *p;
- play_wrlock_wanted = 1;
- for (p = player_next(0); p != 0; p = player_next(p)) {
+ for (p = player_next(NULL); p; p = player_next(p)) {
if (p->state != PS_PLAYING)
continue;
if (p->command) {
pr_flash(p, "Update aborting command\n");
+ p->may_sleep = PLAYER_SLEEP_NEVER;
p->aborted = 1;
empth_wakeup(p->proc);
}
empth_rwlock_wrlock(play_lock);
if (*pre_update_hook) {
if (run_hook(pre_update_hook, "pre-update")) {
- play_wrlock_wanted = 0;
empth_rwlock_unlock(play_lock);
return;
}
}
update_running = 1;
update_main();
- play_wrlock_wanted = update_running = 0;
+ update_running = 0;
empth_rwlock_unlock(play_lock);
}
-static int
+int
run_hook(char *cmd, char *name)
{
int status;
-
+
fflush(NULL);
-
+
status = system(cmd);
if (status == 0)
; /* successful exit */