Give PropLists an ObjectNumber

stable-5.2
Günther Brammer 2009-04-19 23:33:42 +02:00
parent 64c7be0429
commit 4b022c0a45
4 changed files with 7 additions and 13 deletions

View File

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

View File

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

View File

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

View File

@ -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));
}