revolucas / CoC-Xray

Modified X-Ray engine for Call of Chernobyl
Other
74 stars 33 forks source link

[Bugs] Some info about weapon is losing when it switches offline #7

Closed FreeZoneMods closed 7 years ago

FreeZoneMods commented 7 years ago

Steps to reproduce: 1) Attach to the weapon scope which has non-zero index in 'm_scopes' 2) Drop the weapon and switch it offline by running from it 3) Return to the weapon and take it into the hands 4) See MAGIC: the weapon has scope of another type!

Solution: The problem appears because CSE_ALifeItemWeapon class has no field to store scope type. Gunslinger mod uses bithacking of m_addon_flags field (writing scope index into the left 5 bits of the field in net_Destroy). This way provides best compatibility with original game, but leads to some restrictions (up to 32 types of scopes) and not fully proper. More correct way is to extend CSE_ALifeItemWeapon with extra field and export/import data from it when the weapon spawns/destroys. The problem is that such fix could conflict with some game's or mod's content.

P.S. The same bug you could see with ammos in the mag (if the weapon has different ammo types loaded). Moreover, info about types is losing during simple game saving and loading! It allows cheating with transformation cartridges from one type to another.

revolucas commented 7 years ago

I'm closing this because I've added a scripted solution to Call of Chernobyl. I've exported a way to get/set m_cur_scope and use my custom persistent storage system to save this value. https://bitbucket.org/revo_lucas/call-of-chernobyl/commits/618d19495290309cd70c37e135f88a53c60b75bf

& ammo types: https://bitbucket.org/revo_lucas/call-of-chernobyl/commits/d7bdb065f49ede291bfbdf66a57d7f65fc3da16c