diff --git a/src/CBot/CBotVar/CBotVar.cpp b/src/CBot/CBotVar/CBotVar.cpp index 836b2a7d..a0bf3597 100644 --- a/src/CBot/CBotVar/CBotVar.cpp +++ b/src/CBot/CBotVar/CBotVar.cpp @@ -49,7 +49,7 @@ namespace CBot long CBotVar::m_identcpt = 0; //////////////////////////////////////////////////////////////////////////////// -CBotVar::CBotVar( ) +CBotVar::CBotVar( ) : m_token(nullptr) { m_pMyThis = nullptr; m_pUserPtr = nullptr; @@ -62,9 +62,17 @@ CBotVar::CBotVar( ) m_mPrivate = ProtectionLevel::Public; } -CBotVar::CBotVar(const CBotToken &name) : CBotVar() +CBotVar::CBotVar(const CBotToken &name) : m_token(new CBotToken(name)) { - m_token = new CBotToken(name); + m_pMyThis = nullptr; + m_pUserPtr = nullptr; + m_InitExpr = nullptr; + m_LimExpr = nullptr; + m_type = -1; + m_binit = InitType::UNDEF; + m_ident = 0; + m_bStatic = false; + m_mPrivate = ProtectionLevel::Public; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h index 1a2bff76..8801621d 100644 --- a/src/CBot/CBotVar/CBotVar.h +++ b/src/CBot/CBotVar/CBotVar.h @@ -650,7 +650,7 @@ public: protected: //! The corresponding token, defines the variable name - CBotToken* m_token; + CBotToken* const m_token; //! Type of value. CBotTypResult m_type; //! Initialization status diff --git a/src/CBot/CBotVar/CBotVarArray.cpp b/src/CBot/CBotVar/CBotVarArray.cpp index 207b0f45..ff89920b 100644 --- a/src/CBot/CBotVar/CBotVarArray.cpp +++ b/src/CBot/CBotVar/CBotVarArray.cpp @@ -31,12 +31,11 @@ namespace CBot { //////////////////////////////////////////////////////////////////////////////// -CBotVarArray::CBotVarArray(const CBotToken& name, CBotTypResult& type) +CBotVarArray::CBotVarArray(const CBotToken& name, CBotTypResult& type) : CBotVar(name) { if ( !type.Eq(CBotTypArrayPointer) && !type.Eq(CBotTypArrayBody)) assert(0); - m_token = new CBotToken(name); m_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = nullptr; diff --git a/src/CBot/CBotVar/CBotVarClass.cpp b/src/CBot/CBotVar/CBotVarClass.cpp index de3d274f..0f5349de 100644 --- a/src/CBot/CBotVar/CBotVarClass.cpp +++ b/src/CBot/CBotVar/CBotVarClass.cpp @@ -36,7 +36,7 @@ namespace CBot std::set CBotVarClass::m_instances{}; //////////////////////////////////////////////////////////////////////////////// -CBotVarClass::CBotVarClass(const CBotToken& name, const CBotTypResult& type) +CBotVarClass::CBotVarClass(const CBotToken& name, const CBotTypResult& type) : CBotVar(name) { if ( !type.Eq(CBotTypClass) && !type.Eq(CBotTypIntrinsic) && // by convenience there accepts these types @@ -44,7 +44,6 @@ CBotVarClass::CBotVarClass(const CBotToken& name, const CBotTypResult& type) !type.Eq(CBotTypArrayPointer) && !type.Eq(CBotTypArrayBody)) assert(0); - m_token = new CBotToken(name); m_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = OBJECTCREATED;//nullptr; diff --git a/src/CBot/CBotVar/CBotVarPointer.cpp b/src/CBot/CBotVar/CBotVarPointer.cpp index f98b1463..71c9a4d5 100644 --- a/src/CBot/CBotVar/CBotVarPointer.cpp +++ b/src/CBot/CBotVar/CBotVarPointer.cpp @@ -32,14 +32,13 @@ namespace CBot { //////////////////////////////////////////////////////////////////////////////// -CBotVarPointer::CBotVarPointer(const CBotToken& name, CBotTypResult& type) +CBotVarPointer::CBotVarPointer(const CBotToken& name, CBotTypResult& type) : CBotVar(name) { 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_next = nullptr; m_pMyThis = nullptr; m_pUserPtr = nullptr;