Skip to content

Commit

Permalink
X2CommunityCore#275 Use self for instance methods, CDO for static met…
Browse files Browse the repository at this point in the history
…hods
  • Loading branch information
Musashi1584 committed Aug 17, 2017
1 parent 8704811 commit 5aad08c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
10 changes: 5 additions & 5 deletions X2CommunityHighlander.XCOM_sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# XCOM ModBuddy Solution File, Format Version 11.00
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{5DAE07AF-E217-45C1-8DE7-FF99D6011E8A}") = "X2CommunityHighlander", "X2CommunityHighlander\X2CommunityHighlander.x2proj", "{7AD29FBC-D864-4EAF-B8E6-2D3E5CECE537}"
Project("{5DAE07AF-E217-45C1-8DE7-FF99D6011E8A}") = "X2CommunityHighlander", "X2CommunityHighlander\X2CommunityHighlander.x2proj", "{B6499644-295D-4FEF-A98C-894D4C57D9C0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|XCOM 2 = Debug|XCOM 2
Default|XCOM 2 = Default|XCOM 2
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7AD29FBC-D864-4EAF-B8E6-2D3E5CECE537}.Debug|XCOM 2.ActiveCfg = Debug|XCOM 2
{7AD29FBC-D864-4EAF-B8E6-2D3E5CECE537}.Debug|XCOM 2.Build.0 = Debug|XCOM 2
{7AD29FBC-D864-4EAF-B8E6-2D3E5CECE537}.Default|XCOM 2.ActiveCfg = Debug|XCOM 2
{7AD29FBC-D864-4EAF-B8E6-2D3E5CECE537}.Default|XCOM 2.Build.0 = Debug|XCOM 2
{B6499644-295D-4FEF-A98C-894D4C57D9C0}.Debug|XCOM 2.ActiveCfg = Debug|XCOM 2
{B6499644-295D-4FEF-A98C-894D4C57D9C0}.Debug|XCOM 2.Build.0 = Debug|XCOM 2
{B6499644-295D-4FEF-A98C-894D4C57D9C0}.Default|XCOM 2.ActiveCfg = Debug|XCOM 2
{B6499644-295D-4FEF-A98C-894D4C57D9C0}.Default|XCOM 2.Build.0 = Debug|XCOM 2
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
34 changes: 20 additions & 14 deletions X2CommunityHighlander/Src/XComGame/Classes/X2LootTable.uc
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ native function RollForLootTable(const out name LootTableName, out array<name> R

// Start Issue #275 - Add a loot table interface
// static function are for use in the DLCInfo OnPostTemplatesCreated event
public function AddEntryAndReload(name TableName, LootTableEntry AddTableEntry)
public function AddEntryAndReload(name TableName, LootTableEntry TableEntry)
{
AddEntry(TableName, AddTableEntry);
AddEntry(self, TableName, TableEntry);
InitLootTables();
}

public function RemoveEntryAndReload(name TableName, LootTableEntry TableEntry)
{
RemoveEntry(TableName, TableEntry);
RemoveEntry(self, TableName, TableEntry);
InitLootTables();
}

Expand All @@ -35,7 +35,7 @@ public function AddLootTableAndReload(LootTable AddLootTable)
local LootTableEntry Loot;
foreach AddLootTable.Loots(Loot)
{
AddEntry(AddLootTable.TableName, Loot);
AddEntry(self, AddLootTable.TableName, Loot);
}
InitLootTables();
}
Expand All @@ -48,10 +48,13 @@ public function RemoveLootTableAndReload(LootTable LootTable)

public static function AddLootTable(LootTable AddLootTable)
{
local X2LootTable LootTable;
local LootTableEntry Loot;

LootTable = X2LootTable(class'Engine'.static.FindClassDefaultObject(string(default.Class.Name)));
foreach AddLootTable.Loots(Loot)
{
AddEntry(AddLootTable.TableName, Loot);
AddEntry(LootTable, AddLootTable.TableName, Loot);
}
}

Expand All @@ -65,15 +68,22 @@ public static function RemoveLootTable(LootTable RemoveLootTable)

public static function AddEntryToLootTable(name TableName, LootTableEntry AddTableEntry)
{
AddEntry(TableName, AddTableEntry);
local X2LootTable LootTable;

LootTable = X2LootTable(class'Engine'.static.FindClassDefaultObject(string(default.Class.Name)));
AddEntry(LootTable, TableName, AddTableEntry);
}

private static function RemoveEntry(name TableName, LootTableEntry TableEntry)
public static function RemoveEntryFromLootTable(name TableName, LootTableEntry TableEntry)
{
local X2LootTable LootTable;
local int Index;

LootTable = X2LootTable(class'Engine'.static.FindClassDefaultObject(string(default.Class.Name)));
RemoveEntry(LootTable, TableName, TableEntry);
}

private static function RemoveEntry(X2LootTable LootTable, name TableName, LootTableEntry TableEntry)
{
local int Index;

Index = LootTable.LootTables.Find('TableName', TableName);

Expand All @@ -84,15 +94,11 @@ private static function RemoveEntry(name TableName, LootTableEntry TableEntry)
}

// When the sum of chances is greater 100% after adding an entry, recalculate chances to 100% total
private static function AddEntry(name TableName, LootTableEntry AddTableEntry)
private static function AddEntry(X2LootTable LootTable, name TableName, LootTableEntry AddTableEntry)
{
local X2LootTable LootTable;
local LootTableEntry TableEntry;
local int Index, OldChance, NewChance, SumChances, TableEntryIndex;

LootTable = X2LootTable(class'Engine'.static.FindClassDefaultObject(string(default.Class.Name)));
`LOG(string(default.Class.Name) @ LootTable);

Index = LootTable.LootTables.Find('TableName', TableName);

if (Index != INDEX_NONE)
Expand Down

0 comments on commit 5aad08c

Please sign in to comment.