From 995f898317a0db3e070dfed546119041fa12a3a1 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Sun, 14 May 2023 04:02:28 +0300 Subject: [PATCH 1/5] update build tools --- tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools b/tools index 0e821f3..fb458ac 160000 --- a/tools +++ b/tools @@ -1 +1 @@ -Subproject commit 0e821f3dbbc6b3528f2028b0060d3b6f7f1c4b93 +Subproject commit fb458ac61f7e6c6426b8dff366dd5e7499e0d95f From db05d95a84802089822bf3dfa14ee20f45fd359b Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Sun, 14 May 2023 04:02:50 +0300 Subject: [PATCH 2/5] add .editorconfig --- .editorconfig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b60821d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,32 @@ +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 + +# Unreal Engine 3 / Source +[*.uc] +indent_style = tab + +[*.{uci,upkg}] + +# Unreal Engine 3 / i18n +[*.{chn,cht,cze,dan,deu,dut,esl,esn,fra,frc,hun,int,ita,jpn,kor,pol,por,ptb,rus,tur,ukr}] +charset = utf-16le + +# Other +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_style = space +indent_size = 2 + +[*.{txt,cfg,conf}] +indent_style = tab From b3897611a1026786cc9c32fcb0c4bf889eaf6dcf Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Sun, 14 May 2023 04:03:26 +0300 Subject: [PATCH 3/5] add MegaLinter --- .github/workflows/mega-linter.yml | 72 +++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/mega-linter.yml diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml new file mode 100644 index 0000000..24897f3 --- /dev/null +++ b/.github/workflows/mega-linter.yml @@ -0,0 +1,72 @@ +--- +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 + +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 From 176e2b7fd8a7b682a8957ebbe5498e1dcb2378b6 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Sun, 14 May 2023 04:05:13 +0300 Subject: [PATCH 4/5] update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 563c347..fc5f969 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,17 @@ [![Steam Workshop](https://img.shields.io/static/v1?message=workshop&logo=steam&labelColor=gray&color=blue&logoColor=white&label=steam%20)](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) [![Steam Downloads](https://img.shields.io/steam/downloads/2864944858)](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) [![Steam Favorites](https://img.shields.io/steam/favorites/2864944858)](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) -[![Steam Update Date](https://img.shields.io/steam/update-date/2864944858)](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) +[![MegaLinter](https://github.com/GenZmeY/KF2-DroppedPickupLifespan/actions/workflows/mega-linter.yml/badge.svg?branch=master)](https://github.com/GenZmeY/KF2-DroppedPickupLifespan/actions/workflows/mega-linter.yml) [![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/GenZmeY/KF2-CustomTraderInventory)](https://github.com/GenZmeY/KF2-CustomTraderInventory/tags) [![GitHub](https://img.shields.io/github/license/GenZmeY/KF2-CustomTraderInventory)](LICENSE) -# Description +## Description Small server-side mutator that changes the lifespan of dropped weapons and dosh. -# Usage & Setup +## Usage & Setup [See steam workshop page](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) -# Build +## Build **Note:** If you want to build/test/brew/publish a mutator without git-bash and/or scripts, follow [these instructions](https://tripwireinteractive.atlassian.net/wiki/spaces/KF2SW/pages/26247172/KF2+Code+Modding+How-to) instead of what is described here. 1. Install [Killing Floor 2](https://store.steampowered.com/app/232090/Killing_Floor_2/), Killing Floor 2 - SDK and [git for windows](https://git-scm.com/download/win); 2. open git-bash and go to any folder where you want to store sources: @@ -27,5 +27,5 @@ Small server-side mutator that changes the lifespan of dropped weapons and dosh. 5. The compiled files will be here: `C:\Users\\Documents\My Games\KillingFloor2\KFGame\Unpublished\BrewedPC\Script\` -# License -[GNU GPLv3](LICENSE) +## License +[![license](https://www.gnu.org/graphics/gplv3-with-text-136x68.png)](LICENSE) From 762499ace157e998213818653902bbdcb679b562 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Sun, 14 May 2023 04:10:08 +0300 Subject: [PATCH 5/5] fix style --- DPL/Classes/DPL.uc | 36 ++++----- DPL/Classes/DPL.upkg | 8 +- DPL/Classes/DPLMut.uc | 118 ++++++++++++++--------------- DPL/Classes/Lifespan.uc | 84 ++++++++++---------- DPL/Classes/_Logger.uc | 40 +++++----- DPL/Constants.uci | 4 +- DPL/Globals.uci | 6 +- DPL/Logger.uci | 30 ++++---- PublicationContent/description.txt | 2 +- builder.cfg | 6 +- 10 files changed, 167 insertions(+), 167 deletions(-) diff --git a/DPL/Classes/DPL.uc b/DPL/Classes/DPL.uc index c2eae09..1c1abc0 100644 --- a/DPL/Classes/DPL.uc +++ b/DPL/Classes/DPL.uc @@ -19,58 +19,58 @@ var private config E_LogLevel LogLevel; public simulated function bool SafeDestroy() { `Log_Trace(); - + return (bPendingDelete || bDeleteMe || Destroy()); } public event PreBeginPlay() { `Log_Trace(); - + if (WorldInfo.NetMode == NM_Client) { `Log_Fatal("NetMode:" @ WorldInfo.NetMode); SafeDestroy(); return; } - + Super.PreBeginPlay(); - + Init(); } private function Init() { `Log_Trace(); - + if (Version == `NO_CONFIG) { LogLevel = LL_Info; SaveConfig(); } - + CfgLifespan.static.InitConfig(Version, LatestVersion, LogLevel); - + switch (Version) { case `NO_CONFIG: `Log_Info("Config created"); - + case MaxInt: `Log_Info("Config updated to version" @ LatestVersion); break; - + case LatestVersion: `Log_Info("Config is up-to-date"); break; - + default: `Log_Warn("The config version is higher than the current version (are you using an old mutator?)"); `Log_Warn("Config version is" @ Version @ "but current version is" @ LatestVersion); `Log_Warn("The config version will be changed to" @ LatestVersion); break; } - + if (LatestVersion != Version) { Version = LatestVersion; @@ -84,16 +84,16 @@ private function Init() SaveConfig(); } `Log_Base("LogLevel:" @ LogLevel); - + CfgLifespan.static.Load(LogLevel); - + `Log_Info("Initialized"); } public function ModifyLifespan(Actor A) { `Log_Trace(); - + switch (PickupType(A)) { case PT_Dosh: @@ -107,7 +107,7 @@ public function ModifyLifespan(Actor A) `Log_Debug("Skip modify dosh lifespan"); } break; - + case PT_Weapon: if (CfgLifespan.default.Weap > 0) { @@ -119,7 +119,7 @@ public function ModifyLifespan(Actor A) `Log_Debug("Skip modify weapon lifespan"); } break; - + case PT_Carryable: case PT_NotPickup: default: @@ -130,7 +130,7 @@ public function ModifyLifespan(Actor A) private function E_PickupType PickupType(Actor A) { `Log_Trace(); - + if (KFDroppedPickup_Cash(A) != None) { return PT_Dosh; @@ -143,7 +143,7 @@ private function E_PickupType PickupType(Actor A) { return PT_Weapon; } - + return PT_NotPickup; } diff --git a/DPL/Classes/DPL.upkg b/DPL/Classes/DPL.upkg index 7d148dd..ae6c83c 100644 --- a/DPL/Classes/DPL.upkg +++ b/DPL/Classes/DPL.upkg @@ -1,4 +1,4 @@ -[Flags] -AllowDownload=False -ClientOptional=False -ServerSideOnly=True +[Flags] +AllowDownload=False +ClientOptional=False +ServerSideOnly=True diff --git a/DPL/Classes/DPLMut.uc b/DPL/Classes/DPLMut.uc index 5b0b5cb..7fb3a7c 100644 --- a/DPL/Classes/DPLMut.uc +++ b/DPL/Classes/DPLMut.uc @@ -1,59 +1,59 @@ -class DPLMut extends KFMutator; - -var private DPL DPL; - -public simulated function bool SafeDestroy() -{ - return (bPendingDelete || bDeleteMe || Destroy()); -} - -public event PreBeginPlay() -{ - Super.PreBeginPlay(); - - if (WorldInfo.NetMode == NM_Client) return; - - foreach WorldInfo.DynamicActors(class'DPL', DPL) - { - break; - } - - if (DPL == None) - { - DPL = WorldInfo.Spawn(class'DPL'); - } - - if (DPL == None) - { - `Log_Base("FATAL: Can't Spawn 'DPL'"); - SafeDestroy(); - } -} - -public function AddMutator(Mutator Mut) -{ - if (Mut == Self) return; - - if (Mut.Class == Class) - Mut.Destroy(); - else - Super.AddMutator(Mut); -} - -public function bool CheckRelevance(Actor A) -{ - local bool Relevance; - - Relevance = Super.CheckRelevance(A); - if (Relevance) - { - DPL.ModifyLifespan(A); - } - - return Relevance; -} - -defaultproperties -{ - -} +class DPLMut extends KFMutator; + +var private DPL DPL; + +public simulated function bool SafeDestroy() +{ + return (bPendingDelete || bDeleteMe || Destroy()); +} + +public event PreBeginPlay() +{ + Super.PreBeginPlay(); + + if (WorldInfo.NetMode == NM_Client) return; + + foreach WorldInfo.DynamicActors(class'DPL', DPL) + { + break; + } + + if (DPL == None) + { + DPL = WorldInfo.Spawn(class'DPL'); + } + + if (DPL == None) + { + `Log_Base("FATAL: Can't Spawn 'DPL'"); + SafeDestroy(); + } +} + +public function AddMutator(Mutator Mut) +{ + if (Mut == Self) return; + + if (Mut.Class == Class) + Mut.Destroy(); + else + Super.AddMutator(Mut); +} + +public function bool CheckRelevance(Actor A) +{ + local bool Relevance; + + Relevance = Super.CheckRelevance(A); + if (Relevance) + { + DPL.ModifyLifespan(A); + } + + return Relevance; +} + +defaultproperties +{ + +} diff --git a/DPL/Classes/Lifespan.uc b/DPL/Classes/Lifespan.uc index 0e0d7bc..c3beea5 100644 --- a/DPL/Classes/Lifespan.uc +++ b/DPL/Classes/Lifespan.uc @@ -1,42 +1,42 @@ -class Lifespan extends Object - config(DPL) - abstract; - -var public config int Weap; -var public config int Dosh; - -public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel) -{ - `Log_TraceStatic(); - - switch (Version) - { - case `NO_CONFIG: - ApplyDefault(LogLevel); - - default: break; - } - - if (LatestVersion != Version) - { - StaticSaveConfig(); - } -} - -public static function Load(E_LogLevel LogLevel) -{ - `Log_TraceStatic(); -} - -protected static function ApplyDefault(E_LogLevel LogLevel) -{ - `Log_TraceStatic(); - - default.Weap = int(class'KFDroppedPickup'.default.Lifespan); - default.Dosh = int(class'KFDroppedPickup_Cash'.default.Lifespan); -} - -defaultproperties -{ - -} +class Lifespan extends Object + config(DPL) + abstract; + +var public config int Weap; +var public config int Dosh; + +public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel) +{ + `Log_TraceStatic(); + + switch (Version) + { + case `NO_CONFIG: + ApplyDefault(LogLevel); + + default: break; + } + + if (LatestVersion != Version) + { + StaticSaveConfig(); + } +} + +public static function Load(E_LogLevel LogLevel) +{ + `Log_TraceStatic(); +} + +protected static function ApplyDefault(E_LogLevel LogLevel) +{ + `Log_TraceStatic(); + + default.Weap = int(class'KFDroppedPickup'.default.Lifespan); + default.Dosh = int(class'KFDroppedPickup_Cash'.default.Lifespan); +} + +defaultproperties +{ + +} diff --git a/DPL/Classes/_Logger.uc b/DPL/Classes/_Logger.uc index 93fc28a..d9cfb52 100644 --- a/DPL/Classes/_Logger.uc +++ b/DPL/Classes/_Logger.uc @@ -1,20 +1,20 @@ -class _Logger extends Object - abstract; - -enum E_LogLevel -{ - LL_WrongLevel, - LL_None, - LL_Fatal, - LL_Error, - LL_Warning, - LL_Info, - LL_Debug, - LL_Trace, - LL_All -}; - -defaultproperties -{ - -} +class _Logger extends Object + abstract; + +enum E_LogLevel +{ + LL_WrongLevel, + LL_None, + LL_Fatal, + LL_Error, + LL_Warning, + LL_Info, + LL_Debug, + LL_Trace, + LL_All +}; + +defaultproperties +{ + +} diff --git a/DPL/Constants.uci b/DPL/Constants.uci index 1003f19..432fa68 100644 --- a/DPL/Constants.uci +++ b/DPL/Constants.uci @@ -1,2 +1,2 @@ -// Constants -`define NO_CONFIG 0 +// Constants +`define NO_CONFIG 0 diff --git a/DPL/Globals.uci b/DPL/Globals.uci index a48ac52..4dcd4fb 100644 --- a/DPL/Globals.uci +++ b/DPL/Globals.uci @@ -1,3 +1,3 @@ -// Imports -`include(Logger.uci) -`include(Constants.uci) +// Imports +`include(Logger.uci) +`include(Constants.uci) diff --git a/DPL/Logger.uci b/DPL/Logger.uci index c9e710a..6fe07c0 100644 --- a/DPL/Logger.uci +++ b/DPL/Logger.uci @@ -1,15 +1,15 @@ -// Logger -`define Log_Tag 'DPL' - -`define LocationStatic "`{ClassName}::" $ GetFuncName() - -`define Log_Base(msg, cond) `log(`msg `if(`cond), `cond`{endif}, `Log_Tag) - -`define Log_Fatal(msg) `log("FATAL:" @ `msg, (LogLevel >= LL_Fatal), `Log_Tag) -`define Log_Error(msg) `log("ERROR:" @ `msg, (LogLevel >= LL_Error), `Log_Tag) -`define Log_Warn(msg) `log("WARN:" @ `msg, (LogLevel >= LL_Warning), `Log_Tag) -`define Log_Info(msg) `log("INFO:" @ `msg, (LogLevel >= LL_Info), `Log_Tag) -`define Log_Debug(msg) `log("DEBUG:" @ `msg, (LogLevel >= LL_Debug), `Log_Tag) - -`define Log_Trace(msg) `log("TRACE:" @ `Location `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag) -`define Log_TraceStatic(msg) `log("TRACE:" @ `LocationStatic `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag) +// Logger +`define Log_Tag 'DPL' + +`define LocationStatic "`{ClassName}::" $ GetFuncName() + +`define Log_Base(msg, cond) `log(`msg `if(`cond), `cond`{endif}, `Log_Tag) + +`define Log_Fatal(msg) `log("FATAL:" @ `msg, (LogLevel >= LL_Fatal), `Log_Tag) +`define Log_Error(msg) `log("ERROR:" @ `msg, (LogLevel >= LL_Error), `Log_Tag) +`define Log_Warn(msg) `log("WARN:" @ `msg, (LogLevel >= LL_Warning), `Log_Tag) +`define Log_Info(msg) `log("INFO:" @ `msg, (LogLevel >= LL_Info), `Log_Tag) +`define Log_Debug(msg) `log("DEBUG:" @ `msg, (LogLevel >= LL_Debug), `Log_Tag) + +`define Log_Trace(msg) `log("TRACE:" @ `Location `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag) +`define Log_TraceStatic(msg) `log("TRACE:" @ `LocationStatic `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag) diff --git a/PublicationContent/description.txt b/PublicationContent/description.txt index 2ebf79b..8e3e1ab 100644 --- a/PublicationContent/description.txt +++ b/PublicationContent/description.txt @@ -12,7 +12,7 @@ https://forums.tripwireinteractive.com/index.php?threads/whitelisting-mods-and-m [h1]Usage (single player)[/h1] [olist] [*]Subscribe to this mutator; -[*]Start KF2; +[*]Start KF2; [*]Open console (~) and input: [b]open KF-BioticsLab?Mutator=DPL.DPLMut[/b] (replace the map and add the parameters you need) diff --git a/builder.cfg b/builder.cfg index b75f0c4..d9b0dd0 100644 --- a/builder.cfg +++ b/builder.cfg @@ -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="DPL" @@ -16,7 +16,7 @@ PackageBuildOrder="DPL" # 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="" @@ -24,7 +24,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="DPL"