Skip to content

Commit

Permalink
Merge pull request #290 from InvalidArgument3/slipspace-patches
Browse files Browse the repository at this point in the history
reduce teleport rate of sipsapce from 1 tick to every 10 ticsk
  • Loading branch information
InvalidArgument3 authored Dec 9, 2024
2 parents 959bbc6 + d84bf42 commit e93ea59
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void TransmitToggleWarp(IMyTerminalBlock block)
}));
}

private void ReceiveWarpSpeed(ushort channel, byte[] data, ulong sender, bool fromServer)
private void ReceiveWarpSpeed(ushort channel, byte[] data, ulong sender, bool fromServer) //TODO: suspect this for constant warp load sent to clients
{
var message = MyAPIGateway.Utilities.SerializeFromBinary<SpeedMessage>(data);
if (message == null)
Expand Down
42 changes: 27 additions & 15 deletions Slipspace Engine/Data/Scripts/WarpDrive/WarpSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public class WarpSystem {
public string ProximytyAlert = "Can't Start SSD, Proximity Alert!";

public const float EARTH_GRAVITY = 9.806652f;
private int teleportTick = 0;
private const int TELEPORT_DELAY = 10; // Adjust this value to change the update frequency


public WarpSystem(WarpDrive block, WarpSystem oldSystem) {
if (block == null)
Expand Down Expand Up @@ -211,21 +214,30 @@ public void UpdateBeforeSimulation() {
}
}

if (TeleportNow && !SafeTriggerON) {
TeleportNow = false;

if (currentSpeedPt > 1f && gridMatrix != null) {
gridMatrix.Translation += gridMatrix.Forward * currentSpeedPt;

if (MyAPIGateway.Utilities.IsDedicated || MyAPIGateway.Multiplayer.IsServer)
MainGrid.Teleport(gridMatrix);

if (!MyAPIGateway.Utilities.IsDedicated) {
DrawAllLinesCenter1();

if (currentSpeedPt > 316.6666) {
//StartBlinkParticleEffect();
DrawAllLinesCenter4();
if (TeleportNow && !SafeTriggerON)
{
teleportTick++;
if (teleportTick >= TELEPORT_DELAY)
{
teleportTick = 0;
TeleportNow = false;

if (currentSpeedPt > 1f && gridMatrix != null)
{
// Multiply the movement by TELEPORT_DELAY to maintain the same effective speed
gridMatrix.Translation += gridMatrix.Forward * currentSpeedPt * TELEPORT_DELAY;

if (MyAPIGateway.Utilities.IsDedicated || MyAPIGateway.Multiplayer.IsServer)
MainGrid.Teleport(gridMatrix);

if (!MyAPIGateway.Utilities.IsDedicated)
{
DrawAllLinesCenter1();

if (currentSpeedPt > 316.6666)
{
DrawAllLinesCenter4();
}
}
}
}
Expand Down
60 changes: 60 additions & 0 deletions Slipspace Engine/Data/Scripts/concatrecursivelyandminify.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@echo off
setlocal enabledelayedexpansion
chcp 65001
REM ^^ this is to change the encoding to UTF-8, apparently

echo Starting operation...

set TEMP_OUTPUT=temp_concatenated.txt
set FINAL_OUTPUT=minified_output.txt
set /a COUNT=0
set /a ERRORS=0

if exist "%TEMP_OUTPUT%" (
echo Existing temporary file found. Deleting...
del "%TEMP_OUTPUT%"
)

if exist "%FINAL_OUTPUT%" (
echo Existing output file found. Deleting...
del "%FINAL_OUTPUT%"
)

for /r %%i in (*.cs) do (
echo Processing: "%%i"
type "%%i" >> "%TEMP_OUTPUT%"
if errorlevel 1 (
echo Error processing "%%i".
set /a ERRORS+=1
) else (
set /a COUNT+=1
)
)

echo Concatenation completed.
echo Total files processed: %COUNT%
if %ERRORS% gtr 0 (
echo There were %ERRORS% errors during the concatenation.
) else (
echo No errors encountered during concatenation.
)

echo Minifying concatenated file...
csmin < "%TEMP_OUTPUT%" > "%FINAL_OUTPUT%"
if errorlevel 1 (
echo Error occurred during minification.
set /a ERRORS+=1
) else (
echo Minification completed successfully.
)

echo Cleaning up temporary file...
del "%TEMP_OUTPUT%"

echo Operation completed.
if %ERRORS% gtr 0 (
echo There were %ERRORS% errors during the entire operation.
) else (
echo No errors encountered during the entire operation.
)
pause

0 comments on commit e93ea59

Please sign in to comment.