Show treasury status on EOF, quit, shutdown
status() informs the player of non-trivial command costs and earnings, and when he goes broke or becomes solvent. However, this is skipped when the command gets aborted by the player signalling EOF, or by server shutdown, and after a quit command. Fix by moving the check for EOF or shutdown down to the may_play_now() check. This looks a bit like it would also fix charging of play time. But that's not broken, because player_main() charges, too.
This commit is contained in:
parent
8342618450
commit
bdc1c40f0a
Notes:
Markus Armbruster
2012-03-14 21:43:27 +01:00
Treasury update can be lost on EOF and shutdown Commands can accumulate cost in player->dolcost. status() charges the accumulated cost. This is skipped when the command gets aborted by the player signalling EOF, or by server shutdown, and after a quit command. The latter is harmless, as quitting is always free. EOF can happen when a command prompts for input. shutdown can additionally happen when a command blocks on output. No command that messes with dolcost blocks on output (all have C_MOD set). Commands build bridge, build tower, designate, and improve prompt for input after adding to dolcost. This can be abused to build bridges, towers and infrastructures free of charge. It can also be abused to designate sectors for free, but the stock game's sector types are all free anyway. Command scuttle prompts for input after subtracting from dolcost. A player can lose payment for tradeships when the command gets aborted by EOF or shutdown at the "Are you sure you want to scuttle" prompt. Similarly, a player can lose the gains from sacking a capital, for instance at the attack command's "move in" prompts. Commands build ship, build plane, build land, build nuke, change, collect, consider accept, convert, demobilize, harden, repay, shark, upgrade, and work, are believed not to prompt after messing with dolcost. Already broken in BSD Empire 1.1.
1 changed files with 3 additions and 3 deletions
|
@ -145,8 +145,6 @@ status(void)
|
|||
int old_nstat;
|
||||
char buf[128];
|
||||
|
||||
if (player->eof || player->state == PS_SHUTDOWN)
|
||||
return 0;
|
||||
natp = getnatp(player->cnum);
|
||||
if (player->dolcost > 100.0)
|
||||
pr("That just cost you $%.2f\n", player->dolcost);
|
||||
|
@ -173,8 +171,10 @@ status(void)
|
|||
|
||||
time(&player->curup);
|
||||
update_timeused(player->curup);
|
||||
if (!may_play_now(natp, player->curup))
|
||||
if (player->eof || player->state == PS_SHUTDOWN
|
||||
|| !may_play_now(natp, player->curup))
|
||||
return 0;
|
||||
|
||||
if (player->btused) {
|
||||
natp->nat_btu -= player->btused;
|
||||
player->btused = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue