[colobot] 198/377: Some random refactoring
Didier Raboud
odyx at moszumanska.debian.org
Wed Mar 30 13:34:16 UTC 2016
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit 921c266311fa1c24c0178829f3123ad31258a355
Author: krzys-h <krzys_h at interia.pl>
Date: Thu Dec 24 14:39:38 2015 +0100
Some random refactoring
---
src/CBot/CBotCallMethode.cpp | 2 +-
src/CBot/CBotClass.cpp | 2 +-
src/CBot/CBotExternalCall.cpp | 4 +-
src/CBot/CBotExternalCall.h | 2 +-
src/CBot/CBotInstr/CBotClassInst.cpp | 2 +-
src/CBot/CBotInstr/CBotFieldExpr.cpp | 2 +-
src/CBot/CBotInstr/CBotFunction.cpp | 12 +--
src/CBot/CBotInstr/CBotIndexExpr.cpp | 2 +-
src/CBot/CBotInstr/CBotInstArray.cpp | 2 +-
src/CBot/CBotInstr/CBotInstr.cpp | 29 ++----
src/CBot/CBotInstr/CBotInstr.h | 97 +++++++++--------
src/CBot/CBotInstr/CBotInstrMethode.cpp | 4 +-
src/CBot/CBotInstr/CBotLeftExpr.cpp | 2 +-
src/CBot/CBotInstr/CBotLeftExprVar.cpp | 40 +++----
src/CBot/CBotInstr/CBotLeftExprVar.h | 32 ++----
src/CBot/CBotProgram.cpp | 99 +++++++-----------
src/CBot/CBotProgram.h | 2 +-
src/CBot/CBotStack.cpp | 178 ++++----------------------------
src/CBot/CBotStack.h | 68 +++++-------
src/CBot/CBotVar/CBotVar.cpp | 2 +-
src/CBot/CBotVar/CBotVar.h | 5 +-
src/CBot/CBotVar/CBotVarClass.cpp | 8 +-
src/CBot/CBotVar/CBotVarClass.h | 2 +-
src/CBot/CBotVar/CBotVarPointer.cpp | 4 +-
src/CBot/CBotVar/CBotVarPointer.h | 2 +-
src/script/script.cpp | 2 +-
26 files changed, 194 insertions(+), 412 deletions(-)
diff --git a/src/CBot/CBotCallMethode.cpp b/src/CBot/CBotCallMethode.cpp
index 474b1cf..a66ebd2 100644
--- a/src/CBot/CBotCallMethode.cpp
+++ b/src/CBot/CBotCallMethode.cpp
@@ -90,7 +90,7 @@ int CBotCallMethode::DoCall(const std::string& name, CBotVar* pThis, CBotVar** p
CBotVar* pVarToDelete = pVar;
int Exception = 0; // TODO: Change this to CBotError
- int res = pt->m_rExec(pThis, pVar, pResult, Exception, pStack->GetPUser());
+ int res = pt->m_rExec(pThis, pVar, pResult, Exception, pStack->GetUserPtr());
pStack->SetVar(pResult);
if (res == false)
diff --git a/src/CBot/CBotClass.cpp b/src/CBot/CBotClass.cpp
index 4de2d2e..8e8d8e2 100644
--- a/src/CBot/CBotClass.cpp
+++ b/src/CBot/CBotClass.cpp
@@ -762,7 +762,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
if ( pv->IsStatic() && pv->m_InitExpr != nullptr )
{
- CBotStack* pile = CBotStack::FirstStack(); // independent stack
+ CBotStack* pile = CBotStack::AllocateStack(); // independent stack
while(pile->IsOk() && !pv->m_InitExpr->Execute(pile)); // evaluates the expression without timer
pv->SetVal( pile->GetVar() ) ;
pile->Delete();
diff --git a/src/CBot/CBotExternalCall.cpp b/src/CBot/CBotExternalCall.cpp
index 46ccf3e..ca37dc5 100644
--- a/src/CBot/CBotExternalCall.cpp
+++ b/src/CBot/CBotExternalCall.cpp
@@ -148,7 +148,7 @@ bool CBotExternalCallDefault::Run(CBotVar* thisVar, CBotStack* pStack)
CBotVar* result = pile2->GetVar();
int exception = CBotNoErr; // TODO: Change to CBotError
- bool res = m_rExec(args, result, exception, pStack->GetPUser());
+ bool res = m_rExec(args, result, exception, pStack->GetUserPtr());
if (!res)
{
@@ -193,7 +193,7 @@ bool CBotExternalCallDefaultClass::Run(CBotVar* thisVar, CBotStack* pStack)
CBotVar* result = pile2->GetVar();
int exception = CBotNoErr; // TODO: Change to CBotError
- bool res = m_rExec(thisVar, args, result, exception, pStack->GetPUser());
+ bool res = m_rExec(thisVar, args, result, exception, pStack->GetUserPtr());
pStack->SetVar(result);
if (!res)
diff --git a/src/CBot/CBotExternalCall.h b/src/CBot/CBotExternalCall.h
index 12b768b..071f6e9 100644
--- a/src/CBot/CBotExternalCall.h
+++ b/src/CBot/CBotExternalCall.h
@@ -197,7 +197,7 @@ public:
/**
* \brief Set user pointer to pass to compile functions
*
- * This is for compile functions only, runtime functions use CBotStack::GetPUser()
+ * This is for compile functions only, runtime functions use CBotStack::GetUserPtr()
*
* \param pUser User pointer
*/
diff --git a/src/CBot/CBotInstr/CBotClassInst.cpp b/src/CBot/CBotInstr/CBotClassInst.cpp
index 04650e3..f598db9 100644
--- a/src/CBot/CBotInstr/CBotClassInst.cpp
+++ b/src/CBot/CBotInstr/CBotClassInst.cpp
@@ -257,7 +257,7 @@ bool CBotClassInst::Execute(CBotStack* &pj)
pile->IncState();
}
- if ( pThis == nullptr ) pThis = pile->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
+ if ( pThis == nullptr ) pThis = pile->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent, false);
if ( pile->GetState()<3)
{
diff --git a/src/CBot/CBotInstr/CBotFieldExpr.cpp b/src/CBot/CBotInstr/CBotFieldExpr.cpp
index 0105455..8bd5919 100644
--- a/src/CBot/CBotInstr/CBotFieldExpr.cpp
+++ b/src/CBot/CBotInstr/CBotFieldExpr.cpp
@@ -108,7 +108,7 @@ bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev
}
// request the update of the element, if applicable
- pVar->Maj(pile->GetPUser(), true);
+ pVar->Maj(pile->GetUserPtr());
if ( m_next3 != nullptr &&
!m_next3->ExecuteVar(pVar, pile, &m_token, bStep, bExtend) ) return false;
diff --git a/src/CBot/CBotInstr/CBotFunction.cpp b/src/CBot/CBotInstr/CBotFunction.cpp
index 8d6c8d5..4f4df63 100644
--- a/src/CBot/CBotInstr/CBotFunction.cpp
+++ b/src/CBot/CBotInstr/CBotFunction.cpp
@@ -351,7 +351,7 @@ bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
CBotStack* pile = pj->AddStack(this, CBotStack::UnknownEnumBlock::UNKNOWN_2); // one end of stack local to this function
// if ( pile == EOX ) return true;
- pile->SetBotCall(m_pProg); // bases for routines
+ pile->SetProgram(m_pProg); // bases for routines
if ( pile->GetState() == 0 )
{
@@ -402,7 +402,7 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
if ( pile == nullptr ) return;
CBotStack* pile2 = pile;
- pile->SetBotCall(m_pProg); // bases for routines
+ pile->SetProgram(m_pProg); // bases for routines
if ( pile->GetBlock() != CBotStack::UnknownEnumBlock::UNKNOWN_2 )
{
@@ -611,7 +611,7 @@ int CBotFunction::DoCall(long& nIdent, const std::string& name, CBotVar** ppVars
CBotStack* pStk1 = pStack->AddStack(pt, CBotStack::UnknownEnumBlock::UNKNOWN_2); // to put "this"
// if ( pStk1 == EOX ) return true;
- pStk1->SetBotCall(pt->m_pProg); // it may have changed module
+ pStk1->SetProgram(pt->m_pProg); // it may have changed module
if ( pStk1->IfStep() ) return false;
@@ -682,7 +682,7 @@ void CBotFunction::RestoreCall(long& nIdent, const std::string& name, CBotVar**
pStk1 = pStack->RestoreStack(pt);
if ( pStk1 == nullptr ) return;
- pStk1->SetBotCall(pt->m_pProg); // it may have changed module
+ pStk1->SetProgram(pt->m_pProg); // it may have changed module
if ( pStk1->GetBlock() != CBotStack::UnknownEnumBlock::UNKNOWN_2 )
{
@@ -738,7 +738,7 @@ int CBotFunction::DoCall(long& nIdent, const std::string& name, CBotVar* pThis,
CBotStack* pStk = pStack->AddStack(pt, CBotStack::UnknownEnumBlock::UNKNOWN_2);
// if ( pStk == EOX ) return true;
- pStk->SetBotCall(pt->m_pProg); // it may have changed module
+ pStk->SetProgram(pt->m_pProg); // it may have changed module
CBotStack* pStk3 = pStk->AddStack(nullptr, CBotStack::UnknownEnumBlock::UNKNOWN_TRUE); // to set parameters passed
// preparing parameters on the stack
@@ -815,7 +815,7 @@ void CBotFunction::RestoreCall(long& nIdent, const std::string& name, CBotVar* p
{
CBotStack* pStk = pStack->RestoreStack(pt);
if ( pStk == nullptr ) return;
- pStk->SetBotCall(pt->m_pProg); // it may have changed module
+ pStk->SetProgram(pt->m_pProg); // it may have changed module
CBotVar* pthis = pStk->FindVar("this");
pthis->SetUniqNum(-2);
diff --git a/src/CBot/CBotInstr/CBotIndexExpr.cpp b/src/CBot/CBotInstr/CBotIndexExpr.cpp
index e83f561..62d37f7 100644
--- a/src/CBot/CBotInstr/CBotIndexExpr.cpp
+++ b/src/CBot/CBotInstr/CBotIndexExpr.cpp
@@ -93,7 +93,7 @@ bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev
return pj->Return(pile);
}
- pVar->Maj(pile->GetPUser(), true);
+ pVar->Maj(pile->GetUserPtr());
if ( m_next3 != nullptr &&
!m_next3->ExecuteVar(pVar, pile, prevToken, bStep, bExtend) ) return false;
diff --git a/src/CBot/CBotInstr/CBotInstArray.cpp b/src/CBot/CBotInstr/CBotInstArray.cpp
index e2e9fcc..c841dd8 100644
--- a/src/CBot/CBotInstr/CBotInstArray.cpp
+++ b/src/CBot/CBotInstr/CBotInstArray.cpp
@@ -174,7 +174,7 @@ bool CBotInstArray::Execute(CBotStack* &pj)
{
if (m_listass != nullptr) // there is the assignment for this table
{
- CBotVar* pVar = pj->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
+ CBotVar* pVar = pj->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent, false);
if (!m_listass->Execute(pile1, pVar)) return false;
}
diff --git a/src/CBot/CBotInstr/CBotInstr.cpp b/src/CBot/CBotInstr/CBotInstr.cpp
index 9302949..ade2388 100644
--- a/src/CBot/CBotInstr/CBotInstr.cpp
+++ b/src/CBot/CBotInstr/CBotInstr.cpp
@@ -108,12 +108,6 @@ bool CBotInstr::ChkLvl(const std::string& label, int type)
}
////////////////////////////////////////////////////////////////////////////////
-bool CBotInstr::IsOfClass(const std::string& n)
-{
- return name == n;
-}
-
-////////////////////////////////////////////////////////////////////////////////
void CBotInstr::SetToken(CBotToken* p)
{
m_token = *p;
@@ -180,14 +174,11 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
if (p == nullptr) return nullptr;
- int type = p->GetType(); // what is the next token
-
- // is it a lable?
- if (IsOfType(pp, TokenTypVar) &&
- IsOfType(pp, ID_DOTS))
+ int type = p->GetType(); // what is the next token?
+ if (IsOfType(pp, TokenTypVar) && IsOfType(pp, ID_DOTS)) // is it a label?
{
type = pp->GetType();
- // these instructions accept only lable
+ // Allow only instructions that accept a label
if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, 0))
{
pStack->SetError(CBotErrLabel, pp->GetStart());
@@ -195,7 +186,7 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
}
}
- // call routine corresponding to the compilation token found
+ // Call Compile() function for the given token type
switch (type)
{
case ID_WHILE:
@@ -252,26 +243,26 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
pStack->SetStartError(p->GetStart());
- // should not be a reserved word DefineNum
+ // Should not be a reserved constant defined with DefineNum
if (p->GetType() == TokenTypDef)
{
pStack->SetError(CBotErrReserved, p);
return nullptr;
}
- // this might be an instance of class definnition
+ // If not, this might be an instance of class definnition
CBotToken* ppp = p;
if (IsOfType(ppp, TokenTypVar))
{
- if (CBotClass::Find(p) != nullptr)
+ if (CBotClass::Find(p) != nullptr) // Does class with this name exist?
{
- // yes, compiles the declaration of the instance
+ // Yes, compile the declaration of the instance
return CBotClassInst::Compile(p, pStack);
}
}
- // this can be an arythmetic instruction
- CBotInstr* inst = CBotExpression::Compile(p, pStack);
+ // This can be an arithmetic expression
+ CBotInstr* inst = CBotExpression::Compile(p, pStack);
if (IsOfType(p, ID_SEP))
{
return inst;
diff --git a/src/CBot/CBotInstr/CBotInstr.h b/src/CBot/CBotInstr/CBotInstr.h
index e8221a2..ec010a5 100644
--- a/src/CBot/CBotInstr/CBotInstr.h
+++ b/src/CBot/CBotInstr/CBotInstr.h
@@ -41,35 +41,51 @@
m_next->...
*/
-/*!
- * \brief The CBotInstr class Class defining an instruction.
+/**
+ * \brief Class for one CBot instruction
+ *
+ * \todo More documentation
*/
class CBotInstr
{
public:
-
- /*!
- * \brief CBotInstr
+ /**
+ * \brief Constructor
*/
CBotInstr();
- /*!
- * \brief ~CBotInstr
+ /**
+ * \brief Destructor
*/
virtual ~CBotInstr();
- /*!
- * \brief Compile Compile an instruction which can be while, do, try,
- * throw, if, for, switch, break, continue, return, int, float, boolean,
- * string, declaration of an instance of a class, arbitrary expression.
- * \param p
- * \param pStack
- * \return
+ /**
+ * \brief Compile an instruction.
+ *
+ * Supported instructions are:
+ * * while
+ * * do
+ * * try
+ * * throw
+ * * if
+ * * for
+ * * switch
+ * * break
+ * * continue
+ * * return
+ * * int
+ * * float
+ * * boolean
+ * * string
+ * * declaration of an instance of a class
+ * * arithmetic expression (with or without assigment)
+ * \param[in, out] p Token to start at, updated to point at the next token
+ * \param pStack Compilation stack
+ * \return Compiled instruction
*/
- static CBotInstr* Compile(CBotToken* &p,
- CBotCStack* pStack);
+ static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
- /*!
+ /**
* \brief CompileArray
* \param p
* \param pStack
@@ -82,14 +98,14 @@ public:
CBotTypResult type,
bool first = true);
- /*!
+ /**
* \brief Execute
* \param pj
* \return
*/
virtual bool Execute(CBotStack* &pj);
- /*!
+ /**
* \brief Execute
* \param pj
* \param pVar
@@ -98,7 +114,7 @@ public:
virtual bool Execute(CBotStack* &pj,
CBotVar* pVar);
- /*!
+ /**
* \brief RestoreState
* \param pj
* \param bMain
@@ -106,7 +122,7 @@ public:
virtual void RestoreState(CBotStack* &pj,
bool bMain);
- /*!
+ /**
* \brief ExecuteVar
* \param pVar
* \param pile
@@ -115,7 +131,7 @@ public:
virtual bool ExecuteVar(CBotVar* &pVar,
CBotCStack* &pile);
- /*!
+ /**
* \brief ExecuteVar
* \param pVar
* \param pile
@@ -130,7 +146,7 @@ public:
bool bStep,
bool bExtend);
- /*!
+ /**
* \brief RestoreStateVar
* \param pile
* \param bMain
@@ -138,7 +154,7 @@ public:
virtual void RestoreStateVar(CBotStack* &pile,
bool bMain);
- /*!
+ /**
* \brief CompCase This routine is defined only for the subclass CBotCase
* this allows to make the call on all instructions CompCase to see if it's
* a case to the desired value..
@@ -149,78 +165,78 @@ public:
virtual bool CompCase(CBotStack* &pj,
int val);
- /*!
+ /**
* \brief SetToken Set the token corresponding to the instruction.
* \param p
*/
void SetToken(CBotToken* p);
- /*!
+ /**
* \brief GetTokenType Return the type of the token assicated with the
* instruction.
* \return
*/
int GetTokenType();
- /*!
+ /**
* \brief GetToken Return associated token.
* \return
*/
CBotToken* GetToken();
- /*!
+ /**
* \brief AddNext Adds the statement following the other.
* \param n
*/
void AddNext(CBotInstr* n);
- /*!
+ /**
* \brief GetNext Returns next statement.
* \return
*/
CBotInstr* GetNext();
- /*!
+ /**
* \brief AddNext3
* \param n
*/
void AddNext3(CBotInstr* n);
- /*!
+ /**
* \brief GetNext3
* \return
*/
CBotInstr* GetNext3();
- /*!
+ /**
* \brief AddNext3b
* \param n
*/
void AddNext3b(CBotInstr* n);
- /*!
+ /**
* \brief GetNext3b
* \return
*/
CBotInstr* GetNext3b();
- /*!
+ /**
* \brief IncLvl Adds a level with a label.
* \param label
*/
static void IncLvl(std::string& label);
- /*!
+ /**
* \brief IncLvl Adds a level (switch statement).
*/
static void IncLvl();
- /*!
+ /**
* \brief DecLvl Free a level.
*/
static void DecLvl();
- /*!
+ /**
* \brief ChkLvl Control validity of break and continue.
* \param label
* \param type
@@ -228,13 +244,6 @@ public:
*/
static bool ChkLvl(const std::string& label, int type);
- /*!
- * \brief IsOfClass
- * \param name
- * \return
- */
- bool IsOfClass(const std::string& name);
-
protected:
//! Keeps the token.
diff --git a/src/CBot/CBotInstr/CBotInstrMethode.cpp b/src/CBot/CBotInstr/CBotInstrMethode.cpp
index f5800c1..f8493bc 100644
--- a/src/CBot/CBotInstr/CBotInstrMethode.cpp
+++ b/src/CBot/CBotInstr/CBotInstrMethode.cpp
@@ -152,7 +152,7 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
ppVars[i] = nullptr;
CBotClass* pClass = CBotClass::Find(m_ClassName);
- CBotVar* pThis = pile1->FindVar(-2);
+ CBotVar* pThis = pile1->FindVar(-2, false);
CBotVar* pResult = nullptr;
if (m_typRes.GetType() > 0) pResult = CBotVar::Create("", m_typRes);
if (m_typRes.Eq(CBotTypClass))
@@ -272,7 +272,7 @@ bool CBotInstrMethode::Execute(CBotStack* &pj)
pResult, pile2, GetToken())) return false; // interupted
// set the new value of this in place of the old variable
- CBotVar* old = pile1->FindVar(m_token);
+ CBotVar* old = pile1->FindVar(m_token, false);
old->Copy(pThis, false);
if (pRes != pResult) delete pRes;
diff --git a/src/CBot/CBotInstr/CBotLeftExpr.cpp b/src/CBot/CBotInstr/CBotLeftExpr.cpp
index d87f74a..01b43cc 100644
--- a/src/CBot/CBotInstr/CBotLeftExpr.cpp
+++ b/src/CBot/CBotInstr/CBotLeftExpr.cpp
@@ -219,7 +219,7 @@ bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevT
{
pile = pile->AddStack(this);
- pVar = pile->FindVar(m_nIdent);
+ pVar = pile->FindVar(m_nIdent, false);
if (pVar == nullptr)
{
pile->SetError(static_cast<CBotError>(2), &m_token); // TODO: yup, another unknown error ~krzys_h
diff --git a/src/CBot/CBotInstr/CBotLeftExprVar.cpp b/src/CBot/CBotInstr/CBotLeftExprVar.cpp
index 8115fc9..d517015 100644
--- a/src/CBot/CBotInstr/CBotLeftExprVar.cpp
+++ b/src/CBot/CBotInstr/CBotLeftExprVar.cpp
@@ -17,7 +17,6 @@
* along with this program. If not, see http://gnu.org/licenses
*/
-// Modules inlcude
#include "CBot/CBotInstr/CBotLeftExprVar.h"
#include "CBot/CBotStack.h"
@@ -25,31 +24,23 @@
#include "CBot/CBotVar/CBotVar.h"
-// Local include
+#include <cassert>
-// Global include
-#include <assert.h>
-
-////////////////////////////////////////////////////////////////////////////////
CBotLeftExprVar::CBotLeftExprVar()
{
- name = "CBotLeftExprVar";
- m_typevar = -1;
- m_nIdent = 0;
+ name = "CBotLeftExprVar";
}
-////////////////////////////////////////////////////////////////////////////////
CBotLeftExprVar::~CBotLeftExprVar()
{
}
-////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotLeftExprVar::Compile(CBotToken* &p, CBotCStack* pStack)
{
- // verifies that the token is a variable name
+ // Verifies that the token is a variable name
if (p->GetType() != TokenTypVar)
{
- pStack->SetError( CBotErrNoVar, p->GetStart());
+ pStack->SetError(CBotErrNoVar, p);
return nullptr;
}
@@ -60,29 +51,28 @@ CBotInstr* CBotLeftExprVar::Compile(CBotToken* &p, CBotCStack* pStack)
return inst;
}
-////////////////////////////////////////////////////////////////////////////////
bool CBotLeftExprVar::Execute(CBotStack* &pj)
{
- CBotVar* var1;
- CBotVar* var2;
-
- var1 = CBotVar::Create(m_token.GetString(), m_typevar);
- var1->SetUniqNum(m_nIdent); // with the unique identifier
- pj->AddVar(var1); // place it on the stack
+ // Create the variable
+ CBotVar* var1 = CBotVar::Create(m_token.GetString(), m_typevar);
+ var1->SetUniqNum(m_nIdent);
+ pj->AddVar(var1);
- var2 = pj->GetVar(); // result on the stack
- if (var2) var1->SetVal(var2); // do the assignment
+ CBotVar* var2 = pj->GetVar(); // Initial value on the stack
+ if (var2 != nullptr)
+ {
+ var1->SetVal(var2); // Set the value
+ }
return true;
}
-////////////////////////////////////////////////////////////////////////////////
void CBotLeftExprVar::RestoreState(CBotStack* &pj, bool bMain)
{
CBotVar* var1;
var1 = pj->FindVar(m_token.GetString());
- if (var1 == nullptr) assert(0);
+ if (var1 == nullptr) assert(false);
- var1->SetUniqNum(m_nIdent); // with the unique identifier
+ var1->SetUniqNum(m_nIdent); // Restore the identifier
}
diff --git a/src/CBot/CBotInstr/CBotLeftExprVar.h b/src/CBot/CBotInstr/CBotLeftExprVar.h
index a9526e8..e692a6f 100644
--- a/src/CBot/CBotInstr/CBotLeftExprVar.h
+++ b/src/CBot/CBotInstr/CBotLeftExprVar.h
@@ -19,37 +19,19 @@
#pragma once
-// Modules inlcude
#include "CBot/CBotInstr/CBotInstr.h"
-// Local include
-// Global include
-
-
-/*!
- * \brief The CBotLeftExprVar class Compilation of an element to the left of an assignment.
+/**
+ * \brief Expression on the left side of an assignment
*/
class CBotLeftExprVar : public CBotInstr
{
-public:
-
- /*!
- * \brief CBotLeftExprVar
- */
+private:
CBotLeftExprVar();
-
- /*!
- * \brief ~CBotLeftExprVar
- */
+public:
~CBotLeftExprVar();
- /*!
- * \brief Compile
- * \param p
- * \param pStack
- * \return
- */
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
/*!
@@ -69,7 +51,7 @@ public:
public:
//! Type of variable declared.
- CBotTypResult m_typevar;
- //! Unique identifier for that variable.
- long m_nIdent;
+ CBotTypResult m_typevar = -1;
+ //! Unique identifier of that variable
+ long m_nIdent = 0;
};
diff --git a/src/CBot/CBotProgram.cpp b/src/CBot/CBotProgram.cpp
index 884e2e1..e0da567 100644
--- a/src/CBot/CBotProgram.cpp
+++ b/src/CBot/CBotProgram.cpp
@@ -50,11 +50,7 @@ CBotProgram::~CBotProgram()
CBotClass::FreeLock(this);
delete m_functions;
-#if STACKMEM
- m_pStack->Delete();
-#else
- delete m_pStack;
-#endif
+ m_stack->Delete();
}
bool CBotProgram::Compile(const std::string& program, std::vector<std::string>& functions, void* pUser)
@@ -150,12 +146,7 @@ bool CBotProgram::Compile(const std::string& program, std::vector<std::string>&
////////////////////////////////////////////////////////////////////////////////
bool CBotProgram::Start(const std::string& name)
{
-#if STACKMEM
- m_pStack->Delete();
-#else
- delete m_pStack;
-#endif
- m_pStack = nullptr;
+ Stop();
m_entryPoint = m_functions;
while (m_entryPoint != nullptr)
@@ -164,21 +155,16 @@ bool CBotProgram::Start(const std::string& name)
m_entryPoint = m_entryPoint->m_next;
}
- if (m_entryPoint == nullptr )
+ if (m_entryPoint == nullptr)
{
m_error = CBotErrNoRun;
return false;
}
-#if STACKMEM
- m_pStack = CBotStack::FirstStack();
-#else
- m_pStack = new CBotStack(nullptr); // creates an execution stack
-#endif
-
- m_pStack->SetBotCall(this); // bases for routines
+ m_stack = CBotStack::AllocateStack();
+ m_stack->SetProgram(this);
- return true; // we are ready for Run ()
+ return true; // we are ready for Run()
}
////////////////////////////////////////////////////////////////////////////////
@@ -200,55 +186,46 @@ bool CBotProgram::GetPosition(const std::string& name, int& start, int& stop, CB
////////////////////////////////////////////////////////////////////////////////
bool CBotProgram::Run(void* pUser, int timer)
{
- bool ok;
-
- if (m_pStack == nullptr || m_entryPoint == nullptr) goto error;
+ if (m_stack == nullptr || m_entryPoint == nullptr)
+ {
+ m_error = CBotErrNoRun;
+ return true;
+ }
m_error = CBotNoErr;
- m_pStack->Reset(pUser); // empty the possible previous error, and resets the timer
- if ( timer >= 0 ) m_pStack->SetTimer(timer);
+ m_stack->SetUserPtr(pUser);
+ if ( timer >= 0 ) m_stack->SetTimer(timer); // TODO: Check if changing order here fixed ipf()
+ m_stack->Reset(); // reset the possible previous error, and resets the timer
- m_pStack->SetBotCall(this); // bases for routines
+ m_stack->SetProgram(this); // bases for routines
// resumes execution on the top of the stack
- ok = m_pStack->Execute();
- if ( ok )
+ bool ok = m_stack->Execute();
+ if (ok)
{
// returns to normal execution
- ok = m_entryPoint->Execute(nullptr, m_pStack, m_thisVar);
+ ok = m_entryPoint->Execute(nullptr, m_stack, m_thisVar);
}
// completed on a mistake?
- if (!ok && !m_pStack->IsOk())
+ if (!ok && !m_stack->IsOk())
{
- m_error = m_pStack->GetError(m_errorStart, m_errorEnd);
-#if STACKMEM
- m_pStack->Delete();
-#else
- delete m_pStack;
-#endif
- m_pStack = nullptr;
+ m_error = m_stack->GetError(m_errorStart, m_errorEnd);
+ m_stack->Delete();
+ m_stack = nullptr;
return true; // execution is finished!
}
if ( ok ) m_entryPoint = nullptr; // more function in execution
return ok;
-
-error:
- m_error = CBotErrNoRun;
- return true;
}
////////////////////////////////////////////////////////////////////////////////
void CBotProgram::Stop()
{
-#if STACKMEM
- m_pStack->Delete();
-#else
- delete m_pStack;
-#endif
- m_pStack = nullptr;
+ m_stack->Delete();
+ m_stack = nullptr;
m_entryPoint = nullptr;
}
@@ -257,9 +234,9 @@ bool CBotProgram::GetRunPos(std::string& functionName, int& start, int& end)
{
functionName = "";
start = end = 0;
- if (m_pStack == nullptr) return false;
+ if (m_stack == nullptr) return false;
- m_pStack->GetRunPos(functionName, start, end);
+ m_stack->GetRunPos(functionName, start, end);
return true;
}
@@ -267,9 +244,9 @@ bool CBotProgram::GetRunPos(std::string& functionName, int& start, int& end)
CBotVar* CBotProgram::GetStackVars(std::string& functionName, int level)
{
functionName.clear();
- if (m_pStack == nullptr) return nullptr;
+ if (m_stack == nullptr) return nullptr;
- return m_pStack->GetStackVars(functionName, level);
+ return m_stack->GetStackVars(functionName, level);
}
////////////////////////////////////////////////////////////////////////////////
@@ -357,11 +334,11 @@ bool CBotProgram::SaveState(FILE* pf)
if (!WriteWord( pf, CBOTVERSION)) return false;
- if ( m_pStack != nullptr )
+ if (m_stack != nullptr )
{
if (!WriteWord( pf, 1)) return false;
if (!WriteString( pf, m_entryPoint->GetName() )) return false;
- if (!m_pStack->SaveState(pf)) return false;
+ if (!m_stack->SaveState(pf)) return false;
}
else
{
@@ -387,20 +364,16 @@ bool CBotProgram::RestoreState(FILE* pf)
if (!ReadString( pf, s )) return false;
Start(s); // point de reprise
-#if STACKMEM
- m_pStack->Delete();
-#else
- delete m_pStack;
-#endif
- m_pStack = nullptr;
+ m_stack->Delete();
+ m_stack = nullptr;
// retrieves the stack from the memory
- // uses a nullptr pointer (m_pStack) but it's ok like that
- if (!m_pStack->RestoreState(pf, m_pStack)) return false;
- m_pStack->SetBotCall(this); // bases for routines
+ // uses a nullptr pointer (m_stack) but it's ok like that
+ if (!m_stack->RestoreState(pf, m_stack)) return false;
+ m_stack->SetProgram(this); // bases for routines
// restored some states in the stack according to the structure
- m_entryPoint->RestoreState(nullptr, m_pStack, m_thisVar);
+ m_entryPoint->RestoreState(nullptr, m_stack, m_thisVar);
return true;
}
diff --git a/src/CBot/CBotProgram.h b/src/CBot/CBotProgram.h
index 80236ea..c8aaa0a 100644
--- a/src/CBot/CBotProgram.h
+++ b/src/CBot/CBotProgram.h
@@ -351,7 +351,7 @@ private:
//! Classes defined in this program
CBotClass* m_classes = nullptr;
//! Execution stack
- CBotStack* m_pStack = nullptr;
+ CBotStack* m_stack = nullptr;
//! "this" variable
CBotVar* m_thisVar = nullptr;
friend class CBotFunction;
diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp
index 6764177..93ab3fd 100644
--- a/src/CBot/CBotStack.cpp
+++ b/src/CBot/CBotStack.cpp
@@ -17,7 +17,6 @@
* along with this program. If not, see http://gnu.org/licenses
*/
-// Modules inlcude
#include "CBot/CBotStack.h"
#include "CBotExternalCall.h"
@@ -29,9 +28,6 @@
#include "CBot/CBotFileUtils.h"
#include "CBot/CBotUtils.h"
-// Local include
-
-// Global include
#include <cassert>
#include <cstdlib>
#include <cstring>
@@ -48,10 +44,8 @@ int CBotStack::m_end = 0;
std::string CBotStack::m_labelBreak="";
void* CBotStack::m_pUser = nullptr;
-#if STACKMEM
-
////////////////////////////////////////////////////////////////////////////////
-CBotStack* CBotStack::FirstStack()
+CBotStack* CBotStack::AllocateStack()
{
CBotStack* p;
@@ -81,19 +75,6 @@ CBotStack* CBotStack::FirstStack()
}
////////////////////////////////////////////////////////////////////////////////
-CBotStack::CBotStack(CBotStack* ppapa)
-{
- // constructor must exist or the destructor is never called!
- assert(0);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-CBotStack::~CBotStack()
-{
- assert(0); // use Delete () instead
-}
-
-////////////////////////////////////////////////////////////////////////////////
void CBotStack::Delete()
{
if ( this == nullptr || this == EOX ) return;
@@ -235,134 +216,14 @@ bool CBotStack::StackOver()
return true;
}
-#else
-
-////////////////////////////////////////////////////////////////////////////////
-CBotStack::CBotStack(CBotStack* ppapa)
-{
- m_next = nullptr;
- m_next2 = nullptr;
- m_prev = ppapa;
-
- m_bBlock = (ppapa == nullptr) ? true : false;
-
- m_state = 0;
- m_step = 1;
-
- if (ppapa == nullptr) m_timer = m_initimer; // sets the timer at the beginning
-
- m_listVar = nullptr;
- m_bDontDelete = false;
-
- m_var = nullptr;
- m_prog = nullptr;
- m_instr = nullptr;
- m_call = nullptr;
- m_bFunc = false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// destructor
-CBotStack::~CBotStack()
-{
- if ( m_next != EOX) delete m_next;
- delete m_next2;
- if (m_prev != nullptr && m_prev->m_next == this )
- m_prev->m_next = nullptr; // removes chain
-
- delete m_var;
- if ( !m_bDontDelete ) delete m_listVar;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \TODO routine has/to optimize
-CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock)
-{
- if (m_next != nullptr)
- {
- return m_next; // included in an existing stack
- }
- CBotStack* p = new CBotStack(this);
- m_next = p; // chain an element
- p->m_bBlock = bBlock;
- p->m_instr = instr;
- p->m_prog = m_prog;
- p->m_step = 0;
- return p;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-CBotStack* CBotStack::AddStackEOX(CBotExternalCall* instr, bool bBlock)
-{
- if (m_next != nullptr)
- {
- if ( m_next == EOX )
- {
- m_next = nullptr;
- return EOX;
- }
- return m_next; // included in an existing stack
- }
- CBotStack* p = new CBotStack(this);
- m_next = p; // chain an element
- p->m_bBlock = bBlock;
- p->m_call = instr;
- p->m_prog = m_prog;
- p->m_step = 0;
- p->m_bFunc = 2; // special
- return p;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-CBotStack* CBotStack::AddStack2(bool bBlock)
-{
- if (m_next2 != nullptr)
- {
- m_next2->m_prog = m_prog; // special avoids RestoreStack2
- return m_next2; // included in an existing stack
- }
-
- CBotStack* p = new CBotStack(this);
- m_next2 = p; // chain an element
- p->m_bBlock = bBlock;
- p->m_prog = m_prog;
- p->m_step = 0;
-
- return p;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-bool CBotStack::Return(CBotStack* pfils)
-{
- if ( pfils == this ) return true; // special
-
- if (m_var != nullptr) delete m_var; // value replaced?
- m_var = pfils->m_var; // result transmitted
- pfils->m_var = nullptr; // do not destroy the variable
-
- if ( m_next != EOX ) delete m_next; // releases the stack above
- delete m_next2;m_next2 = nullptr; // also the second stack (catch)
-
- return (m_error == 0); // interrupted if error
-}
-
-////////////////////////////////////////////////////////////////////////////////
-bool CBotStack::StackOver()
-{
- return false; // no overflow check in this version
-}
-
-#endif
-
////////////////////////////////////////////////////////////////////////////////
-void CBotStack::Reset(void* pUser)
+void CBotStack::Reset()
{
- m_timer = m_initimer; // resets the timer
+ m_timer = m_initimer; // resets the timer
m_error = CBotNoErr;
// m_start = 0;
// m_end = 0;
m_labelBreak.clear();
- m_pUser = pUser;
}
////////////////////////////////////////////////////////////////////////////////
@@ -479,7 +340,7 @@ void CBotStack::SetType(CBotTypResult& type)
}
////////////////////////////////////////////////////////////////////////////////
-CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif)
+CBotVar* CBotStack::FindVar(CBotToken*& pToken, bool bUpdate)
{
CBotStack* p = this;
std::string name = pToken->GetString();
@@ -492,7 +353,7 @@ CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif)
if (pp->GetName() == name)
{
if ( bUpdate )
- pp->Maj(m_pUser, false);
+ pp->Maj(m_pUser);
return pp;
}
@@ -524,7 +385,7 @@ CBotVar* CBotStack::FindVar(const std::string& name)
}
////////////////////////////////////////////////////////////////////////////////
-CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif)
+CBotVar* CBotStack::FindVar(long ident, bool bUpdate)
{
CBotStack* p = this;
while (p != nullptr)
@@ -535,7 +396,7 @@ CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif)
if (pp->GetUniqNum() == ident)
{
if ( bUpdate )
- pp->Maj(m_pUser, false);
+ pp->Maj(m_pUser);
return pp;
}
@@ -547,16 +408,16 @@ CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif)
}
////////////////////////////////////////////////////////////////////////////////
-CBotVar* CBotStack::FindVar(CBotToken& pToken, bool bUpdate, bool bModif)
+CBotVar* CBotStack::FindVar(CBotToken& pToken, bool bUpdate)
{
CBotToken* pt = &pToken;
- return FindVar(pt, bUpdate, bModif);
+ return FindVar(pt, bUpdate);
}
////////////////////////////////////////////////////////////////////////////////
CBotVar* CBotStack::CopyVar(CBotToken& Token, bool bUpdate)
{
- CBotVar* pVar = FindVar( Token, bUpdate );
+ CBotVar* pVar = FindVar(Token, bUpdate);
if ( pVar == nullptr) return nullptr;
@@ -639,11 +500,7 @@ bool CBotStack::Execute()
if (!instr->Run(nullptr, pile)) return false; // \TODO exécution à partir de là
-#if STACKMEM
pile->m_next->Delete();
-#else
- delete pile->m_next;
-#endif
pile->m_next = EOX; // special for recovery
return true;
@@ -716,7 +573,7 @@ void CBotStack::AddVar(CBotVar* pVar)
}
////////////////////////////////////////////////////////////////////////////////
-void CBotStack::SetBotCall(CBotProgram* p)
+void CBotStack::SetProgram(CBotProgram* p)
{
m_prog = p;
m_bFunc = IsFunctionParam::TRUE;
@@ -732,11 +589,16 @@ CBotProgram* CBotStack::GetBotCall(bool bFirst)
}
////////////////////////////////////////////////////////////////////////////////
-void* CBotStack::GetPUser()
+void* CBotStack::GetUserPtr()
{
return m_pUser;
}
+void CBotStack::SetUserPtr(void* user)
+{
+ m_pUser = user;
+}
+
////////////////////////////////////////////////////////////////////////////////
bool CBotStack::ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype)
{
@@ -912,12 +774,8 @@ bool CBotStack::RestoreState(FILE* pf, CBotStack* &pStack)
if (!ReadWord(pf, w)) return false;
if ( w == 0 ) return true;
-#if STACKMEM
- if ( this == nullptr ) pStack = FirstStack();
+ if ( this == nullptr ) pStack = AllocateStack();
else pStack = AddStack();
-#else
- pStack = new CBotStack(this);
-#endif
if ( w == 2 )
{
diff --git a/src/CBot/CBotStack.h b/src/CBot/CBotStack.h
index 0c780fa..4e1566e 100644
--- a/src/CBot/CBotStack.h
+++ b/src/CBot/CBotStack.h
@@ -19,29 +19,21 @@
#pragma once
-// Modules inlcude
#include "CBot/CBotDefines.h"
#include "CBot/CBotTypResult.h"
#include "CBotEnums.h"
-// Local include
-
-// Global include
#include <cstdio>
#include <string>
-// Forward declaration
class CBotInstr;
class CBotExternalCall;
class CBotVar;
class CBotProgram;
class CBotToken;
-/*!
- * \class CBotStack
- * \brief The CBotStack class Management of the execution stack. Actually the
- * only thing it can do is to create an instance of a stack. To use for routine
- * CBotProgram :: Execute(CBotStack)
+/**
+ * \brief The execution stack
*/
class CBotStack
{
@@ -49,52 +41,44 @@ public:
enum class UnknownEnumBlock : unsigned short { UNKNOWN_FALSE = 0, UNKNOWN_TRUE = 1, UNKNOWN_2 = 2 }; // TODO: figure out what these mean ~krzys_h
enum class IsFunctionParam : unsigned short { FALSE = 0, TRUE = 1, UNKNOWN_EOX_SPECIAL = 2 }; // TODO: just guessing the meaning of values, should be verified ~krzys_h
-#if STACKMEM
/**
- * \brief FirstStack Allocate first stack
+ * \brief AllocateStack Allocate the stack
* \return pointer to created stack
*/
- static CBotStack * FirstStack();
+ static CBotStack* AllocateStack();
/** \brief Delete Remove current stack */
void Delete();
-#endif
-
- /**
- * \brief CBotStack Constructor of the stack
- * \param ppapa Not used.
- */
- CBotStack(CBotStack* ppapa);
-
- /** \brief ~CBotStack Destructor */
- ~CBotStack();
+ CBotStack() = delete;
+ ~CBotStack() = delete;
/**
- * \brief StackOver Check if end of stack is reached
- * \return true if end of stack
+ * \brief Check for stack overflow and set error status as needed
+ * \return true on stack overflow
*/
bool StackOver();
/**
- * \brief GetError Get error number of the stack
- * \param [out] start beginning of the stack
- * \param [out] end end of stack
- * \return error number
+ * \brief Get last error
+ * \param[out] start Starting position in code of the error
+ * \param[out] end Ending position in code of the error
+ * \return Error number
*/
CBotError GetError(int& start, int& end);
/**
- * \brief GetError Get error number
- * \return eror number
+ * \brief Get last error
+ * \return Error number
+ * \see GetError(int&, int&) for error position in code
*/
- int GetError();// rend le numéro d'erreur retourné
+ CBotError GetError();
/**
* \brief Reset Reset error at and set user
* \param [in] pUser User of stack
*/
- void Reset(void* pUser);
+ void Reset();
/**
* \brief SetType Determines the type.
@@ -130,9 +114,7 @@ public:
* \param [in] bModif Not used. Probably need to be removed
* \return Found variable
*/
- CBotVar* FindVar(CBotToken* &pToken,
- bool bUpdate = false,
- bool bModif = false);
+ CBotVar* FindVar(CBotToken*& pToken, bool bUpdate);
/**
* \brief Fetch a variable by its token.
@@ -142,9 +124,7 @@ public:
* \param [in] bModif Not used. Probably need to be removed
* \return Found variable
*/
- CBotVar* FindVar(CBotToken& pToken,
- bool bUpdate = false,
- bool bModif = false);
+ CBotVar* FindVar(CBotToken& pToken, bool bUpdate);
/**
* \brief Fetch variable by its name
@@ -161,8 +141,7 @@ public:
* \param [in] bModif Not used. Probably need to be removed
* \return Found variable
*/
- CBotVar* FindVar(long ident, bool bUpdate = false,
- bool bModif = false);
+ CBotVar* FindVar(long ident, bool bUpdate);
/**
* \brief Find variable by its token and returns a copy of it.
@@ -207,9 +186,10 @@ public:
void ResetError(CBotError n, int start, int end);
void SetBreak(int val, const std::string& name);
- void SetBotCall(CBotProgram* p);
+ void SetProgram(CBotProgram* p);
CBotProgram* GetBotCall(bool bFirst = false);
- void* GetPUser();
+ void SetUserPtr(void* user);
+ void* GetUserPtr();
UnknownEnumBlock GetBlock();
@@ -274,7 +254,7 @@ inline int CBotStack::GetState()
return m_state;
}
-inline int CBotStack::GetError()
+inline CBotError CBotStack::GetError()
{
return m_error;
}
diff --git a/src/CBot/CBotVar/CBotVar.cpp b/src/CBot/CBotVar/CBotVar.cpp
index 8499f11..1dd19e1 100644
--- a/src/CBot/CBotVar/CBotVar.cpp
+++ b/src/CBot/CBotVar/CBotVar.cpp
@@ -128,7 +128,7 @@ bool CBotVar::Save1State(FILE* pf)
}
////////////////////////////////////////////////////////////////////////////////
-void CBotVar::Maj(void* pUser, bool bContinu)
+void CBotVar::Maj(void* pUser)
{
/* if (!bContinu && m_pMyThis != nullptr)
m_pMyThis->Maj(pUser, true);*/
diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h
index 22cc222..3bb7c5a 100644
--- a/src/CBot/CBotVar/CBotVar.h
+++ b/src/CBot/CBotVar/CBotVar.h
@@ -349,11 +349,10 @@ public:
/**
* \brief Call the class update function
*
- * \param pUser user pointer to pass to the update function
- * \param bContinue UNUSED
+ * \param pUser User pointer to pass to the update function
* \see CBotClass::SetUpdateFunc()
*/
- virtual void Maj(void* pUser = nullptr, bool bContinue = true);
+ virtual void Maj(void* pUser);
/**
* \brief Set unique identifier of this variable
diff --git a/src/CBot/CBotVar/CBotVarClass.cpp b/src/CBot/CBotVar/CBotVarClass.cpp
index 9a852e9..f7caeb2 100644
--- a/src/CBot/CBotVar/CBotVarClass.cpp
+++ b/src/CBot/CBotVar/CBotVarClass.cpp
@@ -187,7 +187,7 @@ void CBotVarClass::SetClass(CBotClass* pClass)//, int &nIdent)
CBotInstr* p = pv->m_LimExpr; // the different formulas
if ( p != nullptr )
{
- CBotStack* pile = CBotStack::FirstStack(); // an independent stack
+ CBotStack* pile = CBotStack::AllocateStack(); // an independent stack
int n = 0;
int max[100];
@@ -212,7 +212,7 @@ void CBotVarClass::SetClass(CBotClass* pClass)//, int &nIdent)
if ( pv->m_InitExpr != nullptr ) // expression for initialization?
{
#if STACKMEM
- CBotStack* pile = CBotStack::FirstStack(); // an independent stack
+ CBotStack* pile = CBotStack::AllocateStack(); // an independent stack
while(pile->IsOk() && !pv->m_InitExpr->Execute(pile, pn)); // evaluates the expression without timer
@@ -242,7 +242,7 @@ CBotClass* CBotVarClass::GetClass()
}
////////////////////////////////////////////////////////////////////////////////
-void CBotVarClass::Maj(void* pUser, bool bContinu)
+void CBotVarClass::Maj(void* pUser)
{
/* if (!bContinu && m_pMyThis != nullptr)
m_pMyThis->Maj(pUser, true);*/
@@ -409,7 +409,7 @@ void CBotVarClass::DecrementUse()
CBotStack* pile = nullptr;
err = pile->GetError(start,end); // stack == nullptr it does not bother!
- pile = CBotStack::FirstStack(); // clears the error
+ pile = CBotStack::AllocateStack(); // clears the error
CBotVar* ppVars[1];
ppVars[0] = nullptr;
diff --git a/src/CBot/CBotVar/CBotVarClass.h b/src/CBot/CBotVar/CBotVarClass.h
index bc3d6b5..2f8a236 100644
--- a/src/CBot/CBotVar/CBotVarClass.h
+++ b/src/CBot/CBotVar/CBotVarClass.h
@@ -51,7 +51,7 @@ public:
bool Save1State(FILE* pf) override;
- void Maj(void* pUser, bool bContinue) override;
+ void Maj(void* pUser) override;
//! \name Reference counter
//@{
diff --git a/src/CBot/CBotVar/CBotVarPointer.cpp b/src/CBot/CBotVar/CBotVarPointer.cpp
index e289923..2d98506 100644
--- a/src/CBot/CBotVar/CBotVarPointer.cpp
+++ b/src/CBot/CBotVar/CBotVarPointer.cpp
@@ -62,12 +62,12 @@ CBotVarPointer::~CBotVarPointer()
}
////////////////////////////////////////////////////////////////////////////////
-void CBotVarPointer::Maj(void* pUser, bool bContinu)
+void CBotVarPointer::Maj(void* pUser)
{
/* if ( !bContinu && m_pMyThis != nullptr )
m_pMyThis->Maj(pUser, false);*/
- if ( m_pVarClass != nullptr) m_pVarClass->Maj(pUser, false);
+ if ( m_pVarClass != nullptr) m_pVarClass->Maj(pUser);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/CBot/CBotVar/CBotVarPointer.h b/src/CBot/CBotVar/CBotVarPointer.h
index 070a533..6eb8d4e 100644
--- a/src/CBot/CBotVar/CBotVarPointer.h
+++ b/src/CBot/CBotVar/CBotVarPointer.h
@@ -60,7 +60,7 @@ public:
bool Save1State(FILE* pf) override;
- void Maj(void* pUser, bool bContinue) override;
+ void Maj(void* pUser) override;
bool Eq(CBotVar* left, CBotVar* right) override;
bool Ne(CBotVar* left, CBotVar* right) override;
diff --git a/src/script/script.cpp b/src/script/script.cpp
index b7d24be..08110da 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -508,7 +508,7 @@ void PutList(const char *baseName, bool bArray, CBotVar *var, Ui::CList *list, i
index = 0;
while ( var != nullptr )
{
- var->Maj(nullptr, false);
+ var->Maj(nullptr);
pStatic = var->GetStaticVar(); // finds the static element
p = pStatic->GetName(); // variable name
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list