Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#6960) [Request for patch] pft_fill_default_parameter
Home

[Freeciv-Dev] (PR#6960) [Request for patch] pft_fill_default_parameter

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory.Berkolaiko@xxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#6960) [Request for patch] pft_fill_default_parameter
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Jan 2004 16:23:01 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [glip - Wed Nov 26 22:51:28 2003]:
> 
> The above function is redundant.  It should be killed and the things it 
> sets now should be set inside pft_fill_unit_*_parameter functions instead.

Here's a patch for you.

jason

? data/isotrident/.xvpics
Index: ai/aidiplomat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidiplomat.c,v
retrieving revision 1.31
diff -u -r1.31 aidiplomat.c
--- ai/aidiplomat.c     2003/11/28 17:37:18     1.31
+++ ai/aidiplomat.c     2004/01/28 00:22:04
@@ -163,7 +163,6 @@
     struct unit *punit = create_unit_virtual(pplayer, pcity, u,
                                              do_make_unit_veteran(pcity, u));
 
-    pft_fill_default_parameter(&parameter);
     pft_fill_unit_parameter(&parameter, punit);
     map = pf_create_map(&parameter);
 
@@ -556,7 +555,6 @@
   CHECK_UNIT(punit);
 
   /* Generate map */
-  pft_fill_default_parameter(&parameter);
   pft_fill_unit_parameter(&parameter, punit);
   parameter.get_zoc = NULL; /* kludge */
   map = pf_create_map(&parameter);
@@ -618,7 +616,6 @@
   if (parameter.start_x != punit->x || parameter.start_y != punit->y
       || punit->ai.ai_role == AIUNIT_NONE) {
     pf_destroy_map(map);
-    pft_fill_default_parameter(&parameter);
     pft_fill_unit_parameter(&parameter, punit);
     parameter.get_zoc = NULL; /* kludge */
     map = pf_create_map(&parameter);
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.306
diff -u -r1.306 aiunit.c
--- ai/aiunit.c 2004/01/11 17:45:02     1.306
+++ ai/aiunit.c 2004/01/28 00:22:04
@@ -538,7 +538,6 @@
 
 #define DIST_FACTOR   0.6
 
-  pft_fill_default_parameter(&parameter);
   pft_fill_unit_parameter(&parameter, punit);
   parameter.get_TB = no_fights_or_unknown;
   /* When exploring, even AI should pretend to not cheat. */
@@ -988,7 +987,6 @@
   int max_want = 0;
   struct player *pplayer = unit_owner(punit);
  
-  pft_fill_default_parameter(&parameter);  
   pft_fill_unit_attack_param(&parameter, punit);
   
   tgt_map = pf_create_map(&parameter);
@@ -2254,7 +2252,6 @@
 
   UNIT_LOG(LOGLEVEL_FERRY, punit, "Ferryboat is looking for cargo.");
 
-  pft_fill_default_parameter(&parameter);
   pft_fill_unit_overlap_param(&parameter, punit);
   /* We are looking for our units, no need to look into the unknown */
   parameter.get_TB = no_fights_or_unknown;
Index: client/climisc.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v
retrieving revision 1.126
diff -u -r1.126 climisc.c
--- client/climisc.c    2004/01/24 16:45:18     1.126
+++ client/climisc.c    2004/01/28 00:22:05
@@ -99,8 +99,10 @@
 
   pcity = map_get_city(x, y);
   if (pcity) {
-    pcity->client.occupied =
+    if (pplayers_allied(city_owner(pcity), game.player_ptr)) {
+      pcity->client.occupied =
        (unit_list_size(&(map_get_tile(pcity->x, pcity->y)->units)) > 0);
+    }
 
     refresh_city_dialog(pcity);
     freelog(LOG_DEBUG, "map city %s, %s, (%d %d)", pcity->name,
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.66
diff -u -r1.66 goto.c
--- client/goto.c       2004/01/20 21:52:06     1.66
+++ client/goto.c       2004/01/28 00:22:05
@@ -371,7 +371,6 @@
 static void fill_client_goto_parameter(struct unit *punit,
                                       struct pf_parameter *parameter)
 {
-  pft_fill_default_parameter(parameter);
   pft_fill_unit_parameter(parameter, punit);
   assert(parameter->get_EC == NULL);
   parameter->get_EC = get_EC;
Index: common/aicore/pf_tools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/pf_tools.c,v
retrieving revision 1.11
diff -u -r1.11 pf_tools.c
--- common/aicore/pf_tools.c    2004/01/19 06:01:22     1.11
+++ common/aicore/pf_tools.c    2004/01/28 00:22:05
@@ -21,6 +21,10 @@
 
 #include "pf_tools.h"
 
+
+static void pft_fill_unit_default_parameter(struct pf_parameter *parameter,
+                                           struct unit *punit);
+
 /* ===================== Move Cost Callbacks ========================= */
 
 /*************************************************************
@@ -388,13 +392,7 @@
 void pft_fill_unit_parameter(struct pf_parameter *parameter,
                             struct unit *punit)
 {
-  parameter->start_x = punit->x;
-  parameter->start_y = punit->y;
-  parameter->moves_left_initially = punit->moves_left;
-  parameter->move_rate = unit_move_rate(punit);
-  parameter->owner = unit_owner(punit);
-  parameter->unit_flags = unit_type(punit)->flags;
-  parameter->omniscience = !ai_handicap(unit_owner(punit), H_MAP);
+  pft_fill_unit_default_parameter(parameter, punit);
 
   switch (unit_type(punit)->move_type) {
   case LAND_MOVING:
@@ -438,17 +436,7 @@
 void pft_fill_unit_overlap_param(struct pf_parameter *parameter,
                                 struct unit *punit)
 {
-  parameter->turn_mode = TM_CAPPED;
-  parameter->get_TB = NULL;
-  parameter->get_EC = NULL;
-
-  parameter->start_x = punit->x;
-  parameter->start_y = punit->y;
-  parameter->moves_left_initially = punit->moves_left;
-  parameter->move_rate = unit_move_rate(punit);
-  parameter->owner = unit_owner(punit);
-  parameter->unit_flags = unit_type(punit)->flags;
-  parameter->omniscience = !ai_handicap(unit_owner(punit), H_MAP);
+  pft_fill_unit_default_parameter(parameter, punit);
 
   switch (unit_type(punit)->move_type) {
   case LAND_MOVING:
@@ -478,18 +466,8 @@
 void pft_fill_unit_attack_param(struct pf_parameter *parameter,
                                 struct unit *punit)
 {
-  parameter->turn_mode = TM_CAPPED;
-  parameter->get_TB = NULL;
-  parameter->get_EC = NULL;
+  pft_fill_unit_default_parameter(parameter, punit);
 
-  parameter->start_x = punit->x;
-  parameter->start_y = punit->y;
-  parameter->moves_left_initially = punit->moves_left;
-  parameter->move_rate = unit_move_rate(punit);
-  parameter->owner = unit_owner(punit);
-  parameter->unit_flags = unit_type(punit)->flags;
-  parameter->omniscience = !ai_handicap(unit_owner(punit), H_MAP);
-
   switch (unit_type(punit)->move_type) {
   case LAND_MOVING:
     parameter->get_MC = land_attack_move;
@@ -515,13 +493,25 @@
 /**********************************************************************
   Fill general use parameters to defaults
 ***********************************************************************/
-void pft_fill_default_parameter(struct pf_parameter *parameter)
+static void pft_fill_unit_default_parameter(struct pf_parameter *parameter,
+                                           struct unit *punit)
 {
   parameter->turn_mode = TM_CAPPED;
   parameter->get_TB = NULL;
   parameter->get_EC = NULL;
   BV_CLR_ALL(parameter->unit_flags);
   parameter->omniscience = TRUE;
+
+  parameter->start_x = punit->x;
+  parameter->start_y = punit->y;
+  parameter->moves_left_initially = punit->moves_left;
+  parameter->move_rate = unit_move_rate(punit);
+  parameter->owner = unit_owner(punit);
+  parameter->unit_flags = unit_type(punit)->flags;
+
+  parameter->omniscience = !ai_handicap(unit_owner(punit), H_MAP);
+
+
 }
 
 /**********************************************************************
Index: common/aicore/pf_tools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/pf_tools.h,v
retrieving revision 1.5
diff -u -r1.5 pf_tools.h
--- common/aicore/pf_tools.h    2003/10/13 07:30:57     1.5
+++ common/aicore/pf_tools.h    2004/01/28 00:22:05
@@ -17,7 +17,6 @@
 
 struct pf_path *pft_concat(struct pf_path *dest_path,
                           const struct pf_path *src_path);
-void pft_fill_default_parameter(struct pf_parameter *parameter);
 void pft_fill_unit_parameter(struct pf_parameter *parameter,
                             struct unit *punit);
 void pft_fill_unit_overlap_param(struct pf_parameter *parameter,

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6960) [Request for patch] pft_fill_default_parameter, Jason Short <=