1628: Make client know about other solo players, fixes #258 r=heinrich5991 a=Ryozuki

When another player is in solo and you are not, you could notice a weird collision and also the hook moving a little towards the solo player. This as been fixed.

It also applies m_ClShowOthersAlpha to other players whenever you are on solo or others are.

It uses the protocol extension thingy.

fixes #258 

Co-authored-by: Ryozuki <ryo@ryozuki.xyz>
Co-authored-by: Learath <learath2@gmail.com>
This commit is contained in:
bors[bot] 2019-04-18 23:03:52 +00:00
commit bbf485a9ac
10 changed files with 57 additions and 7 deletions

View file

@ -4,6 +4,7 @@ Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD", "AIM"]
GameFlags = ["TEAMS", "FLAGS"]
GameStateFlags = ["GAMEOVER", "SUDDENDEATH", "PAUSED", "RACETIME"]
CharacterFlags = ["SOLO"]
Emoticons = ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"]
@ -56,7 +57,8 @@ Enums = [
Flags = [
Flags("PLAYERFLAG", PlayerFlags),
Flags("GAMEFLAG", GameFlags),
Flags("GAMESTATEFLAG", GameStateFlags)
Flags("GAMESTATEFLAG", GameStateFlags),
Flags("CHARACTERFLAG", CharacterFlags),
]
Objects = [
@ -206,6 +208,10 @@ Objects = [
NetIntRange("m_AuthLevel", "AUTHED_NO", "AUTHED_ADMIN"),
]),
NetObjectEx("DDNetCharacter", "character@netobj.ddnet.tw", [
NetIntAny("m_Flags"),
]),
## Events
NetEvent("Common", [

View file

@ -29,6 +29,7 @@ void CNamePlates::RenderNameplate(
{
float IntraTick = Client()->IntraGameTick();
int ClientID = pPlayerInfo->m_ClientID;
bool Local = m_pClient->m_Snap.m_LocalClientID == ClientID;
vec2 Position;
if((!m_pClient->AntiPingPlayers() && !pPlayerInfo->m_Local) || m_pClient->m_Snap.m_SpecInfo.m_Active)
@ -53,6 +54,12 @@ void CNamePlates::RenderNameplate(
else
OtherTeam = m_pClient->m_Teams.Team(pPlayerInfo->m_ClientID) != m_pClient->m_Teams.Team(m_pClient->m_Snap.m_LocalClientID);
if(m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Solo && !Local)
OtherTeam = true;
if(!Local && m_pClient->m_aClients[pPlayerInfo->m_ClientID].m_Solo)
OtherTeam = true;
float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f;
float FontSizeClan = 18.0f + 20.0f * g_Config.m_ClNameplatesClanSize / 100.0f;
// render name plate

View file

@ -245,6 +245,12 @@ void CPlayers::RenderHook(
else
OtherTeam = m_pClient->m_Teams.Team(ClientID) != m_pClient->m_Teams.Team(m_pClient->m_Snap.m_LocalClientID);
if(m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Solo && !Local)
OtherTeam = true;
if(!Local && m_pClient->m_aClients[ClientID].m_Solo)
OtherTeam = true;
if(OtherTeam)
{
RenderInfo.m_ColorBody.a = g_Config.m_ClShowOthersAlpha / 100.0f;
@ -403,6 +409,12 @@ void CPlayers::RenderPlayer(
else
OtherTeam = m_pClient->m_Teams.Team(ClientID) != m_pClient->m_Teams.Team(m_pClient->m_Snap.m_LocalClientID);
if(m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Solo && !Local)
OtherTeam = true;
if(!Local && m_pClient->m_aClients[ClientID].m_Solo)
OtherTeam = true;
// set size
RenderInfo.m_Size = 64.0f;
@ -468,6 +480,7 @@ void CPlayers::RenderPlayer(
{
// apply predicted results
m_pClient->m_aClients[ClientID].m_Predicted.Write(&Player);
m_pClient->m_aClients[ClientID].m_Predicted.m_Solo = m_pClient->m_aClients[ClientID].m_Solo;
m_pClient->m_aClients[ClientID].m_PrevPredicted.Write(&Prev);
IntraTick = Client()->PredIntraGameTick();

View file

@ -1116,6 +1116,11 @@ void CGameClient::OnNewSnapshot()
Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Cur, Client()->GameTick());
}
}
else if(Item.m_Type == NETOBJTYPE_DDNETCHARACTER)
{
m_aClients[Item.m_ID].m_Solo = m_aClients[Item.m_ID].m_Predicted.m_Solo =
((const CNetObj_DDNetCharacter *)pData)->m_Flags & CHARACTERFLAG_SOLO;
}
else if(Item.m_Type == NETOBJTYPE_SPECTATORINFO)
{
m_Snap.m_pSpectatorInfo = (const CNetObj_SpectatorInfo *)pData;
@ -1849,6 +1854,7 @@ void CGameClient::CClientData::Reset()
m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(0)->m_ColorTexture;
m_SkinInfo.m_ColorBody = vec4(1,1,1,1);
m_SkinInfo.m_ColorFeet = vec4(1,1,1,1);
m_Solo = false;
UpdateRenderInfo();
}
@ -2064,7 +2070,7 @@ int CGameClient::IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2& NewPos2, in
vec2 Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), Client()->IntraGameTick());
if(!cData.m_Active || i == ownID || !m_Teams.SameTeam(i, ownID))
if(!cData.m_Active || i == ownID || !m_Teams.SameTeam(i, ownID) || cData.m_Solo)
continue;
vec2 ClosestPoint = closest_point_on_line(HookPos, NewPos, Position);
@ -2098,7 +2104,7 @@ int CGameClient::IntersectCharacter(vec2 OldPos, vec2 NewPos, float Radius, vec2
continue;
CClientData cData = m_aClients[i];
if(!cData.m_Active || i == ownID || !m_Teams.CanCollide(i, ownID))
if(!cData.m_Active || i == ownID || !m_Teams.CanCollide(i, ownID) || cData.m_Solo)
continue;
vec2 Position = World->m_apCharacters[i]->m_Pos;
vec2 ClosestPoint = closest_point_on_line(OldPos, NewPos, Position);

View file

@ -242,6 +242,7 @@ public:
int m_Team;
int m_Emoticon;
int m_EmoticonStart;
bool m_Solo;
CCharacterCore m_Predicted;
CCharacterCore m_PrevPredicted;

View file

@ -101,6 +101,7 @@ void CCharacterCore::Reset()
m_TriggeredEvents = 0;
m_Hook = true;
m_Collision = true;
m_Solo = false;
}
void CCharacterCore::Tick(bool UseInput, bool IsClient)
@ -294,7 +295,7 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient)
for(int i = 0; i < MAX_CLIENTS; i++)
{
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[i];
if(!pCharCore || pCharCore == this || !m_pTeams->CanCollide(i, m_Id))
if(!pCharCore || pCharCore == this || !m_pTeams->CanCollide(i, m_Id) || pCharCore->m_Solo)
continue;
vec2 ClosestPoint = closest_point_on_line(m_HookPos, NewPos, pCharCore->m_Pos);
@ -408,7 +409,7 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient)
//player *p = (player*)ent;
//if(pCharCore == this) // || !(p->flags&FLAG_ALIVE)
if(pCharCore == this || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, i)))
if(pCharCore == this || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, i)) || pCharCore->m_Solo)
continue; // make sure that we don't nudge our self
// handle player <-> player collision
@ -621,7 +622,10 @@ void CCharacterCore::Move()
for(int p = 0; p < MAX_CLIENTS; p++)
{
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p];
if(!pCharCore || pCharCore == this || !pCharCore->m_Collision || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p)))
if(!pCharCore || pCharCore == this
|| !pCharCore->m_Collision
|| (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p))
|| pCharCore->m_Solo)
continue;
float D = distance(Pos, pCharCore->m_Pos);
if(D < 28.0f && D > 0.0f)

