1 QuestHelper_File
["db_get.lua"] = "Development Version"
2 QuestHelper_Loadtime
["db_get.lua"] = GetTime()
8 local QHDB = QHDB_temp]]
9 QuestHelper
: Assert(#QHDB
== 4)
11 local weak_v
= { __mode
= 'v' }
15 local function DBC_Get(group
, id
)
16 if not cache
[group
] then return end
17 return cache
[group
][id
]
20 local function DBC_Put(group
, id
, item
)
21 if not cache
[group
] then cache
[group
] = setmetatable({}, weak_v
) end
22 QuestHelper
: Assert(not cache
[group
][id
])
23 cache
[group
][id
] = item
25 DB_how_many_are_used()
28 local function mark(tab
, tomark
)
29 for k
, v
in pairs(tab
) do
30 if type(v
) == "table" then
37 function DB_GetItem(group
, id
)
38 QuestHelper
: Assert(group
, string.format("%s %s", tostring(group
), tostring(id
)))
39 QuestHelper
: Assert(id
, string.format("%s %s", tostring(group
), tostring(id
)))
40 local ite
= DBC_Get(group
, id
)
41 if ite
then return ite
end
43 if type(id
) == "string" then QuestHelper
: Assert(not id
:match("__.*")) end
45 --QuestHelper:TextOut(string.format("%s %d", group, id))
49 for _
, db
in ipairs(QHDB
) do
50 --print(db, db[group], db[group] and db[group][id], type(group), type(id))
51 if db
[group
] and db
[group
][id
] then
52 if not ite
then ite
= QuestHelper
:CreateTable("db") end
56 if type(db
[group
][id
]) == "string" then
57 srctab
= loadstring("return {" .. QH_LZW_Decompress_Dicts_Arghhacky(db
[group
][id
], db
[group
].__dictionary
) .. "}")()
58 elseif type(db
[group
][id
]) == "table" then
59 srctab
= db
[group
][id
]
61 print(type(db
[group
][id
]))
65 for k
, v
in pairs(srctab
) do
66 QuestHelper
: Assert(not ite
[k
])
76 DBC_Put(group
, id
, ite
)
78 QuestHelper
:TextOut(string.format("Tried to get %s/%s, failed", tostring(group
), tostring(id
)))
84 function DB_ListItems(group
)
86 for _
, db
in ipairs(QHDB
) do
87 if db
[group
] then for k
, _
in pairs(db
[group
]) do
88 if type(k
) == "string" and not k
:match("__.*") then
95 for k
, _
in pairs(tab
) do
102 function DB_how_many_are_used()
104 for k
, v
in pairs(cache
) do
105 for k2
, v2
in pairs(v
) do