MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CheckNextClientToSendMap

Method CheckNextClientToSendMap

src/network/network_server.cpp:520–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518}
519
520void 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 */
550NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap()

Callers 2

CloseConnectionMethod · 0.95
SendMapMethod · 0.95

Calls 3

SendMapMethod · 0.80
SendWaitMethod · 0.80
GetInfoMethod · 0.45

Tested by

no test coverage detected