(upd_ship, upd_land): Simplify. No functional changes.

This commit is contained in:
Markus Armbruster 2004-03-11 13:31:28 +00:00
parent c7d3a8ffa8
commit 0652930d67
2 changed files with 29 additions and 36 deletions

View file

@ -147,8 +147,8 @@ upd_land(register struct lndstr *lp, register int etus,
mult *= 3; mult *= 3;
/* cost = -(mult * etus * dmin(0.0, money_land * LND_COST(lcp->l_cost, lp->lnd_tech - lcp->l_tech)));*/ /* cost = -(mult * etus * dmin(0.0, money_land * LND_COST(lcp->l_cost, lp->lnd_tech - lcp->l_tech)));*/
cost = -(mult * etus * dmin(0.0, money_land * lcp->l_cost)); cost = -(mult * etus * dmin(0.0, money_land * lcp->l_cost));
if ((np->nat_priorities[PRI_LMAINT] == 0 || if ((np->nat_priorities[PRI_LMAINT] == 0 || np->nat_money < cost)
np->nat_money < cost) && !player->simulation) { && !player->simulation) {
if ((eff = lp->lnd_effic - etus / 5) < LAND_MINEFF) { if ((eff = lp->lnd_effic - etus / 5) < LAND_MINEFF) {
wu(0, lp->lnd_own, wu(0, lp->lnd_own,
"%s lost to lack of maintenance\n", prland(lp)); "%s lost to lack of maintenance\n", prland(lp));
@ -164,15 +164,13 @@ upd_land(register struct lndstr *lp, register int etus,
} else { } else {
np->nat_money -= cost; np->nat_money -= cost;
} }
/* Mil costs are now part of regular mil costs, not maint costs */
/* np->nat_money += (int) (money_mil * etus * lnd_getmil(lp));*/
/* Grab more stuff */ /* Grab more stuff */
if ((opt_NOFOOD == 0) && !player->simulation) if ((opt_NOFOOD == 0) && !player->simulation)
resupply_commod(lp, I_FOOD); resupply_commod(lp, I_FOOD);
getvec(VT_ITEM, vec, (s_char *)lp, EF_LAND);
if (!player->simulation) { if (!player->simulation) {
getvec(VT_ITEM, vec, (s_char *)lp, EF_LAND);
if ((n = feed_land(lp, vec, etus, &needed, 1)) > 0) { if ((n = feed_land(lp, vec, etus, &needed, 1)) > 0) {
wu(0, lp->lnd_own, "%d starved in %s%s\n", wu(0, lp->lnd_own, "%d starved in %s%s\n",
n, prland(lp), n, prland(lp),

View file

@ -144,8 +144,8 @@ upd_ship(register struct shpstr *sp, register int etus,
if (np->nat_level[NAT_TLEV] < sp->shp_tech * 0.85) if (np->nat_level[NAT_TLEV] < sp->shp_tech * 0.85)
mult = 2; mult = 2;
cost = -(mult * etus * dmin(0.0, money_ship * mp->m_cost)); cost = -(mult * etus * dmin(0.0, money_ship * mp->m_cost));
if ((np->nat_priorities[PRI_SMAINT] == 0 || if ((np->nat_priorities[PRI_SMAINT] == 0 || np->nat_money < cost)
np->nat_money < cost) && !player->simulation) { && !player->simulation) {
if ((eff = sp->shp_effic - etus / 5) < SHIP_MINEFF) { if ((eff = sp->shp_effic - etus / 5) < SHIP_MINEFF) {
wu(0, sp->shp_own, wu(0, sp->shp_own,
"%s lost to lack of maintenance\n", prship(sp)); "%s lost to lack of maintenance\n", prship(sp));
@ -162,36 +162,31 @@ upd_ship(register struct shpstr *sp, register int etus,
np->nat_money -= cost; np->nat_money -= cost;
} }
getvec(VT_ITEM, vec, (s_char *)sp, EF_SHIP);
sectp = getsectp(sp->shp_x, sp->shp_y);
if (((mp->m_flags & M_OIL) && (sectp->sct_type == SCT_WATER))
&& !player->simulation) {
/*
* take care of oil production
*/
oil_gained = roundavg((vec[I_CIVIL] * etus / 10000.0)
* sectp->sct_oil);
vec[I_OIL] += oil_gained;
max_oil = vl_find(V_OIL, mp->m_vtype, mp->m_vamt, mp->m_nv);
if (vec[I_OIL] > max_oil)
vec[I_OIL] = max_oil;
product = &pchr[P_OIL];
if (product->p_nrdep != 0 && oil_gained > 0) {
resource = ((s_char *)sectp) + product->p_nrndx;
*resource -= roundavg(oil_gained *
product->p_nrdep / 100.0);
}
}
if (((mp->m_flags & M_FOOD) && (sectp->sct_type == SCT_WATER))
&& !player->simulation) {
sectp = getsectp(sp->shp_x, sp->shp_y);
vec[I_FOOD] += ((vec[I_CIVIL] * etus) / 1000.0)
* sectp->sct_fertil;
}
/* Military costs are now part of regular military costs, not ship costs */
/* np->nat_money += (int) (etus * vec[I_MILIT] * money_mil);*/
if (!player->simulation) { if (!player->simulation) {
getvec(VT_ITEM, vec, (s_char *)sp, EF_SHIP);
sectp = getsectp(sp->shp_x, sp->shp_y);
if ((mp->m_flags & M_OIL) && sectp->sct_type == SCT_WATER) {
/*
* take care of oil production
*/
oil_gained = roundavg((vec[I_CIVIL] * etus / 10000.0)
* sectp->sct_oil);
vec[I_OIL] += oil_gained;
max_oil = vl_find(V_OIL, mp->m_vtype, mp->m_vamt, mp->m_nv);
if (vec[I_OIL] > max_oil)
vec[I_OIL] = max_oil;
product = &pchr[P_OIL];
if (product->p_nrdep != 0 && oil_gained > 0) {
resource = ((s_char *)sectp) + product->p_nrndx;
*resource -= roundavg(oil_gained *
product->p_nrdep / 100.0);
}
}
if ((mp->m_flags & M_FOOD) && sectp->sct_type == SCT_WATER) {
vec[I_FOOD] += ((vec[I_CIVIL] * etus) / 1000.0)
* sectp->sct_fertil;
}
if ((n = feed_ship(sp, vec, etus, &needed, 1)) > 0) { if ((n = feed_ship(sp, vec, etus, &needed, 1)) > 0) {
wu(0, sp->shp_own, "%d starved on %s\n", n, prship(sp)); wu(0, sp->shp_own, "%d starved on %s\n", n, prship(sp));
if (n > 10) if (n > 10)