/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
+ * Copyright (C) 1986-2016, 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/>.
*
* ---
*
* Dave Pare, 1986
* Steve McClure, 1996
* Ron Koenderink, 2004
- * Markus Armbruster, 2006-2009
+ * Markus Armbruster, 2006-2011
*/
#include <config.h>
#include <math.h>
#include "budg.h"
+#include "chance.h"
#include "land.h"
#include "lost.h"
#include "news.h"
np = getnatp(sp->shp_own);
start_money = np->nat_money;
upd_ship(sp, etus, np, bp, build);
- if (build && !player->simulation) /* make sure to only autonav once */
- nav_ship(sp); /* autonav the ship */
sea_money[sp->shp_own] += np->nat_money - start_money;
if (!build || np->nat_money != start_money)
k++;
np->nat_money = start_money;
}
- if (opt_SAIL) {
- if (build && !player->simulation) /* make sure to only sail once */
- sail_ship(natnum);
- }
return k;
}
struct pchrstr *product;
unsigned char *resource;
int dep;
- int n;
- int mult;
- int cost;
- int eff;
+ int n, mult, cost, eff_lost;
mp = &mchr[(int)sp->shp_type];
if (build == 1) {
mult = 2;
cost = -(mult * etus * MIN(0.0, money_ship * mp->m_cost));
if (np->nat_money < cost && !player->simulation) {
- if ((eff = sp->shp_effic - etus / 5) < SHIP_MINEFF) {
- wu(0, sp->shp_own,
- "%s lost to lack of maintenance\n", prship(sp));
- makelost(EF_SHIP, sp->shp_own, sp->shp_uid,
- sp->shp_x, sp->shp_y);
- sp->shp_own = 0;
- return;
+ eff_lost = etus / 5;
+ if (sp->shp_effic - eff_lost < SHIP_MINEFF)
+ eff_lost = sp->shp_effic - SHIP_MINEFF;
+ if (eff_lost > 0) {
+ wu(0, sp->shp_own, "%s lost %d%% to lack of maintenance\n",
+ prship(sp), eff_lost);
+ sp->shp_effic -= eff_lost;
}
- wu(0, sp->shp_own,
- "%s lost %d%% to lack of maintenance\n",
- prship(sp), sp->shp_effic - eff);
- sp->shp_effic = eff;
} else {
np->nat_money -= cost;
}
product = &pchr[dchr[SCT_OIL].d_prd];
oil_gained = roundavg(total_work(100, etus,
sp->shp_item[I_CIVIL],
- sp->shp_item[I_MILIT],
+ sp->shp_item[I_MILIT],
sp->shp_item[I_UW],
ITEM_MAX)
* sp->shp_effic / 100.0
int w_p_eff;
int mult;
int mvec[I_MAX + 1];
- int rel;
mp = &mchr[(int)ship->shp_type];
sp = getsectp(ship->shp_x, ship->shp_y);
- if ((sp->sct_own != ship->shp_own) && (sp->sct_own != 0)) {
- rel = getrel(getnatp(sp->sct_own), ship->shp_own);
-
- if (rel < FRIENDLY)
- return;
- }
+ if (sp->sct_own != 0
+ && relations_with(sp->sct_own, ship->shp_own) < FRIENDLY)
+ return;
- wf = 0;
/* only military can work on a military boat */
if (mp->m_glim != 0)
wf = etus * ship->shp_item[I_MILIT] / 2;