1
0

add MegaLinter, .editorconfig and style fixes

This commit is contained in:
GenZmeY 2023-05-10 02:53:03 +03:00
parent e8ec59a852
commit 01497d35ca
12 changed files with 291 additions and 197 deletions

31
.editorconfig Normal file
View File

@ -0,0 +1,31 @@
root = true
# Global
[*]
indent_style = unset
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = unset
# Source
[*.{sh,bash,dash,ksh}]
indent_style = tab
insert_final_newline = true
[builder]
insert_final_newline = true
# Other
[*.md]
trim_trailing_whitespace = false
[*.yml]
indent_style = space
indent_size = 2
insert_final_newline = true
[*.{txt,cfg,conf}]
indent_style = tab

View File

@ -1,41 +1,47 @@
name: docs-autoupdate
on:
push:
branches:
- '*'
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update docs
run: |
if ! [[ -e USAGE.md ]]; then touch USAGE.md; fi
mv USAGE.md USAGE.md.old
mkdir tools
cp ./builder ./tools/
chmod +x ./tools/builder
echo '# KF2-BuildTools' >> USAGE.md
echo '[![title](https://img.shields.io/badge/Help-Page-w)](https://github.com/GenZmeY/KF2-BuildTools)' >> USAGE.md
echo '[![version](https://img.shields.io/github/v/tag/genzmey/KF2-BuildTools)](https://github.com/GenZmeY/KF2-BuildTools/tags)' >> USAGE.md
echo '[![docs-autoupdate](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml)' >> USAGE.md
echo '```' >> USAGE.md
./tools/builder -nch >> USAGE.md
echo '```' >> USAGE.md
if ! cmp -s USAGE.md USAGE.md.old; then
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions"
git add USAGE.md
git commit -m "Update USAGE.md to version $(git describe 2> /dev/null)"
else
echo "No change, skip updating USAGE.md"
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
---
name: docs-autoupdate
# checkov:skip=CKV2_GHA_1:Write permission is needed to push changes to the repository
permissions: write-all
on:
push:
branches:
- '*'
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update docs
run: |
if ! [[ -e USAGE.md ]]; then touch USAGE.md; fi
mv USAGE.md USAGE.md.old
mkdir tools
cp ./builder ./tools/
chmod +x ./tools/builder
{
echo '# KF2-BuildTools'
echo '[![title](https://img.shields.io/badge/Help-Page-w)](https://github.com/GenZmeY/KF2-BuildTools)'
echo '[![version](https://img.shields.io/github/v/tag/genzmey/KF2-BuildTools)](https://github.com/GenZmeY/KF2-BuildTools/tags)'
echo '[![docs-autoupdate](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml)'
echo '```text'
./tools/builder -nch
echo '```'
} >> USAGE.md
if ! cmp -s USAGE.md USAGE.md.old; then
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions"
git add USAGE.md
git commit -m "Update USAGE.md to version $(git describe 2> /dev/null)"
else
echo "No change, skip updating USAGE.md"
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

73
.github/workflows/mega-linter.yml vendored Normal file
View File

@ -0,0 +1,73 @@
---
name: MegaLinter
permissions: read-all
on:
push:
pull_request:
branches: [master]
env:
APPLY_FIXES: none
APPLY_FIXES_EVENT: pull_request
APPLY_FIXES_MODE: commit
DISABLE: SPELL
DISABLE_ERRORS_LINTERS: REPOSITORY_CHECKOV # Barks at write-permission on docs-autoupdate.yml which I need
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
build:
name: MegaLinter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
- name: MegaLinter
id: ml
uses: oxsecurity/megalinter@v6
env:
VALIDATE_ALL_CODEBASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Archive production artifacts
if: ${{ success() }} || ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log
- name: Create Pull Request with applied fixes
id: cpr
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
commit-message: "[MegaLinter] Apply linters automatic fixes"
title: "[MegaLinter] Apply linters automatic fixes"
labels: bot
- name: Create PR output
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
- name: Prepare commit
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
run: sudo chown -Rc $UID .git/
- name: Commit and push applied linter fixes
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
commit_message: "[MegaLinter] Apply linters fixes"
commit_user_name: megalinter-bot
commit_user_email: nicolas.vuillamy@ox.security

