mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 03:28:19 +00:00
Add converse command
This commit is contained in:
parent
9f45368225
commit
34e568f41b
|
@ -698,6 +698,11 @@ void CGameContext::ConMe(IConsole::IResult *pResult, void *pUserData)
|
||||||
"/me is disabled on this server, admin can enable it by using sv_slash_me");
|
"/me is disabled on this server, admin can enable it by using sv_slash_me");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameContext::ConConverse(IConsole::IResult *pResult, void *pUserData)
|
||||||
|
{
|
||||||
|
// This will never be called
|
||||||
|
}
|
||||||
|
|
||||||
void CGameContext::ConWhisper(IConsole::IResult *pResult, void *pUserData)
|
void CGameContext::ConWhisper(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
// This will never be called
|
// This will never be called
|
||||||
|
|
|
@ -15,6 +15,8 @@ CHAT_COMMAND("info", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConInfo, this, "Shows info
|
||||||
CHAT_COMMAND("me", "r", CFGFLAG_CHAT|CFGFLAG_SERVER, ConMe, this, "Like the famous irc command '/me says hi' will display '<yourname> says hi'")
|
CHAT_COMMAND("me", "r", CFGFLAG_CHAT|CFGFLAG_SERVER, ConMe, this, "Like the famous irc command '/me says hi' will display '<yourname> says hi'")
|
||||||
CHAT_COMMAND("w", "sr", CFGFLAG_CHAT|CFGFLAG_SERVER, ConWhisper, this, "Whisper something to someone (private message)")
|
CHAT_COMMAND("w", "sr", CFGFLAG_CHAT|CFGFLAG_SERVER, ConWhisper, this, "Whisper something to someone (private message)")
|
||||||
CHAT_COMMAND("whisper", "sr", CFGFLAG_CHAT|CFGFLAG_SERVER, ConWhisper, this, "Whisper something to someone (private message)")
|
CHAT_COMMAND("whisper", "sr", CFGFLAG_CHAT|CFGFLAG_SERVER, ConWhisper, this, "Whisper something to someone (private message)")
|
||||||
|
CHAT_COMMAND("c", "r", CFGFLAG_CHAT|CFGFLAG_SERVER, ConConverse, this, "Converse with the last person you whispered to (private message)");
|
||||||
|
CHAT_COMMAND("converse", "r", CFGFLAG_CHAT|CFGFLAG_SERVER, ConConverse, this, "Converse with the last person you whispered to (private message)");
|
||||||
CHAT_COMMAND("pause", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTogglePause, this, "Toggles pause (if not activated on the server, it toggles spec)")
|
CHAT_COMMAND("pause", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTogglePause, this, "Toggles pause (if not activated on the server, it toggles spec)")
|
||||||
CHAT_COMMAND("spec", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConToggleSpec, this, "Toggles spec")
|
CHAT_COMMAND("spec", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConToggleSpec, this, "Toggles spec")
|
||||||
CHAT_COMMAND("rankteam", "?r", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTeamRank, this, "Shows the team rank of player with name r (your team rank by default)")
|
CHAT_COMMAND("rankteam", "?r", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTeamRank, this, "Shows the team rank of player with name r (your team rank by default)")
|
||||||
|
|
|
@ -759,6 +759,13 @@ void CGameContext::OnClientDrop(int ClientID, const char *pReason)
|
||||||
if(m_apPlayers[i] && m_apPlayers[i]->m_SpectatorID == ClientID)
|
if(m_apPlayers[i] && m_apPlayers[i]->m_SpectatorID == ClientID)
|
||||||
m_apPlayers[i]->m_SpectatorID = SPEC_FREEVIEW;
|
m_apPlayers[i]->m_SpectatorID = SPEC_FREEVIEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update conversation targets
|
||||||
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||||
|
{
|
||||||
|
if(m_apPlayers[i] && m_apPlayers[i]->m_LastWhisperTo == ClientID)
|
||||||
|
m_apPlayers[i]->m_LastWhisperTo = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
||||||
|
@ -822,6 +829,18 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
||||||
str_copy(pWhisperMsg, pMsg->m_pMessage + 9, 256);
|
str_copy(pWhisperMsg, pMsg->m_pMessage + 9, 256);
|
||||||
Whisper(pPlayer->GetCID(), pWhisperMsg);
|
Whisper(pPlayer->GetCID(), pWhisperMsg);
|
||||||
}
|
}
|
||||||
|
else if (str_comp_nocase_num(pMsg->m_pMessage+1, "c ", 2) == 0)
|
||||||
|
{
|
||||||
|
char pWhisperMsg[256];
|
||||||
|
str_copy(pWhisperMsg, pMsg->m_pMessage + 3, 256);
|
||||||
|
Converse(pPlayer->GetCID(), pWhisperMsg);
|
||||||
|
}
|
||||||
|
else if (str_comp_nocase_num(pMsg->m_pMessage+1, "converse ", 9) == 0)
|
||||||
|
{
|
||||||
|
char pWhisperMsg[256];
|
||||||
|
str_copy(pWhisperMsg, pMsg->m_pMessage + 10, 256);
|
||||||
|
Converse(pPlayer->GetCID(), pWhisperMsg);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(g_Config.m_SvSpamprotection
|
if(g_Config.m_SvSpamprotection
|
||||||
|
@ -2337,9 +2356,6 @@ void CGameContext::Whisper(int ClientID, char *pStr)
|
||||||
|
|
||||||
pMessage = pStr;
|
pMessage = pStr;
|
||||||
|
|
||||||
if (!CheckClientID2(ClientID))
|
|
||||||
return;
|
|
||||||
|
|
||||||
char aBuf[256];
|
char aBuf[256];
|
||||||
|
|
||||||
if (Error)
|
if (Error)
|
||||||
|
@ -2356,9 +2372,38 @@ void CGameContext::Whisper(int ClientID, char *pStr)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
str_format(aBuf, sizeof(aBuf), "[← %s] %s", Server()->ClientName(ClientID), pMessage);
|
WhisperID(ClientID, Victim, pMessage);
|
||||||
SendChatTarget(Victim, aBuf);
|
}
|
||||||
|
|
||||||
str_format(aBuf, sizeof(aBuf), "[→ %s] %s", Server()->ClientName(Victim), pMessage);
|
void CGameContext::WhisperID(int ClientID, int VictimID, char *pMessage)
|
||||||
|
{
|
||||||
|
if (!CheckClientID2(ClientID))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!CheckClientID2(VictimID))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_apPlayers[ClientID]->m_LastWhisperTo = VictimID;
|
||||||
|
|
||||||
|
char aBuf[256];
|
||||||
|
|
||||||
|
str_format(aBuf, sizeof(aBuf), "[← %s] %s", Server()->ClientName(ClientID), pMessage);
|
||||||
|
SendChatTarget(VictimID, aBuf);
|
||||||
|
|
||||||
|
str_format(aBuf, sizeof(aBuf), "[→ %s] %s", Server()->ClientName(VictimID), pMessage);
|
||||||
SendChatTarget(ClientID, aBuf);
|
SendChatTarget(ClientID, aBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameContext::Converse(int ClientID, char *pStr)
|
||||||
|
{
|
||||||
|
CPlayer *pPlayer = m_apPlayers[ClientID];
|
||||||
|
if (!pPlayer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (pPlayer->m_LastWhisperTo < 0)
|
||||||
|
SendChatTarget(ClientID, "You do not have an ongoing conversation. Whisper to someone to start one");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WhisperID(ClientID, pPlayer->m_LastWhisperTo, pStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -243,6 +243,7 @@ private:
|
||||||
static void ConJoinTeam(IConsole::IResult *pResult, void *pUserData);
|
static void ConJoinTeam(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConMe(IConsole::IResult *pResult, void *pUserData);
|
static void ConMe(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConWhisper(IConsole::IResult *pResult, void *pUserData);
|
static void ConWhisper(IConsole::IResult *pResult, void *pUserData);
|
||||||
|
static void ConConverse(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConSetEyeEmote(IConsole::IResult *pResult, void *pUserData);
|
static void ConSetEyeEmote(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConToggleBroadcast(IConsole::IResult *pResult, void *pUserData);
|
static void ConToggleBroadcast(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConEyeEmote(IConsole::IResult *pResult, void *pUserData);
|
static void ConEyeEmote(IConsole::IResult *pResult, void *pUserData);
|
||||||
|
@ -275,6 +276,8 @@ private:
|
||||||
int m_NumMutes;
|
int m_NumMutes;
|
||||||
void Mute(IConsole::IResult *pResult, NETADDR *Addr, int Secs, const char *pDisplayName);
|
void Mute(IConsole::IResult *pResult, NETADDR *Addr, int Secs, const char *pDisplayName);
|
||||||
void Whisper(int ClientID, char *pStr);
|
void Whisper(int ClientID, char *pStr);
|
||||||
|
void WhisperID(int ClientID, int VictimID, char *pMessage);
|
||||||
|
void Converse(int ClientID, char *pStr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CLayers *Layers() { return &m_Layers; }
|
CLayers *Layers() { return &m_Layers; }
|
||||||
|
|
|
@ -43,6 +43,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team)
|
||||||
m_TimerType = g_Config.m_SvDefaultTimerType;
|
m_TimerType = g_Config.m_SvDefaultTimerType;
|
||||||
m_DefEmote = EMOTE_NORMAL;
|
m_DefEmote = EMOTE_NORMAL;
|
||||||
m_Afk = false;
|
m_Afk = false;
|
||||||
|
m_LastWhisperTo = -1;
|
||||||
|
|
||||||
//New Year
|
//New Year
|
||||||
if (g_Config.m_SvEvents)
|
if (g_Config.m_SvEvents)
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
int m_LastKill;
|
int m_LastKill;
|
||||||
int m_LastCommands[4];
|
int m_LastCommands[4];
|
||||||
int m_LastCommandPos;
|
int m_LastCommandPos;
|
||||||
|
int m_LastWhisperTo;
|
||||||
|
|
||||||
// TODO: clean this up
|
// TODO: clean this up
|
||||||
struct
|
struct
|
||||||
|
|
Loading…
Reference in a new issue