Skip to content

Commit

Permalink
Format MVES sources
Browse files Browse the repository at this point in the history
  • Loading branch information
peterekepeter committed Nov 21, 2023
1 parent c3b4802 commit d94f526
Show file tree
Hide file tree
Showing 21 changed files with 684 additions and 6,211 deletions.
124 changes: 54 additions & 70 deletions MVES/Classes/MVPlayerWatcher.uc
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ state Initializing
if ( !bHooked )
{
nextWatcher = Mutator.WatcherList;
Mutator.WatcherList = self;
bHooked = true;
Mutator.WatcherList = Self;
bHooked = True;
}
bHTTPLoading = false;
bHTTPLoading = False;
}
event Tick( float DeltaTime)
{
if ( MapVoteWRIActor != none && MapVoteWRIActor.bDeleteMe )
MapVoteWRIActor = none;
if ( Watched == none || Watched.bDeleteMe )
if ( MapVoteWRIActor != None && MapVoteWRIActor.bDeleteMe )
MapVoteWRIActor = None;
if ( Watched == None || Watched.bDeleteMe )
GotoState('Inactive');
bOverflow = false;
bOverflow = False;
}
Begin:
Begin:
if ( Mutator.PlayerIDType == PID_Default ) //15 ticks to retrieve ip
{
While( TicksLeft-- > 0 )
while( TicksLeft -- > 0 )
Sleep(0.0);
if ( Watched == none || Watched.bDeleteMe )
if ( Watched == None || Watched.bDeleteMe )
Stop;
PlayerCode = class'MV_MainExtension'.static.ByDelimiter( Watched.GetPlayerNetworkAddress(), ":"); //Remove port
if ( (PlayerCode != "") && Mutator.IpBanned(PlayerCode) )
Expand All @@ -66,17 +66,17 @@ Begin:
}
else if ( Mutator.PlayerIDType == PID_NexGen ) //6 seconds to retrieve NexGen ID
{
While ( TicksLeft-- > 0 )
while ( TicksLeft -- > 0 )
{
if ( Watched == none || Watched.bDeleteMe )
if ( Watched == None || Watched.bDeleteMe )
Stop;
if ( NexGenClient == none )
if ( NexGenClient == None )
{
NexGenClient = Mutator.Extension.FindNexgenClient( Watched);
if ( NexGenClient != none ) //Found! let's give more time
if ( NexGenClient != None ) //Found! let's give more time
TicksLeft += 6;
}
if ( (NexGenClient != none) && (NexGenClient.GetPropertyText("bInitialized") == GetPropertyText("bHooked")) && (NexGenClient.GetPropertyText("loginComplete") == GetPropertyText("bHooked")) )
if ( (NexGenClient != None) && (NexGenClient.GetPropertyText("bInitialized") == GetPropertyText("bHooked")) && (NexGenClient.GetPropertyText("loginComplete") == GetPropertyText("bHooked")) )
{
PlayerCode = NexGenClient.GetPropertyText("playerID");
if ( (PlayerCode == "") || Mutator.IpBanned(PlayerCode) )
Expand All @@ -86,11 +86,11 @@ Begin:
Stop;
}
TicksLeft = 0;
Goto('PostID');
goto('PostID');
}
Sleep(0.80 * Level.TimeDilation);
}
if ( NexGenClient == none )
if ( NexGenClient == None )
Watched.ClientMessage("MVE: NexgenClient detection timeout");
else if (NexGenClient.GetPropertyText("bInitialized") != GetPropertyText("bHooked"))
Watched.ClientMessage("MVE: Unable to find initialization var on NexgenClient");
Expand All @@ -99,22 +99,22 @@ Begin:
Watched.Destroy();
Stop;
}
PostID:
PostID:
PlayerIP = class'MV_MainExtension'.static.ByDelimiter( Watched.GetPlayerNetworkAddress(), ":"); //Remove port
bInitialized = true;
bInitialized = True;
if ( Mutator.bWelcomeWindow && Mutator.ServerInfoURL != "")
{
Mutator.Extension.WelcomeWindowTo( Watched);
}
PlayerID = class'MV_MainExtension'.static.NumberToByte( Watched.PlayerReplicationInfo.PlayerID);
PlayerID = class'MV_MainExtension'.static.PreFill( PlayerID, "0", 3);
Mutator.Extension.AddPlayerToWindows( self);
GetCache:
Mutator.Extension.AddPlayerToWindows( Self);
GetCache:
Sleep( 1.0 + FRand() * 1.0 );
if ( !GetCacheActor() )
Stop;
TicksLeft = 15;
if ( ViewPort(Watched.Player) != none ) //Local player, proceed to hack the MLC
if ( ViewPort(Watched.Player) != None ) //Local player, proceed to hack the MLC
{
// MapListCacheActor.SetPropertyText("bNeedServerMapList","1");
MapListCacheActor.SetPropertyText("bClientLoadEnd","1");
Expand All @@ -124,7 +124,7 @@ GetCache:
MapListCacheActor.SetPropertyText("LoadRuleCount", string(Mutator.MapList.GameCount) );
MapListCacheActor.SetPropertyText("LoadPercentage", "100" );
}
While ( TicksLeft-- > 0 )
while ( TicksLeft -- > 0 )
{
if ( NeedsFullCache() )
{
Expand Down Expand Up @@ -157,19 +157,19 @@ GetCache:
Sleep(0.5); // Total: 8-10 seconds
}
if ( bHTTPLoading ) // Started but not ended
Goto('FullCache');
goto('FullCache');
}

