add game&rawdata
This commit is contained in:
parent
0133cd976c
commit
49b34b5546
45731 changed files with 709831 additions and 0 deletions
145
gamedata/scripts/check_logic_path.script
Normal file
145
gamedata/scripts/check_logic_path.script
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
-- run_string check_logic_path.check()
|
||||
|
||||
local path_fields = { "path_walk", "path_main", "path_home", "center_point" }
|
||||
|
||||
function check()
|
||||
for smart_name,smart in pairs(smart_terrain.smart_terrains_by_name) do
|
||||
--printf("checking smart ---> %s", smart_name)
|
||||
|
||||
for k,v in pairs(smart.job_data) do
|
||||
--printf(" checking work --> %s", v.section)
|
||||
local ltx = v.ini_file or smart.ltx
|
||||
check_ini(ltx, v.section, smart, v.prefix_name)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local section_to_check = {}
|
||||
|
||||
function get_sections(ini, active_section_cond)
|
||||
for k,cond in pairs(active_section_cond) do
|
||||
if cond.section ~= nil then
|
||||
if section_to_check[cond.section] ~= true then
|
||||
section_to_check[cond.section] = true
|
||||
|
||||
local switch_sections = xr_logic.cfg_get_switch_conditions(ini, cond.section)
|
||||
if switch_sections ~= nil and switch_sections ~= "" then
|
||||
for kk, v in pairs(switch_sections) do
|
||||
get_sections(ini, v.condlist)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function check_ini(ini, section, smart, prefix_name)
|
||||
section_to_check = {}
|
||||
|
||||
local active_section_cond = xr_logic.cfg_get_condlist(ini, section, "active")
|
||||
|
||||
get_sections(ini, active_section_cond.condlist)
|
||||
|
||||
--print_table(section_to_check)
|
||||
|
||||
for sect,v in pairs(section_to_check) do
|
||||
|
||||
local path_field
|
||||
for i,vv in pairs(path_fields) do
|
||||
if ini:line_exist(sect, vv) then
|
||||
path_field = vv
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if path_field ~= nil then
|
||||
local prefix
|
||||
if prefix_name ~= nil then
|
||||
prefix = prefix_name
|
||||
else
|
||||
prefix = smart:name()
|
||||
end
|
||||
|
||||
local path_walk = utils.cfg_get_string(ini, sect, path_field, smart, false, prefix)
|
||||
|
||||
--printf(" check path %s", path_walk)
|
||||
|
||||
local patrol_walk = patrol(path_walk)
|
||||
|
||||
-- Ïðîâåðêà íàëè÷èÿ ïóòè
|
||||
if not patrol_walk then
|
||||
printf("path_walk [%s] doesnt exist in the game", path_walk)
|
||||
end
|
||||
|
||||
-- Åñëè ýòî âàëê ïóòü, ïðîâåðÿåì åñòü ëè ëóê.
|
||||
local patrol_look = nil
|
||||
if path_field == "path_walk" then
|
||||
local path_look_name = utils.cfg_get_string(ini, sect, "path_look", smart, false, prefix)
|
||||
if path_look_name ~= nil then
|
||||
--printf(" checking path look %s", tostring(path_look_name))
|
||||
patrol_look = patrol(path_look_name)
|
||||
if not patrol_look then
|
||||
printf("path_look [%s] doesnt exist in the game", path_look_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Èòåðèðóåìñÿ ïî òî÷êàì ïàòðóëüíîãî ïóòè
|
||||
local cnt = patrol_walk:count()
|
||||
for pt = 0, cnt - 1 do
|
||||
local point = patrol_walk:point(pt)
|
||||
|
||||
-- Ïðîâåðêà ÷òî òî÷êà íà ÀÈ êàðòå
|
||||
local level_vertex_id = patrol_walk:level_vertex_id(pt)
|
||||
|
||||
if level_vertex_id == nil then
|
||||
printf("path_walk [%s] point [%s] is not on the AI map (no_level_id)", path_walk, pt)
|
||||
end
|
||||
-- local vertex_position = level.vertex_position(level_vertex_id)
|
||||
-- if vertex_position:distance_to_sqr(point) > 0.49 then
|
||||
-- printf("path_walk [%s] point [%s] is not on the AI map (by_distance)", path_walk, pt)
|
||||
-- end
|
||||
|
||||
-- Ïðîâåðêà ÷òî åñòü ñîîòâåòñòâóþùèé ëóê ïóòü.
|
||||
if patrol_look ~= nil then
|
||||
local flags = patrol_walk:flags(pt)
|
||||
|
||||
local look_cnt = patrol_look:count()
|
||||
local is_found = false
|
||||
for look_pt = 0, look_cnt - 1 do
|
||||
local look_flags = patrol_walk:flags(look_pt)
|
||||
|
||||
if flags:equal(look_flags) then
|
||||
is_found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if cnt == 1 and not_is_found then
|
||||
printf("path_walk [%s] is one-point walk path without corresponding look points", path_walk)
|
||||
end
|
||||
else
|
||||
-- Ñïåøë êåéñ íà ñëó÷àé êîãäà îäíîòî÷å÷íûì ïóòü âîëêà
|
||||
if cnt == 1 then
|
||||
printf("path_walk [%s] is one-point walk path without path_look", path_walk)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function main()
|
||||
check()
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue