/*
* 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
* Known contributors to this file:
* Ken Stevens, 1995
* Steve McClure, 1996-2000
- * Markus Armbruster, 2006-2008
+ * Markus Armbruster, 2006-2009
*/
#include <config.h>
if ((com->mob - com->mobcost) < -127)
sect.sct_mobil = -127;
else
- sect.sct_mobil = (short)(com->mob - com->mobcost);
+ sect.sct_mobil = com->mob - com->mobcost;
} else {
if ((com->mob - com->mobcost) < 0)
sect.sct_mobil = 0;
else
- sect.sct_mobil = (short)(com->mob - com->mobcost);
+ sect.sct_mobil = com->mob - com->mobcost;
}
}
sect.sct_own = com->own;
*fortp = *shipp = 0;
*landp = *planep = 0;
- if (!(p = getstarg(player->argp[offset], "Use fort support? ",
- buf)))
+ p = getstarg(player->argp[offset], "Use fort support? ", buf);
+ if (!p)
return RET_SYN;
if ((*p == 'y') || (*p == 'Y'))
*fortp = 1;
- if (!(p = getstarg(player->argp[offset + 1], "Use ship support? ",
- buf)))
+ p = getstarg(player->argp[offset + 1], "Use ship support? ", buf);
+ if (!p)
return RET_SYN;
if ((*p == 'y') || (*p == 'Y'))
*shipp = 1;
- if (!(p = getstarg(player->argp[offset + 2], "Use land support? ",
- buf)))
+ p = getstarg(player->argp[offset + 2], "Use land support? ", buf);
+ if (!p)
return RET_SYN;
if ((*p == 'y') || (*p == 'Y'))
*landp = 1;
- if (!(p = getstarg(player->argp[offset + 3], "Use plane support? ",
- buf)))
+ p = getstarg(player->argp[offset + 3], "Use plane support? ", buf);
+ if (!p)
return RET_SYN;
if ((*p == 'y') || (*p == 'Y'))
sprintf(prompt, "Number of mil from %s (max %d) : ",
prcom(0, off), mob_support);
}
- if ((attacking_mil = onearg(0, prompt)) < 0)
+ if ((attacking_mil = onearg(NULL, prompt)) < 0)
abort_attack();
if (att_abort(combat_mode, off, def))
return 0;
{
struct nstr_item ni;
struct lndstr land;
- double mobcost;
+ double pathcost, mobcost;
+ int reqmob;
struct ulist *llp;
struct lchrstr *lcp;
double att_val;
* of high-mobility sectors (mountains): for those we
* still require attack mobility.
*/
- mobcost = att_mobcost(off->own, def, lnd_mobtype(&land));
- if (mobcost < 1.0) {
+ pathcost = att_mobcost(off->own, def, lnd_mobtype(&land));
+ mobcost = lnd_pathcost(&land, pathcost);
+ if (pathcost < 1.0) {
if (land.lnd_mobil <= 0) {
pr("%s is out of mobility\n", prland(&land));
continue;
}
} else {
- mobcost = lnd_pathcost(&land, mobcost);
- if (land.lnd_mobil < mobcost) {
+ reqmob = MIN(land_mob_max, (int)ceil(mobcost));
+ if (land.lnd_mobil < reqmob) {
pr("%s does not have enough mobility (%d needed)\n",
- prland(&land), (int)ceil(mobcost));
+ prland(&land), reqmob);
continue;
}
}
pr("%s has no offensive strength\n", prland(&land));
continue;
}
- resupply_all(&land);
- putland(land.lnd_uid, &land);
- if (!has_supply(&land)) {
+ if (!lnd_supply_all(&land)) {
pr("%s is out of supply, and cannot %s\n",
prland(&land), att_mode[combat_mode]);
continue;
}
memset(llp, 0, sizeof(struct ulist));
emp_insque(&llp->queue, list);
- llp->supplied = has_supply(&land);
+ llp->supplied = lnd_supply_all(&land);
if (!get_land(A_DEFEND, def, land.lnd_uid, llp, 1))
continue;
if (lnd_spyval(&land) > *d_spyp)
for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw;
llp = (struct ulist *)qp;
- if (check && !get_land(combat_mode, 0, llp->unit.land.lnd_uid, llp, 0))
+ if (check &&
+ !get_land(combat_mode, NULL, llp->unit.land.lnd_uid, llp, 0))
continue;
if (combat_mode == A_ATTACK) {
w = -1;
emp_remque((struct emp_qelem *)llp);
free(llp);
} else
- get_land(A_ATTACK, 0, llp->unit.land.lnd_uid, llp, 0);
+ get_land(A_ATTACK, NULL, llp->unit.land.lnd_uid, llp, 0);
}
}
continue;
/* Only supplied units can react */
- if (!has_supply(&land))
+ if (list ? !lnd_supply_all(&land) : !lnd_could_be_supplied(&land))
continue;
if (!in_oparea((struct empobj *)&land, def->x, def->y))
getsect(def->x, def->y, §);
if (sect.sct_oldown != player->cnum) {
- mines = MIN(sect.sct_mines, 20);
+ mines = SCT_LANDMINES(§);
+ mines = MIN(mines, 20);
if (a_engineer)
mines = ldround(mines / 2.0, 1);
if (mines > 0) {
{
int n;
int occuppied = 0;
- struct ulist *llp, *delete_me = 0;
+ struct ulist *llp, *delete_me = NULL;
char buf[1024];
struct sctstr sect;
struct shpstr ship;
*answerp = 'N';
if (*answerp == 'Y')
continue;
+ if (!get_land(A_ATTACK, def, llp->unit.land.lnd_uid, llp, 0))
+ continue;
if (*answerp != 'N') {
- if (!get_land(A_ATTACK, def, llp->unit.land.lnd_uid, llp, 0))
- continue;
sprintf(prompt, "Move in with %s (%c %d%%) [ynYNq?] ",
prland(&llp->unit.land),
llp->unit.land.lnd_army ? llp->unit.land.lnd_army : '~',
return;
sprintf(prompt, "How many mil to move in from %s (%d max)? ",
xyas(off->x, off->y, player->cnum), mob_support);
- if (!(p = getstring(prompt, buf)) || !*p || (num_mil = atoi(p)) <= 0)
+ p = getstring(prompt, buf);
+ if (!p || !*p || (num_mil = atoi(p)) <= 0)
return;
/* Make sure we don't move in more than we can support mobility-wise */
if (num_mil > mob_support)