Skip to content

Commit

Permalink
UPBGE: Remove unused function and arguments in GameLogic/.
Browse files Browse the repository at this point in the history
  • Loading branch information
panzergame committed May 25, 2017
1 parent 666ec76 commit e7ef47b
Show file tree
Hide file tree
Showing 31 changed files with 158 additions and 298 deletions.
13 changes: 4 additions & 9 deletions source/gameengine/Converter/BL_ActionActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@ CValue* BL_ActionActuator::GetReplica()
return replica;
}

bool BL_ActionActuator::Update(double curtime, bool frame)
bool BL_ActionActuator::Update(double curtime)
{
bool bNegativeEvent = false;
bool bPositiveEvent = false;
bool bUseContinue = false;
KX_GameObject *obj = (KX_GameObject*)GetParent();
short playtype = BL_Action::ACT_MODE_PLAY;
Expand Down Expand Up @@ -219,12 +217,9 @@ bool BL_ActionActuator::Update(double curtime, bool frame)


// Handle events
if (frame)
{
bNegativeEvent = m_negevent;
bPositiveEvent = m_posevent;
RemoveAllEvents();
}
bool bNegativeEvent = m_negevent;
bool bPositiveEvent = m_posevent;
RemoveAllEvents();

// "Active" actions need to keep updating their current frame
if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE))
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Converter/BL_ActionActuator.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class BL_ActionActuator : public SCA_IActuator
float stride);

virtual ~BL_ActionActuator();
virtual bool Update(double curtime, bool frame);
virtual bool Update(double curtime);
virtual CValue* GetReplica();
virtual void ProcessReplica();

Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Converter/BL_ArmatureActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void BL_ArmatureActuator::FindConstraint()
}
}

