1
0
Bifurcation 0
Ce dépôt a été archivé le 2020-03-15. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
questhelperredux/QuestHelper/collect_bitstream.lua
Nathanial.C.Jones 965e8589c9 Everything SEEMS to work, less of course the db. Something I did before screwed everything up.
I implemented a QuestHelper_GetTime function for the next time Blizzard decides to fiddle with the time functions. It returns debugprofilestop() / 1000, to exactly match the precision of GetTime().

I also re-removed references to Cartographer from the rollback.
2012-01-01 03:01:18 +00:00

57 lignes
1,5 Kio
Lua

local GetTime = QuestHelper_GetTime
QuestHelper_File["collect_bitstream.lua"] = "4.0.1.$svnversion$"
QuestHelper_Loadtime["collect_bitstream.lua"] = GetTime()
local Merger
local function Output(outbits)
return {
r = {},
cbits = 0,
cval = 0,
append = function (self, value, bits)
self.cbits = self.cbits + bits
self.cval = bit.lshift(self.cval, bits)
self.cval = self.cval + value
while self.cbits >= outbits do
Merger.Add(self.r, strchar(bit.rshift(self.cval, self.cbits - outbits)))
self.cbits = self.cbits - outbits
self.cval = bit.band(self.cval, bit.lshift(1, self.cbits) - 1)
end
end,
finish = function (self)
if self.cbits > 0 then self:append(0, outbits - self.cbits) end
return Merger.Finish(self.r)
end,
}
end
local function Input(indata, outbits)
return {
cbits = 0,
cval = 0,
coffset = 1,
depend = function (self, bits)
while self.cbits < bits do
self.cbits = self.cbits + outbits
self.cval = bit.lshift(self.cval, outbits) + strbyte(indata, self.coffset)
self.coffset = self.coffset + 1
end
local rv = bit.rshift(self.cval, self.cbits - bits)
self.cbits = self.cbits - bits;
self.cval = bit.band(self.cval, bit.lshift(1, self.cbits) - 1)
return rv
end,
}
end
function QH_Collect_Bitstream_Init(_, API)
Merger = API.Utility_Merger
QuestHelper: Assert(Merger)
API.Utility_Bitstream = {Input = Input, Output = Output}
end