diff --git a/ChaosMod/Util/Weapon.h b/ChaosMod/Util/Weapon.h index aa1bdc7c0..779950224 100644 --- a/ChaosMod/Util/Weapon.h +++ b/ChaosMod/Util/Weapon.h @@ -1,25 +1,21 @@ #pragma once +#include + using Hash = unsigned long; namespace Util { - // TODO: Maybe CWeaponInfo has some field which can be checked (instead of hardcoding the weapon hashes) inline bool IsWeaponShotgun(Hash weaponHash) { - switch ((long)weaponHash) + static std::unordered_map cachedResults; + static const Hash shotgunGroup = "GROUP_SHOTGUN"_hash; + + if (const auto result = cachedResults.find(weaponHash); result != cachedResults.end()) { - case 487013001: - case 2017895192: - case -1654528753: - case -494615257: - case -1466123874: - case 984333226: - case -275439685: - case 317205821: - return true; + return result->second; } - return false; + return cachedResults.emplace(weaponHash, (GET_WEAPONTYPE_GROUP(weaponHash) == shotgunGroup)).first->second; } } \ No newline at end of file