mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-27 21:33:41 +00:00

(1) fixed some naming inconsistencies; (2) hidden some methods to the cache table, so that they don't lie around unused in the ai table
24 lines
473 B
Lua
24 lines
473 B
Lua
--! #textdomain wesnoth
|
|
|
|
return {
|
|
init = function(ai)
|
|
|
|
ai.cache = {}
|
|
ai.cache.data = {}
|
|
|
|
function ai.cache.update_cache(item, getter)
|
|
ai.cache.data[item] = ai.cache[getter]()
|
|
return ai.cache.data[item]
|
|
end
|
|
|
|
function ai.cache.get_cached_item(item, getter, validator)
|
|
if not ai.cache.data[item] or not ai.cache[validator]() then
|
|
local result = ai.cache.update_cache(item, getter)
|
|
return result
|
|
end
|
|
return ai.cache.data[item]
|
|
|
|
end
|
|
end
|
|
|
|
} |