mutators: minor fixes, move to folder
This commit is contained in:
parent
ec95192907
commit
b7f47297b2
1 changed files with 10 additions and 14 deletions
|
@ -40,11 +40,6 @@ local function update_mutators_sequence(mutator_name, enable_these_after)
|
||||||
table.combine(mutators_sequence[mutator_name], enable_these_after)
|
table.combine(mutators_sequence[mutator_name], enable_these_after)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This shouldn't happen
|
|
||||||
local function error_endless_loop()
|
|
||||||
vmf:error("Mutators: too many iterations. Check for loops in 'enable_before_these'/'enable_after_these'.")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Sorts mutators in order they should be enabled
|
-- Sorts mutators in order they should be enabled
|
||||||
local function sort_mutators()
|
local function sort_mutators()
|
||||||
|
|
||||||
|
@ -56,8 +51,8 @@ local function sort_mutators()
|
||||||
print("-----------")
|
print("-----------")
|
||||||
-- /LOG --
|
-- /LOG --
|
||||||
|
|
||||||
-- Preventing endless loops (worst case is n*n*(n+1)/2 I believe)
|
-- Preventing endless loops (worst case is n*(n+1)/2 I believe)
|
||||||
local maxIter = #mutators * #mutators * (#mutators + 1)/2
|
local maxIter = #mutators * (#mutators + 1)/2
|
||||||
local numIter = 0
|
local numIter = 0
|
||||||
|
|
||||||
-- The idea is that all mutators before the current one are already in the right order
|
-- The idea is that all mutators before the current one are already in the right order
|
||||||
|
@ -68,7 +63,7 @@ local function sort_mutators()
|
||||||
local mutator_name = mutator:get_name()
|
local mutator_name = mutator:get_name()
|
||||||
local enable_these_after = mutators_sequence[mutator_name] or {}
|
local enable_these_after = mutators_sequence[mutator_name] or {}
|
||||||
|
|
||||||
-- Going back from the previous mutator
|
-- Going back from the previous mutator to the start of the list
|
||||||
local j = i - 1
|
local j = i - 1
|
||||||
while j > 0 do
|
while j > 0 do
|
||||||
local other_mutator = mutators[j]
|
local other_mutator = mutators[j]
|
||||||
|
@ -82,21 +77,21 @@ local function sort_mutators()
|
||||||
i = i - 1
|
i = i - 1
|
||||||
end
|
end
|
||||||
j = j - 1
|
j = j - 1
|
||||||
|
|
||||||
numIter = numIter + 1
|
|
||||||
if numIter > maxIter then return error_endless_loop() end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
numIter = numIter + 1
|
numIter = numIter + 1
|
||||||
if numIter > maxIter then return error_endless_loop() end
|
if numIter > maxIter then
|
||||||
|
vmf:error("Mutators: too many iterations. Check for loops in 'enable_before_these'/'enable_after_these'.")
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
mutators_sorted = true
|
mutators_sorted = true
|
||||||
|
|
||||||
-- LOG --
|
-- LOG --
|
||||||
for i, v in ipairs(mutators) do
|
for k, v in ipairs(mutators) do
|
||||||
print(i, v:get_name())
|
print(k, v:get_name())
|
||||||
end
|
end
|
||||||
print("-----------")
|
print("-----------")
|
||||||
-- /LOG --
|
-- /LOG --
|
||||||
|
@ -133,6 +128,7 @@ local function set_mutator_state(self, state)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Enable/disable current mutator
|
-- Enable/disable current mutator
|
||||||
|
-- We're calling methods on the class object because we've overwritten them on the current one
|
||||||
if state then
|
if state then
|
||||||
print("Enabled ", self:get_name(), "!")
|
print("Enabled ", self:get_name(), "!")
|
||||||
VMFMod.enable(self)
|
VMFMod.enable(self)
|
Loading…
Add table
Reference in a new issue