AUDIO: Mark more AdLib symbols as const#6266
Conversation
| OplInstrumentDefinition *_instrumentBank; | ||
| const OplInstrumentDefinition *_instrumentBank; | ||
| // Pointer to the rhythm instrument definitions. | ||
| OplInstrumentDefinition *_rhythmBank; | ||
| const OplInstrumentDefinition *_rhythmBank; |
There was a problem hiding this comment.
Why would we want to make these two const?
They are accessed and updated by engine code, and making them const makes the engine code ugly with no real gain
There was a problem hiding this comment.
As I understand it, the purpose of this PR is to make every statically define OplInstrumentDefinition objects constant (to have them located in .rodata instead of having them copied in .data at load time).
But this means that these pointers must be declared as pointing to const data.
This prevents some engines needing to it to update the tables.
11e600f to
bd850ee
Compare
|
Following a chat with @bluegr here is a proposal (as a commit to squash) that removes the writable pointer. |
const_cast is valid in these cases because the pointed data is dynamically allocated.
bd850ee to
030d2f8
Compare
|
Thanks for your work @ccawley2011 and @lephilousophe! The implementation is much cleaner now. I've tested the changes with Simon the Sorcerer 1 and Elvira 2, and both work great. Nice work! Merging |
No description provided.