Exemplo n.º 1
0
static VOID
DestroyTreeView(HWND hTreeView)
{
    HTREEITEM hItem;

    /* Get the first item in the top level */
    hItem = TreeView_GetFirstVisible(hTreeView);
    if (hItem)
    {
        /* Kill it and all children */
        DestroyItem(hTreeView, hItem);

        /* Kill all remaining top level items */
        while (hItem)
        {
            /* Are there any more items at the top level */
            hItem = TreeView_GetNextSibling(hTreeView, hItem);
            if (hItem)
            {
                /*  Kill it and all children */
                DestroyItem(hTreeView, hItem);
            }
        }
    }
}
Exemplo n.º 2
0
void CUIMpTradeWnd::OnBtnRifleAmmo2Clicked(CUIWindow* w, void* d)
{
	CheckDragItemToDestroy				();
	CUIDragDropListEx*	res		= m_list[e_rifle];
	CUICellItem* ci				= (res->ItemsCount())?res->GetItemIdx(0):NULL;
	if(!ci)	
		return;

	CInventoryItem* ii			= (CInventoryItem*)ci->m_pData;
	CWeaponMagazinedWGrenade* wpn = smart_cast<CWeaponMagazinedWGrenade*>(ii);
	if(!wpn)		
		return;

	u32 ammo_idx				= 0;
	
	const shared_str& ammo_name	= wpn->m_ammoTypes2[ammo_idx];

	if ( NULL==m_store_hierarchy->FindItem(ammo_name) )
		return;

	SBuyItemInfo* pitem			= CreateItem		(ammo_name, SBuyItemInfo::e_undefined, false);
	bool b_res					= TryToBuyItem		(pitem, bf_normal, NULL);
	if(!b_res)
		DestroyItem				(pitem);
}
Exemplo n.º 3
0
void CUIMpTradeWnd::OnBtnRifleSilencerClicked(CUIWindow* w, void* d)
{
	CheckDragItemToDestroy				();
	CUIDragDropListEx*	res			= m_list[e_rifle];
	CUICellItem* ci					= (res->ItemsCount())?res->GetItemIdx(0):NULL;
	if(!ci)	
		return;

	SBuyItemInfo* pitem				= FindItem(ci);
	if(IsAddonAttached(pitem, at_silencer))
	{//detach
		SellItemAddons				(pitem,at_silencer);
	}else
	if(CanAttachAddon(pitem, at_silencer))
	{//attach
		shared_str addon_name		= GetAddonNameSect(pitem,at_silencer);

		if ( NULL==m_store_hierarchy->FindItem(addon_name) )
			return;
						
		SBuyItemInfo* addon_item	= CreateItem(addon_name, SBuyItemInfo::e_undefined, false);
		bool b_res_addon			= TryToBuyItem(addon_item, bf_normal, pitem );
		if(!b_res_addon)
			DestroyItem				(addon_item);
	}
}
Exemplo n.º 4
0
void CUIMpTradeWnd::OnBtnPistolAmmoClicked(CUIWindow* w, void* d)
{
	CheckDragItemToDestroy				();
	CUIDragDropListEx*	res		= m_list[e_pistol];
	CUICellItem* ci				= (res->ItemsCount())?res->GetItemIdx(0):NULL;
	if(!ci)	
		return;

	CInventoryItem* ii			= (CInventoryItem*)ci->m_pData;
	CWeapon*		wpn			= smart_cast<CWeapon*>(ii);
	R_ASSERT		(wpn);

	u32 ammo_idx				= (pInput->iGetAsyncKeyState(DIK_LSHIFT))?1:0;
	
	if(wpn->m_ammoTypes.size() < ammo_idx+1)	return;
	const shared_str& ammo_name	= wpn->m_ammoTypes[ammo_idx];

	if ( NULL==m_store_hierarchy->FindItem(ammo_name) )
		return;

	SBuyItemInfo* pitem			= CreateItem		(ammo_name, SBuyItemInfo::e_undefined, false);
	bool b_res					= TryToBuyItem		(pitem, bf_normal, NULL );
	if(!b_res)
		DestroyItem				(pitem);
}
Exemplo n.º 5
0
void CUIMpTradeWnd::SellItemAddons(SBuyItemInfo* sell_itm, item_addon_type addon_type)
{
	CInventoryItem* item_	= (CInventoryItem*)sell_itm->m_cell_item->m_pData;
	CWeapon* w				= smart_cast<CWeapon*>(item_);
	if(!w)					return; //ammo,medkit etc.

	if(IsAddonAttached(sell_itm, addon_type))
	{
		SBuyItemInfo* detached_addon	= DetachAddon(sell_itm, addon_type);
		u32 _item_cost					= m_item_mngr->GetItemCost(detached_addon->m_name_sect, GetRank() );
		SetMoneyAmount					(GetMoneyAmount() + _item_cost);
		DestroyItem						(detached_addon);

		if ( addon_type == at_glauncher )
		{
			CWeaponMagazinedWGrenade* wpn2 = smart_cast<CWeaponMagazinedWGrenade*>(item_);
			VERIFY(wpn2);

			for ( u32 ammo_idx							=	0;
					  ammo_idx							<	wpn2->m_ammoTypes2.size();
					++ammo_idx )
			{
				const shared_str&	ammo_name			=	wpn2->m_ammoTypes2[ammo_idx];
				SBuyItemInfo*		ammo				=	NULL;

				while ( (ammo = FindItem(ammo_name, SBuyItemInfo::e_bought)) != NULL )
				{
					SBuyItemInfo*   tempo				=	NULL;
					TryToSellItem(ammo, true, tempo);
				}
			}
		}
	}
}
Exemplo n.º 6
0
void CUIMpTradeWnd::ApplyPreset(ETradePreset idx)
{
	Msg("--ApplyPreset [%d]",idx);

	SellAll								();

	const preset_items&		v			=  GetPreset(idx);
	preset_items::const_iterator it		= v.begin();
	preset_items::const_iterator it_e	= v.end();

	for(;it!=it_e;++it)
	{
		const _preset_item& _one		= *it;
		u32 _cnt						= GetItemCount(_one.sect_name, SBuyItemInfo::e_own);
		for(u32 i=_cnt; i<_one.count; ++i)
		{
			SBuyItemInfo* pitem				= CreateItem(_one.sect_name, SBuyItemInfo::e_undefined, false);

			bool b_res						= TryToBuyItem(pitem, bf_normal, NULL );
			if(!b_res)
			{
				DestroyItem					(pitem);
			}else
			{
				if(_one.addon_state)
				{
					for(u32 i=0; i<3; ++i)
					{
						item_addon_type at		= (i==0)?at_scope : ((i==1)?at_glauncher : at_silencer);
						
						if(!(_one.addon_state&at) )	
							continue;

						shared_str addon_name	= GetAddonNameSect(pitem, at);
						
						SBuyItemInfo* addon_item = CreateItem(addon_name, SBuyItemInfo::e_undefined, false);
						bool b_res_addon		 = TryToBuyItem(addon_item, /*(idx==_preset_idx_origin)?bf_own_item:*/bf_normal, pitem );
						if(!b_res_addon)
							DestroyItem			(addon_item);
					}
				}
			}
		}
	}
}
Exemplo n.º 7
0
void CL_BTreeNodeSpace::_Destroy (CL_GenericBTreeNode* node) const
{
    if (node) {
        register short n = node->Size();
        for (short i = 0; i < n; i++)
            DestroyItem (node->Item(i));
        delete node;
    }
}
Exemplo n.º 8
0
void CSmokeGrenade::Holster()
{
    m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;

    if( !m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] )
    {
        ClearBits( m_pPlayer->pev->weapons, 1 << WEAPON_SMOKEGRENADE );
        DestroyItem();
    }

    m_flStartThrow   = 0;
    m_flReleaseThrow = -1.0;
}
Exemplo n.º 9
0
void CHEGrenade::__MAKE_VHOOK(Holster)(int skiplocal)
{
	m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;

	if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
	{
		m_pPlayer->pev->weapons &= ~(1 << WEAPON_HEGRENADE);
		DestroyItem();
	}

	m_flStartThrow = 0;
	m_flReleaseThrow = -1.0f;
}
Exemplo n.º 10
0
/* <25b6fa> ../cstrike/dlls/wpn_shared/wpn_flashbang.cpp:102 */
void CFlashbang::__MAKE_VHOOK(Holster)(int skiplocal)
{
	m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;

	if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
	{
		m_pPlayer->pev->weapons &= ~(1 << WEAPON_FLASHBANG);
		DestroyItem();
	}

	m_flStartThrow = 0;
	m_flReleaseThrow = -1.0;
}
Exemplo n.º 11
0
void CSmokeGrenade::__MAKE_VHOOK(Holster)(int skiplocal)
{
	m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
	
	if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
	{
		// no more smokegrenades!
		// clear the smokegrenade of bits for HUD
		m_pPlayer->pev->weapons &= ~(1 << WEAPON_SMOKEGRENADE);
		DestroyItem();
	}

	m_flStartThrow = 0;
	m_flReleaseThrow = -1;
}
Exemplo n.º 12
0
/* <2466fc> ../cstrike/dlls/wpn_shared/wpn_c4.cpp:123 */
void CC4::__MAKE_VHOOK(Holster)(int skiplocal)
{
	m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
	m_bStartedArming = false;

	if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
	{
		m_pPlayer->pev->weapons &= ~(1 << WEAPON_C4);
		DestroyItem();
	}

	if (m_bHasShield)
	{
		m_pPlayer->pev->gamestate = 0;
		m_bHasShield = false;
	}
}
Exemplo n.º 13
0
void CUIBagWnd::DestroyAllItems()
{
    u32 sz = m_allItems.size();
	for (u32 i = 0; i < sz; i++)
	{
		DestroyItem				(m_allItems[i]);
	}
	for (int i = 0; i < NUMBER_OF_GROUPS; i++)
	{
		m_groups[i].ClearAll	(true);
	}
	m_allItems.clear			();
	m_info.clear				();

	for (int i = 0; i<4; i++)
        subSection_group3[i] = 0;
}
Exemplo n.º 14
0
void CWeaponHealthKit::PrimaryAttack( void )
{
	CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
	if (pPlayer->GetHealth()<100)
	{
		pPlayer->TakeHealth( 50, DMG_GENERIC );
		for (int i=0 ; i<8 ; i++)
		{
			if (pPlayer->GetWeapon(i) == (CBaseCombatWeapon*)this)
			{
				pPlayer->SetWeapon(i,NULL);
				break;
			}
		}
		DestroyItem();
	}
}
Exemplo n.º 15
0
void ICCItem::Discard (CCodeChain *pCC)

//	Discard
//
//	Decrement reference count and delete if necessary

	{
	//	By checking for very-high reference counts we can
	//	also prevent discarding that are already in the free list
	//	(because we use the refcount field to store the free list chain)
	ASSERT(m_bNoRefCount || (m_dwRefCount > 0 && m_dwRefCount < 0x00010000));

	m_dwRefCount--;
	if (m_dwRefCount == 0)
		{
		//	Let subclasses handle this

		DestroyItem(pCC);
		}
	}
Exemplo n.º 16
0
bool CUIMpTradeWnd::OnItemLButtonClick(CUICellItem* itm)
{
	CUIDragDropListEx*	owner_list		=	itm->OwnerList();
	SBuyItemInfo*		iinfo 			=	FindItem(itm);

	if ( !CanBuyOrSellInList(owner_list) )
	{
		return								false;
	}	

	const shared_str&	buy_item_name	=	 iinfo->m_name_sect;

	SBuyItemInfo* pitem					=	CreateItem(buy_item_name, SBuyItemInfo::e_undefined, false);
	bool b_res							=	TryToBuyItem(pitem, bf_normal, NULL );
	if( !b_res )
	{
		DestroyItem							(pitem);
	}

	return									true;
}
Exemplo n.º 17
0
void RlistFilter(Rlist **list, bool (*KeepPredicate)(void *, void *), void *predicate_user_data, void (*DestroyItem)(void *))
{
    assert(KeepPredicate);

    Rlist *start = *list;
    Rlist *prev = NULL;

    for (Rlist *rp = start; rp;)
    {
        if (!KeepPredicate(rp->item, predicate_user_data))
        {
            if (prev)
            {
                prev->next = rp->next;
            }
            else
            {
                *list = rp->next;
            }

            if (DestroyItem)
            {
                DestroyItem(rp->item);
                rp->item = NULL;
            }

            Rlist *next = rp->next;
            rp->next = NULL;
            RlistDestroy(rp);
            rp = next;
        }
        else
        {
            prev = rp;
            rp = rp->next;
        }
    }
}
Exemplo n.º 18
0
void CHandGrenade::Holster( int skiplocal /* = 0 */ )
{
	m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;

	if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
	{
		SendWeaponAnim( HANDGRENADE_HOLSTER );
	}
	else
	{
		// no more grenades!
		m_pPlayer->pev->weapons &= ~( 1 << WEAPON_HANDGRENADE );
		DestroyItem();
	}

	if( m_flStartThrow )
	{
		m_flStartThrow = 0;
		m_flReleaseThrow = 0;
	}

	EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM );
}
Exemplo n.º 19
0
void RlistFilter(Rlist **list,
                 bool (*KeepPredicate)(void *, void *), void *predicate_user_data,
                 void (*DestroyItem)(void *))
{
    assert(KeepPredicate);
    Rlist *start = *list, *prev = NULL, *next;

    for (Rlist *rp = start; rp; rp = next)
    {
        next = rp->next;
        if (KeepPredicate(RlistScalarValue(rp), predicate_user_data))
        {
            prev = rp;
        }
        else
        {
            if (prev)
            {
                prev->next = next;
            }
            else
            {
                assert(rp == *list);
                *list = next;
            }

            if (DestroyItem)
            {
                DestroyItem(rp->val.item);
                rp->val.item = NULL;
            }

            rp->next = NULL;
            RlistDestroy(rp);
        }
    }
}
Exemplo n.º 20
0
static VOID
DestroyItem(HWND hTreeView,
            HTREEITEM hItem)
{
    HTREEITEM hChildItem;
    LPWSTR lpServiceName;

    /* Does this item have any children */
    hChildItem = TreeView_GetChild(hTreeView, hItem);
    if (hChildItem)
    {
        /* It does, recurse to that one */
        DestroyItem(hTreeView, hChildItem);
    }

    /* Get the string and free it */
    lpServiceName = (LPWSTR)TreeView_GetItemParam(hTreeView, hItem);
    if (lpServiceName)
    {
        HeapFree(GetProcessHeap(),
                 0,
                 lpServiceName);
    }
}