mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-26 16:53:17 +00:00

The whitespace-fixing script seems to be slightly different depending on the platform. Even though it produces no effect in the CI, it made these changes locally on my Mac. I'm committing them now so as to avoid unrelated files being changed in other pull requests.
25 lines
472 B
Lua
25 lines
472 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
|
|
|
|
}
|