void Streamer::processAttachedAreas()
{
	for (boost::unordered_set<Item::SharedArea>::iterator a = attachedAreas.begin(); a != attachedAreas.end(); ++a)
	{
		if ((*a)->attach)
		{
			bool adjust = false;
			if ((*a)->attach->object.get<0>() != INVALID_GENERIC_ID)
			{
				switch ((*a)->attach->object.get<1>())
				{
					case STREAMER_OBJECT_TYPE_GLOBAL:
					{
						adjust = GetObjectPos((*a)->attach->object.get<0>(), &(*a)->attach->position[0], &(*a)->attach->position[1], &(*a)->attach->position[2]);
						break;
					}
					case STREAMER_OBJECT_TYPE_PLAYER:
					{
						adjust = GetPlayerObjectPos((*a)->attach->object.get<2>(), (*a)->attach->object.get<0>(), &(*a)->attach->position[0], &(*a)->attach->position[1], &(*a)->attach->position[2]);
						break;
					}
					case STREAMER_OBJECT_TYPE_DYNAMIC:
					{
						boost::unordered_map<int, Item::SharedObject>::iterator o = core->getData()->objects.find((*a)->attach->object.get<0>());
						if (o != core->getData()->objects.end())
						{
							(*a)->attach->position = o->second->position;
							adjust = true;
						}
						break;
					}
				}
			}
			else if ((*a)->attach->player != INVALID_GENERIC_ID)
			{
				adjust = GetPlayerPos((*a)->attach->player, &(*a)->attach->position[0], &(*a)->attach->position[1], &(*a)->attach->position[2]);
			}
			else if ((*a)->attach->vehicle != INVALID_GENERIC_ID)
			{
				adjust = GetVehiclePos((*a)->attach->vehicle, &(*a)->attach->position[0], &(*a)->attach->position[1], &(*a)->attach->position[2]);
			}
			if (adjust)
			{
				if ((*a)->cell)
				{
					core->getGrid()->removeArea(*a, true);
				}
			}
			else
			{
				(*a)->attach->position.fill(std::numeric_limits<float>::infinity());
			}
		}
	}
}
Esempio n. 2
0
HLTSOUND CGameSoundMgr::PlaySoundFromObject(HOBJECT hObject, char const* pName, LTFLOAT fORadius,
                                        SoundPriority ePriority, uint32 dwFlags, uint8 nVolume,
										float fPitchShift, LTFLOAT fIRadius, uint8 nSoundClass )
{
    if (!pName || !hObject) return LTNULL;

	PlaySoundInfo psi;
	PLAYSOUNDINFO_INIT(psi);

	LTFLOAT	fInnerRadius = fIRadius;

	if( fORadius > 0.0f && fInnerRadius < 0.0f )
	{
		// If a valid outter radius and invalid inner radius were given 
		// set the inner radius to a percentage of the outter...

		fInnerRadius = fORadius * m_fInnerRadiusPercent;
	}

	// See if the passed in name is really a sound bute...
	if( !FillPSIFromButeOrParams( pName, psi, fORadius, ePriority, dwFlags, nVolume, fPitchShift, fInnerRadius ))
		return NULL;

	// Incorporate the flags passed in.
	psi.m_dwFlags		|= dwFlags;

	// If they asked for a clientlocal then turn into a local and remove clientlocal.  
	if (psi.m_dwFlags & PLAYSOUND_CLIENTLOCAL)
	{
		psi.m_dwFlags &= ~( PLAYSOUND_3D );
	}
	// Note : CLIENTLOCAL sounds don't work correctly if marked as "attached"
	else
	{
		psi.m_dwFlags |= PLAYSOUND_ATTACHED;
	}

	if (psi.m_nVolume < 100)
	{
		psi.m_dwFlags |= PLAYSOUND_CTRL_VOL;
	}

	psi.m_hObject		= hObject;
	psi.m_vPosition		= GetObjectPos(hObject);
	psi.m_nSoundVolumeClass = nSoundClass;

	return PlaySound(psi);
}
Esempio n. 3
0
HLTSOUND CGameSoundMgr::PlaySoundFromObject(HOBJECT hObject, char *pName, LTFLOAT fRadius,
                                        SoundPriority ePriority, uint32 dwFlags, uint8 nVolume,
										float fPitchShift)
{
    if (!pName || !hObject) return LTNULL;

	PlaySoundInfo psi;
	PLAYSOUNDINFO_INIT(psi);

	psi.m_dwFlags = PLAYSOUND_3D | PLAYSOUND_REVERB;
	psi.m_dwFlags |= dwFlags;

	if (psi.m_dwFlags & PLAYSOUND_CLIENTLOCAL)
	{
		psi.m_dwFlags &= ~PLAYSOUND_3D;
	}
	// Note : CLIENTLOCAL sounds don't work correctly if marked as "attached"
	else
	{
		psi.m_dwFlags |= PLAYSOUND_ATTACHED;
	}

	if (nVolume < 100)
	{
		psi.m_dwFlags |= PLAYSOUND_CTRL_VOL;
	}

	strncpy(psi.m_szSoundName, pName, _MAX_PATH);
	psi.m_nPriority		= ePriority;
	psi.m_fOuterRadius	= fRadius;
	psi.m_fInnerRadius	= fRadius * m_fInnerRadiusPercent;
	psi.m_nVolume		= nVolume;
	psi.m_hObject		= hObject;
	psi.m_fPitchShift	= fPitchShift;
	psi.m_vPosition		= GetObjectPos(hObject);

	return PlaySound(psi);
}