From 5ecd0ed3de37f554058261e62c022301fe326539 Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:03:00 +0200 Subject: [PATCH 1/5] Fix performances issues when taking materials from crate and the Upgrade option is On --- CHANGELOG.md | 9 +++++++- Harmony/TileEntityEfficientBaseRepair.cs | 27 +++++++++++++++--------- ModInfo.xml | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ea728b..162979b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] +## [0.1.1] - 2024-06-09 + +### Fixed + +- Fix performances issues when taking materials from crate and the Upgrade option is On + ## [0.1.0] - 2024-06-09 ### Fixed @@ -52,7 +58,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - Set the repairation algorithm parametrizable from xml files -[unreleased]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.1.0...unreleased +[unreleased]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/master...unreleased +[0.1.0]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.1.0...0.1.1 [0.1.0]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.0.3...0.1.0 [0.0.3]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.0.2...0.0.3 [0.0.2]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.0.1...0.0.2 diff --git a/Harmony/TileEntityEfficientBaseRepair.cs b/Harmony/TileEntityEfficientBaseRepair.cs index 721a7ea..aa20171 100644 --- a/Harmony/TileEntityEfficientBaseRepair.cs +++ b/Harmony/TileEntityEfficientBaseRepair.cs @@ -45,7 +45,9 @@ public class TileEntityEfficientBaseRepair : TileEntitySecureLootContainer //TOD public bool upgradeOn; - private bool forceRefresh; + private bool forceFullRefresh; + + private bool forceRefreshMaterials; public bool IsOn => isOn; @@ -502,7 +504,7 @@ public void AnalyseStructure(Vector3i initial_pos) public void ForceRefresh() { - forceRefresh = true; + forceFullRefresh = true; setModified(); } @@ -515,7 +517,7 @@ private void RefreshStats(World world) bfsIterationsCount = 0; visitedBlocksCount = 0; totalDamagesCount = 0; - forceRefresh = false; + forceFullRefresh = false; AnalyseStructure(ToWorldPos()); RefreshMaterialsStats(); @@ -523,6 +525,8 @@ private void RefreshStats(World world) private void RefreshMaterialsStats() { + forceRefreshMaterials = false; + if (blocksToRepair == null) return; @@ -567,7 +571,7 @@ private void RefreshMaterialsStats() public void Switch(bool forceRefresh_ = false) { if (forceRefresh_) - forceRefresh = true; + forceFullRefresh = true; isOn = !isOn; Logging($"Switch TileEntity to {isOn}"); @@ -578,6 +582,7 @@ public void Switch(bool forceRefresh_ = false) public void SwitchUpgrade() { upgradeOn = !upgradeOn; + forceRefreshMaterials = true; setModified(); } @@ -590,7 +595,8 @@ public override void read(PooledBinaryReader _br, StreamModeRead _eStreamMode) return; upgradeOn = _br.ReadBoolean(); - forceRefresh = _br.ReadBoolean(); + forceRefreshMaterials = _br.ReadBoolean(); + forceFullRefresh = _br.ReadBoolean(); damagedBlockCount = _br.ReadInt32(); totalDamagesCount = _br.ReadInt32(); visitedBlocksCount = _br.ReadInt32(); @@ -629,13 +635,13 @@ public override void read(PooledBinaryReader _br, StreamModeRead _eStreamMode) return; // force refresh on server side if he receives the param forceRefresh=true from client. - if (forceRefresh) + if (forceFullRefresh) { Log.Out("[EfficientBaseRepair] Refresh forced from server."); RefreshStats(GameManager.Instance.World); setModified(); } - else + else if (forceRefreshMaterials) { RefreshMaterialsStats(); setModified(); @@ -651,7 +657,8 @@ public override void write(PooledBinaryWriter _bw, StreamModeWrite _eStreamMode) return; _bw.Write(upgradeOn); - _bw.Write(forceRefresh); + _bw.Write(forceRefreshMaterials); + _bw.Write(forceFullRefresh); _bw.Write(damagedBlockCount); _bw.Write(totalDamagesCount); _bw.Write(visitedBlocksCount); @@ -682,12 +689,12 @@ public override void write(PooledBinaryWriter _bw, StreamModeWrite _eStreamMode) // trigger forceRefresh=true in single player mode // TODO: try with SingletonMonoBehaviour.Instance.IsSinglePlayer - if (forceRefresh) + if (forceFullRefresh) { Log.Out("[EfficientBaseRepair] Refresh forced from Client."); RefreshStats(GameManager.Instance.World); } - else + else if (forceRefreshMaterials) { RefreshMaterialsStats(); } diff --git a/ModInfo.xml b/ModInfo.xml index 16cb218..0fcdaad 100644 --- a/ModInfo.xml +++ b/ModInfo.xml @@ -4,6 +4,6 @@ - + \ No newline at end of file From dab2176f65d5e9103746bf85e36677a55342e24c Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:29:51 +0200 Subject: [PATCH 2/5] refactor ci scripts --- Scripts/compile.cmd | 22 +++++++++++++++++++++- Scripts/release.cmd | 31 ------------------------------- Scripts/shut-down.cmd | 4 ++++ Scripts/start-dedi.cmd | 4 ++-- Scripts/start-local.cmd | 17 +++++++++++++++++ 5 files changed, 44 insertions(+), 34 deletions(-) delete mode 100644 Scripts/release.cmd create mode 100644 Scripts/shut-down.cmd create mode 100644 Scripts/start-local.cmd diff --git a/Scripts/compile.cmd b/Scripts/compile.cmd index 9a6cedd..95ec53f 100644 --- a/Scripts/compile.cmd +++ b/Scripts/compile.cmd @@ -1,3 +1,23 @@ @echo off -dotnet build --no-incremental .\EfficientBaseRepair.csproj \ No newline at end of file +dotnet build --no-incremental .\EfficientBaseRepair.csproj + +if ERRORLEVEL 1 exit /b 1 + +if exist "EfficientBaseRepair.zip" DEL "EfficientBaseRepair.zip" + +if exist ".\EfficientBaseRepair" rmdir ".\EfficientBaseRepair" /s /q + +MKDIR .\EfficientBaseRepair + +xcopy Config EfficientBaseRepair\Config\ /s > nul +xcopy *.dll EfficientBaseRepair\ > nul +xcopy *.md EfficientBaseRepair\ > nul +xcopy ModInfo.xml EfficientBaseRepair\ > nul + +7z.exe a "EfficientBaseRepair.zip" EfficientBaseRepair > nul + +rmdir ".\EfficientBaseRepair" /s /q + +DEL EfficientBaseRepair.dll +DEL EfficientBaseRepair.pdb diff --git a/Scripts/release.cmd b/Scripts/release.cmd deleted file mode 100644 index a7e2118..0000000 --- a/Scripts/release.cmd +++ /dev/null @@ -1,31 +0,0 @@ -@echo off - -call ".\Scripts\compile.cmd" - -if %ERRORLEVEL% neq 0 exit /b 1 - -if exist "EfficientBaseRepair.zip" DEL "EfficientBaseRepair.zip" - -if exist ".\EfficientBaseRepair" rmdir ".\EfficientBaseRepair" /s /q - -MKDIR .\EfficientBaseRepair - -xcopy Config EfficientBaseRepair\Config\ /s > nul -xcopy *.dll EfficientBaseRepair\ > nul -xcopy *.md EfficientBaseRepair\ > nul -xcopy ModInfo.xml EfficientBaseRepair\ > nul - -7z.exe a "EfficientBaseRepair.zip" EfficientBaseRepair > nul - -rmdir ".\EfficientBaseRepair" /s /q - -DEL EfficientBaseRepair.dll -DEL EfficientBaseRepair.pdb - -set MOD_PATH="%PATH_7D2D%\Mods\EfficientBaseRepair" - -if exist %MOD_PATH% RMDIR /s /q %MOD_PATH% - -cd %MOD_PATH%\.. - -7z.exe x "%~dp0..\EfficientBaseRepair.zip" > nul diff --git a/Scripts/shut-down.cmd b/Scripts/shut-down.cmd new file mode 100644 index 0000000..06201a3 --- /dev/null +++ b/Scripts/shut-down.cmd @@ -0,0 +1,4 @@ +@echo off + +taskkill /IM 7DaysToDie.exe /F >nul 2>&1 +taskkill /IM 7DaysToDieServer.exe /F >nul 2>&1 \ No newline at end of file diff --git a/Scripts/start-dedi.cmd b/Scripts/start-dedi.cmd index b2e115e..91e276a 100644 --- a/Scripts/start-dedi.cmd +++ b/Scripts/start-dedi.cmd @@ -1,8 +1,8 @@ @echo off -call "%~dp0..\Scripts\release.cmd" +call "%~dp0\start-local.cmd" -if %ERRORLEVEL% neq 0 exit /b 1 +if ERRORLEVEL 1 exit /b 1 IF NOT DEFINED PATH_7D2D_DEDI ( echo env variable 'PATH_7D2D_DEDI' must be defined. diff --git a/Scripts/start-local.cmd b/Scripts/start-local.cmd new file mode 100644 index 0000000..1f846ae --- /dev/null +++ b/Scripts/start-local.cmd @@ -0,0 +1,17 @@ +@echo off + +call "%~dp0\compile.cmd" + +if ERRORLEVEL 1 exit /b 1 + +set MOD_PATH="%PATH_7D2D%\Mods\EfficientBaseRepair" + +if exist %MOD_PATH% RMDIR /s /q %MOD_PATH% + +cd %MOD_PATH%\.. + +7z.exe x "%~dp0..\EfficientBaseRepair.zip" > nul + +taskkill /IM 7DaysToDie.exe /F + +start steam://rungameid/251570 \ No newline at end of file From 5b928f9f9f151c0fb9accaa6a8850dfb100da065 Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:31:09 +0200 Subject: [PATCH 3/5] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 162979b..4af06b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Fixed -- Fix performances issues when taking materials from crate and the Upgrade option is On +- Fix performances issues due to useless stats refresh ## [0.1.0] - 2024-06-09 From 3d0edbb809e4fcb3496d7a8ea58922337ebf92cc Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:40:18 +0200 Subject: [PATCH 4/5] debug start-dedi.cmd --- Scripts/start-dedi.cmd | 6 ++++-- Scripts/start-local.cmd | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Scripts/start-dedi.cmd b/Scripts/start-dedi.cmd index 91e276a..1c1593a 100644 --- a/Scripts/start-dedi.cmd +++ b/Scripts/start-dedi.cmd @@ -19,6 +19,8 @@ cd %MOD_PATH%\.. cd .. -taskkill /IM 7DaysToDieServer.exe /F +taskkill /IM 7DaysToDieServer.exe /F >nul 2>&1 -call "startdedicated.bat" \ No newline at end of file +call "startdedicated.bat" + +exit /b 0 \ No newline at end of file diff --git a/Scripts/start-local.cmd b/Scripts/start-local.cmd index 1f846ae..e7e0981 100644 --- a/Scripts/start-local.cmd +++ b/Scripts/start-local.cmd @@ -12,6 +12,8 @@ cd %MOD_PATH%\.. 7z.exe x "%~dp0..\EfficientBaseRepair.zip" > nul -taskkill /IM 7DaysToDie.exe /F +taskkill /IM 7DaysToDie.exe /F >nul 2>&1 -start steam://rungameid/251570 \ No newline at end of file +start steam://rungameid/251570 + +exit /b 0 \ No newline at end of file From 4a1f1ab8fe1bdf7c96462761dc96d782f665cc25 Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:46:28 +0200 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4af06b2..4dac254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,7 +59,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), [unreleased]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/master...unreleased -[0.1.0]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.1.0...0.1.1 +[0.1.1]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.1.0...0.1.1 [0.1.0]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.0.3...0.1.0 [0.0.3]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.0.2...0.0.3 [0.0.2]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.0.1...0.0.2