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

Method SendWelcome

src/network/network_server.cpp:472–499  ·  view source on GitHub ↗

Send the client a welcome message with some basic information. */

Source from the content-addressed store, hash-verified

470
471/** Send the client a welcome message with some basic information. */
472NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome()
473{
474 Debug(net, 9, "client[{}] SendWelcome()", this->client_id);
475
476 /* Invalid packet when status is anything but STATUS_NEWGRFS_CHECK. */
477 if (this->status != STATUS_NEWGRFS_CHECK) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET);
478
479 Debug(net, 9, "client[{}] status = AUTHORIZED", this->client_id);
480 this->status = STATUS_AUTHORIZED;
481
482 /* Reset 'lag' counters */
483 this->last_frame = this->last_frame_server = _frame_counter;
484
485 _network_game_info.clients_on++;
486
487 auto p = std::make_unique<Packet>(this, PACKET_SERVER_WELCOME);
488 p->Send_uint32(this->client_id);
489 this->SendPacket(std::move(p));
490
491 /* Transmit info about all the active clients */
492 for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
493 if (new_cs != this && new_cs->status >= STATUS_AUTHORIZED) {
494 this->SendClientInfo(new_cs->GetInfo());
495 }
496 }
497 /* Also send the info of the server */
498 return this->SendClientInfo(NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER));
499}
500
501/** Tell the client that its put in a waiting queue. */
502NetworkRecvStatus ServerNetworkGameSocketHandler::SendWait()

Callers 2

SendNewGRFCheckMethod · 0.95

Calls 5

CloseConnectionMethod · 0.95
SendClientInfoMethod · 0.95
Send_uint32Method · 0.80
SendPacketMethod · 0.45
GetInfoMethod · 0.45

Tested by

no test coverage detected