Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7211) units can't be upgraded
Home

[Freeciv-Dev] Re: (PR#7211) units can't be upgraded

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ggracian@xxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7211) units can't be upgraded
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 7 Jan 2004 15:09:44 -0800
Reply-to: rt@xxxxxxxxxxx

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

Genevieve Gracian wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7211 >
> 
> Hello,
> 
> On recent cvs head version (less than 1 week), units can't be upgraded :
> 
> - units in cities are too 'expensive',
> - leonardo crashes the server.

My patch was incredibly buggy.  I'm not sure how it happened; I clearly 
remember testing it.  I think I just bungled this patch altogther - at 
one point it was lost and I had to rewrite it...

jason

Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.68
diff -u -r1.68 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        2004/01/06 08:11:34     1.68
+++ client/gui-gtk-2.0/citydlg.c        2004/01/07 23:07:44
@@ -2215,7 +2215,7 @@
     return;
   }
 
-  if (get_unit_upgrade_info(buf, sizeof(buf), punit) == UR_OK) {
+  if (get_unit_upgrade_info(buf, sizeof(buf), punit) != UR_OK) {
     shell = gtk_message_dialog_new(NULL, 0,
                                   GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, buf);
     gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Unit!"));
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.191
diff -u -r1.191 unit.c
--- common/unit.c       2004/01/06 08:11:34     1.191
+++ common/unit.c       2004/01/07 23:07:44
@@ -1552,7 +1552,9 @@
 
   if (!is_free) {
     cost = unit_upgrade_price(pplayer, punit->type, to_unittype);
-    if (!pplayer->economic.gold < cost) {
+    if (pplayer->economic.gold < cost) {
+      freelog(LOG_NORMAL, "Test: not enough money (%d/%d).",
+             pplayer->economic.gold, cost);
       return UR_NO_MONEY;
     }
 
@@ -1584,21 +1586,22 @@
 enum unit_upgrade_result get_unit_upgrade_info(char *buf, size_t bufsz,
                                               struct unit *punit)
 {
+  struct player *pplayer = unit_owner(punit);
   enum unit_upgrade_result result = test_unit_upgrade(punit, FALSE);
   int upgrade_cost;
   Unit_Type_id from_unittype = punit->type;
-  Unit_Type_id to_unittype = can_upgrade_unittype(game.player_ptr,
+  Unit_Type_id to_unittype = can_upgrade_unittype(pplayer,
                                                  punit->type);
 
   switch (result) {
   case UR_OK:
-    upgrade_cost = unit_upgrade_price(game.player_ptr,
+    upgrade_cost = unit_upgrade_price(pplayer,
                                      from_unittype, to_unittype);
     /* This message is targeted toward the GUI callers. */
     my_snprintf(buf, bufsz, _("Upgrade %s to %s for %d gold?\n"
                              "Treasury contains %d gold."),
                unit_types[from_unittype].name, unit_types[to_unittype].name,
-               upgrade_cost, game.player_ptr->economic.gold);
+               upgrade_cost, pplayer->economic.gold);
     break;
   case UR_NO_UNITTYPE:
     my_snprintf(buf, bufsz,
@@ -1606,13 +1609,12 @@
                unit_types[from_unittype].name);
     break;
   case UR_NO_MONEY:
-    upgrade_cost = unit_upgrade_price(game.player_ptr,
-                                     from_unittype, to_unittype);
+    upgrade_cost = unit_upgrade_price(pplayer, from_unittype, to_unittype);
     my_snprintf(buf, bufsz,
                _("Upgrading %s to %s costs %d gold.\n"
                  "Treasury contains %d gold."),
                unit_types[from_unittype].name, unit_types[to_unittype].name,
-               upgrade_cost, game.player_ptr->economic.gold);
+               upgrade_cost, pplayer->economic.gold);
     break;
   case UR_NOT_IN_CITY:
   case UR_NOT_CITY_OWNER:

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