diff options
Diffstat (limited to 'source/gameengine/GameLogic')
58 files changed, 427 insertions, 427 deletions
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 9f532527a80..369ec4257cf 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -59,10 +59,10 @@ SCA_Joystick::SCA_Joystick(short int index) { for (int i=0; i < JOYAXIS_MAX; i++) m_axis_array[i] = 0; - + for (int i=0; i < JOYHAT_MAX; i++) m_hat_array[i] = 0; - + #ifdef WITH_SDL m_private = new PrivateData(); #endif @@ -94,7 +94,7 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) return NULL; } - if (m_refCount == 0) + if (m_refCount == 0) { int i; @@ -124,9 +124,9 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) JOYSTICK_ECHO("Error-Initializing-SDL: " << SDL_GetError()); return NULL; } - + m_joynum = SDL_NumJoysticks(); - + for (i = 0; i < m_joynum; i++) { m_instance[i] = new SCA_Joystick(i); m_instance[i]->CreateJoystickDevice(); @@ -189,7 +189,7 @@ bool SCA_Joystick::aAxisPairDirectionIsPositive(int axis, int dir) res = pGetAxis(axis, 1); else /* JOYAXIS_LEFT || JOYAXIS_RIGHT */ res = pGetAxis(axis, 0); - + if (dir==JOYAXIS_DOWN || dir==JOYAXIS_RIGHT) return (res > m_prec) ? true : false; else /* JOYAXIS_UP || JOYAXIS_LEFT */ @@ -273,7 +273,7 @@ bool SCA_Joystick::CreateJoystickDevice(void) if (m_joyindex>=m_joynum) { /* don't print a message, because this is done anyway */ //JOYSTICK_ECHO("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)"); - + /* Need this so python args can return empty lists */ m_axismax = m_buttonmax = m_hatmax = 0; return false; @@ -282,9 +282,9 @@ bool SCA_Joystick::CreateJoystickDevice(void) m_private->m_joystick = SDL_JoystickOpen(m_joyindex); SDL_JoystickEventState(SDL_ENABLE); m_isinit = true; - + JOYSTICK_ECHO("Joystick " << m_joyindex << " initialized"); - + /* must run after being initialized */ m_axismax = SDL_JoystickNumAxes(m_private->m_joystick); m_buttonmax = SDL_JoystickNumButtons(m_private->m_joystick); @@ -292,12 +292,12 @@ bool SCA_Joystick::CreateJoystickDevice(void) if (m_axismax > JOYAXIS_MAX) m_axismax = JOYAXIS_MAX; /* very unlikely */ else if (m_axismax < 0) m_axismax = 0; - + if (m_hatmax > JOYHAT_MAX) m_hatmax = JOYHAT_MAX; /* very unlikely */ else if (m_hatmax < 0) m_hatmax = 0; - + if (m_buttonmax < 0) m_buttonmax = 0; - + } return true; #endif /* WITH_SDL */ @@ -355,7 +355,7 @@ int SCA_Joystick::pAxisTest(int axisnum) * than what a short can hold. In other words, abs(MIN_SHORT) > MAX_SHRT. */ int i1 = m_axis_array[(axisnum * 2)]; int i2 = m_axis_array[(axisnum * 2) + 1]; - + /* long winded way to do: * return max_ff(absf(i1), absf(i2)) * ...avoid abs from math.h */ diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index c9221753d45..98b117b70d1 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -68,16 +68,16 @@ class SCA_Joystick #endif int m_joyindex; - /** + /** *support for JOYAXIS_MAX axes (in pairs) */ int m_axis_array[JOYAXIS_MAX]; - /** + /** *support for JOYHAT_MAX hats (each is a direction) */ int m_hat_array[JOYHAT_MAX]; - + /** * Precision or range of the axes */ @@ -86,15 +86,15 @@ class SCA_Joystick /** * max # of buttons avail */ - + int m_axismax; int m_buttonmax; int m_hatmax; - + /** is the joystick initialized ?*/ bool m_isinit; - + /** is triggered for each event type */ bool m_istrig_axis; bool m_istrig_button; @@ -112,7 +112,7 @@ class SCA_Joystick #if 0 /* not used yet */ void OnBallMotion(SDL_Event *sdl_event) {} #endif - + #endif /* WITH_SDL */ /** * Open the joystick @@ -142,13 +142,13 @@ class SCA_Joystick SCA_Joystick(short int index); ~SCA_Joystick(); - + public: static SCA_Joystick *GetInstance(short int joyindex); static void HandleEvents(void); void ReleaseInstance(); - + /* */ @@ -182,11 +182,11 @@ public: bool IsTrigAxis(void) { return m_istrig_axis; } - + bool IsTrigButton(void) { return m_istrig_button; } - + bool IsTrigHat(void) { return m_istrig_hat; } @@ -198,7 +198,7 @@ public: int GetNumberOfAxes(void); int GetNumberOfButtons(void); int GetNumberOfHats(void); - + /** * Test if the joystick is connected */ diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp index 1dee1de9de2..b1ce31662ed 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp @@ -41,7 +41,7 @@ void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event) { if (sdl_event->jaxis.axis >= JOYAXIS_MAX) return; - + m_axis_array[sdl_event->jaxis.axis] = sdl_event->jaxis.value; m_istrig_axis = 1; } @@ -68,7 +68,7 @@ void SCA_Joystick::OnButtonDown(SDL_Event* sdl_event) //if (sdl_event->jbutton.button > m_buttonmax) /* unsigned int so always above 0 */ // return; // sdl_event->jbutton.button; - + m_istrig_button = 1; } @@ -93,17 +93,17 @@ void SCA_Joystick::HandleEvents(void) if (SCA_Joystick::m_instance[i]) SCA_Joystick::m_instance[i]->OnNothing(&sdl_event); } - + while (SDL_PollEvent(&sdl_event)) { /* Note! m_instance[sdl_event.jaxis.which] * will segfault if over JOYINDEX_MAX, not too nice but what are the chances? */ - + /* Note!, with buttons, this wont care which button is pressed, * only to set 'm_istrig_button', actual pressed buttons are detected by SDL_JoystickGetButton */ - + /* Note!, if you manage to press and release a button within 1 logic tick * it wont work as it should */ - + switch (sdl_event.type) { case SDL_JOYAXISMOTION: SCA_Joystick::m_instance[sdl_event.jaxis.which]->OnAxisMotion(&sdl_event); diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h index 472a7353190..ab42eb57079 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h @@ -24,7 +24,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ - + /** \file SCA_JoystickPrivate.h * \ingroup gamelogic */ diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp index 2cb7406779c..26380105e91 100644 --- a/source/gameengine/GameLogic/SCA_ANDController.cpp +++ b/source/gameengine/GameLogic/SCA_ANDController.cpp @@ -71,7 +71,7 @@ void SCA_ANDController::Trigger(SCA_LogicManager* logicmgr) break; } } - + for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); !(i==m_linkedactuators.end());i++) { diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index 8b7702228ce..03c142e8c14 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -96,7 +96,7 @@ bool SCA_ActuatorSensor::Evaluate() { bool result = m_actuator->IsActive(); bool reset = m_reset && m_level; - + m_reset = false; if (m_lastresult != result || m_midresult != result) { diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h index 6005bd3ac6c..f728dc5c0ca 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h @@ -47,7 +47,7 @@ public: SCA_ActuatorSensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, const STR_String& actname); - + virtual ~SCA_ActuatorSensor(); virtual CValue* GetReplica(); virtual void Init(); @@ -63,7 +63,7 @@ public: /* --------------------------------------------------------------------- */ static int CheckActuator(void *self, const PyAttributeDef*); - + #endif /* WITH_PYTHON */ }; diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp index 1a6a82a33eb..28f8b2123e1 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp @@ -78,7 +78,7 @@ CValue* SCA_AlwaysSensor::GetReplica() bool SCA_AlwaysSensor::IsPositiveTrigger() -{ +{ return (m_invert ? false : true); } @@ -90,7 +90,7 @@ bool SCA_AlwaysSensor::Evaluate() //return true; /* even nicer ;) */ //return false; - + /* nicest ! */ bool result = m_alwaysresult; m_alwaysresult = false; diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp index af751cffc2e..5222d1961af 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -85,7 +85,7 @@ CValue* SCA_DelaySensor::GetReplica() bool SCA_DelaySensor::IsPositiveTrigger() -{ +{ return (m_invert ? !m_lastResult : m_lastResult); } diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h index 9b39de7e099..0544bfef8c4 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.h +++ b/source/gameengine/GameLogic/SCA_DelaySensor.h @@ -41,7 +41,7 @@ class SCA_DelaySensor : public SCA_ISensor Py_Header bool m_lastResult; bool m_repeat; - int m_delay; + int m_delay; int m_duration; int m_frameCount; diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h index eb9a6d9aca1..53cd16a810d 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.h +++ b/source/gameengine/GameLogic/SCA_EventManager.h @@ -51,8 +51,8 @@ public: enum EVENT_MANAGER_TYPE { KEYBOARD_EVENTMGR = 0, MOUSE_EVENTMGR, - ALWAYS_EVENTMGR, - TOUCH_EVENTMGR, + ALWAYS_EVENTMGR, + TOUCH_EVENTMGR, PROPERTY_EVENTMGR, TIME_EVENTMGR, RANDOM_EVENTMGR, @@ -65,7 +65,7 @@ public: SCA_EventManager(SCA_LogicManager* logicmgr, EVENT_MANAGER_TYPE mgrtype); virtual ~SCA_EventManager(); - + virtual void RemoveSensor(class SCA_ISensor* sensor); virtual void NextFrame(double curtime, double fixedtime); virtual void NextFrame(); diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h index c16944ccde1..993b3b67a96 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.h +++ b/source/gameengine/GameLogic/SCA_ExpressionController.h @@ -51,7 +51,7 @@ public: virtual CValue* GetReplica(); virtual void Trigger(SCA_LogicManager* logicmgr); virtual CValue* FindIdentifier(const STR_String& identifiername); - /** + /** * used to release the expression cache * so that self references are removed before the controller itself is released */ diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp index 9a355fdf3c9..ca67f5b672e 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.cpp +++ b/source/gameengine/GameLogic/SCA_IActuator.cpp @@ -49,7 +49,7 @@ bool SCA_IActuator::Update(double curtime, bool frame) { if (frame) return Update(); - + return true; } @@ -99,7 +99,7 @@ SCA_IActuator::~SCA_IActuator() void SCA_IActuator::DecLink() { m_links--; - if (m_links < 0) + if (m_links < 0) { printf("Warning: actuator %s has negative m_links: %d\n", m_name.Ptr(), m_links); m_links = 0; @@ -123,8 +123,8 @@ void SCA_IActuator::UnlinkController(SCA_IController* controller) return; } } - printf("Missing link from actuator %s:%s to controller %s:%s\n", - m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(), + printf("Missing link from actuator %s:%s to controller %s:%s\n", + m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(), controller->GetParent()->GetName().ReadPtr(), controller->GetName().ReadPtr()); } diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h index b63cb633b4e..bca0b1ad764 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.h +++ b/source/gameengine/GameLogic/SCA_IActuator.h @@ -92,7 +92,7 @@ public: KX_ACT_MOUSE, }; - SCA_IActuator(SCA_IObject* gameobj, KX_ACTUATOR_TYPE type); + SCA_IActuator(SCA_IObject* gameobj, KX_ACTUATOR_TYPE type); /** * UnlinkObject(...) @@ -105,11 +105,11 @@ public: /** * Update(...) - * Update the actuator based upon the events received since + * Update the actuator based upon the events received since * the last call to Update, the current time and deltatime the * time elapsed in this frame ? * It is the responsibility of concrete Actuators to clear - * their event's. This is usually done in the Update() method via + * their event's. This is usually done in the Update() method via * a call to RemoveAllEvents() */ @@ -117,9 +117,9 @@ public: virtual bool Update(double curtime, bool frame); virtual bool Update(); - /** + /** * Add an event to an actuator. - */ + */ //void AddEvent(CValue* event) void AddEvent(bool event) { @@ -131,7 +131,7 @@ public: virtual void ProcessReplica(); - /** + /** * Return true if all the current events * are negative. The definition of negative event is * not immediately clear. But usually refers to key-up events @@ -159,7 +159,7 @@ public: virtual void DecLink(); bool IsNoLink() const { return !m_links; } bool IsType(KX_ACTUATOR_TYPE type) { return m_type == type; } - + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_IActuator") #endif diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index c4176d66688..46ea2910a74 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -48,9 +48,9 @@ SCA_IController::SCA_IController(SCA_IObject* gameobj) m_justActivated(false) { } - - + + SCA_IController::~SCA_IController() { //UnlinkAllActuators(); @@ -77,7 +77,7 @@ void SCA_IController::UnlinkAllSensors() std::vector<class SCA_ISensor*>::iterator sensit; for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit) { - if (IsActive()) + if (IsActive()) { (*sensit)->DecLink(); } @@ -93,7 +93,7 @@ void SCA_IController::UnlinkAllActuators() std::vector<class SCA_IActuator*>::iterator actit; for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit) { - if (IsActive()) + if (IsActive()) { (*actit)->DecLink(); } @@ -127,8 +127,8 @@ void SCA_IController::UnlinkActuator(class SCA_IActuator* actua) return; } } - printf("Missing link from controller %s:%s to actuator %s:%s\n", - m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(), + printf("Missing link from controller %s:%s to actuator %s:%s\n", + m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(), actua->GetParent()->GetName().ReadPtr(), actua->GetName().ReadPtr()); } @@ -157,8 +157,8 @@ void SCA_IController::UnlinkSensor(class SCA_ISensor* sensor) return; } } - printf("Missing link from controller %s:%s to sensor %s:%s\n", - m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(), + printf("Missing link from controller %s:%s to sensor %s:%s\n", + m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(), sensor->GetParent()->GetName().ReadPtr(), sensor->GetName().ReadPtr()); } @@ -168,9 +168,9 @@ void SCA_IController::ApplyState(unsigned int state) std::vector<class SCA_IActuator*>::iterator actit; std::vector<class SCA_ISensor*>::iterator sensit; - if (m_statemask & state) + if (m_statemask & state) { - if (!IsActive()) + if (!IsActive()) { // reactive the controller, all the links to actuator are valid again for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit) diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h index 4ec872c2316..a249a6e85f9 100644 --- a/source/gameengine/GameLogic/SCA_IController.h +++ b/source/gameengine/GameLogic/SCA_IController.h @@ -100,7 +100,7 @@ public: } } } - + #ifdef WITH_PYTHON static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.cpp b/source/gameengine/GameLogic/SCA_IInputDevice.cpp index f4fce034c87..0808028fed3 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.cpp +++ b/source/gameengine/GameLogic/SCA_IInputDevice.cpp @@ -111,7 +111,7 @@ void SCA_IInputDevice::NextFrame() m_currentTable = 1 - m_currentTable; // cerr << "SCA_IInputDevice::NextFrame " << GetNumActiveEvents() << endl; - + for (int i=0;i<SCA_IInputDevice::KX_MAX_KEYS;i++) { switch (m_eventStatusTables[1 - m_currentTable][i].m_status) diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h index f306ae4f26b..6aea80f848d 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.h +++ b/source/gameengine/GameLogic/SCA_IInputDevice.h @@ -39,12 +39,12 @@ #include "MEM_guardedalloc.h" #endif -class SCA_InputEvent +class SCA_InputEvent { - + public: enum SCA_EnumInputs { - + KX_NO_INPUTSTATUS = 0, KX_JUSTACTIVATED, KX_ACTIVE, @@ -68,25 +68,25 @@ public: #define MOUSEX MOUSEMOVE #define MOUSEY ACTIONMOUSE -class SCA_IInputDevice +class SCA_IInputDevice { - + public: SCA_IInputDevice(); virtual ~SCA_IInputDevice(); enum KX_EnumInputs { - + KX_NOKEY = 0, - - // TIMERS - + + // TIMERS + KX_TIMER0, KX_TIMER1, KX_TIMER2, - + // SYSTEM /* Moved to avoid clashes with KX_RETKEY */ @@ -104,8 +104,8 @@ public: KX_WINQUIT, KX_Q_FIRSTTIME, /* sequence ends on 16 */ - - // standard keyboard + + // standard keyboard /* Because of the above preamble, KX_BEGINKEY is 15 ! This * means that KX_RETKEY on 13d (0Dh)) will double up with @@ -131,7 +131,7 @@ public: KX_PERIODKEY = 46, KX_PLUSKEY = 47, KX_ZEROKEY = 48, - + KX_ONEKEY, // =49 KX_TWOKEY, KX_THREEKEY, @@ -168,64 +168,64 @@ public: KX_XKEY, // =120 KX_YKEY, KX_ZKEY, // =122 - - - + + + KX_CAPSLOCKKEY, // 123 - + KX_LEFTCTRLKEY, // 124 KX_LEFTALTKEY, KX_RIGHTALTKEY, KX_RIGHTCTRLKEY, KX_RIGHTSHIFTKEY, KX_LEFTSHIFTKEY,// 129 - + KX_ESCKEY, // 130 KX_TABKEY, //131 - - + + KX_LINEFEEDKEY, // 132 KX_BACKSPACEKEY, KX_DELKEY, KX_SEMICOLONKEY, // 135 - - + + KX_QUOTEKEY, //136 KX_ACCENTGRAVEKEY, //137 - + KX_SLASHKEY, //138 KX_BACKSLASHKEY, KX_EQUALKEY, KX_LEFTBRACKETKEY, KX_RIGHTBRACKETKEY, // 142 - + KX_LEFTARROWKEY, // 145 KX_DOWNARROWKEY, KX_RIGHTARROWKEY, KX_UPARROWKEY, // 148 - + KX_PAD2 , KX_PAD4 , KX_PAD6 , KX_PAD8 , - + KX_PAD1 , KX_PAD3 , KX_PAD5 , KX_PAD7 , KX_PAD9 , - + KX_PADPERIOD, KX_PADSLASHKEY, - - - + + + KX_PAD0 , KX_PADMINUS, KX_PADENTER, KX_PADPLUSKEY, - - + + KX_F1KEY , KX_F2KEY , KX_F3KEY , @@ -247,7 +247,7 @@ public: KX_F19KEY, KX_OSKEY, - + KX_PAUSEKEY, KX_INSERTKEY, KX_HOMEKEY , @@ -257,41 +257,41 @@ public: // MOUSE KX_BEGINMOUSE, - + KX_BEGINMOUSEBUTTONS, KX_LEFTMOUSE, KX_MIDDLEMOUSE, KX_RIGHTMOUSE, - + KX_ENDMOUSEBUTTONS, - + KX_WHEELUPMOUSE, KX_WHEELDOWNMOUSE, KX_MOUSEX, KX_MOUSEY, - + KX_ENDMOUSE, KX_MAX_KEYS - + }; // enum protected: - /** + /** * m_eventStatusTables are two tables that contain current and previous * status of all events */ SCA_InputEvent m_eventStatusTables[2][SCA_IInputDevice::KX_MAX_KEYS]; - /** + /** * m_currentTable is index for m_keyStatusTable that toggle between 0 or 1 */ - int m_currentTable; + int m_currentTable; void ClearStatusTable(int tableid); public: @@ -307,9 +307,9 @@ public: * Get the number of remapping events (just_activated, just_released) */ virtual int GetNumJustEvents(); - + virtual void HookEscape(); - + /** * Next frame: we calculate the new key states. This goes as follows: * diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index d0a6e4540c9..d388317ce6a 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -88,7 +88,7 @@ CValue* SCA_ILogicBrick::Calc(VALUE_OPERATOR op, CValue *val) temp->Release(); return result; -} +} @@ -107,7 +107,7 @@ CValue* SCA_ILogicBrick::CalcFinal(VALUE_DATA_TYPE dtype, const STR_String& SCA_ILogicBrick::GetText() -{ +{ if (m_name.Length()) return m_name; @@ -137,8 +137,8 @@ void SCA_ILogicBrick::SetName(const char *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) && + 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)); } @@ -178,7 +178,7 @@ CValue* SCA_ILogicBrick::GetEvent() { return m_eventval->AddRef(); } - + return NULL; } @@ -244,10 +244,10 @@ PyObject *SCA_ILogicBrick::pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_D { SCA_ILogicBrick* self = static_cast<SCA_ILogicBrick*>(self_v); CValue* parent = self->GetParent(); - + if (parent) return parent->GetProxy(); - + Py_RETURN_NONE; } diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index f9ef18cc348..46c62f0258a 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -81,7 +81,7 @@ public: virtual double GetNumber(); virtual STR_String& GetName(); virtual void SetName(const char *); - + bool IsActive() { return m_bActive; @@ -101,7 +101,7 @@ public: } // insert in a QList at position corresponding to m_Execute_Priority - // inside a longer list that contains elements of other objects. + // inside a longer list that contains elements of other objects. // Sorting is done only between the elements of the same object. // head is the head of the combined list // current points to the first element of the object in the list, NULL if none yet @@ -138,7 +138,7 @@ public: #ifdef WITH_PYTHON // python methods - + static PyObject* pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); // check that attribute is a property @@ -152,14 +152,14 @@ public: }; -protected: +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 */ }; diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 526e695e792..c5eab53d67e 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -60,7 +60,7 @@ SCA_IObject::~SCA_IObject() (*its)->Delete(); //((CValue*)(*its))->Release(); } - SCA_ControllerList::iterator itc; + SCA_ControllerList::iterator itc; for (itc = m_controllers.begin(); !(itc == m_controllers.end()); ++itc) { //Use Delete for controller to ensure proper cleaning (expression controller) @@ -250,7 +250,7 @@ SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname) void SCA_IObject::Suspend() { - if ((!m_ignore_activity_culling) + if ((!m_ignore_activity_culling) && (!m_suspended)) { m_suspended = true; /* flag suspend for all sensors */ @@ -286,8 +286,8 @@ void SCA_IObject::SetState(unsigned int state) // 1) set the new state bits that are 1 // 2) clr the new state bits that are 0 // This to ensure continuity if a sensor is attached to two states - // that are switching state: no need to deactive and reactive the sensor - + // that are switching state: no need to deactive and reactive the sensor + tmpstate = m_state | state; if (tmpstate != m_state) { diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index 29a21fd8708..5c2dd351fb3 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -53,9 +53,9 @@ typedef std::vector<SCA_IObject *> SCA_ObjectList; class SCA_IObject : public CValue { - + Py_Header - + protected: friend class KX_StateActuator; friend class SCA_IActuator; @@ -110,7 +110,7 @@ protected: SG_QList* m_firstState; public: - + SCA_IObject(); virtual ~SCA_IObject(); @@ -148,7 +148,7 @@ public: } void RegisterActuator(SCA_IActuator* act); void UnregisterActuator(SCA_IActuator* act); - + void RegisterObject(SCA_IObject* objs); void UnregisterObject(SCA_IObject* objs); /** @@ -165,7 +165,7 @@ public: void SetCurrentTime(float currentTime) {} virtual void ReParentLogic(); - + /** * Set whether or not to ignore activity culling requests */ @@ -187,7 +187,7 @@ public: * Suspend all progress. */ void Suspend(void); - + /** * Resume progress */ @@ -216,7 +216,7 @@ public: // const class MT_Point3& ConvertPythonPylist(PyObject *pylist); virtual int GetGameObjectType() {return -1;} - + typedef enum ObjectTypes { OBJ_ARMATURE=0, OBJ_CAMERA=1, diff --git a/source/gameengine/GameLogic/SCA_IScene.cpp b/source/gameengine/GameLogic/SCA_IScene.cpp index a4c905096d7..07b7e008e83 100644 --- a/source/gameengine/GameLogic/SCA_IScene.cpp +++ b/source/gameengine/GameLogic/SCA_IScene.cpp @@ -39,8 +39,8 @@ SCA_DebugProp::SCA_DebugProp(): m_obj(NULL) SCA_DebugProp::~SCA_DebugProp() { - if (m_obj) - m_obj->Release(); + if (m_obj) + m_obj->Release(); } SCA_IScene::SCA_IScene() @@ -64,7 +64,7 @@ SCA_IScene::~SCA_IScene() } -std::vector<SCA_DebugProp*>& SCA_IScene::GetDebugProperties() +std::vector<SCA_DebugProp*>& SCA_IScene::GetDebugProperties() { return m_debugList; } @@ -129,7 +129,7 @@ void SCA_IScene::RemoveDebugProperty(class CValue *gameobj, void SCA_IScene::RemoveObjectDebugProperties(class CValue* gameobj) -{ +{ vector<SCA_DebugProp*>::iterator it = m_debugList.begin(); while (it != m_debugList.end()) { CValue* debugobj = (*it)->m_obj; diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h index b76b5636b13..e08c68f63e4 100644 --- a/source/gameengine/GameLogic/SCA_IScene.h +++ b/source/gameengine/GameLogic/SCA_IScene.h @@ -51,7 +51,7 @@ struct SCA_DebugProp ~SCA_DebugProp(); }; -class SCA_IScene +class SCA_IScene { std::vector<SCA_DebugProp*> m_debugList; public: @@ -63,7 +63,7 @@ public: virtual void RemoveObject(class CValue* gameobj)=0; virtual void DelayedRemoveObject(class CValue* gameobj)=0; //virtual void DelayedReleaseObject(class CValue* gameobj)=0; - + virtual void ReplaceMesh(class CValue* gameobj, void* meshobj, bool use_gfx, bool use_phys)=0; std::vector<SCA_DebugProp*>& GetDebugProperties(); @@ -74,8 +74,8 @@ public: void RemoveDebugProperty(class CValue *gameobj, const STR_String &name); void RemoveObjectDebugProperties(class CValue* gameobj); - virtual void Update2DFilter(std::vector<STR_String>& propNames, void* gameObj, - RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, + virtual void Update2DFilter(std::vector<STR_String>& propNames, void* gameObj, + RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) {} diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 66dd69f93c4..44fbe1d4692 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -70,12 +70,12 @@ SCA_ISensor::SCA_ISensor(SCA_IObject* gameobj, m_skipped_ticks = 0; m_state = false; m_prev_state = false; - + m_eventmgr = eventmgr; } -SCA_ISensor::~SCA_ISensor() +SCA_ISensor::~SCA_ISensor() { // intentionally empty } @@ -89,18 +89,18 @@ void SCA_ISensor::ProcessReplica() bool SCA_ISensor::IsPositiveTrigger() { bool result = false; - + if (m_eventval) { result = (m_eventval->GetNumber() != 0.0); } if (m_invert) { result = !result; } - + return result; } -void SCA_ISensor::SetPulseMode(bool posmode, +void SCA_ISensor::SetPulseMode(bool posmode, bool negmode, int skippedticks) { @@ -153,7 +153,7 @@ void SCA_ISensor::Init() void SCA_ISensor::DecLink() { m_links--; - if (m_links < 0) + if (m_links < 0) { printf("Warning: sensor %s has negative m_links: %d\n", m_name.Ptr(), m_links); m_links = 0; @@ -203,8 +203,8 @@ void SCA_ISensor::UnlinkController(SCA_IController* controller) return; } } - printf("Missing link from sensor %s:%s to controller %s:%s\n", - m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(), + printf("Missing link from sensor %s:%s to controller %s:%s\n", + m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(), controller->GetParent()->GetName().ReadPtr(), controller->GetName().ReadPtr()); } @@ -237,7 +237,7 @@ void SCA_ISensor::ActivateControllers(class SCA_LogicManager* logicmgr) void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr) { - + // calculate if a __triggering__ is wanted // don't evaluate a sensor that is not connected to any controller if (m_links && !m_suspended) { @@ -270,7 +270,7 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr) result = true; } m_pos_ticks = 0; - } + } } // negative pulse doesn't make sense in tap mode, skip if (m_neg_pulsemode && !m_tap) @@ -304,8 +304,8 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr) } if (!result && m_level) { - // This level sensor is connected to at least one controller that was just made - // active but it did not generate an event yet, do it now to those controllers only + // This level sensor is connected to at least one controller that was just made + // active but it did not generate an event yet, do it now to those controllers only for (vector<SCA_IController*>::const_iterator c= m_linkedcontrollers.begin(); c!=m_linkedcontrollers.end();++c) { @@ -314,7 +314,7 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr) logicmgr->AddTriggeredController(contr, this); } } - } + } } #ifdef WITH_PYTHON @@ -400,18 +400,18 @@ PyObject *SCA_ISensor::pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF { SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v); int status = 0; - if (self->GetState()) + if (self->GetState()) { - if (self->GetState() == self->GetPrevState()) + if (self->GetState() == self->GetPrevState()) { status = 2; } - else + else { status = 1; } } - else if (self->GetState() != self->GetPrevState()) + else if (self->GetState() != self->GetPrevState()) { status = 3; } diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 1e82f3ab11f..f8276b1c79f 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -40,7 +40,7 @@ /** * Interface Class for all logic Sensors. Implements - * pulsemode,pulsefrequency + * pulsemode,pulsefrequency * Use of SG_DList element: link sensors to their respective event manager * Head: SCA_EventManager::m_sensors * Use of SG_QList element: not used @@ -126,7 +126,7 @@ public: void SetPulseMode(bool posmode, bool negmode, int skippedticks); - + /** Set inversion of pulses on or off. */ void SetInvert(bool inv); /** set the level detection on or off */ @@ -156,13 +156,13 @@ public: /** Is this sensor switched off? */ bool IsSuspended(); - + /** get the state of the sensor: positive or negative */ bool GetState() { return m_state; } - + /** get the previous state of the sensor: positive or negative */ bool GetPrevState() { @@ -189,13 +189,13 @@ public: void IncLink() { if (!m_links++) RegisterToManager(); } void DecLink(); - bool IsNoLink() const + bool IsNoLink() const { return !m_links; } #ifdef WITH_PYTHON /* Python functions: */ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,reset); - + static PyObject* pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); @@ -206,13 +206,13 @@ public: static int pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - + enum SensorStatus { KX_SENSOR_INACTIVE = 0, KX_SENSOR_JUST_ACTIVATED, KX_SENSOR_ACTIVE, KX_SENSOR_JUST_DEACTIVATED - + }; #endif /* WITH_PYTHON */ }; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 56df9692e72..c98efd6db08 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -95,7 +95,7 @@ CValue* SCA_JoystickSensor::GetReplica() bool SCA_JoystickSensor::IsPositiveTrigger() -{ +{ bool result = m_istrig; if (m_invert) result = !result; @@ -108,10 +108,10 @@ bool SCA_JoystickSensor::Evaluate() SCA_Joystick *js = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex); bool result = false; bool reset = m_reset && m_level; - + if (js==NULL) /* no joystick - don't do anything */ return false; - + m_reset = false; switch (m_joymode) { @@ -128,10 +128,10 @@ bool SCA_JoystickSensor::Evaluate() * also note that this starts at 1 where functions its used * with expect a zero index. */ - + if (!js->IsTrigAxis() && !reset) /* No events from SDL? - don't bother */ return false; - + js->cSetPrecision(m_precision); if (m_bAllEvents) { if (js->aAxisPairIsPositive(m_axis-1)) { /* use zero based axis index internally */ @@ -164,7 +164,7 @@ bool SCA_JoystickSensor::Evaluate() /* Like KX_JOYSENSORMODE_AXIS but don't pair up axis */ if (!js->IsTrigAxis() && !reset) /* No events from SDL? - don't bother */ return false; - + /* No need for 'm_bAllEvents' check here since were only checking 1 axis */ js->cSetPrecision(m_precision); if (js->aAxisIsPositive(m_axis-1)) { /* use zero based axis index internally */ @@ -187,7 +187,7 @@ bool SCA_JoystickSensor::Evaluate() */ if (!js->IsTrigButton() && !reset) /* No events from SDL? - don't bother */ return false; - + if (( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) { m_istrig = 1; result = true; @@ -206,10 +206,10 @@ bool SCA_JoystickSensor::Evaluate() * numberof = m_hat -- max 4 * direction= m_hatf -- max 12 */ - + if (!js->IsTrigHat() && !reset) /* No events from SDL? - don't bother */ return false; - + if ((m_bAllEvents && js->GetHat(m_hat-1)) || js->aHatIsPositive(m_hat-1, m_hatf)) { m_istrig = 1; result = true; @@ -227,7 +227,7 @@ bool SCA_JoystickSensor::Evaluate() printf("Error invalid switch statement\n"); break; } - + /* if not all events are enabled, only send a positive pulse when * the button state changes */ if (!m_bAllEvents) { @@ -238,10 +238,10 @@ bool SCA_JoystickSensor::Evaluate() m_istrig_prev = m_istrig; } } - + if (reset) result = true; - + return result; } @@ -306,7 +306,7 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = { }; /* get button active list -------------------------------------------------- */ -const char SCA_JoystickSensor::GetButtonActiveList_doc[] = +const char SCA_JoystickSensor::GetButtonActiveList_doc[] = "getButtonActiveList\n" "\tReturns a list containing the indices of the button currently pressed.\n"; PyObject *SCA_JoystickSensor::PyGetButtonActiveList( ) @@ -315,7 +315,7 @@ PyObject *SCA_JoystickSensor::PyGetButtonActiveList( ) PyObject *ls = PyList_New(0); PyObject *value; int i; - + if (joy) { for (i=0; i < joy->GetNumberOfButtons(); i++) { if (joy->aButtonPressIsPositive(i)) { @@ -329,14 +329,14 @@ PyObject *SCA_JoystickSensor::PyGetButtonActiveList( ) } /* get button status -------------------------------------------------- */ -const char SCA_JoystickSensor::GetButtonStatus_doc[] = +const char SCA_JoystickSensor::GetButtonStatus_doc[] = "getButtonStatus(buttonIndex)\n" "\tReturns a bool of the current pressed state of the specified button.\n"; PyObject *SCA_JoystickSensor::PyGetButtonStatus( PyObject *args ) { SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex); int index; - + if (!PyArg_ParseTuple(args, "i:getButtonStatus", &index)) { return NULL; } @@ -350,14 +350,14 @@ PyObject *SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYAT { SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); - + int axis_index = (joy ? joy->GetNumberOfAxes() : 0); PyObject *list = PyList_New(axis_index); - + while (axis_index--) { PyList_SET_ITEM(list, axis_index, PyLong_FromLong(joy->GetAxisPosition(axis_index))); } - + return list; } @@ -365,12 +365,12 @@ PyObject *SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYAT { SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); - + if (self->m_joymode != KX_JOYSENSORMODE_AXIS_SINGLE) { PyErr_SetString(PyExc_AttributeError, "val = sensor.axisSingle: Joystick Sensor, not 'Single Axis' type"); return NULL; } - + return PyLong_FromLong(joy ? joy->GetAxisPosition(self->m_axis - 1) : 0); } @@ -378,14 +378,14 @@ PyObject *SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATT { SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); - + int hat_index = (joy ? joy->GetNumberOfHats() : 0); PyObject *list = PyList_New(hat_index); - + while (hat_index--) { PyList_SET_ITEM(list, hat_index, PyLong_FromLong(joy->GetHat(hat_index))); } - + return list; } @@ -393,7 +393,7 @@ PyObject *SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATT { SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); - + return PyLong_FromLong(joy ? joy->GetHat(self->m_hat - 1) : 0); } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index 6c6dc019a5e..30c2d1a30c3 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -39,7 +39,7 @@ class SCA_JoystickSensor :public SCA_ISensor { Py_Header - + /** * Axis 1-JOYAXIS_MAX, MUST be followed by m_axisf */ @@ -112,11 +112,11 @@ public: int hat, int hatf, bool allevents); virtual ~SCA_JoystickSensor(); virtual CValue* GetReplica(); - + virtual bool Evaluate(); virtual bool IsPositiveTrigger(); virtual void Init(); - + short int GetJoyIndex(void) { return m_joyindex; } @@ -139,7 +139,7 @@ public: static PyObject* pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_num_hats(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_connected(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - + /* attribute check */ static int CheckAxis(void *self, const PyAttributeDef*) @@ -160,7 +160,7 @@ public: sensor->m_hat = JOYHAT_MAX; return 0; } - + #endif /* WITH_PYTHON */ }; diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h index cd1cbf4adee..5a5c8e77b21 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardManager.h +++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h @@ -47,13 +47,13 @@ using namespace std; class SCA_KeyboardManager : public SCA_EventManager { class SCA_IInputDevice* m_inputDevice; - + public: SCA_KeyboardManager(class SCA_LogicManager* logicmgr,class SCA_IInputDevice* inputdev); virtual ~SCA_KeyboardManager(); bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode); - + virtual void NextFrame(); SCA_IInputDevice* GetInputDevice(); diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 414a685d358..a502158f453 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -106,19 +106,19 @@ short int SCA_KeyboardSensor::GetHotkey() bool SCA_KeyboardSensor::IsPositiveTrigger() -{ +{ bool result = (m_val != 0); if (m_invert) result = !result; - + return result; } bool SCA_KeyboardSensor::TriggerOnAllKeys() -{ +{ return m_bAllKeys; } @@ -131,7 +131,7 @@ bool SCA_KeyboardSensor::Evaluate() bool qual = true; bool qual_change = false; short int m_val_orig = m_val; - + SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); // cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n"; @@ -157,8 +157,8 @@ bool SCA_KeyboardSensor::Evaluate() for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++) { const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i); - switch (inevent.m_status) - { + switch (inevent.m_status) + { case SCA_InputEvent::KX_JUSTACTIVATED: justactivated = true; break; @@ -216,10 +216,10 @@ bool SCA_KeyboardSensor::Evaluate() // cerr << "======= SCA_KeyboardSensor::Evaluate:: peeking at key status" << endl; const SCA_InputEvent & inevent = inputdev->GetEventValue( (SCA_IInputDevice::KX_EnumInputs) m_hotkey); - + // cerr << "======= SCA_KeyboardSensor::Evaluate:: status: " << inevent.m_status << endl; - - + + /* Check qualifier keys * - see if the qualifiers we request are pressed - 'qual' true/false * - see if the qualifiers we request changed their state - 'qual_change' true/false @@ -260,12 +260,12 @@ bool SCA_KeyboardSensor::Evaluate() } } /* done reading qualifiers */ - + if (inevent.m_status == SCA_InputEvent::KX_NO_INPUTSTATUS) { if (m_val == 1) { - // this situation may occur after a scene suspend: the keyboard release + // this situation may occur after a scene suspend: the keyboard release // event was not captured, produce now the event off m_val = 0; result = true; @@ -282,14 +282,14 @@ bool SCA_KeyboardSensor::Evaluate() { m_val = 0; result = true; - } else + } else { if (inevent.m_status == SCA_InputEvent::KX_ACTIVE) { if (m_val == 0) { m_val = 1; - if (m_level) + if (m_level) { result = true; } @@ -298,14 +298,14 @@ bool SCA_KeyboardSensor::Evaluate() } } } - + /* Modify the key state based on qual(s) * Tested carefully. don't touch unless your really sure. * note, this will only change the results if key modifiers are set. * * When all modifiers and keys are positive * - pulse true - * + * * When ANY of the modifiers or main key become inactive, * - pulse false */ @@ -322,9 +322,9 @@ bool SCA_KeyboardSensor::Evaluate() } } /* done with key quals */ - + } - + if (reset) // force an event result = true; @@ -371,21 +371,21 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex, int unicode) } } } - + /** * Tests whether shift is pressed */ bool SCA_KeyboardSensor::IsShifted(void) { SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); - - if ( (inputdev->GetEventValue(SCA_IInputDevice::KX_RIGHTSHIFTKEY).m_status + + if ( (inputdev->GetEventValue(SCA_IInputDevice::KX_RIGHTSHIFTKEY).m_status == SCA_InputEvent::KX_ACTIVE) - || (inputdev->GetEventValue(SCA_IInputDevice::KX_RIGHTSHIFTKEY).m_status + || (inputdev->GetEventValue(SCA_IInputDevice::KX_RIGHTSHIFTKEY).m_status == SCA_InputEvent::KX_JUSTACTIVATED) - || (inputdev->GetEventValue(SCA_IInputDevice::KX_LEFTSHIFTKEY).m_status + || (inputdev->GetEventValue(SCA_IInputDevice::KX_LEFTSHIFTKEY).m_status == SCA_InputEvent::KX_ACTIVE) - || (inputdev->GetEventValue(SCA_IInputDevice::KX_LEFTSHIFTKEY).m_status + || (inputdev->GetEventValue(SCA_IInputDevice::KX_LEFTSHIFTKEY).m_status == SCA_InputEvent::KX_JUSTACTIVATED) ) { return true; @@ -395,7 +395,7 @@ bool SCA_KeyboardSensor::IsShifted(void) } } -void SCA_KeyboardSensor::LogKeystrokes(void) +void SCA_KeyboardSensor::LogKeystrokes(void) { SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); int num = inputdev->GetNumActiveEvents(); @@ -403,7 +403,7 @@ void SCA_KeyboardSensor::LogKeystrokes(void) /* weird loop, this one... */ if (num > 0) { - + int index = 0; /* Check on all keys whether they were pushed. This does not * untangle the ordering, so don't type too fast :) */ @@ -436,16 +436,16 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus, PyErr_SetString(PyExc_ValueError, "sensor.getKeyStatus(int): Keyboard Sensor, expected an int"); return NULL; } - + SCA_IInputDevice::KX_EnumInputs keycode = (SCA_IInputDevice::KX_EnumInputs)PyLong_AsLong(value); - + if ((keycode < SCA_IInputDevice::KX_BEGINKEY) || (keycode > SCA_IInputDevice::KX_ENDKEY)) { PyErr_SetString(PyExc_AttributeError, "sensor.getKeyStatus(int): Keyboard Sensor, invalid keycode specified!"); return NULL; } - + SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); const SCA_InputEvent & inevent = inputdev->GetEventValue(keycode); return PyLong_FromLong(inevent.m_status); @@ -497,11 +497,11 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = { PyObject *SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_KeyboardSensor* self = static_cast<SCA_KeyboardSensor*>(self_v); - + SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)self->m_eventmgr)->GetInputDevice(); PyObject *resultlist = PyList_New(0); - + for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++) { const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i); @@ -526,42 +526,42 @@ PyObject *SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBU char ToCharacter(int keyIndex, bool shifted) { /* numerals */ - if ( (keyIndex >= SCA_IInputDevice::KX_ZEROKEY) + if ( (keyIndex >= SCA_IInputDevice::KX_ZEROKEY) && (keyIndex <= SCA_IInputDevice::KX_NINEKEY) ) { if (shifted) { char numshift[] = ")!@#$%^&*("; - return numshift[keyIndex - '0']; + return numshift[keyIndex - '0']; } else { - return keyIndex - SCA_IInputDevice::KX_ZEROKEY + '0'; + return keyIndex - SCA_IInputDevice::KX_ZEROKEY + '0'; } } - + /* letters... always lowercase... is that desirable? */ - if ( (keyIndex >= SCA_IInputDevice::KX_AKEY) + if ( (keyIndex >= SCA_IInputDevice::KX_AKEY) && (keyIndex <= SCA_IInputDevice::KX_ZKEY) ) { if (shifted) { - return keyIndex - SCA_IInputDevice::KX_AKEY + 'A'; + return keyIndex - SCA_IInputDevice::KX_AKEY + 'A'; } else { - return keyIndex - SCA_IInputDevice::KX_AKEY + 'a'; + return keyIndex - SCA_IInputDevice::KX_AKEY + 'a'; } } - + if (keyIndex == SCA_IInputDevice::KX_SPACEKEY) { return ' '; } if (keyIndex == SCA_IInputDevice::KX_RETKEY || keyIndex == SCA_IInputDevice::KX_PADENTER) { return '\n'; } - - + + if (keyIndex == SCA_IInputDevice::KX_PADASTERKEY) { return '*'; } - + if (keyIndex == SCA_IInputDevice::KX_TABKEY) { return '\t'; } - + /* comma to period */ char commatoperiod[] = ",-."; char commatoperiodshifted[] = "<_>"; @@ -586,11 +586,11 @@ char ToCharacter(int keyIndex, bool shifted) return commatoperiod[2]; } } - + /* semicolon to rightbracket */ char semicolontorightbracket[] = ";\'`/\\=[]"; char semicolontorightbracketshifted[] = ":\"~\?|+{}"; - if ((keyIndex >= SCA_IInputDevice::KX_SEMICOLONKEY) + if ((keyIndex >= SCA_IInputDevice::KX_SEMICOLONKEY) && (keyIndex <= SCA_IInputDevice::KX_RIGHTBRACKETKEY)) { if (shifted) { return semicolontorightbracketshifted[keyIndex - SCA_IInputDevice::KX_SEMICOLONKEY]; @@ -598,11 +598,11 @@ char ToCharacter(int keyIndex, bool shifted) return semicolontorightbracket[keyIndex - SCA_IInputDevice::KX_SEMICOLONKEY]; } } - + /* keypad2 to padplus */ char pad2topadplus[] = "246813579. 0- +"; - if ((keyIndex >= SCA_IInputDevice::KX_PAD2) - && (keyIndex <= SCA_IInputDevice::KX_PADPLUSKEY)) { + if ((keyIndex >= SCA_IInputDevice::KX_PAD2) + && (keyIndex <= SCA_IInputDevice::KX_PADPLUSKEY)) { return pad2topadplus[keyIndex - SCA_IInputDevice::KX_PAD2]; } @@ -617,33 +617,33 @@ char ToCharacter(int keyIndex, bool shifted) * keycodes. */ bool IsPrintable(int keyIndex) { - /* only print + /* only print * - numerals: KX_ZEROKEY to KX_NINEKEY - * - alphas: KX_AKEY to KX_ZKEY. + * - alphas: KX_AKEY to KX_ZKEY. * - specials: KX_RETKEY, KX_PADASTERKEY, KX_PADCOMMAKEY to KX_PERIODKEY, * KX_TABKEY, KX_SEMICOLONKEY to KX_RIGHTBRACKETKEY, * KX_PAD2 to KX_PADPLUSKEY - * - delete and backspace: also printable in the sense that they modify + * - delete and backspace: also printable in the sense that they modify * the string * - retkey: should this be printable? * - virgule: prints a space... don't know which key that's supposed * to be... */ - if ( ((keyIndex >= SCA_IInputDevice::KX_ZEROKEY) + if ( ((keyIndex >= SCA_IInputDevice::KX_ZEROKEY) && (keyIndex <= SCA_IInputDevice::KX_NINEKEY)) - || ((keyIndex >= SCA_IInputDevice::KX_AKEY) - && (keyIndex <= SCA_IInputDevice::KX_ZKEY)) - || (keyIndex == SCA_IInputDevice::KX_SPACEKEY) + || ((keyIndex >= SCA_IInputDevice::KX_AKEY) + && (keyIndex <= SCA_IInputDevice::KX_ZKEY)) + || (keyIndex == SCA_IInputDevice::KX_SPACEKEY) || (keyIndex == SCA_IInputDevice::KX_RETKEY) || (keyIndex == SCA_IInputDevice::KX_PADENTER) - || (keyIndex == SCA_IInputDevice::KX_PADASTERKEY) - || (keyIndex == SCA_IInputDevice::KX_TABKEY) - || ((keyIndex >= SCA_IInputDevice::KX_COMMAKEY) - && (keyIndex <= SCA_IInputDevice::KX_PERIODKEY)) - || ((keyIndex >= SCA_IInputDevice::KX_SEMICOLONKEY) - && (keyIndex <= SCA_IInputDevice::KX_RIGHTBRACKETKEY)) - || ((keyIndex >= SCA_IInputDevice::KX_PAD2) - && (keyIndex <= SCA_IInputDevice::KX_PADPLUSKEY)) + || (keyIndex == SCA_IInputDevice::KX_PADASTERKEY) + || (keyIndex == SCA_IInputDevice::KX_TABKEY) + || ((keyIndex >= SCA_IInputDevice::KX_COMMAKEY) + && (keyIndex <= SCA_IInputDevice::KX_PERIODKEY)) + || ((keyIndex >= SCA_IInputDevice::KX_SEMICOLONKEY) + && (keyIndex <= SCA_IInputDevice::KX_RIGHTBRACKETKEY)) + || ((keyIndex >= SCA_IInputDevice::KX_PAD2) + && (keyIndex <= SCA_IInputDevice::KX_PADPLUSKEY)) || (keyIndex == SCA_IInputDevice::KX_DELKEY) || (keyIndex == SCA_IInputDevice::KX_BACKSPACEKEY) ) diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h index 51d7756bd1f..0429ccf9bd1 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h @@ -75,7 +75,7 @@ class SCA_KeyboardSensor : public SCA_ISensor * Log the keystrokes from the current input buffer. */ void LogKeystrokes(void); - + /** * Adds this key-code to the target prop. */ @@ -85,7 +85,7 @@ class SCA_KeyboardSensor : public SCA_ISensor * Tests whether shift is pressed. */ bool IsShifted(void); - + public: SCA_KeyboardSensor(class SCA_KeyboardManager* keybdmgr, short int hotkey, @@ -111,11 +111,11 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - // KeyEvents: + // KeyEvents: KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,getEventList); - // KeyStatus: + // KeyStatus: KX_PYMETHOD_DOC_O(SCA_KeyboardSensor,getKeyStatus); - + static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); #endif }; diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 978f6d6b836..0913f576d00 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -104,12 +104,12 @@ void SCA_LogicManager::RegisterGameMeshName(const STR_String& gamemeshname, void -void SCA_LogicManager::RegisterGameObj(void* blendobj, CValue* gameobj) +void SCA_LogicManager::RegisterGameObj(void* blendobj, CValue* gameobj) { m_map_blendobj_to_gameobj.insert(CHashedPtr(blendobj), gameobj); } -void SCA_LogicManager::UnregisterGameObj(void* blendobj, CValue* gameobj) +void SCA_LogicManager::UnregisterGameObj(void* blendobj, CValue* gameobj) { void **obp = m_map_blendobj_to_gameobj[CHashedPtr(blendobj)]; if (obp && (CValue*)(*obp) == gameobj) @@ -120,7 +120,7 @@ CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname) { STR_HashedString mn = gameobjname; CValue** gameptr = m_mapStringToGameObjects[mn]; - + if (gameptr) return *gameptr; @@ -128,7 +128,7 @@ CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname) } -CValue* SCA_LogicManager::FindGameObjByBlendObj(void* blendobj) +CValue* SCA_LogicManager::FindGameObjByBlendObj(void* blendobj) { void **obp= m_map_blendobj_to_gameobj[CHashedPtr(blendobj)]; return obp?(CValue*)(*obp):NULL; @@ -136,7 +136,7 @@ CValue* SCA_LogicManager::FindGameObjByBlendObj(void* blendobj) -void* SCA_LogicManager::FindBlendObjByGameMeshName(const STR_String& gamemeshname) +void* SCA_LogicManager::FindBlendObjByGameMeshName(const STR_String& gamemeshname) { STR_HashedString mn = gamemeshname; void **obp= m_map_gamemeshname_to_blendobj[mn]; @@ -225,15 +225,15 @@ void SCA_LogicManager::UpdateFrame(double curtime, bool frame) if (!actua->Update(curtime, frame)) { // this actuator is not active anymore, remove - actua->QDelink(); - actua->SetActive(false); + actua->QDelink(); + actua->SetActive(false); } else if (actua->IsNoLink()) { // This actuator has no more links but it still active // make sure it will get a negative event on next frame to stop it // Do this check after Update() rather than before to make sure // that all the actuators that are activated at same time than a state - // actuator have a chance to execute. + // actuator have a chance to execute. bool event = false; actua->RemoveAllEvents(); actua->AddEvent(event); diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index 7319bb537dd..231af077c8e 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -33,7 +33,7 @@ #ifdef _MSC_VER # pragma warning (disable:4786) -#endif +#endif #include <vector> //#include "CTR_Map.h" @@ -73,7 +73,7 @@ typedef std::map<class SCA_ISensor*,controllerlist > sensormap_t; class SCA_LogicManager { vector<class SCA_EventManager*> m_eventmanagers; - + // SG_DList: Head of objects having activated actuators // element: SCA_IObject::m_activeActuators SG_DList m_activeActuators; @@ -99,7 +99,7 @@ public: class SCA_ISensor* sensor); void RegisterToActuator(SCA_IController* controller, class SCA_IActuator* actuator); - + void BeginFrame(double curtime, double fixedtime); void UpdateFrame(double curtime, bool frame); void EndFrame(); @@ -113,7 +113,7 @@ public: void AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor); SCA_EventManager* FindEventManager(int eventmgrtype); vector<class SCA_EventManager*> GetEventManagers() { return m_eventmanagers; } - + void RemoveGameObject(const STR_String& gameobjname); /** @@ -122,14 +122,14 @@ public: void RemoveSensor(SCA_ISensor* sensor); void RemoveController(SCA_IController* controller); void RemoveActuator(SCA_IActuator* actuator); - + // for the scripting... needs a FactoryManager later (if we would have time... ;) void RegisterMeshName(const STR_String& meshname,void* mesh); void UnregisterMeshName(const STR_String& meshname,void* mesh); CTR_Map<STR_HashedString,void*>& GetMeshMap() { return m_mapStringToMeshes; } CTR_Map<STR_HashedString,void*>& GetActionMap() { return m_mapStringToActions; } - + void RegisterActionName(const STR_String& actname,void* action); void* GetActionByName (const STR_String& actname); @@ -144,8 +144,8 @@ public: void RegisterGameObj(void* blendobj, CValue* gameobj); void UnregisterGameObj(void* blendobj, CValue* gameobj); CValue* FindGameObjByBlendObj(void* blendobj); - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_LogicManager") #endif diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp index 51c03d1e350..1842b7a9ded 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.cpp +++ b/source/gameengine/GameLogic/SCA_MouseManager.cpp @@ -85,17 +85,17 @@ void SCA_MouseManager::NextFrame() // coordinates if (!mousesensor->IsSuspended()) { - const SCA_InputEvent& event1 = + const SCA_InputEvent& event1 = m_mousedevice->GetEventValue(SCA_IInputDevice::KX_MOUSEX); - const SCA_InputEvent& event2 = + const SCA_InputEvent& event2 = m_mousedevice->GetEventValue(SCA_IInputDevice::KX_MOUSEY); int mx = this->m_canvas->GetMouseX(event1.m_eventval); int my = this->m_canvas->GetMouseY(event2.m_eventval); - + mousesensor->setX(mx); mousesensor->setY(my); - + mousesensor->Activate(m_logicmgr); } } @@ -107,6 +107,6 @@ bool SCA_MouseManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode) /* We should guard for non-mouse events maybe? A rather silly side */ /* effect here is that position-change events are considered presses as */ /* well. */ - + return m_mousedevice->IsPressed(inputcode); } diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h index a57e52070a7..de932584ede 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.h +++ b/source/gameengine/GameLogic/SCA_MouseManager.h @@ -50,10 +50,10 @@ class SCA_MouseManager : public SCA_EventManager class SCA_IInputDevice* m_mousedevice; class RAS_ICanvas* m_canvas; - + unsigned short m_xpos; // Cached location of the mouse pointer unsigned short m_ypos; - + public: SCA_MouseManager(class SCA_LogicManager* logicmgr,class SCA_IInputDevice* mousedev, class RAS_ICanvas* canvas); virtual ~SCA_MouseManager(); diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 2479e859dea..c1ad1c4543a 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -48,7 +48,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, +SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, int startx,int starty, short int mousemode, SCA_IObject* gameobj) @@ -69,7 +69,7 @@ void SCA_MouseSensor::Init() m_reset = true; } -SCA_MouseSensor::~SCA_MouseSensor() +SCA_MouseSensor::~SCA_MouseSensor() { /* Nothing to be done here. */ } @@ -78,8 +78,8 @@ void SCA_MouseSensor::UpdateHotkey(void *self) { // gosh, this function is so damn stupid // its here because of a design mistake in the mouse sensor, it should only - // have 3 trigger modes (button, wheel, move), and let the user set the - // hotkey separately, like the other sensors. but instead it has a mode for + // have 3 trigger modes (button, wheel, move), and let the user set the + // hotkey separately, like the other sensors. but instead it has a mode for // each friggin key and i have to update the hotkey based on it... genius! SCA_MouseSensor* sensor = reinterpret_cast<SCA_MouseSensor*>(self); @@ -121,21 +121,21 @@ bool SCA_MouseSensor::IsPositiveTrigger() bool result = (m_val != 0); if (m_invert) result = !result; - + return result; } short int SCA_MouseSensor::GetModeKey() -{ +{ return m_mousemode; } SCA_IInputDevice::KX_EnumInputs SCA_MouseSensor::GetHotKey() -{ +{ return m_hotkey; } @@ -195,22 +195,22 @@ bool SCA_MouseSensor::Evaluate() { m_val = 1; result = true; - } + } else if (eventX.m_status == SCA_InputEvent::KX_JUSTRELEASED || eventY.m_status == SCA_InputEvent::KX_JUSTRELEASED ) { m_val = 0; result = true; - } + } else //KX_NO_IMPUTSTATUS - { + { if (m_val == 1) { m_val = 0; result = true; } } - + break; } default: @@ -251,19 +251,19 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus, if (PyLong_Check(value)) { SCA_IInputDevice::KX_EnumInputs button = (SCA_IInputDevice::KX_EnumInputs)PyLong_AsLong(value); - + if ((button < SCA_IInputDevice::KX_LEFTMOUSE) || (button > SCA_IInputDevice::KX_RIGHTMOUSE)) { PyErr_SetString(PyExc_ValueError, "sensor.getButtonStatus(int): Mouse Sensor, invalid button specified!"); return NULL; } - + SCA_IInputDevice* mousedev = ((SCA_MouseManager *)m_eventmgr)->GetInputDevice(); const SCA_InputEvent& event = mousedev->GetEventValue(button); return PyLong_FromLong(event.m_status); } - + Py_RETURN_NONE; } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h index 2660aaeacb5..53785fa40da 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.h +++ b/source/gameengine/GameLogic/SCA_MouseSensor.h @@ -40,7 +40,7 @@ class SCA_MouseSensor : public SCA_ISensor { Py_Header - + /** * Use SCA_IInputDevice values to encode the mouse mode for now. */ @@ -51,12 +51,12 @@ class SCA_MouseSensor : public SCA_ISensor */ bool m_triggermode; /** - * Remember the last state update + * Remember the last state update */ int m_val; SCA_IInputDevice::KX_EnumInputs m_hotkey; - + /** * valid x coordinate, MUST be followed by y coordinate */ @@ -66,7 +66,7 @@ class SCA_MouseSensor : public SCA_ISensor * valid y coordinate */ short m_y; - + public: /** * Allowable modes for the trigger status of the mouse sensor. @@ -86,7 +86,7 @@ class SCA_MouseSensor : public SCA_ISensor }; bool isValid(KX_MOUSESENSORMODE); - + SCA_MouseSensor(class SCA_MouseManager* keybdmgr, int startx,int starty, short int mousemode, @@ -109,7 +109,7 @@ class SCA_MouseSensor : public SCA_ISensor /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - + static int UpdateHotkeyPy(void *self, const PyAttributeDef *); // get button status diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp index 6a00c110e2b..ce98c8a5d7c 100644 --- a/source/gameengine/GameLogic/SCA_NANDController.cpp +++ b/source/gameengine/GameLogic/SCA_NANDController.cpp @@ -71,7 +71,7 @@ void SCA_NANDController::Trigger(SCA_LogicManager* logicmgr) break; } } - + for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); !(i==m_linkedactuators.end());i++) { diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp index fb09617e060..16a82a6d23e 100644 --- a/source/gameengine/GameLogic/SCA_NORController.cpp +++ b/source/gameengine/GameLogic/SCA_NORController.cpp @@ -71,7 +71,7 @@ void SCA_NORController::Trigger(SCA_LogicManager* logicmgr) break; } } - + for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); !(i==m_linkedactuators.end());i++) { diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp index 8a59bdf1b89..f758c096cc0 100644 --- a/source/gameengine/GameLogic/SCA_ORController.cpp +++ b/source/gameengine/GameLogic/SCA_ORController.cpp @@ -78,7 +78,7 @@ void SCA_ORController::Trigger(SCA_LogicManager* logicmgr) if (sensor->GetState()) sensorresult = true; is++; } - + for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); !(i==m_linkedactuators.end());i++) { diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index f2907ca6361..87b0503ede8 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -89,9 +89,9 @@ bool SCA_PropertyActuator::Update() CParser parser; parser.SetContext( propowner->AddRef()); - + CExpression* userexpr= NULL; - + if (m_type==KX_ACT_PROP_TOGGLE) { /* don't use */ @@ -127,7 +127,7 @@ bool SCA_PropertyActuator::Update() case KX_ACT_PROP_ASSIGN: { - + CValue* newval = userexpr->Calculate(); CValue* oldprop = propowner->GetProperty(m_propname); if (oldprop) @@ -184,11 +184,11 @@ bool SCA_PropertyActuator::Update() userexpr->Release(); } - + return result; } - bool + bool SCA_PropertyActuator:: @@ -203,7 +203,7 @@ isValid( } - CValue* + CValue* SCA_PropertyActuator:: diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h index 228ecf94bc4..57483bd0e05 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.h +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h @@ -37,7 +37,7 @@ class SCA_PropertyActuator : public SCA_IActuator { Py_Header - + enum KX_ACT_PROP_MODE { KX_ACT_PROP_NODEF = 0, KX_ACT_PROP_ASSIGN, @@ -47,10 +47,10 @@ class SCA_PropertyActuator : public SCA_IActuator KX_ACT_PROP_LEVEL, KX_ACT_PROP_MAX }; - + /**check whether this value is valid */ bool isValid(KX_ACT_PROP_MODE mode); - + int m_type; STR_String m_propname; STR_String m_exprtxt; @@ -70,7 +70,7 @@ public: ~SCA_PropertyActuator(); - CValue* + CValue* GetReplica( ); @@ -78,13 +78,13 @@ public: virtual bool UnlinkObject(SCA_IObject* clientobj); virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map); - virtual bool + virtual bool Update(); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - + }; #endif /* __KX_PROPERTYACTUATOR_DOC */ diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index e34a5296139..f823320a417 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -86,7 +86,7 @@ CValue* SCA_PropertySensor::GetReplica() // m_range_expr must be recalculated on replica! replica->ProcessReplica(); replica->Init(); - + return replica; } @@ -113,7 +113,7 @@ bool SCA_PropertySensor::Evaluate() { bool result = CheckPropertyCondition(); bool reset = m_reset && m_level; - + m_reset = false; if (m_lastresult!=result) { @@ -147,7 +147,7 @@ bool SCA_PropertySensor::CheckPropertyCondition() m_checkpropval.Upper(); } result = (testprop == m_checkpropval); - + /* Patch: floating point values cant use strings usefully since you can have "0.0" == "0.0000" * this could be made into a generic Value class function for comparing values with a string. */ @@ -155,7 +155,7 @@ bool SCA_PropertySensor::CheckPropertyCondition() float f; if (sscanf(m_checkpropval.ReadPtr(), "%f", &f) == 1) { result = (f == ((CFloatValue *)orgprop)->GetFloat()); - } + } else { /* error */ } @@ -215,7 +215,7 @@ bool SCA_PropertySensor::CheckPropertyCondition() case KX_PROPSENSOR_CHANGED: { CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); - + if (!orgprop->IsError()) { if (m_previoustext != orgprop->GetText()) diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index f9cfb5fb1d2..eac1f22cccb 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -63,7 +63,7 @@ public: }; const STR_String S_KX_PROPSENSOR_EQ_STRING; - + SCA_PropertySensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, const STR_String& propname, diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index fd2e723741c..8da660686ef 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -68,7 +68,7 @@ SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode) #endif { - + } #if 0 @@ -90,10 +90,10 @@ SCA_PythonController::~SCA_PythonController() #ifdef WITH_PYTHON //printf("released python byte script\n"); - + Py_XDECREF(m_bytecode); Py_XDECREF(m_function); - + if (m_pythondictionary) { // break any circular references in the dictionary PyDict_Clear(m_pythondictionary); @@ -112,14 +112,14 @@ CValue* SCA_PythonController::GetReplica() /* why is this needed at all??? - m_bytecode is NULL'd below so this doesnt make sense * but removing it crashes blender (with YoFrankie). so leave in for now - Campbell */ Py_XINCREF(replica->m_bytecode); - + Py_XINCREF(replica->m_function); // this is ok since its not set to NULL replica->m_bModified = replica->m_bytecode == NULL; - + // The replica->m_pythondictionary is stolen - replace with a copy. if (m_pythondictionary) replica->m_pythondictionary = PyDict_Copy(m_pythondictionary); - + #if 0 // The other option is to incref the replica->m_pythondictionary - // the replica objects can then share data. @@ -128,7 +128,7 @@ CValue* SCA_PythonController::GetReplica() #endif #endif /* WITH_PYTHON */ - + // this will copy properties and so on... replica->ProcessReplica(); @@ -138,7 +138,7 @@ CValue* SCA_PythonController::GetReplica() void SCA_PythonController::SetScriptText(const STR_String& text) -{ +{ m_scriptText = text; m_bModified = true; } @@ -160,19 +160,19 @@ void SCA_PythonController::SetNamespace(PyObject* pythondictionary) Py_DECREF(m_pythondictionary); } m_pythondictionary = PyDict_Copy(pythondictionary); /* new reference */ - + /* Without __file__ set the sys.argv[0] is used for the filename * which ends up with lines from the blender binary being printed in the console */ PyObject *value = PyUnicode_From_STR_String(m_scriptName); PyDict_SetItemString(m_pythondictionary, "__file__", value); Py_DECREF(value); - + } #endif bool SCA_PythonController::IsTriggered(class SCA_ISensor* sensor) { - if (std::find(m_triggeredSensors.begin(), m_triggeredSensors.end(), sensor) != + if (std::find(m_triggeredSensors.begin(), m_triggeredSensors.end(), sensor) != m_triggeredSensors.end()) { return true; @@ -201,7 +201,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value) // we don't want to crash gameengine/blender by python scripts std::vector<SCA_IActuator*> lacts = m_sCurrentController->GetLinkedActuators(); std::vector<SCA_IActuator*>::iterator it; - + if (PyUnicode_Check(value)) { /* get the actuator from the name */ const char *name= _PyUnicode_AsString(value); @@ -278,7 +278,7 @@ void SCA_PythonController::ErrorPrint(const char *error_msg) } printf("%s - object '%s', controller '%s':\n", error_msg, obj_name, ctr_name); PyErr_Print(); - + /* Added in 2.48a, the last_traceback can reference Objects for example, increasing * their user count. Not to mention holding references to wrapped data. * This is especially bad when the PyObject for the wrapped data is freed, after blender @@ -291,16 +291,16 @@ bool SCA_PythonController::Compile() { //printf("py script modified '%s'\n", m_scriptName.Ptr()); m_bModified= false; - + // if a script already exists, decref it before replace the pointer to a new script if (m_bytecode) { Py_DECREF(m_bytecode); m_bytecode=NULL; } - + // recompile the scripttext into bytecode m_bytecode = Py_CompileString(m_scriptText.Ptr(), m_scriptName.Ptr(), Py_file_input); - + if (m_bytecode) { return true; } else { @@ -317,7 +317,7 @@ bool SCA_PythonController::Import() /* in case we re-import */ Py_XDECREF(m_function); m_function= NULL; - + STR_String mod_path_str= m_scriptText; /* just for storage, use C style string access */ char *mod_path= mod_path_str.Ptr(); char *function_string; @@ -361,26 +361,26 @@ bool SCA_PythonController::Import() printf("Python module error in object '%s', controller '%s':\n '%s' module found but function missing\n", GetParent()->GetName().Ptr(), GetName().Ptr(), m_scriptText.Ptr()); return false; } - + if (!PyCallable_Check(m_function)) { Py_DECREF(m_function); m_function = NULL; printf("Python module function error in object '%s', controller '%s':\n '%s' not callable\n", GetParent()->GetName().Ptr(), GetName().Ptr(), m_scriptText.Ptr()); return false; } - + m_function_argc = 0; /* rare cases this could be a function that isn't defined in python, assume zero args */ if (PyFunction_Check(m_function)) { m_function_argc= ((PyCodeObject *)PyFunction_GET_CODE(m_function))->co_argcount; } - + if (m_function_argc > 1) { Py_DECREF(m_function); m_function = NULL; printf("Python module function in object '%s', controller '%s':\n '%s' takes %d args, should be zero or 1 controller arg\n", GetParent()->GetName().Ptr(), GetName().Ptr(), m_scriptText.Ptr(), m_function_argc); return false; } - + return true; } @@ -391,7 +391,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) PyObject *excdict= NULL; PyObject *resultobj= NULL; - + switch (m_mode) { case SCA_PYEXEC_SCRIPT: { @@ -454,7 +454,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) Py_DECREF(resultobj); else ErrorPrint("Python script error"); - + if (excdict) /* Only for SCA_PYEXEC_SCRIPT types */ { /* clear after PyErrPrint - seems it can be using @@ -463,7 +463,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) //PyDict_Clear(excdict); Py_DECREF(excdict); } - + m_triggeredSensors.clear(); m_sCurrentController = NULL; } @@ -474,11 +474,11 @@ PyObject *SCA_PythonController::PyActivate(PyObject *value) PyErr_SetString(PyExc_SystemError, "Cannot activate an actuator from a non-active controller"); return NULL; } - + SCA_IActuator* actu = LinkedActuatorFromPy(value); if (actu==NULL) return NULL; - + m_logicManager->AddActiveActuator((SCA_IActuator*)actu, true); Py_RETURN_NONE; } @@ -489,11 +489,11 @@ PyObject *SCA_PythonController::PyDeActivate(PyObject *value) PyErr_SetString(PyExc_SystemError, "Cannot deactivate an actuator from a non-active controller"); return NULL; } - + SCA_IActuator* actu = LinkedActuatorFromPy(value); if (actu==NULL) return NULL; - + m_logicManager->AddActiveActuator((SCA_IActuator*)actu, false); Py_RETURN_NONE; } @@ -512,18 +512,18 @@ PyObject *SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRI int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { SCA_PythonController* self = static_cast<SCA_PythonController*>(self_v); - + const char *scriptArg = _PyUnicode_AsString(value); - + if (scriptArg==NULL) { PyErr_SetString(PyExc_TypeError, "controller.script = string: Python Controller, expected a string script text"); return PY_SET_ATTR_FAIL; } - /* set scripttext sets m_bModified to true, + /* set scripttext sets m_bModified to true, * so next time the script is needed, a reparse into byte code is done */ self->SetScriptText(scriptArg); - + return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 11241da9117..ffb23c152ea 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -52,7 +52,7 @@ class SCA_PythonController : public SCA_IController bool m_debug; /* use with SCA_PYEXEC_MODULE for reloading every logic run */ int m_mode; - + protected: STR_String m_scriptText; STR_String m_scriptName; @@ -61,7 +61,7 @@ class SCA_PythonController : public SCA_IController PyObject* m_pythonfunction; /* for SCA_PYEXEC_MODULE only */ #endif std::vector<class SCA_ISensor*> m_triggeredSensors; - + public: enum SCA_PyExecMode { @@ -81,7 +81,7 @@ class SCA_PythonController : public SCA_IController virtual CValue* GetReplica(); virtual void Trigger(class SCA_LogicManager* logicmgr); - + void SetScriptText(const STR_String& text); void SetScriptName(const STR_String& name); #ifdef WITH_PYTHON @@ -94,7 +94,7 @@ class SCA_PythonController : public SCA_IController bool Compile(); bool Import(); void ErrorPrint(const char *error_msg); - + #ifdef WITH_PYTHON static const char *sPyGetCurrentController__doc__; static PyObject *sPyGetCurrentController(PyObject *self); @@ -103,13 +103,13 @@ class SCA_PythonController : public SCA_IController PyObject *args); static SCA_IActuator* LinkedActuatorFromPy(PyObject *value); - + KX_PYMETHOD_O(SCA_PythonController,Activate); KX_PYMETHOD_O(SCA_PythonController,DeActivate); KX_PYMETHOD_O(SCA_PythonController,SetScript); KX_PYMETHOD_NOARGS(SCA_PythonController,GetScript); - + static PyObject* pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif diff --git a/source/gameengine/GameLogic/SCA_PythonJoystick.cpp b/source/gameengine/GameLogic/SCA_PythonJoystick.cpp index 9b24ad7bcf2..06f42e84147 100644 --- a/source/gameengine/GameLogic/SCA_PythonJoystick.cpp +++ b/source/gameengine/GameLogic/SCA_PythonJoystick.cpp @@ -125,7 +125,7 @@ PyObject* SCA_PythonJoystick::pyattr_get_num_x(void *self_v, const KX_PYATTRIBUT PyObject* SCA_PythonJoystick::pyattr_get_active_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonJoystick* self = static_cast<SCA_PythonJoystick*>(self_v); - + const int button_number = self->m_joystick->GetNumberOfButtons(); PyObject *list = PyList_New(0); @@ -145,25 +145,25 @@ PyObject* SCA_PythonJoystick::pyattr_get_active_buttons(void *self_v, const KX_P PyObject* SCA_PythonJoystick::pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonJoystick* self = static_cast<SCA_PythonJoystick*>(self_v); - + int hat_index = self->m_joystick->GetNumberOfHats(); PyObject *list = PyList_New(hat_index); - + while (hat_index--) { PyList_SET_ITEM(list, hat_index, PyLong_FromLong(self->m_joystick->GetHat(hat_index))); } - + return list; } PyObject* SCA_PythonJoystick::pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonJoystick* self = static_cast<SCA_PythonJoystick*>(self_v); - + int axis_index = self->m_joystick->GetNumberOfAxes(); PyObject *list = PyList_New(axis_index); int position; - + while (axis_index--) { position = self->m_joystick->GetAxisPosition(axis_index); @@ -175,7 +175,7 @@ PyObject* SCA_PythonJoystick::pyattr_get_axis_values(void *self_v, const KX_PYAT else PyList_SET_ITEM(list, axis_index, PyFloat_FromDouble(position/(double)SHRT_MAX)); } - + return list; } diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp index 9a96a7b0334..388ee5b9d4f 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp @@ -112,7 +112,7 @@ PyAttributeDef SCA_PythonKeyboard::Attributes[] = { PyObject *SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonKeyboard* self = static_cast<SCA_PythonKeyboard*>(self_v); - + for (int i = SCA_IInputDevice::KX_BEGINKEY; i <= SCA_IInputDevice::KX_ENDKEY; i++) { const SCA_InputEvent & inevent = self->m_keyboard->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i); PyObject *key = PyLong_FromLong(i); @@ -132,10 +132,10 @@ PyObject *SCA_PythonKeyboard::pyattr_get_active_events(void *self_v, const KX_PY SCA_PythonKeyboard* self = static_cast<SCA_PythonKeyboard*>(self_v); PyDict_Clear(self->m_event_dict); - + for (int i = SCA_IInputDevice::KX_BEGINKEY; i <= SCA_IInputDevice::KX_ENDKEY; i++) { const SCA_InputEvent & inevent = self->m_keyboard->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i); - + if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS) { PyObject *key = PyLong_FromLong(i); PyObject *value = PyLong_FromLong(inevent.m_status); diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.cpp b/source/gameengine/GameLogic/SCA_PythonMouse.cpp index 184b306a665..111d8abe8c5 100644 --- a/source/gameengine/GameLogic/SCA_PythonMouse.cpp +++ b/source/gameengine/GameLogic/SCA_PythonMouse.cpp @@ -95,7 +95,7 @@ PyAttributeDef SCA_PythonMouse::Attributes[] = { PyObject *SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v); - + for (int i = SCA_IInputDevice::KX_BEGINMOUSE; i <= SCA_IInputDevice::KX_ENDMOUSE; i++) { const SCA_InputEvent &inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i); PyObject *key = PyLong_FromLong(i); @@ -115,10 +115,10 @@ PyObject *SCA_PythonMouse::pyattr_get_active_events(void *self_v, const KX_PYATT SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v); PyDict_Clear(self->m_event_dict); - + for (int i = SCA_IInputDevice::KX_BEGINMOUSE; i <= SCA_IInputDevice::KX_ENDMOUSE; i++) { const SCA_InputEvent &inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i); - + if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS) { PyObject *key = PyLong_FromLong(i); diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 8d75be9089d..121be5f003e 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -47,7 +47,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj, +SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj, long seed, SCA_RandomActuator::KX_RANDOMACT_MODE mode, float para1, @@ -62,14 +62,14 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj, m_base = new SCA_RandomNumberGenerator(seed); m_counter = 0; enforceConstraints(); -} +} SCA_RandomActuator::~SCA_RandomActuator() { m_base->Release(); -} +} @@ -112,7 +112,7 @@ bool SCA_RandomActuator::Update() break; case KX_RANDOMACT_BOOL_UNIFORM: { /* flip a coin */ - bool res; + bool res; if (m_counter > 31) { m_previous = m_base->Draw(); res = ((m_previous & 0x1) == 0); @@ -138,7 +138,7 @@ bool SCA_RandomActuator::Update() break; case KX_RANDOMACT_INT_UNIFORM: { /* uniform (toss a die) */ - int res; + int res; /* The [0, 1] interval is projected onto the [min, max+1] domain, */ /* and then rounded. */ res = (int)floor( ((m_parameter2 - m_parameter1 + 1) * m_base->DrawFloat()) + m_parameter1); @@ -267,7 +267,7 @@ void SCA_RandomActuator::enforceConstraints() ; /* Nothing to be done here. We allow uniform distro's to have */ /* 'funny' domains, i.e. max < min. This does not give problems. */ break; - case KX_RANDOMACT_BOOL_BERNOUILLI: + case KX_RANDOMACT_BOOL_BERNOUILLI: /* clamp to [0, 1] */ if (m_parameter1 < 0.0) { m_parameter1 = 0.0; @@ -275,19 +275,19 @@ void SCA_RandomActuator::enforceConstraints() m_parameter1 = 1.0; } break; - case KX_RANDOMACT_INT_POISSON: + case KX_RANDOMACT_INT_POISSON: /* non-negative */ if (m_parameter1 < 0.0) { m_parameter1 = 0.0; } break; - case KX_RANDOMACT_FLOAT_NORMAL: + case KX_RANDOMACT_FLOAT_NORMAL: /* standard dev. is non-negative */ if (m_parameter2 < 0.0) { m_parameter2 = 0.0; } break; - case KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL: + case KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL: /* halflife must be non-negative */ if (m_parameter1 < 0.0) { m_parameter1 = 0.0; @@ -375,22 +375,22 @@ int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setBoolConst, "setBoolConst(value)\n" "\t- value: 0 or 1\n" -"\tSet this generator to produce a constant boolean value.\n") +"\tSet this generator to produce a constant boolean value.\n") { int paraArg; if (!PyArg_ParseTuple(args, "i:setBoolConst", ¶Arg)) { return NULL; } - + m_distribution = KX_RANDOMACT_BOOL_CONST; m_parameter1 = (paraArg) ? 1.0 : 0.0; - + Py_RETURN_NONE; } /* 12. setBoolUniform, */ KX_PYMETHODDEF_DOC_NOARGS(SCA_RandomActuator, setBoolUniform, "setBoolUniform()\n" -"\tSet this generator to produce true and false, each with 50%% chance of occurring\n") +"\tSet this generator to produce true and false, each with 50%% chance of occurring\n") { /* no args */ m_distribution = KX_RANDOMACT_BOOL_UNIFORM; @@ -407,7 +407,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setBoolBernouilli, if (!PyArg_ParseTuple(args, "f:setBoolBernouilli", ¶Arg)) { return NULL; } - + m_distribution = KX_RANDOMACT_BOOL_BERNOUILLI; m_parameter1 = paraArg; enforceConstraints(); @@ -417,13 +417,13 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setBoolBernouilli, KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setIntConst, "setIntConst(value)\n" "\t- value: integer\n" -"\tAlways return value\n") +"\tAlways return value\n") { int paraArg; if (!PyArg_ParseTuple(args, "i:setIntConst", ¶Arg)) { return NULL; } - + m_distribution = KX_RANDOMACT_INT_CONST; m_parameter1 = paraArg; enforceConstraints(); @@ -441,7 +441,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setIntUniform, if (!PyArg_ParseTuple(args, "ii:setIntUniform", ¶Arg1, ¶Arg2)) { return NULL; } - + m_distribution = KX_RANDOMACT_INT_UNIFORM; m_parameter1 = paraArg1; m_parameter2 = paraArg2; @@ -460,7 +460,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setIntPoisson, if (!PyArg_ParseTuple(args, "f:setIntPoisson", ¶Arg)) { return NULL; } - + m_distribution = KX_RANDOMACT_INT_POISSON; m_parameter1 = paraArg; enforceConstraints(); @@ -476,7 +476,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatConst, if (!PyArg_ParseTuple(args, "f:setFloatConst", ¶Arg)) { return NULL; } - + m_distribution = KX_RANDOMACT_FLOAT_CONST; m_parameter1 = paraArg; enforceConstraints(); @@ -494,7 +494,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatUniform, if (!PyArg_ParseTuple(args, "ff:setFloatUniform", ¶Arg1, ¶Arg2)) { return NULL; } - + m_distribution = KX_RANDOMACT_FLOAT_UNIFORM; m_parameter1 = paraArg1; m_parameter2 = paraArg2; @@ -513,7 +513,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNormal, if (!PyArg_ParseTuple(args, "ff:setFloatNormal", ¶Arg1, ¶Arg2)) { return NULL; } - + m_distribution = KX_RANDOMACT_FLOAT_NORMAL; m_parameter1 = paraArg1; m_parameter2 = paraArg2; @@ -521,7 +521,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNormal, Py_RETURN_NONE; } /* 20. setFloatNegativeExponential, */ -KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential, +KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential, "setFloatNegativeExponential(half_life)\n" "\t- half_life: float\n" "\tReturn negative-exponentially distributed numbers. The half-life 'time'\n" @@ -531,7 +531,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential, if (!PyArg_ParseTuple(args, "f:setFloatNegativeExponential", ¶Arg)) { return NULL; } - + m_distribution = KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL; m_parameter1 = paraArg; enforceConstraints(); diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h index 32b29fc4f43..0bce4b765f6 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.h +++ b/source/gameengine/GameLogic/SCA_RandomActuator.h @@ -41,11 +41,11 @@ class SCA_RandomActuator : public SCA_IActuator Py_Header /** Property to assign to */ STR_String m_propname; - - /** First parameter. The meaning of the parameters depends on the + + /** First parameter. The meaning of the parameters depends on the * distribution */ float m_parameter1; - /** Second parameter. The meaning of the parameters depends on the + /** Second parameter. The meaning of the parameters depends on the * distribution */ float m_parameter2; @@ -60,7 +60,7 @@ class SCA_RandomActuator : public SCA_IActuator /** apply constraints for the chosen distribution to the parameters */ void enforceConstraints(void); - + public: enum KX_RANDOMACT_MODE { @@ -79,7 +79,7 @@ class SCA_RandomActuator : public SCA_IActuator }; /** distribution type */ KX_RANDOMACT_MODE m_distribution; - + SCA_RandomActuator(class SCA_IObject* gameobj, long seed, KX_RANDOMACT_MODE mode, @@ -88,12 +88,12 @@ class SCA_RandomActuator : public SCA_IActuator const STR_String &propName); virtual ~SCA_RandomActuator(); virtual bool Update(); - + virtual CValue* GetReplica(); virtual void ProcessReplica(); #ifdef WITH_PYTHON - + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp index eca678f4e89..e6c1b51ea23 100644 --- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp @@ -2,8 +2,8 @@ * \ingroup gamelogic */ /** - * Generate random numbers that can be used by other components. We - * convert to different types/distributions elsewhere. This just + * Generate random numbers that can be used by other components. We + * convert to different types/distributions elsewhere. This just * delivers a clean, random bitvector. * */ @@ -29,7 +29,7 @@ /* See the GNU Library General Public License for more details. */ /* You should have received a copy of the GNU Library General */ /* Public License along with this library; if not, write to the */ -/* Free Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA */ +/* Free Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA */ /* 02110-1301, USA */ /* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. */ @@ -39,14 +39,14 @@ #include <limits.h> #include "SCA_RandomNumberGenerator.h" -/* Period parameters */ +/* Period parameters */ #define N 624 #define M 397 #define MATRIX_A 0x9908b0df /* constant vector a */ #define UPPER_MASK 0x80000000 /* most significant w-r bits */ #define LOWER_MASK 0x7fffffff /* least significant r bits */ -/* Tempering parameters */ +/* Tempering parameters */ #define TEMPERING_MASK_B 0x9d2c5680 #define TEMPERING_MASK_C 0xefc60000 #define TEMPERING_SHIFT_U(y) (y >> 11) @@ -79,8 +79,8 @@ void SCA_RandomNumberGenerator::SetStartVector(void) } long SCA_RandomNumberGenerator::GetSeed() { return m_seed; } -void SCA_RandomNumberGenerator::SetSeed(long newseed) -{ +void SCA_RandomNumberGenerator::SetSeed(long newseed) +{ m_seed = newseed; SetStartVector(); } diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h index 10818cb4e8f..574958e9bec 100644 --- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h +++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h @@ -74,8 +74,8 @@ class SCA_RandomNumberGenerator { if (--m_refcount == 0) delete this; } - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_RandomNumberGenerator") #endif diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 8f2dc8d80f5..0757655e7db 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -46,7 +46,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr, +SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr, SCA_IObject* gameobj, int startseed) : SCA_ISensor(gameobj,eventmgr) @@ -57,7 +57,7 @@ SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr, -SCA_RandomSensor::~SCA_RandomSensor() +SCA_RandomSensor::~SCA_RandomSensor() { m_basegenerator->Release(); } @@ -89,7 +89,7 @@ void SCA_RandomSensor::ProcessReplica() bool SCA_RandomSensor::IsPositiveTrigger() -{ +{ return (m_invert !=m_lastdraw); } diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h index 66107b7b74b..40d7d7d66cd 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.h +++ b/source/gameengine/GameLogic/SCA_RandomSensor.h @@ -62,7 +62,7 @@ public: /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - + static PyObject* pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp index c56a1496823..7aa57b1b6b3 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp @@ -75,7 +75,7 @@ void SCA_TimeEventManager::NextFrame(double curtime, double fixedtime) if (m_timevalues.size() > 0 && fixedtime > 0.0) { CFloatValue* floatval = new CFloatValue(curtime); - + // update sensors, but ... need deltatime ! for (vector<CValue*>::iterator it = m_timevalues.begin(); !(it == m_timevalues.end()); ++it) @@ -84,7 +84,7 @@ void SCA_TimeEventManager::NextFrame(double curtime, double fixedtime) floatval->SetFloat(newtime); (*it)->SetValue(floatval); } - + floatval->Release(); } } diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.h b/source/gameengine/GameLogic/SCA_TimeEventManager.h index 38d7e3fc4d4..723a6ee10a7 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.h +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.h @@ -41,7 +41,7 @@ using namespace std; class SCA_TimeEventManager : public SCA_EventManager { vector<CValue*> m_timevalues; // values that need their time updated regularly - + public: SCA_TimeEventManager(class SCA_LogicManager* logicmgr); virtual ~SCA_TimeEventManager(); diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp index bb1ea822bd8..70e99a7f819 100644 --- a/source/gameengine/GameLogic/SCA_XORController.cpp +++ b/source/gameengine/GameLogic/SCA_XORController.cpp @@ -75,7 +75,7 @@ void SCA_XORController::Trigger(SCA_LogicManager* logicmgr) sensorresult = true; } } - + for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); !(i==m_linkedactuators.end());i++) { |