Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#11092) remove specialist references in cma_core
Home

[Freeciv-Dev] (PR#11092) remove specialist references in cma_core

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11092) remove specialist references in cma_core
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 19 Nov 2004 16:27:22 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=11092 >

This patch removes specialist references in cma_core.c.  It's pretty 
straightforward.

DEFAULT_SPECIALIST is currently hard-coded as SP_ELVIS but should later 
become dynamic or be removed entirely.

jason

Index: client/agents/cma_core.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v
retrieving revision 1.64
diff -u -r1.64 cma_core.c
--- client/agents/cma_core.c    29 Sep 2004 02:24:19 -0000      1.64
+++ client/agents/cma_core.c    20 Nov 2004 00:19:56 -0000
@@ -104,9 +104,10 @@
 
   T(disorder);
   T(happy);
-  T(specialists[SP_ELVIS]);
-  T(specialists[SP_SCIENTIST]);
-  T(specialists[SP_TAXMAN]);
+
+  specialist_type_iterate(sp) {
+    T(specialists[sp]);
+  } specialist_type_iterate_end;
 
   for (stat = 0; stat < NUM_STATS; stat++) {
     T(surplus[stat]);
@@ -194,7 +195,7 @@
 static bool apply_result_on_server(struct city *pcity,
                                   const struct cm_result *const result)
 {
-  int first_request_id = 0, last_request_id = 0, i, sp;
+  int first_request_id = 0, last_request_id = 0, i;
   struct cm_result current_state;
   bool success;
 
@@ -233,24 +234,27 @@
     }
   } my_city_map_iterate_end;
 
-  /* Change the excess non-elvis specialists to elvises. */
-  assert(SP_ELVIS == 0);
-  for (sp = 1; sp < SP_COUNT; sp++) {
+  /* Change the excess non-default specialists to default. */
+  specialist_type_iterate(sp) {
+    if (sp == DEFAULT_SPECIALIST) {
+      continue;
+    }
     for (i = 0; i < pcity->specialists[sp] - result->specialists[sp]; i++) {
       freelog(APPLY_RESULT_LOG_LEVEL, "Change specialist from %d to %d.",
-             sp, SP_ELVIS);
-      last_request_id = city_change_specialist(pcity, sp, SP_ELVIS);
+             sp, DEFAULT_SPECIALIST);
+      last_request_id = city_change_specialist(pcity,
+                                              sp, DEFAULT_SPECIALIST);
       if (first_request_id == 0) {
        first_request_id = last_request_id;
       }
     }
-  }
+  } specialist_type_iterate_end;
 
   /* now all surplus people are enterainers */
 
   /* Set workers */
-  /* FIXME: This code assumes that any toggled worker will turn into an
-   * elvis! */
+  /* FIXME: This code assumes that any toggled worker will turn into a
+   * DEFAULT_SPECIALIST! */
   my_city_map_iterate(pcity, x, y) {
     if (result->worker_positions_used[x][y] &&
        pcity->city_map[x][y] != C_TILE_WORKER) {
@@ -263,19 +267,22 @@
     }
   } my_city_map_iterate_end;
 
-  /* Set all specialists except SP_ELVIS (all the unchanged ones remain
-   * as elvises). */
-  assert(SP_ELVIS == 0);
-  for (sp = 1; sp < SP_COUNT; sp++) {
+  /* Set all specialists except DEFAULT_SPECIALIST (all the unchanged
+   * ones remain as DEFAULT_SPECIALIST). */
+  specialist_type_iterate(sp) {
+    if (sp == DEFAULT_SPECIALIST) {
+      continue;
+    }
     for (i = 0; i < result->specialists[sp] - pcity->specialists[sp]; i++) {
       freelog(APPLY_RESULT_LOG_LEVEL, "Changing specialist from %d to %d.",
-             SP_ELVIS, sp);
-      last_request_id = city_change_specialist(pcity, SP_ELVIS, sp);
+             DEFAULT_SPECIALIST, sp);
+      last_request_id = city_change_specialist(pcity,
+                                              DEFAULT_SPECIALIST, sp);
       if (first_request_id == 0) {
        first_request_id = last_request_id;
       }
     }
-  }
+  } specialist_type_iterate_end;
 
   if (last_request_id == 0 || ALWAYS_APPLY_AT_SERVER) {
       /*
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.155
diff -u -r1.155 game.h
--- common/game.h       4 Nov 2004 06:20:54 -0000       1.155
+++ common/game.h       20 Nov 2004 00:19:57 -0000
@@ -197,6 +197,7 @@
       char name[MAX_LEN_NAME];
       int min_size, bonus;
     } specialists[SP_COUNT];
+#define DEFAULT_SPECIALIST SP_ELVIS
     bool changable_tax;
     int forced_science; /* only relevant if !changable_tax */
     int forced_luxury;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11092) remove specialist references in cma_core, Jason Short <=