Avoid repeated hours and game down status notifications
may_play_now() tells deities about hours restriction and game down status. It runs at login and before and after each command. Getting notified that often is annoying. Avoid repetition by remembering notification in new player flags PF_HOURS and PF_DOWN. Add a notification when hours restriction has been lifted. Ensure the notification is printed before the prompt, not before the command, by calling may_play_now() from command() only for mortals. Safe, because may_play_now() always returns true for deities anyway.
This commit is contained in:
parent
b404216dbe
commit
9ff2c62309
4 changed files with 22 additions and 15 deletions
|
@ -231,27 +231,33 @@ enforce_minimum_session_time(void)
|
|||
}
|
||||
|
||||
int
|
||||
may_play_now(struct natstr *natp, time_t now,
|
||||
int suppress_deity_message)
|
||||
may_play_now(struct natstr *natp, time_t now)
|
||||
{
|
||||
if (CANT_HAPPEN(natp->nat_cnum != player->cnum))
|
||||
return 0;
|
||||
|
||||
if (!gamehours(now)) {
|
||||
if (natp->nat_stat != STAT_GOD || !suppress_deity_message)
|
||||
pr("Empire hours restriction in force\n");
|
||||
if (gamehours(now)) {
|
||||
if (player->flags & PF_HOURS) {
|
||||
pr("\nEmpire hours restriction lifted\n");
|
||||
player->flags &= ~PF_HOURS;
|
||||
}
|
||||
} else {
|
||||
if (!(player->flags & PF_HOURS)) {
|
||||
pr("\nEmpire hours restriction in force\n");
|
||||
player->flags |= PF_HOURS;
|
||||
}
|
||||
if (natp->nat_stat != STAT_GOD)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (game_play_disabled()) {
|
||||
if (natp->nat_stat != STAT_GOD) {
|
||||
if (!(player->flags & PF_DOWN)) {
|
||||
show_first_tel(downfil);
|
||||
pr("\nThe game is down\n");
|
||||
return 0;
|
||||
player->flags |= PF_DOWN;
|
||||
}
|
||||
if (!suppress_deity_message)
|
||||
pr("The game is down\n");
|
||||
if (natp->nat_stat != STAT_GOD)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((natp->nat_stat != STAT_GOD && natp->nat_stat != STAT_VIS)
|
||||
|
|
|
@ -70,7 +70,7 @@ player_main(struct player *p)
|
|||
return;
|
||||
}
|
||||
natp = getnatp(player->cnum);
|
||||
if (!may_play_now(natp, player->curup, 0))
|
||||
if (!may_play_now(natp, player->curup))
|
||||
return;
|
||||
if (natp->nat_stat != STAT_VIS
|
||||
&& natp->nat_last_login
|
||||
|
@ -125,7 +125,7 @@ command(void)
|
|||
|
||||
now = time(NULL);
|
||||
update_timeused(now);
|
||||
if (!may_play_now(getnatp(player->cnum), now, 1))
|
||||
if (!player->god && !may_play_now(getnatp(player->cnum), now))
|
||||
return 0;
|
||||
|
||||
if (parse(player->combuf, scanspace, player->argp, player->comtail,
|
||||
|
@ -173,7 +173,7 @@ status(void)
|
|||
|
||||
time(&player->curup);
|
||||
update_timeused(player->curup);
|
||||
if (!may_play_now(natp, player->curup, 0))
|
||||
if (!may_play_now(natp, player->curup))
|
||||
return 0;
|
||||
if (player->btused) {
|
||||
natp->nat_btu -= player->btused;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue