Skip to content

Commit 71f4cb2

Browse files
committed
Fixed #244
1 parent 627f7d4 commit 71f4cb2

File tree

5 files changed

+141
-129
lines changed

5 files changed

+141
-129
lines changed

Source/Game/SwatGame/Classes/SwatGameInfo.uc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,21 +2034,21 @@ function NetTeam GetTeamFromID( int TeamID )
20342034

20352035
///////////////////////////////////////////////////////////////////////////////
20362036
//overridden from Engine.GameInfo
2037-
event Broadcast( Actor Sender, coerce string Msg, optional name Type, optional PlayerController Target )
2037+
event Broadcast( Actor Sender, coerce string Msg, optional name Type, optional PlayerController Target, optional string Location )
20382038
{
2039-
//log( self$"::Broadcast( "$Msg$" )" );
2040-
BroadcastHandler.Broadcast(Sender,Msg,Type,Target);
2039+
//log( self$"::Broadcast( "$Msg$" "$Location$" )" );
2040+
BroadcastHandler.Broadcast(Sender,Msg,Type,Target,Location);
20412041
}
20422042

20432043
//overridden from Engine.GameInfo
2044-
function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type )
2044+
function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type, optional string Location )
20452045
{
20462046
//log( self$"::BroadcastTeam( "$Sender$", "$Msg$" ), sender.statename = "$Sender.GetStateName() );
20472047
if( Sender.IsInState( 'ObserveTeam' ) ||
20482048
Sender.IsInState( 'Dead' ) )
20492049
BroadcastObservers( Sender, Msg, Type );
20502050

2051-
BroadcastHandler.BroadcastTeam(Sender,Msg,Type);
2051+
BroadcastHandler.BroadcastTeam(Sender,Msg,Type,Location);
20522052
}
20532053

20542054
function BroadcastObservers( Controller Sender, coerce string Msg, optional name Type )

Source/Game/SwatGame/Classes/SwatGamePlayerController.uc

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ replication
310310
ServerGiveCommand, ServerIssueCompliance, ServerOnEffectStopped, ServerSetVoiceType,
311311
ServerRetryStatsAuth, ServerSetMPLoadOutPrimaryAmmo, ServerSetMPLoadOutSecondaryAmmo,
312312
ServerViewportActivate, ServerViewportDeactivate,
313-
ServerHandleViewportFire, ServerHandleViewportReload,
314-
ServerGetPlayerRoomName;
313+
ServerHandleViewportFire, ServerHandleViewportReload;
315314
}
316315

317316
///////////////////////////////////////////////////////////////////////////////
@@ -3055,7 +3054,7 @@ state Dead
30553054
30563055
exec function TeamSay( string Msg )
30573056
{
3058-
//log( self$"::TeamSay( "$Msg$" )" );
3057+
log( self$"::TeamSay( "$Msg$" )" );
30593058
SwatGameInfo(Level.Game).BroadcastObservers( self, Msg, 'TeamSay');
30603059
}
30613060
}
@@ -3119,7 +3118,7 @@ state ObserveFromTeamOrLocation
31193118

31203119
exec function TeamSay( string Msg )
31213120
{
3122-
//log( self$"::TeamSay( "$Msg$" )" );
3121+
log( self$"::TeamSay( "$Msg$" )" );
31233122
SwatGameInfo(Level.Game).BroadcastObservers( self, Msg, 'TeamSay');
31243123
}
31253124
}
@@ -4302,20 +4301,55 @@ function ClientRoundStarted()
43024301

43034302
///////////////////////////////////////////////////////////////////////////////
43044303

4304+
exec function Say( string Msg )
4305+
{
4306+
// log(self$"::Say - "$Pawn.GetRoomName()$" - ("$Msg$")");
4307+
if (PlayerReplicationInfo.bAdmin && left(Msg,1) == "#" )
4308+
{
4309+
Level.Game.AdminSay(right(Msg,len(Msg)-1));
4310+
return;
4311+
}
4312+
4313+
// On a dedicated server, no one gets TeamMessage(), so we need to print
4314+
// it here. We don't do it for listen servers, because we'd get double log
4315+
// messages (since listen servers do get TeamMessage() ).
4316+
if ( Level.NetMode == NM_DedicatedServer )
4317+
{
4318+
mplog( "ChatMessage( "$Msg$", Say )" );
4319+
}
4320+
4321+
if(Pawn != None)
4322+
Level.Game.Broadcast(self, Msg, 'Say', None, string(Pawn.GetRoomName()));
4323+
else
4324+
Level.Game.Broadcast(self, Msg, 'Say');
4325+
}
4326+
4327+
exec function TeamSay( string Msg )
4328+
{
4329+
// log(self$"::TeamSay("$msg$")");
4330+
if( !GameReplicationInfo.bTeamGame )
4331+
{
4332+
Say( Msg );
4333+
return;
4334+
}
4335+
4336+
Level.Game.BroadcastTeam( self, Level.Game.ParseMessageString( Level.Game.BaseMutator , self, Msg ), 'TeamSay', string(Pawn.GetRoomName()));
4337+
}
4338+
43054339
event ClientMessage( coerce string S, optional Name Type )
43064340
{
43074341
//log("[dkaplan] >>> "$self$"::ClientMessage( "$S$", "$Type$" )" );
43084342
TeamMessage(PlayerReplicationInfo, S, Type);
43094343
ConsoleMessage(S);
43104344
}
43114345

4312-
event TeamMessage(PlayerReplicationInfo PRI, coerce string S, name Type)
4346+
event TeamMessage(PlayerReplicationInfo PRI, coerce string S, name Type, optional string Location)
43134347
{
4314-
//log("[dkaplan] >>> "$self$"::TeamMessage( "$PRI$", "$S$", "$Type$" )" );
4348+
//log("[dkaplan] >>> "$self$"::TeamMessage( "$PRI$", "$S$", "$Type$" "$Location$" )" );
43154349

4316-
if (((Type == 'Say') || (Type == 'TeamSay')) && (PRI != None))
4350+
if (Type == 'Say' || Type == 'TeamSay')
43174351
{
4318-
if(!(ServerGetPlayerRoomName(PRI.PlayerID) ~= "None"))
4352+
if(Location != "" && Location != "None")
43194353
{
43204354
// If we have a RoomName of None, we are spectating
43214355
if(Type == 'Say') {
@@ -4324,7 +4358,7 @@ event TeamMessage(PlayerReplicationInfo PRI, coerce string S, name Type)
43244358
Type = 'TeamSayLocalized';
43254359
}
43264360

4327-
S = PRI.PlayerName$"\t"$ServerGetPlayerRoomName(PRI.PlayerID)$"\t"$S;
4361+
S = PRI.PlayerName$"\t"$Location$"\t"$S;
43284362
}
43294363
else
43304364
{
@@ -6047,28 +6081,6 @@ simulated event RenderOverlays( canvas Canvas )
60476081

60486082
///////////////////////////////////////////////////////////////////////////////
60496083

6050-
function string ServerGetPlayerRoomName(int PlayerID)
6051-
{
6052-
local Controller ControllerIter;
6053-
local PlayerController PCIter;
6054-
6055-
for(ControllerIter = Level.ControllerList; ControllerIter != None; ControllerIter = ControllerIter.NextController)
6056-
{
6057-
PCIter = PlayerController(ControllerIter);
6058-
if(PCIter == None)
6059-
{
6060-
// Not a player controller
6061-
continue;
6062-
}
6063-
else if(PCIter.PlayerReplicationInfo.PlayerID != PlayerID)
6064-
{
6065-
continue;
6066-
}
6067-
return string(PCIter.Pawn.GetRoomName());
6068-
}
6069-
return "None";
6070-
}
6071-
60726084
///////////////////////////////////////////////////////////////////////////////
60736085
///////////////////////////////////////////////////////////////////////////////
60746086

Source/Unreal/Engine/Classes/BroadcastHandler.uc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//=============================================================================
22
// BroadcastHandler
33
//
4-
// Message broadcasting is delegated to BroadCastHandler by the GameInfo.
5-
// The BroadCastHandler handles both text messages (typed by a player) and
6-
// localized messages (which are identified by a LocalMessage class and id).
7-
// GameInfos produce localized messages using their DeathMessageClass and
4+
// Message broadcasting is delegated to BroadCastHandler by the GameInfo.
5+
// The BroadCastHandler handles both text messages (typed by a player) and
6+
// localized messages (which are identified by a LocalMessage class and id).
7+
// GameInfos produce localized messages using their DeathMessageClass and
88
// GameMessageClass classes.
99
//
1010
// This is a built-in Unreal class and it shouldn't be modified.
@@ -40,9 +40,9 @@ function bool AllowsBroadcast( actor broadcaster, int Len )
4040
}
4141

4242

43-
function BroadcastText( PlayerReplicationInfo SenderPRI, PlayerController Receiver, coerce string Msg, optional name Type )
43+
function BroadcastText( PlayerReplicationInfo SenderPRI, PlayerController Receiver, coerce string Msg, optional name Type, optional string Location )
4444
{
45-
Receiver.TeamMessage( SenderPRI, Msg, Type );
45+
Receiver.TeamMessage( SenderPRI, Msg, Type, Location );
4646
}
4747

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

5353
#if IG_SWAT // dbeswick: broadcast send to Target only
54-
function Broadcast( Actor Sender, coerce string Msg, optional name Type, optional PlayerController Target )
54+
function Broadcast( Actor Sender, coerce string Msg, optional name Type, optional PlayerController Target, optional string Location )
5555
#else
5656
function Broadcast( Actor Sender, coerce string Msg, optional name Type )
5757
#endif
@@ -79,7 +79,7 @@ function Broadcast( Actor Sender, coerce string Msg, optional name Type )
7979
#else
8080
if ( (P != None) && (P.PlayerReplicationInfo.bOnlySpectator || P.PlayerReplicationInfo.bOutOfLives) )
8181
#endif
82-
BroadcastText(PRI, P, Msg, Type);
82+
BroadcastText(PRI, P, Msg, Type, Location);
8383
}
8484
}
8585
else
@@ -92,12 +92,12 @@ function Broadcast( Actor Sender, coerce string Msg, optional name Type )
9292
#else
9393
if ( P != None )
9494
#endif
95-
BroadcastText(PRI, P, Msg, Type);
95+
BroadcastText(PRI, P, Msg, Type, Location);
9696
}
9797
}
9898
}
9999

100-
function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type )
100+
function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type, optional string Location )
101101
{
102102
local Controller C;
103103
local PlayerController P;
@@ -113,7 +113,7 @@ function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type
113113
P = PlayerController(C);
114114
if ( (P != None) && (P.PlayerReplicationInfo.Team == Sender.PlayerReplicationInfo.Team)
115115
&& (P.PlayerReplicationInfo.bOnlySpectator || P.PlayerReplicationInfo.bOutOfLives) )
116-
BroadcastText(Sender.PlayerReplicationInfo, P, Msg, Type);
116+
BroadcastText(Sender.PlayerReplicationInfo, P, Msg, Type, Location);
117117
}
118118
}
119119
else
@@ -122,7 +122,7 @@ function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type
122122
{
123123
P = PlayerController(C);
124124
if ( (P != None) && (P.PlayerReplicationInfo.Team == Sender.PlayerReplicationInfo.Team) )
125-
BroadcastText(Sender.PlayerReplicationInfo, P, Msg, Type);
125+
BroadcastText(Sender.PlayerReplicationInfo, P, Msg, Type, Location);
126126
}
127127
}
128128
}
@@ -192,4 +192,4 @@ function bool AcceptBroadcastVoice(PlayerController Receiver, PlayerReplicationI
192192

193193
defaultproperties
194194
{
195-
}
195+
}

0 commit comments

Comments
 (0)