From: Markus Armbruster Date: Thu, 19 Aug 2004 18:12:28 +0000 (+0000) Subject: (tran_nuke, tran_plane, set, sell, move): Use military_control(). X-Git-Tag: v4.2.18~70 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=ef0060ec57b6ceffc983d9ad362388512534bf54 (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. --- diff --git a/src/lib/commands/move.c b/src/lib/commands/move.c index 589e2f586..fec474d8b 100644 --- a/src/lib/commands/move.c +++ b/src/lib/commands/move.c @@ -95,15 +95,7 @@ move(void) * goodies in occupied territory. */ if (!istest && sect.sct_oldown != player->cnum && vtype != I_MILIT) { - 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]) { + if (!military_control(§)) { pr("Military control required to move goods.\n"); return RET_FAIL; } diff --git a/src/lib/commands/sell.c b/src/lib/commands/sell.c index 572e76faa..7024997de 100644 --- a/src/lib/commands/sell.c +++ b/src/lib/commands/sell.c @@ -128,25 +128,9 @@ sell(void) if (price > 1000.0) /* Inf can cause overflow */ price = 1000.0; /* bailey@math-cs.kent.edu */ totalcom = 0; - /* - * military control necessary to sell - * goodies in occupied territory. - */ - 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 (!military_control(§)) { + pr("Military control required to sell goods.\n"); + return RET_FAIL; } if ((amt = sect.sct_item[ip->i_vtype]) == 0) { pr("You don't have any %s to sell there.\n", ip->i_name); diff --git a/src/lib/commands/set.c b/src/lib/commands/set.c index 9375bc3aa..09660601d 100644 --- a/src/lib/commands/set.c +++ b/src/lib/commands/set.c @@ -96,24 +96,9 @@ set(void) if (!player->owner && !player->god) continue; getsect(item.gen.trg_x, item.gen.trg_y, §); - /* - * military control necessary to sell - * goodies in occupied territory. - */ - 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; - } + if (!military_control(§)) { + pr("Military control required to sell goods.\n"); + return RET_FAIL; } trade.trd_type = type; sprintf(prompt, "%s #%d; Price? ", diff --git a/src/lib/commands/tran.c b/src/lib/commands/tran.c index a1ba14fb8..f8b1ede26 100644 --- a/src/lib/commands/tran.c +++ b/src/lib/commands/tran.c @@ -153,23 +153,9 @@ tran_nuke(void) else return RET_FAIL; } - /* - * military control necessary to move - * goodies in occupied territory. - */ - 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; - } + if (!military_control(§)) { + pr("Military control required to move nukes.\n"); + return RET_FAIL; } dam = 0; mcost = move_ground((s_char *)&nuke, §, &endsect, @@ -269,22 +255,13 @@ tran_plane(void) /* no planes */ return RET_FAIL; } - getsect(srcx, srcy, §); - /* - * military control necessary to move - * goodies in occupied territory. - */ - 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)) - 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; - } + if (!getsect(srcx, srcy, §) || !player->owner) { + pr("You don't own %s\n", xyas(srcx, srcy, player->cnum)); + return RET_FAIL; + } + if (!military_control(§)) { + pr("Military control required to move planes.\n"); + return RET_FAIL; } dam = 1; mcost = move_ground((s_char *)&plane, §, &endsect,