Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7095) No Capital, and can't build one..
Home

[Freeciv-Dev] (PR#7095) No Capital, and can't build one..

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: admerik@xxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7095) No Capital, and can't build one..
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 25 Jan 2004 23:43:19 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Sat Jan 24 03:29:08 2004]:
> 
> > [jrincayc - Fri Jan 23 21:23:12 2004]:
> 
> > It could instead add a sell message which defaults to nothing.  
> > Then add the sell message to the buildings.ruleset for palace.
> > This has the advantage of allowing any building to have a sell message.
> 
> Indeed.  I suppose this may be marginally cleaner.

Here's a new version with (untested) support for other clients.

jason

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.345
diff -u -r1.345 packhand.c
--- client/packhand.c   2004/01/20 21:52:07     1.345
+++ client/packhand.c   2004/01/26 07:42:40
@@ -2163,6 +2163,8 @@
   b->sabotage = p->sabotage;
   b->variant = p->variant;     /* FIXME: remove when gen-impr obsoletes */
   b->helptext = mystrdup(p->helptext);
+  b->sell_message = ((p->sell_message[0] != '\0')
+                    ? mystrdup(p->sell_message) : NULL);
   sz_strlcpy(b->soundtag, p->soundtag);
   sz_strlcpy(b->soundtag_alt, p->soundtag_alt);
 
Index: client/gui-gtk/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v
retrieving revision 1.175
diff -u -r1.175 citydlg.c
--- client/gui-gtk/citydlg.c    2004/01/06 08:11:33     1.175
+++ client/gui-gtk/citydlg.c    2004/01/26 07:42:40
@@ -3117,6 +3117,11 @@
   pdialog->sell_id = id;
   my_snprintf(buf, sizeof(buf), _("Sell %s for %d gold?"),
              get_impr_name_ex(pdialog->pcity, id), improvement_value(id));
