const functions allow mutating variables from UI scope

Is there something that doesn't work right in the latest GZDoom? Post about it here.

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!
Guest

const functions allow mutating variables from UI scope

Post by Guest »

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.
User avatar
phantombeta
Posts: 2084
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

Post by phantombeta »

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.
Attachments
test.pk3
(621 Bytes) Downloaded 132 times
User avatar
phantombeta
Posts: 2084
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

Post by phantombeta »

Bumping this because it's basically nearly a year since it was reported and it seems it was overlooked.
Post Reply

Return to “Bugs [GZDoom]”