BGE: fix a compatibility problem since logic patch with YoFrankie (and other games I guess). State actuators will now execute before any other actuators to make sure that the actuators link count are up to date when they execute.
This commit is contained in:
@@ -58,6 +58,27 @@ bool SCA_IActuator::Update()
|
||||
return false;
|
||||
}
|
||||
|
||||
void SCA_IActuator::Activate(SG_DList& head)
|
||||
{
|
||||
if (QEmpty())
|
||||
{
|
||||
InsertActiveQList(m_gameobj->m_activeActuators);
|
||||
head.AddBack(&m_gameobj->m_activeActuators);
|
||||
}
|
||||
}
|
||||
|
||||
void SCA_IActuator::Deactivate()
|
||||
{
|
||||
if (QDelink())
|
||||
{
|
||||
// the actuator was in the active list
|
||||
if (m_gameobj->m_activeActuators.QEmpty())
|
||||
// the owner object has no more active actuators, remove it from the global list
|
||||
m_gameobj->m_activeActuators.Delink();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCA_IActuator::ProcessReplica()
|
||||
{
|
||||
SCA_ILogicBrick::ProcessReplica();
|
||||
|
||||
@@ -118,23 +118,8 @@ public:
|
||||
/**
|
||||
* remove this actuator from the list of active actuators
|
||||
*/
|
||||
void Deactivate()
|
||||
{
|
||||
if (QDelink())
|
||||
// the actuator was in the active list
|
||||
if (m_gameobj->m_activeActuators.QEmpty())
|
||||
// the owner object has no more active actuators, remove it from the global list
|
||||
m_gameobj->m_activeActuators.Delink();
|
||||
}
|
||||
|
||||
void Activate(SG_DList& head)
|
||||
{
|
||||
if (QEmpty())
|
||||
{
|
||||
InsertActiveQList(m_gameobj->m_activeActuators);
|
||||
head.AddBack(&m_gameobj->m_activeActuators);
|
||||
}
|
||||
}
|
||||
virtual void Deactivate();
|
||||
virtual void Activate(SG_DList& head);
|
||||
|
||||
void LinkToController(SCA_IController* controller);
|
||||
void UnlinkController(class SCA_IController* cont);
|
||||
|
||||
@@ -312,16 +312,6 @@ void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_I
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCA_LogicManager::AddActiveActuator(SCA_IActuator* actua,bool event)
|
||||
{
|
||||
actua->SetActive(true);
|
||||
actua->Activate(m_activeActuators);
|
||||
actua->AddEvent(event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SCA_EventManager* SCA_LogicManager::FindEventManager(int eventmgrtype)
|
||||
{
|
||||
// find an eventmanager of a certain type
|
||||
|
||||
@@ -65,6 +65,7 @@ typedef std::map<class SCA_ISensor*,controllerlist > sensormap_t;
|
||||
*/
|
||||
|
||||
#include "SCA_ILogicBrick.h"
|
||||
#include "SCA_IActuator.h"
|
||||
|
||||
|
||||
class SCA_LogicManager
|
||||
@@ -103,7 +104,13 @@ public:
|
||||
void BeginFrame(double curtime, double fixedtime);
|
||||
void UpdateFrame(double curtime, bool frame);
|
||||
void EndFrame();
|
||||
void AddActiveActuator(SCA_IActuator* sensor,bool event);
|
||||
void AddActiveActuator(SCA_IActuator* actua,bool event)
|
||||
{
|
||||
actua->SetActive(true);
|
||||
actua->Activate(m_activeActuators);
|
||||
actua->AddEvent(event);
|
||||
}
|
||||
|
||||
void AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor);
|
||||
SCA_EventManager* FindEventManager(int eventmgrtype);
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ KX_StateActuator::~KX_StateActuator(
|
||||
// intentionally empty
|
||||
}
|
||||
|
||||
// used to put state actuator to be executed before any other actuators
|
||||
SG_QList KX_StateActuator::m_stateActuatorHead;
|
||||
|
||||
CValue*
|
||||
KX_StateActuator::GetReplica(
|
||||
void
|
||||
@@ -99,6 +102,28 @@ KX_StateActuator::Update()
|
||||
return false;
|
||||
}
|
||||
|
||||
void KX_StateActuator::Deactivate()
|
||||
{
|
||||
if (QDelink())
|
||||
{
|
||||
// the actuator was in the active list
|
||||
if (m_stateActuatorHead.QEmpty())
|
||||
// no more state object active
|
||||
m_stateActuatorHead.Delink();
|
||||
}
|
||||
}
|
||||
|
||||
void KX_StateActuator::Activate(SG_DList& head)
|
||||
{
|
||||
// no need to sort the state actuators
|
||||
if (m_stateActuatorHead.QAddBack(this))
|
||||
{
|
||||
// add front to make sure it runs before other actuators
|
||||
head.AddFront(&m_stateActuatorHead);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Python functions */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -46,6 +46,7 @@ class KX_StateActuator : public SCA_IActuator
|
||||
OP_NEG,
|
||||
OP_COUNT
|
||||
};
|
||||
static SG_QList m_stateActuatorHead;
|
||||
int m_operation;
|
||||
int m_mask;
|
||||
|
||||
@@ -71,6 +72,9 @@ class KX_StateActuator : public SCA_IActuator
|
||||
virtual bool
|
||||
Update();
|
||||
|
||||
virtual void Deactivate();
|
||||
virtual void Activate(SG_DList& head);
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user