WoWInterface SVN NotBloated

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 2 to Rev 3
    Reverse comparison

Rev 2 → Rev 3

trunk/NotBloated/main.lua
30,7 → 30,7
 
local Times = {}
 
local lastSync, lastUpdate = 180, 1
local lastUpdate, lUpTime = 1, GetTime()
local canUp, doBigWarning = false, false
 
local debug = false
56,73 → 56,18
end
 
function NotBloated:OnUpdate(elapsed)
lastSync = lastSync + elapsed
lastUpdate = lastUpdate + elapsed
 
if lastSync >= 60 then
-- Every minute:
-- Synchronize the timer with WoW
self:Sync()
lastSync = 0
end
 
if canUp and lastUpdate >= 10 then
-- Every ten seconds:
-- Increment the timer [and warn the player]
self:Update()
self:Sync()
lastUpdate = 0
end
end
 
-- Incrementing timer manually (not fetching from WoW)
-- Also calls warnings
function NotBloated:Update()
-- TODO: should store the runtime (system timestamp) on first update
-- then here, do `CurrentTime - LastTime` to get time difference
-- without messing up on slow systems/minimizing/zoning etc
 
-- TODO: need to rewrite this (due to redundancy)
 
local a, i
 
for i = 1, #Times do
a = Times[i]
a.waitTime = a.waitTime - 10
 
if a.waitTime <= 0 then
return
end
 
-- Perform warnings!
 
for warning, done in pairs(warningsDone) do
done = done[i]
 
if warning ~= 'big' and (a.waitTime <= (warning + 1) * 60 and not done) then
warningsDone[warning][i] = true
doWarning = true
 
if bigWarning[i] and not warningsDone.big[i] and bigWarning[i] == warning then
-- big warning will only be performed if a normal warning
-- is also set to this time
 
doBigWarning = i
warningsDone.big[i] = true
end
end
end
 
--doWarning = true
--doBigWarning = true
 
if doWarning then
self:PrintTime(i)
doWarning = false
end
end
end
 
-- Synchronizes the timer with WoW (every minute)
-- Also perform warnings
function NotBloated:Sync()
local a, i
 
133,11 → 78,7
a['newTime'] = select(5, GetWorldPVPAreaInfo(i))
 
a['oldInProgress'] = a.inProgress
a['inProgress'] = select(3, GetWorldPVPAreaInfo(i))
end
 
for i = 1, #Times do
a = Times[i]
a['inProgress'] = select(3, GetWorldPVPAreaInfo(i)) or (a.invalid and a.waitTime == 0) and a.inProgress
 
if not a.waitTime then
-- upon logging in
156,6 → 97,17
end
 
a['invalid'] = true
 
if a.waitTime and a.waitTime > 0 then
-- try to emulate the timer
a.waitTime = a.waitTime - (GetTime() - lUpTime)
 
if a.waitTime < 0 then
-- assume the battle is in progress
a.waitTime = 0
a.inProgress = true
end
end
end
 
if not a.inProgress and a.oldInProgress then
165,11 → 117,35
 
a.oldInProgress = false
end
 
-- Perform warnings ------------------------------------------------
for warning, done in pairs(warningsDone) do
done = done[i]
 
if warning ~= 'big' and (a.waitTime <= (warning + 1) * 60 and not done) then
warningsDone[warning][i] = true
doWarning = true
 
if bigWarning[i] and not warningsDone.big[i] and bigWarning[i] == warning then
-- big warning will only be performed if a normal warning
-- is also set to this time
doBigWarning = i
warningsDone.big[i] = true
end
end
end
 
if doWarning then
self:PrintTime(i)
doWarning = false
end
end
 
--if debug then
lUpTime = GetTime()
 
if debug then
_G['NBTEST'] = Times
--end
end
end
 
-- Prints the time remainng/status of the battle
178,7 → 154,7
 
a = Times[index]
 
if a.waitTime <= 0 and a.invalid then
if not a.waitTime or (a.waitTime <= 0 and a.invalid) then
-- time has never been successfully fetched
print('Time remainng for ' .. a.n .. ' could not be fetched.')
return