Exemplo n.º 1
0
void MeshEntity::Destroy()
{
    traceIn(MeshEntity::Destroy);

    int i;

    DestroyObject(shadowDecal);
    DestroyObject(compositeShadow);

    lightmap.FreeData();

    for(i=0; i<MeshLights.Num(); i++)
        MeshLights[i].light->RemoveEntity(this, MeshLights[i].side);

    for(i=0; i<MaterialList.Num(); i++)
        ReleaseMaterial(MaterialList[i]);
    MaterialList.Clear();

    if(mesh)
        RM->ReleaseMesh(mesh);

    Super::Destroy();

    traceOut;
}
Exemplo n.º 2
0
void DestroyObject(JSON *obj){
    if (obj == NULL) return;
    switch (obj->type){
        case JSON_STRING:{
            free(obj->valuestring);
            break;
        }
        case JSON_ARRAY:{
            JSON *item = obj->son, *nxt_item;
            for ( ; item != NULL; item = nxt_item){
                nxt_item = item->next;
                DestroyObject(item);
            }
            break;
        }
        case JSON_OBJECT:{
            JSON *item = obj->son, *nxt_item;
            for ( ; item != NULL; item = nxt_item){
                nxt_item = item->next;
                DestroyObject(item);
            }
            break;
        }
        case JSON_ENTRY:{
            free(obj->key);
            DestroyObject(obj->value);
            break;
        }
    }
    free(obj);
}
Exemplo n.º 3
0
void CGrenade::State(u32 state) 
{
	switch (state)
	{
	case eThrowStart:
		{
			Fvector						C;
			Center						(C);
			PlaySound					("sndCheckout", C);
		}break;
	case eThrowEnd:
		{
			if(m_thrown)
			{
				if (m_pPhysicsShell)
					m_pPhysicsShell->Deactivate();
				xr_delete	( m_pPhysicsShell );
				m_dwDestroyTime			= 0xffffffff;
				PutNextToSlot			();
				if (Local())
				{
#ifndef MASTER_GOLD
					Msg( "Destroying local grenade[%d][%d]", ID(), Device.dwFrame );
#endif // #ifndef MASTER_GOLD
					DestroyObject();
				}
				
			};
		}break;
	};
	inherited::State( state );
}
Exemplo n.º 4
0
void CGrenade::State(u32 state) 
{
	switch (state)
	{
	case MS_THREATEN:
		{
			Fvector						C;
			Center						(C);
			PlaySound					(sndCheckout,C);
		}break;
	case MS_HIDDEN:
		{
			if(m_thrown)
			{
				if (m_pPhysicsShell)	m_pPhysicsShell->Deactivate();
				xr_delete				(m_pPhysicsShell);
				m_dwDestroyTime			= 0xffffffff;
				
				if(H_Parent())
					PutNextToSlot		();

				if (Local())
				{
					#ifdef DEBUG
					Msg("Destroying local grenade[%d][%d]",ID(),Device.dwFrame);
					#endif
					DestroyObject		();
				}
				
			};
		}break;
	};
	inherited::State(state);
}
Exemplo n.º 5
0
void GameRoom::CleanUpResources()
{
	for (std::map<GLint, std::shared_ptr<GameObject>>::iterator iter = RoomObjects.begin(); iter != RoomObjects.end();)
	{
		if (iter->second->CheckDestroy(Game::GetInstance().GetTimeService().GetDeltaTime()))
		{
				
			DestroyObject(*iter->second);
			iter = RoomObjects.begin();
		}
		else
		{
			for (size_t j = 0; j < iter->second->components.size(); j++)
			{
				if (iter->second->components[j]->CheckDestroy(Game::GetInstance().GetTimeService().GetDeltaTime()))
				{
					delete iter->second->components[j];
					iter->second->components.erase(iter->second->components.begin() + j);
					j--;
				}
			}
			iter++;
		}
			
	}
}
Exemplo n.º 6
0
void CGrenade::State(u32 state) 
{
	switch (state)
	{
	case MS_THREATEN:
		{
			Fvector						C;
			Center						(C);
			PlaySound					(sndCheckout,C);
		}break;
	case MS_HIDDEN:
		{
			if(m_thrown)
			{
				if (m_pPhysicsShell)	m_pPhysicsShell->Deactivate();
				xr_delete				(m_pPhysicsShell);
				m_dwDestroyTime			= 0xffffffff;
				PutNextToSlot			();
				if (Local())			DestroyObject		();
				
			};
		}break;
	};
	inherited::State(state);
}
Exemplo n.º 7
0
void GameRoom::DestroyObject(GameObject &toDestroy)
{
	for (size_t i = 0; i < toDestroy.children.size(); i++)//recursively destroys all the hierarchy beneath the object
	{
		DestroyObject(*toDestroy.children[i]);
	}
	RoomObjects.erase(toDestroy.objectID);
}
Exemplo n.º 8
0
int create_bitmap(bitmap_t **pbitmap, int width, int height)
{
    size_t size;
    size_t pitch;
    bitmap_t  *bitmap;
    uint64_t  gaddr;
    void     *uaddr;

    struct radeon_device *rdev = main_device;
    struct radeon_bo     *sobj = NULL;

    int   r;

    bitmap = CreateObject(GetPid(), sizeof(bitmap_t));
    if( bitmap == NULL)
    {
        *pbitmap = NULL;
        return -1;
    }

    pitch = radeon_align_pitch(rdev, width, 32, false) * 4;

    size = pitch * height;

    r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
                         RADEON_GEM_DOMAIN_GTT, &sobj);
    if (r) {
        goto fail;
    }
    r = radeon_bo_reserve(sobj, false);
    if (unlikely(r != 0))
        goto fail;
    r = radeon_bo_pin(sobj, RADEON_GEM_DOMAIN_GTT, &gaddr);
    if (r) {
        goto fail;
    }

    r = radeon_bo_user_map(sobj, &uaddr);
    if (r) {
        goto fail;
    }

    bitmap->width  = width;
    bitmap->height = height;
    bitmap->stride = pitch;
    bitmap->gaddr  = gaddr;
    bitmap->uaddr  = uaddr;
    bitmap->robj   = sobj;

    *pbitmap       = bitmap;
    return 0;

fail:

    DestroyObject(bitmap);
    return -1;

};
Exemplo n.º 9
0
void Registry::DestroyNominated()
{
	// copy the elements in deathrow because when we delete
	// objects, they may release other objects.
	std::vector<Handle> dr(deathrow.begin(), deathrow.end());
	deathrow.clear();
	for (auto const &ob : dr)
		DestroyObject(ob);
}
Exemplo n.º 10
0
void CBreakableObject::SendDestroy()
{
	if (Local())	DestroyObject	();
//	NET_Packet		P;
//	u_EventGen		(P,GE_DESTROY,ID());
//	Msg				("ge_destroy: [%d] - %s",ID(),*cName());
//	if (Local())	u_EventSend			(P);
	bRemoved=true;
}
Exemplo n.º 11
0
void Registry::ReleaseWhite()
{
	// make a copy of the white set to avoid mutation while iterating
	nstd::vector<Handle> to_delete(white.begin(), white.end());
	white.clear();
	foreach (Handle handle, to_delete)
	{
		DestroyObject(handle);
	}
Exemplo n.º 12
0
void Burger::LinkedListObjects::Destroy(void)
{
	// Get the root pointer
	Object *pStart = m_pRoot;
	if (pStart) {
		do {
			DestroyObject(pStart);
		} while ((pStart = m_pRoot)!=NULL);
	}
}
Exemplo n.º 13
0
void ReplaceItemInObject(JSON *object, const char *key, JSON *new_value){
    JSON *it = object->son;
    if (it==NULL)
        return; //fail
    for ( ; it != NULL&& strcmp(it->key, key) != 0; it = it->next);
    if (it==NULL)
        return; //fail
    DestroyObject(it->value);
    it->value = new_value;
}
Exemplo n.º 14
0
void CWeaponAmmo::OnH_B_Independent(bool just_before_destroy) 
{
	if(!Useful()) {
		
		if (Local()){
			DestroyObject	();
		}
		m_ready_to_destroy	= true;
	}
	inherited::OnH_B_Independent(just_before_destroy);
}
Exemplo n.º 15
0
STRING TimeToString(const struct tm* t)
{
  STRING _s;
  _s = CreateObject(char, 20);
  if(!strftime(_s, 20, "%Y-%m-%d %H:%M:%S", t))
  {
    DestroyObject(_s);
    return NULL;
  }
  return _s;
}
Exemplo n.º 16
0
void GameRoom::ClearRoom()
{
	for (std::map<GLint, std::shared_ptr<GameObject>>::iterator iter = RoomObjects.begin(); iter != RoomObjects.end();)
	{
		if (!(iter->second->dontDestroyOnClean))
		{
			DestroyObject(*iter->second);
			iter = RoomObjects.begin();
		}
		else
			iter++;
	}
}
Exemplo n.º 17
0
void CWBQuadObject::Release(uint32 uSlot, CTrMirrorBuffer* pMgr)
{
	CMirrorBuffer* pBuffer = pMgr->GetWriteBuffer();
	
	pBuffer->RestoreIdleSlot(uSlot);

	CMirrorPatch* pPatch = pMgr->GetCurWBPatch();
	pPatch->AddCmd(new (pPatch)CWBQuadObjectReleasedCmd(uSlot));

	pMgr->AddDiscardedCmd(uSlot);
	
	DestroyObject();
}
Exemplo n.º 18
0
void Registry::ClearInstances()
{
	// create a set of handles to destroy, then destroy them
	// this can't be done in one pass, as otherwise we would be mutating the
	// container as we traverse it
	nstd::vector<Handle> handles;
	for (auto const &instance : instances)
		handles.push_back(instance.first);

	for (auto const &handle : handles)
		DestroyObject(handle, true);

	instances.clear();
}
Exemplo n.º 19
0
int main() {
	Handle splash = 0;
	CreateImage(splash, splash_png, sizeof(splash_png));
	DrawImage(splash, 0, 0);
	UpdateScreen();
	do {
		Wait(WAIT_KEY);
		if(GetKeys() & MAK_FIRE)
			break;
	} while(1);
	DestroyObject(splash);

	Handle backg = 0;
	CreateImage(backg, ttsdemo_png, sizeof(ttsdemo_png));
	DrawImage(backg, 0, 0);
	UpdateScreen();

	int oldKeys = GetKeys();
	while(1) {
		Wait(WAIT_KEY);
		int newKeys = GetKeys();
		int downedKeys = newKeys & (~oldKeys);
		oldKeys = newKeys;

		if(downedKeys)
			StopSpeaking();

		if(downedKeys & MAK_FIRE) {
			StartSpeaking("Du står i korsningen Götgatan Åsögatan riktning Slussen. En meter till "
				"vänster om dig är ett övergångställe, för passage över Götgatan med "
				"tryckknapp för gångtrafikanter. Vid trottoarkanten löper en cykelväg.");
		}
		if(downedKeys & MAK_DOWN) {
			StartSpeaking("Tre meter bakom dig i riktning Skanstull är ett övergångställe för "
				"passage över Åsögatan.");
		}
		if(downedKeys & MAK_UP) {
			StartSpeaking("Trottoaren rakt framfortsätter 50 meter till nästa korsning Folkungagatan. "
				"På andra sidan av övergångstället finns ingångar till tunnelbanestation "
				"medborgarplatsen.");
		}
		/*if(downedKeys & MAK_RIGHT) {
		StartSpeaking("Am I right? Of course I'm right.");
		}
		if(downedKeys & MAK_LEFT) {
		StartSpeaking("No one is left behind.");
		}*/
	}
	return 0;
}
Exemplo n.º 20
0
double GetRealFromKeyboard()
{
  STRING _s;
  double _d;
  char _junk;
  while(TRUE)
  {
    _s = GetStringFromKeyboard();
    switch(sscanf(_s, " %lf %c", &_d, &_junk))
    {
    case 1:
      DestroyObject(_s);
      return _d;
    case 2:
      printf("Unexpected character '%c'.\n", _junk);
      break;
    default:
      printf("Please input an real number.\n");
      break;
    }
    DestroyObject(_s);
    printf("Retry: ");
  }
}
Exemplo n.º 21
0
void ReplaceItemInArray(JSON *array, int which, JSON *new_item){
    JSON *it = array->son;
    if (it==NULL)
        return; // fail
    int count = 0;
    for ( ; it != NULL&& count < which; it = it->next, ++count);
    assert(count == which);
    new_item->next = it->next;
    if (it->next != NULL)
        it->next->last = new_item;
    new_item->last = it->last;
    if (it->last != NULL)
        it->last->next = new_item;
    DestroyObject(it);
}
Exemplo n.º 22
0
int GetIntegerFromKeyboard()
{
  STRING _s;
  int _n;
  char _junk;
  while(TRUE)
  {
    _s = GetStringFromKeyboard();
    switch(sscanf(_s, " %d %c", &_n, &_junk))
    {
    case 1:
      DestroyObject(_s);
      return _n;
    case 2:
      printf("Unexpected character '%c'.\n", _junk);
      break;
    default:
      printf("Please input an integer.\n");
      break;
    }
    DestroyObject(_s);
    printf("Retry: ");
  }
}
Exemplo n.º 23
0
void	cBullet::Update()
{ 
	if( m_pResourceFile->GetKey() == "virus" )
	{
		m_vRotation.y += 0.25f * D3DX_PI * _GETSINGLE( cSystemMgr )->GetDeltaTime();

	}
	if( m_vPos.z > 200.0f || m_vPos.z < -50.0f )
	{
		DestroyObject();
	}
	DirectionMove();
	DirectionRotation();
	Translation();
}
Exemplo n.º 24
0
void OutdoorLevel::RemoveEntity(Entity *ent, BOOL bChildren)
{
    if(!GetEntityData(ent))
        return;

    int i;
    BOOL isLight = ent->IsOf(GetClass(Light));
    BOOL isMeshEnt = ent->IsOf(GetClass(MeshEntity));

    OutdoorEntityData *entData = GetOutdoorEntityData(ent);

    if(entData->Blocks.Num() || entData->VisBlocks.Num())
    {
        if(isLight)
        {
            for(i=0; i<entData->Blocks.Num(); i++)
                entData->Blocks[i]->lights.RemoveItem(static_cast<Light*>(ent));

            for(i=0; i<entData->VisBlocks.Num(); i++)
                entData->VisBlocks[i]->visLights.RemoveItem(static_cast<Light*>(ent));
        }
        else
        {
            for(i=0; i<entData->Blocks.Num(); i++)
                entData->Blocks[i]->entities.RemoveItem(ent);

            if(isMeshEnt)
            {
                for(i=0; i<entData->VisBlocks.Num(); i++)
                    entData->VisBlocks[i]->visMeshEntities.RemoveItem(static_cast<MeshEntity*>(ent));
            }
            else
            {
                for(i=0; i<entData->VisBlocks.Num(); i++)
                    entData->VisBlocks[i]->visEntities.RemoveItem(ent);
            }
        }
    }

    DestroyObject(GetEntityData(ent));
    GetEntityData(ent) = NULL;

    if(bChildren)
    {
        for(i=0; i<ent->NumChildren(); i++)
            RemoveEntity(ent->GetChild(i));
    }
}
Exemplo n.º 25
0
void DamageObject(const NMapObjectDamage mod)
{
	TObject *o = ObjGetByUID(mod.UID);
	// Don't bother if object already destroyed
	if (o->Health <= 0)
	{
		return;
	}

	o->Health -= mod.Power;

	// Destroying objects and all the wonderful things that happen
	if (o->Health <= 0)
	{
		DestroyObject(o, mod.Flags, mod.PlayerUID, mod.UID);
	}
}
Exemplo n.º 26
0
void CGameObject::shedule_Update	(u32 dt)
{
	//уничтожить
	if(NeedToDestroyObject())
	{
#ifndef MASTER_GOLD
		Msg("--NeedToDestroyObject for [%d][%d]", ID(), Device.dwFrame);
#endif // #ifndef MASTER_GOLD
		DestroyObject			();
	}

	// Msg							("-SUB-:[%x][%s] CGameObject::shedule_Update",smart_cast<void*>(this),*cName());
	inherited::shedule_Update	(dt);
	
	if(!g_dedicated_server)
		CScriptBinder::shedule_Update(dt);
}
Exemplo n.º 27
0
JSON *DetachItemFromObject(JSON *object, const char *key){
    JSON *it = object->son;
    assert(it!=NULL);
    for ( ; it != NULL&& strcmp(it->key, key) != 0; it = it->next);
    assert(it != NULL);
    if (it->last!=NULL)
        it->last->next = it->next;
    if (it->next!=NULL)
        it->next->last = it->last;
    if (it == object->son)
        object->son = it->next;
    it->next = NULL;
    it->last = NULL;
    JSON *ret = it->value;
    it->value = NULL;
    DestroyObject(it);
    return ret;
}
Exemplo n.º 28
0
//-----------------------------------------------------------------------------
// Purpose: Change our model based on the object we are attaching to
//-----------------------------------------------------------------------------
void CObjectSapper::SetupAttachedVersion( void )
{
	CBaseObject *pObject = dynamic_cast<CBaseObject *>( m_hBuiltOnEntity.Get() );

	Assert( pObject );

	if ( !pObject )
	{
		DestroyObject();
		return;
	}

	if ( IsPlacing() )
	{
		SetModel( GetSapperModelName( SAPPER_MODEL_PLACEMENT ) );
	}	

	BaseClass::SetupAttachedVersion();
}
Exemplo n.º 29
0
STRING GetLineFromFile(FILE* fp)
{
  STRING _s, _t;
  int _n, _c, _size;
  _n = 0;
  _size = BUFSIZ;
  _s = CreateObject(char, _size);
  while((_c = getc(fp)) != '\n' && _c != EOF)
  {
    if(_n >= _size - 1)
    {
      _size <<= 1;
      _t = CreateObject(char, _size);
      strncpy(_t, _s, _n);
      DestroyObject(_s);
      _s = _t;
    }
    _s[_n++] = (char)_c;
  }
Exemplo n.º 30
0
Burger::LinkedListObjects::Object *Burger::LinkedListObjects::IterateForward(ProcAction pProc)
{
	Object *pFirst = m_pRoot;		// Is there a list?
	if (pFirst) {
		Object *pObject = pFirst;
		do {
			Word uResult = pProc(pObject->GetData());	// Call the function
			Object *pNext = pObject->GetNext();			// Get the next entry
			if (uResult&DELETEOBJECT) {					// Dispose of the entry?
				DestroyObject(pObject);
			}
			if (uResult&ABORT) {		// Abort the traversal?
				pFirst = pObject;
				break;
			}
			pObject = pNext;			// Next entry please...
		} while (pObject!=pFirst);		// More left?
	}
	return pFirst;						// Entry I stopped on
}