mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Move DefaultEmote logic into CPlayer
This commit is contained in:
parent
4004fc093c
commit
f0e34c9c36
|
@ -1110,23 +1110,24 @@ void CGameContext::ConEyeEmote(IConsole::IResult *pResult, void *pUserData)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(pPlayer->m_LastEyeEmote + (int64_t)g_Config.m_SvEyeEmoteChangeDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
|
||||
if(!pPlayer->CanOverrideDefaultEmote())
|
||||
return;
|
||||
|
||||
int EmoteType = 0;
|
||||
if(!str_comp(pResult->GetString(0), "angry"))
|
||||
pPlayer->m_DefEmote = EMOTE_ANGRY;
|
||||
EmoteType = EMOTE_ANGRY;
|
||||
else if(!str_comp(pResult->GetString(0), "blink"))
|
||||
pPlayer->m_DefEmote = EMOTE_BLINK;
|
||||
EmoteType = EMOTE_BLINK;
|
||||
else if(!str_comp(pResult->GetString(0), "close"))
|
||||
pPlayer->m_DefEmote = EMOTE_BLINK;
|
||||
EmoteType = EMOTE_BLINK;
|
||||
else if(!str_comp(pResult->GetString(0), "happy"))
|
||||
pPlayer->m_DefEmote = EMOTE_HAPPY;
|
||||
EmoteType = EMOTE_HAPPY;
|
||||
else if(!str_comp(pResult->GetString(0), "pain"))
|
||||
pPlayer->m_DefEmote = EMOTE_PAIN;
|
||||
EmoteType = EMOTE_PAIN;
|
||||
else if(!str_comp(pResult->GetString(0), "surprise"))
|
||||
pPlayer->m_DefEmote = EMOTE_SURPRISE;
|
||||
EmoteType = EMOTE_SURPRISE;
|
||||
else if(!str_comp(pResult->GetString(0), "normal"))
|
||||
pPlayer->m_DefEmote = EMOTE_NORMAL;
|
||||
EmoteType = EMOTE_NORMAL;
|
||||
else
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
|
@ -1138,8 +1139,7 @@ void CGameContext::ConEyeEmote(IConsole::IResult *pResult, void *pUserData)
|
|||
if(pResult->NumArguments() > 1)
|
||||
Duration = clamp(pResult->GetInteger(1), 1, 86400);
|
||||
|
||||
pPlayer->m_DefEmoteReset = pSelf->Server()->Tick() + Duration * pSelf->Server()->TickSpeed();
|
||||
pPlayer->m_LastEyeEmote = pSelf->Server()->Tick();
|
||||
pPlayer->OverrideDefaultEmote(EmoteType, pSelf->Server()->Tick() + Duration * pSelf->Server()->TickSpeed());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -768,7 +768,7 @@ void CCharacter::Tick()
|
|||
// set emote
|
||||
if(m_EmoteStop < Server()->Tick())
|
||||
{
|
||||
m_EmoteType = m_pPlayer->m_DefEmote;
|
||||
m_EmoteType = m_pPlayer->GetDefaultEmote();
|
||||
m_EmoteStop = -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -787,6 +787,23 @@ void CPlayer::AfkVoteTimer(CNetObj_PlayerInput *NewTarget)
|
|||
m_Afk = false;
|
||||
}
|
||||
|
||||
int CPlayer::GetDefaultEmote() const
|
||||
{
|
||||
return m_DefEmote;
|
||||
}
|
||||
|
||||
void CPlayer::OverrideDefaultEmote(int Emote, int Tick)
|
||||
{
|
||||
m_DefEmote = Emote;
|
||||
m_DefEmoteReset = Tick;
|
||||
m_LastEyeEmote = Server()->Tick();
|
||||
}
|
||||
|
||||
bool CPlayer::CanOverrideDefaultEmote() const
|
||||
{
|
||||
return m_LastEyeEmote > 0 && m_LastEyeEmote + (int64_t)g_Config.m_SvEyeEmoteChangeDelay * Server()->TickSpeed() >= Server()->Tick();
|
||||
}
|
||||
|
||||
void CPlayer::ProcessPause()
|
||||
{
|
||||
if(m_ForcePauseTime && m_ForcePauseTime < Server()->Tick())
|
||||
|
|
|
@ -192,6 +192,11 @@ public:
|
|||
char m_pAfkMsg[160];
|
||||
bool m_EyeEmoteEnabled;
|
||||
int m_TimerType;
|
||||
|
||||
int GetDefaultEmote() const;
|
||||
void OverrideDefaultEmote(int Emote, int Tick);
|
||||
bool CanOverrideDefaultEmote() const;
|
||||
|
||||
int m_DefEmote;
|
||||
int m_DefEmoteReset;
|
||||
bool m_Halloween;
|
||||
|
|
Loading…
Reference in a new issue