View File

@ -1,20 +0,0 @@
name: shellcheck-dev
on:
push:
branches:
- '*'
- '!master'
jobs:
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -x
with:
additional_files: 'builder'

View File

@ -1,19 +0,0 @@
name: shellcheck
on:
push:
branches:
- master
jobs:
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -x
with:
additional_files: 'builder'

22
.github/workflows/shellcheck.yml vendored Normal file
View File

@ -0,0 +1,22 @@
---
name: shellcheck
permissions: read-all
on:
push:
branches:
- master
jobs:
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -x
with:
additional_files: 'builder'

4
.gitignore vendored
View File

@ -1,2 +1,2 @@
3rd-party-bin
shellcheck.exe
3rd-party-bin
shellcheck.exe

View File

@ -7,7 +7,7 @@ StripSource="True"
# Mutators to be compiled
# Specify them with a space as a separator,
# Mutators will be compiled in the specified order
# Mutators will be compiled in the specified order
PackageBuildOrder="SomePackageName SomePackageNameMut"
@ -15,7 +15,7 @@ PackageBuildOrder="SomePackageName SomePackageNameMut"
# Mutators that will be uploaded to the workshop
# Specify them with a space as a separator,
# The order doesn't matter
# The order doesn't matter
PackageUpload="SomePackageName SomePackageNameMut"

View File

@ -1,26 +1,27 @@
# KF2-BuildTools
[![version](https://img.shields.io/github/v/tag/genzmey/KF2-BuildTools)](https://github.com/GenZmeY/KF2-BuildTools/tags)
[![shellcheck](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/shellcheck-master.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/shellcheck-master.yml)
[![MegaLinter](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/mega-linter.yml/badge.svg?branch=master)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/mega-linter.yml)
[![docs-autoupdate](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml)
[![license](https://img.shields.io/github/license/GenZmeY/KF2-Server-Extension)](LICENSE)
# Features:
## Features
- Build, brew, test and upload to Steam Workshop;
- No need to edit KFEditor.ini at all;
- Sources can be stored in any path;
- Easily switch between different projects.
# Requirements
## Requirements
- [Killing Floor 2](https://store.steampowered.com/app/232090/Killing_Floor_2/);
- Killing Floor 2 - SDK;
- [git-bash](https://git-scm.com/download/win).
# Add to your project
## Add to your project
Make sure that the location of folders and files in your project as follows (Correct it if it's not):
`/<PackageName>/Classes/*.uc`
**There are two ways to add KF2-BuildTools to your project:**
## 1. As [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
### 1. As [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
Open git-bash and go to your project: `cd <your_project_path>`
Add submodule: `git submodule add https://github.com/GenZmeY/KF2-BuildTools tools`
@ -28,18 +29,18 @@ Add submodule: `git submodule add https://github.com/GenZmeY/KF2-BuildTools tool
Get updates: `pushd tools && git pull && popd`
Commit the changes: `git add tools && git commit -m 'update tools'`
## 2. As standalone script
### 2. As standalone script
Just create a `tools` folder and put [builder](builder) there.
Now you can use the script in the same way as in the first case, but you will have to update it yourself.
# Usage
## Usage
Available commands can be found here: [USAGE.md](USAGE.md)
If you have a simple mutator or game mode, then the usage is also simple: just use [the commands](USAGE.md) to compile, test and upload to the steam workshop.
![demo](example.gif)
## The result can be found here:
### The result can be found here
**Compiled packages:**
`C:\Users\<username>\Documents\My Games\KillingFloor2\KFGame\Unpublished\`
@ -49,20 +50,20 @@ If you have a simple mutator or game mode, then the usage is also simple: just u
**Uploaded packages:**
your steam workshop 🙃
# Usage (Advanced)
If your project contains several mutators, *.upk files, external dependencies, or you want to customize the whole process in more details, then this section is for you.
## Usage (Advanced)
If your project contains several mutators, *.upk files, external dependencies, or you want to customize the whole process in more details, then this section is for you.
## Setup
### Setup
When you run compilation for the first time or do `./tools/builder --init` `builder.cfg` appears in your project folder.
Edit it to set build/test/upload options. The config contains the necessary comments inside.
Edit the files in the `PublicationContent` folder - they are responsible for the description in the Steam Workshop.
## Project filesystem
### Project filesystem
If you have *.upk or localization files, they must be in a specific location.
Change the filesystem of the project to such a form that everything works correctly:
```
```text
/SomePackageName1
*.upk
/Classes
@ -84,7 +85,7 @@ Change the filesystem of the project to such a form that everything works correc
/Config
*.ini
/BrewedPC
*.*
*.*
/tools
builder
builder.cfg
@ -93,7 +94,7 @@ builder.cfg
**Note:** Use the `BrewedPC` folder for additional content such as sound files for your weapons or other stuff. This will be copied to the final BrewedPC before being uploaded to the workshop.
By the way, this allows you to use a script to upload maps (although this was not its original purpose). Just put the map(s) in `BrewedPC` (don't forget to edit the `PublicationContent`) and run `./tools/builder -u`.
## Examples (Projects that use KF2-BuildTools)
### Examples (Projects that use KF2-BuildTools)
**Simplest case (one mutator):**
- [AdminAutoLogin](https://github.com/GenZmeY/KF2-AdminAutoLogin)
- [StartWave](https://github.com/GenZmeY/KF2-StartWave)
@ -112,5 +113,5 @@ By the way, this allows you to use a script to upload maps (although this was no
**two mutators are uploaded to the steam workshop:**
- [UnofficialMod](https://github.com/GenZmeY/UnofficialMod)
# License
## License
[GNU GPLv3](LICENSE)

View File

@ -1,2 +1,2 @@
# TODO:
# TODO
- [ ] improve error parser (class vs name mismatch, etc...)

View File

@ -2,7 +2,7 @@
[![title](https://img.shields.io/badge/Help-Page-w)](https://github.com/GenZmeY/KF2-BuildTools)
[![version](https://img.shields.io/github/v/tag/genzmey/KF2-BuildTools)](https://github.com/GenZmeY/KF2-BuildTools/tags)
[![docs-autoupdate](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml)
```
```text
Usage: ./tools/builder OPTIONS
Compile, brew, test and upload your kf2 packages to the Steam Workshop.

192
builder
View File

@ -37,11 +37,11 @@ function reg_readkey () # $1: path, $2: key
function steamlib_by_steamid () # $1: SteamID
{
local Path
if ! [[ -f "$SteamLibFoldersVdf" ]]; then
return
fi
while read -r Line
do
if echo "$Line" | grep -Foq '"path"'; then
@ -154,7 +154,7 @@ function get_latest () # $1: Reponame, $2: filename, $3: output filename
local LatestTag=""
LatestTag="$(curl --silent "$ApiUrl" | grep -Po '"tag_name": "\K.*?(?=")')"
local DownloadUrl="https://github.com/$1/releases/download/$LatestTag/$2"
msg "download $2 ($LatestTag)"
mkdir -p "$(dirname "$3")/"
curl -LJs "$DownloadUrl" -o "$3"
@ -176,7 +176,7 @@ function repo_url () # $1: remote.origin.url
if echo "$1" | grep -qoP '^https?://'; then
echo "$1" | sed -r 's|\.git||'
else
echo "$1" | sed -r 's|^.+:(.+)\.git$|https://github.com/\1|'
echo "$1" | sed -r 's|^.+:(.+)\.git$|https://github.com/\1|'
fi
}
@ -224,7 +224,7 @@ function warn () # $1: String
function usage ()
{
local HelpMessage=""
HelpMessage="$(cat <<EOF
${BLD}Usage:${DEF} $0 OPTIONS
@ -257,7 +257,7 @@ EOF
function version ()
{
local Version=""
Version="$(git describe 2> /dev/null)"
if [[ -z "$Version" ]]; then
Version="(standalone)"
@ -309,7 +309,7 @@ function init ()
local DefMap=""
local BaseList=""
local BaseListNext=""
if [[ -e "$MutBuilderConfig" ]]; then
if is_true "$ArgForce"; then
msg "rewriting $(basename "$MutBuilderConfig")"
@ -317,7 +317,7 @@ function init ()
else
msg "creating new $(basename "$MutBuilderConfig")"
fi
if [[ -d "$MutBrewedPCAddon" ]]; then
while read -r Map
do
@ -338,14 +338,14 @@ function init ()
PackageList="$PackageList $Package"
fi
done < <(find "$MutSource" -mindepth 2 -maxdepth 2 -type d -ipath '*/Classes' | sed -r 's|.+/([^/]+)/[^/]+|\1|' | sort)
if [[ -n "$PackageList" ]]; then
msg "packages found: $(print_list "$PackageList" ", ")"
fi
# DISCLAMER: BigO nightmare (*)
# Remove seniors with a weak psyche from the screen
#
#
# (*) As planned though:
# Initialized once and quickly even on large projects,
# There is no point in optimizing this
@ -377,7 +377,7 @@ function init ()
BaseList="$BaseListNext"
BaseListNext=""
done
# find available gamemodes
BaseList='KFGameInfo_'
BaseListNext=''
@ -409,23 +409,23 @@ function init ()
BaseListNext=""
done
fi
if [[ -n "$AviableMutators" ]]; then
msg "mutators found: $(print_list "$AviableMutators" ", ")"
fi
if [[ -z "$AviableGamemodes" ]]; then
DefGamemode="KFGameContent.KFGameInfo_Survival"
else
msg "custom gamemodes found: $(print_list "$AviableGamemodes" ", ")"
fi
if [[ -z "$AviableMaps" ]]; then
DefMap="KF-Nuked"
else
msg "maps found: $(print_list "$AviableMaps" ", ")"
fi
if is_true "$ArgForce" || ! [[ -e "$MutBuilderConfig" ]]; then
cat > "$MutBuilderConfig" <<EOF
### Build parameters ###
@ -437,7 +437,7 @@ StripSource="True"
# Mutators to be compiled
# Specify them with a space as a separator,
# Mutators will be compiled in the specified order
# Mutators will be compiled in the specified order
PackageBuildOrder="$PackageList"
@ -446,7 +446,7 @@ PackageBuildOrder="$PackageList"
# Packages you want to brew using @peelz's patched KFEditor.
# Useful for cases where regular brew doesn't put *.upk inside the package.
# Specify them with a space as a separator,
# The order doesn't matter
# The order doesn't matter
PackagePeelzBrew=""
@ -454,7 +454,7 @@ PackagePeelzBrew=""
# Mutators that will be uploaded to the workshop
# Specify them with a space as a separator,
# The order doesn't matter
# The order doesn't matter
PackageUpload="$PackageList"
@ -492,16 +492,16 @@ Args=""
EOF
msg "$(basename "$MutBuilderConfig") created" "${GRN}"
fi
if ! [[ -d "$MutPubContent" ]]; then mkdir -p "$MutPubContent"; fi
ProjectName="$(basename "$(readlink -e "$MutSource")")"
if is_true "$ArgForce" || ! [[ -e "$MutPubContentTitle" ]]; then
echo "$ProjectName" > "$MutPubContentTitle"
msg "$(basename "$MutPubContentTitle") created" "${GRN}"
fi
if is_true "$ArgForce" || ! [[ -e "$MutPubContentDescription" ]]; then
:> "$MutPubContentDescription"
if [[ -n "$AviableGamemodes" ]] || [[ -n "$AviableMutators" ]] || [[ -n "$AviableMaps" ]]; then
@ -517,7 +517,7 @@ EOF
fi
echo "" >> "$MutPubContentDescription"
fi
GitRemoteUrl="$(repo_url "$(git config --get remote.origin.url)")"
if [[ -n "$GitRemoteUrl" ]]; then
{
@ -526,7 +526,7 @@ EOF
echo ""
} >> "$MutPubContentDescription"
fi
GitUsername="$(git config --get user.name)"
if [[ -n "$GitUsername" ]]; then
{
@ -535,10 +535,10 @@ EOF
echo ""
} >> "$MutPubContentDescription"
fi
msg "$(basename "$MutPubContentDescription") created" "${GRN}"
fi
if is_true "$ArgForce" || [[ "$(preview_extension)" == "None" ]]; then
if [[ -e "$DummyPreview" ]]; then
cp -f "$DummyPreview" "${MutPubContentPreview}.png"
@ -547,7 +547,7 @@ EOF
fi
msg "$(basename "${MutPubContentPreview}.png") created" "${GRN}"
fi
if is_true "$ArgForce" || ! [[ -e "$MutPubContentTags" ]]; then
:> "$MutPubContentTags"
if [[ -n "$AviableGamemodes" ]]; then
@ -574,14 +574,14 @@ function preview_extension ()
return 0
fi
done
echo "None"
}
function read_settings ()
{
if ! [[ -f "$MutBuilderConfig" ]]; then init; fi
if bash -n "$MutBuilderConfig"; then
# shellcheck source=./.shellcheck/builder.cfg
source "$MutBuilderConfig"
@ -595,9 +595,9 @@ function merge_package () # $1: What, $2: Where
local ModificationTime=""
local ModificationTimeNew=""
local PID=""
msg "merge $1 into $2"
if is_true "$ArgHoldEditor"; then
pushd "$KFWin64" &> /dev/null
CMD //C "$(basename "$KFEditorMergePackages")" make "$1" "$2"
@ -627,16 +627,16 @@ function merge_package () # $1: What, $2: Where
sleep 1
done
fi
rm -f "$KFWin64/$1" # cleanup (manual)
}
function merge_packages () # $1: Mutator name
{
msg "merge packages for $1.u"
cp -f "$KFUnpublishScript/$1.u" "$KFWin64"
while read -r Upk
do
cp -f "$Upk" "$KFWin64"
@ -653,7 +653,7 @@ function parse_log () # $1: Logfile
local Message=''
local I=1
if grep -qP ' Error:(.+:)? Error, ' "$1"; then # check to prevent a very strange crash
if grep -qP ' Error:(.+:)? Error, ' "$1"; then # check to prevent a very strange crash
while read -r Error
do
if [[ -z "$Error" ]]; then break; fi
@ -670,7 +670,7 @@ function parse_log () # $1: Logfile
((I+=1))
done < <(grep -P ' Error:(.+:)? Error, ' "$1")
fi
if grep -qP ' Warning:(.+:)? Warning, ' "$1"; then # and here too
while read -r Warning
do
@ -711,49 +711,49 @@ function compile ()
local StripSourceArg=""
local PID=""
local Logfile=""
read_settings
if ! command -v multini &> /dev/null; then
get_latest_multini "$ThirdPartyBin/multini.exe"
fi
if [[ -z "$PackageBuildOrder" ]]; then
die "No packages found! Check project filesystem, fix config and try again"
fi
multini --del "$KFEditorConf" 'ModPackages' 'ModPackages'
for Package in $PackageBuildOrder
do
multini --add "$KFEditorConf" 'ModPackages' 'ModPackages' "$Package"
done
multini --set "$KFEditorConf" 'ModPackages' 'ModPackagesInPath' "$(cygpath -w "$MutSource")"
rm -rf "$KFUnpublish" "$KFPublish"
mkdir -p "$KFUnpublishPackages" "$KFUnpublishScript"
for Package in $PackageBuildOrder
do
find "$MutSource/$Package" -type f -iname '*.upk' -not -ipath "*/Weapons/*" -exec cp -f {} "$KFUnpublishPackages" \;
find "$MutSource/$Package" -type d -iname 'WwiseAudio' -exec cp -rf {} "$KFUnpublishBrewedPC" \;
find "$MutSource/$Package" -type d -iname 'Weapons' -exec cp -rf {} "$KFUnpublishPackages" \;
done
if [[ -d "$MutLocalization" ]]; then
mkdir -p "$KFUnpublishLocalization"
cp -rf "$MutLocalization"/* "$KFUnpublishLocalization"
fi
if [[ -d "$MutConfig" ]]; then
mkdir -p "$KFUnpublishConfig"
cp -rf "$MutConfig"/* "$KFUnpublishConfig"
fi
if is_true "$StripSource"; then StripSourceArg="-stripsource"; fi
msg "compilation"
if is_true "$ArgHoldEditor"; then
CMD //C "$(cygpath -w "$KFEditor")" make $StripSourceArg -useunpublished
parse_log "$(find_log)"
@ -770,7 +770,7 @@ function compile ()
Logfile="$(find_log)"
if compiled; then
msg "successfully compiled" "${GRN}"
msg "wait for the log"
while ! grep -qF 'Log file closed' "$Logfile"
do
@ -786,7 +786,7 @@ function compile ()
fi
done
fi
find "$KFUnpublish" -type d -empty -delete
}
@ -796,12 +796,12 @@ function publish_common ()
mkdir -p "$KFPublishLocalization"
cp -rf "$MutLocalization"/* "$KFPublishLocalization"
fi
if [[ -d "$MutConfig" ]]; then
mkdir -p "$KFPublishConfig"
cp -rf "$MutConfig"/* "$KFPublishConfig"
fi
if [[ -d "$MutBrewedPCAddon" ]]; then
mkdir -p "$KFPublishBrewedPC"
cp -rf "$MutBrewedPCAddon"/* "$KFPublishBrewedPC"
@ -833,15 +833,15 @@ function brew ()
{
local PackageBrew=""
local PID=""
msg "brewing"
read_settings
if ! compiled; then
die "You must compile packages before brewing. Use --compile option for this." 2
fi
if [[ -z "$PackagePeelzBrew" ]]; then
PackageBrew="$PackageBuildOrder"
else
@ -852,17 +852,17 @@ function brew ()
fi
done
fi
rm -rf "$KFPublish"
mkdir -p "$KFPublishBrewedPC" "$KFPublishPackages"
for Package in $PackageBuildOrder
do
find "$MutSource/$Package" -type d -iname 'WwiseAudio' -exec cp -rf {} "$KFPublishBrewedPC" \;
find "$MutSource/$Package" -type d -iname 'Weapons' -exec cp -rf {} "$KFPublishPackages" \;
done
if [[ -n "$PackageBrew" ]]; then
if is_true "$ArgHoldEditor"; then
pushd "$KFWin64" &> /dev/null
@ -887,20 +887,20 @@ function brew ()
die "brewing failed"
fi
fi
if [[ -n "$PackagePeelzBrew" ]]; then
msg "peelz brewing"
if ! [[ -x "$KFEditorPatcher" ]]; then
get_latest_kfeditor_patcher "$KFEditorPatcher"
fi
msg "patching $(basename "$KFEditor")"
pushd "$KFWin64" &> /dev/null
CMD //C "$(basename "$KFEditorPatcher")"
popd &> /dev/null
msg "successfully patched" "${GRN}"
for Package in $PackagePeelzBrew
do
merge_packages "$Package"
@ -908,20 +908,20 @@ function brew ()
find "$MutSource/$Package" -type f -iname '*.upk' -not -ipath '*/Weapons/*' -printf "%f\n" | xargs -I{} find "$KFPublishBrewedPC" -type f -iname {} -delete
done
fi
msg "successfully brewed" "${GRN}"
rm -f "$KFPublishBrewedPC"/*.tmp
find "$KFPublish" -type d -empty -delete
}
function publish_unpublished ()
{
warn "uploading without brewing${DEF}"
mkdir -p "$KFPublishBrewedPC" "$KFPublishScript" "$KFPublishPackages"
for Package in $PackageUpload
do
cp -f "$KFUnpublishScript/$Package.u" "$KFPublishScript"
@ -929,7 +929,7 @@ function publish_unpublished ()
find "$MutSource/$Package" -type d -iname 'WwiseAudio' -exec cp -rf {} "$KFPublishBrewedPC" \;
find "$MutSource/$Package" -type d -iname 'Weapons' -exec cp -rf {} "$KFPublishPackages" \;
done
find "$KFPublish" -type d -empty -delete
}
@ -938,36 +938,36 @@ function upload ()
local PreparedWsDir=""
local Preview=""
local Success="False"
read_settings
if ! compiled && ! test -d "$MutBrewedPCAddon"; then
die "You must compile packages before uploading. Use --compile option for this." 2
fi
if [[ -d "$KFPublish" ]]; then
brew_cleanup
elif [[ -d "$KFUnpublish" ]]; then
publish_unpublished
fi
publish_common
Preview="${MutPubContentPreview}.$(preview_extension)"
if ! [[ -e "$Preview" ]]; then
die "No preview image in PublicationContent" 2
elif [[ $(stat --printf="%s" "$Preview") -ge 1048576 ]]; then
warn "The size of $(basename "$Preview") is greater than 1mb. Steam may prevent you from loading content with this image. if you get an error while loading - try using a smaller preview."
fi
if grep -Fq '"' "$MutPubContentDescription"; then
warn "Double quotes (\") found in $(basename "$MutPubContentDescription"), this may prevent the item from being uploaded to the workshop"
warn "Remove double quotes if there are problems uploading to the workshop"
fi
find "$KFPublish" -type d -empty -delete
# it's a bad idea to use the $KFPublish folder for upload
# because in that case some files won't get uploaded to the workshop for some reason
# so create a temporary folder to get around this
@ -981,9 +981,9 @@ function upload ()
\$MicroTxItem "false"
\$PackageDirectory "$(cygpath -w "$PreparedWsDir")"
EOF
cp -rf "$KFPublish" "$PreparedWsDir"
msg "upload to steam workshop"
while read -r Output
do
@ -994,10 +994,10 @@ EOF
err "UploadTool: $Output"
fi
done < <("$KFWorkshop" "$(basename "$MutWsInfo")" 2>&1)
rm -rf "$PreparedWsDir"
rm -f "$MutWsInfo"
if is_true "$Success"; then
msg "successfully uploaded to steam workshop" "${GRN}"
else
@ -1008,16 +1008,16 @@ EOF
function run_test ()
{
local UseUnpublished=""
read_settings
if brewed "$PackageBuildOrder"; then
msg "run test (brewed)"
else
UseUnpublished="-useunpublished"
msg "run test (unpublished)"
fi
CMD //C "$(cygpath -w "$KFGame")" "$Map?Difficulty=$Difficulty?GameLength=$GameLength?Game=$Game?Mutator=$Mutators?$Args" $UseUnpublished -log
}
@ -1026,7 +1026,7 @@ function parse_combined_params () # $1: Combined short parameters
local Param="${1}"
local Length="${#Param}"
local Position=1
while true
do
if [[ "$Position" -ge "$Length" ]]; then break; fi
@ -1034,7 +1034,7 @@ function parse_combined_params () # $1: Combined short parameters
he ) ((Position+=2)); ArgHoldEditor="true" ;;
nc ) ((Position+=2)); ArgNoColors="true" ;;
esac
if [[ "$Position" -ge "$Length" ]]; then break; fi
case "${Param:$Position:1}" in
h ) ((Position+=1)); ArgHelp="true" ;;
@ -1083,41 +1083,41 @@ function main ()
parse_params "$@"
setup_colors
export PATH="$PATH:$ThirdPartyBin"
# Modifiers
if is_true "$ArgDebug"; then set -o xtrace; fi
# Help
if is_true "$ArgVersion" && is_true "$ArgHelp"; then version; usage; die "" 0; fi
if is_true "$ArgVersion"; then version; die "" 0; fi
if is_true "$ArgHelp"; then usage; die "" 0; fi
# Checks
if [[ -z "$KFSteamLibraryFolder" ]]; then
err "\"Killing Floor 2\" not found"
fi
if [[ -z "$KFSDKSteamLibraryFolder" ]]; then
err "\"Killing Floor 2 - SDK\" not found"
fi
if [[ -z "$KFSteamLibraryFolder" ]] || [[ -z "$KFSDKSteamLibraryFolder" ]]; then
die "" 1
elif [[ "$KFPath" != "$KFSDKPath" ]]; then
warn "\"Killing Floor 2\" and \"Killing Floor 2 - SDK\" installed in different steam library folders."
warn "If you get errors, install them in the same steam library folder."
fi
# Backup
if is_true "$ArgCompile" || is_true "$ArgBrew"; then backup_kfeditorconf; fi
# Actions
if is_true "$ArgInit"; then init; fi
if is_true "$ArgCompile"; then compile; fi
if is_true "$ArgBrew"; then brew; fi
if is_true "$ArgUpload"; then upload; fi
if is_true "$ArgTest"; then run_test; fi
# Restore
if is_true "$ArgCompile" || is_true "$ArgBrew"; then restore_kfeditorconf; fi
}