I've got an inventory item to represent stamina and a const function that mutates one of the variables of the class
class ActorStamina : Inventory {
...
protected int _regenTick;
...
void PauseRegeneration(int ticks) const {
_regenTick = ticks;
}
...
}
I have a status bar and I call this function
class PlayerStatusBar : BaseStatusBar {
...
override void Draw (int state, double tic) {
stamina.PauseRegeneration(1000);
}
...
}
I shouldn't be able to modify anything because it's const, but I still can from the UI scope.
const functions allow mutating variables from UI scope
Moderator: GZDoom Developers
Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.
If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.
Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.
If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.
Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
-
- Posts: 2119
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: const functions allow mutating variables from UI scope
Attached test PK3. Give yourself "Derp" on the console.
I think it's a good idea to fix this as soon as possible. I'd try to help, but for some reason, I can't find the damn code that handles const functions at all.
I think it's a good idea to fix this as soon as possible. I'd try to help, but for some reason, I can't find the damn code that handles const functions at all.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 2119
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: const functions allow mutating variables from UI scope
Bumping this because it's basically nearly a year since it was reported and it seems it was overlooked.