Skip to content

Commit 923f9e0

Browse files
committed
Fixed Force Less Lethal not working correctly on dedicated servers.
1 parent abfacbd commit 923f9e0

6 files changed

Lines changed: 52 additions & 29 deletions

File tree

Source/Game/SwatGame/Classes/LoadOut/LoadOut.uc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ simulated protected function SpawnEquipmentForPocket( Pocket i, class<actor> Equ
292292

293293
PocketEquipment[i] = Owner.Spawn(EquipmentClass, Owner);
294294

295+
mplog(" ...SpawnEquipmentForPocket("$i$", "$EquipmentClass$") --> "$PocketEquipment[i]);
296+
295297
assertWithDescription(PocketEquipment[i] != None,
296298
"LoadOut "$name$" failed to spawn PocketEquipment item in pocket "$GetEnum(Pocket,i)$" of class "$EquipmentClass$".");
297299

Source/Game/SwatGame/Classes/Net/NetPlayer.uc

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ function InitializeReplicatedCounts()
107107
for ( i = 0; i < Pocket.EnumCount; ++i )
108108
{
109109
//assert(i != Pocket.Pocket_CustomSkin || ReplicatedLoadOutSpec[i] == None);
110+
mplog("---NetPlayer::InitializeReplicatedCounts("$i$") = "$ReplicatedLoadoutSpec[i]);
110111
if ( ReplicatedLoadOutSpec[i] != None )
111112
++LoadOutSpecCount;
112113
}
@@ -244,6 +245,25 @@ simulated event PostReplication()
244245
mplog( self$" has name: "$GetHumanReadableName() );
245246
}
246247

248+
event PostNetReceive()
249+
{
250+
local OfficerLoadout NewLoadout;
251+
252+
if(ReplicatedLoadoutSpec[0] != DynamicLoadoutSpec.LoadOutSpec[0])
253+
{
254+
// Our loadout got forced to something else by the server. Adjust. Adapt. Overcome.
255+
NewLoadOut = Spawn(class'OfficerLoadOut', self, 'EmptyMultiplayerOfficerLoadOut' );
256+
257+
CopyReplicatedSpecToDynamicSpec();
258+
259+
NewLoadout.Initialize(DynamicLoadoutSpec, false);
260+
ReceiveLoadout(NewLoadout);
261+
262+
CheckDesiredItemAndEquipIfNeeded();
263+
264+
SwatGamePlayerController(Controller).EquipNextSlot();
265+
}
266+
}
247267

248268
///////////////////////////////////////////////////////////////////////////////
249269
//
@@ -799,11 +819,6 @@ simulated function OnDoorUnlocked( SwatDoor TheDoor )
799819
simulated function DynamicLoadOutSpec GetLoadoutSpec()
800820
{
801821
//mplog( self$"---NetPlayer::GetLoadoutSpec()." );
802-
if(SwatGamePlayerController(Controller) != None && SwatGamePlayerController(Controller).SwatRepoPlayerItem.bForcedLessLethal)
803-
{
804-
return SwatGameInfo(Level.Game).Admin.GetLessLethalSpec();
805-
}
806-
807822
if( DynamicLoadOutSpec == None )
808823
{
809824
if ( IsTheVIP() )
@@ -1009,6 +1024,8 @@ defaultproperties
10091024
10101025
TeamNumber=-1
10111026
1027+
bNetNotify=true
1028+
10121029
bLoadOutInitialized=false
10131030
LoadOutSpecCount=0
10141031
SkinsCount=0

Source/Game/SwatGame/Classes/SwatAdmin.uc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ public function bool ForceLessLethalOnPlayer(SwatGamePlayerController PC)
739739
local int i;
740740
local NetPlayer Player;
741741
local OfficerLoadout NewLoadout;
742+
local DynamicLoadoutSpec OldSpec;
742743

743744
RepoItem = PC.SwatRepoPlayerItem;
744745

@@ -758,25 +759,28 @@ public function bool ForceLessLethalOnPlayer(SwatGamePlayerController PC)
758759
return false;
759760
}
760761

762+
NewLoadout = Spawn(class'OfficerLoadout', Player, 'EmptyMultiplayerOfficerLoadOut');
763+
761764
for(i = 0; i < Pocket.EnumCount; i++)
762765
{
763-
if(Player != None)
764-
{
765-
Player.SetPocketItemClass(Pocket(i), NewSpec.LoadOutSpec[i]);
766-
}
767-
768-
RepoItem.SetPocketItemClass(Pocket(i), NewSpec.LoadOutSpec[i]);
766+
RepoItem.RepoLoadOutSpec[i] = NewSpec.LoadOutSpec[i];
769767
}
770768

771769
PC.SetMPLoadOut(NewSpec);
770+
772771
if(Player != None)
773772
{
774-
NewLoadout = Spawn(class'OfficerLoadout', Player, 'EmptyMultiplayerOfficerLoadOut');
773+
OldSpec = Player.GetLoadoutSpec();
774+
for(i = 0; i < Pocket.EnumCount; i++)
775+
{
776+
Player.SetPocketItemClass(Pocket(i), RepoItem.RepoLoadOutSpec[i]);
777+
OldSpec.LoadOutSpec[i] = RepoItem.RepoLoadOutSpec[i];
778+
}
779+
775780
NewLoadout.Initialize(NewSpec, false);
776781
Player.ReceiveLoadOut(NewLoadout);
777782
Player.InitializeReplicatedCounts();
778783
SwatGameInfo(Level.Game).SetPlayerDefaults(Player);
779-
PC.EquipNextSlot();
780784
}
781785

782786
RepoItem.bForcedLessLethal = true;

Source/Game/SwatGame/Classes/SwatGameInfo.uc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,11 +1135,22 @@ function AddDefaultInventory(Pawn inPlayerPawn)
11351135
else
11361136
theNetPlayer.SetCustomSkinClassName( "SwatGame.DefaultCustomSkin" );
11371137
1138-
LoadOutSpec = theNetPlayer.GetLoadoutSpec();
1138+
if(RepoPlayerItem.bForcedLessLethal)
1139+
{
1140+
LoadOutSpec = Admin.GetLessLethalSpec();
1141+
for(i = 0; i < Pocket.EnumCount; i++)
1142+
{
1143+
theNetPlayer.ReplicatedLoadOutSpec[i] = LoadOutSpec.LoadOutSpec[i];
1144+
}
1145+
}
1146+
else
1147+
{
1148+
LoadOutSpec = theNetPlayer.GetLoadoutSpec();
11391149
1140-
// Alter it *ex post facto* to have the correct ammo counts
1141-
LoadOutSpec.SetPrimaryAmmoCount(RepoPlayerItem.GetPrimaryAmmoCount());
1142-
LoadOutSpec.SetSecondaryAmmoCount(RepoPlayerItem.GetSecondaryAmmoCount());
1150+
// Alter it *ex post facto* to have the correct ammo counts
1151+
LoadOutSpec.SetPrimaryAmmoCount(RepoPlayerItem.GetPrimaryAmmoCount());
1152+
LoadOutSpec.SetSecondaryAmmoCount(RepoPlayerItem.GetSecondaryAmmoCount());
1153+
}
11431154
}
11441155
11451156
IsSuspect = theNetPlayer.GetTeamNumber() == 1;

Source/Game/SwatGame/Classes/SwatGamePlayerController.uc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ replication
308308
ServerRequestThrowPrep, ServerEndThrow, ServerRequestQualifyInterrupt, /*ServerRequestInteract,*/
309309
ServerRequestViewportChange, ServerSetAlwaysRun, ServerActivateOfficerViewport,
310310
ServerGiveCommand, ServerIssueCompliance, ServerOnEffectStopped, ServerSetVoiceType,
311-
ServerRetryStatsAuth, ServerSetMPLoadOutPrimaryAmmo, ServerSetMPLoadOutSecondaryAmmo,
311+
ServerRetryStatsAuth, ServerSetMPLoadOutPrimaryAmmo, ServerSetMPLoadOutSecondaryAmmo,
312312
ServerViewportActivate, ServerViewportDeactivate,
313313
ServerHandleViewportFire, ServerHandleViewportReload;
314314
}
@@ -6103,7 +6103,6 @@ function ClientSetObjectiveVisibility( string ObjectiveName, bool Visible )
61036103
Repo.SetObjectiveVisibility( name(ObjectiveName), Visible );
61046104
}
61056105

6106-
61076106
simulated function ClientReportableReportedToTOC( IAmReportableCharacter ReportableCharacter, string inUniqueID, string PlayerTag, string PlayerName )
61086107
{
61096108
local SwatPlayer Player;

Source/Game/SwatGame/Classes/SwatRepoPlayerItem.uc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ function SetSecondaryAmmoCount(int amount) {
6666
function SetPocketItemClass( Pocket Pocket, class<actor> ItemClass )
6767
{
6868
//log( self$" in SwatRepoPlayerItem::SetPocketItemClass(). Pocket="$Pocket$", Item="$ItemClass );
69-
if(bForcedLessLethal)
70-
{
71-
return;
72-
}
73-
7469
RepoLoadOutSpec[ Pocket ] = ItemClass;
7570
}
7671

@@ -86,11 +81,6 @@ function SetPocketItemClassName( Pocket Pocket, string ItemClassName )
8681
ItemClass = class<HandheldEquipment>(DynamicLoadObject(ItemClassName, class'Class'));
8782
}
8883

89-
if(bForcedLessLethal)
90-
{
91-
return;
92-
}
93-
9484
SetPocketItemClass( Pocket, ItemClass );
9585
}
9686

0 commit comments

Comments
 (0)