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

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

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: marko.lindqvist@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#11336) [Patch] movetype.[ch]
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 6 Dec 2004 12:32:11 -0800
Reply-to: rt@xxxxxxxxxxx

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

Here is a modification of your patch.

- I renamed movetype.[ch] as movement.[ch].  Not quite sure why...I
don't think there's a technical reason why one would be better but at
least movement is a full word.

- Move unit_type() back into unittype.c.  Looks like it got moved over
by mistake (the .h files were fine).

- Fixed some style.

- Added *lots* of comments.  This includes some FIXMEs that may actually
be bugs.

- Renamed some parameters.  I changed all movement functions to use
src_tile and dst_tile as their tile parameters.

jason

Index: ai/advmilitary.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v
retrieving revision 1.180
diff -u -r1.180 advmilitary.c
--- ai/advmilitary.c    30 Nov 2004 08:37:01 -0000      1.180
+++ ai/advmilitary.c    6 Dec 2004 20:26:03 -0000
@@ -23,6 +23,7 @@
 #include "government.h"
 #include "log.h"
 #include "map.h"
+#include "movement.h"
 
 #include "citytools.h"
 #include "cityturn.h"
Index: ai/aiair.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiair.c,v
retrieving revision 1.28
diff -u -r1.28 aiair.c
--- ai/aiair.c  29 Sep 2004 02:24:18 -0000      1.28
+++ ai/aiair.c  6 Dec 2004 20:26:03 -0000
@@ -20,6 +20,7 @@
 #include "combat.h"
 #include "log.h"
 #include "map.h"
+#include "movement.h"
 #include "player.h"
 #include "unit.h"
 
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.179
diff -u -r1.179 aicity.c
--- ai/aicity.c 5 Dec 2004 09:01:00 -0000       1.179
+++ ai/aicity.c 6 Dec 2004 20:26:03 -0000
@@ -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"
Index: ai/aidata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidata.c,v
retrieving revision 1.47
diff -u -r1.47 aidata.c
--- ai/aidata.c 30 Nov 2004 08:37:02 -0000      1.47
+++ ai/aidata.c 6 Dec 2004 20:26:04 -0000
@@ -23,6 +23,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "unit.h"
 
 #include "citytools.h"
Index: ai/aidiplomat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidiplomat.c,v
retrieving revision 1.41
diff -u -r1.41 aidiplomat.c
--- ai/aidiplomat.c     18 Oct 2004 23:28:12 -0000      1.41
+++ ai/aidiplomat.c     6 Dec 2004 20:26:04 -0000
@@ -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"
Index: ai/aiexplorer.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiexplorer.c,v
retrieving revision 1.5
diff -u -r1.5 aiexplorer.c
--- ai/aiexplorer.c     29 Sep 2004 02:24:18 -0000      1.5
+++ ai/aiexplorer.c     6 Dec 2004 20:26:04 -0000
@@ -16,6 +16,7 @@
 #endif
 
 #include "log.h"
+#include "movement.h"
 #include "player.h"
 #include "unit.h"
 
Index: ai/aiferry.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiferry.c,v
retrieving revision 1.12
diff -u -r1.12 aiferry.c
--- ai/aiferry.c        30 Nov 2004 06:14:42 -0000      1.12
+++ ai/aiferry.c        6 Dec 2004 20:26:04 -0000
@@ -16,6 +16,7 @@
 #endif
 
 #include "log.h"
+#include "movement.h"
 #include "unit.h"
 
 #include "path_finding.h"
