Send laser objects as DDNetLaser with type (fixes #5885)

This commit is contained in:
fokkonaut 2022-09-26 19:49:17 +02:00
parent f8d9808c18
commit 900417b84d
8 changed files with 176 additions and 97 deletions

View file

@ -282,7 +282,7 @@ Objects = [
NetIntAny("m_FromX"),
NetIntAny("m_FromY"),
NetTick("m_StartTick"),
NetIntRange("m_Owner", 0, 'MAX_CLIENTS-1'),
NetIntRange("m_Owner", -1, 'MAX_CLIENTS-1'),
NetIntAny("m_Type"),
]),

View file

@ -479,21 +479,18 @@ void CItems::OnRender()
if(Inactive && BlinkingLight)
continue;
Data.m_StartTick = DraggerStartTick;
Data.m_Type = LASERTYPE_FREEZE;
}
if(pEntEx->m_EntityClass >= ENTITYCLASS_GUN_NORMAL && pEntEx->m_EntityClass <= ENTITYCLASS_GUN_UNFREEZE)
{
if(Inactive && BlinkingGun)
continue;
Data.m_StartTick = GunStartTick;
Data.m_Type = pEntEx->m_EntityClass == ENTITYCLASS_GUN_FREEZE ? LASERTYPE_FREEZE : LASERTYPE_DOOR;
}
if(pEntEx->m_EntityClass >= ENTITYCLASS_DRAGGER_WEAK && pEntEx->m_EntityClass <= ENTITYCLASS_DRAGGER_STRONG)
{
if(Inactive && BlinkingDragger)
continue;
Data.m_StartTick = DraggerStartTick;
Data.m_Type = LASERTYPE_DOOR;
}
if(pEntEx->m_EntityClass == ENTITYCLASS_DOOR)
{
@ -503,7 +500,6 @@ void CItems::OnRender()
Data.m_From.y = Data.m_To.y;
}
Data.m_StartTick = Client()->GameTick(g_Config.m_ClDummy);
Data.m_Type = LASERTYPE_DOOR;
}
}
RenderLaser(&Data);

View file

@ -45,30 +45,23 @@ void CDoor::Snap(int SnappingClient)
if(NetworkClipped(SnappingClient, m_Pos) && NetworkClipped(SnappingClient, m_To))
return;
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser)));
if(!pObj)
return;
pObj->m_X = (int)m_Pos.x;
pObj->m_Y = (int)m_Pos.y;
int SnappingClientVersion = GameServer()->GetClientVersion(SnappingClient);
CNetObj_EntityEx *pEntData = 0;
if(SnappingClientVersion >= VERSION_DDNET_SWITCH)
pEntData = static_cast<CNetObj_EntityEx *>(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx)));
vec2 From;
int StartTick;
if(pEntData)
{
pEntData->m_SwitchNumber = m_Number;
pEntData->m_Layer = m_Layer;
pEntData->m_EntityClass = ENTITYCLASS_DOOR;
pObj->m_FromX = (int)m_To.x;
pObj->m_FromY = (int)m_To.y;
pObj->m_StartTick = 0;
From = m_To;
StartTick = 0;
}
else
{
@ -79,14 +72,39 @@ void CDoor::Snap(int SnappingClient)
if(pChr && pChr->Team() != TEAM_SUPER && pChr->IsAlive() && !Switchers().empty() && Switchers()[m_Number].m_aStatus[pChr->Team()])
{
pObj->m_FromX = (int)m_To.x;
pObj->m_FromY = (int)m_To.y;
From = m_To;
}
else
{
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
From = m_Pos;
}
pObj->m_StartTick = Server()->Tick();
StartTick = Server()->Tick();
}
if(SnappingClientVersion >= VERSION_DDNET_MULTI_LASER)
{
CNetObj_DDNetLaser *pObj = static_cast<CNetObj_DDNetLaser *>(Server()->SnapNewItem(NETOBJTYPE_DDNETLASER, GetID(), sizeof(CNetObj_DDNetLaser)));
if(!pObj)
return;
pObj->m_ToX = (int)m_Pos.x;
pObj->m_ToY = (int)m_Pos.y;
pObj->m_FromX = (int)From.x;
pObj->m_FromY = (int)From.y;
pObj->m_StartTick = StartTick;
pObj->m_Owner = -1;
pObj->m_Type = LASERTYPE_DOOR;
}
else
{
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser)));
if(!pObj)
return;
pObj->m_X = (int)m_Pos.x;
pObj->m_Y = (int)m_Pos.y;
pObj->m_FromX = (int)From.x;
pObj->m_FromY = (int)From.y;
pObj->m_StartTick = StartTick;
}
}

