commit
fc7e621471
|
@ -119,7 +119,7 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
|
||||||
|
|
||||||
pThis->SetName("this");
|
pThis->SetName("this");
|
||||||
pThis->SetUniqNum(-2);
|
pThis->SetUniqNum(-2);
|
||||||
pile1->AddVar(pThis);
|
pile1->SetVar(pThis);
|
||||||
pile1->IncState();
|
pile1->IncState();
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -144,7 +144,7 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
|
||||||
ppVars[i] = nullptr;
|
ppVars[i] = nullptr;
|
||||||
|
|
||||||
CBotClass* pClass = CBotClass::Find(m_className);
|
CBotClass* pClass = CBotClass::Find(m_className);
|
||||||
CBotVar* pThis = pile1->FindVar(-2, false);
|
CBotVar* pThis = pile1->GetVar();
|
||||||
CBotVar* pResult = nullptr;
|
CBotVar* pResult = nullptr;
|
||||||
if (m_typRes.GetType() > 0) pResult = CBotVar::Create("", m_typRes);
|
if (m_typRes.GetType() > 0) pResult = CBotVar::Create("", m_typRes);
|
||||||
if (m_typRes.Eq(CBotTypClass))
|
if (m_typRes.Eq(CBotTypClass))
|
||||||
|
@ -174,7 +174,10 @@ void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, bool bMain)
|
||||||
CBotStack* pile2 = pile1->RestoreStack(); // and for the parameters coming
|
CBotStack* pile2 = pile1->RestoreStack(); // and for the parameters coming
|
||||||
if (pile2 == nullptr) return;
|
if (pile2 == nullptr) return;
|
||||||
|
|
||||||
CBotVar* pThis = pile1->FindVar("this");
|
CBotVar* pThis = pile1->GetVar();
|
||||||
|
|
||||||
|
assert(pThis != nullptr); // see fix for issues #256 & #436
|
||||||
|
|
||||||
pThis->SetUniqNum(-2);
|
pThis->SetUniqNum(-2);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -226,7 +229,7 @@ bool CBotInstrMethode::Execute(CBotStack* &pj)
|
||||||
// Test.Action (Test = Other);
|
// Test.Action (Test = Other);
|
||||||
// Action must act on the value before test = Other!
|
// Action must act on the value before test = Other!
|
||||||
pThis->SetName("this");
|
pThis->SetName("this");
|
||||||
pile1->AddVar(pThis);
|
pile1->SetVar(pThis);
|
||||||
pile1->IncState();
|
pile1->IncState();
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -250,7 +253,7 @@ bool CBotInstrMethode::Execute(CBotStack* &pj)
|
||||||
ppVars[i] = nullptr;
|
ppVars[i] = nullptr;
|
||||||
|
|
||||||
CBotClass* pClass = CBotClass::Find(m_className);
|
CBotClass* pClass = CBotClass::Find(m_className);
|
||||||
CBotVar* pThis = pile1->FindVar("this");
|
CBotVar* pThis = pile1->GetVar();
|
||||||
CBotVar* pResult = nullptr;
|
CBotVar* pResult = nullptr;
|
||||||
if (m_typRes.GetType()>0) pResult = CBotVar::Create("", m_typRes);
|
if (m_typRes.GetType()>0) pResult = CBotVar::Create("", m_typRes);
|
||||||
if (m_typRes.Eq(CBotTypClass))
|
if (m_typRes.Eq(CBotTypClass))
|
||||||
|
|
|
@ -805,6 +805,8 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
|
||||||
|
|
||||||
CBotToken token(name, std::string());
|
CBotToken token(name, std::string());
|
||||||
|
|
||||||
|
bool isClass = false;
|
||||||
|
|
||||||
switch (w)
|
switch (w)
|
||||||
{
|
{
|
||||||
case CBotTypInt:
|
case CBotTypInt:
|
||||||
|
@ -826,6 +828,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
|
||||||
|
|
||||||
// returns an intrinsic object or element of an array
|
// returns an intrinsic object or element of an array
|
||||||
case CBotTypIntrinsic:
|
case CBotTypIntrinsic:
|
||||||
|
isClass = true;
|
||||||
case CBotTypArrayBody:
|
case CBotTypArrayBody:
|
||||||
{
|
{
|
||||||
CBotTypResult r;
|
CBotTypResult r;
|
||||||
|
@ -843,6 +846,17 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
|
||||||
if ( !RestoreState(pf, (static_cast<CBotVarClass*>(pNew))->m_pVar)) return false;
|
if ( !RestoreState(pf, (static_cast<CBotVarClass*>(pNew))->m_pVar)) return false;
|
||||||
pNew->SetIdent(id);
|
pNew->SetIdent(id);
|
||||||
|
|
||||||
|
if (isClass && p == nullptr) // set id for each item in this instance
|
||||||
|
{
|
||||||
|
CBotVar* pVars = pNew->GetItemList();
|
||||||
|
long itemId = 1;
|
||||||
|
while (pVars != nullptr)
|
||||||
|
{
|
||||||
|
pVars->m_ident = itemId++;
|
||||||
|
pVars = pVars->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( p != nullptr )
|
if ( p != nullptr )
|
||||||
{
|
{
|
||||||
delete pNew;
|
delete pNew;
|
||||||
|
|
Loading…
Reference in New Issue