[Freeciv-Dev] (PR#18605) [Bugfix] auto-return fixes
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#18605) [Bugfix] auto-return fixes |
From: |
"Marko Lindqvist" <cazfi74@xxxxxxxxx> |
Date: |
Fri, 14 Jul 2006 17:35:35 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=18605 >
These fix several airplane auto-return problems
- Don't go for another refuel point if we are loaded to carrier.
- If we are above free carrier: land
- Once we reach free carrier: land
Untested
- ML
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c 2006-07-15 02:45:51.171875000 +0300
+++ freeciv/server/unittools.c 2006-07-15 03:01:04.375000000 +0300
@@ -386,24 +386,40 @@
* The problem is (again) that here we know too much. -- Zamar */
if (punit->fuel == 1
- && !is_airunit_refuel_point(punit->tile,
- unit_owner(punit), punit->type, TRUE)) {
- iterate_outward(punit->tile, punit->moves_left/3, itr_tile) {
- if (is_airunit_refuel_point(itr_tile, unit_owner(punit),
- punit->type, FALSE)
- &&(air_can_move_between(punit->moves_left / 3, punit->tile,
- itr_tile, unit_owner(punit)) >= 0)) {
- punit->goto_tile = itr_tile;
- set_unit_activity(punit, ACTIVITY_GOTO);
- (void) do_unit_goto(punit, GOTO_MOVE_ANY, FALSE);
- notify_player(pplayer, punit->tile, E_UNIT_ORDERS,
- _("Your %s has returned to refuel."),
- unit_name(punit->type));
- goto OUT;
- }
- } iterate_outward_end;
+ && punit->transported_by == -1
+ && !punit->tile->city
+ && !contains_special(punit->tile->special, S_AIRBASE)) {
+ struct unit *carrier;
+
+ carrier = find_transport_from_tile(punit, punit->tile);
+ if (carrier) {
+ put_unit_onto_transporter(punit, carrier);
+ } else {
+ iterate_outward(punit->tile, punit->moves_left/3, itr_tile) {
+ if (is_airunit_refuel_point(itr_tile, unit_owner(punit),
+ punit->type, FALSE)
+ &&(air_can_move_between(punit->moves_left / 3, punit->tile,
+ itr_tile, unit_owner(punit)) >= 0)) {
+ punit->goto_tile = itr_tile;
+ set_unit_activity(punit, ACTIVITY_GOTO);
+ (void) do_unit_goto(punit, GOTO_MOVE_ANY, FALSE);
+
+ if (!punit->tile->city
+ && !contains_special(punit->tile->special, S_AIRBASE)) {
+ carrier = find_transport_from_tile(punit, punit->tile);
+ if (carrier) {
+ put_unit_onto_transporter(punit, carrier);
+ }
+ }
+
+ notify_player(pplayer, punit->tile, E_UNIT_ORDERS,
+ _("Your %s has returned to refuel."),
+ unit_name(punit->type));
+ break;
+ }
+ } iterate_outward_end;
+ }
}
- OUT:
/* 6) Update fuel */
punit->fuel--;
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c 2006-07-14 03:26:21.171875000 +0300
+++ freeciv/server/unittools.c 2006-07-15 03:27:21.187500000 +0300
@@ -386,24 +386,55 @@
* The problem is (again) that here we know too much. -- Zamar */
if (punit->fuel == 1
- && !is_airunit_refuel_point(punit->tile,
- unit_owner(punit), punit->type, TRUE)) {
- iterate_outward(punit->tile, punit->moves_left/3, itr_tile) {
- if (is_airunit_refuel_point(itr_tile, unit_owner(punit),
- punit->type, FALSE)
- &&(air_can_move_between(punit->moves_left / 3, punit->tile,
- itr_tile, unit_owner(punit)) >= 0)) {
- punit->goto_tile = itr_tile;
- set_unit_activity(punit, ACTIVITY_GOTO);
- (void) do_unit_goto(punit, GOTO_MOVE_ANY, FALSE);
- notify_player(pplayer, punit->tile, E_UNIT_ORDERS,
- _("Your %s has returned to refuel."),
- unit_name(punit->type));
- goto OUT;
- }
- } iterate_outward_end;
+ && punit->transported_by == -1
+ && !punit->tile->city
+ && !contains_special(punit->tile->special, S_AIRBASE)) {
+ bool carrier_found = FALSE;
+
+ unit_list_iterate(punit->tile->units, carrier) {
+ if ((unit_flag(carrier, F_CARRIER)
+ || (unit_flag(punit, F_MISSILE)
+ && unit_flag(carrier, F_MISSILE_CARRIER)))
+ && get_transporter_capacity(carrier) >
+ get_transporter_occupancy(carrier)) {
+ put_unit_onto_transporter(punit, carrier);
+ carrier_found = TRUE;
+ break;
+ }
+ } unit_list_iterate_end;
+
+ if (!carrier_found) {
+ iterate_outward(punit->tile, punit->moves_left/3, itr_tile) {
+ if (is_airunit_refuel_point(itr_tile, unit_owner(punit),
+ punit->type, FALSE)
+ &&(air_can_move_between(punit->moves_left / 3, punit->tile,
+ itr_tile, unit_owner(punit)) >= 0)) {
+ punit->goto_tile = itr_tile;
+ set_unit_activity(punit, ACTIVITY_GOTO);
+ (void) do_unit_goto(punit, GOTO_MOVE_ANY, FALSE);
+
+ if (!punit->tile->city
+ && !contains_special(punit->tile->special, S_AIRBASE)) {
+ unit_list_iterate(punit->tile->units, carrier) {
+ if ((unit_flag(carrier, F_CARRIER)
+ || (unit_flag(punit, F_MISSILE)
+ && unit_flag(carrier, F_MISSILE_CARRIER)))
+ && get_transporter_capacity(carrier) >
+ get_transporter_occupancy(carrier)) {
+ put_unit_onto_transporter(punit, carrier);
+ break;
+ }
+ } unit_list_iterate_end;
+ }
+
+ notify_player(pplayer, punit->tile, E_UNIT_ORDERS,
+ _("Your %s has returned to refuel."),
+ unit_name(punit->type));
+ break;
+ }
+ } iterate_outward_end;
+ }
}
- OUT:
/* 6) Update fuel */
punit->fuel--;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#18605) [Bugfix] auto-return fixes,
Marko Lindqvist <=
|
|