Fixed UpdateHasteRate and PlayerInfo:GetLifeMeter to check whether the life meter is null before using it.

This commit is contained in:
Kyzentun
2014-07-25 00:20:38 -06:00
parent 1cee5c0e68
commit c05a173d52
+18 -1
View File
@@ -1958,8 +1958,16 @@ void ScreenGameplay::UpdateHasteRate()
{ {
if( !GAMESTATE->IsHumanPlayer(pi->m_pn) ) if( !GAMESTATE->IsHumanPlayer(pi->m_pn) )
continue; continue;
// In Battle/Rave mode, the players don't have life meters.
if(pi->m_pLifeMeter)
{
fMaxLife= max(fMaxLife, pi->m_pLifeMeter->GetLife()); fMaxLife= max(fMaxLife, pi->m_pLifeMeter->GetLife());
} }
else
{
fMaxLife= 1;
}
}
if( fMaxLife <= m_fHasteLifeSwitchPoint ) if( fMaxLife <= m_fHasteLifeSwitchPoint )
GAMESTATE->m_fHasteRate = SCALE( fMaxLife, 0.0f, m_fHasteLifeSwitchPoint, -1.0f, 0.0f ); GAMESTATE->m_fHasteRate = SCALE( fMaxLife, 0.0f, m_fHasteLifeSwitchPoint, -1.0f, 0.0f );
CLAMP( GAMESTATE->m_fHasteRate, -1.0f, +1.0f ); CLAMP( GAMESTATE->m_fHasteRate, -1.0f, +1.0f );
@@ -3008,7 +3016,16 @@ LUA_REGISTER_DERIVED_CLASS( ScreenGameplay, ScreenWithMenuElements )
class LunaPlayerInfo: public Luna<PlayerInfo> class LunaPlayerInfo: public Luna<PlayerInfo>
{ {
public: public:
static int GetLifeMeter( T* p, lua_State *L ) { p->m_pLifeMeter->PushSelf(L); return 1; } static int GetLifeMeter( T* p, lua_State *L )
{
if(p->m_pLifeMeter)
{
p->m_pLifeMeter->PushSelf(L);
return 1;
}
return 0;
}
static int GetStepsQueueWrapped( T* p, lua_State *L ) static int GetStepsQueueWrapped( T* p, lua_State *L )
{ {
int iIndex = IArg(1); int iIndex = IArg(1);