9 Commits

Author SHA1 Message Date
561545de2b a little cleaning 2023-10-20 23:48:04 +03:00
6dfbcbb0b7 force GRI init 2023-10-20 23:30:45 +03:00
18fc55ce42 force skin update 2023-10-20 23:18:04 +03:00
6cc67da26b Merge branch 'replace-dlc-weapons-fix' 2023-10-20 22:56:15 +03:00
dc2108e482 Merge pull request #10 from GenZmeY/Halloween2023Update
Halloween 2023 Update
2023-10-20 22:54:26 +03:00
37944a25c4 remove DLC clones along with their originals from [CTI.RemoveItems] 2023-10-20 22:53:11 +03:00
ce070b66cd Merge branch 'master' into Halloween2023Update 2023-10-05 21:40:07 +03:00
7e0151bf09 Merge branch 'linter' into Halloween2023Update 2023-10-05 20:21:21 +03:00
f4cfa4948b unlock MG3 2023-09-26 01:52:14 +03:00
7 changed files with 117 additions and 51 deletions

View File

@ -187,18 +187,7 @@ private function PostInit()
return; return;
} }
if (Unlocker.static.UnlockDLC(KFGI, KFGRI, UnlockDLC, RemoveItems, AddItems, DLCSkinUpdateRequired, LogLevel)) WeapDefs = Trader.static.GenerateWeapDefList(
{
`Log_Info("DLC unlocked");
}
`Log_Debug("DLCSkinUpdateRequired:" @ String(DLCSkinUpdateRequired.Value));
if (bPreloadContent)
{
Preload(AddItems);
}
Trader.static.ModifyTrader(
KFGRI, KFGRI,
RemoveItems, RemoveItems,
AddItems, AddItems,
@ -208,7 +197,23 @@ private function PostInit()
bDisableItemLimitCheck, bDisableItemLimitCheck,
LogLevel); LogLevel);
WeapDefs = Trader.static.GetTraderWeapDefs(KFGRI, LogLevel); RemoveItems.Length = 0;
AddItems.Length = 0;
if (Unlocker.static.UnlockDLC(KFGI, KFGRI, UnlockDLC, WeapDefs, DLCSkinUpdateRequired, LogLevel))
{
`Log_Info("DLC unlocked");
}
`Log_Debug("DLCSkinUpdateRequired:" @ String(DLCSkinUpdateRequired.Value));
Trader.static.OverwriteTraderItems(KFGRI, WeapDefs, LogLevel);
`Log_Info("Trader items:" @ WeapDefs.Length);
if (bPreloadContent)
{
Preload(WeapDefs);
}
ReadyToSync = true; ReadyToSync = true;

View File

@ -21,6 +21,7 @@ var public bool PendingSync;
var private CTI CTI; var private CTI CTI;
var private E_LogLevel LogLevel; var private E_LogLevel LogLevel;
var private GameReplicationInfo GRI;
var private KFPlayerController KFPC; var private KFPlayerController KFPC;
var private KFPlayerReplicationInfo KFPRI; var private KFPlayerReplicationInfo KFPRI;
var private KFGFxWidget_PartyInGame PartyInGameWidget; var private KFGFxWidget_PartyInGame PartyInGameWidget;
@ -32,6 +33,7 @@ var private String NotificationRightText;
var private int NotificationPercent; var private int NotificationPercent;
var private int WaitingGRI; var private int WaitingGRI;
var private int WaitingGRIThreshold;
var private int WaitingGRILimit; var private int WaitingGRILimit;
var private ReplicationStruct RepData; var private ReplicationStruct RepData;
@ -138,7 +140,7 @@ private simulated function Finished()
`Log_Trace(); `Log_Trace();
if (WorldInfo.GRI == None && WaitingGRI++ < WaitingGRILimit) if (GetGRI(WaitingGRI > WaitingGRIThreshold) == None && WaitingGRI++ < WaitingGRILimit)
{ {
`Log_Debug("Finished: Waiting GRI" @ WaitingGRI); `Log_Debug("Finished: Waiting GRI" @ WaitingGRI);
NotifyWaitingGRI(); NotifyWaitingGRI();
@ -146,7 +148,7 @@ private simulated function Finished()
return; return;
} }
KFGRI = KFGameReplicationInfo(WorldInfo.GRI); KFGRI = KFGameReplicationInfo(GRI);
if (KFGRI != None) if (KFGRI != None)
{ {
`Log_Debug("Finished: Trader.static.OverwriteTraderItems"); `Log_Debug("Finished: Trader.static.OverwriteTraderItems");
@ -155,7 +157,7 @@ private simulated function Finished()
} }
else else
{ {
`Log_Error("Incompatible Replication info:" @ String(WorldInfo.GRI)); `Log_Error("Incompatible Replication info:" @ String(GRI));
NotifyIncompatibleGRI(); NotifyIncompatibleGRI();
} }
@ -180,7 +182,13 @@ private simulated function UpdateSkinsDLC()
{ {
foreach Replacements.default.DLC(WeapReplace) foreach Replacements.default.DLC(WeapReplace)
{ {
if (WeapReplace.WeapParent.default.SkinItemId > 0 && WeapReplace.Weap.default.SkinItemId != WeapReplace.WeapParent.default.SkinItemId) // sometimes "WeapReplace.Weap.default.SkinItemId" can give values greater than zero while actually being zero
// this is the same bug that prevents creating the correct default config
// so for now lets shorten the check a little so that the skinId of the WeapReplace is guaranteed to be correct
// but if this bug is ever fixed, then its worth replacing the check with this one:
// if (WeapReplace.WeapParent.default.SkinItemId > 0 && WeapReplace.Weap.default.SkinItemId != WeapReplace.WeapParent.default.SkinItemId)
// to reduce the number of meaningless disk writes
if (WeapReplace.WeapParent.default.SkinItemId > 0)
{ {
`Log_Debug("Update skin for:" @ String(WeapReplace.WeapDef) @ "SkinId:" @ WeapReplace.WeapParent.default.SkinItemId); `Log_Debug("Update skin for:" @ String(WeapReplace.WeapDef) @ "SkinId:" @ WeapReplace.WeapParent.default.SkinItemId);
class'KFWeaponSkinList'.static.SaveWeaponSkin(WeapReplace.WeapDef, WeapReplace.WeapParent.default.SkinItemId); class'KFWeaponSkinList'.static.SaveWeaponSkin(WeapReplace.WeapDef, WeapReplace.WeapParent.default.SkinItemId);
@ -192,6 +200,29 @@ private simulated function UpdateSkinsDLC()
} }
} }
private simulated function GameReplicationInfo GetGRI(optional bool ForcedSearch = false)
{
`Log_Trace();
if (GRI == None)
{
GRI = WorldInfo.GRI;
}
if (GRI == None && ForcedSearch)
{
foreach WorldInfo.DynamicActors(class'GameReplicationInfo', GRI) break;
}
if (WorldInfo.GRI == None && GRI != None)
{
`Log_Warn("Force initialization of WorldInfo.GRI" @ String(GRI));
WorldInfo.GRI = GRI;
}
return GRI;
}
private simulated function KFPlayerController GetKFPC() private simulated function KFPlayerController GetKFPC()
{ {
`Log_Trace(); `Log_Trace();
@ -332,6 +363,7 @@ private simulated function KeepNotification()
private simulated function ClientCleanup() private simulated function ClientCleanup()
{ {
`Log_Debug("Cleanup");
ServerCleanup(); ServerCleanup();
SafeDestroy(); SafeDestroy();
} }
@ -340,7 +372,7 @@ private reliable server function ServerCleanup()
{ {
`Log_Trace(); `Log_Trace();
`Log_Debug("Cleanup"); `Log_Debug("Cleanup" @ GetKFPC() @ GetKFPRI() == None? "" : GetKFPRI().PlayerName);
if (!CTI.DestroyRepInfo(GetKFPC())) if (!CTI.DestroyRepInfo(GetKFPC()))
{ {
`Log_Debug("Cleanup (forced)"); `Log_Debug("Cleanup (forced)");
@ -381,7 +413,7 @@ private simulated function NotifyIncompatibleGRI()
WriteToChatLocalized( WriteToChatLocalized(
CTI_IncompatibleGRI, CTI_IncompatibleGRI,
class'KFLocalMessage'.default.InteractionColor, class'KFLocalMessage'.default.InteractionColor,
String(WorldInfo.GRI.class)); String(GRI.class));
WriteToChatLocalized( WriteToChatLocalized(
CTI_IncompatibleGRIWarning, CTI_IncompatibleGRIWarning,
class'KFLocalMessage'.default.InteractionColor); class'KFLocalMessage'.default.InteractionColor);
@ -397,5 +429,6 @@ defaultproperties
NotificationPercent = 0 NotificationPercent = 0
WaitingGRI = 0 WaitingGRI = 0
WaitingGRIThreshold = 15
WaitingGRILimit = 30 WaitingGRILimit = 30
} }

View File

@ -0,0 +1,13 @@
class CTI_WeapDef_MG3 extends KFWeapDef_MG3
abstract;
static function String GetItemLocalization(String KeyName)
{
return class'KFGame.KFWeapDef_MG3'.static.GetItemLocalization(KeyName);
}
defaultproperties
{
SharedUnlockId = SCU_None
WeaponClassPath = "CTI.CTI_Weap_LMG_MG3"
}

View File

@ -0,0 +1,6 @@
class CTI_Weap_LMG_MG3 extends KFWeap_LMG_MG3;
defaultproperties
{
}

View File

@ -91,11 +91,11 @@ public static function Array<class<KFWeaponDefinition> > GetTraderWeapDefsDLC(KF
return WeapDefs; return WeapDefs;
} }
public static simulated function ModifyTrader( public static simulated function Array< class<KFWeaponDefinition> > GenerateWeapDefList(
KFGameReplicationInfo KFGRI, KFGameReplicationInfo KFGRI,
const out Array<class<KFWeaponDefinition> > RemoveItems, const out Array<class<KFWeaponDefinition> > RemoveItems,
const out Array<class<KFWeaponDefinition> > AddItems, const out Array<class<KFWeaponDefinition> > AddItems,
bool ReplaceMode, bool RemoveAll,
bool RemoveHRG, bool RemoveHRG,
bool RemoveDLC, bool RemoveDLC,
bool bDisableItemLimitCheck, bool bDisableItemLimitCheck,
@ -110,7 +110,7 @@ public static simulated function ModifyTrader(
TraderItems = GetTraderItems(KFGRI, LogLevel); TraderItems = GetTraderItems(KFGRI, LogLevel);
if (!ReplaceMode) if (!RemoveAll)
{ {
foreach TraderItems.SaleItems(Item) foreach TraderItems.SaleItems(Item)
{ {
@ -126,9 +126,12 @@ public static simulated function ModifyTrader(
} }
for (Index = 0; Index < AddItems.Length; ++Index) for (Index = 0; Index < AddItems.Length; ++Index)
{
if (WeaponClassIsUnique(AddItems[Index].default.WeaponClassPath, WeapDefs, LogLevel))
{ {
WeapDefs.AddItem(AddItems[Index]); WeapDefs.AddItem(AddItems[Index]);
} }
}
WeapDefs.Sort(ByPrice); WeapDefs.Sort(ByPrice);
@ -143,7 +146,7 @@ public static simulated function ModifyTrader(
WeapDefs.Length = ITEMS_LIMIT; WeapDefs.Length = ITEMS_LIMIT;
} }
OverwriteTraderItems(KFGRI, WeapDefs, LogLevel); return WeapDefs;
} }
public static simulated function OverwriteTraderItems( public static simulated function OverwriteTraderItems(

View File

@ -31,8 +31,7 @@ public static function bool UnlockDLC(
KFGameInfo KFGI, KFGameInfo KFGI,
KFGameReplicationInfo KFGRI, KFGameReplicationInfo KFGRI,
String UnlockType, String UnlockType,
out Array<class<KFWeaponDefinition> > RemoveItems, out Array<class<KFWeaponDefinition> > WeapDefs,
out Array<class<KFWeaponDefinition> > AddItems,
out BoolWrapper DLCSkinUpdateRequired, out BoolWrapper DLCSkinUpdateRequired,
E_LogLevel LogLevel) E_LogLevel LogLevel)
{ {
@ -42,11 +41,10 @@ public static function bool UnlockDLC(
{ {
case "true": case "true":
case "auto": case "auto":
return Auto(KFGI, KFGRI, RemoveItems, AddItems, DLCSkinUpdateRequired, LogLevel); return Auto(KFGI, KFGRI, WeapDefs, DLCSkinUpdateRequired, LogLevel);
case "replaceweapons": case "replaceweapons":
DLCSkinUpdateRequired.Value = true; return ReplaceWeapons(KFGRI, WeapDefs, DLCSkinUpdateRequired, LogLevel);
return ReplaceWeapons(KFGRI, RemoveItems, AddItems, LogLevel);
case "replacefilter": case "replacefilter":
DLCSkinUpdateRequired.Value = false; DLCSkinUpdateRequired.Value = false;
@ -61,8 +59,7 @@ public static function bool UnlockDLC(
private static function bool Auto( private static function bool Auto(
KFGameInfo KFGI, KFGameInfo KFGI,
KFGameReplicationInfo KFGRI, KFGameReplicationInfo KFGRI,
out Array<class<KFWeaponDefinition> > RemoveItems, out Array<class<KFWeaponDefinition> > WeapDefs,
out Array<class<KFWeaponDefinition> > AddItems,
out BoolWrapper DLCSkinUpdateRequired, out BoolWrapper DLCSkinUpdateRequired,
E_LogLevel LogLevel) E_LogLevel LogLevel)
{ {
@ -83,8 +80,7 @@ private static function bool Auto(
if (CustomGFxManager) if (CustomGFxManager)
{ {
DLCSkinUpdateRequired.Value = true; return ReplaceWeapons(KFGRI, WeapDefs, DLCSkinUpdateRequired, LogLevel);
return ReplaceWeapons(KFGRI, RemoveItems, AddItems, LogLevel);
} }
else else
{ {
@ -95,14 +91,14 @@ private static function bool Auto(
private static function bool ReplaceWeapons( private static function bool ReplaceWeapons(
KFGameReplicationInfo KFGRI, KFGameReplicationInfo KFGRI,
out Array<class<KFWeaponDefinition> > RemoveItems, out Array<class<KFWeaponDefinition> > WeapDefs,
out Array<class<KFWeaponDefinition> > AddItems, out BoolWrapper DLCSkinUpdateRequired,
E_LogLevel LogLevel) E_LogLevel LogLevel)
{ {
local Array<class<KFWeaponDefinition> > WeapDefsDLCs; local class<KFWeaponDefinition> WeapDef;
local class<KFWeaponDefinition> WeapDefDLC;
local class<KFWeaponDefinition> WeapDefReplacement; local class<KFWeaponDefinition> WeapDefReplacement;
local bool Unlock, PartialUnlock; local bool Unlock, PartialUnlock;
local int Index;
`Log_TraceStatic(); `Log_TraceStatic();
@ -110,30 +106,34 @@ private static function bool ReplaceWeapons(
Unlock = false; Unlock = false;
PartialUnlock = false; PartialUnlock = false;
DLCSkinUpdateRequired.Value = false;
WeapDefsDLCs = Trader.static.GetTraderWeapDefsDLC(KFGRI, LogLevel); for (Index = 0; Index < WeapDefs.Length; Index++)
foreach WeapDefsDLCs(WeapDefDLC)
{ {
WeapDefReplacement = PickReplacementWeapDefDLC(WeapDefDLC, LogLevel); WeapDef = WeapDefs[Index];
if (WeapDef.default.SharedUnlockId == SCU_None) continue;
WeapDefReplacement = PickReplacementWeapDefDLC(WeapDef, LogLevel);
if (WeapDefReplacement != None) if (WeapDefReplacement != None)
{ {
Unlock = true; Unlock = true;
if (AddItems.Find(WeapDefReplacement) == INDEX_NONE) DLCSkinUpdateRequired.Value = true;
if (WeapDefs.Find(WeapDefReplacement) == INDEX_NONE)
{ {
AddItems.AddItem(WeapDefReplacement); WeapDefs[Index] = WeapDefReplacement;
`Log_Debug(WeapDef @ "replaced by" @ WeapDefReplacement);
}
else
{
WeapDefs.Remove(Index--, 1);
`Log_Debug("Skip already unlocked weapon:" @ WeapDef);
} }
`Log_Debug(WeapDefDLC @ "replaced by" @ WeapDefReplacement);
} }
else else
{ {
PartialUnlock = true; PartialUnlock = true;
`Log_Warn("Can't unlock item:" @ WeapDefDLC @ "SharedUnlockId:" @ WeapDefDLC.default.SharedUnlockId); `Log_Warn("Can't unlock item:" @ WeapDef @ "SharedUnlockId:" @ WeapDef.default.SharedUnlockId);
}
if (RemoveItems.Find(WeapDefDLC) == INDEX_NONE)
{
RemoveItems.AddItem(WeapDefDLC);
} }
} }

View File

@ -102,6 +102,12 @@ defaultproperties
Weap=class'CTI_Weap_Edged_IonThruster', Weap=class'CTI_Weap_Edged_IonThruster',
WeapParent=class'KFWeap_Edged_IonThruster' WeapParent=class'KFWeap_Edged_IonThruster'
)}) )})
DLC.Add({(
WeapDef=class'CTI_WeapDef_MG3',
WeapDefParent=class'KFWeapDef_MG3',
Weap=class'CTI_Weap_LMG_MG3',
WeapParent=class'KFWeap_LMG_MG3'
)})
DLC.Add({( DLC.Add({(
WeapDef=class'CTI_WeapDef_Mine_Reconstructor', WeapDef=class'CTI_WeapDef_Mine_Reconstructor',
WeapDefParent=class'KFWeapDef_Mine_Reconstructor', WeapDefParent=class'KFWeapDef_Mine_Reconstructor',