Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#4684) Patch: client-side air goto
Home

[Freeciv-Dev] (PR#4684) Patch: client-side air goto

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#4684) Patch: client-side air goto
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 22 Nov 2004 13:21:29 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Wed Jan 21 06:23:31 2004]:
> 
> Here's a new version of the air-goto-in-pf patch.  I think this should
> go in fairly soon.  Removing server-side client goto will make a lot of
> things much prettier.

And, a new version.

It still has no fuel support.  I still think this is a small price to
pay to be able to use PF+orders for this.  Once we have a user for air
PF, that's more incentive to write fuel support into PF ;-).

Greg, what do you think of this?

jason

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    22 Nov 2004 21:17:15 -0000
@@ -605,14 +605,9 @@
   if (hover_state != HOVER_GOTO) {
     set_hover_state(punit, HOVER_GOTO, ACTIVITY_LAST);
     update_unit_info_label(punit);
-    /* Not yet implemented for air units, including helicopters. */
-    if (is_air_unit(punit) || is_heli_unit(punit)) {
-      draw_goto_line = FALSE;
-    } else {
-      enter_goto_state(punit);
-      create_line_at_mouse_pos();
-    }
-  } else if (!is_air_unit(punit) && !is_heli_unit(punit)) {
+    enter_goto_state(punit);
+    create_line_at_mouse_pos();
+  } else {
     assert(goto_is_active());
     goto_add_waypoint();
   }
@@ -756,11 +751,6 @@
 {
   struct pf_path *path;
 
-  if (is_air_unit(punit) || is_heli_unit(punit)) {
-    /* PF doesn't support air or helicopter units yet. */
-    return;
-  }
-
   if ((path = path_to_nearest_allied_city(punit))) {
     enum unit_activity activity = ACTIVITY_LAST;
     int turns = pf_last_position(path)->turn;
@@ -1029,13 +1019,8 @@
   if (hover_state != HOVER_PATROL) {
     set_hover_state(punit, HOVER_PATROL, ACTIVITY_LAST);
     update_unit_info_label(punit);
-    /* Not yet implemented for air units, including helicopters. */
-    if (is_air_unit(punit) || is_heli_unit(punit)) {
-      draw_goto_line = FALSE;
-    } else {
-      enter_goto_state(punit);
-      create_line_at_mouse_pos();
-    }
+    enter_goto_state(punit);
+    create_line_at_mouse_pos();
   } else {
     assert(goto_is_active());
     goto_add_waypoint();
@@ -1665,19 +1650,14 @@
 **************************************************************************/
 void do_unit_patrol_to(struct unit *punit, struct tile *ptile)
 {
-  if (is_air_unit(punit)) {
-    append_output_window(_("Game: Sorry, airunit patrol not yet 
implemented."));
-    return;
-  } else {
-    struct tile *dest_tile;
+  struct tile *dest_tile;
 
-    draw_line(ptile);
-    dest_tile = get_line_dest();
-    if (ptile == dest_tile) {
-      send_patrol_route(punit);
-    } else {
-      append_output_window(_("Game: Didn't find a route to the destination!"));
-    }
+  draw_line(ptile);
+  dest_tile = get_line_dest();
+  if (ptile == dest_tile) {
+    send_patrol_route(punit);
+  } else {
+    append_output_window(_("Game: Didn't find a route to the destination!"));
   }
 
   set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST);
Index: client/gui-gtk/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/menu.c,v
retrieving revision 1.94
diff -u -r1.94 menu.c
--- client/gui-gtk/menu.c       22 Nov 2004 07:54:46 -0000      1.94
+++ client/gui-gtk/menu.c       22 Nov 2004 21:17:16 -0000
@@ -1180,8 +1180,6 @@
                           can_unit_do_connect(punit, ACTIVITY_RAILROAD));
       menus_set_sensitive("<main>/_Orders/_Connect/_Irrigate",
                           can_unit_do_connect(punit, ACTIVITY_IRRIGATE));
-      menus_set_sensitive("<main>/_Orders/Return to nearest city",
-                         !(is_air_unit(punit) || is_heli_unit(punit)));
       menus_set_sensitive("<main>/_Orders/_Disband Unit",
                           !unit_flag(punit, F_UNDISBANDABLE));
       menus_set_sensitive("<main>/_Orders/Diplomat|Spy Actions",
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.55
diff -u -r1.55 menu.c
--- client/gui-gtk-2.0/menu.c   22 Nov 2004 07:54:46 -0000      1.55
+++ client/gui-gtk-2.0/menu.c   22 Nov 2004 21:17:16 -0000
@@ -1334,8 +1334,6 @@
                           can_unit_do_connect(punit, ACTIVITY_RAILROAD));
       menus_set_sensitive("<main>/_Orders/_Connect/_Irrigate",
                           can_unit_do_connect(punit, ACTIVITY_IRRIGATE));
-      menus_set_sensitive("<main>/_Orders/Return to nearest city",
-                         !(is_air_unit(punit) || is_heli_unit(punit)));
       menus_set_sensitive("<main>/_Orders/Diplomat\\/Spy Actions",
                           (is_diplomat_unit(punit)
                            && diplomat_can_do_action(punit, 
DIPLOMAT_ANY_ACTION,
Index: client/gui-sdl/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/menu.c,v
retrieving revision 1.28
diff -u -r1.28 menu.c
--- client/gui-sdl/menu.c       22 Nov 2004 07:54:47 -0000      1.28
+++ client/gui-sdl/menu.c       22 Nov 2004 21:17:16 -0000
@@ -1220,12 +1220,6 @@
        local_hide(ID_UNIT_ORDER_AIRLIFT);
       }
 
-      if (!pTile->city && !is_air_unittype(pUnit->type)) {
-        local_show(ID_UNIT_ORDER_RETURN);
-      } else {
-       local_hide(ID_UNIT_ORDER_RETURN);
-      }
-      
       if (pTile->city && can_upgrade_unittype(game.player_ptr, pUnit->type) != 
-1) {
        local_show(ID_UNIT_ORDER_UPGRADE);
       } else {
Index: client/gui-xaw/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/menu.c,v
retrieving revision 1.73
diff -u -r1.73 menu.c
--- client/gui-xaw/menu.c       22 Nov 2004 07:54:47 -0000      1.73
+++ client/gui-xaw/menu.c       22 Nov 2004 21:17:16 -0000
@@ -429,8 +429,6 @@
                           unit_can_help_build_wonder_here(punit));
       menu_entry_sensitive(MENU_ORDER, MENU_ORDER_TRADEROUTE,
                           unit_can_est_traderoute_here(punit));
-      menu_entry_sensitive(MENU_ORDER, MENU_ORDER_RETURN,
-                          !(is_air_unit(punit) || is_heli_unit(punit)));
       menu_entry_sensitive(MENU_ORDER, MENU_ORDER_DIPLOMAT_DLG,
                           (is_diplomat_unit(punit)
                            && diplomat_can_do_action(punit, 
DIPLOMAT_ANY_ACTION,
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    22 Nov 2004 21:17:16 -0000
@@ -408,6 +408,28 @@
          || (is_ocean(ptile->terrain) && !is_safe_ocean(ptile)))
          && ptile->city == NULL);
 }
+/****************************************************************************
+  Position-dangerous callback for air units.
+****************************************************************************/
+static bool air_is_pos_dangerous(const struct tile *ptile,
+                                enum known_type known,
+                                struct pf_parameter *param)
+{
+  /* FIXME: bombers with fuel remaining should not worry about danger. */
+
+  if (is_allied_city_tile(ptile, param->owner)) {
+    return FALSE;
+  }
+
+  if (map_has_special(ptile, S_AIRBASE)) {
+    /* All airbases are considered non-dangerous, although non-allied ones
+     * are inaccessible. */
+    return FALSE;
+  }
+
+  /* Carriers are ignored since they are likely to move. */
+  return TRUE;
+}
 
 /**********************************************************************
   Position-dangerous callback for all units other than triremes.
@@ -447,9 +469,22 @@
     break;
   case AIR_MOVING:
     parameter->get_MC = single_airmove;
+    parameter->is_pos_dangerous = air_is_pos_dangerous;
+    parameter->turn_mode = TM_WORST_TIME;
+    break;
+  case HELI_MOVING:
+    /* Helicoptors are treated similarly to airplanes. */
+    parameter->get_MC = single_airmove;
+    if (get_player_bonus(unit_owner(punit), EFT_UNIT_RECOVER)
+       >= unit_type(punit)->hp / 10) {
+      /* United nations cancels out helicoptor fuel loss. */
+      parameter->is_pos_dangerous = NULL;
+    } else {
+      /* Otherwise, don't risk fuel loss. */
+      parameter->is_pos_dangerous = air_is_pos_dangerous;
+      parameter->turn_mode = TM_WORST_TIME;
+    }
     break;
-  default:
-    die("unknown move_type");
   }
 
   if (unit_type(punit)->move_type == LAND_MOVING 
@@ -486,7 +521,8 @@
   case SEA_MOVING:
     parameter->get_MC = sea_overlap_move;
     break;
-  default:
+  case AIR_MOVING:
+  case HELI_MOVING:
     die("Unsupported move_type");
   }
 
@@ -515,7 +551,8 @@
   case SEA_MOVING:
     parameter->get_MC = sea_attack_move;
     break;
-  default:
+  case AIR_MOVING:
+  case HELI_MOVING:
     die("Unsupported move_type");
   }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#4684) Patch: client-side air goto, Jason Short <=