Skip to content
This repository has been archived by the owner on Nov 21, 2017. It is now read-only.

Commit

Permalink
Fix bug where Micro-HARPA would not work you have never built a regul…
Browse files Browse the repository at this point in the history
…ar HARPA before
  • Loading branch information
Afforess committed Feb 21, 2016
1 parent 5281c15 commit 176d98f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE_NAME := Misanthrope
VERSION_STRING := 0.2.3
VERSION_STRING := 0.2.4

OUTPUT_NAME := $(PACKAGE_NAME)_$(VERSION_STRING)
OUTPUT_DIR := build/$(OUTPUT_NAME)
Expand Down
23 changes: 15 additions & 8 deletions libs/harpa.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "defines"

Harpa = {}

function Harpa.register(entity, player_idx)
function Harpa.setup()
if not global.harpa_list then
global.harpa_list = {}
end
Expand All @@ -18,7 +18,10 @@ function Harpa.register(entity, player_idx)
if not global.harpa_overlays then
global.harpa_overlays = {}
end
end

function Harpa.register(entity, player_idx)
Harpa.setup()
if Harpa.is_powered(entity, nil) then
if player_idx then
Harpa.create_overlay(entity, player_idx)
Expand Down Expand Up @@ -139,7 +142,7 @@ end
function Harpa.tick()
if global.harpa_list then
if not global.idle_harpa_list then global.idle_harpa_list = {} end

Harpa.setup()
Harpa.update_overlays()

-- check idle emitters less often
Expand Down Expand Up @@ -209,6 +212,7 @@ function Harpa.update_power_armor()
for i = 1, #game.players do
local player = game.players[i]
if Harpa.has_micro_emitter(player) and not Harpa.is_idle(player, 20) then
Harpa.setup()
table.insert(global.micro_harpa_players, player)
end
end
Expand All @@ -217,6 +221,7 @@ function Harpa.update_power_armor()
for i = #global.micro_harpa_players, 1, -1 do
local player = global.micro_harpa_players[i]
if Harpa.has_micro_emitter(player) then
Harpa.setup()
Harpa.tick_emitter(player, 16)
else
table.remove(global.micro_harpa_players, i)
Expand Down Expand Up @@ -319,12 +324,14 @@ function Harpa.tick_emitter(entity, radius)
end

function Harpa.ignore_biter(entity)
for i = #global.biter_ignore_list, 1, -1 do
local biter_data = global.biter_ignore_list[i]
if not biter_data.biter.valid or game.tick > biter_data.until_tick then
table.remove(global.biter_ignore_list, i)
elseif biter_data.biter == entity then
return true
if global.biter_ignore_list then
for i = #global.biter_ignore_list, 1, -1 do
local biter_data = global.biter_ignore_list[i]
if not biter_data.biter.valid or game.tick > biter_data.until_tick then
table.remove(global.biter_ignore_list, i)
elseif biter_data.biter == entity then
return true
end
end
end
return false
Expand Down

0 comments on commit 176d98f

Please sign in to comment.