MCPcopy Create free account
hub / github.com/ddnet/ddnet / AddFriend

Method AddFriend

src/engine/client/friends.cpp:102–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102void CFriends::AddFriend(const char *pName, const char *pClan)
103{
104 if(m_NumFriends == MAX_FRIENDS || (pName[0] == 0 && pClan[0] == 0))
105 return;
106
107 // make sure we don't have the friend already
108 unsigned NameHash = str_quickhash(pName);
109 unsigned ClanHash = str_quickhash(pClan);
110 for(int i = 0; i < m_NumFriends; ++i)
111 {
112 if((m_aFriends[i].m_NameHash == NameHash && !str_comp(m_aFriends[i].m_aName, pName)) && ((g_Config.m_ClFriendsIgnoreClan && m_aFriends[i].m_aName[0]) || (m_aFriends[i].m_ClanHash == ClanHash && !str_comp(m_aFriends[i].m_aClan, pClan))))
113 return;
114 }
115
116 str_copy(m_aFriends[m_NumFriends].m_aName, pName);
117 str_copy(m_aFriends[m_NumFriends].m_aClan, pClan);
118 m_aFriends[m_NumFriends].m_NameHash = NameHash;
119 m_aFriends[m_NumFriends].m_ClanHash = ClanHash;
120 ++m_NumFriends;
121}
122
123void CFriends::RemoveFriend(const char *pName, const char *pClan)
124{

Callers 5

RenderMethod · 0.80
RenderPlayersMethod · 0.80
ConAddFriendMethod · 0.80

Calls 3

str_quickhashFunction · 0.85
str_compFunction · 0.85
str_copyFunction · 0.50

Tested by

no test coverage detected