This is the mail archive of the xconq7@sources.redhat.com mailing list for the Xconq project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

fix SupplyLow flag on give/take


This patch makes "g" and "t" (give and take) commands update the
SupplyLow flag.  Because of the way past_halfway_point is coded, the
results might be slightly odd (e.g. you are a fighter with fuel 2/18
and you type "1 t" and your SupplyLow flag goes away despite the fact
that you only have 3/18).  But that seems to be a feature, not a bug,
in past_halfway_point.

2000-10-18  Jim Kingdon <http://sourceforge.net/users/kingdon>

	* ui.c (give_supplies_to_one, take_supplies): Recompute
	supply_is_low flag after we move supplies.

Index: kernel/ui.c
===================================================================
RCS file: /cvs/xconq/xconq/kernel/ui.c,v
retrieving revision 1.53
diff -u -r1.53 ui.c
--- ui.c	2000/09/16 12:54:29	1.53
+++ ui.c	2000/10/19 05:28:04
@@ -2744,7 +2744,8 @@
    much of them as possible into the unit's transport, or to a nearby
    units if there is no transport. */
 
-int give_supplies_to_one(Unit *unit, Unit *unit2, short *amts, short *rslts);
+static int give_supplies_to_one(Unit *unit, Unit *unit2, short *amts,
+				short *rslts);
 
 Unit *
 give_supplies(Unit *unit, short *amts, short *rslts)
@@ -2806,7 +2807,7 @@
 /* Given a pair of units, have one give the desired amounts to the
    other. */
 
-int
+static int
 give_supplies_to_one(Unit *unit, Unit *unit2, short *amts, short *rslts)
 {
     int m, gift, maxgift, actual, didsome = FALSE;
@@ -2832,6 +2833,25 @@
 	    }
 	}
     }
+
+    if (didsome) {
+	/* Recompute the supply_is_low flags for both unit and unit2.  */
+	if (unit->plan != NULL
+	    && !unit->plan->supply_is_low
+	    && past_halfway_point(unit)
+	    ) {
+	    unit->plan->supply_is_low = TRUE;
+	    update_unit_display(unit->side, unit, TRUE);
+	}
+	if (unit2->plan != NULL
+	    && unit2->plan->supply_is_low
+	    && !past_halfway_point(unit2)
+	    ) {
+	    unit2->plan->supply_is_low = FALSE;
+	    update_unit_display(unit2->side, unit2, TRUE);
+	}
+    }
+
     return didsome;
 }
 
@@ -2898,6 +2918,25 @@
 	    }
 	}
     }
+
+    if (neededsome) {
+	/* Recompute the supply_is_low flags for both unit and unit2.  */
+	if (unit2->plan != NULL
+	    && !unit2->plan->supply_is_low
+	    && past_halfway_point(unit2)
+	    ) {
+	    unit2->plan->supply_is_low = TRUE;
+	    update_unit_display(unit2->side, unit2, TRUE);
+	}
+	if (unit->plan != NULL
+	    && unit->plan->supply_is_low
+	    && !past_halfway_point(unit)
+	    ) {
+	    unit->plan->supply_is_low = FALSE;
+	    update_unit_display(unit->side, unit, TRUE);
+	}
+    }
+
     return neededsome;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]