Complete.Org: Mailing Lists: Archives: freeciv-dev: May 1999:
[Freeciv-Dev] patch: destroyed wonders
Home

[Freeciv-Dev] patch: destroyed wonders

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] patch: destroyed wonders
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Tue, 18 May 1999 23:01:17 +1000 (EST)

Currently freeciv behaves a bit inconsistently when a city 
with a wonder is destroyed.  Such wonders are effectively
destroyed and cannot be rebuilt, except that if the game is 
saved and re-started, then they can then be rebuilt.

This patch makes it so that destroyed wonders stay destroyed.
(Though some effects like Manhatten for Nuclears and Apollo
for spaceship still work after the wonder is destroyed.)

While changing the wonders report to not destroyed wonders,
I also changed a bit the format of the report, since I found 
it hard to find particular wonders.  Maybe this should be 
re-done as a properly spaced table...

-- David
diff -u -r --exclude-from exclude freeciv-cvs/common/city.c 
freeciv-mod/common/city.c
--- freeciv-cvs/common/city.c   Mon Apr 26 17:16:17 1999
+++ freeciv-mod/common/city.c   Tue May 18 21:33:36 1999
@@ -1184,12 +1184,22 @@
     return 0;
   if (city_got_building(pcity, id))
     return 1;
-  /* For Manhatten it can be owned by anyone, but otherwise the player
-   * who owns the city needs to have it to get the effect.
-   * (Note player_find_city_by_id() may be faster, in the client)
+  
+  /* For Manhatten it can be owned by anyone, and it doesn't matter
+   * whether it is destroyed or not.
+   *
+   * (The same goes for Apollo, with respect to building spaceship parts,
+   * but not for getting the map effect.  This function only returns true
+   * for Apollo for the owner of a non-destroyed Apollo; for building
+   * spaceship parts just check (game.global_wonders[id] != 0).
+   * (Actually, this function is not currently used for either Manhatten
+   * or Apollo.))
+   *
+   * Otherwise the player who owns the city needs to have it to
+   * get the effect.
    */
   if (id==B_MANHATTEN) 
-    return (find_city_by_id(game.global_wonders[id]) != 0);
+    return (game.global_wonders[id] != 0);
   
   tmp = player_find_city_by_id(get_player(pcity->owner),
                               game.global_wonders[id]);
diff -u -r --exclude-from exclude freeciv-cvs/common/game.h 
freeciv-mod/common/game.h
--- freeciv-cvs/common/game.h   Sun Apr 25 21:47:30 1999
+++ freeciv-mod/common/game.h   Tue May 18 20:53:17 1999
@@ -58,6 +58,8 @@
   struct player players[MAX_PLAYERS];   
   int global_advances[A_LAST];             /* a counter */
   int global_wonders[B_LAST];              /* contains city id's */
+         /* global_wonders[] may also be (-1), or the id of a city
+           which no longer exists, if the wonder has been destroyed */
   int globalwarming;                       /* counter of how disturbed 
                                              mother nature is */
   int rail_food, rail_trade, rail_prod;
diff -u -r --exclude-from exclude freeciv-cvs/server/gamehand.c 
freeciv-mod/server/gamehand.c
--- freeciv-cvs/server/gamehand.c       Sat Mar 13 22:48:05 1999
+++ freeciv-mod/server/gamehand.c       Tue May 18 21:42:35 1999
@@ -379,6 +379,14 @@
   }
   map_load(file);
 
+  /* destroyed wonders: */
+  string = secfile_lookup_str_default(file, "", "game.destroyed_wonders");
+  for(i=0; i<B_LAST && string[i]; i++) {
+    if (string[i] == '1') {
+      game.global_wonders[i] = -1; /* destroyed! */
+    }
+  }
+  
   for(i=0; i<game.nplayers; i++) {
     player_load(&game.players[i], i, file); 
   }
@@ -522,6 +530,18 @@
     }
      
   }
+
+  /* destroyed wonders: */
+  for(i=0; i<B_LAST; i++) {
+    if (is_wonder(i) && game.global_wonders[i]!=0
+       && !find_city_by_id(game.global_wonders[i])) {
+      temp[i] = '1';
+    } else {
+      temp[i] = '0';
+    }
+  }
+  temp[i] = '\0';
+  secfile_insert_str(file, temp, "game.destroyed_wonders");
 
   calc_unit_ordering();
   
diff -u -r --exclude-from exclude freeciv-cvs/server/plrhand.c 
freeciv-mod/server/plrhand.c
--- freeciv-cvs/server/plrhand.c        Sat May  8 22:36:08 1999
+++ freeciv-mod/server/plrhand.c        Tue May 18 21:35:01 1999
@@ -177,11 +177,15 @@
   char buf2[4096];
   buffer[0]=0;
   for (i=0;i<B_LAST;i++) {
-    if(is_wonder(i) && game.global_wonders[i] && 
-       (pcity=find_city_by_id(game.global_wonders[i]))) {
-      sprintf(buf2, "%s (%s) has the %s\n", pcity->name, 
-             get_race_name(game.players[pcity->owner].race), 
-             get_imp_name_ex(pcity, i));
+    if(is_wonder(i) && game.global_wonders[i]) {
+      if((pcity=find_city_by_id(game.global_wonders[i]))) {
+       sprintf(buf2, "%s in %s (%s)\n",
+               get_imp_name_ex(pcity, i), pcity->name,
+               get_race_name(game.players[pcity->owner].race));
+      } else {
+       sprintf(buf2, "%s has been DESTROYED\n",
+               get_improvement_type(i)->name);
+      }
       strcat(buffer, buf2);
     }
   }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] patch: destroyed wonders, David Pfitzner <=