Fix passing "this" as an argument to a method
parent
c19f97bc24
commit
6491ce0aa5
|
@ -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))
|
||||||
|
|
Loading…
Reference in New Issue