]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/main.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / update / main.c
index 31d21093a989c08ec272480e15cd26b98d364f2b..9e90de9fab61ed6ab38842db61955c301b19f7cd 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -19,9 +19,9 @@
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
  *     Doug Hay, 1998
  */
 
+#include <config.h>
+
 #include "misc.h"
 #include "nat.h"
 #include "file.h"
 #include "sect.h"
 #include "player.h"
 #include "empthread.h"
-#include "var.h"
 #include "budg.h"
-#include "product.h"
 #include "player.h"
 #include "update.h"
 #include "common.h"
 #include "optlist.h"
+#include "server.h"
 #include <stdlib.h>
 #if !defined(_WIN32)
 #include <sys/time.h>
@@ -75,6 +76,9 @@ update_main(void *unused)
     struct natstr *cnp;
     struct natstr *np;
 
+    if (CANT_HAPPEN(!update_pending))
+        update_pending = 1;
+
     /* First, make sure all mobility is updated correctly. */
     if (opt_MOB_ACCESS) {
        mob_ship(etu);
@@ -82,7 +86,6 @@ update_main(void *unused)
        mob_plane(etu);
        mob_land(etu);
     }
-    update_pending = 1;
     player->proc = empth_self();
     player->cnum = 0;
     player->god = 1;
@@ -96,7 +99,7 @@ update_main(void *unused)
     memset(air_money, 0, sizeof(air_money));
     memset(sea_money, 0, sizeof(sea_money));
     memset(lnd_money, 0, sizeof(lnd_money));
-    bp = (int *)calloc(WORLD_X * WORLD_Y * 7, sizeof(int));
+    bp = calloc(WORLD_X * WORLD_Y * 7, sizeof(int));
     for (n = 0; n < MAXNOC; n++) {
        money[n] = 0;
        if ((np = getnatp(n)) == (struct natstr *)0)
@@ -111,13 +114,13 @@ update_main(void *unused)
     logerror("producing for countries...");
     for (x = 0; x < MAXNOC; x++) {
        int y, z, sb = 0, sm = 0, pb = 0, pm = 0, lm = 0, lb = 0;
-       long p_sect[SCT_MAXDEF + 1][2];
+       long p_sect[SCT_MAXDEF+1][2];
 
        memset(p_sect, 0, sizeof(p_sect));
        mil_dbl_pay = 0;
        if ((np = getnatp(x)) == (struct natstr *)0)
            continue;
-       if (np->nat_stat & STAT_SANCT) {
+       if (np->nat_stat == STAT_SANCT) {
 #ifdef DEBUG
            logerror("Country %i is in sanctuary and did not update", x);
 #endif
@@ -125,8 +128,8 @@ update_main(void *unused)
        }
        np->nat_money += (int)(np->nat_reserve * money_res * etu);
 
-       for (y = 1; y < SCT_MAXDEF + 8; y++) {
-           for (z = 0; z < SCT_MAXDEF + 8; z++) {
+       for (y = 1; y <= PRI_MAX; y++) {
+           for (z = 0; z <= PRI_MAX; z++) {
                if (np->nat_priorities[z] == y) {
                    do_prod(z, etu, x, bp, p_sect,
                            &sb, &sm, &pb, &pm, &lb, &lm);
@@ -178,13 +181,6 @@ update_main(void *unused)
            }
        }
     }
-    /* Age contact */
-    if (opt_LOSE_CONTACT) {
-       for (cn = 1; cn < MAXNOC; cn++) {
-           if ((cnp = getnatp(cn)) != NULL)
-               agecontact(cnp);
-       }
-    }
     /* Only update mobility for non-MOB_ACCESS here, since it doesn't
        get done for MOB_ACCESS anyway during the update */
     if (!opt_MOB_ACCESS) {
@@ -202,6 +198,7 @@ update_main(void *unused)
     ef_flush(EF_PLANE);
     ef_flush(EF_LAND);
     delete_old_announcements();
+    delete_old_news();
     /* Clear all the telegram flags */
     for (cn = 0; cn < MAXNOC; cn++)
        clear_telegram_is_new(cn);