Index: ai/aihunt.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihunt.c,v
retrieving revision 1.12
diff -u -r1.12 aihunt.c
--- ai/aihunt.c 30 Nov 2004 08:37:02 -0000      1.12
+++ ai/aihunt.c 6 Dec 2004 20:26:04 -0000
@@ -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"
Index: ai/aisettler.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aisettler.c,v
retrieving revision 1.11
diff -u -r1.11 aisettler.c
--- ai/aisettler.c      22 Nov 2004 19:14:41 -0000      1.11
+++ ai/aisettler.c      6 Dec 2004 20:26:04 -0000
@@ -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"
Index: ai/aitools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v
retrieving revision 1.132
diff -u -r1.132 aitools.c
--- ai/aitools.c        5 Dec 2004 09:08:18 -0000       1.132
+++ ai/aitools.c        6 Dec 2004 20:26:04 -0000
@@ -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"
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.340
diff -u -r1.340 aiunit.c
--- ai/aiunit.c 30 Nov 2004 08:37:02 -0000      1.340
+++ ai/aiunit.c 6 Dec 2004 20:26:05 -0000
@@ -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"
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.150
diff -u -r1.150 control.c
--- client/control.c    13 Nov 2004 08:27:46 -0000      1.150
+++ client/control.c    6 Dec 2004 20:26:05 -0000
@@ -21,6 +21,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 
 #include "audio.h"
 #include "chatline_g.h"
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.88
diff -u -r1.88 helpdata.c
--- client/helpdata.c   5 Dec 2004 09:08:18 -0000       1.88
+++ client/helpdata.c   6 Dec 2004 20:26:05 -0000
@@ -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"
Index: client/gui-gtk/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/graphics.c,v
retrieving revision 1.53
diff -u -r1.53 graphics.c
--- client/gui-gtk/graphics.c   24 Mar 2004 06:18:18 -0000      1.53
+++ client/gui-gtk/graphics.c   6 Dec 2004 20:26:05 -0000
@@ -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"
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.103
diff -u -r1.103 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        5 Dec 2004 18:02:19 -0000       1.103
+++ client/gui-gtk-2.0/citydlg.c        6 Dec 2004 20:26:06 -0000
@@ -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"
Index: client/gui-gtk-2.0/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/graphics.c,v
retrieving revision 1.28
diff -u -r1.28 graphics.c
--- client/gui-gtk-2.0/graphics.c       23 Nov 2004 15:44:10 -0000      1.28
+++ client/gui-gtk-2.0/graphics.c       6 Dec 2004 20:26:06 -0000
@@ -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"
Index: client/gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.57
diff -u -r1.57 menu.c
--- client/gui-gtk-2.0/menu.c   25 Nov 2004 06:57:17 -0000      1.57
+++ client/gui-gtk-2.0/menu.c   6 Dec 2004 20:26:06 -0000
@@ -27,6 +27,7 @@
 #include "government.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "support.h"
 #include "unit.h"
 
Index: client/gui-mui/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/helpdlg.c,v
retrieving revision 1.37
diff -u -r1.37 helpdlg.c
--- client/gui-mui/helpdlg.c    29 Nov 2004 20:56:51 -0000      1.37
+++ client/gui-mui/helpdlg.c    6 Dec 2004 20:26:06 -0000
@@ -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"
Index: client/gui-win32/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/helpdlg.c,v
retrieving revision 1.24
diff -u -r1.24 helpdlg.c
--- client/gui-win32/helpdlg.c  29 Nov 2004 20:56:51 -0000      1.24
+++ client/gui-win32/helpdlg.c  6 Dec 2004 20:26:06 -0000
@@ -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"
  
Index: client/gui-win32/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/menu.c,v
retrieving revision 1.32
diff -u -r1.32 menu.c
--- client/gui-win32/menu.c     25 Nov 2004 06:57:17 -0000      1.32
+++ client/gui-win32/menu.c     6 Dec 2004 20:26:07 -0000
@@ -28,6 +28,7 @@
 #include "government.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "support.h"
 #include "unit.h"
  
Index: client/gui-xaw/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/graphics.c,v
retrieving revision 1.54
diff -u -r1.54 graphics.c
--- client/gui-xaw/graphics.c   1 Dec 2004 18:56:53 -0000       1.54
+++ client/gui-xaw/graphics.c   6 Dec 2004 20:26:07 -0000
@@ -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"
Index: client/gui-xaw/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/menu.c,v
retrieving revision 1.74
diff -u -r1.74 menu.c
--- client/gui-xaw/menu.c       25 Nov 2004 06:57:17 -0000      1.74
+++ client/gui-xaw/menu.c       6 Dec 2004 20:26:07 -0000
@@ -27,6 +27,7 @@
 
 #include "fcintl.h"
 #include "mem.h"
