Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] Re: HERE'S THE PATCH Re: (PR#5378) Diplomacy information i
Home

[Freeciv-Dev] Re: HERE'S THE PATCH Re: (PR#5378) Diplomacy information i

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: HERE'S THE PATCH Re: (PR#5378) Diplomacy information in map middle-click
From: "Daniel L Speyer" <dspeyer@xxxxxxxxxxx>
Date: Thu, 4 Sep 2003 12:38:50 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Genevieve Gracian wrote:

>On Wed, 3 Sep 2003 18:11:59 -0700
>"Daniel L Speyer" <dspeyer@xxxxxxxxxxx> wrote:
>
>  
>
>>When?  And what characters?  I can't reproduce this.
>>    
>>
>
>On both gtk and xaw clients (but not gtk+) when middle cliking on any unit e.g:
>
>Unit: Explorer(SiouxWEIRD_STRING)
>
>note WEIRD_STRING is the same for all units at the same time.
>
>I guess it's the "tmp" in :
>
You are right, I forgot to initialize tmp.  I don't know why I never saw 
anything wrong, but wild pointers are like that.

Here's the fixed version.

--Daniel

>
>my_snprintf(buf, sizeof(buf), _("\nUnit: %s(%s%s)"), ptype->name,
>       get_nation_name(unit_owner(punit)->nation), tmp)
>
>wich doesn't fit to other clients than gtk+ (tested with both 24/08 and 
>yesterday
>version of cvs).
>
>--
>G. Gracian
>
>  
>


diff -ur freeciv-cvs-Aug-24-orig/client/gui-gtk/mapctrl.c 
freeciv-cvs-Aug-24-popup/client/gui-gtk/mapctrl.c
--- freeciv-cvs-Aug-24-orig/client/gui-gtk/mapctrl.c    2003-08-24 
21:38:19.000000000 +0000
+++ freeciv-cvs-Aug-24-popup/client/gui-gtk/mapctrl.c   2003-09-03 
13:09:53.000000000 +0000
@@ -68,147 +68,28 @@
 **************************************************************************/
 static void popit(GdkEventButton *event, int xtile, int ytile)
 {
-  GtkWidget *p, *b;
+  GtkWidget *p;
   static struct map_position cross_list[2 + 1];
   struct map_position *cross_head = cross_list;
   int i;
-  char s[512];
   static struct t_popup_pos popup_pos;
-  struct city *pcity;
   struct unit *punit;
-  struct tile *ptile = map_get_tile(xtile, ytile);
 
   if(tile_get_known(xtile, ytile) >= TILE_KNOWN_FOGGED) {
     p=gtk_window_new(GTK_WINDOW_POPUP);
-    b=gtk_vbox_new(FALSE, 0);
-    gtk_container_add(GTK_CONTAINER(p), b);
+    gtk_container_add(GTK_CONTAINER(p), gtk_label_new(popup_info_text(xtile, 
ytile)));
 
-#ifdef DEBUG    
-    my_snprintf(s, sizeof(s), _("Location: (%d, %d) [%d]"), xtile, ytile, 
-                ptile->continent);
-    gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                   "GtkLabel::label", s, NULL);
-#endif /* DEBUG */
-
-    my_snprintf(s, sizeof(s), _("Terrain: %s"),
-               map_get_tile_info_text(xtile, ytile));
-    gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                  "GtkLabel::label", s, NULL);
-
-    my_snprintf(s, sizeof(s), _("Food/Prod/Trade: %s"),
-               map_get_tile_fpt_text(xtile, ytile));
-    gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                   "GtkLabel::label", s, NULL);
-
-    if (tile_has_special(ptile, S_HUT)) {
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label", 
-                                     _("Minor Tribe Village"), NULL);
-    }
-
-    pcity = map_get_city(xtile, ytile);
-    if (game.borders > 0 && !pcity) {
-      struct player *owner = map_get_owner(xtile, ytile);
-      if (owner) {
-       my_snprintf(s, sizeof(s), _("Claimed by %s"),
-                   get_nation_name(owner->nation));
-       gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                      "GtkLabel::label", s, NULL);
-      } else {
-       gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                      "GtkLabel::label",
-                                      _("Unclaimed territory"), NULL);
-      }
-    }
-    
-    if (pcity) {
-      my_snprintf(s, sizeof(s), _("City: %s(%s)"), pcity->name,
-                 get_nation_name(city_owner(pcity)->nation));
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label", s, NULL);
-
-      if (city_got_citywalls(pcity)) {
-        gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                      "GtkLabel::label", _("with City Walls"), NULL);
-      }
-    }
-
-    if(get_tile_infrastructure_set(ptile)) {
-      sz_strlcpy(s, _("Infrastructure: "));
-      sz_strlcat(s, map_get_infrastructure_text(ptile->special));
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label", s, NULL);
-    }
-    
-    sz_strlcpy(s, _("Activity: "));
-    if (concat_tile_activity_text(s, sizeof(s), xtile, ytile)) {
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                    "GtkLabel::label", s, NULL);
-    }
-    
-    if((punit = find_visible_unit(ptile)) && !pcity) {
-      char cn[64];
-      struct unit_type *ptype = unit_type(punit);
-      cn[0] = '\0';
-      if(punit->owner == game.player_idx) {
-       struct city *pcity;
-       pcity=player_find_city_by_id(game.player_ptr, punit->homecity);
-       if(pcity)
-         my_snprintf(cn, sizeof(cn), "/%s", pcity->name);
-      }
-      my_snprintf(s, sizeof(s), _("Unit: %s(%s%s)"), ptype->name,
-                 get_nation_name(unit_owner(punit)->nation), cn);
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label", s, NULL);
-
-      if(punit->owner == game.player_idx)  {
-       char uc[64] = "";
-       if(unit_list_size(&ptile->units) >= 2) {
-         my_snprintf(uc, sizeof(uc), _("  (%d more)"),
-                     unit_list_size(&ptile->units) - 1);
-       }
-        my_snprintf(s, sizeof(s), _("A:%d D:%d FP:%d HP:%d/%d%s%s"),
-                   ptype->attack_strength, 
-                   ptype->defense_strength, ptype->firepower, punit->hp, 
-                   ptype->hp, punit->veteran ? _(" V") : "", uc);
-
-        if(punit->activity == ACTIVITY_GOTO || punit->connecting)  {
-         cross_head->x = goto_dest_x(punit);
-         cross_head->y = goto_dest_y(punit);
-         cross_head++;
-        }
-      } else {
-        struct unit *apunit;
-        
-        /* calculate chance to win */
-        if ((apunit = get_unit_in_focus())) {
-          /* chance to win when active unit is attacking the selected unit */
-          int att_chance = unit_win_chance(apunit, punit) * 100;
-
-          /* chance to win when selected unit is attacking the active unit */
-          int def_chance = (1.0 - unit_win_chance(punit, apunit)) * 100;
-
-          my_snprintf(s, sizeof(s), _("Chance to win: A:%d%% D:%d%%"),
-               att_chance, def_chance);
-          gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                         "GtkLabel::label", s, NULL);
-        }
-
-        my_snprintf(s, sizeof(s), _("A:%d D:%d FP:%d HP:%d0%%"),
-                   ptype->attack_strength, 
-                   ptype->defense_strength, ptype->firepower, 
-                   (punit->hp * 100 / ptype->hp + 9) / 10);
-      }
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label", s, NULL);
+    punit = find_visible_unit(map_get_tile(xtile, ytile));
+    if(punit && (punit->activity == ACTIVITY_GOTO || punit->connecting))  {
+      cross_head->x = goto_dest_x(punit);
+      cross_head->y = goto_dest_y(punit);
+      cross_head++;
     }
 
     cross_head->x = xtile;
     cross_head->y = ytile;
     cross_head++;
 
-    gtk_widget_show_all(b);
-
     cross_head->x = -1;
     for (i = 0; cross_list[i].x >= 0; i++) {
       put_cross_overlay_tile(cross_list[i].x, cross_list[i].y);
@@ -224,7 +105,7 @@
                        GTK_SIGNAL_FUNC(popupinfo_positioning_callback), 
                        &popup_pos);
 
