Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] Re: (PR#2521) general effects framework
Home

[Freeciv-Dev] Re: (PR#2521) general effects framework

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: kaufman@xxxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2521) general effects framework
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 20 Apr 2004 20:08:51 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=2521 >

On the topic of effects-pre:

- I don't understand why there is a game.can_xxx and also a 
pplayer->can_nuke.

- I don't understand why can_xxx is needed when we could just check 
game.global_wonders[id] (where id is determined by some flag).  Is it 
because the effect need not always come from a wonder?

But anyway...

This patch is an "update" of effects-pre8 that hopefully makes these 
values work.  I haven't tested it.

- game.can_xxx is kept and is actually sent to the client.

- pplayer->can_xxx is removed.

- game.can_xxx is set when the appropriate wonders are built (eventually 
this should be a flag or effect; for now it's just hard-coded to the 
enumerated value).

- game.can_xxx is checked instead of checking for the existance of those 
wonders.

- Savegame backwards compatability is added.  If the appropriate 
capability isn't set the game checks game.global_wonders to find out if 
the appropriate wonders have been built.

As a side note, the savegame capstring is pretty long.  Since we rarely 
break savegame compatability it will probably continue to grow.

jason

? cma_weirdness
? diff
? data/civ3
? data/womoks
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.362
diff -u -r1.362 packhand.c
--- client/packhand.c   14 Apr 2004 17:18:36 -0000      1.362
+++ client/packhand.c   21 Apr 2004 03:06:51 -0000
@@ -1336,6 +1336,8 @@
   game.heating=pinfo->heating;
   game.nuclearwinter=pinfo->nuclearwinter;
   game.cooling=pinfo->cooling;
+  game.can_nuke = pinfo->can_nuke;
+  game.can_space = pinfo->can_space;
   if (!can_client_change_view()) {
     improvement_status_init(game.improvements,
                            ARRAY_SIZE(game.improvements));
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.178
diff -u -r1.178 game.c
--- common/game.c       10 Apr 2004 23:05:51 -0000      1.178
+++ common/game.c       21 Apr 2004 03:06:51 -0000
@@ -257,6 +257,10 @@
 
   game.heating     = 0;
   game.cooling     = 0;
+
+  game.can_nuke    = FALSE;
+  game.can_space   = FALSE;
+
   sz_strlcpy(game.save_name, GAME_DEFAULT_SAVE_NAME);
   game.save_nturns=10;
 #ifdef HAVE_LIBZ
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.134
diff -u -r1.134 game.h
--- common/game.h       14 Apr 2004 10:57:26 -0000      1.134
+++ common/game.h       21 Apr 2004 03:06:51 -0000
@@ -120,6 +120,9 @@
   int coolinglevel; /* If nuclearwinter is higher than this number there is
                       a chance of a cooling event. */
 
+  bool can_nuke;        /* bits to record the two effects which survive */
+  bool can_space;       /* their origin's destruction. */
+
   char save_name[MAX_LEN_NAME];
   int save_nturns;
   int save_compress_level;
Index: common/improvement.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.c,v
retrieving revision 1.36
diff -u -r1.36 improvement.c
--- common/improvement.c        25 Feb 2004 20:23:49 -0000      1.36
+++ common/improvement.c        21 Apr 2004 03:06:51 -0000
@@ -366,8 +366,9 @@
     while ((type = peffect->type) != EFT_LAST) {
       if (type == EFT_SPACE_PART) {
        /* TODO: remove this */
-       if (game.global_wonders[B_APOLLO] == 0)
+       if (!game.can_space) {
          return FALSE;
+       }
         if (p->spaceship.state >= SSHIP_LAUNCHED)
          return FALSE;
        if (peffect->amount == 1 && p->spaceship.structurals >= 
NUM_SS_STRUCTURALS)
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.20
diff -u -r1.20 packets.def
--- common/packets.def  14 Apr 2004 11:19:44 -0000      1.20
+++ common/packets.def  21 Apr 2004 03:06:51 -0000
@@ -337,7 +337,7 @@
   UINT8 civstyle;
   UINT8 diplomacy;
 
-  BOOL spacerace;
+  BOOL spacerace, can_nuke, can_space;
 
   UINT8 global_advances[A_LAST]; diff
   UINT16 global_wonders[B_LAST]; diff
Index: common/unittype.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.c,v
retrieving revision 1.32
diff -u -r1.32 unittype.c
--- common/unittype.c   14 Apr 2004 11:38:45 -0000      1.32
+++ common/unittype.c   21 Apr 2004 03:06:52 -0000
@@ -445,8 +445,9 @@
 
   if (!unit_type_exists(id))
     return FALSE;
-  if (unit_type_flag(id, F_NUCLEAR) && game.global_wonders[B_MANHATTEN] == 0)
+  if (unit_type_flag(id, F_NUCLEAR) && !game.can_nuke) {
     return FALSE;
+  }
   if (unit_type_flag(id, F_FANATIC)
       && !government_has_flag(get_gov_pplayer(p), G_FANATIC_TROOPS))
     return FALSE;
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.245
diff -u -r1.245 cityturn.c
--- server/cityturn.c   25 Feb 2004 20:23:50 -0000      1.245
+++ server/cityturn.c   21 Apr 2004 03:06:52 -0000
@@ -1000,6 +1000,10 @@
                       get_nation_name_plural(pplayer->nation), buffer,
                       get_tech_name(pplayer, second),
                       improvement_types[B_DARWIN].name);
+    } else if (pcity->currently_building == B_MANHATTEN) {
+      game.can_nuke = TRUE;
+    } else if (pcity->currently_building == B_APOLLO) {
+      game.can_space = TRUE;
     }
     if (space_part && pplayer->spaceship.state == SSHIP_NONE) {
       notify_player_ex(NULL, pcity->x, pcity->y, E_SPACESHIP,
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.131
diff -u -r1.131 gamehand.c
--- server/gamehand.c   10 Apr 2004 03:47:49 -0000      1.131
+++ server/gamehand.c   21 Apr 2004 03:06:52 -0000
@@ -299,6 +299,8 @@
   ginfo.foodbox = game.foodbox;
   ginfo.civstyle = game.civstyle;
   ginfo.spacerace = game.spacerace;
+  ginfo.can_nuke = game.can_nuke;
+  ginfo.can_space = game.can_space;
   ginfo.unhappysize = game.unhappysize;
   ginfo.angrycitizen = game.angrycitizen;
   ginfo.diplcost = game.diplcost;
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.149
diff -u -r1.149 savegame.c
--- server/savegame.c   26 Mar 2004 17:31:55 -0000      1.149
+++ server/savegame.c   21 Apr 2004 03:06:53 -0000
@@ -176,7 +176,7 @@
    and rulesets */
 #define SAVEFILE_OPTIONS "startoptions spacerace2 rulesets" \
 " diplchance_percent worklists2 map_editor known32fix turn " \
-"attributes watchtower rulesetdir client_worklists orders"
+"attributes watchtower rulesetdir client_worklists orders can_nuke"
 
 static const char hex_chars[] = "0123456789abcdef";
 static const char terrain_chars[] = "adfghjm prstu";
@@ -2005,6 +2005,14 @@
     game.warminglevel  = secfile_lookup_int(file, "game.warminglevel");
     game.nuclearwinter = secfile_lookup_int_default(file, 0, 
"game.nuclearwinter");
     game.coolinglevel  = secfile_lookup_int_default(file, 8, 
"game.coolinglevel");
+
+    if (has_capability("can_nuke", savefile_options)) {
+      game.can_nuke
+       = secfile_lookup_bool_default(file, FALSE, "game.can_nuke");
+      game.can_space
+       = secfile_lookup_bool_default(file, FALSE, "game.can_space");
+    }
+
     game.notradesize   = secfile_lookup_int_default(file, 0, 
"game.notradesize");
     game.fulltradesize = secfile_lookup_int_default(file, 1, 
"game.fulltradesize");
     game.unhappysize   = secfile_lookup_int(file, "game.unhappysize");
@@ -2292,6 +2300,16 @@
        * loaded (in player_load) but before player (dumb) cities are loaded
        * (in player_map_load). */
       generic_city_refresh(pcity, FALSE, NULL);
+
+      if (!has_capability("can_nuke", savefile_options)) {
+       /* For older savegames that don't have can_nuke or can_space, we
+        * look at the list of global wonders directly.  Once the impr
+        * enum goes away these values should be hard-coded.  However it
+        * should not be removed or converted into an effects check, since
+        * these effects didn't exist in the older savegames. */
+       game.can_nuke = (game.global_wonders[B_MANHATTEN] != 0);
+       game.can_space = (game.global_wonders[B_APOLLO] != 0);
+      }
     } cities_iterate_end;
 
     /* Since the cities must be placed on the map to put them on the
@@ -2423,6 +2441,8 @@
   secfile_insert_int(file, game.warminglevel, "game.warminglevel");
   secfile_insert_int(file, game.nuclearwinter, "game.nuclearwinter");
   secfile_insert_int(file, game.coolinglevel, "game.coolinglevel");
+  secfile_insert_bool(file, game.can_nuke, "game.can_nuke");
+  secfile_insert_bool(file, game.can_space, "game.can_space");
   secfile_insert_int(file, game.notradesize, "game.notradesize");
   secfile_insert_int(file, game.fulltradesize, "game.fulltradesize");
   secfile_insert_int(file, game.unhappysize, "game.unhappysize");

[Prev in Thread] Current Thread [Next in Thread]