+#include "movement.h"
 #include "support.h"
 
 #include "government.h"
Index: common/Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/Makefile.am,v
retrieving revision 1.53
diff -u -r1.53 Makefile.am
--- common/Makefile.am  5 Sep 2004 20:02:17 -0000       1.53
+++ common/Makefile.am  6 Dec 2004 20:26:07 -0000
@@ -36,6 +36,8 @@
                improvement.h   \
                map.c           \
                map.h           \
+               movement.c      \
+               movement.h      \
                nation.c        \
                nation.h        \
                packets.c       \
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.272
diff -u -r1.272 city.c
--- common/city.c       6 Dec 2004 18:01:14 -0000       1.272
+++ common/city.c       6 Dec 2004 20:26:07 -0000
@@ -28,6 +28,7 @@
 #include "government.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "packets.h"
 
 #include "cm.h"
Index: common/combat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/combat.c,v
retrieving revision 1.48
diff -u -r1.48 combat.c
--- common/combat.c     17 Nov 2004 19:21:14 -0000      1.48
+++ common/combat.c     6 Dec 2004 20:26:08 -0000
@@ -20,6 +20,7 @@
 
 #include "log.h"
 #include "map.h"
+#include "movement.h"
 #include "packets.h"
 #include "unit.h"
 
Index: common/fc_types.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/fc_types.h,v
retrieving revision 1.11
diff -u -r1.11 fc_types.h
--- common/fc_types.h   3 Dec 2004 09:39:40 -0000       1.11
+++ common/fc_types.h   6 Dec 2004 20:26:08 -0000
@@ -45,4 +45,13 @@
 struct tile;
 struct unit;
 
+/* 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 */
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.208
diff -u -r1.208 map.c
--- common/map.c        30 Nov 2004 05:39:12 -0000      1.208
+++ common/map.c        6 Dec 2004 20:26:08 -0000
@@ -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"
Index: common/movement.c
===================================================================
RCS file: common/movement.c
diff -N common/movement.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ common/movement.c   6 Dec 2004 20:26:08 -0000
@@ -0,0 +1,433 @@
+/****************************************************************************
+ 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)
+{
+  /* Transported units cannot be defenders.
+   *
+   * FIXME: Should this just check punit->transported_by? */
+  if (is_ground_unit(punit)
+      && is_ocean(map_get_terrain(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 ground/land/normal unit type.
+****************************************************************************/
+bool is_ground_unittype(Unit_Type_id id)
+{
+  return (unit_types[id].move_type == LAND_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 sailing/naval/sea/water unit type.
+****************************************************************************/
+bool is_water_unit(Unit_Type_id id)
+{
+  return (unit_types[id].move_type == SEA_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 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.  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;
+}
Index: common/movement.h
===================================================================
RCS file: common/movement.h
diff -N common/movement.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ common/movement.h   6 Dec 2004 20:26:08 -0000
@@ -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_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);
+
+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 */
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.222
diff -u -r1.222 unit.c
--- common/unit.c       6 Dec 2004 18:01:15 -0000       1.222
+++ common/unit.c       6 Dec 2004 20:26:08 -0000
@@ -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)
@@ -1384,207 +1289,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.
 
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.130
diff -u -r1.130 unit.h
--- common/unit.h       6 Dec 2004 18:01:15 -0000       1.130
+++ common/unit.h       6 Dec 2004 20:26:08 -0000
@@ -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(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);
 
Index: common/unittype.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.c,v
retrieving revision 1.44
diff -u -r1.44 unittype.c
--- common/unittype.c   6 Dec 2004 17:54:40 -0000       1.44
+++ common/unittype.c   6 Dec 2004 20:26:08 -0000
@@ -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", 
@@ -86,38 +84,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);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
 int utype_shield_cost(struct unit_type *ut, struct government *g)
 {
   if (government_has_flag(g, G_FANATIC_TROOPS) &&
@@ -379,25 +345,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.
 **************************************************************************/
Index: common/unittype.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.h,v
retrieving revision 1.35
diff -u -r1.35 unittype.h
--- common/unittype.h   5 Dec 2004 09:08:19 -0000       1.35
+++ common/unittype.h   6 Dec 2004 20:26:08 -0000
@@ -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.)
  */
@@ -229,11 +225,6 @@
 bool unit_flag(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);
Index: common/aicore/pf_tools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/pf_tools.c,v
retrieving revision 1.24
diff -u -r1.24 pf_tools.c
--- common/aicore/pf_tools.c    20 Oct 2004 18:20:53 -0000      1.24
+++ common/aicore/pf_tools.c    6 Dec 2004 20:26:09 -0000
@@ -20,6 +20,8 @@
 
 #include "mem.h"
 
+#include "movement.h"
+
 #include "pf_tools.h"
 
 
Index: server/airgoto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/airgoto.c,v
retrieving revision 1.7
diff -u -r1.7 airgoto.c
--- server/airgoto.c    29 Sep 2004 02:24:23 -0000      1.7
+++ server/airgoto.c    6 Dec 2004 20:26:09 -0000
@@ -18,6 +18,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "pqueue.h"
 
 #include "gotohand.h"
Index: server/barbarian.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/barbarian.c,v
retrieving revision 1.80
diff -u -r1.80 barbarian.c
--- server/barbarian.c  6 Oct 2004 17:32:14 -0000       1.80
+++ server/barbarian.c  6 Dec 2004 20:26:10 -0000
@@ -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"
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.287
diff -u -r1.287 citytools.c
--- server/citytools.c  5 Dec 2004 13:00:16 -0000       1.287
+++ server/citytools.c  6 Dec 2004 20:26:10 -0000
@@ -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"
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.146
diff -u -r1.146 gamehand.c
--- server/gamehand.c   4 Dec 2004 00:29:38 -0000       1.146
+++ server/gamehand.c   6 Dec 2004 20:26:11 -0000
@@ -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"
Index: server/gotohand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
retrieving revision 1.188
diff -u -r1.188 gotohand.c
--- server/gotohand.c   22 Nov 2004 19:14:41 -0000      1.188
+++ server/gotohand.c   6 Dec 2004 20:26:11 -0000
@@ -25,6 +25,7 @@
 #include "log.h"
 #include "map.h"
 #include "mem.h"
+#include "movement.h"
 #include "rand.h"
 
 #include "airgoto.h"
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.341
diff -u -r1.341 plrhand.c
--- server/plrhand.c    3 Dec 2004 19:01:10 -0000       1.341
+++ server/plrhand.c    6 Dec 2004 20:26:11 -0000
@@ -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"
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.213
diff -u -r1.213 ruleset.c
--- server/ruleset.c    6 Dec 2004 17:54:40 -0000       1.213
+++ server/ruleset.c    6 Dec 2004 20:26:12 -0000
@@ -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"
Index: server/sanitycheck.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sanitycheck.c,v
retrieving revision 1.55
diff -u -r1.55 sanitycheck.c
--- server/sanitycheck.c        22 Nov 2004 07:12:39 -0000      1.55
+++ server/sanitycheck.c        6 Dec 2004 20:26:12 -0000
@@ -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"
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.210
diff -u -r1.210 savegame.c
--- server/savegame.c   30 Nov 2004 08:37:03 -0000      1.210
+++ server/savegame.c   6 Dec 2004 20:26:13 -0000
@@ -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"
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.213
diff -u -r1.213 settlers.c
--- server/settlers.c   3 Dec 2004 23:00:02 -0000       1.213
+++ server/settlers.c   6 Dec 2004 20:26:13 -0000
@@ -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"
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.316
diff -u -r1.316 unithand.c
--- server/unithand.c   4 Dec 2004 04:44:08 -0000       1.316
+++ server/unithand.c   6 Dec 2004 20:26:14 -0000
@@ -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"
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.312
diff -u -r1.312 unittools.c
--- server/unittools.c  6 Dec 2004 18:01:15 -0000       1.312
+++ server/unittools.c  6 Dec 2004 20:26:14 -0000
@@ -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]