Author: cazfi
Date: Wed Jun 29 12:24:29 2016
New Revision: 33108

URL: http://svn.gna.org/viewcvs/freeciv?rev=33108&view=rev
Log:
Correceted the way sdl-clients calculate production change penalty.

See bug #24807

Modified:
    branches/S2_6/client/gui-sdl/wldlg.c
    branches/S2_6/client/gui-sdl2/wldlg.c

Modified: branches/S2_6/client/gui-sdl/wldlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/wldlg.c?rev=33108&r1=33107&r2=33108&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/wldlg.c        (original)
+++ branches/S2_6/client/gui-sdl/wldlg.c        Wed Jun 29 12:24:29 2016
@@ -287,38 +287,38 @@
   flush_dirty();
 }
 
-/*
- * Find if two targets are the same class (unit, imprv. , wonder).
- * This is needed by calculation of change production shields penalty.
- * [similar to are_universals_equal()]
- */
-static bool are_the_same_class(const struct universal *one,
-                               const struct universal *two)
+/**************************************************************************
+  Find if two targets are the same class (unit, imprv. , wonder).
+  This is needed by calculation of change production shields penalty.
+  [similar to are_universals_equal()]
+**************************************************************************/
+static bool are_prods_same_class(const struct universal *one,
+                                 const struct universal *two)
 {
   if (one->kind != two->kind) {
     return FALSE;
   }
-  if (VUT_UTYPE == one->kind) {
-    return one->value.utype == two->value.utype;
-  }
+
   if (VUT_IMPROVEMENT == one->kind) {
     if (is_wonder(one->value.building)) {
       return is_wonder(two->value.building);
-    }
-    return (one->value.building == two->value.building);
-  }
+    } else {
+      return !is_wonder(two->value.building);
+    }
+  }
+
   return FALSE;
 }
 
-/*
- * Change production in editor shell, callculate production shields penalty and
- * refresh production progress label
- */
+/**************************************************************************
+  Change production in editor shell, calculate production shields penalty and
+  refresh production progress label
+**************************************************************************/
 static void change_production(struct universal *prod)
 {
-  if (!are_the_same_class(&pEditor->currently_building, prod)) {
+  if (!are_prods_same_class(&pEditor->currently_building, prod)) {
     if (pEditor->stock != pEditor->pCity->shield_stock) {
-      if (are_the_same_class(&pEditor->pCity->production, prod)) {
+      if (are_prods_same_class(&pEditor->pCity->production, prod)) {
         pEditor->stock = pEditor->pCity->shield_stock;
       }
     } else {

Modified: branches/S2_6/client/gui-sdl2/wldlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/wldlg.c?rev=33108&r1=33107&r2=33108&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/wldlg.c       (original)
+++ branches/S2_6/client/gui-sdl2/wldlg.c       Wed Jun 29 12:24:29 2016
@@ -300,35 +300,33 @@
   This is needed by calculation of change production shields penalty.
   [similar to are_universals_equal()]
 **************************************************************************/
-static bool are_the_same_class(const struct universal *one,
-                               const struct universal *two)
+static bool are_prods_same_class(const struct universal *one,
+                                 const struct universal *two)
 {
   if (one->kind != two->kind) {
     return FALSE;
   }
-  if (VUT_UTYPE == one->kind) {
-    return one->value.utype == two->value.utype;
-  }
+
   if (VUT_IMPROVEMENT == one->kind) {
     if (is_wonder(one->value.building)) {
       return is_wonder(two->value.building);
-    }
-
-    return (one->value.building == two->value.building);
+    } else {
+      return !is_wonder(two->value.building);
+    }
   }
 
   return FALSE;
 }
 
 /**************************************************************************
-  Change production in editor shell, callculate production shields penalty and
+  Change production in editor shell, calculate production shields penalty and
   refresh production progress label
 **************************************************************************/
 static void change_production(struct universal *prod)
 {
-  if (!are_the_same_class(&pEditor->currently_building, prod)) {
+  if (!are_prods_same_class(&pEditor->currently_building, prod)) {
     if (pEditor->stock != pEditor->pCity->shield_stock) {
-      if (are_the_same_class(&pEditor->pCity->production, prod)) {
+      if (are_prods_same_class(&pEditor->pCity->production, prod)) {
         pEditor->stock = pEditor->pCity->shield_stock;
       }
     } else {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to