Index: client/agents/cma_core.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v retrieving revision 1.25 diff -u -r1.25 cma_core.c --- client/agents/cma_core.c 2002/06/20 16:42:43 1.25 +++ client/agents/cma_core.c 2002/06/27 10:14:51 @@ -587,6 +587,33 @@ } /**************************************************************************** + Invalidate cache3 if the given city is the one which is cached by + cache3. The other caches (cache1, cache2 and tile_stats) doesn't have + to be invalidated since they are chained on cache3. +*****************************************************************************/ +static void clear_caches(struct city *pcity) +{ + freelog(LOG_DEBUG, "clear_caches(city='%s'(%d))", pcity->name, + pcity->id); + + if (cache3.pcity == pcity) { + int i, j; + for (i = 0; i < MAX_FIELDS_USED + 1; i++) { + for (j = 0; j < MAX_COMBINATIONS; j++) { + if (!cache3.results[i].combinations[j].is_valid) { + continue; + } + if (cache3.results[i].combinations[j].cache1) { + free(cache3.results[i].combinations[j].cache1); + cache3.results[i].combinations[j].cache1 = NULL; + } + } + } + cache3.pcity = NULL; + } +} + +/**************************************************************************** Change the actual city setting to the given result. Returns TRUE iff the actual data matches the calculated one. *****************************************************************************/ @@ -723,11 +750,15 @@ freelog(APPLY_RESULT_LOG_LEVEL, "apply_result: return"); success = results_are_equal(pcity, result, ¤t_state); - if (!success && SHOW_APPLY_RESULT_ON_SERVER_ERRORS) { - freelog(LOG_NORMAL, "expected"); - print_result(pcity, result); - freelog(LOG_NORMAL, "got"); - print_result(pcity, ¤t_state); + if (!success) { + clear_caches(pcity); + + if (SHOW_APPLY_RESULT_ON_SERVER_ERRORS) { + freelog(LOG_NORMAL, "expected"); + print_result(pcity, result); + freelog(LOG_NORMAL, "got"); + print_result(pcity, ¤t_state); + } } return success; } @@ -948,33 +979,6 @@ freelog(CALC_FITNESS_LOG_LEVEL, "calc_fitness: fitness = %d, minor_fitness=%d", *major_fitness, *minor_fitness); -} - -/**************************************************************************** - Invalidate cache3 if the given city is the one which is cached by - cache3. The other caches (cache1, cache2 and tile_stats) doesn't have - to be invalidated since they are chained on cache3. -*****************************************************************************/ -static void clear_caches(struct city *pcity) -{ - freelog(LOG_DEBUG, "clear_caches(city='%s'(%d))", pcity->name, - pcity->id); - - if (cache3.pcity == pcity) { - int i, j; - for (i = 0; i < MAX_FIELDS_USED + 1; i++) { - for (j = 0; j < MAX_COMBINATIONS; j++) { - if (!cache3.results[i].combinations[j].is_valid) { - continue; - } - if (cache3.results[i].combinations[j].cache1) { - free(cache3.results[i].combinations[j].cache1); - cache3.results[i].combinations[j].cache1 = NULL; - } - } - } - cache3.pcity = NULL; - } } /****************************************************************************