2012-01-01 04:01:18 +01:00
local GetTime = QuestHelper_GetTime
2010-11-08 14:28:59 +01:00
QuestHelper_File [ " collect_zone.lua " ] = " 4.0.1.$svnversion$ "
2010-10-24 23:17:33 +02:00
QuestHelper_Loadtime [ " collect_zone.lua " ] = GetTime ( )
local debug_output = false
if QuestHelper_File [ " collect_zone.lua " ] == " Development Version " then debug_output = true end
local QHCZ
local GetLoc
local Merger
2011-01-28 03:29:12 +01:00
local function DoZoneUpdate ( label , debugverbose )
2012-09-26 17:44:24 +02:00
local zt , rzt , szt , mzt = GetZoneText ( ) or " " , GetRealZoneText ( ) or " " , GetSubZoneText ( ) or " " , GetMinimapZoneText ( ) or " "
local zname = string.format ( " %s@@%s@@%s@@%s " , zt , rzt , szt , mzt ) -- I don't *think* any zones will have a @@ in them :D
2011-01-28 03:29:12 +01:00
if zname == " @@@@ " then return end -- denied
if not QHCZ [ zname ] then QHCZ [ zname ] = { } end
if not QHCZ [ zname ] [ label ] then QHCZ [ zname ] [ label ] = { } end
local znl = QHCZ [ zname ] [ label ]
if debugverbose and debug_output then
--QuestHelper:TextOut("zoneupdate " .. zname .. " type " .. label)
2010-10-24 23:17:33 +02:00
end
2011-01-28 03:29:12 +01:00
QHCZ [ zname ] . mapname = GetMapInfo ( )
local loc = GetLoc ( )
if loc.delayed == 128 and loc.c == 0 and loc.z == 0 and loc.x == - 128 and loc.y == - 128 then return end
--if loc == "<22> \000\000\000<30> \000\000\000<30> <30> <EFBFBD> " then return end -- this is kind of the "null value"
local found = false
2012-09-26 17:44:24 +02:00
if not znl.locs then
znl.locs = { }
end
table.insert ( znl.locs , loc )
2011-01-28 03:29:12 +01:00
-- Commented out, 'cause this module isn't really loaded anymore. I'll remove it after the next commit.
--Merger.Add(znl, loc, true)
2010-10-24 23:17:33 +02:00
end
local function OnEvent ( )
2011-01-28 03:29:12 +01:00
DoZoneUpdate ( " border " , true )
end
local lastupdate = 0
local function OnUpdate ( )
2012-01-01 03:22:56 +01:00
if lastupdate + 15 <= GetTime ( ) then
2011-01-28 03:29:12 +01:00
DoZoneUpdate ( " update " )
2012-01-01 03:22:56 +01:00
lastupdate = GetTime ( )
2011-01-28 03:29:12 +01:00
end
2010-10-24 23:17:33 +02:00
end
2012-09-26 01:52:08 +02:00
function QH_Collect_Zone_FactionChange ( QHCData )
2011-01-28 03:29:12 +01:00
if not QHCData.zone then QHCData.zone = { } end
QHCZ = QHCData.zone
2012-09-26 01:52:08 +02:00
end
function QH_Collect_Zone_Init ( QHCData , API )
QH_Collect_Zone_FactionChange ( QHCData )
2010-10-24 23:17:33 +02:00
QH_Event ( " ZONE_CHANGED " , OnEvent )
QH_Event ( " ZONE_CHANGED_INDOORS " , OnEvent )
QH_Event ( " ZONE_CHANGED_NEW_AREA " , OnEvent )
2012-09-26 01:52:08 +02:00
API.Registrar_OnUpdateHook ( OnUpdate )
2010-10-24 23:17:33 +02:00
GetLoc = API.Callback_LocationBolusCurrent
QuestHelper : Assert ( GetLoc )
Merger = API.Utility_Merger
QuestHelper : Assert ( Merger )
end