calculate road relationship after village generation
This commit is contained in:
parent
6d0d26fe10
commit
7de39bb4a7
@ -14,7 +14,7 @@ mg_villages.list_plots_formspec = function( player, formname, fields )
|
||||
local pname = player:get_player_name();
|
||||
|
||||
-- analyze the road network (this has not been done from the beginning..)
|
||||
mg_villages.get_road_list( fields.village_id );
|
||||
mg_villages.get_road_list( fields.village_id, false );
|
||||
|
||||
local formspec = 'size[12,12]'..
|
||||
'field[20,20;0.1,0.1;village_id;VillageID;'..minetest.formspec_escape( fields.village_id ).."]"..
|
||||
|
@ -1225,10 +1225,11 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm,
|
||||
t1 = time_elapsed( t1, 'do fill chests' );
|
||||
-- TODO: extra_calls.signs
|
||||
|
||||
|
||||
-- set up workplace markers so that they know for which mob they are responsible
|
||||
for _, village in ipairs(villages) do
|
||||
local village_id = tostring( village.vx )..':'..tostring( village.vz );
|
||||
-- this is a good time to analyze the road network as well
|
||||
mg_villages.get_road_list( village_id, true );
|
||||
for building_nr_in_bpos,pos in ipairs( village.to_add_data.bpos ) do
|
||||
if( pos.workplaces and #pos.workplaces>0) then
|
||||
for workplace_nr, wp in ipairs( pos.workplaces ) do
|
||||
|
@ -30,7 +30,7 @@ mg_villages.get_path_from_pos_to_plot_via_roads = function( village_id, pos, tar
|
||||
|
||||
-- find out which road is the one next to pos
|
||||
local standing_on_road = nil;
|
||||
local roads = mg_villages.get_road_list( village_id );
|
||||
local roads = mg_villages.get_road_list( village_id, false );
|
||||
for i,road in ipairs( roads ) do
|
||||
local r = bpos_list[ road ]; -- road data
|
||||
-- if this is really a road, and if a parent road exists (or is 0)
|
||||
@ -142,7 +142,7 @@ end
|
||||
|
||||
-- try to reconstruct the tree-like road network structure (the data was
|
||||
-- not saved completely from the beginning)
|
||||
mg_villages.get_road_list = function( village_id )
|
||||
mg_villages.get_road_list = function( village_id, force_check )
|
||||
if( not( mg_villages.all_villages[ village_id ] )) then
|
||||
return {};
|
||||
end
|
||||
@ -165,7 +165,7 @@ mg_villages.get_road_list = function( village_id )
|
||||
return {};
|
||||
end
|
||||
-- the parent roads have already been identified
|
||||
if( bpos_list[ roads[ 1 ]].parent_road_plot == 0 ) then
|
||||
if( not( force_check ) and bpos_list[ roads[ 1 ]].parent_road_plot == 0 ) then
|
||||
return roads;
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user