<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39677 >
> [EMAIL PROTECTED] - Do 06. Sep 2007, 21:08:48]:
>
> I am running Freeciv version 2.1.0-beta6 (beta version) gui-sdl
>
> I got the following error when trying to upgrade a unit:
>
> civclient
> 2: Using Video Output: x11
> 2: 480, 27, 0
> 2: area.h = 410
> 2: 768, 27, 0
> 2: area.h = 614
> 2: 768, 27, 0
> 2: area.h = 614
> 2: 768, 27, 0
> 2: area.h = 614
> 2: 768, 27, 0
> 2: area.h = 614
> civclient: repodlgs.c:171: popup_upgrade_unit_callback: Assertion
> `(&ut1) != ((void *)0) && (utype_by_number((&ut1)->index) == (&ut1))'
> failed.
> Aborted
>
> The game died :(
>
The attached patch fixes the failed assertion in S2_1 (already fixed in
S2_2/trunk) and removes the forgotten debug output. The segmentation
fault still remains at the moment.
Index: client/gui-sdl/repodlgs.c
===================================================================
--- client/gui-sdl/repodlgs.c (revision 13783)
+++ client/gui-sdl/repodlgs.c (working copy)
@@ -3050,7 +3050,7 @@
/* max row - 204 is goal tech widget height */
max_row = (Main.screen->h - (pWindow->size.h - pWindow->area.h) - adj_size(2)) / adj_size(204);
- freelog(LOG_NORMAL, "%d, %d, %d", Main.screen->h, pWindow->size.h, pWindow->area.h);
+
/* make space on screen for scrollbar */
if (max_col * max_row < count) {
max_col--;
@@ -3129,7 +3129,7 @@
area.w = MAX(area.w, (col * pBuf->size.w + adj_size(2) + i));
area.h = MAX(area.h, count * pBuf->size.h + adj_size(2));
- freelog(LOG_NORMAL, "area.h = %d", area.h);
+
/* alloca window theme and win background buffer */
pSurf = theme_get_background(theme, BACKGROUND_CHANGERESEARCHDLG);
resize_window(pWindow, pSurf, NULL,
Index: client/gui-sdl/repodlgs.c
===================================================================
--- client/gui-sdl/repodlgs.c (revision 13780)
+++ client/gui-sdl/repodlgs.c (working copy)
@@ -153,7 +153,7 @@
static int popup_upgrade_unit_callback(struct widget *pWidget)
{
if (Main.event.button.button == SDL_BUTTON_LEFT) {
- struct unit_type ut1;
+ struct unit_type *ut1;
struct unit_type *ut2;
int value;
char cBuf[128];
@@ -163,12 +163,12 @@
SDL_Rect dst;
SDL_Rect area;
- ut1.index = MAX_ID - pWidget->ID;
+ ut1 = utype_by_number(MAX_ID - pWidget->ID);
if (pUnits_Upg_Dlg) {
return 1;
}
- CHECK_UNIT_TYPE(&ut1);
+ CHECK_UNIT_TYPE(ut1);
set_wstate(pWidget, FC_WS_NORMAL);
pSellected_Widget = NULL;
@@ -177,13 +177,13 @@
pUnits_Upg_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
- ut2 = can_upgrade_unittype(game.player_ptr, &ut1);
- value = unit_upgrade_price(game.player_ptr, &ut1, ut2);
+ ut2 = can_upgrade_unittype(game.player_ptr, ut1);
+ value = unit_upgrade_price(game.player_ptr, ut1, ut2);
my_snprintf(cBuf, sizeof(cBuf),
_("Upgrade as many %s to %s as possible for %d gold each?\n"
"Treasury contains %d gold."),
- utype_name_translation(&ut1),
+ utype_name_translation(ut1),
utype_name_translation(ut2),
value, game.player_ptr->economic.gold);
@@ -876,7 +876,7 @@
pBuf = pWidget;
if ((units[i->index].active_count > 0) || (units[i->index].building_count > 0)) {
if (i->index == MAX_ID - pBuf->ID) {
-UPD: upgrade = can_upgrade_unittype(game.player_ptr, i)->index;
+UPD: upgrade = (can_upgrade_unittype(game.player_ptr, i) != NULL);
pBuf = pBuf->prev;
if(upgrade) {
pBuf->string16->fgcol = *get_game_colorRGB(COLOR_THEME_UNITUPGRADE_TEXT);
@@ -3043,7 +3043,7 @@
/* max row - 204 is goal tech widget height */
max_row = (Main.screen->h - (pWindow->size.h - pWindow->area.h) - adj_size(2)) / adj_size(204);
- freelog(LOG_NORMAL, "%d, %d, %d", Main.screen->h, pWindow->size.h, pWindow->area.h);
+
/* make space on screen for scrollbar */
if (max_col * max_row < count) {
max_col--;
@@ -3121,7 +3121,7 @@
area.w = MAX(area.w, (col * pBuf->size.w + adj_size(2) + i));
area.h = MAX(area.h, count * pBuf->size.h + adj_size(2));
- freelog(LOG_NORMAL, "area.h = %d", area.h);
+
/* alloca window theme and win background buffer */
pSurf = theme_get_background(theme, BACKGROUND_CHANGERESEARCHDLG);
resize_window(pWindow, pSurf, NULL,
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev