Re: [Freeciv-Dev] (PR#39330) Re: (PR#39335) Re: Fix for PR#39330

2007-04-11 Thread Jason Short

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39330 

On 4/11/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 URL: http://bugs.freeciv.org/Ticket/Display.html?id=39330 

 Jason Short wrote:
  URL: http://bugs.freeciv.org/Ticket/Display.html?id=39335 

 Attached to this message is a patch to fix the issue reported in
  PR#39330. Basically, the problem seems to be that cities can see unknown
  terrain, and this is considered acceptable and normal. But, in at least
  one place in the code that possibility is overlooked. In a player's view
  of a tile, the terrain ptr may be NULL (indicating it is unknown).
  Attempts to reference a member, such as 'type', of such a NULL ptr
  obviously results in a segfault.
 
  Good catch but the bug is deeper.  We do NEED to know the terrain type
  here since the tile is being sent as TILE_KNOWN_FOGGED.  Can you find
  a way to reproduce the problem and figure out why a known tile has
  unknown terrain type?  That should not be possible.

 Well, the patch can be easily be modified to send 'TILE_UNKNOWN'
 instead, for the case when the tile is seen by a city, but unknown.
 A *seen* tile is allowed to be *unknown* according to a comment in
 server/maphand.c, starting at line 810 on the SVN head revision, which I
 quote here:

A tile can be known but not seen.  In this case the tile should be
marked as TILE_UNKNOWN in the player tile, NOT as TILE_KNOWN_FOGGED.
This isn't an error in the network code - it's an error in whatever
code marked the plrtile as TILE_KNOWN_FOGGED yet didn't set the
terrain.

The vision code *has* changed recently so there is a reasonable chance
of errors of this type.  If we're able to reproduce it I can probably
track it down next week, but if you can find the error yourself that
would naturally be even better.

 /
Return whether the player can see the tile.  Seeing a tile means you have
vision of it now (as opposed to knowing a tile which means you've seen it
before).  Note that a tile can be seen but not known (currently this only
happens when a city is founded with some unknown tiles in its radius); in
this case the tile is unknown (but map_get_seen will still return TRUE).
 /

 Is this in dispute?

No, not in dispute.  What is a bit tricky is that map_get_seen can
return TRUE for unknown tiles: this is a low-level function that
should only be used in a few places.

   P.S. Send future reports to the bug tracker.

 I *did* send the *report* to the tracker. Are you asking me to only send
 future *patches* for open/new tickets to the tracker and not the list?
 Do you want me to create a new ticket for each patch, like you
 apparently did to respond to my earlier message?

You sent the report to the tracker then sent the patch to the list.  I
erronously made a new report which I merged into the old once when I
realized it already existed (hence the ugly subject line).  Simply
responding to the email from the bug tracker (with PR# in the subject)
is generally sufficient for any reply.

-jason



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#39330) Re: (PR#39335) Re: Fix for PR#39330

2007-04-11 Thread [EMAIL PROTECTED]

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39330 

Jason Short wrote:
 URL: http://bugs.freeciv.org/Ticket/Display.html?id=39330 

 Well, the patch can be easily be modified to send 'TILE_UNKNOWN'
 instead, for the case when the tile is seen by a city, but unknown.
 A *seen* tile is allowed to be *unknown* according to a comment in
 server/maphand.c, starting at line 810 on the SVN head revision, which I
 quote here:
 
 A tile can be known but not seen.  In this case the tile should be
 marked as TILE_UNKNOWN in the player tile, NOT as TILE_KNOWN_FOGGED.

No, a known but unseen tile *should* be marked as TILE_KNOWN_FOGGED. The 
code already does this, and my patch does not change this.

Anyway, I modified the patch as I said I would, so that unknown but seen 
tiles are marked as TILE_UNKNOWN now. I tested it, and it works fine. 
The revised patch is attached to this message.

 What is a bit tricky is that map_get_seen can
 return TRUE for unknown tiles

That is precisely the case the patch deals with, since it wasn't being 
dealt with before.

 P.S. Send future reports to the bug tracker.
 I *did* send the *report* to the tracker. Are you asking me to only send
 future *patches* for open/new tickets to the tracker and not the list?
 Do you want me to create a new ticket for each patch, like you
 apparently did to respond to my earlier message?
 
 You sent the report to the tracker then sent the patch to the list. 

Part of the reason for this was to make sure that I could actually post 
to the list, if needed. :-)

Eric



Index: server/maphand.c
===
--- server/maphand.c(revision 12916)
+++ server/maphand.c(working copy)
@@ -475,10 +475,10 @@
map_get_seen(ptile, pplayer, V_MAIN) == 0) {
   struct player_tile *plrtile = map_get_player_tile(ptile, pplayer);
 
-  info.known = TILE_KNOWN_FOGGED;
-  info.type = plrtile-terrain-index;
+  info.known = plrtile-terrain ? TILE_KNOWN_FOGGED : TILE_UNKNOWN;
+  info.type = plrtile-terrain ? plrtile-terrain-index : -1;
   for (spe = 0; spe  S_LAST; spe++) {
-   info.special[spe] = BV_ISSET(plrtile-special, spe);
+info.special[spe] = BV_ISSET(plrtile-special, spe);
   }
   info.resource = plrtile-resource ? plrtile-resource-index : -1;
   info.continent = ptile-continent;
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39324) Bugs in SDL client for 2.1.0-beta4

2007-04-11 Thread Christian Prochaska

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39324 

 [EMAIL PROTECTED] - Mi 04. Apr 2007, 21:34:31]:
 
 -The dialogue for selling all of a certain improvement isn't destroyed
 when an option is selected
 - The dialogue for buying a unit isn't destroyed when buying isn't
 allowed (due to a city being in disorder) until the city dialogue 
 itself is closed


Here's a patch for these two problems.

Index: client/gui-sdl/citydlg.c
===
--- client/gui-sdl/citydlg.c	(Revision 12916)
+++ client/gui-sdl/citydlg.c	(Arbeitskopie)
@@ -1071,19 +1071,21 @@
 static int ok_buy_prod_city_dlg_callback(struct widget *pButton)
 {
   if (Main.event.button.button == SDL_BUTTON_LEFT) {
+popdown_hurry_production_dialog();
+
 city_buy_production(pButton-data.city);
 
-if (pCityDlg)
-{
-  popdown_window_group_dialog(pHurry_Prod_Dlg-pBeginWidgetList,
-  pHurry_Prod_Dlg-pEndWidgetList);
-  FC_FREE(pHurry_Prod_Dlg);
+if (pCityDlg) {
   /* enable city dlg */
   enable_city_dlg_widgets();
+  
+  /* disable buy button */
   set_wstate(pCityDlg-pBuy_Button, FC_WS_DISABLED);
-} else {
-  popdown_hurry_production_dialog();
+  widget_redraw(pCityDlg-pBuy_Button);
+  widget_mark_dirty(pCityDlg-pBuy_Button);
+  flush_dirty();
 }
+
   }
   return -1;
 }
@@ -1109,7 +,7 @@
 {
   if (pHurry_Prod_Dlg) {
 popdown_window_group_dialog(pHurry_Prod_Dlg-pBeginWidgetList,
-			  pHurry_Prod_Dlg-pEndWidgetList);
+pHurry_Prod_Dlg-pEndWidgetList);
 FC_FREE(pHurry_Prod_Dlg);
 flush_dirty();
   }
@@ -1155,7 +1157,7 @@
   }
 
   value = city_buy_cost(pCity);
-  if(!pCity-did_buy) {
+  if (city_can_buy(pCity)) {
 if (game.player_ptr-economic.gold = value) {
   my_snprintf(cBuf, sizeof(cBuf),
 		_(Buy %s for %d gold?\n
@@ -1168,8 +1170,13 @@
 		name, value, game.player_ptr-economic.gold);
 }
   } else {
-my_snprintf(cBuf, sizeof(cBuf),
-		_(Sorry, You have already bought here in this turn));
+if (pCity-did_buy) {
+  my_snprintf(cBuf, sizeof(cBuf),
+  _(Sorry, You have already bought here in this turn.));
+} else {
+  my_snprintf(cBuf, sizeof(cBuf),
+  _(Sorry, You can't buy here in this turn.));
+}
   }
 
   pStr = create_str16_from_char(_(Buy It?), adj_font(12));
@@ -1207,7 +1214,7 @@
 
   add_to_gui_list(ID_BUTTON, pBuf);
 
-  if (!pCity-did_buy  game.player_ptr-economic.gold = value) {
+  if (city_can_buy(pCity)  game.player_ptr-economic.gold = value) {
 pBuf = create_themeicon_button_from_chars(pTheme-OK_Icon, pWindow-dst,
 	  _(Yes), adj_font(12), 0);
 
@@ -1278,7 +1285,7 @@
   pBuf = pWindow-prev;
   pBuf-size.y = dst.y;
   
-  if (!pCity-did_buy  game.player_ptr-economic.gold = value) {
+  if (city_can_buy(pCity)  game.player_ptr-economic.gold = value) {
 /* yes */
 pBuf = pBuf-prev;
 pBuf-size.x = area.x + (area.w - (2 * pBuf-size.w + adj_size(20))) / 2;
@@ -1512,7 +1519,7 @@
   }
 }
   
-if (pCityDlg-pCity-did_buy  pCityDlg-pBuy_Button) {
+if (!city_can_buy(pCityDlg-pCity)  pCityDlg-pBuy_Button) {
   set_wstate(pCityDlg-pBuy_Button, FC_WS_DISABLED);
 }
 
@@ -3237,7 +3244,7 @@
 
 } else {
 
-  if (!pCity-did_buy  pCityDlg-pBuy_Button
+  if (city_can_buy(pCity)  pCityDlg-pBuy_Button
 	  (get_wstate(pCityDlg-pBuy_Button) == FC_WS_DISABLED)) {
 	set_wstate(pCityDlg-pBuy_Button, FC_WS_NORMAL);
 	widget_redraw(pCityDlg-pBuy_Button);
@@ -3815,7 +3822,7 @@
   pBuf-size.y = area.y + area.h - pBuf-size.h - adj_size(5);
   pCityDlg-pBuy_Button = pBuf;
   pBuf-key = SDLK_h;
-  if ((pOwner == game.player_ptr)  (!pCity-did_buy)) {
+  if (city_can_buy(pCity)) {
 set_wstate(pBuf, FC_WS_NORMAL);
   }
   add_to_gui_list(ID_CITY_DLG_PROD_BUY_BUTTON, pBuf);
Index: client/gui-sdl/repodlgs.c
===
--- client/gui-sdl/repodlgs.c	(Revision 12916)
+++ client/gui-sdl/repodlgs.c	(Arbeitskopie)
@@ -1414,7 +1414,7 @@
 total_count = pImpr-data.cont-id1;
 
 /* popdown sell dlg */
-del_group_of_widgets_from_gui_list(pEconomy_Sell_Dlg-pBeginWidgetList,
+popdown_window_group_dialog(pEconomy_Sell_Dlg-pBeginWidgetList,
 pEconomy_Sell_Dlg-pEndWidgetList);
 FC_FREE(pEconomy_Sell_Dlg);
 enable_economy_dlg();
@@ -1496,12 +1496,12 @@
 if(count  0) {
   my_snprintf(cBuf, sizeof(cBuf),
   _(We have %d of %s\n(total value is : %d)\n
-  We can sell %d of them for %d gold),
+  We can sell %d of them for %d gold.),
   total_count, get_improvement_name(imp),
   total_count * value, count, gold); 
 } else {
   my_snprintf(cBuf, sizeof(cBuf),
-  _(We can't sell any %s in this turn), get_improvement_name(imp)); 
+  _(We can't