2353: Fix /spec rendering r=def- a=edg-l

Fixes https://github.com/ddnet/ddnet/issues/2344

Co-authored-by: Edgar <git@edgarluque.com>
This commit is contained in:
bors[bot] 2020-06-24 19:29:29 +00:00 committed by GitHub
commit 677d92aa32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 0 deletions

View file

@ -269,6 +269,11 @@ Objects = [
NetObjectEx("MyOwnEvent", "my-own-event@heinrich5991.de", [
NetIntAny("m_Test"),
]),
NetObjectEx("SpecChar", "spec-char@netobj.ddnet.tw", [
NetIntAny("m_X"),
NetIntAny("m_Y"),
]),
]
Messages = [

View file

@ -35,6 +35,12 @@ void CNamePlates::RenderNameplate(
else
Position = mix(vec2(pPrevChar->m_X, pPrevChar->m_Y), vec2(pPlayerChar->m_X, pPlayerChar->m_Y), Client()->IntraGameTick(g_Config.m_ClDummy));
if(m_pClient->m_aClients[ClientID].m_Spec)
{
Position.x = m_pClient->m_aClients[ClientID].m_SpecChar.m_X;
Position.y = m_pClient->m_aClients[ClientID].m_SpecChar.m_Y;
}
bool OtherTeam = m_pClient->IsOtherTeam(ClientID);
float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f;

View file

@ -234,6 +234,13 @@ void CPlayers::RenderPlayer(
Position = m_pClient->m_aClients[ClientID].m_RenderPos;
else
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
if(Spec)
{
Position.x = m_pClient->m_aClients[ClientID].m_SpecChar.m_X;
Position.y = m_pClient->m_aClients[ClientID].m_SpecChar.m_Y;
}
vec2 Vel = mix(vec2(Prev.m_VelX/256.0f, Prev.m_VelY/256.0f), vec2(Player.m_VelX/256.0f, Player.m_VelY/256.0f), IntraTick);
m_pClient->m_pFlow->Add(Position, Vel*100.0f, 10.0f);

View file

@ -1284,6 +1284,13 @@ void CGameClient::OnNewSnapshot()
m_aClients[Item.m_ID].m_Predicted.ReadDDNet(pCharacterData);
}
else if(Item.m_Type == NETOBJTYPE_SPECCHAR)
{
const CNetObj_SpecChar *pSpecCharData = (const CNetObj_SpecChar *)pData;
m_aClients[Item.m_ID].m_SpecChar.m_X = pSpecCharData->m_X;
m_aClients[Item.m_ID].m_SpecChar.m_Y = pSpecCharData->m_Y;
}
else if(Item.m_Type == NETOBJTYPE_SPECTATORINFO)
{
m_Snap.m_pSpectatorInfo = (const CNetObj_SpectatorInfo *)pData;
@ -1853,6 +1860,9 @@ void CGameClient::CClientData::Reset()
m_Evolved.m_Tick = -1;
m_SpecChar.m_X = 0;
m_SpecChar.m_Y = 0;
UpdateRenderInfo();
}

View file

@ -290,6 +290,12 @@ public:
int64 m_SmoothLen[2];
vec2 m_PredPos[200];
int m_PredTick[200];
struct SpecChar
{
int m_X;
int m_Y;
} m_SpecChar;
};
CClientData m_aClients[MAX_CLIENTS];

View file

@ -411,6 +411,13 @@ void CPlayer::Snap(int SnappingClient)
protocol7::CNetObj_PlayerInfoRace *pRaceInfo = static_cast<protocol7::CNetObj_PlayerInfoRace *>(Server()->SnapNewItem(-protocol7::NETOBJTYPE_PLAYERINFORACE, id, sizeof(protocol7::CNetObj_PlayerInfoRace)));
pRaceInfo->m_RaceStartTick = m_pCharacter->m_StartTime;
}
if(m_Paused == PAUSE_SPEC && m_pCharacter && m_pCharacter->Core())
{
CNetObj_SpecChar *pSpecChar = static_cast<CNetObj_SpecChar *>(Server()->SnapNewItem(NETOBJTYPE_SPECCHAR, id, sizeof(CNetObj_SpecChar)));
pSpecChar->m_X = m_pCharacter->Core()->m_Pos.x;
pSpecChar->m_Y = m_pCharacter->Core()->m_Pos.y;
}
}
void CPlayer::FakeSnap()