Skip to content

Commit

Permalink
Move lag query fix to delayed init
Browse files Browse the repository at this point in the history
  • Loading branch information
peterekepeter committed Aug 7, 2024
1 parent b2afd44 commit e7c3820
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
20 changes: 2 additions & 18 deletions MVES/Classes/MapVote.uc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var MV_Result CurrentMap;
var Music SongOverride;

//XC_GameEngine and Unreal 227 interface
native(1718) final function bool AddToPackageMap( optional string PkgName);
//native(1718) final function bool AddToPackageMap( optional string PkgName);

state Voting
{
Expand Down Expand Up @@ -210,7 +210,7 @@ Begin:
event PostBeginPlay()
{
local class<MV_MainExtension> ExtensionC;
local string Cmd, NextParm, aStr, Settings;
local string Cmd, NextParm, Settings;
local Actor A;
local class<Actor> ActorClass;
local int MapIdx;
Expand All @@ -219,7 +219,6 @@ event PostBeginPlay()
local string CurrentPackages;
local bool bGotoSuccess;
local bool bNeedToRestorePackages, bNeedToRestoreMap;
local MV_IdleTimer MV_IdleTimer;

Log("[MVE] Map Vote Extended version: "$ClientPackageInternal);

Expand Down Expand Up @@ -472,10 +471,6 @@ event PostBeginPlay()
PlayerDetector = Spawn(class'MV_PlayerDetector');
PlayerDetector.Initialize(Self);

if ( bFixMutatorsQueryLagSpikes )
{
ApplyFixForMutatorsQueryLagSpikes();
}

// finally done!
Log("[MVE] Finished loading map: `"$TravelMap$"` idx: "$TravelInfo.TravelIdx$" mode: "$CurrentMode);
Expand Down Expand Up @@ -1729,17 +1724,6 @@ final function LoadAliases()
}
}

function ApplyFixForMutatorsQueryLagSpikes()
{
// fixes common issue of server query DDOS-ing the game engine
// https://ut99.org/viewtopic.php?p=142091
Level.Game.GetRules();
if ( Level.Game.EnabledMutators == "" )
{
Level.Game.EnabledMutators = "MapVote "$ClientPackageInternal;
}
}

//***************************************
//*************** TRIGGERS *************
//***************************************
Expand Down
16 changes: 16 additions & 0 deletions MVES/Classes/MapVoteDelayedInit.uc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ event InitializeDelayedInit(MapVote mutator)

event Timer()
{
ApplyFixForMutatorsQueryLagSpikes();
EnsureMutatorRegistered();
EnsureScoreboardUpdated();
Destroy();
Expand All @@ -36,6 +37,21 @@ function EnsureScoreboardUpdated()
Level.Game.InitGameReplicationInfo();
}

function ApplyFixForMutatorsQueryLagSpikes()
{
if ( !MapVote.bFixMutatorsQueryLagSpikes )
{
return; // fix is disabled
}
// fixes common issue of server query DDOS-ing the game engine
// https://ut99.org/viewtopic.php?p=142091
Level.Game.GetRules();
if ( Level.Game.EnabledMutators == "" )
{
Level.Game.EnabledMutators = "MapVote "$MapVote.ClientPackageInternal;
}
}

static function Err(coerce string message)
{
class'MV_Util'.static.Err(message);
Expand Down

0 comments on commit e7c3820

Please sign in to comment.