Fix rare case where chainsaw spawns before players exist.

This commit is contained in:
Mari the Deer 2022-09-24 02:11:07 +02:00
commit 6928249118
2 changed files with 12 additions and 3 deletions

View file

@ -2117,7 +2117,7 @@ Class SWWMUtility
int np = 0;
for ( int i=0; i<MAXPLAYERS; i++ )
{
if ( !playeringame[i] ) continue;
if ( !playeringame[i] || !players[i].mo ) continue;
np++;
}
int required = np;
@ -2182,6 +2182,15 @@ Class SWWMUtility
// melee weapon + extra slot 2 guns
static Class<Weapon> PickSWWMSlot1()
{
// [GROSS HACK] default to a hammer if there are no players
// (this genuinely can happen, if player starts were placed AFTER the item)
int np = 0;
for ( int i=0; i<MAXPLAYERS; i++ )
{
if ( !playeringame[i] || !players[i].mo ) continue;
np++;
}
if ( np <= 0 ) return 'ItamexHammer';
// so the player can recover it if they decided to drop it in a previous map, or they didn't start with it
if ( CheckNeedsItem('DeepImpact') ) return 'DeepImpact';
if ( CheckNeedsItem('ItamexHammer') ) return 'ItamexHammer';