Fix lmine for engineers that don't use ammo
landmine() used resupply_commod() to get shells, but that doesn't get any unless the engineer uses ammo. Use supply_commod() instead.
This commit is contained in:
parent
bc2989a3b3
commit
fbaef4794e
1 changed files with 14 additions and 16 deletions
|
@ -93,9 +93,8 @@ landmine(void)
|
||||||
{
|
{
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
struct lchrstr *lp;
|
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
int shells;
|
int shells, todo;
|
||||||
int mines_wanted;
|
int mines_wanted;
|
||||||
int mines_laid;
|
int mines_laid;
|
||||||
int total_mines_laid;
|
int total_mines_laid;
|
||||||
|
@ -106,8 +105,7 @@ landmine(void)
|
||||||
while (nxtitem(&ni, &land)) {
|
while (nxtitem(&ni, &land)) {
|
||||||
if (!player->owner)
|
if (!player->owner)
|
||||||
continue;
|
continue;
|
||||||
lp = &lchr[(int)land.lnd_type];
|
if (!(lchr[land.lnd_type].l_flags & L_ENGINEER))
|
||||||
if (!(lp->l_flags & L_ENGINEER))
|
|
||||||
continue;
|
continue;
|
||||||
if (land.lnd_ship >= 0 || land.lnd_land >= 0) {
|
if (land.lnd_ship >= 0 || land.lnd_land >= 0) {
|
||||||
pr("%s is on a %s\n", prland(&land),
|
pr("%s is on a %s\n", prland(&land),
|
||||||
|
@ -118,11 +116,6 @@ landmine(void)
|
||||||
pr("%s is out of mobility\n", prland(&land));
|
pr("%s is out of mobility\n", prland(&land));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
resupply_commod(&land, I_SHELL);
|
|
||||||
putland(land.lnd_uid, &land);
|
|
||||||
if (!(shells = land.lnd_item[I_SHELL]))
|
|
||||||
continue;
|
|
||||||
shells = MIN(shells, land.lnd_mobil);
|
|
||||||
if (!getsect(land.lnd_x, land.lnd_y, §)
|
if (!getsect(land.lnd_x, land.lnd_y, §)
|
||||||
|| sect.sct_type == SCT_WATER || sect.sct_type == SCT_BSPAN
|
|| sect.sct_type == SCT_WATER || sect.sct_type == SCT_BSPAN
|
||||||
|| sect.sct_own != land.lnd_own) {
|
|| sect.sct_own != land.lnd_own) {
|
||||||
|
@ -141,18 +134,23 @@ landmine(void)
|
||||||
if (!check_land_ok(&land) || !check_sect_ok(§))
|
if (!check_land_ok(&land) || !check_sect_ok(§))
|
||||||
continue;
|
continue;
|
||||||
land.lnd_mission = 0;
|
land.lnd_mission = 0;
|
||||||
|
todo = MIN(mines_wanted, land.lnd_mobil);
|
||||||
total_mines_laid = 0;
|
total_mines_laid = 0;
|
||||||
while (shells > 0 && total_mines_laid < mines_wanted) {
|
do {
|
||||||
mines_laid = MIN(shells, mines_wanted - total_mines_laid);
|
shells = land.lnd_item[I_SHELL];
|
||||||
|
if (shells < todo)
|
||||||
|
shells += supply_commod(land.lnd_own,
|
||||||
|
land.lnd_x, land.lnd_y, I_SHELL,
|
||||||
|
todo - shells);
|
||||||
|
mines_laid = MIN(todo, shells);
|
||||||
land.lnd_item[I_SHELL] = shells - mines_laid;
|
land.lnd_item[I_SHELL] = shells - mines_laid;
|
||||||
land.lnd_mobil -= mines_laid;
|
land.lnd_mobil -= mines_laid;
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
resupply_commod(&land, I_SHELL); /* Get more shells */
|
|
||||||
putland(land.lnd_uid, &land);
|
|
||||||
total_mines_laid += mines_laid;
|
total_mines_laid += mines_laid;
|
||||||
shells = land.lnd_item[I_SHELL];
|
todo -= mines_laid;
|
||||||
shells = MIN(shells, land.lnd_mobil);
|
} while (todo && mines_laid);
|
||||||
}
|
resupply_commod(&land, I_SHELL);
|
||||||
|
putland(land.lnd_uid, &land);
|
||||||
getsect(sect.sct_x, sect.sct_y, §);
|
getsect(sect.sct_x, sect.sct_y, §);
|
||||||
sect.sct_mines = MIN(sect.sct_mines + total_mines_laid, MINES_MAX);
|
sect.sct_mines = MIN(sect.sct_mines + total_mines_laid, MINES_MAX);
|
||||||
putsect(§);
|
putsect(§);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue