/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
+ * Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Ken Stevens, Steve McClure, Markus Armbruster
*
- * This program is free software; you can redistribute it and/or modify
+ * Empire is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ---
*
* Known contributors to this file:
* Dave Pare, 1986
* Steve McClure, 1996
+ * Markus Armbruster, 2004-2013
*/
#include <config.h>
#include "budg.h"
+#include "chance.h"
#include "item.h"
#include "land.h"
#include "lost.h"
#include "path.h"
#include "player.h"
-#include "product.h"
#include "ship.h"
#include "update.h"
}
neweff = n;
*cost += work_cost;
- if (!n && IS_BIG_CITY(old_type) &&
- !IS_BIG_CITY(*desig)) {
+ if (!n && IS_BIG_CITY(old_type) && !IS_BIG_CITY(*desig)) {
// FIXME use trunc_people() and total_work()
int maxpop = max_population(np->nat_level[NAT_RLEV], *desig, n);
if (vec[I_CIVIL] > maxpop)
int maxmil;
int enlisted;
- /* Need to check treaties here */
enlisted = 0;
maxmil = vec[I_CIVIL] / 2 - vec[I_MILIT];
if (maxmil > 0) {
/* Fallout is calculated here. */
static void
-meltitems(int etus, int fallout, int own, short *vec, int type, int x, int y,
- int uid)
+meltitems(int etus, int fallout, int own, short *vec,
+ int type, int x, int y, int uid)
{
i_type n;
int melt;
for (n = I_NONE + 1; n <= I_MAX; n++) {
- melt = roundavg(vec[n] * etus * (long)fallout
+ melt = roundavg(vec[n] * etus * (double)fallout
/ (1000.0 * ichr[n].i_melt_denom));
if (melt > vec[n])
melt = vec[n];
return;
if (etus > 24)
etus = 24;
- meltitems(etus, sp->sct_fallout, sp->sct_own, sp->sct_item, EF_SECTOR,
- sp->sct_x, sp->sct_y, 0);
+ meltitems(etus, sp->sct_fallout, sp->sct_own, sp->sct_item,
+ EF_SECTOR, sp->sct_x, sp->sct_y, 0);
for (i = 0; NULL != (lp = getlandp(i)); i++) {
if (!lp->lnd_own)
continue;
if (lp->lnd_x != sp->sct_x || lp->lnd_y != sp->sct_y)
continue;
- meltitems(etus, sp->sct_fallout, lp->lnd_own, lp->lnd_item, EF_LAND,
- lp->lnd_x, lp->lnd_y, lp->lnd_uid);
+ meltitems(etus, sp->sct_fallout, lp->lnd_own, lp->lnd_item,
+ EF_LAND, lp->lnd_x, lp->lnd_y, lp->lnd_uid);
}
for (i = 0; NULL != (spp = getshipp(i)); i++) {
if (!spp->shp_own)
continue;
if (mchr[(int)spp->shp_type].m_flags & M_SUB)
continue;
- meltitems(etus, sp->sct_fallout, spp->shp_own, spp->shp_item, EF_SHIP,
- spp->shp_x, spp->shp_y, spp->shp_uid);
+ meltitems(etus, sp->sct_fallout, spp->shp_own, spp->shp_item,
+ EF_SHIP, spp->shp_x, spp->shp_y, spp->shp_uid);
}
}
* Produce for a specific nation
*/
void
-produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
+produce_sect(int natnum, int etu, struct bp *bp, int p_sect[][2])
{
struct sctstr *sp;
struct natstr *np;
np = getnatp(natnum);
- if (sp->sct_type == SCT_CAPIT && sp->sct_effic >= 60) {
- p_sect[SCT_CAPIT][0]++;
- p_sect[SCT_CAPIT][1] += etu;
- if (!player->simulation)
- np->nat_money -= etu;
- }
-
if (player->simulation) {
/* work on a copy, which will be discarded */
memcpy(buf, sp->sct_item, sizeof(buf));
* they all starved or were plagued off.
*/
if (vec[I_CIVIL] == 0 && vec[I_MILIT] == 0 &&
- !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) {
+ !has_units(sp->sct_x, sp->sct_y, sp->sct_own, NULL)) {
if (!player->simulation) {
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
sp->sct_own = 0;
sp->sct_updated = 1;
work = 0;
- /* do_feed trys to supply. So, we need to enable cacheing
- here */
- bp_enable_cachepath();
-
sctwork = do_feed(sp, np, vec, &work, etu);
bp_put_items(bp, sp, vec);
- bp_disable_cachepath();
- bp_clear_cachepath();
-
if (sp->sct_off || np->nat_money < 0)
continue;
desig = sp->sct_type;
+ if (dchr[desig].d_maint) {
+ cost = etu * dchr[desig].d_maint;
+ p_sect[SCT_MAINT][0]++;
+ p_sect[SCT_MAINT][1] += cost;
+ if (!player->simulation)
+ np->nat_money -= cost;
+ }
+
if ((sp->sct_effic < 100 || sp->sct_type != sp->sct_newtype) &&
np->nat_money >= 0) {
neweff = upd_buildeff(np, sp, &work, vec, etu, &desig, sctwork,