From 397e3124246a67ddb9b7f16b1fecdda6abd3f3cd Mon Sep 17 00:00:00 2001 From: melex750 Date: Wed, 3 Aug 2016 17:52:53 -0400 Subject: [PATCH] Fix RestoreState for subclass instance vars --- src/CBot/CBotStack.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp index 27c648f2..aa67264b 100644 --- a/src/CBot/CBotStack.cpp +++ b/src/CBot/CBotStack.cpp @@ -19,6 +19,8 @@ #include "CBot/CBotStack.h" +#include "CBot/CBotClass.h" + #include "CBot/CBotInstr/CBotFunction.h" #include "CBot/CBotVar/CBotVarPointer.h" @@ -866,10 +868,11 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) if (isClass && p == nullptr) // set id for each item in this instance { CBotVar* pVars = pNew->GetItemList(); - long itemId = 1; - while (pVars != nullptr) + CBotVar* pv = pNew->GetClass()->GetVar(); + while (pVars != nullptr && pv != nullptr) { - pVars->m_ident = itemId++; + pVars->m_ident = pv->m_ident; + pv = pv->GetNext(); pVars = pVars->GetNext(); } }