# HG changeset patch # User Adam Kaminski # Date 1623684221 14400 # Mon Jun 14 11:23:41 2021 -0400 # Node ID 1406b99a3a6f92ad8594dbbf9a6456924db3df2c # Parent 19ba229ae673d3f8c8004b8a7c4439755297a76a Moved some code from SCOREBOARD_RefreshHUD into a separate function: TEAM_UpdateCarriers. This fixes an issue with GetTeamProperty and TPROP_CARRIER not working properly on the server in online games. diff -r 19ba229ae673 -r 1406b99a3a6f src/g_level.cpp --- a/src/g_level.cpp Sat Jun 12 23:07:53 2021 -0400 +++ b/src/g_level.cpp Mon Jun 14 11:23:41 2021 -0400 @@ -1381,6 +1381,10 @@ level.maptime = 0; + // [AK] Update the team carriers if we're playing on a team-based game mode. + if ( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSONTEAMS ) + TEAM_UpdateCarriers( ); + // Refresh the HUD. HUD_Refresh( ); diff -r 19ba229ae673 -r 1406b99a3a6f src/p_user.cpp --- a/src/p_user.cpp Sat Jun 12 23:07:53 2021 -0400 +++ b/src/p_user.cpp Mon Jun 14 11:23:41 2021 -0400 @@ -911,6 +911,10 @@ { InvSel = item; } + + // [AK] Update the carriers if we added a team item to the player's inventory in a team-based game mode. + if (( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSONTEAMS ) && ( item->IsKindOf( RUNTIME_CLASS( ATeamItem )))) + TEAM_UpdateCarriers( ); } //=========================================================================== @@ -967,6 +971,10 @@ { PickNewWeapon (NULL); } + + // [AK] Update the carriers if we removed a team item from the player's inventory in a team-based game mode. + if (( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSONTEAMS ) && ( item->IsKindOf( RUNTIME_CLASS( ATeamItem )))) + TEAM_UpdateCarriers( ); } //=========================================================================== diff -r 19ba229ae673 -r 1406b99a3a6f src/scoreboard.cpp --- a/src/scoreboard.cpp Sat Jun 12 23:07:53 2021 -0400 +++ b/src/scoreboard.cpp Mon Jun 14 11:23:41 2021 -0400 @@ -1174,25 +1174,6 @@ // [AK] Determine which player is carrying the terminator sphere, possession hellstone, or white flag. g_pArtifactCarrier = GAMEMODE_GetArtifactCarrier( ); - // [AK] Determine which players are carrying a team's item. - if ( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSONTEAMS ) - { - for ( ULONG ulTeam = 0; ulTeam < teams.Size( ); ulTeam++ ) - { - TEAM_SetCarrier( ulTeam, NULL ); - - for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ ) - { - // [AK] Ignore invalid players. - if (( playeringame[ulIdx] == false ) || ( PLAYER_IsTrueSpectator( &players[ulIdx] )) || ( players[ulIdx].mo == NULL )) - continue; - - if ( players[ulIdx].mo->FindInventory( TEAM_GetItem( ulTeam ))) - TEAM_SetCarrier( ulTeam, &players[ulIdx] ); - } - } - } - player_t *player = &players[HUD_GetViewPlayer( )]; g_ulRank = HUD_CalcRank( player - players ); diff -r 19ba229ae673 -r 1406b99a3a6f src/team.cpp --- a/src/team.cpp Sat Jun 12 23:07:53 2021 -0400 +++ b/src/team.cpp Mon Jun 14 11:23:41 2021 -0400 @@ -1211,6 +1211,26 @@ //***************************************************************************** // +void TEAM_UpdateCarriers( void ) +{ + for ( ULONG ulTeam = 0; ulTeam < teams.Size( ); ulTeam++ ) + { + TEAM_SetCarrier( ulTeam, NULL ); + + for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ ) + { + // [AK] Ignore invalid players. + if ( PLAYER_IsValidPlayerWithMo( ulIdx ) == false ) + continue; + + if ( players[ulIdx].mo->FindInventory( TEAM_GetItem( ulTeam ))) + TEAM_SetCarrier( ulTeam, &players[ulIdx] ); + } + } +} + +//***************************************************************************** +// player_t *TEAM_GetCarrier( ULONG ulTeamIdx ) { if ( TEAM_CheckIfValid( ulTeamIdx )) diff -r 19ba229ae673 -r 1406b99a3a6f src/team.h --- a/src/team.h Sat Jun 12 23:07:53 2021 -0400 +++ b/src/team.h Mon Jun 14 11:23:41 2021 -0400 @@ -128,6 +128,7 @@ AInventory *TEAM_FindOpposingTeamsItemInPlayersInventory( player_t *pPlayer ); +void TEAM_UpdateCarriers( void ); player_t *TEAM_GetCarrier( ULONG ulTeamIdx ); void TEAM_SetCarrier( ULONG ulTeamIdx, player_t *player );