Fix various broadcasting issues:

- Sound in solo parts
- Sound when spectating
- Projectiles of players in other teams when spectating
This commit is contained in:
def 2014-01-12 15:48:53 +01:00
parent 865509f266
commit adbaae769c
4 changed files with 30 additions and 13 deletions

View file

@ -170,13 +170,22 @@ void CLaser::Snap(int SnappingClient)
{
if(NetworkClipped(SnappingClient))
return;
CCharacter * SnappingChar = GameServer()->GetPlayerChar(SnappingClient);
CCharacter * OwnerChar = 0;
if(m_Owner >= 0)
OwnerChar = GameServer()->GetPlayerChar(m_Owner);
if(!OwnerChar)
return;
if(SnappingChar && !SnappingChar->CanCollide(m_Owner))
CCharacter *pOwnerChar = 0;
int64_t TeamMask = -1LL;
if(m_Owner >= 0)
pOwnerChar = GameServer()->GetPlayerChar(m_Owner);
if (pOwnerChar && pOwnerChar->IsAlive())
TeamMask = pOwnerChar->Teams()->TeamMask(pOwnerChar->Team(), -1, m_Owner);
if(!CmaskIsSet(TeamMask, SnappingClient))
return;
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
if(!pObj)

View file

@ -197,7 +197,16 @@ void CProjectile::Snap(int SnappingClient)
if (pSnapChar && pSnapChar->IsAlive() && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pSnapChar->Team()] && (!Tick)))
return;
if(pSnapChar && m_Owner != -1 && !pSnapChar->CanCollide(m_Owner))
CCharacter *pOwnerChar = 0;
int64_t TeamMask = -1LL;
if(m_Owner >= 0)
pOwnerChar = GameServer()->GetPlayerChar(m_Owner);
if (pOwnerChar && pOwnerChar->IsAlive())
TeamMask = pOwnerChar->Teams()->TeamMask(pOwnerChar->Team(), -1, m_Owner);
if(m_Owner != -1 && !CmaskIsSet(TeamMask, SnappingClient))
return;
CNetObj_Projectile *pProj = static_cast<CNetObj_Projectile *>(Server()->SnapNewItem(NETOBJTYPE_PROJECTILE, m_ID, sizeof(CNetObj_Projectile)));

View file

@ -42,8 +42,6 @@ void CEventHandler::Clear()
void CEventHandler::Snap(int SnappingClient)
{
if (SnappingClient != -1 && GameServer()->m_apPlayers[SnappingClient]->m_Paused)
SnappingClient = GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID;
for(int i = 0; i < m_NumEvents; i++)
{
if(SnappingClient == -1 || CmaskIsSet(m_aClientMasks[i], SnappingClient))

View file

@ -261,18 +261,19 @@ int64_t CGameTeams::TeamMask(int Team, int ExceptID, int Asker)
{
if (Team == TEAM_SUPER)
return -1LL;
if (m_Core.GetSolo(Asker) && ExceptID == Asker)
return 0;
if (m_Core.GetSolo(Asker))
return 1LL << Asker;
int Mask = 0;
if (m_Core.GetSolo(Asker) && ExceptID == Asker)
Mask = 0;
if (m_Core.GetSolo(Asker))
Mask = 1LL << Asker;
for (int i = 0; i < MAX_CLIENTS; ++i)
if (i != ExceptID)
if ((Asker == i || !m_Core.GetSolo(i))
&& ((Character(i)
&& (m_Core.Team(i) == Team
if (((Character(i)
&& ((!m_Core.GetSolo(i) && m_Core.Team(i) == Team)
|| m_Core.Team(i) == TEAM_SUPER))
|| (GetPlayer(i) && GetPlayer(i)->GetTeam() == -1)))
|| ((GetPlayer(i) && (GetPlayer(i)->GetTeam() == -1 || GetPlayer(i)->m_Paused))
&& (GetPlayer(i)->m_SpectatorID == SPEC_FREEVIEW
|| m_Core.Team(GetPlayer(i)->m_SpectatorID) == Team))))
Mask |= 1LL << i;
return Mask;
}