| 177 | |
| 178 | |
| 179 | bool CUpDownClient::IsSourceRequestAllowed() |
| 180 | { |
| 181 | //#warning REWRITE - Source swapping from eMule. |
| 182 | // 0.42e |
| 183 | uint64 dwTickCount = ::GetTickCount64() + CONNECTION_LATENCY; |
| 184 | uint64 nTimePassedClient = dwTickCount - GetLastSrcAnswerTime(); |
| 185 | uint64 nTimePassedFile = dwTickCount - m_reqfile->GetLastAnsweredTime(); |
| 186 | bool bNeverAskedBefore = (GetLastAskedForSources() == 0); |
| 187 | |
| 188 | uint32 uSources = m_reqfile->GetSourceCount(); |
| 189 | return ( |
| 190 | // if client has the correct extended protocol |
| 191 | ExtProtocolAvailable() && (SupportsSourceExchange2() || GetSourceExchange1Version() > 1) && |
| 192 | // AND if we need more sources |
| 193 | thePrefs::GetMaxSourcePerFileSoft() > uSources && |
| 194 | // AND if... |
| 195 | ( |
| 196 | //source is not complete and file is very rare |
| 197 | ( !m_bCompleteSource |
| 198 | && (bNeverAskedBefore || nTimePassedClient > SOURCECLIENTREASKS) |
| 199 | && (uSources <= RARE_FILE/5) |
| 200 | ) || |
| 201 | //source is not complete and file is rare |
| 202 | ( !m_bCompleteSource |
| 203 | && (bNeverAskedBefore || nTimePassedClient > SOURCECLIENTREASKS) |
| 204 | && (uSources <= RARE_FILE || uSources - m_reqfile->GetValidSourcesCount() <= RARE_FILE / 2) |
| 205 | && (nTimePassedFile > SOURCECLIENTREASKF) |
| 206 | ) || |
| 207 | // OR if file is not rare |
| 208 | ( (bNeverAskedBefore || nTimePassedClient > (unsigned)(SOURCECLIENTREASKS * MINCOMMONPENALTY)) |
| 209 | && (nTimePassedFile > (unsigned)(SOURCECLIENTREASKF * MINCOMMONPENALTY)) |
| 210 | ) |
| 211 | ) |
| 212 | ); |
| 213 | } |
| 214 | |
| 215 | |
| 216 | void CUpDownClient::SendFileRequest() |
nothing calls this directly
no test coverage detected