Skip to content

Commit

Permalink
Fix #596: nametags are interiorless
Browse files Browse the repository at this point in the history
  • Loading branch information
qaisjp committed Apr 28, 2020
1 parent 3f39bb5 commit 3df58bd
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 7 deletions.
8 changes: 7 additions & 1 deletion Client/mods/deathmatch/logic/CClientGame.cpp
Expand Up @@ -2312,6 +2312,11 @@ void CClientGame::SetAllDimensions(unsigned short usDimension)
m_pCamera->SetDimension(usDimension);
}

void CClientGame::SetAllInteriors(unsigned char ucInterior)
{
m_pNametags->m_ucInterior = ucInterior;
}

bool CClientGame::StaticKeyStrokeHandler(const SString& strKey, bool bState, bool bIsConsoleInputKey)
{
return g_pClientGame->KeyStrokeHandler(strKey, bState, bIsConsoleInputKey);
Expand Down Expand Up @@ -5683,8 +5688,9 @@ void CClientGame::ResetMapInfo()
m_pCamera->SetFocusToLocalPlayer();
g_pGame->GetSettings()->ResetFieldOfViewFromScript();

// Dimension
// Dimension and interiors
SetAllDimensions(0);
SetAllInteriors(0);

// Hud
g_pGame->GetHud()->SetComponentVisible(HUD_ALL, true);
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.h
Expand Up @@ -349,6 +349,7 @@ class CClientGame
void ResetVehicleInOut();

void SetAllDimensions(unsigned short usDimension);
void SetAllInteriors(unsigned char ucInterior);

static bool StaticKeyStrokeHandler(const SString& strKey, bool bState, bool bIsConsoleInputKey);
bool KeyStrokeHandler(const SString& strKey, bool bState, bool bIsConsoleInputKey);
Expand Down
18 changes: 14 additions & 4 deletions Client/mods/deathmatch/logic/CNametags.cpp
Expand Up @@ -25,6 +25,8 @@ using std::list;
#define DEFAULT_VIEW_RANGE 45.0f
#define DEFAULT_VIEW_RANGE_EXP ((DEFAULT_VIEW_RANGE)*(DEFAULT_VIEW_RANGE))

const bool bRenderOwn = false;

CNametags::CNametags(CClientManager* pManager)
{
m_pPlayerStreamer = pManager->GetPlayerStreamer();
Expand Down Expand Up @@ -261,7 +263,7 @@ void CNametags::DrawDefault()
static float fResHeight = static_cast<float>(g_pCore->GetGraphics()->GetViewportHeight());

// Got any players that are not local?
if (m_pPlayerManager->Count() <= 1)
if (m_pPlayerManager->Count() <= 1 && !bRenderOwn)
return;

list<CClientPlayer*> playerTags;
Expand Down Expand Up @@ -363,7 +365,7 @@ void CNametags::DrawDefault()
if (pElement->GetType() != CCLIENTPLAYER)
continue;
pPlayer = static_cast<CClientPlayer*>(pElement);
if (pPlayer->IsLocalPlayer())
if (pPlayer->IsLocalPlayer() && !bRenderOwn)
continue;

// Get the distance from the camera
Expand Down Expand Up @@ -428,8 +430,16 @@ void CNametags::DrawDefault()

void CNametags::DrawTagForPlayer(CClientPlayer* pPlayer, unsigned char ucAlpha)
{
// If they aren't in the same dimension, dont draw
if (pPlayer->GetDimension() != m_usDimension || !pPlayer->IsNametagShowing())
// If nametag is hidden, don't draw
if (!pPlayer->IsNametagShowing())
return;

// If they aren't in the same dimension, don't draw
if (pPlayer->GetDimension() != m_usDimension)
return;

// If they aren't in the same interior, don't draw
if (pPlayer->GetInterior() != m_ucInterior)
return;

// Grab the resolution width and height
Expand Down
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/CNametags.h
Expand Up @@ -40,6 +40,8 @@ class CNametags
bool IsVisible() { return m_bVisible; }
void SetVisible(bool bVisible) { m_bVisible = bVisible; }

unsigned char m_ucInterior = 0;

private:
static bool CompareNametagDistance(CClientPlayer* p1, CClientPlayer* p2);

Expand Down
4 changes: 2 additions & 2 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Expand Up @@ -1109,9 +1109,9 @@ void CPacketHandler::Packet_PlayerSpawn(NetBitStreamInterface& bitStream)
// Reset vehicle in/out stuff
g_pClientGame->ResetVehicleInOut();

// Make sure all other elements are aware of what dimension we are in now.
// So elements can be removed properly.
// Announce our dimension/interior to all elements, so that elements are removed properly
g_pClientGame->SetAllDimensions(usDimension);
g_pClientGame->SetAllInteriors(ucInterior);

// Reset return position so we can't warp back to where we were if local player
g_pClientGame->m_pNetAPI->ResetReturnPosition();
Expand Down
10 changes: 10 additions & 0 deletions Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Expand Up @@ -1237,6 +1237,16 @@ bool CStaticFunctionDefinitions::SetElementInterior(CClientEntity& Entity, unsig
if (bSetPosition)
Entity.SetPosition(vecPosition);

if (Entity.GetType() == CCLIENTPLAYER)
{
CClientPed& Ped = static_cast<CClientPed&>(Entity);
if (Ped.IsLocalPlayer())
{
// Update all of our streamers/managers to the local player's interior
m_pClientGame->SetAllInteriors(ucInterior);
}
}

return true;
}

Expand Down
9 changes: 9 additions & 0 deletions Client/mods/deathmatch/logic/rpc/CElementRPCs.cpp
Expand Up @@ -253,6 +253,15 @@ void CElementRPCs::SetElementInterior(CClientEntity* pSource, NetBitStreamInterf
if (bitStream.Read(ucInterior) && bitStream.Read(ucSetPosition))
{
pSource->SetInterior(ucInterior);
if (pSource->GetType() == CCLIENTPLAYER)
{
CClientPlayer* pPlayer = static_cast<CClientPlayer*>(pSource);
if (pPlayer->IsLocalPlayer())
{
// Update all of our streamers/managers to the local player's interior
m_pClientGame->SetAllInteriors(ucInterior);
}
}

if (ucSetPosition == 1)
{
Expand Down

0 comments on commit 3df58bd

Please sign in to comment.