levelsranks / levels-ranks-core

Statistics plugin for servers on the Source Engine
GNU General Public License v3.0
73 stars 39 forks source link

Wrong calculation in 'Native_ChangeClientValue()'. #54

Closed Natanel-Shitrit closed 3 years ago

Natanel-Shitrit commented 3 years ago

g_iPlayerInfo[iClient].iRoundExp += iExpChange = iOldExp - g_iPlayerInfo[iClient].iStats[ST_EXP];

This calculation is wrong. This is resulting a opposite value (negative becomes positive, and the other way around).

Proof:

Lets say:

  1. iExpChange = 100
  2. iOldExp = 1000
  3. g_iPlayerInfo[iClient].iStats[ST_EXP] = 1000 + 100 + 100 is because iExpChange is added to this variable in line 189: if((g_iPlayerInfo[iClient].iStats[ST_EXP] += iExpChange) < iExpMin)

This makes the above calculation evaluate to this: g_iPlayerInfo[iClient].iRoundExp += iExpChange = 1000 - 1100; Making iExpChange be equal -100 and wrongly decreasing g_iPlayerInfo[iClient].iRoundExp also by this variable value.