mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
CCoreCharacter: Add and use HookedPlayer()
This commit is contained in:
parent
ab5834278f
commit
9eb4cf7508
|
@ -1171,7 +1171,7 @@ void CCharacter::ResetPrediction()
|
|||
SetWeaponGot(w, false);
|
||||
SetWeaponAmmo(w, -1);
|
||||
}
|
||||
if(m_Core.m_HookedPlayer >= 0)
|
||||
if(m_Core.HookedPlayer() >= 0)
|
||||
{
|
||||
m_Core.SetHookedPlayer(-1);
|
||||
m_Core.m_HookState = HOOK_IDLE;
|
||||
|
|
|
@ -315,7 +315,7 @@ void CGameWorld::ReleaseHooked(int ClientID)
|
|||
for(; pChr; pChr = (CCharacter *)pChr->TypeNext())
|
||||
{
|
||||
CCharacterCore *pCore = pChr->Core();
|
||||
if(pCore->m_HookedPlayer == ClientID)
|
||||
if(pCore->HookedPlayer() == ClientID)
|
||||
{
|
||||
pCore->SetHookedPlayer(-1);
|
||||
pCore->m_HookState = HOOK_RETRACTED;
|
||||
|
@ -556,7 +556,7 @@ void CGameWorld::NetObjEnd()
|
|||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
if(CCharacter *pChar = GetCharacterByID(i))
|
||||
if(!pChar->m_MarkedForDestroy)
|
||||
if(CCharacter *pHookedChar = GetCharacterByID(pChar->m_Core.m_HookedPlayer))
|
||||
if(CCharacter *pHookedChar = GetCharacterByID(pChar->m_Core.HookedPlayer()))
|
||||
if(pHookedChar->m_MarkedForDestroy)
|
||||
{
|
||||
pHookedChar->m_Pos = pHookedChar->m_Core.m_Pos = pChar->m_Core.m_HookPos;
|
||||
|
|
|
@ -236,8 +236,8 @@ public:
|
|||
vec2 m_HookTeleBase;
|
||||
int m_HookTick;
|
||||
int m_HookState;
|
||||
int m_HookedPlayer;
|
||||
std::set<int> m_AttachedPlayers;
|
||||
int HookedPlayer() const { return m_HookedPlayer; }
|
||||
void SetHookedPlayer(int HookedPlayer);
|
||||
|
||||
int m_ActiveWeapon;
|
||||
|
@ -318,6 +318,7 @@ public:
|
|||
private:
|
||||
CTeamsCore *m_pTeams;
|
||||
int m_MoveRestrictions;
|
||||
int m_HookedPlayer;
|
||||
static bool IsSwitchActiveCb(int Number, void *pUser);
|
||||
};
|
||||
|
||||
|
|
|
@ -768,7 +768,8 @@ void CCharacter::Tick()
|
|||
|
||||
if(m_Core.m_TriggeredEvents & COREEVENT_HOOK_ATTACH_PLAYER)
|
||||
{
|
||||
if(m_Core.m_HookedPlayer != -1 && GameServer()->m_apPlayers[m_Core.m_HookedPlayer]->GetTeam() != TEAM_SPECTATORS)
|
||||
const int HookedPlayer = m_Core.HookedPlayer();
|
||||
if(HookedPlayer != -1 && GameServer()->m_apPlayers[HookedPlayer]->GetTeam() != TEAM_SPECTATORS)
|
||||
{
|
||||
Antibot()->OnHookAttach(m_pPlayer->GetCID(), true);
|
||||
}
|
||||
|
@ -1138,7 +1139,7 @@ bool CCharacter::IsSnappingCharacterInView(int SnappingClientID)
|
|||
for(const auto &AttachedPlayerID : m_Core.m_AttachedPlayers)
|
||||
{
|
||||
CCharacter *pOtherPlayer = GameServer()->GetPlayerChar(AttachedPlayerID);
|
||||
if(pOtherPlayer && pOtherPlayer->m_Core.m_HookedPlayer == ID)
|
||||
if(pOtherPlayer && pOtherPlayer->m_Core.HookedPlayer() == ID)
|
||||
{
|
||||
if(!NetworkClippedLine(SnappingClientID, m_Pos, pOtherPlayer->m_Pos))
|
||||
{
|
||||
|
@ -1269,7 +1270,7 @@ void CCharacter::FillAntibot(CAntibotCharacterData *pData)
|
|||
pData->m_Pos = m_Pos;
|
||||
pData->m_Vel = m_Core.m_Vel;
|
||||
pData->m_Angle = m_Core.m_Angle;
|
||||
pData->m_HookedPlayer = m_Core.m_HookedPlayer;
|
||||
pData->m_HookedPlayer = m_Core.HookedPlayer();
|
||||
pData->m_SpawnTick = m_SpawnTick;
|
||||
pData->m_WeaponChangeTick = m_WeaponChangeTick;
|
||||
pData->m_aLatestInputs[0].m_TargetX = m_LatestInput.m_TargetX;
|
||||
|
@ -2229,7 +2230,7 @@ void CCharacter::Pause(bool Pause)
|
|||
GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0;
|
||||
GameServer()->m_World.RemoveEntity(this);
|
||||
|
||||
if(m_Core.m_HookedPlayer != -1) // Keeping hook would allow cheats
|
||||
if(m_Core.HookedPlayer() != -1) // Keeping hook would allow cheats
|
||||
{
|
||||
ResetHook();
|
||||
GameWorld()->ReleaseHooked(GetPlayer()->GetCID());
|
||||
|
@ -2332,5 +2333,6 @@ CClientMask CCharacter::TeamMask()
|
|||
|
||||
void CCharacter::SwapClients(int Client1, int Client2)
|
||||
{
|
||||
m_Core.SetHookedPlayer(m_Core.m_HookedPlayer == Client1 ? Client2 : m_Core.m_HookedPlayer == Client2 ? Client1 : m_Core.m_HookedPlayer);
|
||||
const int HookedPlayer = m_Core.HookedPlayer();
|
||||
m_Core.SetHookedPlayer(HookedPlayer == Client1 ? Client2 : HookedPlayer == Client2 ? Client1 : HookedPlayer);
|
||||
}
|
||||
|
|
|
@ -428,7 +428,7 @@ void CGameWorld::ReleaseHooked(int ClientID)
|
|||
for(; pChr; pChr = (CCharacter *)pChr->TypeNext())
|
||||
{
|
||||
CCharacterCore *pCore = pChr->Core();
|
||||
if(pCore->m_HookedPlayer == ClientID && !pChr->IsSuper())
|
||||
if(pCore->HookedPlayer() == ClientID && !pChr->IsSuper())
|
||||
{
|
||||
pCore->SetHookedPlayer(-1);
|
||||
pCore->m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
||||
|
|
|
@ -100,7 +100,7 @@ void CSaveTee::Save(CCharacter *pChr)
|
|||
m_HookTick = pChr->m_Core.m_HookTick;
|
||||
|
||||
m_HookState = pChr->m_Core.m_HookState;
|
||||
m_HookedPlayer = pChr->m_Core.m_HookedPlayer;
|
||||
m_HookedPlayer = pChr->m_Core.HookedPlayer();
|
||||
m_NewHook = pChr->m_Core.m_NewHook != 0;
|
||||
|
||||
m_InputDirection = pChr->m_SavedInput.m_Direction;
|
||||
|
|
Loading…
Reference in a new issue