-    gtk_widget_show(p);
+    gtk_widget_show_all(p);
     gdk_pointer_grab(p->window, TRUE, GDK_BUTTON_RELEASE_MASK,
                     NULL, NULL, event->time);
     gtk_grab_add(p);
diff -ur freeciv-cvs-Aug-24-orig/client/gui-gtk-2.0/mapctrl.c 
freeciv-cvs-Aug-24-popup/client/gui-gtk-2.0/mapctrl.c
--- freeciv-cvs-Aug-24-orig/client/gui-gtk-2.0/mapctrl.c        2003-08-24 
21:38:20.000000000 +0000
+++ freeciv-cvs-Aug-24-popup/client/gui-gtk-2.0/mapctrl.c       2003-09-03 
15:06:04.000000000 +0000
@@ -65,161 +65,31 @@
 **************************************************************************/
 static void popit(GdkEventButton *event, int xtile, int ytile)
 {
-  GtkWidget *p, *b;
+  GtkWidget *p;
   static struct map_position cross_list[2 + 1];
   struct map_position *cross_head = cross_list;
   int i, count = 0;
   int popx, popy;
-  char s[512];
-  struct city *pcity;
   struct unit *punit;
-  struct tile *ptile = map_get_tile(xtile, ytile);
 
   if(tile_get_known(xtile, ytile) >= TILE_KNOWN_FOGGED) {
     p=gtk_window_new(GTK_WINDOW_POPUP);
     gtk_widget_set_app_paintable(p, TRUE);
     gtk_container_set_border_width(GTK_CONTAINER(p), 4);
-    b=gtk_vbox_new(FALSE, 0);
-    gtk_container_add(GTK_CONTAINER(p), b);
-
-#ifdef DEBUG    
-    my_snprintf(s, sizeof(s), _("Location: (%d, %d)"), xtile, ytile);
-    gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                   "GtkLabel::label", s, NULL);
-    count++;
-#endif /* DEBUG */
-
-    my_snprintf(s, sizeof(s), _("Terrain: %s"),
-               map_get_tile_info_text(xtile, ytile));
-    gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                  "GtkLabel::label", s, NULL);
-    count++;
-
-    my_snprintf(s, sizeof(s), _("Food/Prod/Trade: %s"),
-               map_get_tile_fpt_text(xtile, ytile));
-    gtk_widget_new(GTK_TYPE_LABEL,  "GtkWidget::parent", b,
-                                   "GtkLabel::label", s, NULL);
-    count++;
-
-    if (tile_has_special(ptile, S_HUT)) {
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label",
-                                    _("Minor Tribe Village"), NULL);
-      count++;
-    }
 
-    pcity = map_get_city(xtile, ytile);
+    gtk_container_add(GTK_CONTAINER(p), gtk_label_new(popup_info_text(xtile, 
ytile)));
 
-    if (game.borders > 0 && !pcity) {
-      struct player *owner = map_get_owner(xtile, ytile);
-      if (owner) {
-        my_snprintf(s, sizeof(s), _("Claimed by %s"),
-                   get_nation_name(owner->nation));
-        gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                      "GtkLabel::label", s, NULL);
-      } else {
-        gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                      "GtkLabel::label",
-                                      _("Unclaimed territory"), NULL);
-      }
-      count++;
-    }
-    
-    if (pcity) {
-      my_snprintf(s, sizeof(s), _("City: %s(%s)"), pcity->name,
-                 get_nation_name(city_owner(pcity)->nation));
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label", s, NULL);
-      count++;
-
-      if (city_got_citywalls(pcity)) {
-        gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                      "GtkLabel::label", _("with City Walls"), NULL);
-       count++;
-      }
-    }
-
-    if(get_tile_infrastructure_set(ptile)) {
-      sz_strlcpy(s, _("Infrastructure: "));
-      sz_strlcat(s, map_get_infrastructure_text(ptile->special));
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label", s, NULL);
-      count++;
-    }
-    
-    sz_strlcpy(s, _("Activity: "));
-    if (concat_tile_activity_text(s, sizeof(s), xtile, ytile)) {
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                    "GtkLabel::label", s, NULL);
-      count++;
-    }
-    
-    if((punit = find_visible_unit(ptile)) && !pcity) {
-      char cn[64];
-      struct unit_type *ptype = unit_type(punit);
-      cn[0] = '\0';
-      if(punit->owner == game.player_idx) {
-       struct city *pcity;
-       pcity=player_find_city_by_id(game.player_ptr, punit->homecity);
-       if(pcity)
-         my_snprintf(cn, sizeof(cn), "/%s", pcity->name);
-      }
-      my_snprintf(s, sizeof(s), _("Unit: %s(%s%s)"), ptype->name,
-                 get_nation_name(unit_owner(punit)->nation), cn);
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label", s, NULL);
-      count++;
-
-      if(punit->owner == game.player_idx)  {
-       char uc[64] = "";
-       if(unit_list_size(&ptile->units) >= 2) {
-         my_snprintf(uc, sizeof(uc), _("  (%d more)"),
-                     unit_list_size(&ptile->units) - 1);
-       }
-        my_snprintf(s, sizeof(s), _("A:%d D:%d FP:%d HP:%d/%d%s%s"),
-                   ptype->attack_strength, 
-                   ptype->defense_strength, ptype->firepower, punit->hp, 
-                   ptype->hp, punit->veteran ? _(" V") : "", uc);
-
-        if(punit->activity == ACTIVITY_GOTO || punit->connecting)  {
-         cross_head->x = goto_dest_x(punit);
-         cross_head->y = goto_dest_y(punit);
-         cross_head++;
-        }
-      } else {
-        struct unit *apunit;
-        
-        /* calculate chance to win */
-        if ((apunit = get_unit_in_focus())) {
-          /* chance to win when active unit is attacking the selected unit */
-          int att_chance = unit_win_chance(apunit, punit) * 100;
-
-          /* chance to win when selected unit is attacking the active unit */
-          int def_chance = (1.0 - unit_win_chance(punit, apunit)) * 100;
-
-          my_snprintf(s, sizeof(s), _("Chance to win: A:%d%% D:%d%%"),
-               att_chance, def_chance);
-          gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                         "GtkLabel::label", s, NULL);
-          count++;
-        }
-
-        my_snprintf(s, sizeof(s), _("A:%d D:%d FP:%d HP:%d0%%"),
-                   ptype->attack_strength, 
-                   ptype->defense_strength, ptype->firepower, 
-                   (punit->hp * 100 / ptype->hp + 9) / 10 );
-      }
-      gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
-                                    "GtkLabel::label", s, NULL);
-      count++;
+    punit = find_visible_unit(map_get_tile(xtile, ytile));
+    if(punit && (punit->activity == ACTIVITY_GOTO || punit->connecting)) {
+      cross_head->x = goto_dest_x(punit);
+      cross_head->y = goto_dest_y(punit);
+      cross_head++;
     }
 
     cross_head->x = xtile;
     cross_head->y = ytile;
     cross_head++;
 
