Fix weapon replacement logic (didn't check STAT_TRAVELLING inventory).
This commit is contained in:
parent
bb51a77ad6
commit
5afc381e42
2 changed files with 20 additions and 4 deletions
|
|
@ -1,3 +1,3 @@
|
|||
[default]
|
||||
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r351 \cu(Fri 12 Mar 20:08:40 CET 2021)\c-";
|
||||
SWWM_SHORTVER="\cw0.9.11b-pre r351 \cu(2021-03-12 20:08:40)\c-";
|
||||
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r352 \cu(Fri 12 Mar 21:36:08 CET 2021)\c-";
|
||||
SWWM_SHORTVER="\cw0.9.11b-pre r352 \cu(2021-03-12 21:36:08)\c-";
|
||||
|
|
|
|||
|
|
@ -1658,7 +1658,7 @@ Class SWWMUtility
|
|||
int np = 0;
|
||||
for ( int i=0; i<MAXPLAYERS; i++ )
|
||||
{
|
||||
if ( !playeringame[i] || !players[i].mo ) continue;
|
||||
if ( !playeringame[i] ) continue;
|
||||
np++;
|
||||
}
|
||||
int required = np;
|
||||
|
|
@ -1671,13 +1671,22 @@ Class SWWMUtility
|
|||
if ( multi ) required -= i.Amount;
|
||||
else required--;
|
||||
}
|
||||
// check travelling inventory separately, as by default iterators don't check anything below STAT_FIRST_THINKING
|
||||
ti = ThinkerIterator.Create(itm,Thinker.STAT_TRAVELLING);
|
||||
while ( i = Inventory(ti.Next()) )
|
||||
{
|
||||
if ( multi ) required -= i.Amount;
|
||||
else required--;
|
||||
}
|
||||
return (required>0);
|
||||
}
|
||||
|
||||
// checks if instances of a certain item exist
|
||||
// skipme: optionally, ignore checking for one specific instance
|
||||
// (useful to check if we're the only copy of an item)
|
||||
static bool ItemExists( Class<Inventory> itm, Inventory skipme = null )
|
||||
// mapstart: this function is being called during map load, so we
|
||||
// should also check STAT_TRAVELLING inventory
|
||||
static bool ItemExists( Class<Inventory> itm, Inventory skipme = null, bool mapstart = false )
|
||||
{
|
||||
let ti = ThinkerIterator.Create(itm);
|
||||
Inventory i;
|
||||
|
|
@ -1686,6 +1695,13 @@ Class SWWMUtility
|
|||
if ( i == skipme ) continue;
|
||||
return true;
|
||||
}
|
||||
if ( !mapstart ) return false;
|
||||
ti = ThinkerIterator.Create(itm,Thinker.STAT_TRAVELLING);
|
||||
while ( i = Inventory(ti.Next()) )
|
||||
{
|
||||
if ( i == skipme ) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue