Skip to content

Commit

Permalink
Logout and damage sources adjustments
Browse files Browse the repository at this point in the history
- Projectiles belonging to players either become owned by the Core, or
get destroyed, this solves an exploit where shooting a friendly building
and disconnecting can cause damage to said buildings.
- Optimized the ragequit sound loop.
- Buildings can no longer damage themselves.
  • Loading branch information
CacoFFF committed Dec 29, 2015
1 parent 709e2e3 commit 09ff528
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
53 changes: 37 additions & 16 deletions Classes/SiegeGI.uc
Original file line number Diff line number Diff line change
Expand Up @@ -1932,8 +1932,9 @@ simulated Event Timer()
function Logout( pawn Exiting )
{
local bool bMessage;
local Actor A ;

local Actor A;
local PlayerPawn P;

bMessage = true;
if ( Exiting.IsA('PlayerPawn') )
{
Expand All @@ -1947,27 +1948,47 @@ function Logout( pawn Exiting )
NumPlayers--;
}
if( bMessage && (Level.NetMode==NM_DedicatedServer || Level.NetMode==NM_ListenServer) )
{
BroadcastMessage( Exiting.PlayerReplicationInfo.PlayerName$LeftMessage, false );
foreach AllActors( class'Actor',A)
{
if ( PlayerPawn(A) != None )
{
if ( PlayerPawn(A) != Exiting )
PlayerPawn(A).PlaySound(Sound'RageQuit',,10);
}
}
}



{
BroadcastMessage( Exiting.PlayerReplicationInfo.PlayerName$LeftMessage, false );
ForEach AllActors( class'PlayerPawn', P)
if ( P != Exiting )
P.PlaySound(Sound'RageQuit',,10);
}

if ( Exiting.PlayerReplicationInfo != none )
CleanupProjectiles( Exiting);

if ( LocalLog != None )
LocalLog.LogPlayerDisconnect(Exiting);
if ( WorldLog != None )
WorldLog.LogPlayerDisconnect(Exiting);
}

//Prevent disconnect + damage exploits
function CleanupProjectiles( Pawn Other)
{
local Projectile Proj;
local byte OutTeam;
local bool bDestructProj;

OutTeam = Other.PlayerReplicationInfo.Team;
if ( OutTeam < 5 )
{
bDestructProj = Cores[OutTeam] == none || Cores[OutTeam].bDeleteMe;
ForEach AllActors (class'Projectile', Proj)
if ( Proj.Instigator == Other )
{
if ( bDestructProj )
Proj.Destroy();
else
{
Proj.Instigator = Cores[OutTeam];
Proj.SetOwner( Cores[OutTeam]);
}
}
}
}

//General event system, a building has been created and initialized
function BuildingCreated( sgBuilding sgNew)
{
Expand Down
5 changes: 2 additions & 3 deletions Classes/sgBaseCore.uc
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ simulated event TakeDamage(int Damage, Pawn instigatedBy, Vector hitLocation,
local float tempScore;
local TournamentPlayer p;

if ( Role < ROLE_Authority || Level.Game == None || bCoreDisabled)
if ( Role < ROLE_Authority || Level.Game == None || bCoreDisabled || instigatedBy == self )
return;

actualDamage = Level.Game.ReduceDamage(Damage, DamageType, Self,
instigatedBy);
actualDamage = Level.Game.ReduceDamage(Damage, DamageType, Self, instigatedBy);

if ( instigatedBy != None && instigatedBy.bIsPlayer )
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/sgBuilding.uc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ event TakeDamage( int damage, Pawn instigatedBy, Vector hitLocation, Vector mome
local int actualDamage;
local float tempScore, tmpRU;

if ( Role < ROLE_Authority || Level.Game == None || !bBuildInitialized )
if ( Role < ROLE_Authority || Level.Game == None || !bBuildInitialized || instigatedBy == self )
return;

actualDamage = Level.Game.ReduceDamage(Damage, DamageType, Self, instigatedBy);
Expand Down

0 comments on commit 09ff528

Please sign in to comment.