mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Improve friends and foes feature
- Add friends and foes commands to list them - Make clan optional for adding and removing
This commit is contained in:
parent
d2bec89c05
commit
eb29a21142
|
@ -28,6 +28,12 @@ void CFriends::ConRemoveFriend(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->RemoveFriend(pResult->GetString(0), pResult->GetString(1));
|
||||
}
|
||||
|
||||
void CFriends::ConFriends(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CFriends *pSelf = (CFriends *)pUserData;
|
||||
pSelf->Friends();
|
||||
}
|
||||
|
||||
void CFriends::Init(bool Foes)
|
||||
{
|
||||
m_Foes = Foes;
|
||||
|
@ -41,13 +47,15 @@ void CFriends::Init(bool Foes)
|
|||
{
|
||||
if(Foes)
|
||||
{
|
||||
pConsole->Register("add_foe", "ss", CFGFLAG_CLIENT, ConAddFriend, this, "Add a foe");
|
||||
pConsole->Register("remove_foe", "ss", CFGFLAG_CLIENT, ConRemoveFriend, this, "Remove a foe");
|
||||
pConsole->Register("add_foe", "s?s", CFGFLAG_CLIENT, ConAddFriend, this, "Add a foe");
|
||||
pConsole->Register("remove_foe", "s?s", CFGFLAG_CLIENT, ConRemoveFriend, this, "Remove a foe");
|
||||
pConsole->Register("foes", "", CFGFLAG_CLIENT, ConFriends, this, "List foes");
|
||||
}
|
||||
else
|
||||
{
|
||||
pConsole->Register("add_friend", "ss", CFGFLAG_CLIENT, ConAddFriend, this, "Add a friend");
|
||||
pConsole->Register("remove_friend", "ss", CFGFLAG_CLIENT, ConRemoveFriend, this, "Remove a friend");
|
||||
pConsole->Register("add_friend", "s?s", CFGFLAG_CLIENT, ConAddFriend, this, "Add a friend");
|
||||
pConsole->Register("remove_friend", "s?s", CFGFLAG_CLIENT, ConRemoveFriend, this, "Remove a friend");
|
||||
pConsole->Register("friends", "", CFGFLAG_CLIENT, ConFriends, this, "List friends");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +141,20 @@ void CFriends::RemoveFriend(int Index)
|
|||
mem_move(&m_aFriends[Index], &m_aFriends[Index+1], sizeof(CFriendInfo)*(m_NumFriends-(Index+1)));
|
||||
--m_NumFriends;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void CFriends::Friends()
|
||||
{
|
||||
char aBuf[128];
|
||||
IConsole *pConsole = Kernel()->RequestInterface<IConsole>();
|
||||
if(pConsole)
|
||||
{
|
||||
for(int i = 0; i < m_NumFriends; ++i)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "Name: %s, Clan: %s", m_aFriends[i].m_aName, m_aFriends[i].m_aClan);
|
||||
pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, m_Foes?"foes":"friends", aBuf, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CFriends::ConfigSaveCallback(IConfig *pConfig, void *pUserData)
|
||||
|
|
|
@ -13,6 +13,7 @@ class CFriends : public IFriends
|
|||
|
||||
static void ConAddFriend(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConRemoveFriend(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConFriends(IConsole::IResult *pResult, void *pUserData);
|
||||
|
||||
static void ConfigSaveCallback(IConfig *pConfig, void *pUserData);
|
||||
|
||||
|
@ -29,6 +30,7 @@ public:
|
|||
void AddFriend(const char *pName, const char *pClan);
|
||||
void RemoveFriend(const char *pName, const char *pClan);
|
||||
void RemoveFriend(int Index);
|
||||
void Friends();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue