OpenNaja / cobra-tools

A suite of GUI tools for extracting and modifying OVL and OVS archives, as well as editing the associated in-house file formats. Also includes a model plugin for Blender. For downloads, guides, and FAQs visit:
https://opennaja.github.io/cobra-tools/
GNU General Public License v3.0
94 stars 27 forks source link

Force int for bitfield `_value` field. #352

Closed Candoran2 closed 11 months ago

Candoran2 commented 11 months ago

In some operations, especially the bitfieldmember assignment, the bitfield _value field could accidentally be converted into something other than an int (like numpy.intc) if the input value was of the right class.

This would cause a conflict with the __int__ function, which returns _value directly, and needs to be an int. I've therefore applied some int coercion on the functions that didn't already have it. This way, it is guaranteed that _value is always a proper python int (and the __int__ function functioning properly is an indicator of that, hence why I didn't apply int coercion there).