| 152 | |
| 153 | |
| 154 | CFriend* CFriendList::FindFriend(const CMD4Hash& userhash, uint32 dwIP, uint16 nPort) |
| 155 | { |
| 156 | |
| 157 | for(FriendList::iterator it = m_FriendList.begin(); it != m_FriendList.end(); ++it) { |
| 158 | |
| 159 | CFriend* cur_friend = *it; |
| 160 | // to avoid that unwanted clients become a friend, we have to distinguish between friends with |
| 161 | // a userhash and of friends which are identified by IP+port only. |
| 162 | if ( !userhash.IsEmpty() && cur_friend->HasHash() ) { |
| 163 | // check for a friend which has the same userhash as the specified one |
| 164 | if (cur_friend->GetUserHash() == userhash) { |
| 165 | return cur_friend; |
| 166 | } |
| 167 | } else if (cur_friend->GetIP() == dwIP && cur_friend->GetPort() == nPort) { |
| 168 | if (!userhash.IsEmpty() && !cur_friend->HasHash() ) { |
| 169 | // Friend without hash (probably IP entered through dialog) |
| 170 | // -> save the hash |
| 171 | cur_friend->SetUserHash(userhash); |
| 172 | SaveList(); |
| 173 | } |
| 174 | return cur_friend; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | return NULL; |
| 179 | } |
| 180 | |
| 181 | |
| 182 | CFriend* CFriendList::FindFriend(uint32 ecid) |
no test coverage detected