gta-chaos-mod / ChaosModV

Chaos Mod for Grand Theft Auto V
https://gta5-mods.com/scripts/chaos-mod-v-beta
GNU General Public License v3.0
258 stars 95 forks source link

future proof(?) shotgun checking logic #3653

Closed holysnipz closed 7 months ago

holysnipz commented 7 months ago

no more hardcoded weapon hashes (even this is used by only 2 effects) 😅

from SHV's natives definition, seems old enough to not cause compatibility issues in earlier game versions NATIVE_DECL Hash GET_WEAPONTYPE_GROUP(Hash weaponHash) { return invoke<Hash>(0xC3287EE3050FB74C, weaponHash); } // 0xC3287EE3050FB74C 0x5F2DE833 b323

Rylxnd commented 7 months ago

Okay, how does this perform compared to the “old” method with the switch case? Probably worse considering the speed of switch compared with the extra overhead of calling a native function.

ShufflePerson commented 7 months ago

Okay, how does this perform compared to the “old” method with the switch case? Probably worse considering the speed of switch compared with the extra overhead of calling a native function.

Maybe adding caching could be the best option of both worlds? First call with each ID will be slower, the rest will be as fast as it was with switch.

holysnipz commented 7 months ago

it was way slower, but still unnoticeable in normal gameplay. so i didn't cared much.

should be better now

pongo1231 commented 7 months ago

The overhead from the native call is very negligible, especially considering the already existing frequency of native calls by the mod. The additional optimization is appreciated regardless.