Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] (PR#7232) message each time changing production
Home

[Freeciv-Dev] (PR#7232) message each time changing production

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7232) message each time changing production
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 5 Feb 2004 20:12:17 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [per - Sun Jan 11 11:15:47 2004]:
> 
> I seem to be getting a message in the message dialog every time I change
> city production. Surely this is new, and surely this is a bug.

This bug is caused by the following change (see "cvs annotate" and "cvs
log"):

date: 2003/11/19 04:40:13;  author: jdorje;  state: Exp;  lines: +9 -4
Replace some 'int' types with 'enum event_type'.  Also fix a buglet
where 0 was used in place of E_NOEVENT.
 
Patch by Raimar Falke as PR#6870, with style changes and added comments
by me.

Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.240
diff -u -u -r1.240 citytools.c
--- server/citytools.c  2003/11/07 09:45:03     1.240
+++ server/citytools.c  2003/11/15 15:08:29
@@ -1872,7 +1872,7 @@
   }
 
   /* Tell the player what's up. */
-  if (event != 0)
+  if (event != E_NOEVENT)
     notify_player_ex(pplayer, pcity->x, pcity->y, event,
                     _("Game: %s is building %s%s."),
                     pcity->name, name, source);

This change certainly fixed a bug.  But there were two bugs working
together to get the right result (two wrongs do make a right!), so now
things don't work.  Because E_NOEVENT is passed in to the function
(E_NOEVENT == -1), the "else" clause is now invoked which causes
E_UNIT_BUILD to (incorrectly) be the event sent to the client (rather
than E_NOEVENT).  Thus we get the buggy behavior of change-build events
being treated like build-completed events.

The attached patch should fix this; it adds a new event.

jason

? server/annotate
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.92
diff -u -r1.92 options.c
--- client/options.c    2004/02/06 01:01:11     1.92
+++ client/options.c    2004/02/06 04:10:33
@@ -198,6 +198,7 @@
   GEN_EV(N_("City: Suggest Growth Throttling"),       E_CITY_GRAN_THROTTLE),
   GEN_EV(N_("City: Transfer"),                        E_CITY_TRANSFER),
   GEN_EV(N_("City: Was Built"),                       E_CITY_BUILD),
+  GEN_EV(N_("City: Production changed"), E_CITY_PRODUCTION_CHANGED),
   GEN_EV(N_("City: Worklist Events"),                 E_WORKLIST),
   GEN_EV(N_("Civ: Barbarian Uprising"),               E_UPRISING ),
   GEN_EV(N_("Civ: Civil War"),                        E_CIVIL_WAR),
@@ -259,7 +260,7 @@
   GEN_EV(N_("Unit: Attack Failed"),                   E_UNIT_LOST_ATT),
   GEN_EV(N_("Unit: Attack Succeeded"),                E_UNIT_WIN_ATT),
   GEN_EV(N_("Unit: Bought"),                          E_UNIT_BUY),
-  GEN_EV(N_("Unit: Built"),                           E_UNIT_BUILD),
+  GEN_EV(N_("Unit: Built"),                           E_UNIT_BUILT),
   GEN_EV(N_("Unit: Defender Destroyed"),              E_UNIT_LOST),
   GEN_EV(N_("Unit: Defender Survived"),               E_UNIT_WIN),
   GEN_EV(N_("Unit: Became More Veteran"),             E_UNIT_BECAME_VET),
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.154
diff -u -r1.154 capstr.c
--- common/capstr.c     2004/01/31 17:52:41     1.154
+++ common/capstr.c     2004/02/06 04:10:33
@@ -75,7 +75,7 @@
  */
 
 #define CAPABILITY "+1.14.delta +last_turns_shield_surplus veteran +orders " \
-                   "+starter +union"
+                   "+starter +union +change_production"
 
 /* "+1.14.delta" is the new delta protocol for 1.14.0-dev.
  *
@@ -90,6 +90,8 @@
  * "starter" means the Starter terrain flag is supported.
  *
  * "union" is team research ability
+ *
+ * "change_production" is the E_CITY_PRODUCTION_CHANGED event.
  */
 
 void init_our_capability(void)
Index: common/events.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/events.h,v
retrieving revision 1.25
diff -u -r1.25 events.h
--- common/events.h     2004/01/28 06:02:44     1.25
+++ common/events.h     2004/02/06 04:10:33
@@ -31,6 +31,7 @@
   E_CITY_GRAN_THROTTLE,
   E_CITY_TRANSFER,
   E_CITY_BUILD,
+  E_CITY_PRODUCTION_CHANGED,
   E_WORKLIST,
   E_UPRISING,
   E_CIVIL_WAR,
@@ -92,7 +93,7 @@
   E_UNIT_LOST_ATT,
   E_UNIT_WIN_ATT,
   E_UNIT_BUY,
-  E_UNIT_BUILD,
+  E_UNIT_BUILT,
   E_UNIT_LOST,
   E_UNIT_WIN,
   E_UNIT_BECAME_VET,
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.250
diff -u -r1.250 citytools.c
--- server/citytools.c  2004/02/05 08:23:09     1.250
+++ server/citytools.c  2004/02/06 04:10:36
@@ -1958,7 +1958,7 @@
                     _("Game: %s is building %s%s."),
                     pcity->name, name, source);
   } else {
-    notify_player_ex(pplayer, pcity->x, pcity->y, E_UNIT_BUILD,
+    notify_player_ex(pplayer, pcity->x, pcity->y, E_CITY_PRODUCTION_CHANGED,
                     /* TRANS: "<city> is building <production>." */
                     _("Game: %s is building %s."), 
                     pcity->name, name);
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.242
diff -u -r1.242 cityturn.c
--- server/cityturn.c   2004/01/31 17:52:41     1.242
+++ server/cityturn.c   2004/02/06 04:10:36
@@ -1082,7 +1082,8 @@
     pcity->before_change_shields -= unit_value(pcity->currently_building);
     pcity->shield_stock -= unit_value(pcity->currently_building);
 
-    notify_player_ex(pplayer, pcity->x, pcity->y, E_UNIT_BUILD,
+    notify_player_ex(pplayer, pcity->x, pcity->y, E_UNIT_BUILT,
+                    /* TRANS: <city> is finished building <unit/building>. */
                     _("Game: %s is finished building %s."),
                     pcity->name,
                     unit_types[pcity->currently_building].name);
@@ -1421,7 +1422,8 @@
    * transferred this is not a problem. */
   transfer_city_units(pplayer, pplayer, &pcity->units_supported, rcity, pcity, 
-1, TRUE);
 
-  notify_player_ex(pplayer, x, y, E_UNIT_BUILD,
+  notify_player_ex(pplayer, x, y, E_UNIT_BUILT,
+                  /* TRANS: Settler production leads to disbanded city. */
                   _("Game: %s is disbanded into %s."), 
                   pcity->name, unit_types[pcity->currently_building].name);
   gamelog(GAMELOG_UNIT, _("%s (%i, %i) disbanded into %s by the %s"),

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7232) message each time changing production, Jason Short <=