/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* ---
*
* supply.c: Supply subroutines
- *
+ *
* Known contributors to this file:
- *
+ *
*/
#include <config.h>
/*
* We want to get enough guns to be maxed out, enough shells to
- * fire once, one update's worth of food.
+ * fire once, one update's worth of food.
*
* Firts, try to forage in the sector
* Second look for a warehouse or headquarters to leech
* Third, look for a ship we own in a harbor
* Fourth, look for supplies in a supply unit we own
- * (one good reason to do this last is that the supply
- * unit will then call resupply, taking more time)
+ * (one good reason to do this last is that the supply
+ * unit will then call resupply, taking more time)
*
* May want to put code to resupply with SAMs here, later --ts
*/
resupply_commod(struct lndstr *lp, i_type type)
{
int amt;
- struct shpstr ship;
- /* Ok, do we now have enough? */
amt = get_minimum(lp, type) - lp->lnd_item[type];
if (amt > 0) {
lp->lnd_item[type] += supply_commod(lp->lnd_own,
lp->lnd_x, lp->lnd_y,
type, amt);
- amt = get_minimum(lp, type) - lp->lnd_item[type];
- }
- /* Now, check again to see if we have enough. */
- if (amt > 0) {
- /* Are we on a ship? if so, try to get it from the ship first. */
- if (lp->lnd_ship >= 0) {
- getship(lp->lnd_ship, &ship);
- /* Now, determine how much we can get */
- if (amt > ship.shp_item[type])
- amt = ship.shp_item[type];
- /* Now, add and subtract */
- lp->lnd_item[type] += amt;
- ship.shp_item[type] -= amt;
- putship(lp->lnd_ship, &ship);
- }
}
}
save = land;
land.lnd_item[type] = 0;
putland(land.lnd_uid, &land);
+ save.lnd_seqno = land.lnd_seqno;
land.lnd_item[type] =
save.lnd_item[type] + s_commod(own, land.lnd_x, land.lnd_y,
if (can_move >= wanted) {
land.lnd_item[type] -= wanted;
-
- /* resupply the supply unit */
- resupply_commod(&land, type);
-
land.lnd_mobil -= roundavg(wanted * weight * move_cost);
if (actually_doit)