How to prevent defaults to be modified in runtime?

Discussions about Coding and Scripting
Post Reply
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

How to prevent defaults to be modified in runtime?

Post by PrinceOfFunky »

Is there a way to prevent class defaults for its own variables to be modified in game?
"Your stuff is known to be buggy and unfinished/not properly tested"
MrLoathsome
Inhuman
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Personal rank: I am quite rank.
Location: MrLoathsome fell out of the world!

Re: How to prevent defaults to be modified in runtime?

Post by MrLoathsome »

Declare them as constants perhaps?
blarg
User avatar
Barbie
Godlike
Posts: 2806
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: How to prevent defaults to be modified in runtime?

Post by Barbie »

I think there is no way to have them protected from changes. As far as I have understood the world's creation process, a template of every needed class is loaded into memory, containing default property values. (That's also the reason why you can call static function without having an instance of that class.)

I may be wrong, but AFAIK there is no way to protect property values in UE1; the modifier private only is available with UE2 and higher.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: How to prevent defaults to be modified in runtime?

Post by PrinceOfFunky »

MrLoathsome wrote:Declare them as constants perhaps?
This worked fine :D
Default values of const variables cannot be modified at runtime, the only problem was if I extended a class, setting its default const variable value, const variable values and constant values, if inside an extended class, they cannot be accessed and the returned value is the value of the same constant/const_vars from the superclass.
But using the "default" keyword on a class type(no instanced classes) solves this problem.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: How to prevent defaults to be modified in runtime?

Post by sektor2111 »

Take in account "ConsoleCommand", or you did not see my "AI_Modifier" moving PathNodes which have a very constant bStatic and which I happily moved as I wanted. Aside I'm not trying to understand the purpose of these... a hacked compilation will be able to screw things anyway and... Natives attached (example Botz Mutator) will not give a chance to your "constants" if somebody wants them properly ruined. Else go figure what constants are implemented in some "Levels" and "Mods" used :? .
Post Reply