Re: [Freeciv-Dev] (PR#39895) deterministic borders (part 1)

2007-11-25 Thread William Allen Simpson

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39895 

Per I. Mathisen wrote:
 The patch that introduced it did not mention it, and none of the
 references to it that I could find, in the code and in your patch,
 said anything about what it was or what it was supposed to do. It is
 quite hopeless to try to keep up with what is happening if you do not
 even try to annotate.
 
Sadly, this is the result of dividing large and complicated patches into
smaller ones.  Not all of the comments and definitions are present.  Some
are intended to be used later

But, it's a symbol.  It's supposed to be self-documenting.

Of course, it would have been so much more helpful to simply use a 0 there
instead of a symbol (as was done by a predecessor in srv_main itself).
[that's sarcasm for the humor impaired.]



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#39895) deterministic borders (part 1)

2007-11-24 Thread Per I. Mathisen

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39895 

What is VISION_SITE_RUIN?

  - Per



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#39895) deterministic borders (part 1)

2007-11-24 Thread William Allen Simpson

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39895 

Per I. Mathisen wrote:
 What is VISION_SITE_RUIN?
 
The value I reserved (several patches ago) for the civ3-like ruin left
behind after a city is destroyed.  It will be displayed per player, just
like other non-owned cities.

Whether you noticed or not, its value (0) has always been reserved by the
global id code.  It makes a very handy constant to check against for valid
city numbers.



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#39895) deterministic borders (part 1)

2007-11-24 Thread Daniel Markstedt

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39895 

On 11/25/07, William Allen Simpson [EMAIL PROTECTED] wrote:

 URL: http://bugs.freeciv.org/Ticket/Display.html?id=39895 

 Per I. Mathisen wrote:
  What is VISION_SITE_RUIN?
 
 The value I reserved (several patches ago) for the civ3-like ruin left
 behind after a city is destroyed.  It will be displayed per player, just
 like other non-owned cities.

 Whether you noticed or not, its value (0) has always been reserved by the
 global id code.  It makes a very handy constant to check against for valid
 city numbers.



You might be interested in PR#16120 Patch: Turning destroyed cities into ruins

If nothing else, it contains some placeholder graphics.

 ~Daniel



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#39895) deterministic borders (part 1)

2007-11-23 Thread Per I. Mathisen

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39895 

On Nov 23, 2007 7:37 PM, William Allen Simpson
[EMAIL PROTECTED] wrote:
 After a fair amount of testing, here's my initial re-design of the border
 code.  I left much of the old code in place (#ifdef OWNER_SOURCE) for
 comparison.  As you can see (or I can supply screen shots), for a game in
 progress the code yields *exactly* the same borders.

That is because it is the same code... ;-)

I think you attached the wrong patch.

  - Per



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#39895) deterministic borders (part 1)

2007-11-23 Thread William Allen Simpson

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39895 

 I think you attached the wrong patch.
 
Sigh, that's what happens with too many branch windows open at the same
time  (Sorry, that was the patch I was committing in S2_1.)


Index: server/citytools.c
===
--- server/citytools.c  (revision 14015)
+++ server/citytools.c  (working copy)
@@ -838,6 +838,7 @@
   city_list_unlink(pgiver-cities, pcity);
   pcity-owner = ptaker;
   map_claim_ownership(pcity-tile, ptaker, pcity-tile);
+  map_claim_border(pcity-tile, ptaker);
   city_list_prepend(ptaker-cities, pcity);
 
   transfer_city_units(ptaker, pgiver, old_city_units,
@@ -946,31 +947,13 @@
 void create_city(struct player *pplayer, struct tile *ptile,
 const char *name)
 {
-  struct city *pcity;
   int x_itr, y_itr;
   struct nation_type *nation = nation_of_player(pplayer);
-  struct base_type *pbase;
+  struct base_type *pbase = tile_get_base(ptile);
+  struct city *pcity = create_city_virtual(pplayer, ptile, name);
 
   freelog(LOG_DEBUG, Creating city %s, name);
 
-  /* Ensure that we claim the ground we stand on */
-  map_claim_ownership(ptile, pplayer, ptile);
-
-  if (terrain_control.may_road) {
-tile_set_special(ptile, S_ROAD);
-if (player_knows_techs_with_flag(pplayer, TF_RAILROAD)) {
-  tile_set_special(ptile, S_RAILROAD);
-  update_tile_knowledge(ptile);
-}
-  }
-
-  /* It is possible that update_tile_knowledge() already sent tile information
-   * to some players, but we don't want to make any special handling for
-   * those cases.  The network code may prevent asecond packet from being
-   * sent anyway. */
-  send_tile_info(NULL, ptile, FALSE);
-
-  pcity = create_city_virtual(pplayer, ptile, name);
   pcity-ai.trade_want = TRADE_WEIGHTING;
   pcity-id = get_next_id_number();
   idex_register_city(pcity);
@@ -1007,9 +990,26 @@
   city_refresh_vision(pcity);
 
   tile_set_city(ptile, pcity);
-
   city_list_prepend(pplayer-cities, pcity);
 
+  /* Claim the ground we stand on */
+  map_claim_ownership(ptile, pplayer, ptile);
+  map_claim_border(ptile, pplayer);
+
+  if (terrain_control.may_road) {
+tile_set_special(ptile, S_ROAD);
+if (player_knows_techs_with_flag(pplayer, TF_RAILROAD)) {
+  tile_set_special(ptile, S_RAILROAD);
+  update_tile_knowledge(ptile);
+}
+  }
+
+  /* It is possible that update_tile_knowledge() already sent tile information
+   * to some players, but we don't want to make any special handling for
+   * those cases.  The network code may prevent a second packet from being
+   * sent anyway. */
+  send_tile_info(NULL, ptile, FALSE);
+
   /* it is possible to build a city on a tile that is already worked
* this will displace the worker on the newly-built city's tile -- Syela */
   for (y_itr = 0; y_itr  CITY_MAP_SIZE; y_itr++) {
@@ -1041,8 +1041,7 @@
   city_refresh(pcity);
   auto_arrange_workers(pcity);
 
-  /* Put vision back to normal, if base acted as a watchtower */
-  pbase = tile_get_base(ptile);
+  /* If base acted as a watchtower, put vision back to normal */
   if (pbase) {
 tile_remove_base(ptile);
 unit_list_refresh_vision(ptile-units);
@@ -1709,7 +1708,6 @@
 bool update_dumb_city(struct player *pplayer, struct city *pcity)
 {
   bv_imprs improvements;
-  struct player_tile *plrtile = map_get_player_tile(pcity-tile, pplayer);
   struct vision_site *pdcity = map_get_player_city(pcity-tile, pplayer);
   /* pcity-occupied isn't used at the server, so we go straight to the
* unit list to check the occupied status. */
@@ -1726,37 +1724,31 @@
 }
   } improvement_iterate_end;
 
-  if (pdcity
-   pdcity-identity == pcity-id
-   strcmp(pdcity-name, pcity-name) == 0
-   pdcity-size == pcity-size
-   pdcity-occupied == occupied
-   pdcity-walls == walls
-   pdcity-happy == happy
-   pdcity-unhappy == unhappy
-   vision_owner(pdcity) == city_owner(pcity)
-   BV_ARE_EQUAL(pdcity-improvements, improvements)) {
+  if (NULL == pdcity) {
+pdcity = create_vision_site_from_city(pcity);
+map_get_player_tile(pcity-tile, pplayer)-site = pdcity;
+  } else if (pdcity-identity == pcity-id
+  vision_owner(pdcity) == city_owner(pcity)
+  pdcity-size == pcity-size
+  0 == strcmp(pdcity-name, pcity-name)
+  pdcity-occupied == occupied
+  pdcity-walls == walls
+  pdcity-happy == happy
+  pdcity-unhappy == unhappy
+  BV_ARE_EQUAL(pdcity-improvements, improvements)) {
 return FALSE;
   }
 
-  if (NULL == pdcity) {
-pdcity = plrtile-site = fc_calloc(1, sizeof(*pdcity));
-pdcity-identity = pcity-id;
-  }
   if (pdcity-identity != pcity-id) {
 freelog(LOG_ERROR, Trying to update old city (wrong ID)
 at %i,%i for player %s,
-   pcity-tile-x, pcity-tile-y, pplayer-name);
+   TILE_XY(pcity-tile), pplayer-name);
 pdcity-identity = pcity-id;   /* ??