/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
* Known contributors to this file:
* Ken Stevens, 1995
* Steve McClure, 1996-2000
- * Markus Armbruster, 2006-2014
+ * Markus Armbruster, 2006-2015
*/
#include <config.h>
putship(com->shp_uid, &ship);
}
com->mobcost = 0;
+ /*
+ * FIXME if we just sank the ship, att_get_combat() will report
+ * "not in the same sector", and proceed to clobber *com. See
+ * also the workaround in boar().
+ */
att_get_combat(com, com->own != player->cnum);
}
}
/*
- * Return path cost for ATTACKER to enter sector given by DEF.
- * MOBTYPE is a mobility type accepted by sector_mcost().
+ * Return path cost for @attacker to enter sector given by @def.
+ * @mobtype is a mobility type accepted by sector_mcost().
*/
static double
att_mobcost(natid attacker, struct combat *def, int mobtype)
case EF_SHIP:
/* the 2 in the formula below is a fudge factor */
getship(def->shp_uid, &ship);
- off->mobcost += (def->eff / 100) * (shp_speed(&ship) / 2);
+ off->mobcost += shp_speed(&ship) / 2 * def->eff / 100;
}
}
}
llp->eff = llp->unit.land.lnd_effic;
if (lnd_spyval(&land) > *a_spyp)
*a_spyp = lnd_spyval(&land);
- if (((struct lchrstr *)llp->chrp)->l_flags & L_ENGINEER)
+ if (lchr[land.lnd_type].l_flags & L_ENGINEER)
++*a_engineerp;
if (def->type == EF_SHIP && ++count >= maxland)
break;
ap = dam / 100.0;
osupport += ap;
}
- sprintf(outs, "attacker\t%1.2f\t%1.2f\t%1.2f\t%1.2f\n", af, as, au,
- ap);
+ sprintf(outs, "attacker\t%1.2f\t%1.2f\t%1.2f\t%1.2f", af, as, au, ap);
return osupport;
}
if (good)
*outs = '\0';
else
- sprintf(outs, "defender\t%1.2f\t%1.2f\t%1.2f\t%1.2f\n\n", df, ds,
- du, dp);
+ sprintf(outs, "defender\t%1.2f\t%1.2f\t%1.2f\t%1.2f",
+ df, ds, du, dp);
if (def->own) {
if (good < 0)
wu(0, def->own,
pr("\n\t\tsupport values\n");
pr("\t\tforts\tships\tunits\tplanes\n");
if (*osupportp != 1.0)
- pr("%s", osupports);
+ pr("%s\n", osupports);
if (*dsupportp != 1.0)
- pr("%s", dsupports);
+ pr("%s\n", dsupports);
+ pr("\n");
if (def->own) {
wu(0, def->own, "\n\t\tsupport values\n");
wu(0, def->own, "\t\tforts\tships\tunits\tplanes\n");
if (*osupportp != 1.0)
- wu(0, def->own, "%s", osupports);
+ wu(0, def->own, "%s\n", osupports);
if (*dsupportp != 1.0)
- wu(0, def->own, "%s", dsupports);
+ wu(0, def->own, "%s\n", dsupports);
+ wu(0, def->own, "\n");
}
}
* Set mobcost to basic assault cost, moblim to maximum
* mobility to keep when assaulting from non-landing ship
*/
- if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE) {
+ if (lchr[llp->unit.land.lnd_type].l_flags & L_MARINE) {
mobcost = gain / 2.0;
moblim = 0;
} else {
mobcost = MAX(mobcost, mob - moblim);
break;
case A_BOARD:
- if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE)
+ if (lchr[llp->unit.land.lnd_type].l_flags & L_MARINE)
mobcost = 10;
else
mobcost = 40;