bool BL_ArmatureActuator::Update(double curtime, bool frame)
bool BL_ArmatureActuator::Update(double curtime)
{
// the only role of this actuator is to ensure that the armature pose will be evaluated
bool result = false;
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Converter/BL_ArmatureActuator.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BL_ArmatureActuator : public SCA_IActuator
virtual void ProcessReplica();
virtual bool UnlinkObject(SCA_IObject* clientobj);
virtual void Relink(std::map<SCA_IObject *, SCA_IObject *>& obj_map);
virtual bool Update(double curtime, bool frame);
virtual bool Update(double curtime);
virtual void ReParent(SCA_IObject* parent);

#ifdef WITH_PYTHON
Expand Down
1 change: 0 additions & 1 deletion source/gameengine/Converter/KX_ConvertActuators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ void BL_ConvertActuators(const char* maggiename,
actcount++;
bact = bact->next;
}
gameobj->ReserveActuator(actcount);
bact = (bActuator*) blenderobject->actuators.first;
while (bact)
{
Expand Down
2 changes: 0 additions & 2 deletions source/gameengine/Converter/KX_ConvertControllers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ LinkControllerToActuators(
// Iterate through the actuators of the game blender
// controller and find the corresponding ketsji actuator.

game_controller->ReserveActuator(bcontr->totlinks);
for (int i=0;i<bcontr->totlinks;i++)
{
bActuator* bact = (bActuator*) bcontr->links[i];
Expand Down Expand Up @@ -108,7 +107,6 @@ void BL_ConvertControllers(
bcontr = bcontr->next;
count++;
}
gameobj->ReserveController(count);
bcontr = (bController*)blenderobject->controllers.first;
while (bcontr)
{
Expand Down
7 changes: 0 additions & 7 deletions source/gameengine/Converter/KX_ConvertSensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ void BL_ConvertSensors(struct Object* blenderobject,
sens = sens->next;
count++;
}
gameobj->ReserveSensor(count);
sens = (bSensor*)blenderobject->sensors.first;

while (sens) {
Expand Down Expand Up @@ -624,12 +623,6 @@ void BL_ConvertSensors(struct Object* blenderobject,

gameobj->AddSensor(gamesensor);

// only register to manager if it's in an active layer
// Make registration dynamic: only when sensor is activated
//if (isInActiveLayer)
// gamesensor->RegisterToManager();

gamesensor->ReserveController(sens->totlinks);
for (int i=0;i<sens->totlinks;i++)
{
bController* linkedcont = (bController*) sens->links[i];
Expand Down
8 changes: 2 additions & 6 deletions source/gameengine/GameLogic/SCA_IActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,9 @@ bool SCA_IActuator::UnlinkObject(SCA_IObject *clientobj)
return false;
}

bool SCA_IActuator::Update(double curtime, bool frame)
bool SCA_IActuator::Update(double curtime)
{
if (frame) {
return Update();
}

return true;
return Update();
}

bool SCA_IActuator::Update()
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/GameLogic/SCA_IActuator.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class SCA_IActuator : public SCA_ILogicBrick
*/


virtual bool Update(double curtime, bool frame);
virtual bool Update(double curtime);
virtual bool Update();

/**
Expand Down
5 changes: 0 additions & 5 deletions source/gameengine/GameLogic/SCA_IController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ std::vector<SCA_IActuator *>& SCA_IController::GetLinkedActuators()
return m_linkedactuators;
}

void SCA_IController::ReserveActuator(int num)
{
m_linkedactuators.reserve(num);
}

void SCA_IController::UnlinkAllSensors()
{
for (SCA_ISensor *sensor : m_linkedsensors) {
Expand Down
1 change: 0 additions & 1 deletion source/gameengine/GameLogic/SCA_IController.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class SCA_IController : public SCA_ILogicBrick
void LinkToActuator(SCA_IActuator *);
std::vector<SCA_ISensor *>& GetLinkedSensors();
std::vector<SCA_IActuator *>& GetLinkedActuators();
void ReserveActuator(int num);
void UnlinkAllSensors();
void UnlinkAllActuators();
void UnlinkActuator(SCA_IActuator *actua);
Expand Down
45 changes: 0 additions & 45 deletions source/gameengine/GameLogic/SCA_ILogicBrick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,6 @@ void SCA_ILogicBrick::Relink(std::map<SCA_IObject *, SCA_IObject *>& obj_map)
// nothing to do
}

CValue* SCA_ILogicBrick::Calc(VALUE_OPERATOR op, CValue *val)
{
CValue* temp = new CBoolValue(false,"");
CValue* result = temp->Calc(op,val);
temp->Release();

return result;
}

CValue* SCA_ILogicBrick::CalcFinal(VALUE_DATA_TYPE dtype,
VALUE_OPERATOR op,
CValue *val)
{
// same as bool implementation, so...
CValue* temp = new CBoolValue(false,"");
CValue* result = temp->CalcFinal(dtype,op,val);
temp->Release();

return result;
}

const std::string SCA_ILogicBrick::GetText()
{
if (m_name.size())
Expand All @@ -120,13 +99,6 @@ void SCA_ILogicBrick::SetName(const std::string& name)
m_name = name;
}

bool SCA_ILogicBrick::LessComparedTo(SCA_ILogicBrick* other)
{
return (this->m_Execute_Ueber_Priority < other->m_Execute_Ueber_Priority)
|| ((this->m_Execute_Ueber_Priority == other->m_Execute_Ueber_Priority) &&
(this->m_Execute_Priority < other->m_Execute_Priority));
}

void SCA_ILogicBrick::SetLogicManager(SCA_LogicManager *logicmgr)
{
m_logicManager = logicmgr;
Expand Down Expand Up @@ -212,21 +184,4 @@ PyObject *SCA_ILogicBrick::pyattr_get_owner(PyObjectPlus *self_v, const KX_PYATT
Py_RETURN_NONE;
}



/* Conversions for making life better. */
bool SCA_ILogicBrick::PyArgToBool(int boolArg)
{
if (boolArg) {
return true;
} else {
return false;
}
}

PyObject *SCA_ILogicBrick::BoolToPyArg(bool boolarg)
{
return PyLong_FromLong(boolarg ? KX_TRUE: KX_FALSE);
}

#endif // WITH_PYTHON
16 changes: 0 additions & 16 deletions source/gameengine/GameLogic/SCA_ILogicBrick.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ class SCA_ILogicBrick : public CValue, public SG_QList
virtual void Relink(std::map<SCA_IObject *, SCA_IObject *>& obj_map);
virtual void Delete() { Release(); }

// act as a BoolValue (with value IsPositiveTrigger)
virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);

virtual const std::string GetText();
virtual std::string GetName();
virtual void SetName(const std::string& name);
Expand Down Expand Up @@ -122,8 +118,6 @@ class SCA_ILogicBrick : public CValue, public SG_QList
it.add_back(this);
}

virtual bool LessComparedTo(SCA_ILogicBrick* other);

virtual void SetLogicManager(SCA_LogicManager *logicmgr);
SCA_LogicManager *GetLogicManager();

Expand All @@ -145,16 +139,6 @@ class SCA_ILogicBrick : public CValue, public SG_QList
KX_FALSE,
KX_BOOL_MAX
};


protected:
/* Some conversions to go with the bool type. */
/** Convert a KX_TRUE, KX_FALSE in Python to a c++ value. */
bool PyArgToBool(int boolArg);

/** Convert a a c++ value to KX_TRUE, KX_FALSE in Python. */
PyObject *BoolToPyArg(bool);

#endif /* WITH_PYTHON */

};
Expand Down
14 changes: 0 additions & 14 deletions source/gameengine/GameLogic/SCA_IObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,8 @@ class SCA_IObject : public CValue
}

void AddSensor(SCA_ISensor* act);
void ReserveSensor(int num)
{
m_sensors.reserve(num);
}
void AddController(SCA_IController* act);
void ReserveController(int num)
{
m_controllers.reserve(num);
}
void AddActuator(SCA_IActuator* act);
void ReserveActuator(int num)
{
m_actuators.reserve(num);
}
void RegisterActuator(SCA_IActuator* act);
void UnregisterActuator(SCA_IActuator* act);

Expand Down Expand Up @@ -215,8 +203,6 @@ class SCA_IObject : public CValue
*/
unsigned int GetState(void) { return m_state; }

// const class MT_Vector3& ConvertPythonPylist(PyObject *pylist);

virtual int GetGameObjectType() const {return -1;}

typedef enum ObjectTypes {
Expand Down
13 changes: 4 additions & 9 deletions source/gameengine/GameLogic/SCA_ISensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,6 @@ void SCA_ISensor::Replace_EventManager(class SCA_LogicManager *logicmgr)
}
}

void SCA_ISensor::ReserveController(int num)
{
m_linkedcontrollers.reserve(num);
}

void SCA_ISensor::LinkToController(SCA_IController *controller)
{
m_linkedcontrollers.push_back(controller);
Expand Down Expand Up @@ -412,17 +407,17 @@ PyObject *SCA_ISensor::pyattr_get_positive(PyObjectPlus *self_v, const KX_PYATTR
PyObject *SCA_ISensor::pyattr_get_status(PyObjectPlus *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
SCA_ISensor *self = static_cast<SCA_ISensor *>(self_v);
int status = 0;
int status = KX_SENSOR_INACTIVE;
if (self->GetState()) {
if (self->GetState() == self->GetPrevState()) {
status = 2;
status = KX_SENSOR_ACTIVE;
}
else {
status = 1;
status = KX_SENSOR_JUST_ACTIVATED;
}
}
else if (self->GetState() != self->GetPrevState()) {
status = 3;
status = KX_SENSOR_JUST_DEACTIVATED;
}
return PyLong_FromLong(status);
}
Expand Down
1 change: 0 additions & 1 deletion source/gameengine/GameLogic/SCA_ISensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ class SCA_ISensor : public SCA_ILogicBrick
virtual void RegisterToManager();
virtual void UnregisterToManager();
void Replace_EventManager(SCA_LogicManager *logicmgr);
void ReserveController(int num);
void LinkToController(SCA_IController *controller);
void UnlinkController(SCA_IController *controller);
void UnlinkAllControllers();
Expand Down
28 changes: 2 additions & 26 deletions source/gameengine/GameLogic/SCA_LogicManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,6 @@ SCA_LogicManager::~SCA_LogicManager()
BLI_assert(m_activeActuators.Empty());
}

#if 0
// this kind of fixes bug 398 but breakes games, so better leave it out for now.
// a removed object's gameobject (and logicbricks and stuff) didn't get released
// because it was still in the m_mapStringToGameObjects map.
void SCA_LogicManager::RemoveGameObject(const std::string& gameobjname)
{
int numgameobj = m_mapStringToGameObjects.size();
for (int i = 0; i < numgameobj; i++)
{
CValue** gameobjptr = m_mapStringToGameObjects.at(i);
BLI_assert(gameobjptr);

if (gameobjptr)
{
if ((*gameobjptr)->GetName() == gameobjname)
(*gameobjptr)->Release();
}
}

m_mapStringToGameObjects.remove(gameobjname);
}
#endif


void SCA_LogicManager::RegisterEventManager(SCA_EventManager* eventmgr)
{
m_eventmanagers.push_back(eventmgr);
Expand Down Expand Up @@ -203,7 +179,7 @@ void SCA_LogicManager::BeginFrame(double curtime, double fixedtime)



void SCA_LogicManager::UpdateFrame(double curtime, bool frame)
void SCA_LogicManager::UpdateFrame(double curtime)
{
for (std::vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin(); !(ie==m_eventmanagers.end()); ie++)
(*ie)->UpdateFrame();
Expand All @@ -220,7 +196,7 @@ void SCA_LogicManager::UpdateFrame(double curtime, bool frame)
SCA_IActuator* actua = *ia;
// increment first to allow removal of inactive actuators.
++ia;
if (!actua->Update(curtime, frame))
if (!actua->Update(curtime))
{
// this actuator is not active anymore, remove
actua->QDelink();
Expand Down
4 changes: 1 addition & 3 deletions source/gameengine/GameLogic/SCA_LogicManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SCA_LogicManager
class SCA_IActuator* actuator);

void BeginFrame(double curtime, double fixedtime);
void UpdateFrame(double curtime, bool frame);
void UpdateFrame(double curtime);
void EndFrame();
void AddActiveActuator(SCA_IActuator* actua,bool event)
{
Expand All @@ -107,8 +107,6 @@ class SCA_LogicManager
void AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor);
SCA_EventManager* FindEventManager(int eventmgrtype);
std::vector<class SCA_EventManager*> GetEventManagers() { return m_eventmanagers; }

void RemoveGameObject(const std::string& gameobjname);

/**
* remove Logic Bricks from the running logicmanager
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Ketsji/KX_CameraActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static void Kx_VecUpMat3(float vec[3], float mat[3][3], short axis)
cross_v3_v3v3(mat[cox], mat[coy], mat[coz]);
}

bool KX_CameraActuator::Update(double curtime, bool frame)
bool KX_CameraActuator::Update(double curtime)
{
/* wondering... is it really necessary/desirable to suppress negative */
/* events here? */
Expand Down
Loading

0 comments on commit e7ef47b

Please sign in to comment.