+  if (impr->sell_message) {
+    my_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+               "\n\n%s", impr->sell_message);
+  }
+
 
   pdialog->sell_shell = popup_message_dialog(pdialog->shell,
                                             _("Sell It!"), buf,
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.69
diff -u -r1.69 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        2004/01/07 23:16:17     1.69
+++ client/gui-gtk-2.0/citydlg.c        2004/01/26 07:42:41
@@ -2371,8 +2371,10 @@
 static void sell_callback(Impr_Type_id id, gpointer data)
 {
   struct city_dialog *pdialog = (struct city_dialog *) data;
+  struct impr_type *impr = get_improvement_type(id);
   GtkWidget *shl;
-  
+  char buf[512];
+
   if (pdialog->pcity->did_buy || pdialog->pcity->did_sell ||
       pdialog->pcity->owner != game.player_idx) {
     return;
@@ -2384,12 +2386,18 @@
 
   pdialog->sell_id = id;
 
+  my_snprintf(buf, sizeof(buf), _("Sell %s for %d gold?"),
+             get_impr_name_ex(pdialog->pcity, id), improvement_value(id));
+  if (impr->sell_message) {
+    my_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+               "\n\n%s", impr->sell_message);
+  }
+
   shl = gtk_message_dialog_new(GTK_WINDOW(pdialog->shell),
     GTK_DIALOG_DESTROY_WITH_PARENT,
     GTK_MESSAGE_QUESTION,
     GTK_BUTTONS_YES_NO,
-    _("Sell %s for %d gold?"),
-    get_impr_name_ex(pdialog->pcity, id), improvement_value(id));
+                              buf);
   pdialog->sell_shell = shl;
   
   gtk_window_set_title(GTK_WINDOW(shl), _("Sell It!"));
Index: client/gui-sdl/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/citydlg.c,v
retrieving revision 1.41
diff -u -r1.41 citydlg.c
--- client/gui-sdl/citydlg.c    2004/01/05 00:18:30     1.41
+++ client/gui-sdl/citydlg.c    2004/01/26 07:42:41
@@ -1443,6 +1443,10 @@
   my_snprintf(cBuf, sizeof(cBuf), _("Sell %s for %d gold?"),
              get_impr_name_ex(pCityDlg->pCity, id),
              improvement_value(id));
+  if (impr->sell_message) {
+    my_snprintf(cbuf + strlen(cbuf), sizeof(cbuf) - strlen(cbuf),
+               "\n\n%s", impr->sell_message);
+  }
 
 
   /* create text label */
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.67
diff -u -r1.67 citydlg.c
--- client/gui-win32/citydlg.c  2004/01/06 08:11:34     1.67
+++ client/gui-win32/citydlg.c  2004/01/26 07:42:42
@@ -1028,7 +1028,8 @@
 *****************************************************************/            
 static void sell_callback(struct city_dialog *pdialog)
 {
-  char buf[100];
+  char buf[512];
+
   if (pdialog->id_selected<0) {
     return;
   }
@@ -1041,6 +1042,10 @@
   my_snprintf(buf, sizeof(buf), _("Sell %s for %d gold?"),
              get_impr_name_ex(pdialog->pcity, pdialog->id_selected),
              improvement_value(pdialog->id_selected));
+  if (impr->sell_message) {
+    my_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+               "\n\n%s", impr->sell_message);
+  }
   
   popup_message_dialog(pdialog->mainwindow, /*"selldialog" */
                       _("Sell It!"), buf, _("_Yes"),
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.108
diff -u -r1.108 citydlg.c
--- client/gui-xaw/citydlg.c    2004/01/06 08:11:34     1.108
+++ client/gui-xaw/citydlg.c    2004/01/26 07:42:42
@@ -2372,6 +2372,11 @@
        my_snprintf(buf, sizeof(buf), _("Sell %s for %d gold?"),
                    get_impr_name_ex(pdialog->pcity, i),
                    improvement_value(i));
+       if (impr->sell_message) {
+         my_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+                     "\n\n%s", impr->sell_message);
+       }
+
 
        popup_message_dialog(pdialog->shell, "selldialog", buf,
                             sell_callback_yes, pdialog, 0,
Index: common/improvement.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.h,v
retrieving revision 1.21
diff -u -r1.21 improvement.h
--- common/improvement.h        2003/08/10 13:46:14     1.21
+++ common/improvement.h        2004/01/26 07:42:42
@@ -119,6 +119,7 @@
   int variant;                 /* FIXME: remove when gen-impr obsoletes */
   struct Sprite *sprite;               /* icon of the improvement */
   char *helptext;
+  char *sell_message;
   char soundtag[MAX_LEN_NAME];
   char soundtag_alt[MAX_LEN_NAME];
 };
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.7
diff -u -r1.7 packets.def
--- common/packets.def  2004/01/20 21:52:08     1.7
+++ common/packets.def  2004/01/26 07:42:42
@@ -1119,6 +1119,7 @@
   STRING soundtag[MAX_LEN_NAME];
   STRING soundtag_alt[MAX_LEN_NAME];
   STRING helptext[MAX_LEN_PACKET];
+  STRING sell_message[MAX_LEN_PACKET];
   UINT8 terr_gate_count;
   TERRAIN terr_gate[255:terr_gate_count];
   UINT8 spec_gate_count;
Index: data/civ1/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/buildings.ruleset,v
retrieving revision 1.32
diff -u -r1.32 buildings.ruleset
--- data/civ1/buildings.ruleset 2003/09/30 23:20:09     1.32
+++ data/civ1/buildings.ruleset 2004/01/26 07:42:43
@@ -714,6 +714,7 @@
  empire plunging into civil war. Losing your current palace also\
  results in losing whatever spaceship you might have.\
 ")
+sell_message    = _("Selling your palace is usally a very bad idea!")
 
 [building_police_station]
 name           = _("Police Station")
Index: data/civ2/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/buildings.ruleset,v
retrieving revision 1.36
diff -u -r1.36 buildings.ruleset
--- data/civ2/buildings.ruleset 2003/09/30 23:20:10     1.36
+++ data/civ2/buildings.ruleset 2004/01/26 07:42:43
@@ -702,6 +702,7 @@
  empire plunging into civil war. Losing your current palace also\
  results in losing whatever spaceship you might have.\
 ")
+sell_message    = _("Selling your palace is usally a very bad idea!")
 
 [building_police_station]
 name           = _("Police Station")
Index: data/default/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/buildings.ruleset,v
retrieving revision 1.42
diff -u -r1.42 buildings.ruleset
--- data/default/buildings.ruleset      2003/09/30 23:20:10     1.42
+++ data/default/buildings.ruleset      2004/01/26 07:42:43
@@ -68,6 +68,8 @@
 ;                supported in client
 ; helptext     = optional help text string; should escape all raw
 ;                newlines so that xgettext parsing works
+; sell_message  = optional text string; it will be displayed to the player
+;                 when they try to sell the building
 ;
 ; */ <-- avoid gettext warnings
 
@@ -758,6 +760,7 @@
  empire plunging into civil war. Losing your current palace also\
  results in losing whatever spaceship you might have.\
 ")
+sell_message    = _("Selling your palace is usally a very bad idea!")
 
 [building_police_station]
 name           = _("Police Station")
Index: data/history/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/buildings.ruleset,v
retrieving revision 1.7
diff -u -r1.7 buildings.ruleset
--- data/history/buildings.ruleset      2003/09/30 23:20:10     1.7
+++ data/history/buildings.ruleset      2004/01/26 07:42:44
@@ -711,6 +711,7 @@
  empire plunging into civil war. Losing your current palace also\
  results in losing whatever spaceship you might have.\
 ")
+sell_message    = _("Selling your palace is usally a very bad idea!")
 
 [building_police_station]
 name           = _("Police Station")
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.160
diff -u -r1.160 ruleset.c
--- server/ruleset.c    2004/01/11 17:45:05     1.160
+++ server/ruleset.c    2004/01/26 07:42:44
@@ -1398,6 +1398,7 @@
               secfile_lookup_str_default(file, "-", "%s.sound_alt",
                                          sec[i]));
     b->helptext = lookup_helptext(file, sec[i]);
+    b->sell_message = lookup_string(file, sec[i], "sell_message");
   }
 
   /* Some more consistency checking: */
@@ -2744,6 +2745,12 @@
       sz_strlcpy(packet.helptext, b->helptext);
     } else {
       packet.helptext[0] = '\0';
+    }
+
+    if (b->sell_message) {
+      sz_strlcpy(packet.sell_message, b->sell_message);
+    } else {
+      packet.sell_message[0] = '\0';
     }
 
 #define T(elem,count,last) \

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