WoWInterface SVN NotBloated

Compare Revisions

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

Rev 3 → Rev 2

trunk/NotBloated/main.lua
30,7 → 30,7
 
local Times = {}
 
local lastUpdate, lUpTime = 1, GetTime()
local lastSync, lastUpdate = 180, 1
local canUp, doBigWarning = false, false
 
local debug = false
56,18 → 56,73
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:Sync()
self:Update()
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
 
78,7 → 133,11
a['newTime'] = select(5, GetWorldPVPAreaInfo(i))
 
a['oldInProgress'] = a.inProgress
a['inProgress'] = select(3, GetWorldPVPAreaInfo(i)) or (a.invalid and a.waitTime == 0) and a.inProgress
a['inProgress'] = select(3, GetWorldPVPAreaInfo(i))
end
 
for i = 1, #Times do
a = Times[i]
 
if not a.waitTime then
-- upon logging in
97,17 → 156,6
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
117,35 → 165,11
 
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
 
lUpTime = GetTime()
 
if debug then
--if debug then
_G['NBTEST'] = Times
end
--end
end
 
-- Prints the time remainng/status of the battle
154,7 → 178,7
 
a = Times[index]
 
if not a.waitTime or (a.waitTime <= 0 and a.invalid) then
if a.waitTime <= 0 and a.invalid then
-- time has never been successfully fetched
print('Time remainng for ' .. a.n .. ' could not be fetched.')
return