MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / CreateIdentity

Method CreateIdentity

engine/Poseidon/Network/NetworkServerMsg.cpp:549–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547 // check if player is still connected
548 if (!GetPlayerInfo(ident.dpnid))
549 {
550 // player already disconnected
551 return;
552 }
553
554 int index = _identities.Add(ident);
555 PlayerIdentity& identity = _identities[index];
556 identity.playerid = _nextPlayerId++;
557 if (identity.dpnid == _botClient)
558 {
559 identity._rights |= PRServer;
560 }
561
562#if LOG_PLAYERS
563 RptF("Server: Identity added - name %s, id %d (total %d identities, %d players)", (const char*)ident.name,
564 ident.dpnid, _identities.Size(), _players.Size());
565#endif
566
567 if (squad)
568 {
569 // add squad and send it to all players except new (do not send twice)
570 _squads.Add(squad);
571 RString src, dst;
572 if (squad->picture.GetLength() > 0)
573 {
574 src = Poseidon::BuildNetworkServerSquadPictureUploadPath(GetServerTmpDir(), squad->nick, squad->picture);
575 if (QIFStream::FileExists(src))
576 {
577 dst = Poseidon::BuildNetworkSquadPictureTmpPath(squad->nick, squad->picture);
578 }
579 else
580 {
581 LOG_WARN(Network, "[squad] logo missing for transfer '{}'", (const char*)src);
582 src = "";
583 }
584 }
585 for (int i = 0; i < _identities.Size(); i++)
586 {
587 if (i != index)
588 {
589 if (src.GetLength() > 0)
590 {
591 TransferFile(_identities[i].dpnid, dst, src);
592 }
593 SendMsg(_identities[i].dpnid, squad, NMFGuaranteed);
594 }
595 }
596 if (_dedicated)
597 {
598 NetworkClient* client = _parent->GetClient();
599 NET_ERROR(client && client->GetPlayer() != identity.dpnid);
600 // send new identity to bot client
601 if (src.GetLength() > 0)
602 {
603 TransferFile(client->GetPlayer(), dst, src);
604 }
605 SendMsg(client->GetPlayer(), squad, NMFGuaranteed);
606 }

Callers

nothing calls this directly

Calls 15

GetServerTmpDirFunction · 0.85
GlobalTickCountFunction · 0.85
LocalizeStringFunction · 0.85
AddMissionListFunction · 0.85
GetClientMethod · 0.80
RStringClass · 0.50
FileExistsFunction · 0.50
stricmpFunction · 0.50
toIntFunction · 0.50
AddMethod · 0.45
SizeMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected