Skip to content

Commit

Permalink
Update 1.7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DarwinBaker committed Apr 3, 2024
1 parent 09e1a0e commit 2c810d8
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 106 deletions.
4 changes: 3 additions & 1 deletion AATool/AATool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@
<Compile Include="Input.cs" />
<Compile Include="Net\AAKey.cs" />
<Compile Include="Net\Lobby.cs" />
<Compile Include="Net\OpenTracker.cs" />
<Compile Include="Net\PeerStatic.cs" />
<Compile Include="Net\Requests\SrcLeaderboardRequest.cs" />
<Compile Include="Net\Requests\AASsgRequest.cs" />
Expand Down Expand Up @@ -3523,6 +3522,9 @@
<Content Include="assets\sprites\global\gui\icons\100k_arrow.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\global\gui\icons\av_hardcore.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\global\gui\icons\patreon_large.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
2 changes: 2 additions & 0 deletions AATool/Configuration/SftpConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class SftpConfig : Config
[JsonProperty] public readonly Setting<string> Username = new (string.Empty);
[JsonProperty] public readonly Setting<string> Password = new (string.Empty);
[JsonProperty] public readonly Setting<int> Port = new (22);
[JsonProperty] public readonly Setting<int> AutoSaveMinutes = new (5);
[JsonProperty] public readonly Setting<bool> Linux = new (false);

[JsonProperty] public readonly Setting<string> ServerRoot = new (string.Empty);

Expand Down
1 change: 0 additions & 1 deletion AATool/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ protected override void Update(GameTime gameTime)
ActiveInstance.Update(this.Time);
MinecraftServer.Update(this.Time);
Tracker.Update(this.Time);
OpenTracker.Update(this.Time);
SpriteSheet.Update(this.Time);
Canvas.Update(this.Time);

Expand Down
55 changes: 0 additions & 55 deletions AATool/Net/OpenTracker.cs

This file was deleted.

4 changes: 2 additions & 2 deletions AATool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: AssemblyVersion("1.7.1.0")]
[assembly: AssemblyFileVersion("1.7.1.0")]
[assembly: NeutralResourcesLanguage("en")]
31 changes: 17 additions & 14 deletions AATool/Saves/MinecraftServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace AATool.Saves
public static class MinecraftServer
{
private const string SftpPrefix = "sftp://";
private const double SaveInterval = (5 * 60) + 5;
private const double RetryInterval = 10;
private const int MaximumRetries = 3;
private const int AttemptIntervalMs = 5000;
Expand All @@ -27,14 +26,15 @@ public static class MinecraftServer
public static SyncState State { get; private set; }
public static string MessageOfTheDay { get; private set; }
public static string WorldName { get; private set; }
public static bool LinuxMode { get; private set; }

private static readonly Utilities.Timer RefreshTimer = new ();

private static ConnectionInfo Credentials;
private static int CurrentDownloadPercent;
private static float SmoothDownloadPercent;
private static bool LinuxMode;

public static double SaveInterval => (Config.Sftp.AutoSaveMinutes * 60) + 5;
public static bool CredentialsValidated => Credentials is not null;
public static bool LastSyncFailed => LastError is not null;
public static bool IsDownloading => State is SyncState.Advancements or SyncState.Statistics;
Expand All @@ -48,8 +48,9 @@ public static DateTime GetRefreshEstimate() => IsEnabled
? LastWorldSave.Add(TimeSpan.FromSeconds(SaveInterval))
: default;

public static string HostAwarePath(params string[] paths) =>
LinuxMode ? Path.Combine(paths).Replace("\\", "/") : Path.Combine(paths);
public static string HostAwarePath(params string[] paths) => LinuxMode
? Path.Combine(paths).Replace(@"\", "/")
: Path.Combine(paths).Replace("/", @"\");

public static void Update(Time time)
{
Expand Down Expand Up @@ -80,6 +81,7 @@ public static void Sync()
{
SftpClient sftp = null;
double remaining = 0;
bool success = false;
try
{
if (!TryConnect(out sftp))
Expand All @@ -105,7 +107,7 @@ public static void Sync()
if (Server.TryGet(out Server server))
server.SendNextRefresh();

Tracker.Invalidate();
success = true;
}
}
finally
Expand All @@ -122,6 +124,12 @@ public static void Sync()
if (RefreshTimer.IsExpired || (LastSyncFailed && LastError is not ArgumentException))
RefreshTimer.SetAndStart(RetryInterval);
SetState(SyncState.Ready);

if (success)
{
Tracker.FileSystemChanged(null, null);
Tracker.Invalidate();
}
}
});
}
Expand Down Expand Up @@ -213,6 +221,8 @@ private static void ApplyCredentials()

private static bool TryConnect(out SftpClient sftp)
{
LinuxMode = Config.Sftp.Linux;

LastError = null;
sftp = null;
ApplyCredentials();
Expand Down Expand Up @@ -321,16 +331,9 @@ private static bool TryGetWorldSaveTime(SftpClient sftp, out DateTime lastWorldS
{
if (exception is SftpPathNotFoundException)
{
if (!LinuxMode)
{
//try switching to linux mode
LinuxMode = true;
Thread.Sleep(AttemptIntervalMs);
return TryGetWorldSaveTime(sftp, out lastWorldSave, failures + 1);
}

//folder not found, world name might be wrong. refresh it next time
LastError = new SftpPathNotFoundException($"File not found: \"{remotePath}\".");
string otherOS = Config.Sftp.Linux ? "Windows" : "Linux";
LastError = new SftpPathNotFoundException($"File not found (server might be {otherOS}): \"{remotePath}\".");
InvalidateWorld();
return false;
}
Expand Down
9 changes: 1 addition & 8 deletions AATool/Tracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static void Initialize()
TrySetVersion(lastVersion);
}

private static void FileSystemChanged(object sender, FileSystemEventArgs e)
public static void FileSystemChanged(object sender, FileSystemEventArgs e)
{
FileSystemEventRaised = true;
}
Expand Down Expand Up @@ -550,9 +550,6 @@ private static void ParseCoOpProgress(Time time, Client client)

SetState(State);

if (Config.Tracking.BroadcastProgress)
OpenTracker.BroadcastProgress();

LastRefresh = time.TotalSeconds;
}
}
Expand Down Expand Up @@ -580,10 +577,6 @@ private static void ReadLocalFiles(Time time)
if (Server.TryGet(out Server server) && server.Connected())
server.SendProgress();

//broadcast progress to opentracker
if (Config.Tracking.BroadcastProgress)
OpenTracker.BroadcastProgress();

LastRefresh = time.TotalSeconds;
}
}
Expand Down
17 changes: 16 additions & 1 deletion AATool/UI/Controls/UIPersonalBest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,22 @@ public override void InitializeRecursive(UIScreen screen)

if (!this.IsSmall && this.Run is AllVersionsRun avRun)
{
this.age.SetText($"({avRun.Range})");
this.age.SetText(avRun.NoF3
? $"No-F3 ({avRun.Range})"
: $"({avRun.Range})");

if (avRun.Hardcore)
{
var icon = new UIPicture() {
FlexWidth = new(9),
FlexHeight = new(9),
HorizontalAlign = HorizontalAlign.Left,
VerticalAlign = VerticalAlign.Top,
Margin = new Margin(108, 0, 29, 0)
};
icon.SetTexture("av_hardcore");
this.AddControl(icon);
}
}

this.face.Glow();
Expand Down
Loading

0 comments on commit 2c810d8

Please sign in to comment.