Fixed some CBot-related memory leaks
* fixed leaks in CScript::CheckToken() * fixed leaks in CInterface * commented out unused function in robotmain.cppdev-ui
parent
141f73866e
commit
5d0d9b5aa5
|
@ -69,16 +69,6 @@ void LightProgression::SetTarget(float value)
|
|||
}
|
||||
|
||||
|
||||
DynamicLight::DynamicLight()
|
||||
{
|
||||
rank = 0;
|
||||
used = enabled = false;
|
||||
priority = LIGHT_PRI_LOW;
|
||||
includeType = excludeType = ENG_OBJTYPE_NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CLightManager::CLightManager(CEngine* engine)
|
||||
{
|
||||
m_device = nullptr;
|
||||
|
|
|
@ -51,9 +51,12 @@ struct LightProgression
|
|||
float speed;
|
||||
|
||||
LightProgression()
|
||||
{
|
||||
starting = ending = current = progress = speed = 0.0f;
|
||||
}
|
||||
: starting(0.0f)
|
||||
, ending(0.0f)
|
||||
, current(0.0f)
|
||||
, progress(0.0f)
|
||||
, speed(0.0f)
|
||||
{}
|
||||
|
||||
//! Initializes the progression
|
||||
void Init(float value);
|
||||
|
@ -113,7 +116,14 @@ struct DynamicLight
|
|||
//! Type of objects excluded from lighting with this light; if ENG_OBJTYPE_NULL is used, it is ignored
|
||||
EngineObjectType excludeType;
|
||||
|
||||
DynamicLight();
|
||||
DynamicLight()
|
||||
: rank(0)
|
||||
, used(false)
|
||||
, enabled(false)
|
||||
, priority(LIGHT_PRI_LOW)
|
||||
, includeType(ENG_OBJTYPE_NULL)
|
||||
, excludeType(ENG_OBJTYPE_NULL)
|
||||
{}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,7 +107,7 @@ float g_unit; // conversion factor
|
|||
// Static variables
|
||||
|
||||
static CBotClass* m_pClassFILE;
|
||||
static CBotProgram* m_pFuncFile;
|
||||
//static CBotProgram* m_pFuncFile;
|
||||
static int m_CompteurFileOpen = 0;
|
||||
static std::string m_filesDir;
|
||||
|
||||
|
@ -503,10 +503,10 @@ void InitClassFILE()
|
|||
m_pClassFILE->AddFunction("readln", rfread, cfread );
|
||||
m_pClassFILE->AddFunction("eof", rfeof, cfeof );
|
||||
|
||||
m_pFuncFile = new CBotProgram( );
|
||||
CBotStringArray ListFonctions;
|
||||
m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
|
||||
m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function
|
||||
//m_pFuncFile = new CBotProgram( );
|
||||
//CBotStringArray ListFonctions;
|
||||
//m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
|
||||
//m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3689,6 +3689,7 @@ bool CScript::IsEmpty()
|
|||
bool CScript::CheckToken()
|
||||
{
|
||||
CBotToken* bt;
|
||||
CBotToken* allBt;
|
||||
CBotString bs;
|
||||
const char* token;
|
||||
int error, cursor1, cursor2, i;
|
||||
|
@ -3706,7 +3707,8 @@ bool CScript::CheckToken()
|
|||
used[i] = 0; // token not used
|
||||
}
|
||||
|
||||
bt = CBotToken::CompileTokens(m_script, error);
|
||||
allBt = CBotToken::CompileTokens(m_script, error);
|
||||
bt = allBt;
|
||||
while ( bt != 0 )
|
||||
{
|
||||
bs = bt->GetString();
|
||||
|
@ -3727,7 +3729,7 @@ bool CScript::CheckToken()
|
|||
m_cursor1 = cursor1;
|
||||
m_cursor2 = cursor2;
|
||||
strcpy(m_title, "<erreur>");
|
||||
CBotToken::Delete(bt);
|
||||
CBotToken::Delete(allBt);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3742,12 +3744,12 @@ bool CScript::CheckToken()
|
|||
strcpy(m_token, m_main->GetObligatoryToken(i));
|
||||
m_error = ERR_OBLIGATORYTOKEN;
|
||||
strcpy(m_title, "<erreur>");
|
||||
CBotToken::Delete(bt);
|
||||
CBotToken::Delete(allBt);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
CBotToken::Delete(bt);
|
||||
CBotToken::Delete(allBt);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ CInterface::CInterface()
|
|||
m_engine = Gfx::CEngine::GetInstancePointer();
|
||||
m_camera = nullptr;
|
||||
|
||||
for (int i = 0; i < MAXCONTROL; i++ )
|
||||
for (int i = 0; i < MAXCONTROL; i++)
|
||||
{
|
||||
m_table[i] = nullptr;
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ CInterface::~CInterface()
|
|||
|
||||
void CInterface::Flush()
|
||||
{
|
||||
for (int i = 0; i < MAXCONTROL; i++ )
|
||||
for (int i = 0; i < MAXCONTROL; i++)
|
||||
{
|
||||
if ( m_table[i] != nullptr )
|
||||
if (m_table[i] != nullptr)
|
||||
{
|
||||
delete m_table[i];
|
||||
m_table[i] = nullptr;
|
||||
|
@ -71,16 +71,15 @@ int CInterface::GetNextFreeControl()
|
|||
|
||||
template <typename T> inline T* CInterface::CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
|
||||
{
|
||||
T* pc;
|
||||
int index;
|
||||
if (eventMsg == EVENT_NULL)
|
||||
eventMsg = GetUniqueEventType();
|
||||
|
||||
if ((index = GetNextFreeControl()) < 0)
|
||||
int index = GetNextFreeControl();
|
||||
if (index < 0)
|
||||
return nullptr;
|
||||
|
||||
m_table[index] = new T();
|
||||
pc = static_cast<T *>(m_table[index]);
|
||||
T* pc = static_cast<T *>(m_table[index]);
|
||||
pc->Create(pos, dim, icon, eventMsg);
|
||||
return pc;
|
||||
}
|
||||
|
@ -90,11 +89,10 @@ template <typename T> inline T* CInterface::CreateControl(Math::Point pos, Math:
|
|||
|
||||
CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
|
||||
{
|
||||
CWindow* pc;
|
||||
int index;
|
||||
if (eventMsg == EVENT_NULL)
|
||||
eventMsg = GetUniqueEventType();
|
||||
|
||||
int index = -1;
|
||||
switch (eventMsg)
|
||||
{
|
||||
case EVENT_WINDOW0: index = 0; break;
|
||||
|
@ -114,8 +112,9 @@ CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, E
|
|||
if (index < 0)
|
||||
return nullptr;
|
||||
|
||||
delete m_table[index];
|
||||
m_table[index] = new CWindow();
|
||||
pc = static_cast<CWindow *>(m_table[index]);
|
||||
CWindow* pc = static_cast<CWindow *>(m_table[index]);
|
||||
pc->Create(pos, dim, icon, eventMsg);
|
||||
return pc;
|
||||
}
|
||||
|
@ -207,16 +206,15 @@ CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, Ev
|
|||
|
||||
CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand)
|
||||
{
|
||||
CList* pc;
|
||||
int index;
|
||||
if (eventMsg == EVENT_NULL)
|
||||
eventMsg = GetUniqueEventType();
|
||||
|
||||
if ((index = GetNextFreeControl()) < 0)
|
||||
int index = GetNextFreeControl();
|
||||
if (index < 0)
|
||||
return nullptr;
|
||||
|
||||
m_table[index] = new CList();
|
||||
pc = static_cast<CList *>(m_table[index]);
|
||||
CList* pc = static_cast<CList *>(m_table[index]);
|
||||
pc->Create(pos, dim, icon, eventMsg, expand);
|
||||
return pc;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue