Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] Re: (PR#11336) [Patch] movetype.[ch]
Home

[Freeciv-Dev] Re: (PR#11336) [Patch] movetype.[ch]

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#11336) [Patch] movetype.[ch]
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Thu, 16 Dec 2004 14:58:16 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11336 >

Jason Short wrote:
> 
> Here is a modification of your patch.

  And here is a modification of your modification, against latest HEAD.

  Replaced your unit_can_defend_here() comment with comment of my own 
and changed code to comply. Behavior (for existing rulesets) is not 
changed, but implementation is more general (handles sea units 
transported by land units etc)

  Renamed is_water_unit() -> is_sailing_unittype() for consistency. We 
now have:
  is_ground_unit() & is_ground_unittype(),
  is_air_unit() & is_air_unittype(),
  is_heli_unit() & is_heli_unittype(),
  is_sailing_unit() & is_sailing_unittype()

  I considered renaming, as your comments suggest, 
can_unit_exist_at_tile() -> unit_needs_transporter() and 
can_unit_survive_at_tile() -> unit_wants_transporter(). Decided against 
it for now, I hope we come up with even better names in the future.


  - ML

diff -Nurd -X.diff_ignore freeciv/ai/advmilitary.c freeciv/ai/advmilitary.c
--- freeciv/ai/advmilitary.c    2004-12-16 23:46:33.578125000 +0200
+++ freeciv/ai/advmilitary.c    2004-12-16 23:55:29.250000000 +0200
@@ -23,6 +23,7 @@
 #include "government.h"
 #include "log.h"
 #include "map.h"
+#include "movement.h"
 
 #include "citytools.h"
 #include "cityturn.h"
diff -Nurd -X.diff_ignore freeciv/ai/aiair.c freeciv/ai/aiair.c
--- freeciv/ai/aiair.c  2004-12-16 23:46:33.578125000 +0200
+++ freeciv/ai/aiair.c  2004-12-16 23:55:29.281250000 +0200
@@ -20,6 +20,7 @@
 #include "combat.h"
 #include "log.h"
 #include "map.h"
+#include "movement.h"
 #include "player.h"
 #include "unit.h"
 
diff -Nurd -X.diff_ignore freeciv/ai/aicity.c freeciv/ai/aicity.c
--- freeciv/ai/aicity.c 2004-12-16 23:46:33.578125000 +0200
+++ freeciv/ai/aicity.c 2004-12-16 23:55:29.281250000 +0200
@@ -27,6 +27,7 @@
 #include "government.h"
 #include "log.h"
 #include "map.h"
+#include "movement.h"
 #include "packets.h"
 #include "player.h"
 #include "rand.h"
diff -Nurd -X.diff_ignore freeciv/ai/aidata.c freeciv/ai/aidata.c
--- freeciv/ai/aidata.c 2004-12-16 23:46:33.578125000 +0200
+++ freeciv/ai/aidata.c 2004-12-16 23:55:29.296875000 +0200
@@ -23,6 +23,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "unit.h"
 
 #include "citytools.h"
diff -Nurd -X.diff_ignore freeciv/ai/aidiplomat.c freeciv/ai/aidiplomat.c
--- freeciv/ai/aidiplomat.c     2004-12-16 23:46:33.578125000 +0200
+++ freeciv/ai/aidiplomat.c     2004-12-16 23:55:29.296875000 +0200
@@ -24,6 +24,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "path_finding.h"
 #include "pf_tools.h"
diff -Nurd -X.diff_ignore freeciv/ai/aiexplorer.c freeciv/ai/aiexplorer.c
--- freeciv/ai/aiexplorer.c     2004-12-16 23:46:33.578125000 +0200
+++ freeciv/ai/aiexplorer.c     2004-12-16 23:55:29.296875000 +0200
@@ -16,6 +16,7 @@
 #endif
 
 #include "log.h"
+#include "movement.h"
 #include "player.h"
 #include "unit.h"
 
diff -Nurd -X.diff_ignore freeciv/ai/aiferry.c freeciv/ai/aiferry.c
--- freeciv/ai/aiferry.c        2004-12-16 23:46:33.593750000 +0200
+++ freeciv/ai/aiferry.c        2004-12-16 23:55:29.312500000 +0200
@@ -16,6 +16,7 @@
 #endif
 
 #include "log.h"
+#include "movement.h"
 #include "unit.h"
 
 #include "path_finding.h"
diff -Nurd -X.diff_ignore freeciv/ai/aihunt.c freeciv/ai/aihunt.c
--- freeciv/ai/aihunt.c 2004-12-16 23:46:33.593750000 +0200
+++ freeciv/ai/aihunt.c 2004-12-16 23:55:29.312500000 +0200
@@ -21,6 +21,7 @@
 #include "combat.h"
 #include "game.h"
 #include "map.h"
+#include "movement.h"
 #include "log.h"
 #include "pf_tools.h"
 #include "player.h"
diff -Nurd -X.diff_ignore freeciv/ai/aisettler.c freeciv/ai/aisettler.c
--- freeciv/ai/aisettler.c      2004-12-16 23:46:33.593750000 +0200
+++ freeciv/ai/aisettler.c      2004-12-16 23:55:29.312500000 +0200
@@ -24,6 +24,7 @@
 #include "government.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "log.h"
 #include "packets.h"
 #include "path_finding.h"
diff -Nurd -X.diff_ignore freeciv/ai/aitools.c freeciv/ai/aitools.c
--- freeciv/ai/aitools.c        2004-12-16 23:46:33.593750000 +0200
+++ freeciv/ai/aitools.c        2004-12-16 23:55:29.312500000 +0200
@@ -24,6 +24,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "player.h"
 #include "shared.h"
diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c
--- freeciv/ai/aiunit.c 2004-12-16 23:46:33.593750000 +0200
+++ freeciv/ai/aiunit.c 2004-12-16 23:55:29.328125000 +0200
@@ -25,6 +25,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "pf_tools.h"
 #include "player.h"
diff -Nurd -X.diff_ignore freeciv/client/control.c freeciv/client/control.c
--- freeciv/client/control.c    2004-12-16 23:46:33.890625000 +0200
+++ freeciv/client/control.c    2004-12-16 23:55:29.390625000 +0200
@@ -21,6 +21,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 
 #include "audio.h"
 #include "chatline_g.h"
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk/graphics.c 
freeciv/client/gui-gtk/graphics.c
--- freeciv/client/gui-gtk/graphics.c   2004-12-16 23:46:34.140625000 +0200
+++ freeciv/client/gui-gtk/graphics.c   2004-12-16 23:55:29.453125000 +0200
@@ -25,6 +25,7 @@
 #include "game.h"
 #include "log.h"
 #include "mem.h"
+#include "movement.h"
 #include "shared.h"
 #include "support.h"
 #include "unit.h"
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/citydlg.c 
freeciv/client/gui-gtk-2.0/citydlg.c
--- freeciv/client/gui-gtk-2.0/citydlg.c        2004-12-16 23:46:34.187500000 
+0200
+++ freeciv/client/gui-gtk-2.0/citydlg.c        2004-12-16 23:55:29.531250000 
+0200
@@ -28,6 +28,7 @@
 #include "game.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "player.h"
 #include "shared.h"
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/graphics.c 
freeciv/client/gui-gtk-2.0/graphics.c
--- freeciv/client/gui-gtk-2.0/graphics.c       2004-12-16 23:46:34.234375000 
+0200
+++ freeciv/client/gui-gtk-2.0/graphics.c       2004-12-16 23:55:29.609375000 
+0200
@@ -26,6 +26,7 @@
 #include "game.h"
 #include "log.h"
 #include "mem.h"
+#include "movement.h"
 #include "shared.h"
 #include "support.h"
 #include "unit.h"
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/menu.c 
freeciv/client/gui-gtk-2.0/menu.c
--- freeciv/client/gui-gtk-2.0/menu.c   2004-12-16 23:46:34.250000000 +0200
+++ freeciv/client/gui-gtk-2.0/menu.c   2004-12-16 23:55:29.671875000 +0200
@@ -27,6 +27,7 @@
 #include "government.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "support.h"
 #include "unit.h"
 
diff -Nurd -X.diff_ignore freeciv/client/gui-mui/helpdlg.c 
freeciv/client/gui-mui/helpdlg.c
--- freeciv/client/gui-mui/helpdlg.c    2004-12-16 23:46:35.093750000 +0200
+++ freeciv/client/gui-mui/helpdlg.c    2004-12-16 23:55:29.718750000 +0200
@@ -34,6 +34,7 @@
 #include "genlist.h"
 #include "government.h"
 #include "mem.h"
+#include "movement.h"
 #include "shared.h"
 #include "support.h"
 #include "tech.h"
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/helpdlg.c 
freeciv/client/gui-win32/helpdlg.c
--- freeciv/client/gui-win32/helpdlg.c  2004-12-16 23:46:35.734375000 +0200
+++ freeciv/client/gui-win32/helpdlg.c  2004-12-16 23:55:29.796875000 +0200
@@ -28,11 +28,12 @@
 #include "game.h"
 #include "genlist.h"
 #include "government.h"
+#include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "shared.h"
 #include "tech.h"
 #include "unit.h"
-#include "map.h"
 #include "support.h"
 #include "version.h"
  
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/menu.c 
freeciv/client/gui-win32/menu.c
--- freeciv/client/gui-win32/menu.c     2004-12-16 23:46:35.734375000 +0200
+++ freeciv/client/gui-win32/menu.c     2004-12-16 23:55:29.843750000 +0200
@@ -28,6 +28,7 @@
 #include "government.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "support.h"
 #include "unit.h"
  
diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/graphics.c 
freeciv/client/gui-xaw/graphics.c
--- freeciv/client/gui-xaw/graphics.c   2004-12-16 23:46:35.828125000 +0200
+++ freeciv/client/gui-xaw/graphics.c   2004-12-16 23:55:29.890625000 +0200
@@ -30,6 +30,7 @@
 #include "game.h"
 #include "log.h"
 #include "mem.h"
+#include "movement.h"
 #include "shared.h"
 #include "support.h"
 #include "unit.h"
diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/menu.c 
freeciv/client/gui-xaw/menu.c
--- freeciv/client/gui-xaw/menu.c       2004-12-16 23:46:35.843750000 +0200
+++ freeciv/client/gui-xaw/menu.c       2004-12-16 23:55:29.968750000 +0200
@@ -27,6 +27,7 @@
 
 #include "fcintl.h"
 #include "mem.h"
+#include "movement.h"
 #include "support.h"
 
 #include "government.h"
diff -Nurd -X.diff_ignore freeciv/client/helpdata.c freeciv/client/helpdata.c
--- freeciv/client/helpdata.c   2004-12-16 23:46:35.906250000 +0200
+++ freeciv/client/helpdata.c   2004-12-16 23:55:30.015625000 +0200
@@ -33,6 +33,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "registry.h"
 #include "support.h"
diff -Nurd -X.diff_ignore freeciv/common/Makefile.am freeciv/common/Makefile.am
--- freeciv/common/Makefile.am  2004-12-16 23:46:36.140625000 +0200
+++ freeciv/common/Makefile.am  2004-12-16 23:55:30.031250000 +0200
@@ -36,6 +36,8 @@
                improvement.h   \
                map.c           \
                map.h           \
+               movement.c      \
+               movement.h      \
                nation.c        \
                nation.h        \
                packets.c       \
diff -Nurd -X.diff_ignore freeciv/common/aicore/pf_tools.c 
freeciv/common/aicore/pf_tools.c
--- freeciv/common/aicore/pf_tools.c    2004-12-16 23:46:36.046875000 +0200
+++ freeciv/common/aicore/pf_tools.c    2004-12-16 23:55:30.031250000 +0200
@@ -20,6 +20,8 @@
 
 #include "mem.h"
 
+#include "movement.h"
+
 #include "pf_tools.h"
 
 
diff -Nurd -X.diff_ignore freeciv/common/city.c freeciv/common/city.c
--- freeciv/common/city.c       2004-12-16 23:46:36.078125000 +0200
+++ freeciv/common/city.c       2004-12-17 00:08:41.593750000 +0200
@@ -28,6 +28,7 @@
 #include "government.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 
 #include "cm.h"
@@ -480,7 +481,7 @@
   }
 
   /* You can't build naval units inland. */
-  if (!is_ocean_near_tile(pcity->tile) && is_water_unit(id)) {
+  if (!is_ocean_near_tile(pcity->tile) && is_sailing_unittype(id)) {
     return FALSE;
   }
   return TRUE;
@@ -516,7 +517,7 @@
 
   /* Some units can be built only in certain cities -- for instance,
      ships may be built only in cities adjacent to ocean. */
-  if (!is_ocean_near_tile(pcity->tile) && is_water_unit(id)) {
+  if (!is_ocean_near_tile(pcity->tile) && is_sailing_unittype(id)) {
     return FALSE;
   }
 
diff -Nurd -X.diff_ignore freeciv/common/combat.c freeciv/common/combat.c
--- freeciv/common/combat.c     2004-12-16 23:46:36.109375000 +0200
+++ freeciv/common/combat.c     2004-12-17 00:08:57.953125000 +0200
@@ -20,6 +20,7 @@
 
 #include "log.h"
 #include "map.h"
+#include "movement.h"
 #include "packets.h"
 #include "unit.h"
 
@@ -432,7 +433,7 @@
          && unit_type_flag(att_type, F_MISSILE)) {
        defensepower = defensepower * (100 + mod) / 100;
       }
-    } else if (is_water_unit(att_type) && pcity) {
+    } else if (is_sailing_unittype(att_type) && pcity) {
       if ((mod = get_city_bonus(pcity, EFT_SEA_DEFEND)) > 0) {
        defensepower = defensepower * (100 + mod) / 100;
       }
diff -Nurd -X.diff_ignore freeciv/common/fc_types.h freeciv/common/fc_types.h
--- freeciv/common/fc_types.h   2004-12-16 23:46:36.140625000 +0200
+++ freeciv/common/fc_types.h   2004-12-16 23:55:30.062500000 +0200
@@ -41,4 +41,13 @@
 
 #define SP_MAX 20
 
+/* This has to be put here for now, otherwise movement.h and unittype.h
+ * would have a recursive dependency. */
+enum unit_move_type {
+  LAND_MOVING = 1,
+  SEA_MOVING,
+  HELI_MOVING,
+  AIR_MOVING
+};
+
 #endif /* FC__FC_TYPES_H */
diff -Nurd -X.diff_ignore freeciv/common/map.c freeciv/common/map.c
--- freeciv/common/map.c        2004-12-16 23:46:36.156250000 +0200
+++ freeciv/common/map.c        2004-12-16 23:55:30.093750000 +0200
@@ -22,6 +22,7 @@
 #include "fcintl.h"
 #include "log.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "rand.h"
 #include "shared.h"
diff -Nurd -X.diff_ignore freeciv/common/movement.c freeciv/common/movement.c
--- freeciv/common/movement.c   1970-01-01 02:00:00.000000000 +0200
+++ freeciv/common/movement.c   2004-12-17 00:18:45.890625000 +0200
@@ -0,0 +1,431 @@
+/****************************************************************************
+ Freeciv - Copyright (C) 2004 - The Freeciv Team
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+
+#include "fcintl.h"
+#include "log.h"
+#include "shared.h"
+#include "support.h"
+
+#include "fc_types.h"
+#include "map.h"
+#include "movement.h"
+#include "unit.h"
+#include "unittype.h"
+#include "terrain.h"
+
+static const char *move_type_names[] = {
+  "Land", "Sea", "Heli", "Air"
+};
+
+/****************************************************************************
+  This function calculates the move rate of the unit, taking into 
+  account the penalty for reduced hitpoints (affects sea and land 
+  units only), the effects of wonders for sea units, and any veteran
+  bonuses.
+****************************************************************************/
+int unit_move_rate(struct unit *punit)
+{
+  int move_rate = 0;
+  int base_move_rate = unit_type(punit)->move_rate 
+    + unit_type(punit)->veteran[punit->veteran].move_bonus;
+
+  switch (unit_type(punit)->move_type) {
+  case LAND_MOVING:
+    /* Scale the MP based on how many HP the unit has. */
+    move_rate = (base_move_rate * punit->hp) / unit_type(punit)->hp;
+    break;
+
+  case SEA_MOVING:
+    /* Scale the MP based on how many MP the unit has. */
+    move_rate = (base_move_rate * punit->hp) / unit_type(punit)->hp;
+
+    /* Add on effects bonus (Magellan's Expedition and Lighthouse). */
+    move_rate += (get_player_bonus(unit_owner(punit), EFT_SEA_MOVE)
+                 * SINGLE_MOVE);
+
+    /* Check for special tech (Nuclear Power). */
+    if (player_knows_techs_with_flag(unit_owner(punit), TF_BOAT_FAST)) {
+      move_rate += SINGLE_MOVE;
+    }
+
+    /* Don't let the move_rate be less than 2 unless the base_move_rate is
+     * also less than 2. */
+    if (move_rate < 2 * SINGLE_MOVE) {
+      move_rate = MIN(2 * SINGLE_MOVE, base_move_rate);
+    }
+    break;
+
+  case HELI_MOVING:
+  case AIR_MOVING:
+    /* No modifiers for air or helicoptor units. */
+    move_rate = base_move_rate;
+    break;
+
+  default:
+    die("In %s:unit_move_rate: illegal move type %d",
+       __FILE__, unit_type(punit)->move_type);
+  }
+
+  /* Don't let any unit get less than 1 MP. */
+  if (move_rate < SINGLE_MOVE && base_move_rate > 0) {
+    move_rate = SINGLE_MOVE;
+  }
+
+  return move_rate;
+}
+
+/****************************************************************************
+  Return TRUE iff the unit can be a defender at its current location.  This
+  should be checked when looking for a defender - not all units on the
+  tile are valid defenders.
+****************************************************************************/
+bool unit_can_defend_here(struct unit *punit)
+{
+  /* Even transported units may step out from transport to fight,
+     if this is their native terrain. */
+  if (can_unit_exist_at_tile(punit, punit->tile)) {
+    return FALSE;
+  }
+  
+  return TRUE;
+}
+
+/****************************************************************************
+  Return TRUE iff this unit is a sailing/naval/sea/water unit.
+****************************************************************************/
+bool is_sailing_unit(struct unit *punit)
+{
+  return (unit_type(punit)->move_type == SEA_MOVING);
+}
+
+/****************************************************************************
+  Return TRUE iff this unit is an air/plane unit (including missiles).
+****************************************************************************/
+bool is_air_unit(struct unit *punit)
+{
+  return (unit_type(punit)->move_type == AIR_MOVING);
+}
+
+/****************************************************************************
+  Return TRUE iff this unit is a helicoptor unit.
+****************************************************************************/
+bool is_heli_unit(struct unit *punit)
+{
+  return (unit_type(punit)->move_type == HELI_MOVING);
+}
+
+/****************************************************************************
+  Return TRUE iff this unit is a ground/land/normal unit.
+****************************************************************************/
+bool is_ground_unit(struct unit *punit)
+{
+  return (unit_type(punit)->move_type == LAND_MOVING);
+}
+
+/****************************************************************************
+  Return TRUE iff this unit type is a sailing/naval/sea/water unit type.
+****************************************************************************/
+bool is_sailing_unittype(Unit_Type_id id)
+{
+  return (unit_types[id].move_type == SEA_MOVING);
+}
+
+/****************************************************************************
+  Return TRUE iff this unit type is an air unit type (including missiles).
+****************************************************************************/
+bool is_air_unittype(Unit_Type_id id)
+{
+  return (unit_types[id].move_type == AIR_MOVING);
+}
+
+/****************************************************************************
+  Return TRUE iff this unit type is a helicoptor unit type.
+****************************************************************************/
+bool is_heli_unittype(Unit_Type_id id)
+{
+  return (unit_types[id].move_type == HELI_MOVING);
+}
+
+/****************************************************************************
+  Return TRUE iff this unit type is a ground/land/normal unit type.
+****************************************************************************/
+bool is_ground_unittype(Unit_Type_id id)
+{
+  return (unit_types[id].move_type == LAND_MOVING);
+}
+
+/****************************************************************************
+  Convert unit_move_type names to enum; case insensitive;
+  returns 0 if can't match.
+****************************************************************************/
+enum unit_move_type unit_move_type_from_str(const char *s)
+{
+  enum unit_move_type i;
+
+  /* a compile-time check would be nicer, but this will do: */
+  assert(ARRAY_SIZE(move_type_names) == (AIR_MOVING - LAND_MOVING + 1));
+
+  for (i = LAND_MOVING; i <= AIR_MOVING; i++) {
+    if (mystrcasecmp(move_type_names[i - LAND_MOVING], s) == 0) {
+      return i;
+    }
+  }
+  return 0;
+}
+
+/****************************************************************************
+  Return TRUE iff the unit can "exist" at this location.  This means it can
+  physically be present on the tile (without the use of a transporter).  See
+  also can_unit_survive_at_tile.
+
+  (This function could be renamed as unit_needs_transporter.)
+****************************************************************************/
+bool can_unit_exist_at_tile(struct unit *punit, const struct tile *ptile)
+{
+  if (ptile->city) {
+    return TRUE;
+  }
+
+  switch (unit_types[punit->type].move_type) {
+  case LAND_MOVING:
+    return !is_ocean(ptile->terrain);
+  case SEA_MOVING:
+    return is_ocean(ptile->terrain);
+  case AIR_MOVING:
+  case HELI_MOVING:
+    return TRUE;
+  }
+  die("Invalid move type");
+  return FALSE;
+}
+
+
+/****************************************************************************
+  Return TRUE iff the unit can "survive" at this location.  This means it can
+  not only be physically present at the tile but will be able to survive
+  indefinitely on its own (without a transporter).  Units that require fuel
+  or have a danger of drowning are examples of non-survivable units.  See
+  also can_unit_exist_at_tile.
+
+  (This function could be renamed as unit_wants_transporter.)
+****************************************************************************/
+bool can_unit_survive_at_tile(struct unit *punit, const struct tile *ptile)
+{
+  if (!can_unit_exist_at_tile(punit, ptile)) {
+    return FALSE;
+  }
+
+  if (map_get_city(ptile)) {
+    return TRUE;
+  }
+
+  /* TODO: check for dangerous positions (like triremes in deep water). */
+
+  switch (unit_types[punit->type].move_type) {
+  case LAND_MOVING:
+  case SEA_MOVING:
+    return TRUE;
+  case AIR_MOVING:
+  case HELI_MOVING:
+    return FALSE;
+  }
+  die("Invalid move type");
+  return TRUE;
+}
+
+/****************************************************************************
+  Returns whether the unit is allowed (by ZOC) to move from src_tile
+  to dest_tile (assumed adjacent).
+
+  You CAN move if:
+    1. You have units there already
+    2. Your unit isn't a ground unit
+    3. Your unit ignores ZOC (diplomat, freight, etc.)
+    4. You're moving from or to a city
+    5. You're moving from an ocean square (from a boat)
+    6. The spot you're moving from or to is in your ZOC
+****************************************************************************/
+bool can_step_taken_wrt_to_zoc(Unit_Type_id type,
+                              struct player *unit_owner,
+                              const struct tile *src_tile,
+                              const struct tile *dst_tile)
+{
+  if (unit_type_really_ignores_zoc(type)) {
+    return TRUE;
+  }
+  if (is_allied_unit_tile(dst_tile, unit_owner)) {
+    return TRUE;
+  }
+  if (map_get_city(src_tile) || map_get_city(dst_tile)) {
+    return TRUE;
+  }
+  if (is_ocean(map_get_terrain(src_tile))
+      || is_ocean(map_get_terrain(dst_tile))) {
+    return TRUE;
+  }
+  return (is_my_zoc(unit_owner, src_tile)
+         || is_my_zoc(unit_owner, dst_tile));
+}
+
+/****************************************************************************
+  See can_step_take_wrt_to_zoc().  This function is exactly the same but
+  it takes a unit instead of a unittype and player.
+****************************************************************************/
+static bool zoc_ok_move_gen(struct unit *punit,
+                           const struct tile *src_tile,
+                           const struct tile *dst_tile)
+{
+  return can_step_taken_wrt_to_zoc(punit->type, unit_owner(punit),
+                                  src_tile, dst_tile);
+}
+
+/****************************************************************************
+  Returns whether the unit can safely move from its current position to
+  the adjacent dst_tile.  This function checks only ZOC.
+
+  See can_step_taken_wrt_to_zoc().
+****************************************************************************/
+bool zoc_ok_move(struct unit *punit, const struct tile *dst_tile)
+{
+  return zoc_ok_move_gen(punit, punit->tile, dst_tile);
+}
+
+/****************************************************************************
+  Returns whether the unit can move from its current tile to the destination
+  tile.
+
+  See test_unit_move_to_tile().
+****************************************************************************/
+bool can_unit_move_to_tile(struct unit *punit, const struct tile *dst_tile,
+                          bool igzoc)
+{
+  return MR_OK == test_unit_move_to_tile(punit->type, unit_owner(punit),
+                                        punit->activity,
+                                        punit->tile, dst_tile,
+                                        igzoc);
+}
+
+/**************************************************************************
+  Returns whether the unit can move from its current tile to the
+  destination tile.  An enumerated value is returned indication the error
+  or success status.
+
+  The unit can move if:
+    1) The unit is idle or on server goto.
+    2) The target location is next to the unit.
+    3) There are no non-allied units on the target tile.
+    4) A ground unit can only move to ocean squares if there
+       is a transporter with free capacity.
+    5) Marines are the only units that can attack from a ocean square.
+    6) Naval units can only be moved to ocean squares or city squares.
+    7) There are no peaceful but un-allied units on the target tile.
+    8) There is not a peaceful but un-allied city on the target tile.
+    9) There is no non-allied unit blocking (zoc) [or igzoc is true].
+**************************************************************************/
+enum unit_move_result test_unit_move_to_tile(Unit_Type_id type,
+                                            struct player *unit_owner,
+                                            enum unit_activity activity,
+                                            const struct tile *src_tile,
+                                            const struct tile *dst_tile,
+                                            bool igzoc)
+{
+  bool zoc;
+  struct city *pcity;
+
+  /* 1) */
+  if (activity != ACTIVITY_IDLE
+      && activity != ACTIVITY_GOTO) {
+    /* For other activities the unit must be stationary. */
+    return MR_BAD_ACTIVITY;
+  }
+
+  /* 2) */
+  if (!is_tiles_adjacent(src_tile, dst_tile)) {
+    /* Of course you can only move to adjacent positions. */
+    return MR_BAD_DESTINATION;
+  }
+
+  /* 3) */
+  if (is_non_allied_unit_tile(dst_tile, unit_owner)) {
+    /* You can't move onto a tile with non-allied units on it (try
+     * attacking instead). */
+    return MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT;
+  }
+
+  if (unit_types[type].move_type == LAND_MOVING) {
+    /* 4) */
+    if (is_ocean(dst_tile->terrain) &&
+       ground_unit_transporter_capacity(dst_tile, unit_owner) <= 0) {
+      /* Ground units can't move onto ocean tiles unless there's enough
+       * room on transporters for them. */
+      return MR_NO_SEA_TRANSPORTER_CAPACITY;
+    }
+
+    /* Moving from ocean */
+    if (is_ocean(src_tile->terrain)) {
+      /* 5) */
+      if (!unit_type_flag(type, F_MARINES)
+         && is_enemy_city_tile(dst_tile, unit_owner)) {
+       /* Most ground units can't move into cities from ships.  (Note this
+        * check is only for movement, not attacking: most ground units
+        * can't attack from ship at *any* units on land.) */
+       return MR_BAD_TYPE_FOR_CITY_TAKE_OVER;
+      }
+    }
+  } else if (unit_types[type].move_type == SEA_MOVING) {
+    /* 6) */
+    if (!is_ocean(dst_tile->terrain)
+       && dst_tile->terrain != T_UNKNOWN
+       && !is_allied_city_tile(dst_tile, unit_owner)) {
+      /* Naval units can't move onto land, except into (allied) cities.
+       *
+       * The check for T_UNKNOWN here is probably unnecessary.  Since the
+       * dst_tile is adjacent to the src_tile it must be known to punit's
+       * owner, even at the client side. */
+      return MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY;
+    }
+  }
+
+  /* 7) */
+  if (is_non_attack_unit_tile(dst_tile, unit_owner)) {
+    /* You can't move into a non-allied tile.
+     *
+     * FIXME: this should never happen since it should be caught by check
+     * #3. */
+    return MR_NO_WAR;
+  }
+
+  /* 8) */
+  pcity = dst_tile->city;
+  if (pcity && pplayers_non_attack(city_owner(pcity), unit_owner)) {
+    /* You can't move into an empty city of a civilization you're at
+     * peace with - you must first either declare war or make alliance. */
+    return MR_NO_WAR;
+  }
+
+  /* 9) */
+  zoc = igzoc
+    || can_step_taken_wrt_to_zoc(type, unit_owner, src_tile, dst_tile);
+  if (!zoc) {
+    /* The move is illegal because of zones of control. */
+    return MR_ZOC;
+  }
+
+  return MR_OK;
+}
diff -Nurd -X.diff_ignore freeciv/common/movement.h freeciv/common/movement.h
--- freeciv/common/movement.h   1970-01-01 02:00:00.000000000 +0200
+++ freeciv/common/movement.h   2004-12-17 00:07:28.250000000 +0200
@@ -0,0 +1,50 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef FC__MOVEMENT_H
+#define FC__MOVEMENT_H
+
+#include "fc_types.h"
+#include "terrain.h"
+#include "unit.h"       /* enum unit_activity */
+#include "unittype.h"
+
+int unit_move_rate(struct unit *punit);
+bool unit_can_defend_here(struct unit *punit);
+
+bool is_sailing_unit(struct unit *punit);
+bool is_air_unit(struct unit *punit);
+bool is_heli_unit(struct unit *punit);
+bool is_ground_unit(struct unit *punit);
+bool is_sailing_unittype(Unit_Type_id id);
+bool is_air_unittype(Unit_Type_id id);
+bool is_heli_unittype(Unit_Type_id id);
+bool is_ground_unittype(Unit_Type_id id);
+
+enum unit_move_type unit_move_type_from_str(const char *s);
+
+bool can_unit_exist_at_tile(struct unit *punit, const struct tile *ptile);
+bool can_unit_survive_at_tile(struct unit *punit, const struct tile *ptile);
+bool can_step_taken_wrt_to_zoc(Unit_Type_id type, struct player *unit_owner,
+                              const struct tile *src_tile,
+                              const struct tile *dst_tile);
+bool zoc_ok_move(struct unit *punit, const struct tile *dst_tile);
+bool can_unit_move_to_tile(struct unit *punit, const struct tile *dst_tile,
+                          bool igzoc);
+enum unit_move_result test_unit_move_to_tile(Unit_Type_id type,
+                                            struct player *unit_owner,
+                                            enum unit_activity activity,
+                                            const struct tile *src_tile,
+                                            const struct tile *dst_tile,
+                                            bool igzoc);
+
+#endif  /* FC__MOVEMENT_H */
diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c       2004-12-16 23:46:36.171875000 +0200
+++ freeciv/common/unit.c       2004-12-16 23:55:30.109375000 +0200
@@ -22,6 +22,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "player.h"
 #include "shared.h"
@@ -31,57 +32,6 @@
 #include "city.h"
 #include "unit.h"
 
-/***************************************************************
-This function calculates the move rate of the unit taking into 
-account the penalty for reduced hitpoints (affects sea and land 
-units only) and the effects of wonders for sea units
-+ veteran bonus.
-
-FIXME: Use generalised improvements code instead of hardcoded
-wonder effects --RK
-***************************************************************/
-int unit_move_rate(struct unit *punit)
-{
-  int move_rate = 0;
-  int base_move_rate = unit_type(punit)->move_rate 
-                       + unit_type(punit)->veteran[punit->veteran].move_bonus;
-
-  switch (unit_type(punit)->move_type) {
-  case LAND_MOVING:
-    move_rate = (base_move_rate * punit->hp) / unit_type(punit)->hp;
-    break;
- 
-  case SEA_MOVING:
-    move_rate = (base_move_rate * punit->hp) / unit_type(punit)->hp;
-
-    move_rate += (get_player_bonus(unit_owner(punit), EFT_SEA_MOVE)
-                 * SINGLE_MOVE);
-
-    if (player_knows_techs_with_flag(unit_owner(punit), TF_BOAT_FAST)) {
-      move_rate += SINGLE_MOVE;
-    }
- 
-    if (move_rate < 2 * SINGLE_MOVE) {
-      move_rate = MIN(2 * SINGLE_MOVE, base_move_rate);
-    }
-    break;
-
-  case HELI_MOVING:
-  case AIR_MOVING:
-    move_rate = base_move_rate;
-    break;
-
-  default:
-    die("In common/unit.c:unit_move_rate: illegal move type %d",
-                                       unit_type(punit)->move_type);
-  }
-  
-  if (move_rate < SINGLE_MOVE && base_move_rate > 0) {
-    move_rate = SINGLE_MOVE;
-  }
-  return move_rate;
-}
-
 /**************************************************************************
 bribe unit
 investigate
@@ -256,19 +206,6 @@
 }
 
 /**************************************************************************
-...
-**************************************************************************/
-bool unit_can_defend_here(struct unit *punit)
-{
-  if (is_ground_unit(punit)
-      && is_ocean(map_get_terrain(punit->tile))) {
-    return FALSE;
-  }
-  
-  return TRUE;
-}
-
-/**************************************************************************
 Returns the number of free spaces for ground units. Can be 0 or negative.
 **************************************************************************/
 int ground_unit_transporter_capacity(const struct tile *ptile,
@@ -321,38 +258,6 @@
 }
 
 /**************************************************************************
-...
-**************************************************************************/
-bool is_sailing_unit(struct unit *punit)
-{
-  return (unit_type(punit)->move_type == SEA_MOVING);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-bool is_air_unit(struct unit *punit)
-{
-  return (unit_type(punit)->move_type == AIR_MOVING);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-bool is_heli_unit(struct unit *punit)
-{
-  return (unit_type(punit)->move_type == HELI_MOVING);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-bool is_ground_unit(struct unit *punit)
-{
-  return (unit_type(punit)->move_type == LAND_MOVING);
-}
-
-/**************************************************************************
   Is the unit capable of attacking?
 **************************************************************************/
 bool is_attack_unit(struct unit *punit)
@@ -1386,207 +1291,6 @@
 }
 
 /**************************************************************************
-  Returns whether the unit is allowed (by ZOC) to move from (src_x,src_y)
-  to (dest_x,dest_y) (assumed adjacent).
-  You CAN move if:
-  1. You have units there already
-  2. Your unit isn't a ground unit
-  3. Your unit ignores ZOC (diplomat, freight, etc.)
-  4. You're moving from or to a city
-  5. You're moving from an ocean square (from a boat)
-  6. The spot you're moving from or to is in your ZOC
-**************************************************************************/
-bool can_step_taken_wrt_to_zoc(Unit_Type_id type,
-                              struct player *unit_owner,
-                              const struct tile *src_tile,
-                              const struct tile *dst_tile)
-{
-  if (unit_type_really_ignores_zoc(type))
-    return TRUE;
-  if (is_allied_unit_tile(dst_tile, unit_owner)) {
-    return TRUE;
-  }
-  if (map_get_city(src_tile) || map_get_city(dst_tile)) {
-    return TRUE;
-  }
-  if (is_ocean(map_get_terrain(src_tile))
-      || is_ocean(map_get_terrain(dst_tile))) {
-    return TRUE;
-  }
-  return (is_my_zoc(unit_owner, src_tile)
-         || is_my_zoc(unit_owner, dst_tile));
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-static bool zoc_ok_move_gen(struct unit *punit, const struct tile *ptile1,
-                           const struct tile *ptile2)
-{
-  return can_step_taken_wrt_to_zoc(punit->type, unit_owner(punit),
-                                  ptile1, ptile2);
-}
-
-/**************************************************************************
-  Convenience wrapper for zoc_ok_move_gen(), using the unit's (x,y)
-  as the starting point.
-**************************************************************************/
-bool zoc_ok_move(struct unit *punit, const struct tile *ptile)
-{
-  return zoc_ok_move_gen(punit, punit->tile, ptile);
-}
-
-/****************************************************************************
-  Return TRUE iff the unit can "exist" at this location.  This means it can
-  physically be present on the tile (without the use of a transporter).
-****************************************************************************/
-bool can_unit_exist_at_tile(struct unit *punit, const struct tile *ptile)
-{
-  if (ptile->city) {
-    return TRUE;
-  }
-
-  switch (unit_types[punit->type].move_type) {
-  case LAND_MOVING:
-    return !is_ocean(ptile->terrain);
-  case SEA_MOVING:
-    return is_ocean(ptile->terrain);
-  case AIR_MOVING:
-  case HELI_MOVING:
-    return TRUE;
-  }
-  die("Invalid move type");
-  return FALSE;
-}
-
-/****************************************************************************
-  Return TRUE iff the unit can "survive" at this location.  This means it can
-  not only be phsically present at the tile but will be able to survive
-  indefinitely on its own (without a transporter).  Units that require fuel
-  or have a danger of drowning are examples of non-survivable units.
-****************************************************************************/
-bool can_unit_survive_at_tile(struct unit *punit, const struct tile *ptile)
-{
-  if (!can_unit_exist_at_tile(punit, ptile)) {
-    return FALSE;
-  }
-
-  if (map_get_city(ptile)) {
-    return TRUE;
-  }
-
-  /* TODO: check for dangerous positions (like triremes in deep water). */
-
-  switch (unit_types[punit->type].move_type) {
-  case LAND_MOVING:
-  case SEA_MOVING:
-    return TRUE;
-  case AIR_MOVING:
-  case HELI_MOVING:
-    return FALSE;
-  }
-  die("Invalid move type");
-  return TRUE;
-}
-
-/**************************************************************************
-  Convenience wrapper for test_unit_move_to_tile.
-**************************************************************************/
-bool can_unit_move_to_tile(struct unit *punit, const struct tile *dst_tile,
-                          bool igzoc)
-{
-  return MR_OK == test_unit_move_to_tile(punit->type, unit_owner(punit),
-                                        punit->activity,
-                                        punit->tile, dst_tile,
-                                        igzoc);
-}
-
-/**************************************************************************
-  unit can be moved if:
-  1) the unit is idle or on server goto.
-  2) the target location is on the map
-  3) the target location is next to the unit
-  4) there are no non-allied units on the target tile
-  5) a ground unit can only move to ocean squares if there
-     is a transporter with free capacity
-  6) marines are the only units that can attack from a ocean square
-  7) naval units can only be moved to ocean squares or city squares
-  8) there are no peaceful but un-allied units on the target tile
-  9) there is not a peaceful but un-allied city on the target tile
-  10) there is no non-allied unit blocking (zoc) [or igzoc is true]
-**************************************************************************/
-enum unit_move_result test_unit_move_to_tile(Unit_Type_id type,
-                                            struct player *unit_owner,
-                                            enum unit_activity activity,
-                                            const struct tile *pfromtile,
-                                            const struct tile *ptotile,
-                                            bool igzoc)
-{
-  bool zoc;
-  struct city *pcity;
-
-  /* 1) */
-  if (activity != ACTIVITY_IDLE
-      && activity != ACTIVITY_GOTO) {
-    return MR_BAD_ACTIVITY;
-  }
-
-  /* 3) */
-  if (!is_tiles_adjacent(pfromtile, ptotile)) {
-    return MR_BAD_DESTINATION;
-  }
-
-  /* 4) */
-  if (is_non_allied_unit_tile(ptotile, unit_owner)) {
-    return MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT;
-  }
-
-  if (unit_types[type].move_type == LAND_MOVING) {
-    /* 5) */
-    if (is_ocean(ptotile->terrain) &&
-       ground_unit_transporter_capacity(ptotile, unit_owner) <= 0) {
-      return MR_NO_SEA_TRANSPORTER_CAPACITY;
-    }
-
-    /* Moving from ocean */
-    if (is_ocean(pfromtile->terrain)) {
-      /* 6) */
-      if (!unit_type_flag(type, F_MARINES)
-         && is_enemy_city_tile(ptotile, unit_owner)) {
-       return MR_BAD_TYPE_FOR_CITY_TAKE_OVER;
-      }
-    }
-  } else if (unit_types[type].move_type == SEA_MOVING) {
-    /* 7) */
-    if (!is_ocean(ptotile->terrain)
-       && ptotile->terrain != T_UNKNOWN
-       && !is_allied_city_tile(ptotile, unit_owner)) {
-      return MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY;
-    }
-  }
-
-  /* 8) */
-  if (is_non_attack_unit_tile(ptotile, unit_owner)) {
-    return MR_NO_WAR;
-  }
-
-  /* 9) */
-  pcity = ptotile->city;
-  if (pcity && pplayers_non_attack(city_owner(pcity), unit_owner)) {
-    return MR_NO_WAR;
-  }
-
-  /* 10) */
-  zoc = igzoc
-    || can_step_taken_wrt_to_zoc(type, unit_owner, pfromtile, ptotile);
-  if (!zoc) {
-    return MR_ZOC;
-  }
-
-  return MR_OK;
-}
-
-/**************************************************************************
   Calculate the chance of losing (as a percentage) if it were to spend a
   turn at the given location.
 
diff -Nurd -X.diff_ignore freeciv/common/unit.h freeciv/common/unit.h
--- freeciv/common/unit.h       2004-12-16 23:46:36.171875000 +0200
+++ freeciv/common/unit.h       2004-12-16 23:55:30.109375000 +0200
@@ -220,11 +220,9 @@
                                  enum diplomat_actions action,
                                  const struct tile *ptile);
 
-int unit_move_rate(struct unit *punit);
 bool unit_can_help_build_wonder(struct unit *punit, struct city *pcity);
 bool unit_can_help_build_wonder_here(struct unit *punit);
 bool unit_can_est_traderoute_here(struct unit *punit);
-bool unit_can_defend_here(struct unit *punit);
 bool unit_can_airlift_to(struct unit *punit, struct city *pcity);
 bool unit_has_orders(struct unit *punit);
 
@@ -262,10 +260,6 @@
 bool is_square_threatened(struct player *pplayer, const struct tile *ptile);
 bool is_field_unit(struct unit *punit);              /* ships+aero */
 bool is_hiding_unit(const struct unit *punit);
-bool is_sailing_unit(struct unit *punit);
-bool is_air_unit(struct unit *punit);
-bool is_heli_unit(struct unit *punit);
-bool is_ground_unit(struct unit *punit);
 #define COULD_OCCUPY(punit) \
   ((is_ground_unit(punit) || is_heli_unit(punit)) && is_military_unit(punit))
 bool can_unit_add_to_city (struct unit *punit);
@@ -306,21 +300,7 @@
 
 bool is_my_zoc(struct player *unit_owner, const struct tile *ptile);
 bool unit_being_aggressive(struct unit *punit);
-bool can_step_taken_wrt_to_zoc(Unit_Type_id type, struct player *unit_owner,
-                              const struct tile *src_tile,
-                              const struct tile *dst_tile);
-bool can_unit_exist_at_tile(struct unit *punit, const struct tile *ptile);
-bool can_unit_survive_at_tile(struct unit *punit, const struct tile *ptile);
-bool can_unit_move_to_tile(struct unit *punit, const struct tile *ptile,
-                          bool igzoc);
-enum unit_move_result test_unit_move_to_tile(Unit_Type_id type,
-                                            struct player *unit_owner,
-                                            enum unit_activity activity,
-                                            const struct tile *src_tile,
-                                            const struct tile *dst_tile,
-                                            bool igzoc);
 bool unit_type_really_ignores_zoc(Unit_Type_id type);
-bool zoc_ok_move(struct unit *punit, const struct tile *ptile);
 
 bool is_build_or_clean_activity(enum unit_activity activity);
 
diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c   2004-12-16 23:46:36.187500000 +0200
+++ freeciv/common/unittype.c   2004-12-16 23:55:30.125000000 +0200
@@ -23,6 +23,7 @@
 #include "game.h"
 #include "government.h"
 #include "mem.h"
+#include "movement.h"
 #include "player.h"
 #include "shared.h"
 #include "support.h"
@@ -36,9 +37,6 @@
    client/packhand.c (for the client)
 */
 
-static const char *move_type_names[] = {
-  "Land", "Sea", "Heli", "Air"
-};
 static const char *flag_names[] = {
   "TradeRoute" ,"HelpWonder", "Missile", "IgZOC", "NonMil", "IgTer", 
   "Carrier", "OneAttack", "Pikemen", "Horse", "IgWall", "FieldUnit", 
@@ -84,38 +82,6 @@
 }
 
 /**************************************************************************
-...
-**************************************************************************/
-bool is_ground_unittype(Unit_Type_id id)
-{
-  return (unit_types[id].move_type == LAND_MOVING);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-bool is_air_unittype(Unit_Type_id id)
-{
-  return (unit_types[id].move_type == AIR_MOVING);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-bool is_heli_unittype(Unit_Type_id id)
-{
-  return (unit_types[id].move_type == HELI_MOVING);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-bool is_water_unit(Unit_Type_id id)
-{
-  return (unit_types[id].move_type == SEA_MOVING);
-}
-
-/**************************************************************************
   Returns the upkeep of a unit of this type under the given government.
 **************************************************************************/
 int utype_upkeep_cost(const struct unit_type *ut,
@@ -365,25 +331,6 @@
 }
 
 /**************************************************************************
-  Convert unit_move_type names to enum; case insensitive;
-  returns 0 if can't match.
-**************************************************************************/
-enum unit_move_type unit_move_type_from_str(const char *s)
-{
-  enum unit_move_type i;
-
-  /* a compile-time check would be nicer, but this will do: */
-  assert(ARRAY_SIZE(move_type_names) == (AIR_MOVING - LAND_MOVING + 1));
-
-  for(i=LAND_MOVING; i<=AIR_MOVING; i++) {
-    if (mystrcasecmp(move_type_names[i-LAND_MOVING], s)==0) {
-      return i;
-    }
-  }
-  return 0;
-}
-
-/**************************************************************************
   Convert Unit_Class_id names to enum; case insensitive;
   returns UCL_LAST if can't match.
 **************************************************************************/
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h   2004-12-16 23:46:36.187500000 +0200
+++ freeciv/common/unittype.h   2004-12-16 23:55:30.125000000 +0200
@@ -49,10 +49,6 @@
   to hold full number of unit types.
 */
 
-enum unit_move_type {
-  LAND_MOVING = 1, SEA_MOVING, HELI_MOVING, AIR_MOVING
-};
-
 /* Classes for unit types.
  * (These must correspond to unit_class_names[] in unit.c.)
  */
@@ -230,11 +226,6 @@
 bool unit_flag(const struct unit *punit, enum unit_flag_id flag);
 bool unit_has_role(Unit_Type_id id, int role);
 
-bool is_water_unit(Unit_Type_id id);
-bool is_air_unittype(Unit_Type_id id);
-bool is_heli_unittype(Unit_Type_id id);
-bool is_ground_unittype(Unit_Type_id id);
-
 int unit_build_shield_cost(Unit_Type_id id);
 int unit_buy_gold_cost(Unit_Type_id id, int shields_in_stock);
 int unit_disband_shields(Unit_Type_id id);
@@ -258,7 +249,6 @@
 Unit_Type_id find_unit_type_by_name(const char *name);
 Unit_Type_id find_unit_type_by_name_orig(const char *name_orig);
 
-enum unit_move_type unit_move_type_from_str(const char *s);
 Unit_Class_id unit_class_from_str(const char *s);
 enum unit_flag_id unit_flag_from_str(const char *s);
 enum unit_role_id unit_role_from_str(const char *s);
diff -Nurd -X.diff_ignore freeciv/server/airgoto.c freeciv/server/airgoto.c
--- freeciv/server/airgoto.c    2004-12-16 23:47:11.046875000 +0200
+++ freeciv/server/airgoto.c    2004-12-16 23:55:30.125000000 +0200
@@ -18,6 +18,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "pqueue.h"
 
 #include "gotohand.h"
diff -Nurd -X.diff_ignore freeciv/server/barbarian.c freeciv/server/barbarian.c
--- freeciv/server/barbarian.c  2004-12-16 23:47:11.078125000 +0200
+++ freeciv/server/barbarian.c  2004-12-16 23:55:30.140625000 +0200
@@ -31,6 +31,7 @@
 #include "government.h"
 #include "log.h"
 #include "map.h"
+#include "movement.h"
 #include "nation.h"
 #include "rand.h"
 #include "support.h"
diff -Nurd -X.diff_ignore freeciv/server/citytools.c freeciv/server/citytools.c
--- freeciv/server/citytools.c  2004-12-16 23:47:11.484375000 +0200
+++ freeciv/server/citytools.c  2004-12-17 00:20:17.015625000 +0200
@@ -28,6 +28,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "player.h"
 #include "rand.h"
 #include "shared.h"
@@ -494,7 +495,7 @@
   if (is_ground_unittype(id)) {
     return (get_city_bonus(pcity, EFT_LAND_VETERAN) > 0) ? 1 : 0;
   } else {
-    if (is_water_unit(id)) {
+    if (is_sailing_unittype(id)) {
       return (get_city_bonus(pcity, EFT_SEA_VETERAN) > 0) ? 1 : 0;
     } else {
       return (get_city_bonus(pcity, EFT_AIR_VETERAN) > 0) ? 1 : 0;
diff -Nurd -X.diff_ignore freeciv/server/gamehand.c freeciv/server/gamehand.c
--- freeciv/server/gamehand.c   2004-12-16 23:47:12.593750000 +0200
+++ freeciv/server/gamehand.c   2004-12-16 23:55:30.140625000 +0200
@@ -24,6 +24,7 @@
 #include "improvement.h"
 #include "log.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "rand.h"
 #include "registry.h"
diff -Nurd -X.diff_ignore freeciv/server/gotohand.c freeciv/server/gotohand.c
--- freeciv/server/gotohand.c   2004-12-16 23:47:14.359375000 +0200
+++ freeciv/server/gotohand.c   2004-12-16 23:55:30.156250000 +0200
@@ -25,6 +25,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "rand.h"
 
 #include "airgoto.h"
diff -Nurd -X.diff_ignore freeciv/server/plrhand.c freeciv/server/plrhand.c
--- freeciv/server/plrhand.c    2004-12-16 23:47:14.687500000 +0200
+++ freeciv/server/plrhand.c    2004-12-16 23:55:30.156250000 +0200
@@ -24,6 +24,7 @@
 #include "government.h"
 #include "log.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "player.h"
 #include "rand.h"
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c    2004-12-16 23:47:14.718750000 +0200
+++ freeciv/server/ruleset.c    2004-12-16 23:55:30.171875000 +0200
@@ -28,6 +28,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "nation.h"
 #include "packets.h"
 #include "registry.h"
diff -Nurd -X.diff_ignore freeciv/server/sanitycheck.c 
freeciv/server/sanitycheck.c
--- freeciv/server/sanitycheck.c        2004-12-16 23:47:14.781250000 +0200
+++ freeciv/server/sanitycheck.c        2004-12-16 23:55:30.171875000 +0200
@@ -21,6 +21,7 @@
 #include "game.h"
 #include "log.h"
 #include "map.h"
+#include "movement.h"
 #include "player.h"
 #include "terrain.h"
 #include "unit.h"
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c   2004-12-16 23:47:14.890625000 +0200
+++ freeciv/server/savegame.c   2004-12-16 23:55:30.187500000 +0200
@@ -24,6 +24,7 @@
 #include "fcintl.h"
 #include "log.h"
 #include "mem.h"
+#include "movement.h"
 #include "rand.h"
 #include "registry.h"
 #include "shared.h"
diff -Nurd -X.diff_ignore freeciv/server/settlers.c freeciv/server/settlers.c
--- freeciv/server/settlers.c   2004-12-16 23:47:15.015625000 +0200
+++ freeciv/server/settlers.c   2004-12-16 23:55:30.187500000 +0200
@@ -25,6 +25,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "support.h"
 #include "timing.h"
diff -Nurd -X.diff_ignore freeciv/server/unithand.c freeciv/server/unithand.c
--- freeciv/server/unithand.c   2004-12-16 23:47:15.187500000 +0200
+++ freeciv/server/unithand.c   2004-12-16 23:55:30.187500000 +0200
@@ -28,6 +28,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "player.h"
 #include "rand.h"
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c  2004-12-16 23:47:15.187500000 +0200
+++ freeciv/server/unittools.c  2004-12-16 23:55:30.203125000 +0200
@@ -29,6 +29,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 #include "player.h"
 #include "rand.h"

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