(player_set_nstat): New, factored out of init_nats().
(init_nats): Use it. No functional change. (status): Use it. This sets player->nstat from scratch, not just MONEY and CAP. (brea): Don't bother to update player->nstat, status() will.
This commit is contained in:
parent
96b20c90b2
commit
2b5ebf1f3f
4 changed files with 31 additions and 28 deletions
|
@ -411,6 +411,7 @@ extern int getminleft(time_t, int);
|
|||
/* empmod.c */
|
||||
/* init_nats.c */
|
||||
extern int init_nats(void);
|
||||
extern int player_set_nstat(struct player *, struct natstr *);
|
||||
/* login.c */
|
||||
extern void player_login(void *);
|
||||
/* nat.c */
|
||||
|
|
|
@ -48,6 +48,5 @@ brea(void)
|
|||
bsanct();
|
||||
natp->nat_stat = STAT_ACTIVE;
|
||||
putnat(natp);
|
||||
player->nstat |= NORM;
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -47,30 +47,41 @@
|
|||
int
|
||||
init_nats(void)
|
||||
{
|
||||
static int nstat[] = {
|
||||
/* must match nat_status */
|
||||
0, VIS, VIS, SANCT, NORM, GOD
|
||||
};
|
||||
struct natstr *np;
|
||||
|
||||
np = getnatp(player->cnum);
|
||||
if (CANT_HAPPEN(!np))
|
||||
return -1;
|
||||
player->nstat = nstat[np->nat_stat];
|
||||
player->god = np->nat_stat == STAT_GOD;
|
||||
|
||||
player->map = ef_ptr(EF_MAP, player->cnum);
|
||||
player->bmap = ef_ptr(EF_BMAP, player->cnum);
|
||||
if (opt_HIDDEN) {
|
||||
|
||||
if (opt_HIDDEN)
|
||||
putcontact(np, player->cnum, FOUND_SPY);
|
||||
}
|
||||
if (np->nat_money < 0)
|
||||
player->broke = 1;
|
||||
else {
|
||||
player->nstat |= MONEY;
|
||||
player->broke = 0;
|
||||
}
|
||||
if (grant_btus(np, game_tick_to_now(&np->nat_access)))
|
||||
player->nstat |= CAP;
|
||||
|
||||
player_set_nstat(player, np);
|
||||
grant_btus(np, game_tick_to_now(&np->nat_access));
|
||||
|
||||
putnat(np);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
player_set_nstat(struct player *pl, struct natstr *np)
|
||||
{
|
||||
static int nstat[] = {
|
||||
/* must match nat_status */
|
||||
0, VIS, VIS, SANCT, NORM, GOD
|
||||
};
|
||||
|
||||
if (CANT_HAPPEN(pl->cnum != np->nat_cnum))
|
||||
return pl->nstat;
|
||||
pl->god = np->nat_stat == STAT_GOD;
|
||||
pl->nstat = nstat[np->nat_stat];
|
||||
pl->broke = np->nat_money < 0;
|
||||
if (!pl->broke)
|
||||
pl->nstat |= MONEY;
|
||||
if (np->nat_stat >= STAT_ACTIVE && !influx(np))
|
||||
pl->nstat |= CAP;
|
||||
return pl->nstat;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "player.h"
|
||||
#include "proto.h"
|
||||
#include "prototypes.h"
|
||||
#include "sect.h"
|
||||
#include "tel.h"
|
||||
|
||||
|
||||
|
@ -156,7 +155,6 @@ status(void)
|
|||
{
|
||||
struct natstr *natp;
|
||||
int minute;
|
||||
struct sctstr sect;
|
||||
char buf[128];
|
||||
|
||||
if (player->state == PS_SHUTDOWN)
|
||||
|
@ -172,23 +170,17 @@ status(void)
|
|||
pr("You just made $%.2f\n", -player->dolcost);
|
||||
natp->nat_money -= roundavg(player->dolcost);
|
||||
player->dolcost = 0.0;
|
||||
|
||||
if (natp->nat_money < 0 && !player->broke) {
|
||||
player->broke = 1;
|
||||
player->nstat &= ~MONEY;
|
||||
pr("You are now broke; industries are on strike.\n");
|
||||
} else if (player->broke && natp->nat_money >= 0) {
|
||||
player->broke = 0;
|
||||
player->nstat |= MONEY;
|
||||
pr("You are no longer broke!\n");
|
||||
}
|
||||
getsect(natp->nat_xcap, natp->nat_ycap, §);
|
||||
if (influx(natp))
|
||||
player->nstat &= ~CAP;
|
||||
else
|
||||
player->nstat |= CAP;
|
||||
player_set_nstat(player, natp);
|
||||
player->ncomstat = player->nstat;
|
||||
if (player->god)
|
||||
player->ncomstat |= CAP | MONEY;
|
||||
|
||||
time(&player->curup);
|
||||
minute = (player->curup - player->lasttime) / 60;
|
||||
if (minute > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue