/
erlang.spawn
/
fallout2-ce
Обзор
Документация
Войти
/
erlang.spawn
/
fallout2-ce
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
sfall_testing/gl_test_tile_path.ssl
106 строк
4 KB
Mike Klaas
Implement `objects_in_radius` (#399)
22 апр 2026, 08:20
Не верифицирован
22 апр 2026, 08:20
1026c79
Код
Авторство
О чём код?
#include "sfall.h" #include "define_extra.h" #include "test_utils.h" #define TEST_ITEM_PID 40 variable blocker_obj := 0; variable radius_obj := 0; procedure cleanup begin if (blocker_obj) then begin destroy_object(blocker_obj); blocker_obj := 0; end if (radius_obj) then begin destroy_object(radius_obj); radius_obj := 0; end end procedure start begin variable elev := elevation(dude_obj); variable dude_tile := tile_num(dude_obj); variable dir; variable step_tile := -1; variable step_dir := -1; variable block_tile := -1; variable path; variable objs; variable ground_fid; variable roof_fid; display_msg("Testing tile/path functions..."); call cleanup(); for (dir := 0; dir < 6; dir += 1) begin variable candidate := tile_num_in_direction(dude_tile, dir, 1); if (candidate != dude_tile and obj_blocking_tile(candidate, elev, BLOCKING_TYPE_BLOCK) == 0) then begin if (step_tile == -1) then begin step_tile := candidate; step_dir := dir; end if (block_tile == -1 and candidate != step_tile) then begin block_tile := candidate; end end end call assertNotEquals("found reachable neighboring tile", step_tile, -1); if (step_tile != -1) then begin path := path_find_to(dude_obj, step_tile, BLOCKING_TYPE_BLOCK); call assertEquals("one-step path length", len_array(path), 1); if (len_array(path) == 1) then call assertEquals("one-step path direction", get_array(path, 0), step_dir); radius_obj := create_object_sid(TEST_ITEM_PID, step_tile, elev, -1); call assertNotEquals("spawned radius item", radius_obj, 0); if (radius_obj) then begin objs := sfall_func3("objects_in_radius", dude_tile, 1, elev); call assertTrue("objects_in_radius all contains dude", scan_array(objs, dude_obj) != -1); call assertTrue("objects_in_radius all contains item", scan_array(objs, radius_obj) != -1); objs := sfall_func3("objects_in_radius", dude_tile, 0, elev); call assertTrue("objects_in_radius radius 0 contains dude", scan_array(objs, dude_obj) != -1); call assertEquals("objects_in_radius radius 0 excludes adjacent item", scan_array(objs, radius_obj), -1); objs := objects_in_radius(dude_tile, 1, elev, OBJ_TYPE_ITEM); call assertTrue("objects_in_radius item filter contains item", scan_array(objs, radius_obj) != -1); call assertEquals("objects_in_radius item filter excludes dude", scan_array(objs, dude_obj), -1); objs := objects_in_radius(dude_tile, 1, elev, OBJ_TYPE_CRITTER); call assertTrue("objects_in_radius critter filter contains dude", scan_array(objs, dude_obj) != -1); call assertEquals("objects_in_radius critter filter excludes item", scan_array(objs, radius_obj), -1); end end if (block_tile != -1) then begin blocker_obj := create_object_sid(obj_pid(dude_obj), block_tile, elev, -1); call assertNotEquals("spawned blocking critter", blocker_obj, 0); if (blocker_obj) then begin path := path_find_to(dude_obj, tile_num(blocker_obj), BLOCKING_TYPE_BLOCK); call assertEquals("occupied destination returns empty path", len_array(path), 0); end end else begin display_msg("Skipping occupied-destination path check: no free adjacent tile for blocker."); end objs := tile_get_objs(dude_tile, elev); call assertTrue("tile_get_objs contains dude", scan_array(objs, dude_obj) != -1); ground_fid := get_tile_ground_fid(dude_tile, elev); roof_fid := get_tile_roof_fid(dude_tile, elev); call assertTrue("ground fid is non-negative", ground_fid >= 0); call assertTrue("roof fid is non-negative", roof_fid >= 0); call assertEquals("ground helper matches ext", ground_fid, get_tile_fid_ext(dude_tile, elev, 0)); call assertEquals("roof helper matches ext", roof_fid, get_tile_fid_ext(dude_tile, elev, 1)); call assertTrue("tile_light returns non-negative intensity", tile_light(elev, dude_tile) >= 0); call assertEquals("tile_by_position metarule exists", metarule_exist("tile_by_position"), 1); call assertEquals("tile_by_position matches tile_under_cursor", tile_by_position(get_mouse_x, get_mouse_y), tile_under_cursor); tile_refresh_display; call cleanup(); call report_test_results("tile_path"); end