Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] Re: (PR#11192) CMA detaches after revolution
Home

[Freeciv-Dev] Re: (PR#11192) CMA detaches after revolution

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: chrisk@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#11192) CMA detaches after revolution
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 25 Nov 2004 08:00:15 -0800
Reply-to: rt@xxxxxxxxxxx

<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.

The CMA runs a comparison to see if the result after applying the found 
result is the same as the found result.  That is, the CM searches for a 
"result", the CMA applies it, then checks to see that it did what was 
expected.  If it doesn't, the CM is run again: up to 5 times.

In this case the result the CM finds expects the city to be happy.  But 
of course the city isn't happy, and cannot be happy.  So the CMA fails.

Why does the CM expect the city to be happy?  Benoit?

-jason

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 15:54:05 -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, &current_state);
 
-  if (results_are_equal(pcity, result, &current_state)
+  if (results_are_equal(pcity, result, &current_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, &current_state);
+  success = results_are_equal(pcity, result, &current_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;

[Prev in Thread] Current Thread [Next in Thread]