Skip to content

Commit

Permalink
fixed infinite loop in PickEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinsplash committed Jul 18, 2023
1 parent 37b6aba commit 67a2f71
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5300,7 +5300,7 @@ int CHL2_Player::PickEffect(int iWeightSum, bool bTest)
}

//list of effects we've already checked availability for. false means unchecked, true means checked and unpickable.
//if an effect is found to be pickable, then we would instantly return it instead, not tracked in this list because it'd be pointless, though it could be useful to in the future.
//this does not track effects that are pickable but not chosen by the RNG, but in the future this should be done for optimization.
bool bEffectStatus[NUM_EFFECTS] = { true };//(Error) should never be picked
int iUnpickableAmt = 1;

Expand Down Expand Up @@ -5333,7 +5333,7 @@ int CHL2_Player::PickEffect(int iWeightSum, bool bTest)
if (bEffectStatus[i] == false)
{
bool bGoodActiveness = !EffectOrGroupAlreadyActive(candEffect->m_nID);
bool bGoodContext;
bool bGoodContext = false;
//check activeness and context
if (bGoodActiveness)
{
Expand All @@ -5358,8 +5358,11 @@ int CHL2_Player::PickEffect(int iWeightSum, bool bTest)
{
if (chaos_print_rng.GetBool()) Msg("Bad activeness for i %i %s\n", i, STRING(g_ChaosEffects[i]->m_strGeneralName), nRememberRandom);
}
iUnpickableAmt++;
bEffectStatus[i] = true;
if (!bGoodActiveness || !bGoodContext)
{
iUnpickableAmt++;
bEffectStatus[i] = true;
}
}
if (nRandom <= g_ChaosEffects[i]->m_iCurrentWeight)
{
Expand Down

0 comments on commit 67a2f71

Please sign in to comment.