[Freeciv-Dev] Re: (PR#3518) Can't popup city (cma bug?)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, Feb 24, 2003 at 10:43:06PM -0800, mateusz stefek wrote:
>
> It's a bug in current cvs.
> Load walbrzych_bug.gz, login as mateusz.
> Every time you try to open Walbrzych the client crashes with message:
> civclient: cm.c:559: update_cache2: Assertion `p->production ==
> result->production[LUXURY] && p->surplus == result->surplus[LUXURY]'
> failed.
> Aborted (core dumped)
The savegame shows two problems:
- the asserts are off by one this leads to access of memory which
isn't initialized and so produces the above core dump
- the total trade (tile trade + trade routes) is estimated too low
because for the trade route estimation cm.c doesn't use the maximal
estimated tile trade.
I'm pretty sure that these were also the reasons for 2731.
A patch for these two problem is attached.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
Windows: Where do you want to go today?
Linux: Where do you want to go tomorrow?
BSD: Are you guys coming or what?
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.4
diff -u -u -r1.4 cm.c
--- common/aicore/cm.c 2003/02/04 17:07:44 1.4
+++ common/aicore/cm.c 2003/02/26 18:26:53
@@ -482,11 +482,11 @@
freelog(LOG_DEBUG, "second: trade=%d spec=%d type=%d", trade, specialists,
specialist_type);
- assert(trade <= cache2.allocated_trade);
- assert(specialists <= cache2.allocated_size);
+ assert(trade >= 0 && trade < cache2.allocated_trade);
+ assert(specialists >= 0 && specialists < cache2.allocated_size);
return &cache2.secondary_stats[NUM_SPECIALISTS_ROLES *
- (cache2.allocated_size * (trade) +
+ (cache2.allocated_size * trade +
specialists) + specialist_type];
}
@@ -497,8 +497,8 @@
{
freelog(LOG_DEBUG, "status: lux=%d worker=%d", luxury, workers);
- assert(luxury <= cache2.allocated_luxury);
- assert(workers <= cache2.allocated_size);
+ assert(luxury >=0 && luxury < cache2.allocated_luxury);
+ assert(workers >= 0 && workers < cache2.allocated_size);
return &cache2.city_status[cache2.allocated_size * luxury + workers];
}
@@ -1052,13 +1052,17 @@
static void ensure_invalid_cache2(struct city *pcity, int total_tile_trade)
{
bool change_size = FALSE;
- int i, luxury, total_trade = total_tile_trade;
+ int backup,i, luxury, total_trade = total_tile_trade;
+ /* Hack since trade_between_cities accesses pcity->tile_trade */
+ backup = pcity->tile_trade;
+ pcity->tile_trade = total_tile_trade;
for (i = 0; i < NUM_TRADEROUTES; i++) {
struct city *pc2 = find_city_by_id(pcity->trade[i]);
total_trade += trade_between_cities(pcity, pc2);
}
+ pcity->tile_trade = backup;
/*
* Estimate an upper limit for the luxury. We assume that the player
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#3518) Can't popup city (cma bug?),
Raimar Falke <=
|
|