X-Git-Url: http://git.pond.sub.org/?p=empserver;a=blobdiff_plain;f=src%2Flib%2Fcommands%2Fupda.c;h=beca583c13632c45a23383f33663e23b1922b823;hp=a381af8b385a92d590997eb3e4821f10bf73e398;hb=9b7adfbe;hpb=5f263a7753dc728809ff85c993af975f6c76e61e diff --git a/src/lib/commands/upda.c b/src/lib/commands/upda.c index a381af8b3..beca583c1 100644 --- a/src/lib/commands/upda.c +++ b/src/lib/commands/upda.c @@ -48,140 +48,141 @@ int upda(void) { - FILE *fp; - struct mob_acc_globals timestamps; - extern int updating_mob; - extern int update_window; - extern s_char *timestampfil; + FILE *fp; + struct mob_acc_globals timestamps; + extern int updating_mob; + extern int update_window; + extern s_char *timestampfil; if (opt_MOB_ACCESS) { #if !defined(_WIN32) - if ((fp = fopen(timestampfil, "r")) == NULL) { + if ((fp = fopen(timestampfil, "r")) == NULL) { #else - if ((fp = fopen(timestampfil, "rb")) == NULL) { + if ((fp = fopen(timestampfil, "rb")) == NULL) { #endif - logerror("Unable to open timestamp file."); - } else { - rewind(fp); - fread(×tamps, sizeof(timestamps), 1, fp); - fclose(fp); - if (updating_mob) - pr("Mobility updating is enabled.\n\n"); - else { - pr("Mobility updating will come back on around %s", - ctime(×tamps.starttime)); - pr("game time, within 3 minutes, depending on when the server checks.\n\n"); - } - } + logerror("Unable to open timestamp file."); + } else { + rewind(fp); + fread(×tamps, sizeof(timestamps), 1, fp); + fclose(fp); + if (updating_mob) + pr("Mobility updating is enabled.\n\n"); + else { + pr("Mobility updating will come back on around %s", + ctime(×tamps.starttime)); + pr("game time, within 3 minutes, depending on when the server checks.\n\n"); + } + } + } + if (opt_UPDATESCHED) { + time_t now, next, delta; + extern int update_time; + extern int update_policy; + extern int update_demandpolicy; + extern int update_wantmin; + extern int blitz_time; + extern s_char *update_times; + extern s_char *update_demandtimes; + extern s_char *game_days; + extern s_char *game_hours; + + if (updates_disabled()) + pr("UPDATES ARE DISABLED!\n"); + + (void)time(&now); + switch (update_policy) { + case UDP_NORMAL: + next_update_time(&now, &next, &delta); + pr("\nUpdates occur at times specified by the ETU rates.\n\n"); + pr("The next update is at %19.19s.\n", ctime(&next)); + break; + case UDP_TIMES: + next_update_time(&now, &next, &delta); + pr("\nUpdates occur at scheduled times.\n\n"); + pr("The next update is at %19.19s.\n", ctime(&next)); + break; + case UDP_BLITZ: + next_update_time(&now, &next, &delta); + pr("\nBlitz Updates occur every %d minutes. \n\n", blitz_time); + pr("The next update is at %19.19s.\n", ctime(&next)); + break; + case UDP_NOREG: + pr("There are no regularly scheduled updates.\n"); + break; + default: + pr("Update policy is inconsistent.\n"); + } + pr("The current time is %19.19s.\n\n", ctime(&now)); + + if (update_window) { + now = update_time - update_window; + next_update_time(&now, &next, &delta); + pr("The next update window starts at %19.19s.\n", + ctime(&next)); + next += update_window; + pr("The next update window stops at %19.19s.\n", ctime(&next)); } - if (opt_UPDATESCHED) { - time_t now, next, delta; - extern int update_time; - extern int update_policy; - extern int update_demandpolicy; - extern int update_wantmin; - extern int blitz_time; - extern s_char *update_times; - extern s_char *update_demandtimes; - extern s_char *game_days; - extern s_char *game_hours; - - if (updates_disabled()) - pr("UPDATES ARE DISABLED!\n"); - - (void) time(&now); - switch (update_policy) { - case UDP_NORMAL: - next_update_time(&now, &next, &delta); - pr("\nUpdates occur at times specified by the ETU rates.\n\n"); - pr("The next update is at %19.19s.\n", ctime(&next)); - break; - case UDP_TIMES: - next_update_time(&now, &next, &delta); - pr("\nUpdates occur at scheduled times.\n\n"); - pr("The next update is at %19.19s.\n", ctime(&next)); - break; - case UDP_BLITZ: - next_update_time(&now, &next, &delta); - pr("\nBlitz Updates occur every %d minutes. \n\n", - blitz_time); - pr("The next update is at %19.19s.\n",ctime(&next)); - break; - case UDP_NOREG: - pr("There are no regularly scheduled updates.\n"); - break; + if (opt_DEMANDUPDATE) { + if (update_demandpolicy != UDDEM_DISABLE) { + switch (update_demandpolicy) { + case UDDEM_TMCHECK: + next_update_check_time(&now, &next, &delta); + pr("Demand updates occur at update CHECK times.\n"); + pr("The next update check is at %19.19s.\n", + ctime(&next)); + break; + case UDDEM_COMSET: + pr("Demand updates occur right after the demand is set.\n"); + break; default: - pr("Update policy is inconsistent.\n"); - } - pr("The current time is %19.19s.\n\n", ctime(&now)); - - if (update_window) { - now = update_time - update_window; - next_update_time(&now, &next, &delta); - pr("The next update window starts at %19.19s.\n",ctime(&next)); - next += update_window; - pr("The next update window stops at %19.19s.\n",ctime(&next)); - } - if (opt_DEMANDUPDATE) { - if (update_demandpolicy != UDDEM_DISABLE) { - switch (update_demandpolicy) { - case UDDEM_TMCHECK: - next_update_check_time(&now, &next, &delta); - pr("Demand updates occur at update CHECK times.\n"); - pr("The next update check is at %19.19s.\n", - ctime(&next)); - break; - case UDDEM_COMSET: - pr("Demand updates occur right after the demand is set.\n"); - break; - default: - pr("Update demand policy is inconsistent.\n"); - } - } + pr("Update demand policy is inconsistent.\n"); } - - if ((update_policy == UDP_TIMES) || - ((update_demandpolicy == UDDEM_TMCHECK) && - opt_DEMANDUPDATE)) { - if (*update_times != 0) - pr("The update schedule is: %s\n", update_times); - } - if (opt_DEMANDUPDATE) { - if (update_demandpolicy != UDDEM_DISABLE) { - if (*update_demandtimes != 0) - pr("Demand updates are allowed during: %s\n", update_demandtimes); - if (update_wantmin == 0) { - pr("Demand updates are disabled by a mininum of 0\n"); - } else { - pr("Demand updates require %d country(s) to want one.\n",update_wantmin); - } - } + } + } + + if ((update_policy == UDP_TIMES) || + ((update_demandpolicy == UDDEM_TMCHECK) && opt_DEMANDUPDATE)) { + if (*update_times != 0) + pr("The update schedule is: %s\n", update_times); + } + if (opt_DEMANDUPDATE) { + if (update_demandpolicy != UDDEM_DISABLE) { + if (*update_demandtimes != 0) + pr("Demand updates are allowed during: %s\n", + update_demandtimes); + if (update_wantmin == 0) { + pr("Demand updates are disabled by a mininum of 0\n"); + } else { + pr("Demand updates require %d country(s) to want one.\n", update_wantmin); } - if (*game_days != 0) pr("Game days are: %s\n", game_days); - if (*game_hours != 0) pr("Game hours are: %s\n", game_hours); - - return(0); + } + } + if (*game_days != 0) + pr("Game days are: %s\n", game_days); + if (*game_hours != 0) + pr("Game hours are: %s\n", game_hours); + + return (0); } else { - extern int s_p_etu; - extern int etu_per_update; - extern int adj_update; - time_t now; - time_t upd_time; - time_t next_update; - int secs_per_update; - int delta; - - (void) time(&now); - upd_time = now + adj_update; - secs_per_update = etu_per_update * s_p_etu; - delta = secs_per_update - (upd_time % secs_per_update); - next_update = now + delta; - pr("The next update is at %19.19s.\n",ctime(&next_update)); - pr("The current time is %19.19s.\n",ctime(&now)); - if (update_window) { - pr("Update times are variable, update window is +/- %d minutes %d seconds.\n", - update_window / 60, update_window % 60); - } - return 0; + extern int s_p_etu; + extern int etu_per_update; + extern int adj_update; + time_t now; + time_t upd_time; + time_t next_update; + int secs_per_update; + int delta; + + (void)time(&now); + upd_time = now + adj_update; + secs_per_update = etu_per_update * s_p_etu; + delta = secs_per_update - (upd_time % secs_per_update); + next_update = now + delta; + pr("The next update is at %19.19s.\n", ctime(&next_update)); + pr("The current time is %19.19s.\n", ctime(&now)); + if (update_window) { + pr("Update times are variable, update window is +/- %d minutes %d seconds.\n", update_window / 60, update_window % 60); + } + return 0; } }