<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39982 >

> [EMAIL PROTECTED] - Sat Mar 01 12:08:48 2008]:
> 
> Looking at get_impr_name_ex(), it's fairly obvious why we never see
> "(O)" for wonders!

Yes, it is because for wonders 'state' is always set to either
the "built" string or the "wonder" string, even though it was
set to "obsolete" in the block above.

> The attached trivial patch (against 2.1.3) reinstates "(O)" for
> wonders (and potentially "(*)" as well, although I don't know if
> that can happen in practice).

Maybe for small wonders in some strange rulesets. Not as
far as I can see anyway.

> Looking through svn (trying to see if it's the way it is for a good
> reason), I think the semantics of this part of the function last
> significantly changed in r9379, PR#11477, 2004-12-19. I think it was
> dodgy before that, too, but in a different way.

You are right that r9369 changed the if-else block to two
if blocks (with the second clobbering the results of the first
for wonders).

> This function still seems a bit fishy to me. It looks as if for
> non-wonders, my_snprintf() could end up getting called with
> state==NULL (with or without my patch), which seems wrong. I
> don't know if this is a problem in practice; I haven't
> investigated further.

Actually no, there is a test for "state != NULL" (with
the "!= NULL" implicit) in which case my_snprintf does
not get called and the function just returns the result
of improvement_name_translation.

> (Also, in the specific case of wonders, the function could in
> principle say that a wonder was obsolete even if pcity==NULL,
> because wonder obsoletion is global and known to all; but the
> current implementation only attempts to do this in the context
> of a city/player. Again, dunno if this is a real problem; I
> didn't find anywhere obvious where this function was called
> with pcity==NULL.)

I did not find any obvious places where this would be called
with a NULL pcity either. Probably because it would be hard to
have a building without a city. ;)

Anyway, I fixed up your patch according to
http://freeciv.wikia.com/wiki/How_to_Contribute
and also ported the changes to a version for S2_2 and
trunk.

If nobody cries, I'll commit this in a few days.


----------------------------------------------------------------------
長い間でしたね。
diff --git a/common/city.c b/common/city.c
index 3ad55ea..435bd78 100644
--- a/common/city.c
+++ b/common/city.c
@@ -345,6 +345,13 @@ const char *get_impr_name_ex(const struct city *pcity, Impr_type_id id)
   static char buffer[256];
   const char *state = NULL;
 
+  if (is_great_wonder(id)) {
+    if (great_wonder_was_built(id)) {
+      state = Q_("?built:B");
+    } else {
+      state = Q_("?wonder:w");
+    }
+  }
   if (pcity) {
     struct player *pplayer = city_owner(pcity);
 
@@ -355,13 +362,6 @@ const char *get_impr_name_ex(const struct city *pcity, Impr_type_id id)
       state = Q_("?redundant:*");
     }
   }
-  if (is_great_wonder(id)) {
-    if (great_wonder_was_built(id)) {
-      state = Q_("?built:B");
-    } else {
-      state = Q_("?wonder:w");
-    }
-  }
 
   if (state) {
     my_snprintf(buffer, sizeof(buffer), "%s(%s)",
diff --git a/common/city.c b/common/city.c
index a1e78bb..f9c1efe 100644
--- a/common/city.c
+++ b/common/city.c
@@ -288,6 +288,13 @@ const char *city_improvement_name_translation(const struct city *pcity,
   static char buffer[256];
   const char *state = NULL;
 
+  if (is_great_wonder(pimprove)) {
+    if (great_wonder_was_built(pimprove)) {
+      state = Q_("?built:B");
+    } else {
+      state = Q_("?wonder:w");
+    }
+  }
   if (pcity) {
     struct player *pplayer = city_owner(pcity);
 
@@ -298,13 +305,6 @@ const char *city_improvement_name_translation(const struct city *pcity,
       state = Q_("?redundant:*");
     }
   }
-  if (is_great_wonder(pimprove)) {
-    if (great_wonder_was_built(pimprove)) {
-      state = Q_("?built:B");
-    } else {
-      state = Q_("?wonder:w");
-    }
-  }
 
   if (state) {
     my_snprintf(buffer, sizeof(buffer), "%s(%s)",
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to