From 30fea5893b7de0773d8d225d8620b70abbcc778b Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 23 Dec 2015 17:50:10 +0100 Subject: [PATCH] Fixed crash from previous commit (oops again) --- src/CBot/CBotClass.cpp | 4 ++-- src/CBot/CBotInstr/CBotBoolean.cpp | 2 +- src/CBot/CBotInstr/CBotCatch.cpp | 2 +- src/CBot/CBotInstr/CBotExprAlpha.cpp | 4 ++-- src/CBot/CBotInstr/CBotExprBool.cpp | 4 ++-- src/CBot/CBotInstr/CBotExprNan.cpp | 2 +- src/CBot/CBotInstr/CBotExprNull.cpp | 2 +- src/CBot/CBotInstr/CBotExprNum.cpp | 4 ++-- src/CBot/CBotInstr/CBotFloat.cpp | 2 +- src/CBot/CBotInstr/CBotFunction.cpp | 2 +- src/CBot/CBotInstr/CBotIString.cpp | 2 +- src/CBot/CBotInstr/CBotInstArray.cpp | 4 ++-- src/CBot/CBotInstr/CBotInt.cpp | 2 +- src/CBot/CBotInstr/CBotTwoOpExpr.cpp | 12 +++++------ src/CBot/CBotStack.cpp | 12 +++++------ src/CBot/CBotToken.cpp | 14 +++++++----- src/CBot/CBotVar/CBotVar.cpp | 32 ++++++++++++++-------------- src/CBot/CBotVar/CBotVar.h | 4 ++-- src/CBot/CBotVar/CBotVarArray.cpp | 6 +++--- src/CBot/CBotVar/CBotVarArray.h | 2 +- src/CBot/CBotVar/CBotVarBoolean.cpp | 4 ++-- src/CBot/CBotVar/CBotVarBoolean.h | 2 +- src/CBot/CBotVar/CBotVarClass.cpp | 4 ++-- src/CBot/CBotVar/CBotVarClass.h | 2 +- src/CBot/CBotVar/CBotVarFloat.cpp | 4 ++-- src/CBot/CBotVar/CBotVarFloat.h | 2 +- src/CBot/CBotVar/CBotVarInt.cpp | 4 ++-- src/CBot/CBotVar/CBotVarInt.h | 2 +- src/CBot/CBotVar/CBotVarPointer.cpp | 4 ++-- src/CBot/CBotVar/CBotVarPointer.h | 2 +- src/CBot/CBotVar/CBotVarString.cpp | 4 ++-- src/CBot/CBotVar/CBotVarString.h | 2 +- 32 files changed, 79 insertions(+), 75 deletions(-) diff --git a/src/CBot/CBotClass.cpp b/src/CBot/CBotClass.cpp index 1f8a3076..07d8f357 100644 --- a/src/CBot/CBotClass.cpp +++ b/src/CBot/CBotClass.cpp @@ -683,7 +683,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond) // make "this" known CBotToken TokenThis(std::string("this"), std::string()); - CBotVar* pThis = CBotVar::Create(&TokenThis, CBotTypResult( CBotTypClass, this ) ); + CBotVar* pThis = CBotVar::Create(TokenThis, CBotTypResult( CBotTypClass, this ) ); pThis->SetUniqNum(-2); pile->AddVar(pThis); @@ -691,7 +691,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond) { // makes "super" known CBotToken TokenSuper(std::string("super"), std::string()); - CBotVar* pThis = CBotVar::Create(&TokenSuper, CBotTypResult( CBotTypClass, m_pParent ) ); + CBotVar* pThis = CBotVar::Create(TokenSuper, CBotTypResult( CBotTypClass, m_pParent ) ); pThis->SetUniqNum(-3); pile->AddVar(pThis); } diff --git a/src/CBot/CBotInstr/CBotBoolean.cpp b/src/CBot/CBotInstr/CBotBoolean.cpp index 802727b2..3cbf45cf 100644 --- a/src/CBot/CBotInstr/CBotBoolean.cpp +++ b/src/CBot/CBotInstr/CBotBoolean.cpp @@ -107,7 +107,7 @@ CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo } } - var = CBotVar::Create(vartoken, CBotTypBoolean);// create the variable (evaluated after the assignment) + var = CBotVar::Create(*vartoken, CBotTypBoolean);// create the variable (evaluated after the assignment) var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); var->SetUniqNum( (static_cast(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); diff --git a/src/CBot/CBotInstr/CBotCatch.cpp b/src/CBot/CBotInstr/CBotCatch.cpp index d187bec9..2388a0cf 100644 --- a/src/CBot/CBotInstr/CBotCatch.cpp +++ b/src/CBot/CBotInstr/CBotCatch.cpp @@ -105,7 +105,7 @@ bool CBotCatch :: TestCatch(CBotStack* &pile, int val) if ( val > 0 || pile->GetType() != CBotTypBoolean ) { - CBotVar* var = CBotVar::Create(static_cast(nullptr), CBotTypBoolean); + CBotVar* var = CBotVar::Create("", CBotTypBoolean); var->SetValInt( pile->GetVal() == val ); pile->SetVar(var); // calls on the stack } diff --git a/src/CBot/CBotInstr/CBotExprAlpha.cpp b/src/CBot/CBotInstr/CBotExprAlpha.cpp index a5a415b4..641eee1e 100644 --- a/src/CBot/CBotInstr/CBotExprAlpha.cpp +++ b/src/CBot/CBotInstr/CBotExprAlpha.cpp @@ -50,7 +50,7 @@ CBotInstr* CBotExprAlpha::Compile(CBotToken* &p, CBotCStack* pStack) inst->SetToken(p); p = p->GetNext(); - CBotVar* var = CBotVar::Create(static_cast(nullptr), CBotTypString); + CBotVar* var = CBotVar::Create("", CBotTypString); pStk->SetVar(var); return pStack->Return(inst, pStk); @@ -63,7 +63,7 @@ bool CBotExprAlpha::Execute(CBotStack* &pj) if (pile->IfStep()) return false; - CBotVar* var = CBotVar::Create(static_cast(nullptr), CBotTypString); + CBotVar* var = CBotVar::Create("", CBotTypString); std::string chaine = m_token.GetString(); chaine = chaine.substr(1, chaine.length()-2); // removes the quotes diff --git a/src/CBot/CBotInstr/CBotExprBool.cpp b/src/CBot/CBotInstr/CBotExprBool.cpp index 94736934..ab639ed4 100644 --- a/src/CBot/CBotInstr/CBotExprBool.cpp +++ b/src/CBot/CBotInstr/CBotExprBool.cpp @@ -54,7 +54,7 @@ CBotInstr* CBotExprBool::Compile(CBotToken* &p, CBotCStack* pStack) inst->SetToken(p); // stores the operation false or true p = p->GetNext(); - CBotVar* var = CBotVar::Create(static_cast(nullptr), CBotTypBoolean); + CBotVar* var = CBotVar::Create("", CBotTypBoolean); pStk->SetVar(var); } @@ -68,7 +68,7 @@ bool CBotExprBool::Execute(CBotStack* &pj) if (pile->IfStep()) return false; - CBotVar* var = CBotVar::Create(static_cast(nullptr), CBotTypBoolean); + CBotVar* var = CBotVar::Create("", CBotTypBoolean); if (GetTokenType() == ID_TRUE) var->SetValInt(1); else var->SetValInt(0); diff --git a/src/CBot/CBotInstr/CBotExprNan.cpp b/src/CBot/CBotInstr/CBotExprNan.cpp index df0a296d..02d07ba4 100644 --- a/src/CBot/CBotInstr/CBotExprNan.cpp +++ b/src/CBot/CBotInstr/CBotExprNan.cpp @@ -45,7 +45,7 @@ bool CBotExprNan::Execute(CBotStack* &pj) CBotStack* pile = pj->AddStack(this); if (pile->IfStep()) return false; - CBotVar* var = CBotVar::Create(static_cast(nullptr), CBotTypInt); + CBotVar* var = CBotVar::Create("", CBotTypInt); var->SetInit(CBotVar::InitType::IS_NAN); // nan pile->SetVar(var); // put on the stack diff --git a/src/CBot/CBotInstr/CBotExprNull.cpp b/src/CBot/CBotInstr/CBotExprNull.cpp index a36b4889..25cad7d1 100644 --- a/src/CBot/CBotInstr/CBotExprNull.cpp +++ b/src/CBot/CBotInstr/CBotExprNull.cpp @@ -46,7 +46,7 @@ bool CBotExprNull::Execute(CBotStack* &pj) CBotStack* pile = pj->AddStack(this); if (pile->IfStep()) return false; - CBotVar* var = CBotVar::Create(static_cast(nullptr), CBotTypNullPointer); + CBotVar* var = CBotVar::Create("", CBotTypNullPointer); var->SetInit(CBotVar::InitType::DEF); // null pointer valid pile->SetVar(var); // place on the stack diff --git a/src/CBot/CBotInstr/CBotExprNum.cpp b/src/CBot/CBotInstr/CBotExprNum.cpp index 633fcb7f..cc2beb0b 100644 --- a/src/CBot/CBotInstr/CBotExprNum.cpp +++ b/src/CBot/CBotInstr/CBotExprNum.cpp @@ -72,7 +72,7 @@ CBotInstr* CBotExprNum::Compile(CBotToken* &p, CBotCStack* pStack) if (pStk->NextToken(p)) { - CBotVar* var = CBotVar::Create(static_cast(nullptr), inst->m_numtype); + CBotVar* var = CBotVar::Create("", inst->m_numtype); pStk->SetVar(var); return pStack->Return(inst, pStk); @@ -88,7 +88,7 @@ bool CBotExprNum::Execute(CBotStack* &pj) if (pile->IfStep()) return false; - CBotVar* var = CBotVar::Create(static_cast(nullptr), m_numtype); + CBotVar* var = CBotVar::Create("", m_numtype); std::string nombre ; if (m_token.GetType() == TokenTypDef) diff --git a/src/CBot/CBotInstr/CBotFloat.cpp b/src/CBot/CBotInstr/CBotFloat.cpp index f7cbfedf..bc71f43b 100644 --- a/src/CBot/CBotInstr/CBotFloat.cpp +++ b/src/CBot/CBotInstr/CBotFloat.cpp @@ -105,7 +105,7 @@ CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool } } - var = CBotVar::Create(vartoken, CBotTypFloat); + var = CBotVar::Create(*vartoken, CBotTypFloat); var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); var->SetUniqNum( (static_cast(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); diff --git a/src/CBot/CBotInstr/CBotFunction.cpp b/src/CBot/CBotInstr/CBotFunction.cpp index 141cdd78..fb74930d 100644 --- a/src/CBot/CBotInstr/CBotFunction.cpp +++ b/src/CBot/CBotInstr/CBotFunction.cpp @@ -236,7 +236,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct // and compiles the following instruction block func->m_openblk = *p; func->m_Block = CBotBlock::Compile(p, pStk, false); - func->m_closeblk = *(p->GetPrev()); + func->m_closeblk = p->GetPrev() != nullptr ? *(p->GetPrev()) : CBotToken(); if ( pStk->IsOk() ) { if ( func->m_bPublic ) // public function, return known for all diff --git a/src/CBot/CBotInstr/CBotIString.cpp b/src/CBot/CBotInstr/CBotIString.cpp index 90001888..04220f8c 100644 --- a/src/CBot/CBotInstr/CBotIString.cpp +++ b/src/CBot/CBotInstr/CBotIString.cpp @@ -89,7 +89,7 @@ CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo }*/ } - CBotVar* var = CBotVar::Create(vartoken, CBotTypString); + CBotVar* var = CBotVar::Create(*vartoken, CBotTypString); var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); var->SetUniqNum( (static_cast(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); diff --git a/src/CBot/CBotInstr/CBotInstArray.cpp b/src/CBot/CBotInstr/CBotInstArray.cpp index 9909a57c..e2e9fcc0 100644 --- a/src/CBot/CBotInstr/CBotInstArray.cpp +++ b/src/CBot/CBotInstr/CBotInstArray.cpp @@ -89,7 +89,7 @@ CBotInstr* CBotInstArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu } } - CBotVar* var = CBotVar::Create(vartoken, type); // create an instance + CBotVar* var = CBotVar::Create(*vartoken, type); // create an instance inst->m_typevar = type; var->SetUniqNum( @@ -157,7 +157,7 @@ bool CBotInstArray::Execute(CBotStack* &pj) m_typevar.SetArray(max); // store the limitations // create simply a nullptr pointer - CBotVar* var = CBotVar::Create(m_var->GetToken(), m_typevar); + CBotVar* var = CBotVar::Create(*(m_var->GetToken()), m_typevar); var->SetPointer(nullptr); var->SetUniqNum((static_cast(m_var))->m_nIdent); pj->AddVar(var); diff --git a/src/CBot/CBotInstr/CBotInt.cpp b/src/CBot/CBotInstr/CBotInt.cpp index bafce954..d26599f2 100644 --- a/src/CBot/CBotInstr/CBotInt.cpp +++ b/src/CBot/CBotInstr/CBotInt.cpp @@ -119,7 +119,7 @@ CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool n } { - CBotVar* var = CBotVar::Create(vartoken, CBotTypInt);// create the variable (evaluated after the assignment) + CBotVar* var = CBotVar::Create(*vartoken, CBotTypInt);// create the variable (evaluated after the assignment) var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); // if initialized with assignment var->SetUniqNum( //set it with a unique number (static_cast(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); diff --git a/src/CBot/CBotInstr/CBotTwoOpExpr.cpp b/src/CBot/CBotInstr/CBotTwoOpExpr.cpp index 43d7c0dd..e2727f09 100644 --- a/src/CBot/CBotInstr/CBotTwoOpExpr.cpp +++ b/src/CBot/CBotInstr/CBotTwoOpExpr.cpp @@ -260,7 +260,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera CBotTypResult t(type1); t.SetType(TypeRes); // is a variable on the stack for the type of result - pStk->SetVar(CBotVar::Create(static_cast(nullptr), t)); + pStk->SetVar(CBotVar::Create("", t)); // and returns the requested object return pStack->Return(inst, pStk); @@ -313,14 +313,14 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack) // for OR and AND logic does not evaluate the second expression if not necessary if ( (GetTokenType() == ID_LOG_AND || GetTokenType() == ID_TXT_AND ) && pStk1->GetVal() == false ) { - CBotVar* res = CBotVar::Create( static_cast(nullptr), CBotTypBoolean); + CBotVar* res = CBotVar::Create("", CBotTypBoolean); res->SetValInt(false); pStk1->SetVar(res); return pStack->Return(pStk1); // transmits the result } if ( (GetTokenType() == ID_LOG_OR||GetTokenType() == ID_TXT_OR) && pStk1->GetVal() == true ) { - CBotVar* res = CBotVar::Create( static_cast(nullptr), CBotTypBoolean); + CBotVar* res = CBotVar::Create("", CBotTypBoolean); res->SetValInt(true); pStk1->SetVar(res); return pStack->Return(pStk1); // transmits the result @@ -378,7 +378,7 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack) } // creates a variable for the result - CBotVar* result = CBotVar::Create( static_cast(nullptr), TypeRes); + CBotVar* result = CBotVar::Create("", TypeRes); // creates a variable to perform the calculation in the appropriate type TypeRes = MAX(type1.GetType(), type2.GetType()); @@ -391,8 +391,8 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack) CBotVar* temp; if ( TypeRes == CBotTypPointer ) TypeRes = CBotTypNullPointer; - if ( TypeRes == CBotTypClass ) temp = CBotVar::Create( static_cast(nullptr), CBotTypResult(CBotTypIntrinsic, type1.GetClass() ) ); - else temp = CBotVar::Create( static_cast(nullptr), TypeRes ); + if ( TypeRes == CBotTypClass ) temp = CBotVar::Create("", CBotTypResult(CBotTypIntrinsic, type1.GetClass() ) ); + else temp = CBotVar::Create("", TypeRes ); CBotError err = CBotNoErr; // is a operation according to request diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp index cb4ecc8b..f91b56e5 100644 --- a/src/CBot/CBotStack.cpp +++ b/src/CBot/CBotStack.cpp @@ -1021,17 +1021,17 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) { case CBotTypInt: case CBotTypBoolean: - pNew = CBotVar::Create(&token, w); // creates a variable + pNew = CBotVar::Create(token, w); // creates a variable if (!ReadWord(pf, w)) return false; pNew->SetValInt(static_cast(w), defnum); break; case CBotTypFloat: - pNew = CBotVar::Create(&token, w); // creates a variable + pNew = CBotVar::Create(token, w); // creates a variable if (!ReadFloat(pf, ww)) return false; pNew->SetValFloat(ww); break; case CBotTypString: - pNew = CBotVar::Create(&token, w); // creates a variable + pNew = CBotVar::Create(token, w); // creates a variable if (!ReadString(pf, s)) return false; pNew->SetValString(s); break; @@ -1050,7 +1050,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) CBotVar* p = nullptr; if ( id ) p = CBotVarClass::Find(id) ; - pNew = new CBotVarClass(&token, r); // directly creates an instance + pNew = new CBotVarClass(token, r); // directly creates an instance // attention cptuse = 0 if ( !RestoreState(pf, (static_cast(pNew))->m_pVar)) return false; pNew->SetIdent(id); @@ -1068,7 +1068,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) case CBotTypNullPointer: if (!ReadString(pf, s)) return false; { - pNew = CBotVar::Create(&token, CBotTypResult(w, s));// creates a variable + pNew = CBotVar::Create(token, CBotTypResult(w, s));// creates a variable // CBotVarClass* p = nullptr; long id; ReadLong(pf, id); @@ -1089,7 +1089,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) CBotTypResult r; if (!ReadType(pf, r)) return false; - pNew = CBotVar::Create(&token, r); // creates a variable + pNew = CBotVar::Create(token, r); // creates a variable // returns a copy of the original instance CBotVar* pInstance = nullptr; diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp index 6c7919b5..4e1c31d9 100644 --- a/src/CBot/CBotToken.cpp +++ b/src/CBot/CBotToken.cpp @@ -186,12 +186,16 @@ void CBotToken::ClearDefineNum() //////////////////////////////////////////////////////////////////////////////// const CBotToken& CBotToken::operator=(const CBotToken& src) { - delete m_next; - m_next = nullptr; - m_prev = nullptr; + assert(m_prev == nullptr); + if (m_next != nullptr) + { + m_next->m_prev = nullptr; + delete m_next; + m_next = nullptr; + } - m_text = src.m_text; - m_sep = src.m_sep; + m_text = src.m_text; + m_sep = src.m_sep; m_type = src.m_type; m_keywordId = src.m_keywordId; diff --git a/src/CBot/CBotVar/CBotVar.cpp b/src/CBot/CBotVar/CBotVar.cpp index 677a126e..847509fb 100644 --- a/src/CBot/CBotVar/CBotVar.cpp +++ b/src/CBot/CBotVar/CBotVar.cpp @@ -137,14 +137,14 @@ void CBotVar::Maj(void* pUser, bool bContinu) } //////////////////////////////////////////////////////////////////////////////// -CBotVar* CBotVar::Create(const CBotToken* name, CBotType type ) +CBotVar* CBotVar::Create(const CBotToken& name, CBotType type) { CBotTypResult t(type); return Create(name, t); } //////////////////////////////////////////////////////////////////////////////// -CBotVar* CBotVar::Create(const CBotToken* name, CBotTypResult type) +CBotVar* CBotVar::Create(const CBotToken& name, CBotTypResult type) { switch (type.GetType()) { @@ -213,23 +213,23 @@ CBotVar* CBotVar::Create(const std::string& n, CBotTypResult type) { case CBotTypShort: case CBotTypInt: - return new CBotVarInt(&name); + return new CBotVarInt(name); case CBotTypFloat: - return new CBotVarFloat(&name); + return new CBotVarFloat(name); case CBotTypBoolean: - return new CBotVarBoolean(&name); + return new CBotVarBoolean(name); case CBotTypString: - return new CBotVarString(&name); + return new CBotVarString(name); case CBotTypPointer: case CBotTypNullPointer: { - CBotVarPointer* p = new CBotVarPointer(&name, type); + CBotVarPointer* p = new CBotVarPointer(name, type); // p->SetClass(type.GetClass()); return p; } case CBotTypIntrinsic: { - CBotVarClass* p = new CBotVarClass(&name, type); + CBotVarClass* p = new CBotVarClass(name, type); // p->SetClass(type.GetClass()); return p; } @@ -238,20 +238,20 @@ CBotVar* CBotVar::Create(const std::string& n, CBotTypResult type) // creates a new instance of a class // and returns the POINTER on this instance { - CBotVarClass* instance = new CBotVarClass(&name, type); - CBotVarPointer* pointer = new CBotVarPointer(&name, type); + CBotVarClass* instance = new CBotVarClass(name, type); + CBotVarPointer* pointer = new CBotVarPointer(name, type); pointer->SetPointer( instance ); // pointer->SetClass( type.GetClass() ); return pointer; } case CBotTypArrayPointer: - return new CBotVarArray(&name, type); + return new CBotVarArray(name, type); case CBotTypArrayBody: { - CBotVarClass* instance = new CBotVarClass(&name, type); - CBotVarArray* array = new CBotVarArray(&name, type); + CBotVarClass* instance = new CBotVarClass(name, type); + CBotVarArray* array = new CBotVarArray(name, type); array->SetPointer( instance ); CBotVar* pv = array; @@ -273,7 +273,7 @@ CBotVar* CBotVar::Create(const std::string& n, CBotTypResult type) CBotVar* CBotVar::Create(const std::string& name, CBotType type, CBotClass* pClass) { CBotToken token( name, "" ); - CBotVar* pVar = Create( &token, type ); + CBotVar* pVar = Create( token, type ); if ( type == CBotTypPointer && pClass == nullptr ) // pointer "null" ? return pVar; @@ -295,7 +295,7 @@ CBotVar* CBotVar::Create(const std::string& name, CBotType type, CBotClass* pCla CBotVar* CBotVar::Create(const std::string& name, CBotClass* pClass) { CBotToken token( name, "" ); - CBotVar* pVar = Create( &token, CBotTypResult( CBotTypClass, pClass ) ); + CBotVar* pVar = Create( token, CBotTypResult( CBotTypClass, pClass ) ); // pVar->SetClass( pClass ); return pVar; } @@ -354,7 +354,7 @@ void CBotVar::SetInit(CBotVar::InitType initType) CBotVarClass* instance = GetPointer(); if ( instance == nullptr ) { - instance = new CBotVarClass(nullptr, m_type); + instance = new CBotVarClass(CBotToken(), m_type); // instance->SetClass((static_cast(this))->m_classes); SetPointer(instance); } diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h index fe92e442..c2616ff3 100644 --- a/src/CBot/CBotVar/CBotVar.h +++ b/src/CBot/CBotVar/CBotVar.h @@ -82,14 +82,14 @@ public: * \param name Variable name token * \param type Variable type */ - static CBotVar* Create(const CBotToken* name, CBotType type); + static CBotVar* Create(const CBotToken& name, CBotType type); /** * \brief Create a new variable of a given type described by CBotTypResult * \param name Variable name token * \param type Variable type */ - static CBotVar* Create(const CBotToken* name, CBotTypResult type); + static CBotVar* Create(const CBotToken& name, CBotTypResult type); /** * \brief Create a new variable of a given type of given class instance diff --git a/src/CBot/CBotVar/CBotVarArray.cpp b/src/CBot/CBotVar/CBotVarArray.cpp index e4cd2c3d..3c99b978 100644 --- a/src/CBot/CBotVar/CBotVarArray.cpp +++ b/src/CBot/CBotVar/CBotVarArray.cpp @@ -31,12 +31,12 @@ #include //////////////////////////////////////////////////////////////////////////////// -CBotVarArray::CBotVarArray(const CBotToken* name, CBotTypResult& type ) +CBotVarArray::CBotVarArray(const CBotToken& name, CBotTypResult& type) { if ( !type.Eq(CBotTypArrayPointer) && !type.Eq(CBotTypArrayBody)) assert(0); - m_token = new CBotToken(*name); + m_token = new CBotToken(name); m_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = nullptr; @@ -117,7 +117,7 @@ CBotVar* CBotVarArray::GetItem(int n, bool bExtend) if ( !bExtend ) return nullptr; // creates an instance of the table - CBotVarClass* instance = new CBotVarClass(nullptr, m_type); + CBotVarClass* instance = new CBotVarClass(CBotToken(), m_type); SetPointer( instance ); } return m_pInstance->GetItem(n, bExtend); diff --git a/src/CBot/CBotVar/CBotVarArray.h b/src/CBot/CBotVar/CBotVarArray.h index 989c4fd0..76a18106 100644 --- a/src/CBot/CBotVar/CBotVarArray.h +++ b/src/CBot/CBotVar/CBotVarArray.h @@ -32,7 +32,7 @@ public: /** * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarArray(const CBotToken* name, CBotTypResult& type); + CBotVarArray(const CBotToken& name, CBotTypResult& type); /** * \brief Destructor. Do not call directly, use CBotVar::Destroy() */ diff --git a/src/CBot/CBotVar/CBotVarBoolean.cpp b/src/CBot/CBotVar/CBotVarBoolean.cpp index 81b8f682..57de0f07 100644 --- a/src/CBot/CBotVar/CBotVarBoolean.cpp +++ b/src/CBot/CBotVar/CBotVarBoolean.cpp @@ -26,9 +26,9 @@ //////////////////////////////////////////////////////////////////////////////// -CBotVarBoolean::CBotVarBoolean( const CBotToken* name ) +CBotVarBoolean::CBotVarBoolean(const CBotToken& name) { - m_token = new CBotToken(*name); + m_token = new CBotToken(name); m_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = nullptr; diff --git a/src/CBot/CBotVar/CBotVarBoolean.h b/src/CBot/CBotVar/CBotVarBoolean.h index f78bf046..965ff0fb 100644 --- a/src/CBot/CBotVar/CBotVarBoolean.h +++ b/src/CBot/CBotVar/CBotVarBoolean.h @@ -30,7 +30,7 @@ public: /** * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarBoolean(const CBotToken* name); + CBotVarBoolean(const CBotToken& name); void SetValInt(int val, const std::string& s = nullptr) override; void SetValFloat(float val) override; diff --git a/src/CBot/CBotVar/CBotVarClass.cpp b/src/CBot/CBotVar/CBotVarClass.cpp index 5937a269..9a852e92 100644 --- a/src/CBot/CBotVar/CBotVarClass.cpp +++ b/src/CBot/CBotVar/CBotVarClass.cpp @@ -37,7 +37,7 @@ CBotVarClass* CBotVarClass::m_ExClass = nullptr; //////////////////////////////////////////////////////////////////////////////// -CBotVarClass::CBotVarClass( const CBotToken* name, const CBotTypResult& type) +CBotVarClass::CBotVarClass(const CBotToken& name, const CBotTypResult& type) { if ( !type.Eq(CBotTypClass) && !type.Eq(CBotTypIntrinsic) && // by convenience there accepts these types @@ -45,7 +45,7 @@ CBotVarClass::CBotVarClass( const CBotToken* name, const CBotTypResult& type) !type.Eq(CBotTypArrayPointer) && !type.Eq(CBotTypArrayBody)) assert(0); - m_token = new CBotToken(*name); + m_token = new CBotToken(name); m_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = OBJECTCREATED;//nullptr; diff --git a/src/CBot/CBotVar/CBotVarClass.h b/src/CBot/CBotVar/CBotVarClass.h index ee9a5416..bc3d6b5a 100644 --- a/src/CBot/CBotVar/CBotVarClass.h +++ b/src/CBot/CBotVar/CBotVarClass.h @@ -32,7 +32,7 @@ public: /** * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarClass(const CBotToken* name, const CBotTypResult& type); + CBotVarClass(const CBotToken& name, const CBotTypResult& type); /** * \brief Destructor. Do not call directly, use CBotVar::Destroy() */ diff --git a/src/CBot/CBotVar/CBotVarFloat.cpp b/src/CBot/CBotVar/CBotVarFloat.cpp index 1407dac7..60b8afdc 100644 --- a/src/CBot/CBotVar/CBotVarFloat.cpp +++ b/src/CBot/CBotVar/CBotVarFloat.cpp @@ -31,9 +31,9 @@ #include //////////////////////////////////////////////////////////////////////////////// -CBotVarFloat::CBotVarFloat( const CBotToken* name ) +CBotVarFloat::CBotVarFloat(const CBotToken& name) { - m_token = new CBotToken(*name); + m_token = new CBotToken(name); m_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = nullptr; diff --git a/src/CBot/CBotVar/CBotVarFloat.h b/src/CBot/CBotVar/CBotVarFloat.h index 86f3dfc7..5b44a3be 100644 --- a/src/CBot/CBotVar/CBotVarFloat.h +++ b/src/CBot/CBotVar/CBotVarFloat.h @@ -30,7 +30,7 @@ public: /** * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarFloat(const CBotToken* name); + CBotVarFloat(const CBotToken& name); void SetValInt(int val, const std::string& s = nullptr) override; void SetValFloat(float val) override; diff --git a/src/CBot/CBotVar/CBotVarInt.cpp b/src/CBot/CBotVar/CBotVarInt.cpp index fec48d28..a36f84ee 100644 --- a/src/CBot/CBotVar/CBotVarInt.cpp +++ b/src/CBot/CBotVar/CBotVarInt.cpp @@ -30,9 +30,9 @@ #include //////////////////////////////////////////////////////////////////////////////// -CBotVarInt::CBotVarInt( const CBotToken* name ) +CBotVarInt::CBotVarInt(const CBotToken& name) { - m_token = new CBotToken(*name); + m_token = new CBotToken(name); m_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = nullptr; diff --git a/src/CBot/CBotVar/CBotVarInt.h b/src/CBot/CBotVar/CBotVarInt.h index 3080189b..56f9c68b 100644 --- a/src/CBot/CBotVar/CBotVarInt.h +++ b/src/CBot/CBotVar/CBotVarInt.h @@ -30,7 +30,7 @@ public: /** * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarInt(const CBotToken* name); + CBotVarInt(const CBotToken& name); void SetValInt(int val, const std::string& s = "") override; void SetValFloat(float val) override; diff --git a/src/CBot/CBotVar/CBotVarPointer.cpp b/src/CBot/CBotVar/CBotVarPointer.cpp index 49fda509..e2899239 100644 --- a/src/CBot/CBotVar/CBotVarPointer.cpp +++ b/src/CBot/CBotVar/CBotVarPointer.cpp @@ -33,14 +33,14 @@ #include //////////////////////////////////////////////////////////////////////////////// -CBotVarPointer::CBotVarPointer(const CBotToken* name, CBotTypResult& type ) +CBotVarPointer::CBotVarPointer(const CBotToken& name, CBotTypResult& type) { if ( !type.Eq(CBotTypPointer) && !type.Eq(CBotTypNullPointer) && !type.Eq(CBotTypClass) && // for convenience accepts Class and Intrinsic !type.Eq(CBotTypIntrinsic) ) assert(0); - m_token = new CBotToken(*name); + m_token = new CBotToken(name); m_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = nullptr; diff --git a/src/CBot/CBotVar/CBotVarPointer.h b/src/CBot/CBotVar/CBotVarPointer.h index 276e4e84..070a533b 100644 --- a/src/CBot/CBotVar/CBotVarPointer.h +++ b/src/CBot/CBotVar/CBotVarPointer.h @@ -30,7 +30,7 @@ public: /** * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarPointer(const CBotToken* name, CBotTypResult& type); + CBotVarPointer(const CBotToken& name, CBotTypResult& type); /** * \brief Destructor. Do not call directly, use CBotVar::Destroy() */ diff --git a/src/CBot/CBotVar/CBotVarString.cpp b/src/CBot/CBotVar/CBotVarString.cpp index 6a5645b8..dc942c5d 100644 --- a/src/CBot/CBotVar/CBotVarString.cpp +++ b/src/CBot/CBotVar/CBotVarString.cpp @@ -29,9 +29,9 @@ // Global include //////////////////////////////////////////////////////////////////////////////// -CBotVarString::CBotVarString( const CBotToken* name ) +CBotVarString::CBotVarString(const CBotToken& name) { - m_token = new CBotToken(*name); + m_token = new CBotToken(name); m_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = nullptr; diff --git a/src/CBot/CBotVar/CBotVarString.h b/src/CBot/CBotVar/CBotVarString.h index f0c9105b..ad24a106 100644 --- a/src/CBot/CBotVar/CBotVarString.h +++ b/src/CBot/CBotVar/CBotVarString.h @@ -30,7 +30,7 @@ public: /** * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarString(const CBotToken* name); + CBotVarString(const CBotToken& name); void SetValString(const std::string& val) override; std::string GetValString() override;