BGE: memory leak in Random actuator + make actuator truly random when seed=0 in the UI. When running the game, seed 0 is replaced by a random seed accessible through Python in seed attribute of the actuator. Other seed value will be left unchanged and will generate fixed pseudo random series.
This commit is contained in:
@@ -58,7 +58,6 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj,
|
||||
m_parameter2(para2),
|
||||
m_distribution(mode)
|
||||
{
|
||||
// m_base is never deleted, probably a memory leak!
|
||||
m_base = new SCA_RandomNumberGenerator(seed);
|
||||
m_counter = 0;
|
||||
enforceConstraints();
|
||||
@@ -68,7 +67,7 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj,
|
||||
|
||||
SCA_RandomActuator::~SCA_RandomActuator()
|
||||
{
|
||||
/* intentionally empty */
|
||||
m_base->Release();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +80,13 @@ CValue* SCA_RandomActuator::GetReplica()
|
||||
return replica;
|
||||
}
|
||||
|
||||
void SCA_RandomActuator::ProcessReplica()
|
||||
{
|
||||
SCA_IActuator::ProcessReplica();
|
||||
// increment reference count so that we can release the generator at the end
|
||||
m_base->AddRef();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool SCA_RandomActuator::Update()
|
||||
|
||||
Reference in New Issue
Block a user