View file

@ -215,28 +215,40 @@ void CDragger::Snap(int SnappingClient)
return;
}
CNetObj_Laser *pObjLaser = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser)));
if(!pObjLaser)
return;
pObjLaser->m_X = (int)m_Pos.x;
pObjLaser->m_Y = (int)m_Pos.y;
pObjLaser->m_FromX = (int)m_Pos.x;
pObjLaser->m_FromY = (int)m_Pos.y;
if(pEntData)
int StartTick = 0;
if(!pEntData)
{
pObjLaser->m_StartTick = 0;
}
else
{
int StartTick = m_EvalTick;
StartTick = m_EvalTick;
if(StartTick < Server()->Tick() - 4)
StartTick = Server()->Tick() - 4;
else if(StartTick > Server()->Tick())
StartTick = Server()->Tick();
pObjLaser->m_StartTick = StartTick;
}
if(SnappingClientVersion >= VERSION_DDNET_MULTI_LASER)
{
CNetObj_DDNetLaser *pObj = static_cast<CNetObj_DDNetLaser *>(Server()->SnapNewItem(NETOBJTYPE_DDNETLASER, GetID(), sizeof(CNetObj_DDNetLaser)));
if(!pObj)
return;
pObj->m_ToX = (int)m_Pos.x;
pObj->m_ToY = (int)m_Pos.y;
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
pObj->m_StartTick = StartTick;
pObj->m_Owner = -1;
pObj->m_Type = LASERTYPE_DOOR;
}
else
{
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, GetID(), 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;
pObj->m_FromY = (int)m_Pos.y;
pObj->m_StartTick = StartTick;
}
}

View file

@ -108,16 +108,6 @@ void CDraggerBeam::Snap(int SnappingClient)
{
return;
}
CNetObj_Laser *pObjLaser = static_cast<CNetObj_Laser *>(
Server()->SnapNewItem(NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser)));
if(!pObjLaser)
{
return;
}
pObjLaser->m_X = (int)m_Pos.x;
pObjLaser->m_Y = (int)m_Pos.y;
pObjLaser->m_FromX = (int)TargetPos.x;
pObjLaser->m_FromY = (int)TargetPos.y;
int StartTick = m_EvalTick;
if(StartTick < Server()->Tick() - 4)
@ -128,5 +118,31 @@ void CDraggerBeam::Snap(int SnappingClient)
{
StartTick = Server()->Tick();
}
pObjLaser->m_StartTick = StartTick;
if(GameServer()->GetClientVersion(SnappingClient) >= VERSION_DDNET_MULTI_LASER)
{
CNetObj_DDNetLaser *pObj = static_cast<CNetObj_DDNetLaser *>(Server()->SnapNewItem(NETOBJTYPE_DDNETLASER, GetID(), sizeof(CNetObj_DDNetLaser)));
if(!pObj)
return;
pObj->m_ToX = (int)m_Pos.x;
pObj->m_ToY = (int)m_Pos.y;
pObj->m_FromX = (int)TargetPos.x;
pObj->m_FromY = (int)TargetPos.y;
pObj->m_StartTick = StartTick;
pObj->m_Owner = -1;
pObj->m_Type = LASERTYPE_DOOR;
}
else
{
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser)));
if(!pObj)
return;
pObj->m_X = (int)m_Pos.x;
pObj->m_Y = (int)m_Pos.y;
pObj->m_FromX = (int)TargetPos.x;
pObj->m_FromY = (int)TargetPos.y;
pObj->m_StartTick = StartTick;
}
}

View file

@ -186,19 +186,32 @@ void CGun::Snap(int SnappingClient)
return;
}
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser)));
int StartTick = pEntData ? 0 : m_EvalTick;
if(!pObj)
return;
if(SnappingClientVersion >= VERSION_DDNET_MULTI_LASER)
{
CNetObj_DDNetLaser *pObj = static_cast<CNetObj_DDNetLaser *>(Server()->SnapNewItem(NETOBJTYPE_DDNETLASER, GetID(), sizeof(CNetObj_DDNetLaser)));
if(!pObj)
return;
pObj->m_X = (int)m_Pos.x;
pObj->m_Y = (int)m_Pos.y;
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
if(pEntData)
pObj->m_StartTick = 0;
pObj->m_ToX = (int)m_Pos.x;
pObj->m_ToY = (int)m_Pos.y;
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
pObj->m_StartTick = StartTick;
pObj->m_Owner = -1;
pObj->m_Type = m_Freeze ? LASERTYPE_FREEZE : LASERTYPE_RIFLE;
}
else
pObj->m_StartTick = m_EvalTick;
{
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, GetID(), 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;
pObj->m_FromY = (int)m_Pos.y;
pObj->m_StartTick = StartTick;
}
}

View file

@ -129,47 +129,55 @@ void CLight::Snap(int SnappingClient)
return;
}
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser)));
if(!pObj)
return;
pObj->m_X = (int)m_Pos.x;
pObj->m_Y = (int)m_Pos.y;
vec2 From = m_Pos;
int StartTick = 0;
if(pChr && pChr->Team() == TEAM_SUPER)
{
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
From = m_Pos;
}
else if(pChr && m_Layer == LAYER_SWITCH && Switchers()[m_Number].m_aStatus[pChr->Team()])
{
pObj->m_FromX = (int)m_To.x;
pObj->m_FromY = (int)m_To.y;
From = m_To;
}
else if(m_Layer != LAYER_SWITCH)
{
pObj->m_FromX = (int)m_To.x;
pObj->m_FromY = (int)m_To.y;
}
else
{
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
From = m_To;
}
if(pEntData)
if(!pEntData)
{
pObj->m_StartTick = 0;
}
else
{
int StartTick = m_EvalTick;
StartTick = m_EvalTick;
if(StartTick < Server()->Tick() - 4)
StartTick = Server()->Tick() - 4;
else if(StartTick > Server()->Tick())
StartTick = Server()->Tick();
}
if(SnappingClientVersion >= VERSION_DDNET_MULTI_LASER)
{
CNetObj_DDNetLaser *pObj = static_cast<CNetObj_DDNetLaser *>(Server()->SnapNewItem(NETOBJTYPE_DDNETLASER, GetID(), sizeof(CNetObj_DDNetLaser)));
if(!pObj)
return;
pObj->m_ToX = (int)m_Pos.x;
pObj->m_ToY = (int)m_Pos.y;
pObj->m_FromX = (int)From.x;
pObj->m_FromY = (int)From.y;
pObj->m_StartTick = StartTick;
pObj->m_Owner = -1;
pObj->m_Type = LASERTYPE_FREEZE;
}
else
{
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser)));
if(!pObj)
return;
pObj->m_X = (int)m_Pos.x;
pObj->m_Y = (int)m_Pos.y;
pObj->m_FromX = (int)From.x;
pObj->m_FromY = (int)From.y;
pObj->m_StartTick = StartTick;
}
}

View file

@ -118,14 +118,30 @@ void CPlasma::Snap(int SnappingClient)
if(NetworkClipped(SnappingClient))
return;
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser)));
if(!pObj)
return;
if(GameServer()->GetClientVersion(SnappingClient) >= VERSION_DDNET_MULTI_LASER)
{
CNetObj_DDNetLaser *pObj = static_cast<CNetObj_DDNetLaser *>(Server()->SnapNewItem(NETOBJTYPE_DDNETLASER, GetID(), sizeof(CNetObj_DDNetLaser)));
if(!pObj)
return;
pObj->m_X = (int)m_Pos.x;
pObj->m_Y = (int)m_Pos.y;
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
pObj->m_StartTick = m_EvalTick;
pObj->m_ToX = (int)m_Pos.x;
pObj->m_ToY = (int)m_Pos.y;
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
pObj->m_StartTick = m_EvalTick;
pObj->m_Owner = -1;
pObj->m_Type = m_Freeze ? LASERTYPE_FREEZE : LASERTYPE_RIFLE;
}
else
{
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, GetID(), 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;
pObj->m_FromY = (int)m_Pos.y;
pObj->m_StartTick = m_EvalTick;
}
}