state Inactive
{
event BeginState()
{
RemoveFromActive();
Watched = none;
Watched = None;
nextWatcher = Mutator.InactiveList;
Mutator.InactiveList = self;
bInitialized = false;
bOverflow = false;
Mutator.InactiveList = Self;
bInitialized = False;
bOverflow = False;
if ( PlayerVote != "" )
{
PlayerVote = "";
Expand All @@ -181,16 +181,16 @@ state Inactive
PlayerCode = "";
KickVoteID = -1;
KickVoteCode = "";
NexGenClient = none;
if ( MapListCacheActor != none )
NexGenClient = None;
if ( MapListCacheActor != None )
{
MapListCacheActor.Destroy();
MapListCacheActor = none;
MapListCacheActor = None;
}
if ( MapVoteWRIActor != none )
if ( MapVoteWRIActor != None )
{
MapVoteWRIActor.Destroy();
MapVoteWRIActor = none;
MapVoteWRIActor = None;
}
}
event EndState() //NEVER, EVER PULL THIS THING OUT OF THIS STATE IF IT ISN'T MUTATOR.INACTIVELIST
Expand All @@ -203,49 +203,49 @@ function RemoveFromActive()
{
local MVPlayerWatcher PW;

if ( Mutator.WatcherList == self )
if ( Mutator.WatcherList == Self )
Mutator.WatcherList = nextWatcher;
else
{
For ( PW=Mutator.WatcherList ; PW!=none ; PW=PW.nextWatcher )
if ( PW.nextWatcher == self )
for ( PW = Mutator.WatcherList ; PW != None ; PW = PW.nextWatcher )
if ( PW.nextWatcher == Self )
{
PW.nextWatcher = nextWatcher;
break;
}
}
nextWatcher = none;
bHooked = false;
nextWatcher = None;
bHooked = False;
}

function bool GetCacheActor()
{
local MapListCache transfer;
if ( (Watched == none) || Watched.bDeleteMe || (Mutator.ServerCodeName == '') )
if ( (Watched == None) || Watched.bDeleteMe || (Mutator.ServerCodeName == '') )
{
Log("[MVE] ERROR: GetCacheActor called with incorrect parameters");
return false;
return False;
}
if ( MapListCacheActor != none )
if ( MapListCacheActor != None )
{
MapListCacheActor.SetOwner( Watched);
if ( Mutator.bEnableHTTPMapList )
MapListCacheActor.SetPropertyText( "HTTPMapListLocation", Mutator.HTTPMapListLocation $ "/MapList" $ chr(47) $ string(Mutator.ServerCodeName) ); //Reset just in case
return true;
MapListCacheActor.SetPropertyText( "HTTPMapListLocation", Mutator.HTTPMapListLocation$"/MapList"$chr(47)$string(Mutator.ServerCodeName) ); //Reset just in case
return True;
}
transfer = Spawn(class'MapListCache', Watched);
transfer.ServerCallbacks = self;
transfer.ServerCallbacks = Self;
MapListCacheActor = transfer;
if ( MapListCacheActor == none )
if ( MapListCacheActor == None )
{
Log("[MVE] !!! FATAL ERROR !!!");
Log("[MVE] failed to spawn "$Mutator.ClientPackageInternal$".MapListCache");
Log("[MVE] make sure you have the correct client package in MVE_Config");
return false;
return False;
}
if ( Mutator.bEnableHTTPMapList )
{
MapListCacheActor.SetPropertyText( "HTTPMapListLocation", Mutator.HTTPMapListLocation $ "/MapList" $ chr(47) $ string(Mutator.ServerCodeName));
MapListCacheActor.SetPropertyText( "HTTPMapListLocation", Mutator.HTTPMapListLocation$"/MapList"$chr(47)$string(Mutator.ServerCodeName));
}
else
{
Expand All @@ -257,14 +257,14 @@ function bool GetCacheActor()
MapListCacheActor.SetPropertyText("ClientLogoTexture", Mutator.ClientLogoTexture );
MapListCacheActor.SetPropertyText("ServerInfoURL", Mutator.ServerInfoURL );
MapListCacheActor.SetPropertyText("MapInfoURL", Mutator.MapInfoURL );
return true;
return True;
}

function bool NeedsFullCache()
{
local string test;
if ( MapListCacheActor == none )
return false;
if ( MapListCacheActor == None )
return False;
test = GetPropertyText("bInitialized"); //Always true here
return (MapListCacheActor.GetPropertyText("HTTPMapListLocation") == "None"
&& MapListCacheActor.GetPropertyText("bNeedServerMapList") == test );
Expand Down Expand Up @@ -303,28 +303,12 @@ function FullCacheLoaded()

function bool IsModerator()
{
if ( (NexGenClient != none) && (InStr(NexGenClient.GetPropertyText("rights"),"G") >= 0) )
return true;
if ( (NexGenClient != None) && (InStr(NexGenClient.GetPropertyText("rights"),"G") >= 0) )
return True;
}

defaultproperties
{
Mutator=None
Watched=None
PlayerIP=""
PlayerCode=""
PlayerID=""
PlayerVote=""
KickVoteID=-1
KickVoteCode=""
nextWatcher=None
TicksLeft=0
bInitialized=False
bHooked=False
bHTTPLoading=False
bOverflow=False
MapListCacheActor=None
MapVoteWRIActor=None
NexGenClient=None
RemoteRole=ROLE_None
KickVoteID=-1
RemoteRole=ROLE_None
}
22 changes: 11 additions & 11 deletions MVES/Classes/MV_IdleTimer.uc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Initialize(MapVote MapVote, bool isIdle, int EmptyMinutes)
Self.MapVote = MapVote;
Self.EmptyMinutes = EmptyMinutes;
Self.bIsIdle = isIdle;
if (isIdle)
if ( isIdle )
{
time = GetRelativeTime(EmptyMinutes);
Log("[MVE] Currently idle, has been empty for at least "$time);
Expand All @@ -27,19 +27,19 @@ function Timer()

// TODO: idea improve watch and handle player count changes
// so each class is notified of change rather than each class tracking
for (P = Level.PawnList; P != None; P = P.NextPawn)
for ( P = Level.PawnList; P != None; P = P.NextPawn )
{
if (P.bIsPlayer && PlayerPawn(P) != None)
if ( P.bIsPlayer && PlayerPawn(P) != None )
{
count += 1;
}
}

if (count > 0)
if ( count > 0 )
{
EmptyMinutes = 0;

if (bIsIdle)
if ( bIsIdle )
{
// state transition -> not idle
Log("[MVE] Server not in idle mode any longer");
Expand All @@ -53,13 +53,13 @@ function Timer()
LogIdleMessage(EmptyMinutes);
}

if (!bIsIdle && MapVote.ServerIdleAfterMinutes != 0 && EmptyMinutes >= MapVote.ServerIdleAfterMinutes)
if ( !bIsIdle && MapVote.ServerIdleAfterMinutes != 0 && EmptyMinutes >= MapVote.ServerIdleAfterMinutes )
{
// state transition -> idle
Log("[MVE] Server is switching to idle mode");
bIsIdle = True;
SaveIdleState();
if (MapVote.bSwitchToDefaultMapOnIdle)
if ( MapVote.bSwitchToDefaultMapOnIdle )
{
MapVote.SwitchToDefaultMap();
}
Expand All @@ -74,7 +74,7 @@ function LogIdleMessage(int m)
{
local string time;
time = GetIdleMessage(m);
if (time == "")
if ( time == "" )
{
// noop
}
Expand All @@ -98,7 +98,7 @@ static function string GetIdleMessage(int m)
modulo = 0;
message = "";

if (m <= 15)
if ( m <= 15 )
{
modulo = 5; // log every 5 minutes
}
Expand All @@ -122,7 +122,7 @@ static function string GetIdleMessage(int m)
}

// execute
if (modulo > 0 && m % modulo == 0)
if ( modulo > 0 && m % modulo == 0 )
{
message = GetRelativeTime(m);
}
Expand All @@ -132,7 +132,7 @@ static function string GetIdleMessage(int m)

static function string GetRelativeTime(int m)
{
if (m <= 60)
if ( m <= 60 )
{
return m$" minutes";
}
Expand Down
Loading

0 comments on commit d94f526

Please sign in to comment.