fix LuaData becoming incorrectly set after a reset
This commit is contained in:
@@ -185,11 +185,18 @@ void LuaData::LoadFromString( const CString &s )
|
|||||||
|
|
||||||
void LuaData::BeforeReset()
|
void LuaData::BeforeReset()
|
||||||
{
|
{
|
||||||
m_sSerializedData = Serialize();
|
/* If we're unset, Register() should leave us unset, not set us to LUA_REFNIL. */
|
||||||
|
m_bWasSet = IsSet();
|
||||||
|
|
||||||
|
if( m_bWasSet )
|
||||||
|
m_sSerializedData = Serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaData::Register()
|
void LuaData::Register()
|
||||||
{
|
{
|
||||||
|
if( !m_bWasSet )
|
||||||
|
return;
|
||||||
|
|
||||||
LoadFromString( m_sSerializedData );
|
LoadFromString( m_sSerializedData );
|
||||||
m_sSerializedData.erase( m_sSerializedData.begin(), m_sSerializedData.end() );
|
m_sSerializedData.erase( m_sSerializedData.begin(), m_sSerializedData.end() );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ protected:
|
|||||||
virtual void Register();
|
virtual void Register();
|
||||||
|
|
||||||
CString m_sSerializedData;
|
CString m_sSerializedData;
|
||||||
|
bool m_bWasSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user