Skip to content

Commit

Permalink
Merge branch 'unreleased'
Browse files Browse the repository at this point in the history
  • Loading branch information
VisualDev-FR committed Jun 9, 2024
2 parents b7b4b33 + 4a1f1ab commit 3a45620
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 48 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 due to useless stats refresh

## [0.1.0] - 2024-06-09

### Fixed
Expand Down Expand Up @@ -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.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
Expand Down
27 changes: 17 additions & 10 deletions Harmony/TileEntityEfficientBaseRepair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -502,7 +504,7 @@ public void AnalyseStructure(Vector3i initial_pos)

public void ForceRefresh()
{
forceRefresh = true;
forceFullRefresh = true;
setModified();
}

Expand All @@ -515,14 +517,16 @@ private void RefreshStats(World world)
bfsIterationsCount = 0;
visitedBlocksCount = 0;
totalDamagesCount = 0;
forceRefresh = false;
forceFullRefresh = false;

AnalyseStructure(ToWorldPos());
RefreshMaterialsStats();
}

private void RefreshMaterialsStats()
{
forceRefreshMaterials = false;

if (blocksToRepair == null)
return;

Expand Down Expand Up @@ -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}");
Expand All @@ -578,6 +582,7 @@ public void Switch(bool forceRefresh_ = false)
public void SwitchUpgrade()
{
upgradeOn = !upgradeOn;
forceRefreshMaterials = true;
setModified();
}

Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -682,12 +689,12 @@ public override void write(PooledBinaryWriter _bw, StreamModeWrite _eStreamMode)

// trigger forceRefresh=true in single player mode
// TODO: try with SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer
if (forceRefresh)
if (forceFullRefresh)
{
Log.Out("[EfficientBaseRepair] Refresh forced from Client.");
RefreshStats(GameManager.Instance.World);
}
else
else if (forceRefreshMaterials)
{
RefreshMaterialsStats();
}
Expand Down
2 changes: 1 addition & 1 deletion ModInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<DisplayName value="EfficientBaseRepair Block"/>
<Description value="Auto repairs your base" />
<Author value="VisualDev-FR" />
<Version value="0.1.0" />
<Version value="0.1.1" />
<Website value="https://github.com/VisualDev-FR/efficient-base-repair-" />
</xml>
22 changes: 21 additions & 1 deletion Scripts/compile.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
@echo off

dotnet build --no-incremental .\EfficientBaseRepair.csproj
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
31 changes: 0 additions & 31 deletions Scripts/release.cmd

This file was deleted.

4 changes: 4 additions & 0 deletions Scripts/shut-down.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off

taskkill /IM 7DaysToDie.exe /F >nul 2>&1
taskkill /IM 7DaysToDieServer.exe /F >nul 2>&1
10 changes: 6 additions & 4 deletions Scripts/start-dedi.cmd
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -19,6 +19,8 @@ cd %MOD_PATH%\..

cd ..

taskkill /IM 7DaysToDieServer.exe /F
taskkill /IM 7DaysToDieServer.exe /F >nul 2>&1

call "startdedicated.bat"
call "startdedicated.bat"

exit /b 0
19 changes: 19 additions & 0 deletions Scripts/start-local.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@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 >nul 2>&1

start steam://rungameid/251570

exit /b 0

0 comments on commit 3a45620

Please sign in to comment.