[Freeciv-Dev] Re: (PR#11192) CMA detaches after revolution
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=11192 >
Christian Knoke wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=11192 >
>
>
> CVS 25 NOV 2004 S2 GTK2
>
> Load the attached game and make a revolution. You get:
>
> CMA: Hannover has changed multiple times due to an error in Freeciv.
>
> It is not possible to reinstall the CMA for Hannover after that, even though
> requirements can be fulfilled.
Problem is that the client never gets a city packet for Hanover.
Hanover instead has its CMA called because an adjacent city changes.
In other words generic_city_refresh *really* needs to be called before
the CM is run. This patch does that. However I can't guarantee it will
fix all problems (there are several other CM query calls out there that
are unchanged, and there may be other problems as well).
jason
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.423
diff -u -r1.423 packhand.c
--- client/packhand.c 24 Nov 2004 06:31:25 -0000 1.423
+++ client/packhand.c 25 Nov 2004 16:01:30 -0000
@@ -579,9 +579,11 @@
{
int i;
+#if 0
if (city_owner(pcity) == game.player_ptr) {
generic_city_refresh(pcity, FALSE, 0);
}
+#endif
if(is_new) {
unit_list_init(&pcity->units_supported);
Index: client/agents/cma_core.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v
retrieving revision 1.67
diff -u -r1.67 cma_core.c
--- client/agents/cma_core.c 25 Nov 2004 07:20:02 -0000 1.67
+++ client/agents/cma_core.c 25 Nov 2004 16:01:33 -0000
@@ -88,9 +88,10 @@
}
-#define T(x) if (result1->x != result2->x) { \
- freelog(RESULTS_ARE_EQUAL_LOG_LEVEL, #x); \
- return FALSE; }
+#define T(x) if (result1->x != result2->x) { \
+ freelog(verbose ? LOG_NORMAL : LOG_DEBUG, "%s: %d versus %d", \
+ #x, result1->x, result2->x); \
+ return FALSE; }
/****************************************************************************
Returns TRUE iff the two results are equal. Both results have to be
@@ -98,7 +99,8 @@
*****************************************************************************/
static bool results_are_equal(struct city *pcity,
const struct cm_result *const result1,
- const struct cm_result *const result2)
+ const struct cm_result *const result2,
+ bool verbose)
{
T(disorder);
T(happy);
@@ -114,7 +116,7 @@
my_city_map_iterate(pcity, x, y) {
if (result1->worker_positions_used[x][y] !=
result2->worker_positions_used[x][y]) {
- freelog(RESULTS_ARE_EQUAL_LOG_LEVEL, "worker_positions_used");
+ freelog(verbose ? LOG_NORMAL : LOG_DEBUG, "worker_positions_used");
return FALSE;
}
} my_city_map_iterate_end;
@@ -199,7 +201,7 @@
get_current_as_result(pcity, ¤t_state);
- if (results_are_equal(pcity, result, ¤t_state)
+ if (results_are_equal(pcity, result, ¤t_state, TRUE)
&& !ALWAYS_APPLY_AT_SERVER) {
stats.apply_result_ignored++;
return TRUE;
@@ -224,7 +226,7 @@
my_city_map_iterate(pcity, x, y) {
if ((pcity->city_map[x][y] == C_TILE_WORKER) &&
!result->worker_positions_used[x][y]) {
- freelog(APPLY_RESULT_LOG_LEVEL, "Removing worker at %d,%d.", x, y);
+ freelog(LOG_NORMAL, "Removing worker at %d,%d.", x, y);
last_request_id = city_toggle_worker(pcity, x, y);
if (first_request_id == 0) {
first_request_id = last_request_id;
@@ -238,7 +240,7 @@
continue;
}
for (i = 0; i < pcity->specialists[sp] - result->specialists[sp]; i++) {
- freelog(APPLY_RESULT_LOG_LEVEL, "Change specialist from %d to %d.",
+ freelog(LOG_NORMAL, "Change specialist from %d to %d.",
sp, DEFAULT_SPECIALIST);
last_request_id = city_change_specialist(pcity,
sp, DEFAULT_SPECIALIST);
@@ -257,7 +259,7 @@
if (result->worker_positions_used[x][y] &&
pcity->city_map[x][y] != C_TILE_WORKER) {
assert(pcity->city_map[x][y] == C_TILE_EMPTY);
- freelog(APPLY_RESULT_LOG_LEVEL, "Putting worker at %d,%d.", x, y);
+ freelog(LOG_NORMAL, "Putting worker at %d,%d.", x, y);
last_request_id = city_toggle_worker(pcity, x, y);
if (first_request_id == 0) {
first_request_id = last_request_id;
@@ -272,7 +274,7 @@
continue;
}
for (i = 0; i < result->specialists[sp] - pcity->specialists[sp]; i++) {
- freelog(APPLY_RESULT_LOG_LEVEL, "Changing specialist from %d to %d.",
+ freelog(LOG_NORMAL, "Changing specialist from %d to %d.",
DEFAULT_SPECIALIST, sp);
last_request_id = city_change_specialist(pcity,
DEFAULT_SPECIALIST, sp);
@@ -313,7 +315,7 @@
freelog(APPLY_RESULT_LOG_LEVEL, "apply_result: return");
- success = results_are_equal(pcity, result, ¤t_state);
+ success = results_are_equal(pcity, result, ¤t_state, TRUE);
if (!success) {
cm_clear_cache(pcity);
@@ -407,7 +409,7 @@
break;
} else {
if (!apply_result_on_server(pcity, &result)) {
- freelog(HANDLE_CITY_LOG_LEVEL2, " doesn't cleanly apply");
+ freelog(LOG_NORMAL, " doesn't cleanly apply");
if (check_city(city_id, NULL) && i == 0) {
create_event(pcity->tile, E_NOEVENT,
_("CMA: %s has changed and the calculated "
@@ -415,7 +417,7 @@
pcity->name);
}
} else {
- freelog(HANDLE_CITY_LOG_LEVEL2, " ok");
+ freelog(LOG_NORMAL, " ok");
/* Everything ok */
handled = TRUE;
break;
Index: client/agents/cma_core.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v
retrieving revision 1.67
diff -u -r1.67 cma_core.c
--- client/agents/cma_core.c 25 Nov 2004 07:20:02 -0000 1.67
+++ client/agents/cma_core.c 25 Nov 2004 16:17:54 -0000
@@ -393,6 +393,7 @@
}
pcity = find_city_by_id(city_id);
+ generic_city_refresh(pcity, FALSE, 0);
cm_query_result(pcity, ¶meter, &result);
if (!result.found_a_valid) {
|
|