From b0c8f05f3886d944c58ba57206693409be23bdcd Mon Sep 17 00:00:00 2001 From: kaltokri Date: Fri, 27 Oct 2023 17:01:51 +0200 Subject: [PATCH 1/4] Build optimization - Remove appveyor - Added docker compose for building docs locally - Added manuall run of GitHub Action builds - Added paths to trigger builds --- .appveyor/appveyor.yml | 87 ---------------------- .gitattributes | 4 + .github/workflows/build-docs.yml | 9 +++ .github/workflows/build-includes.yml | 7 ++ docker/moose-build-docs/Dockerfile | 13 ++++ docker/moose-build-docs/docker-compose.yml | 14 ++++ docker/moose-build-docs/start.sh | 24 ++++++ 7 files changed, 71 insertions(+), 87 deletions(-) delete mode 100644 .appveyor/appveyor.yml create mode 100644 docker/moose-build-docs/Dockerfile create mode 100644 docker/moose-build-docs/docker-compose.yml create mode 100644 docker/moose-build-docs/start.sh diff --git a/.appveyor/appveyor.yml b/.appveyor/appveyor.yml deleted file mode 100644 index 2af7fd529..000000000 --- a/.appveyor/appveyor.yml +++ /dev/null @@ -1,87 +0,0 @@ -version: 2.4.a.{build} -shallow_clone: true -skip_branch_with_pr: false -skip_commits: - message: /!nobuild/ -skip_tags: false - -environment: - access_token_documentation: - secure: JVBVVL8uJUcLXN+48eRdELEeCGOGCCaMzCqutsUqNuaZ/KblG5ZTt7+LV4UKv/0f - LUAROCKS_VER: 2.4.1 - LUA_VER: 5.1.5 - LUA: lua5.3 - matrix: - - LUA_VER: 5.1.5 - -platform: - - x64 - - -init: - - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` - https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` - Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` - throw "There are newer queued builds for this pull request, failing early." } -# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - -install: - - cmd: -# Outcomment if lua environment invalidates and needs to be reinstalled, otherwise all will run from the cache. - call choco install 7zip.commandline - call choco install lua51 - call choco install luarocks - call refreshenv - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" - cmd: PATH = %PATH%;C:\ProgramData\chocolatey\lib\luarocks\luarocks-2.4.3-win32\systree\bin - cmd: set LUA_PATH = %LUA_PATH%;C:\ProgramData\chocolatey\lib\luarocks\luarocks-2.4.3-win32\systree\share\lua\5.1\?.lua;C:\ProgramData\chocolatey\lib\luarocks\luarocks-2.4.3-win32\systree\share\lua\5.1\?\init.lua - cmd: set LUA_CPATH = %LUA_CPATH%;C:\ProgramData\chocolatey\lib\luarocks\luarocks-2.4.3-win32\systree\lib\lua\5.1\?.dll - call luarocks install luasrcdiet - call luarocks install checks - call luarocks install luadocumentor - call luarocks install luacheck - - -cache: -C:\ProgramData\chocolatey\lib -C:\ProgramData\chocolatey\bin - - - -build_script: - - ps: | - if( $env:appveyor_repo_branch -eq 'master' -or $env:appveyor_repo_branch -eq 'develop' ) - { - echo "Hello World!" - $apiUrl = 'https://ci.appveyor.com/api' - $token = 'v2.6hcv3ige78kg3yvg4ge8' - $headers = @{ - "Authorization" = "Bearer $token" - "Content-type" = "application/json" - } - $RequestBody = @{ accountName = 'FlightControl-Master'; projectSlug = 'moose-include'; branch = "$env:appveyor_repo_branch"; environmentVariables = @{} } | ConvertTo-Json - # Generate the new version ... - $project = Invoke-RestMethod -method Post -Uri "$apiUrl/builds" -Headers $headers -Body $RequestBody - } - - ps: | - if( $env:appveyor_repo_branch -eq 'master' -or $env:appveyor_repo_branch -eq 'develop' ) - { - $apiUrl = 'https://ci.appveyor.com/api' - $token = 'v2.6hcv3ige78kg3yvg4ge8' - $headers = @{ - "Authorization" = "Bearer $token" - "Content-type" = "application/json" - } - $RequestBody = @{ accountName = 'FlightControl-Master'; projectSlug = 'moose-docs'; branch = "$env:appveyor_repo_branch"; environmentVariables = @{} } | ConvertTo-Json - # get project with last build details - $project = Invoke-RestMethod -method Post -Uri "$apiUrl/builds" -Headers $headers -Body $RequestBody - } - - -test: off -# test_script: -# - cmd: luacheck "Moose Development\Moose\moose.lua" "Moose Mission Setup\moose.lua" - - -on_finish: -# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) diff --git a/.gitattributes b/.gitattributes index bdb0cabc8..2e755a77c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,3 +15,7 @@ *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain + +# Avoid Windows line endings on shell scripts +# Needed for dockerfile builds +*.sh text eol=lf diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 4a7bc1f8c..5769e409b 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -5,6 +5,15 @@ on: branches: - master - develop + paths: + - 'Moose Setup/**/*.lua' + - 'Moose Development/**/*.lua' + - 'Moose Development/**/*.py' + - 'Moose Development/**/*.html' + - '.github/workflows/build-docs.yml' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: jobs: Build: diff --git a/.github/workflows/build-includes.yml b/.github/workflows/build-includes.yml index 04def15d3..4bd22bdbe 100644 --- a/.github/workflows/build-includes.yml +++ b/.github/workflows/build-includes.yml @@ -5,6 +5,13 @@ on: branches: - master - develop + paths: + - 'Moose Setup/**/*.lua' + - 'Moose Development/**/*.lua' + - '.github/workflows/build-includes.yml' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: jobs: Build: diff --git a/docker/moose-build-docs/Dockerfile b/docker/moose-build-docs/Dockerfile new file mode 100644 index 000000000..839828c60 --- /dev/null +++ b/docker/moose-build-docs/Dockerfile @@ -0,0 +1,13 @@ +FROM nickblah/lua:5.1.5-luarocks-ubuntu + +RUN apt-get -qq update +RUN apt-get -qq install tree +RUN apt-get -qq install build-essential +RUN apt-get -qq install git +RUN luarocks install markdown 0.32-2 +RUN luarocks install penlight 1.11.0-1 +RUN luarocks install metalua-compiler 0.7.3-1 +RUN luarocks install metalua-parser 0.7.3-2 +RUN luarocks install checks +COPY start.sh /start.sh +RUN chmod +x /start.sh \ No newline at end of file diff --git a/docker/moose-build-docs/docker-compose.yml b/docker/moose-build-docs/docker-compose.yml new file mode 100644 index 000000000..8ca5680e4 --- /dev/null +++ b/docker/moose-build-docs/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3.5" + +services: + lua: + image: moose/build-docs + build: + context: . + dockerfile: Dockerfile + container_name: moose-build-docs + volumes: + - ../../:/moose + stdin_open: true + tty: true + command: /bin/bash -c /start.sh diff --git a/docker/moose-build-docs/start.sh b/docker/moose-build-docs/start.sh new file mode 100644 index 000000000..4773540be --- /dev/null +++ b/docker/moose-build-docs/start.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# Prepare environment +cd /moose/ +mkdir -p build/tools +mkdir -p build/doc + +# Checkout luadocumentor +cd /moose/build/tools +if [ ! -f /moose/build/tools/luadocumentor/luadocumentor.lua ] +then + git clone --branch patch-1 --single-branch https://github.com/Applevangelist/luadocumentor.git +fi + +# Run luadocumentor +cd /moose/build/tools/luadocumentor +lua luadocumentor.lua -d /moose/build/doc '/moose/Moose Development/Moose' + +# Copy generated files in the MOOSE_DOCS repo if it is already there +if [ -d /moose/build/MOOSE_DOCS/Documentation ]; then + rm -rf /moose/build/MOOSE_DOCS/Documentation + mkdir -p /moose/build/MOOSE_DOCS/Documentation + cp /moose/build/doc/* /moose/build/MOOSE_DOCS/Documentation/ +fi From 3684a023da0e719dae4f33c76331bef802b1c398 Mon Sep 17 00:00:00 2001 From: kaltokri Date: Fri, 27 Oct 2023 17:27:38 +0200 Subject: [PATCH 2/4] Fixed dead link --- Moose Development/Moose/Wrapper/Controllable.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 20abf3e2a..f54f0bfd8 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -99,7 +99,7 @@ -- This method can also be used to **embed a function call when a certain waypoint has been reached**. -- See below the **Tasks at Waypoints** section. -- --- Demonstration Mission: [GRP-502 - Route at waypoint to random point](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/release-2-2-pre/GRP - Group Commands/GRP-502 - Route at waypoint to random point) +-- Demonstration Mission: [GRP-502 - Route at waypoint to random point](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/GRP%20-%20Group%20Commands/GRP-502%20-%20Route%20at%20waypoint%20to%20random%20point) -- -- ## 2.5) Tasks at Waypoints -- From 764356870690c628b272c8791fe4cadb1ab3fa86 Mon Sep 17 00:00:00 2001 From: kaltokri Date: Fri, 27 Oct 2023 17:48:41 +0200 Subject: [PATCH 3/4] Fixed dead links in documentation --- Moose Development/Moose/Wrapper/Group.lua | 4 ++-- Moose Development/Moose/Wrapper/Weapon.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index faeb810a5..5ac314940 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -30,7 +30,7 @@ -- -- ### Contributions: -- --- * [**Entropy**](https://forums.eagle.ru/member.php?u=111471), **Afinegan**: Came up with the requirement for AIOnOff(). +-- * **Entropy**, **Afinegan**: Came up with the requirement for AIOnOff(). -- -- === -- @@ -1852,7 +1852,7 @@ function GROUP:InitModex(modex) return self end ---- Respawn the @{Wrapper.Group} at a @{Point}. +--- Respawn the @{Wrapper.Group} at a @{Core.Point}. -- The method will setup the new group template according the Init(Respawn) settings provided for the group. -- These settings can be provided by calling the relevant Init...() methods of the Group. -- diff --git a/Moose Development/Moose/Wrapper/Weapon.lua b/Moose Development/Moose/Wrapper/Weapon.lua index 3e6e98092..6f56ceb99 100644 --- a/Moose Development/Moose/Wrapper/Weapon.lua +++ b/Moose Development/Moose/Wrapper/Weapon.lua @@ -14,7 +14,7 @@ -- -- ## Example Missions: -- --- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Wrapper%20-%20Weapon). +-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/WRAPPER%20-%20Weapon). -- -- === -- From 51102e47ae3fb4622bdbcdce37c48237cf8be728 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sun, 29 Oct 2023 17:44:31 +0100 Subject: [PATCH 4/4] #CTLD * Adding re-packing dropped units --- Moose Development/Moose/Ops/CTLD.lua | 58 +++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 8c77f8eb8..d98ffc882 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -19,10 +19,12 @@ -- === -- -- ### Author: **Applevangelist** (Moose Version), ***Ciribob*** (original), Thanks to: Shadowze, Cammel (testing), bbirchnz (additional code!!) +-- ### Repack addition for crates: **Raiden** +-- -- @module Ops.CTLD -- @image OPS_CTLD.jpg --- Last Update June 2023 +-- Last Update October 2023 do @@ -700,6 +702,7 @@ do -- -- my_ctld.useprefix = true -- (DO NOT SWITCH THIS OFF UNLESS YOU KNOW WHAT YOU ARE DOING!) Adjust **before** starting CTLD. If set to false, *all* choppers of the coalition side will be enabled for CTLD. -- my_ctld.CrateDistance = 35 -- List and Load crates in this radius only. +-- my_ctld.PackDistance = 35 -- Pack crates in this radius only -- my_ctld.dropcratesanywhere = false -- Option to allow crates to be dropped anywhere. -- my_ctld.dropAsCargoCrate = false -- Parachuted herc cargo is not unpacked automatically but placed as crate to be unpacked. Needs a cargo with the same name defined like the cargo that was dropped. -- my_ctld.maximumHoverHeight = 15 -- Hover max this high to load. @@ -1121,6 +1124,7 @@ CTLD = { Spawned_Crates = {}, -- Holds objects for crates spawned generally Spawned_Cargo = {}, -- Binds together spawned_crates and their CTLD_CARGO objects CrateDistance = 35, -- list crates in this radius + PackDistance = 35, -- pack crates in this radius debug = false, wpZones = {}, dropOffZones = {}, @@ -1144,6 +1148,7 @@ CTLD = { -- DONE: List cargo in stock -- DONE: Limit of troops, crates buildable? -- DONE: Allow saving of Troops & Vehicles +-- DONE: Adding re-packing dropped units ------------------------------ --- Radio Beacons @@ -1223,7 +1228,7 @@ CTLD.UnitTypes = { --- CTLD class version. -- @field #string version -CTLD.version="1.0.40" +CTLD.version="1.0.41" --- Instantiate a new CTLD. -- @param #CTLD self @@ -1341,6 +1346,7 @@ function CTLD:New(Coalition, Prefixes, Alias) -- setup self.CrateDistance = 35 -- list/load crates in this radius + self.PackDistance = 35 -- pack objects in this radius self.ExtractFactor = 3.33 -- factor for troops extraction, i.e. CrateDistance * Extractfactor self.prefixes = Prefixes or {"Cargoheli"} self.useprefix = true @@ -2260,9 +2266,10 @@ end -- @param #CTLD_CARGO Cargo -- @param #number number Number of crates to generate (for dropping) -- @param #boolean drop If true we\'re dropping from heli rather than loading. -function CTLD:_GetCrates(Group, Unit, Cargo, number, drop) +-- @param #boolean pack If true we\'re packing crates from a template rather than loading or dropping +function CTLD:_GetCrates(Group, Unit, Cargo, number, drop, pack) self:T(self.lid .. " _GetCrates") - if not drop then + if not drop and not pack then local cgoname = Cargo:GetName() -- check if we have stock local instock = Cargo:GetStock() @@ -2279,18 +2286,20 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop) local width = 20 local distance = nil local zone = nil - if not drop then + if not drop and not pack then inzone = self:IsUnitInZone(Unit,CTLD.CargoZoneType.LOAD) if not inzone then ---@diagnostic disable-next-line: cast-local-type inzone, ship, zone, distance, width = self:IsUnitInZone(Unit,CTLD.CargoZoneType.SHIP) end - else + elseif drop and not pack then if self.dropcratesanywhere then -- #1570 inzone = true else inzone = self:IsUnitInZone(Unit,CTLD.CargoZoneType.DROP) end + elseif pack and not drop then + inzone = true end if not inzone then @@ -3229,6 +3238,42 @@ function CTLD:_BuildCrates(Group, Unit,Engineering) return self end +--- (Internal) Function to repair nearby vehicles / FOBs +-- @param #CTLD self +-- @param Wrapper.Group#GROUP Group +-- @param Wrapper.Unit#UNIT Unit + +function CTLD:_PackCratesNearby(Group, Unit) + self:T(self.lid .. " _PackCratesNearby") + ----------------------------------------- + -- search for nearest group to player + -- determine if group is packable + -- generate crates and destroy group + ----------------------------------------- + + -- get nearby vehicles + local location = Group:GetCoordinate() -- get coordinate of group using function + local nearestGroups = SET_GROUP:New():FilterCoalitions("blue"):FilterZones({ZONE_RADIUS:New("TempZone", location:GetVec2(), self.PackDistance, false)}):FilterOnce() -- get all groups withing PackDistance from group using function + -- get template name of all vehicles in zone + + -- determine if group is packable + for _, _Group in pairs(nearestGroups.Set) do -- convert #SET_GROUP to a list of Wrapper.Group#GROUP + for _, _Template in pairs(_DATABASE.Templates.Groups) do -- iterate through the database of templates + if (string.match(_Group:GetName(), _Template.GroupName)) then -- check if the Wrapper.Group#GROUP near the player is in the list of templates by name + -- generate crates and destroy group + for _, _entry in pairs(self.Cargo_Crates) do -- iterate through #CTLD_CARGO + if (_entry.Templates[1] == _Template.GroupName) then -- check if the #CTLD_CARGO matches the template name + _Group:Destroy() -- if a match is found destroy the Wrapper.Group#GROUP near the player + self:_GetCrates(Group, Unit, _entry, nil, false, true) -- spawn the appropriate crates near the player + return self + end + end + end + end + end + return self +end + --- (Internal) Function to repair nearby vehicles / FOBs -- @param #CTLD self -- @param Wrapper.Group#GROUP Group @@ -3541,6 +3586,7 @@ function CTLD:_RefreshF10Menus() if cancrates then local loadmenu = MENU_GROUP_COMMAND:New(_group,"Load crates",topcrates, self._LoadCratesNearby, self, _group, _unit) local cratesmenu = MENU_GROUP:New(_group,"Get Crates",topcrates) + local packmenu = MENU_GROUP_COMMAND:New(_group, "Pack crates", topcrates, self._PackCratesNearby, self, _group, _unit) if self.usesubcats then local subcatmenus = {}