View file

@ -230,6 +230,7 @@ public:
vec2 m_LastVel;
int m_Colliding;
bool m_LeftWall;
bool m_Solo;
void LimitForce(vec2 *Force);
void ApplyForce(vec2 Force);

View file

@ -47,6 +47,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_HasTeleGrenade = false;
m_TeleGunTeleport = false;
m_IsBlueTeleGunTeleport = false;
m_Solo = false;
m_pPlayer = pPlayer;
m_Pos = Pos;
@ -85,6 +86,7 @@ void CCharacter::Destroy()
{
GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0;
m_Alive = false;
m_Solo = false;
}
void CCharacter::SetWeapon(int W)
@ -103,6 +105,8 @@ void CCharacter::SetWeapon(int W)
void CCharacter::SetSolo(bool Solo)
{
m_Solo = Solo;
GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()]->m_Solo = Solo;
Teams()->m_Core.SetSolo(m_pPlayer->GetCID(), Solo);
if(Solo)
@ -902,6 +906,8 @@ void CCharacter::Die(int Killer, int Weapon)
m_pPlayer->m_DieTick = Server()->Tick();
m_Alive = false;
m_Solo = false;
GameServer()->m_World.RemoveEntity(this);
GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0;
GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID(), Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));
@ -1163,6 +1169,11 @@ void CCharacter::Snap(int SnappingClient)
}
pCharacter->m_PlayerFlags = GetPlayer()->m_PlayerFlags;
CNetObj_DDNetCharacter *pDDNetCharacter = static_cast<CNetObj_DDNetCharacter *>(Server()->SnapNewItem(NETOBJTYPE_DDNETCHARACTER, id, sizeof(CNetObj_DDNetCharacter)));
pDDNetCharacter->m_Flags = 0;
if(m_Solo)
pDDNetCharacter->m_Flags |= CHARACTERFLAG_SOLO;
}
int CCharacter::NetworkClipped(int SnappingClient)

View file

@ -173,6 +173,7 @@ private:
bool m_SetSavePos;
vec2 m_PrevSavePos;
bool m_Solo;
public:
CGameTeams* Teams();
@ -185,6 +186,7 @@ public:
int Team();
bool CanCollide(int ClientID);
bool SameTeam(int ClientID);
bool IsSolo() { return m_Solo; };
bool m_Super;
bool m_SuperJump;
bool m_Jetpack;

View file

@ -36,7 +36,6 @@ public:
{
return m_IsSolo[ClientID];
}
;
};
#endif