[Freeciv-Dev] (PR#2581) Layers Patch
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
There is still so much dispute that I can't come up with anything
real yet. But here is the relocation of capacity functions. It's
separate from the subject matter and I think it's necessary: I
made my own air transport function and only when I was adding it
to .h I noticed that there were already these in a wrong place.
--
Juhani Heino
Finnish translator and now hacking too
--- common/unit.c.orig Sat May 17 16:18:40 2003
+++ common/unit.c Thu May 22 21:32:12 2003
@@ -261,6 +261,90 @@
}
/**************************************************************************
+Returns the number of free spaces for missiles. Can be 0 or negative.
+**************************************************************************/
+int missile_carrier_capacity(int x, int y, struct player *pplayer,
+ bool count_units_with_extra_fuel)
+{
+ struct tile *ptile = map_get_tile(x, y);
+ int misonly = 0;
+ int airall = 0;
+ int totalcap;
+
+ unit_list_iterate(map_get_tile(x, y)->units, punit) {
+ if (unit_owner(punit) == pplayer) {
+ if (unit_flag(punit, F_CARRIER)
+ && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
+ airall += get_transporter_capacity(punit);
+ continue;
+ }
+ if (unit_flag(punit, F_MISSILE_CARRIER)
+ && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
+ misonly += get_transporter_capacity(punit);
+ continue;
+ }
+ /* Don't count units which have enough fuel (>1) */
+ if (is_air_unit(punit)
+ && (count_units_with_extra_fuel || punit->fuel <= 1)) {
+ if (unit_flag(punit, F_MISSILE))
+ misonly--;
+ else
+ airall--;
+ }
+ }
+ }
+ unit_list_iterate_end;
+
+ if (airall < 0)
+ airall = 0;
+
+ totalcap = airall + misonly;
+
+ return totalcap;
+}
+
+/**************************************************************************
+Returns the number of free spaces for airunits (includes missiles).
+Can be 0 or negative.
+**************************************************************************/
+int airunit_carrier_capacity(int x, int y, struct player *pplayer,
+ bool count_units_with_extra_fuel)
+{
+ struct tile *ptile = map_get_tile(x, y);
+ int misonly = 0;
+ int airall = 0;
+
+ unit_list_iterate(map_get_tile(x, y)->units, punit) {
+ if (unit_owner(punit) == pplayer) {
+ if (unit_flag(punit, F_CARRIER)
+ && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
+ airall += get_transporter_capacity(punit);
+ continue;
+ }
+ if (unit_flag(punit, F_MISSILE_CARRIER)
+ && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
+ misonly += get_transporter_capacity(punit);
+ continue;
+ }
+ /* Don't count units which have enough fuel (>1) */
+ if (is_air_unit(punit)
+ && (count_units_with_extra_fuel || punit->fuel <= 1)) {
+ if (unit_flag(punit, F_MISSILE))
+ misonly--;
+ else
+ airall--;
+ }
+ }
+ }
+ unit_list_iterate_end;
+
+ if (misonly < 0)
+ airall += misonly;
+
+ return airall;
+}
+
+/**************************************************************************
Returns the number of free spaces for ground units. Can be 0 or negative.
**************************************************************************/
int ground_unit_transporter_capacity(int x, int y, struct player *pplayer)
--- common/unit.c.orig Thu May 22 21:32:12 2003
+++ common/unit.c Thu May 22 21:35:12 2003
@@ -1080,90 +1080,6 @@
}
/**************************************************************************
-Returns the number of free spaces for missiles. Can be 0 or negative.
-**************************************************************************/
-int missile_carrier_capacity(int x, int y, struct player *pplayer,
- bool count_units_with_extra_fuel)
-{
- struct tile *ptile = map_get_tile(x, y);
- int misonly = 0;
- int airall = 0;
- int totalcap;
-
- unit_list_iterate(map_get_tile(x, y)->units, punit) {
- if (unit_owner(punit) == pplayer) {
- if (unit_flag(punit, F_CARRIER)
- && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
- airall += get_transporter_capacity(punit);
- continue;
- }
- if (unit_flag(punit, F_MISSILE_CARRIER)
- && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
- misonly += get_transporter_capacity(punit);
- continue;
- }
- /* Don't count units which have enough fuel (>1) */
- if (is_air_unit(punit)
- && (count_units_with_extra_fuel || punit->fuel <= 1)) {
- if (unit_flag(punit, F_MISSILE))
- misonly--;
- else
- airall--;
- }
- }
- }
- unit_list_iterate_end;
-
- if (airall < 0)
- airall = 0;
-
- totalcap = airall + misonly;
-
- return totalcap;
-}
-
-/**************************************************************************
-Returns the number of free spaces for airunits (includes missiles).
-Can be 0 or negative.
-**************************************************************************/
-int airunit_carrier_capacity(int x, int y, struct player *pplayer,
- bool count_units_with_extra_fuel)
-{
- struct tile *ptile = map_get_tile(x, y);
- int misonly = 0;
- int airall = 0;
-
- unit_list_iterate(map_get_tile(x, y)->units, punit) {
- if (unit_owner(punit) == pplayer) {
- if (unit_flag(punit, F_CARRIER)
- && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
- airall += get_transporter_capacity(punit);
- continue;
- }
- if (unit_flag(punit, F_MISSILE_CARRIER)
- && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
- misonly += get_transporter_capacity(punit);
- continue;
- }
- /* Don't count units which have enough fuel (>1) */
- if (is_air_unit(punit)
- && (count_units_with_extra_fuel || punit->fuel <= 1)) {
- if (unit_flag(punit, F_MISSILE))
- misonly--;
- else
- airall--;
- }
- }
- }
- unit_list_iterate_end;
-
- if (misonly < 0)
- airall += misonly;
-
- return airall;
-}
-
-/**************************************************************************
Returns true if the tile contains an allied unit and only allied units.
(ie, if your nation A is allied with B, and B is allied with C, a tile
containing units from B and C will return false)
- [Freeciv-Dev] (PR#2581) Layers Patch,
Juhani Heino <=
|
|