From 062b618bdaf3e50e3f58e8a931846696345a39c1 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Tue, 24 Mar 2015 18:28:11 -0600 Subject: [PATCH] Changed ActorFrame::SetUpdateRate to reject a negative rate instead of crashing. --- src/ActorFrame.cpp | 11 ++++++++++- src/ActorFrame.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ActorFrame.cpp b/src/ActorFrame.cpp index b54f223af9..309c9be1fe 100644 --- a/src/ActorFrame.cpp +++ b/src/ActorFrame.cpp @@ -624,7 +624,16 @@ public: } static int propagate( T* p, lua_State *L ) { p->SetPropagateCommands( BIArg(1) ); COMMON_RETURN_SELF; } static int fov( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); COMMON_RETURN_SELF; } - static int SetUpdateRate( T* p, lua_State *L ) { p->SetUpdateRate( FArg(1) ); COMMON_RETURN_SELF; } + static int SetUpdateRate( T* p, lua_State *L ) + { + float rate= FArg(1); + if(rate <= 0) + { + luaL_error(L, "ActorFrame:SetUpdateRate(%f) Update rate must be greater than 0.", rate); + } + p->SetUpdateRate(rate); + COMMON_RETURN_SELF; + } DEFINE_METHOD(GetUpdateRate, GetUpdateRate()); static int SetFOV( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); COMMON_RETURN_SELF; } static int vanishpoint( T* p, lua_State *L ) { p->SetVanishPoint( FArg(1), FArg(2) ); COMMON_RETURN_SELF; } diff --git a/src/ActorFrame.h b/src/ActorFrame.h index 274da11ba4..bee6935b22 100644 --- a/src/ActorFrame.h +++ b/src/ActorFrame.h @@ -75,7 +75,7 @@ public: virtual void FinishTweening(); virtual void HurryTweening( float factor ); - void SetUpdateRate( float fUpdateRate ) { m_fUpdateRate = fUpdateRate; } + void SetUpdateRate(float rate) { if(rate > 0.0f) { m_fUpdateRate = rate; }} float GetUpdateRate() { return m_fUpdateRate; } void SetFOV( float fFOV ) { m_fFOV = fFOV; } void SetVanishPoint( float fX, float fY) { m_fVanishX = fX; m_fVanishY = fY; }