From 4b022c0a45a2ceca8d149ae9e10efa5bd5ec7f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Sun, 19 Apr 2009 23:33:42 +0200 Subject: [PATCH] Give PropLists an ObjectNumber --- engine/inc/C4PropList.h | 3 +-- engine/src/C4Game.cpp | 2 -- engine/src/C4Object.cpp | 3 --- engine/src/C4PropList.cpp | 12 ++++++------ 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/engine/inc/C4PropList.h b/engine/inc/C4PropList.h index 7c5b62906..80799cd80 100644 --- a/engine/inc/C4PropList.h +++ b/engine/inc/C4PropList.h @@ -34,8 +34,7 @@ class C4PropList { void SetProperty(C4String * k, const C4Value & to); void ResetProperty(C4String * k); - C4PropList(); - C4PropList(C4PropList * prototype); + C4PropList(C4PropList * prototype = 0); virtual ~C4PropList(); protected: diff --git a/engine/src/C4Game.cpp b/engine/src/C4Game.cpp index 8763b80da..f325857d7 100644 --- a/engine/src/C4Game.cpp +++ b/engine/src/C4Game.cpp @@ -1032,8 +1032,6 @@ C4Object* C4Game::NewObject( C4PropList *pDef, C4Object *pCreator, if (!(pObj=new C4Object)) return NULL; // Initialize object pObj->Init( pDef,pCreator,iOwner,pInfo,iX,iY,iR,xdir,ydir,rdir, iController ); - // Enumerate object - pObj->Number = ++ObjectEnumerationIndex; // Add to object list if (!Objects.Add(pObj)) { delete pObj; return NULL; } // ---- From now on, object is ready to be used in scripts! diff --git a/engine/src/C4Object.cpp b/engine/src/C4Object.cpp index 56c43afc8..092f0f86b 100644 --- a/engine/src/C4Object.cpp +++ b/engine/src/C4Object.cpp @@ -77,8 +77,6 @@ C4Object::C4Object() void C4Object::Default() { id=C4ID_None; - Number=-1; - Status=1; nInfo.Clear(); RemovalDelay=0; Owner=NO_OWNER; @@ -228,7 +226,6 @@ C4Object::~C4Object() #if defined(_DEBUG) // debug: mustn't be listed in any list now - assert(!Game.Objects.ObjectNumber(this)); Game.Objects.Sectors.AssertObjectNotInList(this); #endif } diff --git a/engine/src/C4PropList.cpp b/engine/src/C4PropList.cpp index 5a4159a59..9fb24beac 100644 --- a/engine/src/C4PropList.cpp +++ b/engine/src/C4PropList.cpp @@ -35,15 +35,14 @@ void C4PropList::AssignRemoval() Game.ClearPointers(this); } -C4PropList::C4PropList(): - FirstRef(NULL), prototype(0) - { - Game.Objects.PropLists.Add(this); - } - C4PropList::C4PropList(C4PropList * prototype): + Number(-1), Status(1), FirstRef(NULL), prototype(prototype) { + // Enumerate object + do + Number = ++Game.ObjectEnumerationIndex; + while (Game.Objects.PropLists.Get(Game.ObjectEnumerationIndex)); Game.Objects.PropLists.Add(this); } @@ -52,6 +51,7 @@ C4PropList::~C4PropList() assert(!FirstRef); while (FirstRef) FirstRef->Set(0); Game.Objects.PropLists.Remove(this); + assert(!Game.Objects.ObjectNumber(this)); }