-    gtk_widget_show_all(b);
-
     cross_head->x = -1;
     for (i = 0; cross_list[i].x >= 0; i++) {
       put_cross_overlay_tile(cross_list[i].x, cross_list[i].y);
@@ -234,7 +104,7 @@
     if (popy < 0)
       popy = 0;      
     gtk_window_move(GTK_WINDOW(p), popx, popy);
-    gtk_widget_show(p);
+    gtk_widget_show_all(p);
     gdk_pointer_grab(p->window, TRUE, GDK_BUTTON_RELEASE_MASK,
                     NULL, NULL, event->time);
     gtk_grab_add(p);
diff -ur freeciv-cvs-Aug-24-orig/client/gui-xaw/mapctrl.c 
freeciv-cvs-Aug-24-popup/client/gui-xaw/mapctrl.c
--- freeciv-cvs-Aug-24-orig/client/gui-xaw/mapctrl.c    2003-08-24 
21:38:22.000000000 +0000
+++ freeciv-cvs-Aug-24-popup/client/gui-xaw/mapctrl.c   2003-09-03 
15:48:16.000000000 +0000
@@ -31,6 +31,7 @@
 #include <X11/Xaw/SmeBSB.h>
 #include <X11/Xaw/SmeLine.h>
 
+#include "climap.h"
 #include "fcintl.h"
 #include "game.h"
 #include "map.h"
@@ -104,80 +105,32 @@
   static struct map_position cross_list[2+1];
   struct map_position *cross_head = cross_list;
   int i;
-  char s[512];
-  struct city *pcity;
   struct unit *punit;
-  struct tile *ptile=map_get_tile(xtile, ytile);
-
+  char *content;
   
-  if(ptile->known>=TILE_KNOWN_FOGGED) {
+  if(tile_get_known(xtile, ytile)>=TILE_KNOWN_FOGGED) {
     Widget p=XtCreatePopupShell("popupinfo", simpleMenuWidgetClass,
                                map_canvas, NULL, 0);
-    my_snprintf(s, sizeof(s), _("Terrain: %s"),
-               map_get_tile_info_text(xtile, ytile));
-    XtCreateManagedWidget(s, smeBSBObjectClass, p, NULL, 0);
-
-    my_snprintf(s, sizeof(s), _("Food/Prod/Trade: %s"),
-               map_get_tile_fpt_text(xtile, ytile));
-    XtCreateManagedWidget(s, smeBSBObjectClass, p, NULL, 0);
-
-    if (tile_has_special(ptile, S_HUT)) {
-      XtCreateManagedWidget(_("Minor Tribe Village"), smeBSBObjectClass,
-                           p, NULL, 0);
-    }
-    
-    if((pcity=map_get_city(xtile, ytile))) {
-      my_snprintf(s, sizeof(s), _("City: %s(%s) %s"), pcity->name,
-                 get_nation_name(city_owner(pcity)->nation),
-                 city_got_citywalls(pcity) ? _("with City Walls") : "");
-      XtCreateManagedWidget(s, smeBSBObjectClass, p, NULL, 0);
-    }
-
-    if(get_tile_infrastructure_set(ptile)) {
-      sz_strlcpy(s, _("Infrastructure: "));
-      sz_strlcat(s, map_get_infrastructure_text(ptile->special));
-      XtCreateManagedWidget(s, smeBSBObjectClass, p, NULL, 0);
-    }
-
-    if((punit=find_visible_unit(ptile)) && !pcity) {
-      char cn[64];
-      struct unit_type *ptype=unit_type(punit);
-      cn[0]='\0';
-      if(punit->owner==game.player_idx) {
-       struct city *pcity;
-       pcity=player_find_city_by_id(game.player_ptr, punit->homecity);
-       if(pcity)
-         my_snprintf(cn, sizeof(cn), "/%s", pcity->name);
+    content = popup_info_text(xtile,ytile);
+    while(1){
+      char *end = strchr(content, '\n');
+      if (end){
+       *end=0;
       }
-      my_snprintf(s, sizeof(s), _("Unit: %s(%s%s)"), ptype->name,
-                 get_nation_name(unit_owner(punit)->nation), cn);
-      XtCreateManagedWidget(s, smeBSBObjectClass, p, NULL, 0);
-
-      if(punit->owner==game.player_idx)  {
-       char uc[64] = "";
-       if(unit_list_size(&ptile->units)>=2) {
-         my_snprintf(uc, sizeof(uc), _("  (%d more)"),
-                     unit_list_size(&ptile->units) - 1);
-       }
-        my_snprintf(s, sizeof(s),
-               _("A:%d D:%d FP:%d HP:%d/%d%s%s"), ptype->attack_strength, 
-               ptype->defense_strength, ptype->firepower, punit->hp, 
-               ptype->hp, punit->veteran?_(" V"):"", uc);
-
-        if(punit->activity==ACTIVITY_GOTO)  {
-         cross_head->x = goto_dest_x(punit);
-         cross_head->y = goto_dest_y(punit);
-         cross_head++;
-        }
-      } else {
-        my_snprintf(s, sizeof(s),
-                   _("A:%d D:%d FP:%d HP:%d0%%"), ptype->attack_strength, 
-                   ptype->defense_strength, ptype->firepower, 
-                   (punit->hp*100/ptype->hp + 9)/10 );
+      XtCreateManagedWidget(content, smeBSBObjectClass, p, NULL, 0);
+      if (end){
+       content=end+1;
+      }else{
+       break;
       }
-      XtCreateManagedWidget(s, smeBSBObjectClass, p, NULL, 0);
     }
 
+    punit = find_visible_unit(map_get_tile(xtile, ytile));
+    if(punit && (punit->activity == ACTIVITY_GOTO || punit->connecting)) {
+      cross_head->x = goto_dest_x(punit);
+      cross_head->y = goto_dest_y(punit);
+      cross_head++;
+    }
     cross_head->x = xtile;
     cross_head->y = ytile;
     cross_head++;
diff -ur freeciv-cvs-Aug-24-orig/client/mapctrl_common.c 
freeciv-cvs-Aug-24-popup/client/mapctrl_common.c
--- freeciv-cvs-Aug-24-orig/client/mapctrl_common.c     2003-08-24 
21:38:19.000000000 +0000
+++ freeciv-cvs-Aug-24-popup/client/mapctrl_common.c    2003-09-04 
15:32:37.000000000 +0000
@@ -15,18 +15,22 @@
 #include <config.h>
 #endif
 
-#include "log.h"
-
 #include "agents.h"
 #include "civclient.h"
+#include "climisc.h"
 #include "clinet.h"
 #include "cma_core.h"
 #include "control.h"
+#include "fcintl.h"
 #include "goto.h"
+#include "log.h"
 #include "mapctrl_g.h"
 #include "mapview_g.h"
 #include "options.h"
 
+#include "combat.h"
+#include "support.h"
+
 #include "mapctrl_common.h"
 
 /* Update the workers for a city on the map, when the update is received */
@@ -221,3 +225,110 @@
     }
   }
 }
+
+/************************************************************************
+Text to popup on middle-click
+************************************************************************/
+char* popup_info_text(int xtile, int ytile)
+{
+  static char out[256];
+  char buf[64];
+  struct city *pcity = map_get_city(xtile, ytile);
+  struct tile *ptile = map_get_tile(xtile, ytile);
+  struct unit *punit = find_visible_unit(ptile);
+  char *diplo_adjectives[DS_LAST] = {_("Neutral"), _("Hostile"), 
_("Ceasefire"),
+                                    _("Peaceful"), _("Friendly"), 
_("Mysterious")};
+  out[0]='\0';
+
+#ifdef DEBUG
+  my_snprintf(out, sizeof(out), _("Location: (%d, %d) [%d]\n"), 
+             xtile, ytile, ptile->continent); 
+#endif /*DEBUG*/
+  my_snprintf(buf, sizeof(buf), _("Terrain: %s"),
+             map_get_tile_info_text(xtile, ytile));
+  sz_strlcat(out, buf);
+  my_snprintf(buf, sizeof(buf), _("\nFood/Prod/Trade: %s"),
+             map_get_tile_fpt_text(xtile, ytile));
+  sz_strlcat(out, buf);
+  if (tile_has_special(ptile, S_HUT)) {
+    sz_strlcat(out, _("\nMinor Tribe Village"));
+  }
+  if (game.borders > 0 && !pcity) {
+    struct player *owner = map_get_owner(xtile, ytile);
+    if (owner == game.player_ptr){
+      sz_strlcat(out, _("\nOur Territory"));
+    } else if (owner) {
+      if (game.player_ptr->diplstates[owner->player_no].type==DS_CEASEFIRE){
+       my_snprintf(buf, sizeof(buf), _("\n%s territory (%d turn ceasefire)"),
+                   get_nation_name(owner->nation),
+                   game.player_ptr->diplstates[owner->player_no].turns_left);
+      }else{
+       my_snprintf(buf, sizeof(buf), _("\nTerritory of the %s %s"),
+                   
diplo_adjectives[game.player_ptr->diplstates[owner->player_no].type],
+                   get_nation_name_plural(owner->nation));
+      }
+      sz_strlcat(out, buf);
+    } else {
+      sz_strlcat(out, _("\nUnclaimed territory"));
+    }
+  }
+  if (pcity) {
+      my_snprintf(buf, sizeof(buf), _("\nCity: %s(%s,%s)"), pcity->name,
+                 get_nation_name(city_owner(pcity)->nation),
+                 diplo_adjectives[game.player_ptr->
+                                  
diplstates[city_owner(pcity)->player_no].type]);
+      sz_strlcat(out, buf);
+      if (city_got_citywalls(pcity)) {
+       sz_strlcat(out, _(" with City Walls"));
+      }
+  } 
+  if(get_tile_infrastructure_set(ptile)) {
+    my_snprintf(buf, sizeof(buf), _("\nInfrastructure: %s"),
+               map_get_infrastructure_text(ptile->special));
+    sz_strlcat(out, buf);
+  }
+  sz_strlcpy(buf, _("\nActivity: "));
+  if (concat_tile_activity_text(buf, sizeof(buf), xtile, ytile)) {
+    sz_strlcat(out, buf);
+  }
+  if (punit && !pcity) {
+    char tmp[64] = {0};
+    struct unit_type *ptype = unit_type(punit);
+    if(punit->owner == game.player_idx) {
+       struct city *pcity;
+       pcity=player_find_city_by_id(game.player_ptr, punit->homecity);
+       if(pcity)
+         my_snprintf(tmp, sizeof(tmp), "/%s", pcity->name);
+      }
+    my_snprintf(buf, sizeof(buf), _("\nUnit: %s(%s%s)"), ptype->name,
+               get_nation_name(unit_owner(punit)->nation), tmp);
+    sz_strlcat(out, buf);
+    if (punit->owner != game.player_idx){
+      struct unit *apunit;
+      if ((apunit = get_unit_in_focus())) {
+       /* chance to win when active unit is attacking the selected unit */
+       int att_chance = unit_win_chance(apunit, punit) * 100;
+       
+       /* chance to win when selected unit is attacking the active unit */
+       int def_chance = (1.0 - unit_win_chance(punit, apunit)) * 100;
+       
+       my_snprintf(buf, sizeof(buf), _("\nChance to win: A:%d%% D:%d%%"),
+                   att_chance, def_chance);
+       sz_strlcat(out, buf);
+      }
+    }
+    my_snprintf(buf, sizeof(buf), _("\nA:%d D:%d FP:%d HP:%d/%d%s"),
+                   ptype->attack_strength, 
+                   ptype->defense_strength, ptype->firepower, punit->hp, 
+                   ptype->hp, punit->veteran ? _(" V") : "");
+    sz_strlcat(out, buf);
+    if (punit->owner == game.player_idx && unit_list_size(&ptile->units) >= 2){
+      my_snprintf(buf, sizeof(buf), _("  (%d more)"),
+                 unit_list_size(&ptile->units) - 1);
+      sz_strlcat(out, buf);
+    }
+  } 
+  return out;
+}
+
+       
diff -ur freeciv-cvs-Aug-24-orig/client/mapctrl_common.h 
freeciv-cvs-Aug-24-popup/client/mapctrl_common.h
--- freeciv-cvs-Aug-24-orig/client/mapctrl_common.h     2003-08-24 
21:38:19.000000000 +0000
+++ freeciv-cvs-Aug-24-popup/client/mapctrl_common.h    2003-09-01 
12:22:33.000000000 +0000
@@ -25,6 +25,7 @@
 void recenter_button_pressed(int canvas_x, int canvas_y);
 void update_turn_done_button_state(void);
 void update_line(int canvas_x, int canvas_y);
+char* popup_info_text(int xtile, int ytile);
 
 extern struct city *city_workers_display;
 

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