]> git.pond.sub.org Git - empserver/blobdiff - src/lib/player/init_nats.c
Fix trailing whitespace
[empserver] / src / lib / player / init_nats.c
index 9674153f20234bd426e174e43253cd08c239e0bb..f1bfd2425d1c29a8d8f3b195ec0dd4a5d771369f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@
  *  ---
  *
  *  init_nats.c: Initialize country and nation file stuff
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1994
  *     Steve McClure, 2000
 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 | CAP | MONEY
+    };
+
+    if (CANT_HAPPEN(pl->cnum != np->nat_cnum))
+       return pl->nstat;
+    pl->god = np->nat_stat == STAT_GOD;
+    pl->nstat = nstat[np->nat_stat];
+    if (np->nat_money >= 0)
+       pl->nstat |= MONEY;
+    if (np->nat_stat == STAT_ACTIVE && !influx(np))
+       pl->nstat |= CAP;
+    pl->nstat |= EXEC;
+    return pl->nstat;
+}