================== idAsyncServer::SendUserInfoBroadcast ================== */
| 879 | ================== |
| 880 | */ |
| 881 | void idAsyncServer::SendUserInfoBroadcast( int userInfoNum, const idDict &info, bool sendToAll ) { |
| 882 | idBitMsg msg; |
| 883 | byte msgBuf[MAX_MESSAGE_SIZE]; |
| 884 | const idDict *gameInfo; |
| 885 | bool gameModifiedInfo; |
| 886 | |
| 887 | gameInfo = game->SetUserInfo( userInfoNum, info, false, true ); |
| 888 | if ( gameInfo ) { |
| 889 | gameModifiedInfo = true; |
| 890 | } else { |
| 891 | gameModifiedInfo = false; |
| 892 | gameInfo = &info; |
| 893 | } |
| 894 | |
| 895 | if ( userInfoNum == localClientNum ) { |
| 896 | common->DPrintf( "local user info modified by server\n" ); |
| 897 | cvarSystem->SetCVarsFromDict( *gameInfo ); |
| 898 | cvarSystem->ClearModifiedFlags( CVAR_USERINFO ); // don't emit back |
| 899 | } |
| 900 | |
| 901 | msg.Init( msgBuf, sizeof( msgBuf ) ); |
| 902 | msg.WriteByte( SERVER_RELIABLE_MESSAGE_CLIENTINFO ); |
| 903 | msg.WriteByte( userInfoNum ); |
| 904 | if ( gameModifiedInfo || sendToAll ) { |
| 905 | msg.WriteBits( 0, 1 ); |
| 906 | } else { |
| 907 | msg.WriteBits( 1, 1 ); |
| 908 | } |
| 909 | |
| 910 | #if ID_CLIENTINFO_TAGS |
| 911 | msg.WriteInt( sessLocal.mapSpawnData.userInfo[userInfoNum].Checksum() ); |
| 912 | common->DPrintf( "broadcast for client %d: 0x%x\n", userInfoNum, sessLocal.mapSpawnData.userInfo[userInfoNum].Checksum() ); |
| 913 | sessLocal.mapSpawnData.userInfo[userInfoNum].Print(); |
| 914 | #endif |
| 915 | |
| 916 | if ( gameModifiedInfo || sendToAll ) { |
| 917 | msg.WriteDeltaDict( *gameInfo, NULL ); |
| 918 | } else { |
| 919 | msg.WriteDeltaDict( *gameInfo, &sessLocal.mapSpawnData.userInfo[userInfoNum] ); |
| 920 | } |
| 921 | |
| 922 | for ( int i = 0; i < MAX_ASYNC_CLIENTS; i++ ) { |
| 923 | if ( clients[i].clientState >= SCS_CONNECTED && ( sendToAll || i != userInfoNum || gameModifiedInfo ) ) { |
| 924 | SendReliableMessage( i, msg ); |
| 925 | } |
| 926 | } |
| 927 | |
| 928 | sessLocal.mapSpawnData.userInfo[userInfoNum] = *gameInfo; |
| 929 | } |
| 930 | |
| 931 | /* |
| 932 | ================== |
nothing calls this directly
no test coverage detected