[colobot] 82/145: Fix passing "this" as an argument to a method

Didier Raboud odyx at moszumanska.debian.org
Mon Jul 11 12:56:20 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 6491ce0aa5b1139fc8c55e9bc56d999790b187aa
Author: melex750 <melex750 at users.noreply.github.com>
Date:   Tue May 24 10:30:20 2016 -0400

    Fix passing "this" as an argument to a method
---
 src/CBot/CBotInstr/CBotInstrMethode.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/CBot/CBotInstr/CBotInstrMethode.cpp b/src/CBot/CBotInstr/CBotInstrMethode.cpp
index 52a58cc..e0d08a9 100644
--- a/src/CBot/CBotInstr/CBotInstrMethode.cpp
+++ b/src/CBot/CBotInstr/CBotInstrMethode.cpp
@@ -119,7 +119,7 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
 
         pThis->SetName("this");
         pThis->SetUniqNum(-2);
-        pile1->AddVar(pThis);
+        pile1->SetVar(pThis);
         pile1->IncState();
     }
     int        i = 0;
@@ -144,7 +144,7 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
     ppVars[i] = nullptr;
 
     CBotClass*    pClass = CBotClass::Find(m_className);
-    CBotVar*    pThis  = pile1->FindVar(-2, false);
+    CBotVar*    pThis  = pile1->GetVar();
     CBotVar*    pResult = nullptr;
     if (m_typRes.GetType() > 0) pResult = CBotVar::Create("", m_typRes);
     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
     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);
 
     int        i = 0;
@@ -226,7 +229,7 @@ bool CBotInstrMethode::Execute(CBotStack* &pj)
         // Test.Action (Test = Other);
         // Action must act on the value before test = Other!
         pThis->SetName("this");
-        pile1->AddVar(pThis);
+        pile1->SetVar(pThis);
         pile1->IncState();
     }
     int        i = 0;
@@ -250,7 +253,7 @@ bool CBotInstrMethode::Execute(CBotStack* &pj)
     ppVars[i] = nullptr;
 
     CBotClass*    pClass = CBotClass::Find(m_className);
-    CBotVar*    pThis  = pile1->FindVar("this");
+    CBotVar*    pThis  = pile1->GetVar();
     CBotVar*    pResult = nullptr;
     if (m_typRes.GetType()>0) pResult = CBotVar::Create("", m_typRes);
     if (m_typRes.Eq(CBotTypClass))

-- 
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