mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Network clipping for entityex in CPickup and CProjectile, snap gamecontroller before gameworld, bound checks for switchers in client
This commit is contained in:
parent
c7b8235c91
commit
e2dbba3146
|
@ -318,7 +318,7 @@ void CItems::OnRender()
|
||||||
{
|
{
|
||||||
for(auto *pProj = (CProjectile *)GameClient()->m_PredictedWorld.FindFirst(CGameWorld::ENTTYPE_PROJECTILE); pProj; pProj = (CProjectile *)pProj->NextEntity())
|
for(auto *pProj = (CProjectile *)GameClient()->m_PredictedWorld.FindFirst(CGameWorld::ENTTYPE_PROJECTILE); pProj; pProj = (CProjectile *)pProj->NextEntity())
|
||||||
{
|
{
|
||||||
if(!IsSuper && pProj->m_Number > 0 && !Collision()->m_pSwitchers[pProj->m_Number].m_Status[OwnTeam] && (pProj->m_Explosive ? BlinkingProjEx : BlinkingProj))
|
if(!IsSuper && pProj->m_Number > 0 && pProj->m_Number < Collision()->m_NumSwitchers && !Collision()->m_pSwitchers[pProj->m_Number].m_Status[OwnTeam] && (pProj->m_Explosive ? BlinkingProjEx : BlinkingProj))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CProjectileData Data = pProj->GetData();
|
CProjectileData Data = pProj->GetData();
|
||||||
|
@ -334,7 +334,7 @@ void CItems::OnRender()
|
||||||
}
|
}
|
||||||
for(auto *pPickup = (CPickup *)GameClient()->m_PredictedWorld.FindFirst(CGameWorld::ENTTYPE_PICKUP); pPickup; pPickup = (CPickup *)pPickup->NextEntity())
|
for(auto *pPickup = (CPickup *)GameClient()->m_PredictedWorld.FindFirst(CGameWorld::ENTTYPE_PICKUP); pPickup; pPickup = (CPickup *)pPickup->NextEntity())
|
||||||
{
|
{
|
||||||
if(!IsSuper && pPickup->m_Layer == LAYER_SWITCH && pPickup->m_Number > 0 && !Collision()->m_pSwitchers[pPickup->m_Number].m_Status[OwnTeam] && BlinkingPickup)
|
if(!IsSuper && pPickup->m_Layer == LAYER_SWITCH && pPickup->m_Number > 0 && pPickup->m_Number < Collision()->m_NumSwitchers && !Collision()->m_pSwitchers[pPickup->m_Number].m_Status[OwnTeam] && BlinkingPickup)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(pPickup->InDDNetTile())
|
if(pPickup->InDDNetTile())
|
||||||
|
@ -358,7 +358,7 @@ void CItems::OnRender()
|
||||||
|
|
||||||
bool Inactive = false;
|
bool Inactive = false;
|
||||||
if(pEntEx)
|
if(pEntEx)
|
||||||
Inactive = !IsSuper && pEntEx->m_SwitchNumber > 0 && !Collision()->m_pSwitchers[pEntEx->m_SwitchNumber].m_Status[OwnTeam];
|
Inactive = !IsSuper && pEntEx->m_SwitchNumber > 0 && pEntEx->m_SwitchNumber < Collision()->m_NumSwitchers && !Collision()->m_pSwitchers[pEntEx->m_SwitchNumber].m_Status[OwnTeam];
|
||||||
|
|
||||||
if(Item.m_Type == NETOBJTYPE_PROJECTILE || Item.m_Type == NETOBJTYPE_DDNETPROJECTILE)
|
if(Item.m_Type == NETOBJTYPE_PROJECTILE || Item.m_Type == NETOBJTYPE_DDNETPROJECTILE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ void CPickup::Tick()
|
||||||
{
|
{
|
||||||
if(GameWorld()->m_WorldConfig.m_IsVanilla && distance(m_Pos, pChr->m_Pos) >= 20.0f * 2) // pickup distance is shorter on vanilla due to using ClosestEntity
|
if(GameWorld()->m_WorldConfig.m_IsVanilla && distance(m_Pos, pChr->m_Pos) >= 20.0f * 2) // pickup distance is shorter on vanilla due to using ClosestEntity
|
||||||
continue;
|
continue;
|
||||||
if(m_Layer == LAYER_SWITCH && m_Number > 0 && !GameWorld()->Collision()->m_pSwitchers[m_Number].m_Status[pChr->Team()])
|
if(m_Layer == LAYER_SWITCH && m_Number > 0 && m_Number < Collision()->m_NumSwitchers && !GameWorld()->Collision()->m_pSwitchers[m_Number].m_Status[pChr->Team()])
|
||||||
continue;
|
continue;
|
||||||
bool sound = false;
|
bool sound = false;
|
||||||
// player picked us up, is someone was hooking us, let them go
|
// player picked us up, is someone was hooking us, let them go
|
||||||
|
|
|
@ -110,7 +110,7 @@ void CProjectile::Tick()
|
||||||
CCharacter *apEnts[MAX_CLIENTS];
|
CCharacter *apEnts[MAX_CLIENTS];
|
||||||
int Num = GameWorld()->FindEntities(CurPos, 1.0f, (CEntity **)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
|
int Num = GameWorld()->FindEntities(CurPos, 1.0f, (CEntity **)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
|
||||||
for(int i = 0; i < Num; ++i)
|
for(int i = 0; i < Num; ++i)
|
||||||
if(apEnts[i] && (m_Layer != LAYER_SWITCH || (m_Layer == LAYER_SWITCH && m_Number > 0 && GameWorld()->Collision()->m_pSwitchers[m_Number].m_Status[apEnts[i]->Team()])))
|
if(apEnts[i] && (m_Layer != LAYER_SWITCH || (m_Layer == LAYER_SWITCH && m_Number > 0 && m_Number < Collision()->m_NumSwitchers && GameWorld()->Collision()->m_pSwitchers[m_Number].m_Status[apEnts[i]->Team()])))
|
||||||
apEnts[i]->Freeze();
|
apEnts[i]->Freeze();
|
||||||
}
|
}
|
||||||
if(Collide && m_Bouncing != 0)
|
if(Collide && m_Bouncing != 0)
|
||||||
|
|
|
@ -160,6 +160,8 @@ void CPickup::Snap(int SnappingClient)
|
||||||
if(SnappingClient > -1 && (GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1 || GameServer()->m_apPlayers[SnappingClient]->IsPaused()) && GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
|
if(SnappingClient > -1 && (GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1 || GameServer()->m_apPlayers[SnappingClient]->IsPaused()) && GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
|
||||||
Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);
|
Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);
|
||||||
|
|
||||||
|
if(!NetworkClipped(SnappingClient))
|
||||||
|
{
|
||||||
CNetObj_EntityEx *pEntData = static_cast<CNetObj_EntityEx *>(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx)));
|
CNetObj_EntityEx *pEntData = static_cast<CNetObj_EntityEx *>(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx)));
|
||||||
if(!pEntData)
|
if(!pEntData)
|
||||||
return;
|
return;
|
||||||
|
@ -167,6 +169,7 @@ void CPickup::Snap(int SnappingClient)
|
||||||
pEntData->m_SwitchNumber = m_Number;
|
pEntData->m_SwitchNumber = m_Number;
|
||||||
pEntData->m_Layer = m_Layer;
|
pEntData->m_Layer = m_Layer;
|
||||||
pEntData->m_EntityClass = ENTITYCLASS_PICKUP;
|
pEntData->m_EntityClass = ENTITYCLASS_PICKUP;
|
||||||
|
}
|
||||||
|
|
||||||
int SnappingClientVersion = SnappingClient >= 0 ? GameServer()->GetClientVersion(SnappingClient) : CLIENT_VERSIONNR;
|
int SnappingClientVersion = SnappingClient >= 0 ? GameServer()->GetClientVersion(SnappingClient) : CLIENT_VERSIONNR;
|
||||||
if(SnappingClientVersion < VERSION_DDNET_SWITCH)
|
if(SnappingClientVersion < VERSION_DDNET_SWITCH)
|
||||||
|
|
|
@ -300,6 +300,9 @@ void CProjectile::Snap(int SnappingClient)
|
||||||
{
|
{
|
||||||
float Ct = (Server()->Tick() - m_StartTick) / (float)Server()->TickSpeed();
|
float Ct = (Server()->Tick() - m_StartTick) / (float)Server()->TickSpeed();
|
||||||
|
|
||||||
|
if(NetworkClipped(SnappingClient, GetPos(Ct)))
|
||||||
|
return;
|
||||||
|
|
||||||
if(m_LifeSpan == -2)
|
if(m_LifeSpan == -2)
|
||||||
{
|
{
|
||||||
CNetObj_EntityEx *pEntData = static_cast<CNetObj_EntityEx *>(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx)));
|
CNetObj_EntityEx *pEntData = static_cast<CNetObj_EntityEx *>(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx)));
|
||||||
|
@ -311,9 +314,6 @@ void CProjectile::Snap(int SnappingClient)
|
||||||
pEntData->m_EntityClass = ENTITYCLASS_PROJECTILE;
|
pEntData->m_EntityClass = ENTITYCLASS_PROJECTILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NetworkClipped(SnappingClient, GetPos(Ct)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
int SnappingClientVersion = SnappingClient >= 0 ? GameServer()->GetClientVersion(SnappingClient) : CLIENT_VERSIONNR;
|
int SnappingClientVersion = SnappingClient >= 0 ? GameServer()->GetClientVersion(SnappingClient) : CLIENT_VERSIONNR;
|
||||||
if(SnappingClientVersion < VERSION_DDNET_SWITCH)
|
if(SnappingClientVersion < VERSION_DDNET_SWITCH)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3617,6 +3617,8 @@ void CGameContext::OnSnap(int ClientID)
|
||||||
Server()->SendMsg(&Msg, MSGFLAG_RECORD | MSGFLAG_NOSEND, ClientID);
|
Server()->SendMsg(&Msg, MSGFLAG_RECORD | MSGFLAG_NOSEND, ClientID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_pController->Snap(ClientID);
|
||||||
|
|
||||||
for(auto &pPlayer : m_apPlayers)
|
for(auto &pPlayer : m_apPlayers)
|
||||||
{
|
{
|
||||||
if(pPlayer)
|
if(pPlayer)
|
||||||
|
@ -3627,7 +3629,6 @@ void CGameContext::OnSnap(int ClientID)
|
||||||
m_apPlayers[ClientID]->FakeSnap();
|
m_apPlayers[ClientID]->FakeSnap();
|
||||||
|
|
||||||
m_World.Snap(ClientID);
|
m_World.Snap(ClientID);
|
||||||
m_pController->Snap(ClientID);
|
|
||||||
m_Events.Snap(ClientID);
|
m_Events.Snap(ClientID);
|
||||||
}
|
}
|
||||||
void CGameContext::OnPreSnap() {}
|
void CGameContext::OnPreSnap() {}
|
||||||
|
|
Loading…
Reference in a new issue