[Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > > [pepeto - Sun Jun 29 11:30:06 2008]: > > > [EMAIL PROTECTED] - Dim. Jun. 29 07:41:05 2008]: > > > > pcity->owner is a player id not a pointer. So this patch does the trick. > > > > My patch was against S2_1, and there, pcity->owner is a pointer. > I can verify that this has been fixed in S2_0 now. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > > [EMAIL PROTECTED] - Dim. Jun. 29 07:41:05 2008]: > > pcity->owner is a player id not a pointer. So this patch does the trick. > My patch was against S2_1, and there, pcity->owner is a pointer. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > Daniel Markstedt wrote: > http://bugs.freeciv.org/Ticket/Display.html?id=39568 > > >> [dmarks - Sun Jun 29 01:22:46 2008]: >> >>> [jdorje - Sun Jun 29 01:17:09 2008]: >>> [pepeto - Mon Oct 15 17:07:29 2007]: Isn't this ticket resolved? Or does it need some more improvement? >>> What about 2.0? Is it still broken there? >>> >>> -jason >>> >>> >> Yes it is. >> > > Tried to merge the first revision of the patch to S2_0, but just > worsens the issue. With attached patch selling buildings is completely > broken. Ahh so. pcity->owner is a player id not a pointer. So this patch does the trick. -jason Index: client/gui-gtk-2.0/citydlg.c === --- client/gui-gtk-2.0/citydlg.c(revision 14909) +++ client/gui-gtk-2.0/citydlg.c(working copy) @@ -2389,8 +2389,7 @@ return; } - if (pdialog->pcity->did_buy || pdialog->pcity->did_sell || - pdialog->pcity->owner != game.player_idx) { + if (pdialog->pcity->did_sell || pdialog->pcity->owner != game.player_idx) { return; } ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > > [dmarks - Sun Jun 29 01:22:46 2008]: > > > [jdorje - Sun Jun 29 01:17:09 2008]: > > > > > [pepeto - Mon Oct 15 17:07:29 2007]: > > > > > > Isn't this ticket resolved? Or does it need some more improvement? > > > > What about 2.0? Is it still broken there? > > > > -jason > > > > > > Yes it is. > Tried to merge the first revision of the patch to S2_0, but just worsens the issue. With attached patch selling buildings is completely broken. ~Daniel pr39568s20.diff Description: Binary data ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > > [jdorje - Sun Jun 29 01:17:09 2008]: > > > [pepeto - Mon Oct 15 17:07:29 2007]: > > > > Isn't this ticket resolved? Or does it need some more improvement? > > What about 2.0? Is it still broken there? > > -jason > > Yes it is. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > > [pepeto - Mon Oct 15 17:07:29 2007]: > > Isn't this ticket resolved? Or does it need some more improvement? What about 2.0? Is it still broken there? -jason ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > Isn't this ticket resolved? Or does it need some more improvement? ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > Pepeto's version committed to both branches. Now at least bug itself is fixed even if nobody remembers to commit my version when it becomes possible. -- Related note: Failing attempt to sell building is just silently ignored - no information at all is provided to user. - ML ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > On 14/08/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > More intrusive trunk version attached. Untested. Corrected comments. Cannot test because of #39620 and #39621. - ML diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/citydlg.c freeciv/client/gui-gtk-2.0/citydlg.c --- freeciv/client/gui-gtk-2.0/citydlg.c 2007-08-13 20:51:06.0 +0300 +++ freeciv/client/gui-gtk-2.0/citydlg.c 2007-08-27 01:01:27.0 +0300 @@ -2495,12 +2495,8 @@ return; } - if (pdialog->pcity->did_buy || pdialog->pcity->did_sell - || pdialog->pcity->owner != game.player_ptr) { -return; - } - - if (!can_city_sell_building(pdialog->pcity, pimprove)) { + if (!can_player_sell_building_now(game.player_ptr, pdialog->pcity, +pimprove)) { return; } diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/citydlg.c freeciv/client/gui-sdl/citydlg.c --- freeciv/client/gui-sdl/citydlg.c 2007-08-20 00:55:46.0 +0300 +++ freeciv/client/gui-sdl/citydlg.c 2007-08-27 01:02:55.0 +0300 @@ -1490,14 +1490,21 @@ set_wstate(pCityDlg->pImprv->pScroll->pDown_Right_Button, FC_WS_NORMAL); /* down */ } - if (pCityDlg->pCity->did_sell) { + /* There is common function can_player_sell_building_now(), + * but we are not using it here, since we want to use set_group_state() + * when possible */ + if (pCityDlg->pCity->did_sell + || pCityDlg->pCity->owner != game.player_ptr) { set_group_state(pCityDlg->pImprv->pBeginActiveWidgetList, pCityDlg->pImprv->pEndActiveWidgetList, FC_WS_DISABLED); } else { struct widget *pTmpWidget = pCityDlg->pImprv->pEndActiveWidgetList; while (TRUE) { - if (is_wonder(improvement_by_number(MAX_ID - 3000 - pTmpWidget->ID))) { + struct impr_type *pimpr = improvement_by_number(MAX_ID - 3000 - + pTmpWidget->ID); + + if (!can_city_sell_building(pCityDlg->pCity, pimpr)) { set_wstate(pTmpWidget, FC_WS_DISABLED); } else { set_wstate(pTmpWidget, FC_WS_NORMAL); diff -Nurd -X.diff_ignore freeciv/client/gui-win32/citydlg.c freeciv/client/gui-win32/citydlg.c --- freeciv/client/gui-win32/citydlg.c 2007-08-15 01:04:35.0 +0300 +++ freeciv/client/gui-win32/citydlg.c 2007-08-27 01:01:27.0 +0300 @@ -411,7 +411,11 @@ const char *descr = city_production_name_translation(pcity); EnableWindow(pdialog->buy_but, city_can_buy(pcity)); - EnableWindow(pdialog->sell_but, !pcity->did_sell); + + /* FIXME: Should not pass NULL as improvement + * to can_player_sell_building_now(). It skips many tests. */ + EnableWindow(pdialog->sell_but, + can_player_sell_building_now(game.player_ptr, pcity, NULL)); get_city_dialog_production(pcity, buf, sizeof(buf)); diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/citydlg.c freeciv/client/gui-xaw/citydlg.c --- freeciv/client/gui-xaw/citydlg.c 2007-08-13 20:51:06.0 +0300 +++ freeciv/client/gui-xaw/citydlg.c 2007-08-27 01:01:27.0 +0300 @@ -1476,7 +1476,10 @@ struct city *pcity=pdialog->pcity; XtSetSensitive(pdialog->buy_command, city_can_buy(pcity)); - XtSetSensitive(pdialog->sell_command, !pcity->did_sell); + /* FIXME: Should not pass NULL as improvement + * to can_player_sell_building_now(). It skips many tests. */ + XtSetSensitive(pdialog->sell_command, + can_player_sell_building_now(game.player_ptr, pcity, NULL)); xaw_set_label(pdialog->building_label, city_production_name_translation(pcity)); diff -Nurd -X.diff_ignore freeciv/common/improvement.c freeciv/common/improvement.c --- freeciv/common/improvement.c 2007-08-13 20:51:03.0 +0300 +++ freeciv/common/improvement.c 2007-08-27 01:10:05.0 +0300 @@ -538,3 +538,25 @@ return (city_has_building(pcity, pimprove) && is_improvement(pimprove)); } +/ + Return TRUE iff the player can sell the given improvement from city. + If pimprove is NULL, returns iff city could sell some building type (this + does not check if such building is in this city) +/ +bool can_player_sell_building_now(struct player *pplayer, + struct city *pcity, + struct impr_type *pimprove) +{ + /* Check if player can sell anything from this city */ + if (pcity->did_sell || pcity->owner != pplayer) { +return FALSE; + } + + /* Check if particular building can be built */ + if (pimprove != NULL + && !can_city_sell_building(pcity, pimprove)) { +return FALSE; + } + + return TRUE; +} diff -Nurd -X.diff_ignore freeciv/common/improvement.h freeciv/common/improvement.h --- freeciv/common/improvement.h 2007-08-13 20:51:03.0
Re: [Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > On 14/08/07, Pepeto _ <[EMAIL PROTECTED]> wrote: > > In the gtk2.0 client, you cannot sell an improvement by clicking on this > in the city dialog if you bought in the same turn. This quite annoying... Thanks. Your patch is good for S2_1. More intrusive trunk version attached. Untested. - ML diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/citydlg.c freeciv/client/gui-gtk-2.0/citydlg.c --- freeciv/client/gui-gtk-2.0/citydlg.c 2007-08-13 20:51:06.0 +0300 +++ freeciv/client/gui-gtk-2.0/citydlg.c 2007-08-14 23:02:58.0 +0300 @@ -2495,12 +2495,8 @@ return; } - if (pdialog->pcity->did_buy || pdialog->pcity->did_sell - || pdialog->pcity->owner != game.player_ptr) { -return; - } - - if (!can_city_sell_building(pdialog->pcity, pimprove)) { + if (!can_player_sell_building_now(game.player_ptr, pdialog->pcity, +pimprove)) { return; } diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/citydlg.c freeciv/client/gui-sdl/citydlg.c --- freeciv/client/gui-sdl/citydlg.c 2007-08-13 22:44:48.0 +0300 +++ freeciv/client/gui-sdl/citydlg.c 2007-08-14 23:19:44.0 +0300 @@ -1490,14 +1490,20 @@ set_wstate(pCityDlg->pImprv->pScroll->pDown_Right_Button, FC_WS_NORMAL); /* down */ } - if (pCityDlg->pCity->did_sell) { + /* There is common_function_sell_building_now(), but we are not using + * it here, since we want to use set_group_state() when possible */ + if (pCityDlg->pCity->did_sell + || pCityDlg->pCity->owner != game.player_ptr) { set_group_state(pCityDlg->pImprv->pBeginActiveWidgetList, pCityDlg->pImprv->pEndActiveWidgetList, FC_WS_DISABLED); } else { struct widget *pTmpWidget = pCityDlg->pImprv->pEndActiveWidgetList; while (TRUE) { - if (is_wonder(improvement_by_number(MAX_ID - 3000 - pTmpWidget->ID))) { + struct impr_type *pimpr = improvement_by_number(MAX_ID - 3000 - + pTmpWidget->ID); + + if (!can_city_sell_building(pCityDlg->pCity, pimpr)) { set_wstate(pTmpWidget, FC_WS_DISABLED); } else { set_wstate(pTmpWidget, FC_WS_NORMAL); diff -Nurd -X.diff_ignore freeciv/client/gui-win32/citydlg.c freeciv/client/gui-win32/citydlg.c --- freeciv/client/gui-win32/citydlg.c 2007-08-13 20:51:06.0 +0300 +++ freeciv/client/gui-win32/citydlg.c 2007-08-14 23:20:58.0 +0300 @@ -397,7 +397,11 @@ const char *descr = city_production_name_translation(pcity); EnableWindow(pdialog->buy_but, city_can_buy(pcity)); - EnableWindow(pdialog->sell_but, !pcity->did_sell); + + /* FIXME: Should not pass NULL as improvement + * to can_player_sell_building_now(). It skips many tests. */ + EnableWindow(pdialog->sell_but, + can_player_sell_building_now(game.player_ptr, pcity, NULL)); get_city_dialog_production(pcity, buf, sizeof(buf)); diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/citydlg.c freeciv/client/gui-xaw/citydlg.c --- freeciv/client/gui-xaw/citydlg.c 2007-08-13 20:51:06.0 +0300 +++ freeciv/client/gui-xaw/citydlg.c 2007-08-14 23:22:48.0 +0300 @@ -1476,7 +1476,10 @@ struct city *pcity=pdialog->pcity; XtSetSensitive(pdialog->buy_command, city_can_buy(pcity)); - XtSetSensitive(pdialog->sell_command, !pcity->did_sell); + /* FIXME: Should not pass NULL as improvement + * to can_player_sell_building_now(). It skips many tests. */ + XtSetSensitive(pdialog->sell_command, + can_player_sell_building_now(game.player_ptr, pcity, NULL)); xaw_set_label(pdialog->building_label, city_production_name_translation(pcity)); diff -Nurd -X.diff_ignore freeciv/common/improvement.c freeciv/common/improvement.c --- freeciv/common/improvement.c 2007-08-13 20:51:03.0 +0300 +++ freeciv/common/improvement.c 2007-08-14 23:05:51.0 +0300 @@ -538,3 +538,21 @@ return (city_has_building(pcity, pimprove) && is_improvement(pimprove)); } +/ + Return TRUE iff the player can sell the given improvement from city. +/ +bool can_player_sell_building_now(struct player *pplayer, + struct city *pcity, + struct impr_type *pimprove) +{ + if (pcity->did_sell || pcity->owner != pplayer) { +return FALSE; + } + + if (pimprove != NULL + && !can_city_sell_building(pcity, pimprove)) { +return FALSE; + } + + return TRUE; +} diff -Nurd -X.diff_ignore freeciv/common/improvement.h freeciv/common/improvement.h --- freeciv/common/improvement.h 2007-08-13 20:51:03.0 +0300 +++ freeciv/common/improvement.h 2007-08-14 23:03:21.0 +0300 @@ -109,6 +109,9 @@ bool can_sell_building(struct impr_type *pi
[Freeciv-Dev] (PR#39568) cannot sell an improvement
http://bugs.freeciv.org/Ticket/Display.html?id=39568 > In the gtk2.0 client, you cannot sell an improvement by clicking on this in the city dialog if you bought in the same turn. This quite annoying... --- client/gui-gtk-2.0/citydlg.c2007-08-13 22:49:05.0 +0200 +++ client/gui-gtk-2.0/citydlg.c.new2007-08-14 18:38:34.0 +0200 @@ -2475,8 +2475,7 @@ return; } - if (pdialog->pcity->did_buy || pdialog->pcity->did_sell - || pdialog->pcity->owner != game.player_ptr) { + if (pdialog->pcity->did_sell || pdialog->pcity->owner != game.player_ptr) { return; } --- client/gui-gtk-2.0/citydlg.c 2007-08-13 22:49:05.0 +0200 +++ client/gui-gtk-2.0/citydlg.c.new 2007-08-14 18:38:34.0 +0200 @@ -2475,8 +2475,7 @@ return; } - if (pdialog->pcity->did_buy || pdialog->pcity->did_sell - || pdialog->pcity->owner != game.player_ptr) { + if (pdialog->pcity->did_sell || pdialog->pcity->owner != game.player_ptr) { return; } ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev