Fix weapon ID checks (bug 5872, r=Dr!fter)

This commit is contained in:
Kyle Sanderson 2013-08-21 10:55:12 -04:00
parent 754a6e1177
commit d79b41e4a7

View File

@ -273,11 +273,11 @@ int GetRealWeaponID(int weaponId)
case SMCSWeapon_DEFUSER: case SMCSWeapon_DEFUSER:
return (int)CSGOWeapon_DEFUSER; return (int)CSGOWeapon_DEFUSER;
default: default:
return 0; return (int)CSGOWeapon_NONE;
} }
#else #else
if (weaponId > 33 || weaponId < 0) if (weaponId > (int)SMCSWeapon_NIGHTVISION || weaponId < (int)SMCSWeapon_NONE)
return 0; return (int)SMCSWeapon_NONE;
else else
return weaponId; return weaponId;
#endif #endif
@ -397,26 +397,26 @@ int GetFakeWeaponID(int weaponId)
case CSGOWeapon_DEFUSER: case CSGOWeapon_DEFUSER:
return (int)SMCSWeapon_DEFUSER; return (int)SMCSWeapon_DEFUSER;
default: default:
return 0; return (int)SMCSWeapon_NONE;
} }
#else #else
if (weaponId > 33 || weaponId < 0) if (weaponId > (int)SMCSWeapon_NIGHTVISION || weaponId < (int)SMCSWeapon_NONE)
return 0; return (int)SMCSWeapon_NONE;
else else
return weaponId; return weaponId;
#endif #endif
} }
bool IsValidWeaponID(int id) bool IsValidWeaponID(int id)
{ {
if (id == (int)SMCSWeapon_NONE || id > (int)SMCSWeapon_DEFUSER) if (id <= (int)SMCSWeapon_NONE)
return false; return false;
//Why are these even HERE!?! They dont exist in CS:GO but have valid ID's still //Why are these even HERE!?! They dont exist in CS:GO but have valid ID's still
#if SOURCE_ENGINE == SE_CSGO #if SOURCE_ENGINE == SE_CSGO
else if (id == (int)SMCSWeapon_P228 || id == (int)SMCSWeapon_SCOUT || id == (int)SMCSWeapon_SG550 || id == (int)SMCSWeapon_GALIL || id == (int)SMCSWeapon_SCAR17 || else if (id > (int)SMCSWeapon_DEFUSER || id == (int)SMCSWeapon_P228 || id == (int)SMCSWeapon_SCOUT || id == (int)SMCSWeapon_SG550 || id == (int)SMCSWeapon_GALIL ||
id == (int)SMCSWeapon_USP || id == (int)SMCSWeapon_M3 || id == (int)SMCSWeapon_MP5NAVY || id == (int)SMCSWeapon_TMP || id == (int)SMCSWeapon_SG552) id == (int)SMCSWeapon_SCAR17 || id == (int)SMCSWeapon_USP || id == (int)SMCSWeapon_M3 || id == (int)SMCSWeapon_MP5NAVY || id == (int)SMCSWeapon_TMP || id == (int)SMCSWeapon_SG552)
return false; return false;
#else #else
else if (id > (int)SMCSWeapon_NIGHTVISION || id < (int)SMCSWeapon_NONE) else if (id > (int)SMCSWeapon_NIGHTVISION)
return false; return false;
#endif #endif
return true; return true;