(1) even more naming inconsistencies fixed; 

(2) even more methods hidden
This commit is contained in:
Dmitry Kovalenko 2012-04-12 18:56:08 +00:00
parent b9f9e29a0b
commit ace211df28
2 changed files with 29 additions and 25 deletions

View file

@ -8,9 +8,28 @@ return {
local cache = wesnoth.require("ai/lua/cache.lua")
cache.init(ai)
-- Hiding of get_new_* and is_*_valid methods
local to_hide = {
[1] = "get_new_src_dst",
[2] = "get_new_dst_src",
[3] = "get_new_enemy_src_dst",
[4] = "get_new_enemy_dst_src",
[5] = "is_enemy_dst_src_valid",
[6] = "is_dst_src_valid",
[7] = "is_src_dst_valid",
[8] = "is_enemy_src_dst_valid"
}
for i, v in ipairs(to_hide) do
ai.cache[v] = ai[v]
ai[v] = nil
end
-- End of hiding get_new_* methods
-- Validator section
function ai.cache.dst_src_validator()
if not ai.is_dst_src_valid() then
if not ai.cache.is_dst_src_valid() then
ai.cache.data["dst_src"] = nil
return false
end
@ -18,8 +37,8 @@ return {
return true
end
function ai.cache.dst_src_enemy_validator()
if not ai.is_dst_src_enemy_valid() then
function ai.cache.enemy_dst_src_validator()
if not ai.cache.is_enemy_dst_src_valid() then
ai.cache.data["enemy_dst_src"] = nil
return false
end
@ -28,7 +47,7 @@ return {
end
function ai.cache.src_dst_validator()
if not ai.is_src_dst_valid() then
if not ai.cache.is_src_dst_valid() then
ai.cache.data["src_dst"] = nil
return false
end
@ -36,8 +55,8 @@ return {
return true
end
function ai.cache.src_dst_enemy_validator()
if not ai.is_src_dst_enemy_valid() then
function ai.cache.enemy_src_dst_validator()
if not ai.cache.is_enemy_src_dst_valid() then
ai.cache.data["enemy_src_dst"] = nil
return false
end
@ -47,21 +66,6 @@ return {
-- End of validator section
-- Hiding of get_new_* methods
local to_hide = {
[1] = "get_new_src_dst",
[2] = "get_new_dst_src",
[3] = "get_new_enemy_src_dst",
[4] = "get_new_enemy_dst_src"
}
for i, v in ipairs(to_hide) do
ai.cache[v] = ai[v]
ai[v] = nil
end
-- End of hiding get_new_* methods
-- Proxy function section
function ai.get_dst_src()
@ -69,7 +73,7 @@ return {
end
function ai.get_src_dst()
return ai.cache.get_cached_item("src_dst", "get_new_src_dst", "dst_src_enemy_validator")
return ai.cache.get_cached_item("src_dst", "get_new_src_dst", "enemy_dst_src_validator")
end
function ai.get_enemy_dst_src()
@ -77,7 +81,7 @@ return {
end
function ai.get_enemy_src_dst()
return ai.cache.get_cached_item("enemy_src_dst", "get_new_enemy_src_dst", "src_dst_enemy_validator")
return ai.cache.get_cached_item("enemy_src_dst", "get_new_enemy_src_dst", "enemy_src_dst_validator")
end
-- End of proxy function section

View file

@ -810,9 +810,9 @@ lua_ai_context* lua_ai_context::create(lua_State *L, char const *code, ai::engin
// End of aspects
// Validation/cache functions
{ "is_dst_src_valid", &cfun_ai_is_dst_src_valid },
{ "is_dst_src_enemy_valid", &cfun_ai_is_dst_src_enemy_valid },
{ "is_enemy_dst_src_valid", &cfun_ai_is_dst_src_enemy_valid },
{ "is_src_dst_valid", &cfun_ai_is_src_dst_valid },
{ "is_src_dst_enemy_valid", &cfun_ai_is_src_dst_enemy_valid },
{ "is_enemy_src_dst_valid", &cfun_ai_is_src_dst_enemy_valid },
// End of validation functions
{ "move", &cfun_ai_execute_move_partial },
{ "move_full", &cfun_ai_execute_move_full },