update style
This commit is contained in:
@ -7,5 +7,5 @@ public function bool IsRankedGame()
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,142 +1,142 @@
|
||||
class Mut extends KFMutator;
|
||||
|
||||
const SML = class'SafeMutLoader';
|
||||
|
||||
const OptAC = "AccessControl";
|
||||
const OptMut = "Mutator";
|
||||
|
||||
var private E_LogLevel LogLevel;
|
||||
|
||||
public function PreBeginPlay()
|
||||
{
|
||||
Super.PreBeginPlay();
|
||||
|
||||
LogLevel = SML.static.GetLogLevel();
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
if (CorrectLoadOrder())
|
||||
{
|
||||
ModifyLoad();
|
||||
}
|
||||
else
|
||||
{
|
||||
`Log_Fatal(SML.static.GetName(Self) @ "must be loaded first.");
|
||||
}
|
||||
}
|
||||
|
||||
public function AddMutator(Mutator Mut)
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (CorrectLoadOrder() || Mut == Self) return;
|
||||
|
||||
if (Mut.Class == Class)
|
||||
{
|
||||
Mut.Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
Super.AddMutator(Mut);
|
||||
}
|
||||
}
|
||||
|
||||
private function bool CorrectLoadOrder()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
return (
|
||||
WorldInfo.Game.BaseMutator == None ||
|
||||
WorldInfo.Game.BaseMutator == Self);
|
||||
}
|
||||
|
||||
private function ModifyLoad()
|
||||
{
|
||||
local String LoadURL;
|
||||
local String LoadParams;
|
||||
local String MutatorsRaw;
|
||||
local String AccessControlRaw;
|
||||
local Array<String> Mutators;
|
||||
local int PrevServerActorsCount;
|
||||
local int Index;
|
||||
local GameEngine GameEngine;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
LoadURL = WorldInfo.GetLocalURL();
|
||||
LoadParams = Mid(LoadURL, InStr(LoadURL, "?"));
|
||||
MutatorsRaw = WorldInfo.Game.ParseOption(LoadParams, OptMut);
|
||||
AccessControlRaw = WorldInfo.Game.ParseOption(LoadParams, OptAC);
|
||||
|
||||
LoadURL = Repl(LoadURL, Subst(OptMut) $ MutatorsRaw, "");
|
||||
LoadURL = Repl(LoadURL, Subst(OptAC) $ AccessControlRaw, "");
|
||||
|
||||
SML.static.ClearMutators();
|
||||
SML.static.ClearServerActors();
|
||||
ParseStringIntoArray(MutatorsRaw, Mutators, ",", true);
|
||||
|
||||
Index = 0;
|
||||
while (Index < Mutators.Length)
|
||||
{
|
||||
if (SML.static.AddMutator(Mutators[Index]) ||
|
||||
Mutators[Index] ~= SML.static.GetName(Self))
|
||||
{
|
||||
Mutators.Remove(Index, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
++Index;
|
||||
}
|
||||
}
|
||||
|
||||
GameEngine = GameEngine(Class'Engine'.static.GetEngine());
|
||||
if (GameEngine == None)
|
||||
{
|
||||
`Log_Error("GameEngine is None, skip loading server actors");
|
||||
}
|
||||
else
|
||||
{
|
||||
PrevServerActorsCount = GameEngine.ServerActors.Length;
|
||||
|
||||
Index = 0;
|
||||
while (Index < GameEngine.ServerActors.Length)
|
||||
{
|
||||
if (SML.static.AddServerActor(GameEngine.ServerActors[Index]))
|
||||
{
|
||||
GameEngine.ServerActors.Remove(Index, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
++Index;
|
||||
}
|
||||
}
|
||||
|
||||
if (GameEngine.ServerActors.Length != PrevServerActorsCount)
|
||||
{
|
||||
GameEngine.SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
SML.static.StaticSaveConfig();
|
||||
|
||||
JoinArray(Mutators, MutatorsRaw);
|
||||
LoadURL $= (Subst(OptMut) $ MutatorsRaw);
|
||||
if (SML.static.WantsToSpawn())
|
||||
{
|
||||
LoadURL $= (Subst(OptAC) $ SML.static.GetName());
|
||||
}
|
||||
|
||||
`Log_Info("Loader modified, do server travel...");
|
||||
|
||||
WorldInfo.ServerTravel(LoadURL, true);
|
||||
}
|
||||
|
||||
private static function String Subst(String Option)
|
||||
{
|
||||
return ("?" $ Option $ "=");
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
class Mut extends KFMutator;
|
||||
|
||||
const SML = class'SafeMutLoader';
|
||||
|
||||
const OptAC = "AccessControl";
|
||||
const OptMut = "Mutator";
|
||||
|
||||
var private E_LogLevel LogLevel;
|
||||
|
||||
public function PreBeginPlay()
|
||||
{
|
||||
Super.PreBeginPlay();
|
||||
|
||||
LogLevel = SML.static.GetLogLevel();
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
if (CorrectLoadOrder())
|
||||
{
|
||||
ModifyLoad();
|
||||
}
|
||||
else
|
||||
{
|
||||
`Log_Fatal(SML.static.GetName(Self) @ "must be loaded first.");
|
||||
}
|
||||
}
|
||||
|
||||
public function AddMutator(Mutator Mut)
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (CorrectLoadOrder() || Mut == Self) return;
|
||||
|
||||
if (Mut.Class == Class)
|
||||
{
|
||||
Mut.Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
Super.AddMutator(Mut);
|
||||
}
|
||||
}
|
||||
|
||||
private function bool CorrectLoadOrder()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
return (
|
||||
WorldInfo.Game.BaseMutator == None ||
|
||||
WorldInfo.Game.BaseMutator == Self);
|
||||
}
|
||||
|
||||
private function ModifyLoad()
|
||||
{
|
||||
local String LoadURL;
|
||||
local String LoadParams;
|
||||
local String MutatorsRaw;
|
||||
local String AccessControlRaw;
|
||||
local Array<String> Mutators;
|
||||
local int PrevServerActorsCount;
|
||||
local int Index;
|
||||
local GameEngine GameEngine;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
LoadURL = WorldInfo.GetLocalURL();
|
||||
LoadParams = Mid(LoadURL, InStr(LoadURL, "?"));
|
||||
MutatorsRaw = WorldInfo.Game.ParseOption(LoadParams, OptMut);
|
||||
AccessControlRaw = WorldInfo.Game.ParseOption(LoadParams, OptAC);
|
||||
|
||||
LoadURL = Repl(LoadURL, Subst(OptMut) $ MutatorsRaw, "");
|
||||
LoadURL = Repl(LoadURL, Subst(OptAC) $ AccessControlRaw, "");
|
||||
|
||||
SML.static.ClearMutators();
|
||||
SML.static.ClearServerActors();
|
||||
ParseStringIntoArray(MutatorsRaw, Mutators, ",", true);
|
||||
|
||||
Index = 0;
|
||||
while (Index < Mutators.Length)
|
||||
{
|
||||
if (SML.static.AddMutator(Mutators[Index]) ||
|
||||
Mutators[Index] ~= SML.static.GetName(Self))
|
||||
{
|
||||
Mutators.Remove(Index, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
++Index;
|
||||
}
|
||||
}
|
||||
|
||||
GameEngine = GameEngine(Class'Engine'.static.GetEngine());
|
||||
if (GameEngine == None)
|
||||
{
|
||||
`Log_Error("GameEngine is None, skip loading server actors");
|
||||
}
|
||||
else
|
||||
{
|
||||
PrevServerActorsCount = GameEngine.ServerActors.Length;
|
||||
|
||||
Index = 0;
|
||||
while (Index < GameEngine.ServerActors.Length)
|
||||
{
|
||||
if (SML.static.AddServerActor(GameEngine.ServerActors[Index]))
|
||||
{
|
||||
GameEngine.ServerActors.Remove(Index, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
++Index;
|
||||
}
|
||||
}
|
||||
|
||||
if (GameEngine.ServerActors.Length != PrevServerActorsCount)
|
||||
{
|
||||
GameEngine.SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
SML.static.StaticSaveConfig();
|
||||
|
||||
JoinArray(Mutators, MutatorsRaw);
|
||||
LoadURL $= (Subst(OptMut) $ MutatorsRaw);
|
||||
if (SML.static.WantsToSpawn())
|
||||
{
|
||||
LoadURL $= (Subst(OptAC) $ SML.static.GetName());
|
||||
}
|
||||
|
||||
`Log_Info("Loader modified, do server travel...");
|
||||
|
||||
WorldInfo.ServerTravel(LoadURL, true);
|
||||
}
|
||||
|
||||
private static function String Subst(String Option)
|
||||
{
|
||||
return ("?" $ Option $ "=");
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
[Flags]
|
||||
AllowDownload=False
|
||||
ClientOptional=False
|
||||
ServerSideOnly=True
|
||||
[Flags]
|
||||
AllowDownload=False
|
||||
ClientOptional=False
|
||||
ServerSideOnly=True
|
||||
|
@ -1,331 +1,331 @@
|
||||
class SafeMutLoader extends KFAccessControl
|
||||
config(SML);
|
||||
|
||||
struct CMR
|
||||
{
|
||||
var String Mutator;
|
||||
var String Replacement;
|
||||
};
|
||||
|
||||
var private Array<Actor> ActiveMutators;
|
||||
var private Array<Actor> ActiveServerActors;
|
||||
var private Array<CMR> CustomMutReplacements;
|
||||
var private Array<String> SystemServerActors;
|
||||
var private config E_LogLevel LogLevel;
|
||||
var private config Array<String> Mutators;
|
||||
var private config Array<String> ServerActors;
|
||||
|
||||
public function PreBeginPlay()
|
||||
{
|
||||
LogLevel = GetLogLevel();
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
Super.PreBeginPlay();
|
||||
|
||||
LoadMutators();
|
||||
LoadServerActors();
|
||||
}
|
||||
|
||||
public function PostBeginPlay()
|
||||
{
|
||||
local KFGI_Access KFGIA;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
Super.PostBeginPlay();
|
||||
|
||||
RestoreServerActors();
|
||||
|
||||
KFGIA = GetKFGIA();
|
||||
if (KFGIA == None)
|
||||
{
|
||||
`Log_Error("Can't check ranked status");
|
||||
}
|
||||
else if (KFGIA.IsRankedGame())
|
||||
{
|
||||
`Log_Info("Mutators and server actors successfully loaded! Your server is RANKED!");
|
||||
}
|
||||
else
|
||||
{
|
||||
`Log_Warn("Your server is UNRANKED! Check the mutators and server actors you are using. Maybe some of them are incompatible with SML");
|
||||
}
|
||||
}
|
||||
|
||||
private function KFGI_Access GetKFGIA()
|
||||
{
|
||||
local KFGameInfo KFGI;
|
||||
|
||||
if (WorldInfo == None || WorldInfo.Game == None)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
KFGI = KFGameInfo(WorldInfo.Game);
|
||||
if (KFGI == None)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
return new(KFGI) class'KFGI_Access';
|
||||
}
|
||||
|
||||
private function LoadMutators()
|
||||
{
|
||||
local String MutString;
|
||||
local class<Mutator> MutClass;
|
||||
local class<Actor> ActClass;
|
||||
local Actor ServerActor;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
foreach Mutators(MutString)
|
||||
{
|
||||
MutClass = class<Mutator>(DynamicLoadObject(MutString, class'Class'));
|
||||
if (MutClass == None)
|
||||
{
|
||||
`Log_Error("Can't load mutator:" @ MutString);
|
||||
continue;
|
||||
}
|
||||
|
||||
ActClass = GetMutReplacement(MutClass);
|
||||
if (ActClass == None)
|
||||
{
|
||||
`Log_Warn("Incompatible:" @ MutString @ "(skip)");
|
||||
continue;
|
||||
}
|
||||
|
||||
ServerActor = WorldInfo.Spawn(ActClass);
|
||||
if (ServerActor == None)
|
||||
{
|
||||
`Log_Error("Can't spawn:" @ MutString);
|
||||
continue;
|
||||
}
|
||||
|
||||
ActiveMutators.AddItem(ServerActor);
|
||||
`Log_Info("Loaded:" @ MutString);
|
||||
}
|
||||
}
|
||||
|
||||
private function LoadServerActors()
|
||||
{
|
||||
local String ActorString;
|
||||
local class<Actor> ActorClass;
|
||||
local Actor ServerActor;
|
||||
|
||||
foreach ServerActors(ActorString)
|
||||
{
|
||||
ActorClass = class<Actor>(DynamicLoadObject(ActorString, class'Class'));
|
||||
if (ActorClass == None)
|
||||
{
|
||||
`Log_Error("Can't load server actor:" @ ActorString);
|
||||
continue;
|
||||
}
|
||||
|
||||
ServerActor = WorldInfo.Spawn(ActorClass);
|
||||
if (ServerActor == None)
|
||||
{
|
||||
`Log_Error("Can't spawn:" @ ActorString);
|
||||
continue;
|
||||
}
|
||||
|
||||
ActiveServerActors.AddItem(ServerActor);
|
||||
`Log_Info("Loaded:" @ ActorString);
|
||||
}
|
||||
}
|
||||
|
||||
private function RestoreServerActors()
|
||||
{
|
||||
local GameEngine GameEngine;
|
||||
local String ActorString;
|
||||
local int PrevServerActorsCount;
|
||||
|
||||
GameEngine = GameEngine(Class'Engine'.static.GetEngine());
|
||||
|
||||
if (GameEngine == None)
|
||||
{
|
||||
`Log_Error("GameEngine is None! Can't restore ServerActors!");
|
||||
return;
|
||||
}
|
||||
|
||||
PrevServerActorsCount = GameEngine.ServerActors.Length;
|
||||
foreach ServerActors(ActorString)
|
||||
{
|
||||
if (GameEngine.ServerActors.Find(ActorString) != INDEX_NONE)
|
||||
{
|
||||
GameEngine.ServerActors.AddItem(ActorString);
|
||||
}
|
||||
}
|
||||
|
||||
if (GameEngine.ServerActors.Length != PrevServerActorsCount)
|
||||
{
|
||||
GameEngine.SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public static function bool AddServerActor(String ServerActor)
|
||||
{
|
||||
local class<Actor> ActorClass;
|
||||
|
||||
if (default.SystemServerActors.Find(ServerActor) != INDEX_NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ActorClass = class<Actor>(DynamicLoadObject(ServerActor, class'Class'));
|
||||
|
||||
if (ActorClass == None)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ClassIsChildOf(ActorClass, class'Mutator'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (default.ServerActors.Find(ServerActor) == INDEX_NONE)
|
||||
{
|
||||
default.ServerActors.AddItem(ServerActor);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function bool AddMutator(String MutString)
|
||||
{
|
||||
if (GetMutStringReplacement(MutString) != None)
|
||||
{
|
||||
if (default.Mutators.Find(MutString) == INDEX_NONE)
|
||||
{
|
||||
default.Mutators.AddItem(MutString);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function ClearMutators()
|
||||
{
|
||||
default.Mutators.Length = 0;
|
||||
}
|
||||
|
||||
public static function ClearServerActors()
|
||||
{
|
||||
default.ServerActors.Length = 0;
|
||||
}
|
||||
|
||||
public static function bool WantsToSpawn()
|
||||
{
|
||||
return (default.Mutators.Length > 0);
|
||||
}
|
||||
|
||||
public static function String GetName(optional Object O)
|
||||
{
|
||||
if (O == None)
|
||||
{
|
||||
return (default.class.GetPackageName() $ "." $ String(default.class));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (O.class.GetPackageName() $ "." $ String(O.class));
|
||||
}
|
||||
}
|
||||
|
||||
public static function String GetMutName(class<Mutator> CMut)
|
||||
{
|
||||
if (CMut == None) return "";
|
||||
|
||||
return CMut.GetPackageName() $ "." $ String(CMut);
|
||||
}
|
||||
|
||||
public function PostLogin(PlayerController C)
|
||||
{
|
||||
local Actor A;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
if (C != None)
|
||||
{
|
||||
foreach ActiveMutators(A)
|
||||
{
|
||||
A.GetTargetLocation(C, false);
|
||||
}
|
||||
}
|
||||
|
||||
Super.PostLogin(C);
|
||||
}
|
||||
|
||||
public function OnClientConnectionClose(Player ClientConnection)
|
||||
{
|
||||
local Controller C;
|
||||
local Actor A;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
C = ClientConnection.Actor;
|
||||
if (C != None)
|
||||
{
|
||||
foreach ActiveMutators(A)
|
||||
{
|
||||
A.GetTargetLocation(C, true);
|
||||
}
|
||||
}
|
||||
|
||||
Super.OnClientConnectionClose(ClientConnection);
|
||||
}
|
||||
|
||||
public static function E_LogLevel GetLogLevel()
|
||||
{
|
||||
if (default.LogLevel == LL_WrongLevel)
|
||||
{
|
||||
default.LogLevel = LL_Info;
|
||||
StaticSaveConfig();
|
||||
}
|
||||
|
||||
return default.LogLevel;
|
||||
}
|
||||
|
||||
private static function class<Actor> GetMutReplacement(class<Mutator> MutClass)
|
||||
{
|
||||
local int Index;
|
||||
local String Replacement;
|
||||
|
||||
if (MutClass == None) return None;
|
||||
|
||||
Index = default.CustomMutReplacements.Find('Mutator', GetMutName(MutClass));
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
Replacement = default.CustomMutReplacements[Index].Replacement;
|
||||
}
|
||||
else if (MutClass.static.GetLocalString() == "")
|
||||
{
|
||||
return None;
|
||||
}
|
||||
else
|
||||
{
|
||||
Replacement = MutClass.GetPackageName() $ "." $ MutClass.static.GetLocalString();
|
||||
}
|
||||
|
||||
return class<Actor>(DynamicLoadObject(Replacement, class'Class'));
|
||||
}
|
||||
|
||||
private static function class<Actor> GetMutStringReplacement(String MutString)
|
||||
{
|
||||
return GetMutReplacement(class<Mutator>(DynamicLoadObject(MutString, class'Class')));
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
CustomMutReplacements.Add({(
|
||||
Mutator="UnofficialKFPatch.UKFPMutator",
|
||||
Replacement="UnofficialKFPatch.UKFPReplicationInfo"
|
||||
)})
|
||||
CustomMutReplacements.Add({(
|
||||
Mutator="UnofficialKFPatch.UKFPMutatorNW",
|
||||
Replacement="UnofficialKFPatch.UKFPReplicationInfo"
|
||||
)})
|
||||
|
||||
SystemServerActors.Add("IpDrv.WebServer")
|
||||
class SafeMutLoader extends KFAccessControl
|
||||
config(SML);
|
||||
|
||||
struct CMR
|
||||
{
|
||||
var String Mutator;
|
||||
var String Replacement;
|
||||
};
|
||||
|
||||
var private Array<Actor> ActiveMutators;
|
||||
var private Array<Actor> ActiveServerActors;
|
||||
var private Array<CMR> CustomMutReplacements;
|
||||
var private Array<String> SystemServerActors;
|
||||
var private config E_LogLevel LogLevel;
|
||||
var private config Array<String> Mutators;
|
||||
var private config Array<String> ServerActors;
|
||||
|
||||
public function PreBeginPlay()
|
||||
{
|
||||
LogLevel = GetLogLevel();
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
Super.PreBeginPlay();
|
||||
|
||||
LoadMutators();
|
||||
LoadServerActors();
|
||||
}
|
||||
|
||||
public function PostBeginPlay()
|
||||
{
|
||||
local KFGI_Access KFGIA;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
Super.PostBeginPlay();
|
||||
|
||||
RestoreServerActors();
|
||||
|
||||
KFGIA = GetKFGIA();
|
||||
if (KFGIA == None)
|
||||
{
|
||||
`Log_Error("Can't check ranked status");
|
||||
}
|
||||
else if (KFGIA.IsRankedGame())
|
||||
{
|
||||
`Log_Info("Mutators and server actors successfully loaded! Your server is RANKED!");
|
||||
}
|
||||
else
|
||||
{
|
||||
`Log_Warn("Your server is UNRANKED! Check the mutators and server actors you are using. Maybe some of them are incompatible with SML");
|
||||
}
|
||||
}
|
||||
|
||||
private function KFGI_Access GetKFGIA()
|
||||
{
|
||||
local KFGameInfo KFGI;
|
||||
|
||||
if (WorldInfo == None || WorldInfo.Game == None)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
KFGI = KFGameInfo(WorldInfo.Game);
|
||||
if (KFGI == None)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
return new(KFGI) class'KFGI_Access';
|
||||
}
|
||||
|
||||
private function LoadMutators()
|
||||
{
|
||||
local String MutString;
|
||||
local class<Mutator> MutClass;
|
||||
local class<Actor> ActClass;
|
||||
local Actor ServerActor;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
foreach Mutators(MutString)
|
||||
{
|
||||
MutClass = class<Mutator>(DynamicLoadObject(MutString, class'Class'));
|
||||
if (MutClass == None)
|
||||
{
|
||||
`Log_Error("Can't load mutator:" @ MutString);
|
||||
continue;
|
||||
}
|
||||
|
||||
ActClass = GetMutReplacement(MutClass);
|
||||
if (ActClass == None)
|
||||
{
|
||||
`Log_Warn("Incompatible:" @ MutString @ "(skip)");
|
||||
continue;
|
||||
}
|
||||
|
||||
ServerActor = WorldInfo.Spawn(ActClass);
|
||||
if (ServerActor == None)
|
||||
{
|
||||
`Log_Error("Can't spawn:" @ MutString);
|
||||
continue;
|
||||
}
|
||||
|
||||
ActiveMutators.AddItem(ServerActor);
|
||||
`Log_Info("Loaded:" @ MutString);
|
||||
}
|
||||
}
|
||||
|
||||
private function LoadServerActors()
|
||||
{
|
||||
local String ActorString;
|
||||
local class<Actor> ActorClass;
|
||||
local Actor ServerActor;
|
||||
|
||||
foreach ServerActors(ActorString)
|
||||
{
|
||||
ActorClass = class<Actor>(DynamicLoadObject(ActorString, class'Class'));
|
||||
if (ActorClass == None)
|
||||
{
|
||||
`Log_Error("Can't load server actor:" @ ActorString);
|
||||
continue;
|
||||
}
|
||||
|
||||
ServerActor = WorldInfo.Spawn(ActorClass);
|
||||
if (ServerActor == None)
|
||||
{
|
||||
`Log_Error("Can't spawn:" @ ActorString);
|
||||
continue;
|
||||
}
|
||||
|
||||
ActiveServerActors.AddItem(ServerActor);
|
||||
`Log_Info("Loaded:" @ ActorString);
|
||||
}
|
||||
}
|
||||
|
||||
private function RestoreServerActors()
|
||||
{
|
||||
local GameEngine GameEngine;
|
||||
local String ActorString;
|
||||
local int PrevServerActorsCount;
|
||||
|
||||
GameEngine = GameEngine(Class'Engine'.static.GetEngine());
|
||||
|
||||
if (GameEngine == None)
|
||||
{
|
||||
`Log_Error("GameEngine is None! Can't restore ServerActors!");
|
||||
return;
|
||||
}
|
||||
|
||||
PrevServerActorsCount = GameEngine.ServerActors.Length;
|
||||
foreach ServerActors(ActorString)
|
||||
{
|
||||
if (GameEngine.ServerActors.Find(ActorString) != INDEX_NONE)
|
||||
{
|
||||
GameEngine.ServerActors.AddItem(ActorString);
|
||||
}
|
||||
}
|
||||
|
||||
if (GameEngine.ServerActors.Length != PrevServerActorsCount)
|
||||
{
|
||||
GameEngine.SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public static function bool AddServerActor(String ServerActor)
|
||||
{
|
||||
local class<Actor> ActorClass;
|
||||
|
||||
if (default.SystemServerActors.Find(ServerActor) != INDEX_NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ActorClass = class<Actor>(DynamicLoadObject(ServerActor, class'Class'));
|
||||
|
||||
if (ActorClass == None)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ClassIsChildOf(ActorClass, class'Mutator'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (default.ServerActors.Find(ServerActor) == INDEX_NONE)
|
||||
{
|
||||
default.ServerActors.AddItem(ServerActor);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function bool AddMutator(String MutString)
|
||||
{
|
||||
if (GetMutStringReplacement(MutString) != None)
|
||||
{
|
||||
if (default.Mutators.Find(MutString) == INDEX_NONE)
|
||||
{
|
||||
default.Mutators.AddItem(MutString);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function ClearMutators()
|
||||
{
|
||||
default.Mutators.Length = 0;
|
||||
}
|
||||
|
||||
public static function ClearServerActors()
|
||||
{
|
||||
default.ServerActors.Length = 0;
|
||||
}
|
||||
|
||||
public static function bool WantsToSpawn()
|
||||
{
|
||||
return (default.Mutators.Length > 0);
|
||||
}
|
||||
|
||||
public static function String GetName(optional Object O)
|
||||
{
|
||||
if (O == None)
|
||||
{
|
||||
return (default.class.GetPackageName() $ "." $ String(default.class));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (O.class.GetPackageName() $ "." $ String(O.class));
|
||||
}
|
||||
}
|
||||
|
||||
public static function String GetMutName(class<Mutator> CMut)
|
||||
{
|
||||
if (CMut == None) return "";
|
||||
|
||||
return CMut.GetPackageName() $ "." $ String(CMut);
|
||||
}
|
||||
|
||||
public function PostLogin(PlayerController C)
|
||||
{
|
||||
local Actor A;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
if (C != None)
|
||||
{
|
||||
foreach ActiveMutators(A)
|
||||
{
|
||||
A.GetTargetLocation(C, false);
|
||||
}
|
||||
}
|
||||
|
||||
Super.PostLogin(C);
|
||||
}
|
||||
|
||||
public function OnClientConnectionClose(Player ClientConnection)
|
||||
{
|
||||
local Controller C;
|
||||
local Actor A;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
C = ClientConnection.Actor;
|
||||
if (C != None)
|
||||
{
|
||||
foreach ActiveMutators(A)
|
||||
{
|
||||
A.GetTargetLocation(C, true);
|
||||
}
|
||||
}
|
||||
|
||||
Super.OnClientConnectionClose(ClientConnection);
|
||||
}
|
||||
|
||||
public static function E_LogLevel GetLogLevel()
|
||||
{
|
||||
if (default.LogLevel == LL_WrongLevel)
|
||||
{
|
||||
default.LogLevel = LL_Info;
|
||||
StaticSaveConfig();
|
||||
}
|
||||
|
||||
return default.LogLevel;
|
||||
}
|
||||
|
||||
private static function class<Actor> GetMutReplacement(class<Mutator> MutClass)
|
||||
{
|
||||
local int Index;
|
||||
local String Replacement;
|
||||
|
||||
if (MutClass == None) return None;
|
||||
|
||||
Index = default.CustomMutReplacements.Find('Mutator', GetMutName(MutClass));
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
Replacement = default.CustomMutReplacements[Index].Replacement;
|
||||
}
|
||||
else if (MutClass.static.GetLocalString() == "")
|
||||
{
|
||||
return None;
|
||||
}
|
||||
else
|
||||
{
|
||||
Replacement = MutClass.GetPackageName() $ "." $ MutClass.static.GetLocalString();
|
||||
}
|
||||
|
||||
return class<Actor>(DynamicLoadObject(Replacement, class'Class'));
|
||||
}
|
||||
|
||||
private static function class<Actor> GetMutStringReplacement(String MutString)
|
||||
{
|
||||
return GetMutReplacement(class<Mutator>(DynamicLoadObject(MutString, class'Class')));
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
CustomMutReplacements.Add({(
|
||||
Mutator="UnofficialKFPatch.UKFPMutator",
|
||||
Replacement="UnofficialKFPatch.UKFPReplicationInfo"
|
||||
)})
|
||||
CustomMutReplacements.Add({(
|
||||
Mutator="UnofficialKFPatch.UKFPMutatorNW",
|
||||
Replacement="UnofficialKFPatch.UKFPReplicationInfo"
|
||||
)})
|
||||
|
||||
SystemServerActors.Add("IpDrv.WebServer")
|
||||
}
|
@ -1,20 +1,20 @@
|
||||
class _Logger extends Object
|
||||
abstract;
|
||||
|
||||
enum E_LogLevel
|
||||
{
|
||||
LL_WrongLevel,
|
||||
LL_None,
|
||||
LL_Fatal,
|
||||
LL_Error,
|
||||
LL_Warning,
|
||||
LL_Info,
|
||||
LL_Debug,
|
||||
LL_Trace,
|
||||
LL_All
|
||||
};
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
}
|
||||
class _Logger extends Object
|
||||
abstract;
|
||||
|
||||
enum E_LogLevel
|
||||
{
|
||||
LL_WrongLevel,
|
||||
LL_None,
|
||||
LL_Fatal,
|
||||
LL_Error,
|
||||
LL_Warning,
|
||||
LL_Info,
|
||||
LL_Debug,
|
||||
LL_Trace,
|
||||
LL_All
|
||||
};
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
// Constants
|
||||
`define NO_CONFIG 0
|
||||
// Constants
|
||||
`define NO_CONFIG 0
|
||||
|
@ -1,3 +1,3 @@
|
||||
// Imports
|
||||
`include(Logger.uci)
|
||||
`include(Constants.uci)
|
||||
// Imports
|
||||
`include(Logger.uci)
|
||||
`include(Constants.uci)
|
||||
|
@ -1,15 +1,15 @@
|
||||
// Logger
|
||||
`define Log_Tag 'SML'
|
||||
|
||||
`define LocationStatic "`{ClassName}::" $ GetFuncName()
|
||||
|
||||
`define Log_Base(msg, cond) `log(`msg `if(`cond), `cond`{endif}, `Log_Tag)
|
||||
|
||||
`define Log_Fatal(msg) `log("FATAL:" @ `msg, (LogLevel >= LL_Fatal), `Log_Tag)
|
||||
`define Log_Error(msg) `log("ERROR:" @ `msg, (LogLevel >= LL_Error), `Log_Tag)
|
||||
`define Log_Warn(msg) `log("WARN:" @ `msg, (LogLevel >= LL_Warning), `Log_Tag)
|
||||
`define Log_Info(msg) `log("INFO:" @ `msg, (LogLevel >= LL_Info), `Log_Tag)
|
||||
`define Log_Debug(msg) `log("DEBUG:" @ `msg, (LogLevel >= LL_Debug), `Log_Tag)
|
||||
|
||||
`define Log_Trace(msg) `log("TRACE:" @ `Location `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag)
|
||||
`define Log_TraceStatic(msg) `log("TRACE:" @ `LocationStatic `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag)
|
||||
// Logger
|
||||
`define Log_Tag 'SML'
|
||||
|
||||
`define LocationStatic "`{ClassName}::" $ GetFuncName()
|
||||
|
||||
`define Log_Base(msg, cond) `log(`msg `if(`cond), `cond`{endif}, `Log_Tag)
|
||||
|
||||
`define Log_Fatal(msg) `log("FATAL:" @ `msg, (LogLevel >= LL_Fatal), `Log_Tag)
|
||||
`define Log_Error(msg) `log("ERROR:" @ `msg, (LogLevel >= LL_Error), `Log_Tag)
|
||||
`define Log_Warn(msg) `log("WARN:" @ `msg, (LogLevel >= LL_Warning), `Log_Tag)
|
||||
`define Log_Info(msg) `log("INFO:" @ `msg, (LogLevel >= LL_Info), `Log_Tag)
|
||||
`define Log_Debug(msg) `log("DEBUG:" @ `msg, (LogLevel >= LL_Debug), `Log_Tag)
|
||||
|
||||
`define Log_Trace(msg) `log("TRACE:" @ `Location `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag)
|
||||
`define Log_TraceStatic(msg) `log("TRACE:" @ `LocationStatic `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag)
|
||||
|
Reference in New Issue
Block a user