Better broadcasting for spectators

This commit is contained in:
def 2014-01-13 17:00:49 +01:00
parent fbe1cbe9e8
commit d158267e92
8 changed files with 66 additions and 14 deletions

View file

@ -69,7 +69,7 @@ int CNetServer::Drop(int ClientID, const char *pReason)
int CNetServer::Update()
{
int64 Now = time_get();
//int64 Now = time_get();
for(int i = 0; i < MaxClients(); i++)
{
m_aSlots[i].m_Connection.Update();

View file

@ -1535,6 +1535,8 @@ void CCharacter::HandleTiles(int Index)
int z = GameServer()->Collision()->IsTeleport(MapIndex);
if(!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons && z && Controller->m_TeleOuts[z-1].size())
{
if (m_Super)
return;
m_Core.m_HookedPlayer = -1;
m_Core.m_HookState = HOOK_RETRACTED;
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
@ -1545,8 +1547,10 @@ void CCharacter::HandleTiles(int Index)
return;
}
int evilz = GameServer()->Collision()->IsEvilTeleport(MapIndex);
if(evilz && !m_Super && Controller->m_TeleOuts[evilz-1].size())
if(evilz && Controller->m_TeleOuts[evilz-1].size())
{
if (m_Super)
return;
int Num = Controller->m_TeleOuts[evilz-1].size();
m_Core.m_Pos = Controller->m_TeleOuts[evilz-1][(!Num)?Num:rand() % Num];
if (!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons)
@ -1563,6 +1567,8 @@ void CCharacter::HandleTiles(int Index)
}
if(GameServer()->Collision()->IsCheckTeleport(MapIndex))
{
if (m_Super)
return;
// first check if there is a TeleCheckOut for the current recorded checkpoint, if not check previous checkpoints
for(int k=m_TeleCheckpoint-1; k >= 0; k--)
{

View file

@ -72,13 +72,24 @@ void CDoor::Snap(int SnappingClient)
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
if (!pObj)
return;
pObj->m_X = (int) m_Pos.x;
pObj->m_Y = (int) m_Pos.y;
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
int Tick = (Server()->Tick() % Server()->TickSpeed()) % 11;
if((GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1
|| GameServer()->m_apPlayers[SnappingClient]->m_Paused)
&& GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);
if (Char == 0)
return;
if (Char->IsAlive()
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()]
&& (!Tick))

View file

@ -248,6 +248,12 @@ void CDragger::Snap(int SnappingClient)
return;
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
if((GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1
|| GameServer()->m_apPlayers[SnappingClient]->m_Paused)
&& GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);
int Tick = (Server()->Tick() % Server()->TickSpeed()) % 11;
if (Char && Char->IsAlive()
&& (m_Layer == LAYER_SWITCH

View file

@ -97,10 +97,20 @@ void CGun::Snap(int SnappingClient)
if(NetworkClipped(SnappingClient))
return;
CCharacter * SnapChar = GameServer()->GetPlayerChar(SnappingClient);
CCharacter *Char = GameServer()->GetPlayerChar(SnappingClient);
if((GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1
|| GameServer()->m_apPlayers[SnappingClient]->m_Paused)
&& GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
if (SnapChar && SnapChar->IsAlive() && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()]) && (!Tick)) return;
if (Char && Char->IsAlive() && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()]) && (!Tick)) return;
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
if (!pObj)
return;
pObj->m_X = (int)m_Pos.x;
pObj->m_Y = (int)m_Pos.y;
pObj->m_FromX = (int)m_Pos.x;

View file

@ -108,28 +108,37 @@ void CLight::Snap(int SnappingClient)
&& NetworkClipped(SnappingClient, m_To))
return;
CCharacter * pSnappingCharacter = GameServer()->GetPlayerChar(
SnappingClient);
CCharacter *Char = GameServer()->GetPlayerChar(SnappingClient);
if((GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1
|| GameServer()->m_apPlayers[SnappingClient]->m_Paused)
&& GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);
int Tick = (Server()->Tick() % Server()->TickSpeed()) % 6;
if (pSnappingCharacter && pSnappingCharacter->IsAlive()
if (Char && Char->IsAlive()
&& m_Layer == LAYER_SWITCH
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pSnappingCharacter->Team()]
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()]
&& (Tick))
return;
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
if (!pObj)
return;
pObj->m_X = (int) m_Pos.x;
pObj->m_Y = (int) m_Pos.y;
if (pSnappingCharacter && pSnappingCharacter->Team() == TEAM_SUPER)
if (Char && Char->Team() == TEAM_SUPER)
{
pObj->m_FromX = (int) m_Pos.x;
pObj->m_FromY = (int) m_Pos.y;
}
else if (pSnappingCharacter && m_Layer == LAYER_SWITCH
&& GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pSnappingCharacter->Team()])
else if (Char && m_Layer == LAYER_SWITCH
&& GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()])
{
pObj->m_FromX = (int) m_To.x;
pObj->m_FromY = (int) m_To.y;

View file

@ -150,11 +150,17 @@ void CPickup::Snap(int SnappingClient)
/*if(m_SpawnTick != -1 || NetworkClipped(SnappingClient))
return;*/
CCharacter * SnapChar = GameServer()->GetPlayerChar(SnappingClient);
CCharacter *Char = GameServer()->GetPlayerChar(SnappingClient);
if((GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1
|| GameServer()->m_apPlayers[SnappingClient]->m_Paused)
&& GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
if (SnapChar && SnapChar->IsAlive() &&
if (Char && Char->IsAlive() &&
(m_Layer == LAYER_SWITCH &&
!GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()])
!GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()])
&& (!Tick))
return;

View file

@ -109,6 +109,10 @@ void CPlasma::Snap(int SnappingClient)
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
if(!pObj)
return;
pObj->m_X = (int) m_Pos.x;
pObj->m_Y = (int) m_Pos.y;
pObj->m_FromX = (int) m_Pos.x;