(tran_nuke, tran_plane, set, sell, move): Use military_control().

(tran_plane): Fix message for attempting to transport a plane in a
sector not owned by the player.
This commit is contained in:
Markus Armbruster 2004-08-19 18:12:28 +00:00
parent 766538bc2f
commit ef0060ec57
4 changed files with 17 additions and 79 deletions

View file

@ -95,15 +95,7 @@ move(void)
* goodies in occupied territory. * goodies in occupied territory.
*/ */
if (!istest && sect.sct_oldown != player->cnum && vtype != I_MILIT) { if (!istest && sect.sct_oldown != player->cnum && vtype != I_MILIT) {
int tot_mil = 0; if (!military_control(&sect)) {
struct nstr_item ni;
struct lndstr land;
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
while (nxtitem(&ni, (s_char *)&land)) {
if (land.lnd_own == player->cnum)
tot_mil += total_mil(&land);
}
if ((sect.sct_item[I_MILIT] + tot_mil) * 10 < sect.sct_item[I_CIVIL]) {
pr("Military control required to move goods.\n"); pr("Military control required to move goods.\n");
return RET_FAIL; return RET_FAIL;
} }

View file

@ -128,25 +128,9 @@ sell(void)
if (price > 1000.0) /* Inf can cause overflow */ if (price > 1000.0) /* Inf can cause overflow */
price = 1000.0; /* bailey@math-cs.kent.edu */ price = 1000.0; /* bailey@math-cs.kent.edu */
totalcom = 0; totalcom = 0;
/* if (!military_control(&sect)) {
* military control necessary to sell pr("Military control required to sell goods.\n");
* goodies in occupied territory. return RET_FAIL;
*/
if (sect.sct_oldown != player->cnum) {
int tot_mil = 0;
struct nstr_item ni;
struct lndstr land;
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
while (nxtitem(&ni, (s_char *)&land)) {
if (land.lnd_own == player->cnum)
tot_mil += total_mil(&land);
}
if (((tot_mil + sect.sct_item[I_MILIT]) * 10)
< sect.sct_item[I_CIVIL]) {
pr("Military control required to sell goods.\n");
return RET_FAIL;
}
} }
if ((amt = sect.sct_item[ip->i_vtype]) == 0) { if ((amt = sect.sct_item[ip->i_vtype]) == 0) {
pr("You don't have any %s to sell there.\n", ip->i_name); pr("You don't have any %s to sell there.\n", ip->i_name);

View file

@ -96,24 +96,9 @@ set(void)
if (!player->owner && !player->god) if (!player->owner && !player->god)
continue; continue;
getsect(item.gen.trg_x, item.gen.trg_y, &sect); getsect(item.gen.trg_x, item.gen.trg_y, &sect);
/* if (!military_control(&sect)) {
* military control necessary to sell pr("Military control required to sell goods.\n");
* goodies in occupied territory. return RET_FAIL;
*/
if (sect.sct_oldown != player->cnum && !player->god) {
int tot_mil = 0;
struct nstr_item ni;
struct lndstr land;
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
while (nxtitem(&ni, (s_char *)&land)) {
if (land.lnd_own == player->cnum)
tot_mil += total_mil(&land);
}
if (tot_mil + sect.sct_item[I_MILIT] * 10
< sect.sct_item[I_CIVIL]) {
pr("Military control required to sell goods.\n");
return RET_FAIL;
}
} }
trade.trd_type = type; trade.trd_type = type;
sprintf(prompt, "%s #%d; Price? ", sprintf(prompt, "%s #%d; Price? ",

View file

@ -153,23 +153,9 @@ tran_nuke(void)
else else
return RET_FAIL; return RET_FAIL;
} }
/* if (!military_control(&sect)) {
* military control necessary to move pr("Military control required to move nukes.\n");
* goodies in occupied territory. return RET_FAIL;
*/
if (sect.sct_oldown != player->cnum) {
int tot_mil = 0;
struct nstr_item ni;
struct lndstr land;
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
while (nxtitem(&ni, (s_char *)&land)) {
if (land.lnd_own == player->cnum)
tot_mil += total_mil(&land);
}
if ((sect.sct_item[I_MILIT] + tot_mil) * 10 < sect.sct_item[I_CIVIL]) {
pr("Military control required to move goods.\n");
return RET_FAIL;
}
} }
dam = 0; dam = 0;
mcost = move_ground((s_char *)&nuke, &sect, &endsect, mcost = move_ground((s_char *)&nuke, &sect, &endsect,
@ -269,22 +255,13 @@ tran_plane(void)
/* no planes */ /* no planes */
return RET_FAIL; return RET_FAIL;
} }
getsect(srcx, srcy, &sect); if (!getsect(srcx, srcy, &sect) || !player->owner) {
/* pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
* military control necessary to move return RET_FAIL;
* goodies in occupied territory. }
*/ if (!military_control(&sect)) {
if (sect.sct_oldown != player->cnum) { pr("Military control required to move planes.\n");
int tot_mil = 0; return RET_FAIL;
struct nstr_item ni;
struct lndstr land;
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
while (nxtitem(&ni, (s_char *)&land))
tot_mil += total_mil(&land);
if ((sect.sct_item[I_MILIT] + tot_mil) * 10 < sect.sct_item[I_CIVIL]) {
pr("Military control required to move goods.\n");
return RET_FAIL;
}
} }
dam = 1; dam = 1;
mcost = move_ground((s_char *)&plane, &sect, &endsect, mcost = move_ground((s_char *)&plane, &sect, &endsect,