| 518 | } |
| 519 | |
| 520 | void ServerNetworkGameSocketHandler::CheckNextClientToSendMap(NetworkClientSocket *ignore_cs) |
| 521 | { |
| 522 | Debug(net, 9, "client[{}] CheckNextClientToSendMap()", this->client_id); |
| 523 | |
| 524 | /* Find the best candidate for joining, i.e. the first joiner. */ |
| 525 | NetworkClientSocket *best = nullptr; |
| 526 | for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) { |
| 527 | if (ignore_cs == new_cs) continue; |
| 528 | |
| 529 | if (new_cs->status == STATUS_MAP_WAIT) { |
| 530 | if (best == nullptr || best->GetInfo()->join_date > new_cs->GetInfo()->join_date || (best->GetInfo()->join_date == new_cs->GetInfo()->join_date && best->client_id > new_cs->client_id)) { |
| 531 | best = new_cs; |
| 532 | } |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | /* Is there someone else to join? */ |
| 537 | if (best != nullptr) { |
| 538 | /* Let the first start joining. */ |
| 539 | best->status = STATUS_AUTHORIZED; |
| 540 | best->SendMap(); |
| 541 | |
| 542 | /* And update the rest. */ |
| 543 | for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) { |
| 544 | if (new_cs->status == STATUS_MAP_WAIT) new_cs->SendWait(); |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | /** This sends the map to the client */ |
| 550 | NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap() |
no test coverage detected