Skip to content

Commit

Permalink
Fixed #244
Browse files Browse the repository at this point in the history
  • Loading branch information
eezstreet committed Jun 4, 2017
1 parent 627f7d4 commit 71f4cb2
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 129 deletions.
10 changes: 5 additions & 5 deletions Source/Game/SwatGame/Classes/SwatGameInfo.uc
Original file line number Diff line number Diff line change
Expand Up @@ -2034,21 +2034,21 @@ function NetTeam GetTeamFromID( int TeamID )

///////////////////////////////////////////////////////////////////////////////
//overridden from Engine.GameInfo
event Broadcast( Actor Sender, coerce string Msg, optional name Type, optional PlayerController Target )
event Broadcast( Actor Sender, coerce string Msg, optional name Type, optional PlayerController Target, optional string Location )
{
//log( self$"::Broadcast( "$Msg$" )" );
BroadcastHandler.Broadcast(Sender,Msg,Type,Target);
//log( self$"::Broadcast( "$Msg$" "$Location$" )" );
BroadcastHandler.Broadcast(Sender,Msg,Type,Target,Location);
}

//overridden from Engine.GameInfo
function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type )
function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type, optional string Location )
{
//log( self$"::BroadcastTeam( "$Sender$", "$Msg$" ), sender.statename = "$Sender.GetStateName() );
if( Sender.IsInState( 'ObserveTeam' ) ||
Sender.IsInState( 'Dead' ) )
BroadcastObservers( Sender, Msg, Type );

BroadcastHandler.BroadcastTeam(Sender,Msg,Type);
BroadcastHandler.BroadcastTeam(Sender,Msg,Type,Location);
}

function BroadcastObservers( Controller Sender, coerce string Msg, optional name Type )
Expand Down
74 changes: 43 additions & 31 deletions Source/Game/SwatGame/Classes/SwatGamePlayerController.uc
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ replication
ServerGiveCommand, ServerIssueCompliance, ServerOnEffectStopped, ServerSetVoiceType,
ServerRetryStatsAuth, ServerSetMPLoadOutPrimaryAmmo, ServerSetMPLoadOutSecondaryAmmo,
ServerViewportActivate, ServerViewportDeactivate,
ServerHandleViewportFire, ServerHandleViewportReload,
ServerGetPlayerRoomName;
ServerHandleViewportFire, ServerHandleViewportReload;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3055,7 +3054,7 @@ state Dead
exec function TeamSay( string Msg )
{
//log( self$"::TeamSay( "$Msg$" )" );
log( self$"::TeamSay( "$Msg$" )" );
SwatGameInfo(Level.Game).BroadcastObservers( self, Msg, 'TeamSay');
}
}
Expand Down Expand Up @@ -3119,7 +3118,7 @@ state ObserveFromTeamOrLocation

exec function TeamSay( string Msg )
{
//log( self$"::TeamSay( "$Msg$" )" );
log( self$"::TeamSay( "$Msg$" )" );
SwatGameInfo(Level.Game).BroadcastObservers( self, Msg, 'TeamSay');
}
}
Expand Down Expand Up @@ -4302,20 +4301,55 @@ function ClientRoundStarted()

///////////////////////////////////////////////////////////////////////////////

exec function Say( string Msg )
{
// log(self$"::Say - "$Pawn.GetRoomName()$" - ("$Msg$")");
if (PlayerReplicationInfo.bAdmin && left(Msg,1) == "#" )
{
Level.Game.AdminSay(right(Msg,len(Msg)-1));
return;
}

// On a dedicated server, no one gets TeamMessage(), so we need to print
// it here. We don't do it for listen servers, because we'd get double log
// messages (since listen servers do get TeamMessage() ).
if ( Level.NetMode == NM_DedicatedServer )
{
mplog( "ChatMessage( "$Msg$", Say )" );
}

if(Pawn != None)
Level.Game.Broadcast(self, Msg, 'Say', None, string(Pawn.GetRoomName()));
else
Level.Game.Broadcast(self, Msg, 'Say');
}

exec function TeamSay( string Msg )
{
// log(self$"::TeamSay("$msg$")");
if( !GameReplicationInfo.bTeamGame )
{
Say( Msg );
return;
}

Level.Game.BroadcastTeam( self, Level.Game.ParseMessageString( Level.Game.BaseMutator , self, Msg ), 'TeamSay', string(Pawn.GetRoomName()));
}

event ClientMessage( coerce string S, optional Name Type )
{
//log("[dkaplan] >>> "$self$"::ClientMessage( "$S$", "$Type$" )" );
TeamMessage(PlayerReplicationInfo, S, Type);
ConsoleMessage(S);
}

event TeamMessage(PlayerReplicationInfo PRI, coerce string S, name Type)
event TeamMessage(PlayerReplicationInfo PRI, coerce string S, name Type, optional string Location)
{
//log("[dkaplan] >>> "$self$"::TeamMessage( "$PRI$", "$S$", "$Type$" )" );
//log("[dkaplan] >>> "$self$"::TeamMessage( "$PRI$", "$S$", "$Type$" "$Location$" )" );

if (((Type == 'Say') || (Type == 'TeamSay')) && (PRI != None))
if (Type == 'Say' || Type == 'TeamSay')
{
if(!(ServerGetPlayerRoomName(PRI.PlayerID) ~= "None"))
if(Location != "" && Location != "None")
{
// If we have a RoomName of None, we are spectating
if(Type == 'Say') {
Expand All @@ -4324,7 +4358,7 @@ event TeamMessage(PlayerReplicationInfo PRI, coerce string S, name Type)
Type = 'TeamSayLocalized';
}

S = PRI.PlayerName$"\t"$ServerGetPlayerRoomName(PRI.PlayerID)$"\t"$S;
S = PRI.PlayerName$"\t"$Location$"\t"$S;
}
else
{
Expand Down Expand Up @@ -6047,28 +6081,6 @@ simulated event RenderOverlays( canvas Canvas )

///////////////////////////////////////////////////////////////////////////////

function string ServerGetPlayerRoomName(int PlayerID)
{
local Controller ControllerIter;
local PlayerController PCIter;

for(ControllerIter = Level.ControllerList; ControllerIter != None; ControllerIter = ControllerIter.NextController)
{
PCIter = PlayerController(ControllerIter);
if(PCIter == None)
{
// Not a player controller
continue;
}
else if(PCIter.PlayerReplicationInfo.PlayerID != PlayerID)
{
continue;
}
return string(PCIter.Pawn.GetRoomName());
}
return "None";
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

Expand Down
26 changes: 13 additions & 13 deletions Source/Unreal/Engine/Classes/BroadcastHandler.uc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//=============================================================================
// BroadcastHandler
//
// Message broadcasting is delegated to BroadCastHandler by the GameInfo.
// The BroadCastHandler handles both text messages (typed by a player) and
// localized messages (which are identified by a LocalMessage class and id).
// GameInfos produce localized messages using their DeathMessageClass and
// Message broadcasting is delegated to BroadCastHandler by the GameInfo.
// The BroadCastHandler handles both text messages (typed by a player) and
// localized messages (which are identified by a LocalMessage class and id).
// GameInfos produce localized messages using their DeathMessageClass and
// GameMessageClass classes.
//
// This is a built-in Unreal class and it shouldn't be modified.
Expand Down Expand Up @@ -40,9 +40,9 @@ function bool AllowsBroadcast( actor broadcaster, int Len )
}


function BroadcastText( PlayerReplicationInfo SenderPRI, PlayerController Receiver, coerce string Msg, optional name Type )
function BroadcastText( PlayerReplicationInfo SenderPRI, PlayerController Receiver, coerce string Msg, optional name Type, optional string Location )
{
Receiver.TeamMessage( SenderPRI, Msg, Type );
Receiver.TeamMessage( SenderPRI, Msg, Type, Location );
}

function BroadcastLocalized( Actor Sender, PlayerController Receiver, class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Core.Object OptionalObject )
Expand All @@ -51,7 +51,7 @@ function BroadcastLocalized( Actor Sender, PlayerController Receiver, class<Loca
}

#if IG_SWAT // dbeswick: broadcast send to Target only
function Broadcast( Actor Sender, coerce string Msg, optional name Type, optional PlayerController Target )
function Broadcast( Actor Sender, coerce string Msg, optional name Type, optional PlayerController Target, optional string Location )
#else
function Broadcast( Actor Sender, coerce string Msg, optional name Type )
#endif
Expand Down Expand Up @@ -79,7 +79,7 @@ function Broadcast( Actor Sender, coerce string Msg, optional name Type )
#else
if ( (P != None) && (P.PlayerReplicationInfo.bOnlySpectator || P.PlayerReplicationInfo.bOutOfLives) )
#endif
BroadcastText(PRI, P, Msg, Type);
BroadcastText(PRI, P, Msg, Type, Location);
}
}
else
Expand All @@ -92,12 +92,12 @@ function Broadcast( Actor Sender, coerce string Msg, optional name Type )
#else
if ( P != None )
#endif
BroadcastText(PRI, P, Msg, Type);
BroadcastText(PRI, P, Msg, Type, Location);
}
}
}

function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type )
function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type, optional string Location )
{
local Controller C;
local PlayerController P;
Expand All @@ -113,7 +113,7 @@ function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type
P = PlayerController(C);
if ( (P != None) && (P.PlayerReplicationInfo.Team == Sender.PlayerReplicationInfo.Team)
&& (P.PlayerReplicationInfo.bOnlySpectator || P.PlayerReplicationInfo.bOutOfLives) )
BroadcastText(Sender.PlayerReplicationInfo, P, Msg, Type);
BroadcastText(Sender.PlayerReplicationInfo, P, Msg, Type, Location);
}
}
else
Expand All @@ -122,7 +122,7 @@ function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type
{
P = PlayerController(C);
if ( (P != None) && (P.PlayerReplicationInfo.Team == Sender.PlayerReplicationInfo.Team) )
BroadcastText(Sender.PlayerReplicationInfo, P, Msg, Type);
BroadcastText(Sender.PlayerReplicationInfo, P, Msg, Type, Location);
}
}
}
Expand Down Expand Up @@ -192,4 +192,4 @@ function bool AcceptBroadcastVoice(PlayerController Receiver, PlayerReplicationI

defaultproperties
{
}
}
Loading

0 comments on commit 71f4cb2

Please sign in to comment.