I have added comments to the things that I plan not to change - will need to go 
through the rest in detail.

Diff comments:

> === modified file 'data/tribes/init.lua'
> --- data/tribes/init.lua      2017-02-12 09:10:57 +0000
> +++ data/tribes/init.lua      2017-09-03 11:19:20 +0000
> @@ -11,12 +11,33 @@
>  --
>  -- Basic load order (first wares, then immovables etc.) is important,
>  -- because checks will be made in C++.
> --- Also, enhanced/upgraded units need to come before their basic units.
>  --
>  
>  tribes = wl.Tribes()
>  include "scripting/mapobjects.lua"
>  
> +-- Load all init.lua files in the given table of directory names
> +function load_directories(directories)
> +   -- Helper function to check for file name endings
> +   function string.ends(haystack, needle)
> +      return needle == '' or string.sub(haystack, -string.len(needle)) == 
> needle
> +   end
> +
> +   while #directories > 0 do
> +      local filepath = directories[1]
> +      table.remove(directories, 1)

This is the Lua syntax that I researched, so no idea if hat would work too - 
will have a look

> +      if path.is_directory(filepath) then
> +         for idx, listed_path in ipairs(path.list_directory(filepath)) do
> +            if path.is_directory(listed_path) then
> +               table.insert(directories, listed_path)
> +            elseif string.ends(listed_path , "init.lua") then
> +               include(listed_path)
> +            end
> +         end
> +      end
> +   end
> +end
> +
>  print("┏━ Running Lua for tribes:")
>  
>  print_loading_message("┗━ took", function()
> 
> === modified file 'src/logic/map_objects/tribes/tribes.h'
> --- src/logic/map_objects/tribes/tribes.h     2017-03-23 07:36:36 +0000
> +++ src/logic/map_objects/tribes/tribes.h     2017-09-03 11:19:20 +0000
> @@ -148,6 +151,22 @@
>       /// Complete the Description objects' information with data from other 
> Description objects.
>       void postload();
>  
> +     /// Some workers have other workers as part of their buildcost. If the 
> other worker hasn't been loaded yet, it will need to be added during postload.
> +     struct WorkerBuildcost {
> +             const std::string worker;

No we don't, because we now can't guarantee the load order any more - part of 
the point in this change is that the directories get parsed automatically 
rather than listing all init.lua files in the main init.lua manually, so we 
can't guarantee that basic workers are loaded before the advanced workers. Same 
goes for buildings.

> +             const std::string needed_worker;
> +             const Quantity quantity;
> +     };
> +     void add_worker_buildcost(const WorkerBuildcost& buildcost);
> +
> +     /// Enhanced buildings/workers might not have been loaded yet when a 
> more basic type is being loaded, so we will need to add some of them during 
> postload.
> +     struct MapObjectEnhancement {
> +             const MapObjectType type; // Worker or building
> +             const std::string name;

See above

> +             const std::string enhanced_name;
> +     };
> +     void add_mapobject_enhancement(const MapObjectEnhancement& becomes);
> +
>  private:
>       std::unique_ptr<DescriptionMaintainer<BuildingDescr>> buildings_;
>       std::unique_ptr<DescriptionMaintainer<ImmovableDescr>> immovables_;


-- 
https://code.launchpad.net/~widelands-dev/widelands/dynamic_tribe_loading/+merge/329198
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/dynamic_tribe_loading.

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to