Example #1
0
size_t PropagateMark()
{
	DObject *obj = Gray;
	assert(obj->IsGray());
	obj->Gray2Black();
	Gray = obj->GCNext;
	return !(obj->ObjectFlags & OF_EuthanizeMe) ? obj->PropagateMark() :
		obj->GetClass()->GetSize();
}
Example #2
0
void DObject::PointerSubstitution (DObject *old, DObject *notOld)
{
	unsigned int i, highest;
	highest = Objects.Size ();

	for (i = 0; i <= highest; i++)
	{
		DObject *current = i < highest ? Objects[i] : NULL;
//		DObject *current = i < highest ? Objects[i] : &bglobal;
		if (current)
		{
			const PClass *info = current->GetClass();
			const size_t *offsets = info->FlatPointers;
			if (offsets == NULL)
			{
				const_cast<PClass *>(info)->BuildFlatPointers();
				offsets = info->FlatPointers;
			}
			while (*offsets != ~(size_t)0)
			{
				if (*(DObject **)((BYTE *)current + *offsets) == old)
				{
					*(DObject **)((BYTE *)current + *offsets) = notOld;
				}
				offsets++;
			}
		}
	}

	for (i = 0; i < BODYQUESIZE; ++i)
	{
		if (bodyque[i] == old)
		{
			bodyque[i] = static_cast<AActor *>(notOld);
		}
	}

	// This is an ugly hack, but it's the best I can do for now.
	for (i = 0; i < MAXPLAYERS; i++)
	{
		if (playeringame[i])
			players[i].FixPointers (old, notOld);
	}

	if (sectors != NULL)
	{
		for (i = 0; i < (unsigned int)numsectors; ++i)
		{
			if (sectors[i].SoundTarget == old)
			{
				sectors[i].SoundTarget = static_cast<AActor *>(notOld);
			}
		}
	}
}
Example #3
0
// Search for references to all objects scheduled for
// destruction and NULL them.
void DObject::DestroyScan ()
{
	unsigned int i, highest;
	int j, destroycount;
	DObject **destroybase;
	destroycount = (int)ToDestroy.Size ();
	if (destroycount == 0)
		return;
	destroybase = &ToDestroy[0] + destroycount;
	destroycount = -destroycount;
	highest = Objects.Size ();

	for (i = 0; i <= highest; i++)
	{
		DObject *current = i < highest ? Objects[i] : NULL;
//		DObject *current = i < highest ? Objects[i] : &bglobal;
		if (current)
		{
			const PClass *info = current->GetClass();
			const size_t *offsets = info->FlatPointers;
			if (offsets == NULL)
			{
				const_cast<PClass *>(info)->BuildFlatPointers();
				offsets = info->FlatPointers;
			}
			while (*offsets != ~(size_t)0)
			{
				j = destroycount;
				do
				{
					if (*(DObject **)((BYTE *)current + *offsets) == *(destroybase + j))
					{
						*(DObject **)((BYTE *)current + *offsets) = NULL;
					}
				} while (++j);
				offsets++;
			}
		}
	}

	j = destroycount;
	do
	{
		for (i = 0; i < BODYQUESIZE; ++i)
		{
			if (bodyque[i] == *(destroybase + j))
			{
				bodyque[i] = NULL;
			}
		}

	} while (++j);

	// This is an ugly hack, but it's the best I can do for now.
	for (i = 0; i < MAXPLAYERS; i++)
	{
		if (playeringame[i])
		{
			j = destroycount;
			do
			{
				players[i].FixPointers (*(destroybase + j), NULL);
			} while (++j);
		}
	}

	for (i = 0; i < (unsigned int)numsectors; ++i)
	{
		j = destroycount;
		do
		{
			if (sectors[i].SoundTarget == *(destroybase + j))
			{
				sectors[i].SoundTarget = NULL;
			}
		} while (++j);
	}
}