const functions allow mutating variables from UI scope

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!

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is ON
[img] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: const functions allow mutating variables from UI scope

Re: const functions allow mutating variables from UI scope

by phantombeta » Fri Dec 27, 2019 2:18 pm

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

Re: const functions allow mutating variables from UI scope

by phantombeta » Sat Feb 16, 2019 3:54 pm

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

const functions allow mutating variables from UI scope

by Guest » Sat Feb 16, 2019 3:36 pm

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.

Top