For example:
Code: Select all
class Vampire expands Mutator;
var bool Initialized;
function PostBeginPlay()
{
if (Initialized)
return;
Initialized = True;
}
Code: Select all
class Vampire expands Mutator;
var bool Initialized;
function PostBeginPlay()
{
if (Initialized)
return;
Initialized = True;
}
What do you mean? I'm not a professional tester and coder to find all bugs in my Mod. It may have bugs, which is unknown to me. I would like "to insure" themselves and use the variable var bool Initialized against unknown bugs. It's a wise decision, isn't it?nogardilaref wrote:This is also what is generally called a "code smell".
If you need to use this sort of thing, there's a bigger problem somewhere else, or even in this very class.
What do you mean? This will help in all functions of the Мod or only in function PostBeginPlay() ?Barbie wrote:This is to prevent executing code multiple times.
If I understand you correctly, I do not need to use this variable in the mod?Higor wrote: The engine already does that in the 'BeginPlay' events, the variable that controls that is bScriptInitialized.
I didn't mean the problem to be necessarily yours or your code, I meant mostly that the engine has some of these which are indicative of a bigger problem of how the game itself (and engine) is programmed.Gadavre wrote:What do you mean? I'm not a professional tester and coder to find all bugs in my Mod. It may have bugs, which is unknown to me. I would like "to insure" themselves and use the variable var bool Initialized against unknown bugs. It's a wise decision, isn't it?nogardilaref wrote:This is also what is generally called a "code smell".
If you need to use this sort of thing, there's a bigger problem somewhere else, or even in this very class.