ReStreet: FIFA Street (2012) recompiled for Windows PC, with online play, a launcher with friends, chat and rooms. Bring your own game.
Launcher 2.0.5: room polling, NoAVX2 set incl. GPU plugin
SamuelitoDaVila744597003db8
diff --git a/Launcher/FifaStreetLauncher/DeckLaunch.cs b/Launcher/FifaStreetLauncher/DeckLaunch.csindex aa04f72..b64b9ac 100644--- a/Launcher/FifaStreetLauncher/DeckLaunch.cs+++ b/Launcher/FifaStreetLauncher/DeckLaunch.cs@@ -87,6 +87,7 @@ public partial class LauncherFormprivate void ApplyDeckLaunch(ProcessStartInfo startInfo, string exeDirectory, string graphicsApi, int adapter){+ UseCpuBuild(exeDirectory, graphicsApi);// The deck port's own start-up switches (native renderer, its shader folders...), as its launcher sets them.foreach (string line in File.ReadAllLines(Path.Combine(exeDirectory, "ajustes-del-port.txt"))){@@ -101,6 +102,36 @@ public partial class LauncherFormSaveDeckToml();}+ // The deck build is compiled for x86-64-v3 (AVX2/BMI2/FMA): on older CPUs (Ivy Bridge, AMD FX...) its DLLs fail to+ // load with 0xc0000142. Binaries\AVX2 and Binaries\NoAVX2 hold the game built with and without it; before every+ // start the set for this CPU goes over Binaries\ (only files that differ, so a copy is paid once). The AVX2 runtime+ // is Backends\<api>\rexruntime.dll, already copied by the caller; NoAVX2 has its own Backends.+ private static readonly bool CpuHasX86_64V3 =+ System.Runtime.Intrinsics.X86.Avx2.IsSupported && System.Runtime.Intrinsics.X86.Bmi2.IsSupported &&+ System.Runtime.Intrinsics.X86.Fma.IsSupported && System.Runtime.Intrinsics.X86.Lzcnt.IsSupported;++ private static void UseCpuBuild(string exeDirectory, string graphicsApi)+ {+ string set = Path.Combine(exeDirectory, CpuHasX86_64V3 ? "AVX2" : "NoAVX2");+ if (!Directory.Exists(set)) return;+ foreach (string name in new[] { "fifastreet.exe", "fifastreet_fifadllzf_xex.dll", "fifastreet_footballcompengzf_xex.dll" })+ CopyIfDifferent(Path.Combine(set, name), Path.Combine(exeDirectory, name));+ // rexruntime.dll AND rexgpu-xenos.dll: the GPU plugin is x86-64-v3 code too.+ string backend = Path.Combine(set, "Backends", graphicsApi);+ if (!CpuHasX86_64V3 && Directory.Exists(backend))+ foreach (string dll in Directory.GetFiles(backend, "*.dll"))+ CopyIfDifferent(dll, Path.Combine(exeDirectory, Path.GetFileName(dll)));+ }++ private static void CopyIfDifferent(string source, string target)+ {+ if (!File.Exists(source)) return;+ var s = new FileInfo(source);+ var t = new FileInfo(target);+ if (t.Exists && t.Length == s.Length && t.LastWriteTimeUtc == s.LastWriteTimeUtc) return;+ File.Copy(source, target, true); // File.Copy keeps the write time, so the next start skips it+ }+// The launcher's current choices into fifastreet.toml (on every change, and before each start).private void SaveDeckToml(){diff --git a/Launcher/FifaStreetLauncher/FifaStreetLauncher.csproj b/Launcher/FifaStreetLauncher/FifaStreetLauncher.csprojindex 180dacc..304c42c 100644--- a/Launcher/FifaStreetLauncher/FifaStreetLauncher.csproj+++ b/Launcher/FifaStreetLauncher/FifaStreetLauncher.csproj@@ -6,7 +6,7 @@<Nullable>enable</Nullable><UseWindowsForms>true</UseWindowsForms><ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>- <Version>2.0.3</Version>+ <Version>2.0.5</Version><ApplicationIcon>fifastreet.ico</ApplicationIcon><ImplicitUsings>enable</ImplicitUsings></PropertyGroup>diff --git a/Launcher/FifaStreetLauncher/GlassUi.cs b/Launcher/FifaStreetLauncher/GlassUi.csindex 42a35d4..ea7c201 100644--- a/Launcher/FifaStreetLauncher/GlassUi.cs+++ b/Launcher/FifaStreetLauncher/GlassUi.cs@@ -95,7 +95,11 @@ public partial class LauncherFormstring ui = Path.Combine(AppContext.BaseDirectory, "ui");if (!File.Exists(Path.Combine(ui, "launcher.html"))) { RevealWindow(); return; }string data = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "ReStreet", "WebView2");- var env = await CoreWebView2Environment.CreateAsync(null, data);+ // A minimized launcher must keep polling at full rate: Chromium otherwise slows the page's timers to once a+ // minute, and a host waiting in a room started the game a minute late (the guest gave up meanwhile).+ var options = new CoreWebView2EnvironmentOptions(+ "--disable-background-timer-throttling --disable-renderer-backgrounding --disable-backgrounding-occluded-windows");+ var env = await CoreWebView2Environment.CreateAsync(null, data, options);var view = new WebView2 { Dock = DockStyle.Fill, DefaultBackgroundColor = Color.FromArgb(11, 12, 18) };Controls.Add(view);view.BringToFront();@@ -345,7 +349,19 @@ public partial class LauncherFormprivate int socialFailures;+ private int socialPollBusy;+ private volatile bool inRoom;++ // A background poll is skipped while the previous one still runs: on a slow link they piled up every 3 s.private async Task SocialAsync(string cmd, JsonElement m)+ {+ if (cmd != "social") { await SocialCoreAsync(cmd, m); return; }+ if (Interlocked.Exchange(ref socialPollBusy, 1) == 1) return;+ try { await SocialCoreAsync(cmd, m); }+ finally { Volatile.Write(ref socialPollBusy, 0); }+ }++ private async Task SocialCoreAsync(string cmd, JsonElement m){var online = LoadOnlineConfig();if (online == null || !onlineModeBox.Checked || !PageConnected) return;@@ -357,8 +373,8 @@ public partial class LauncherForm{if (cmd == "social" && channel == ""){- // Social page closed: refresh the badge only every 15 s.- if (DateTime.UtcNow - lastBackgroundSocial < TimeSpan.FromSeconds(15)) return;+ // Social page closed: refresh the badge only every 15 s (every poll while in a room, to start the game on time).+ if (!inRoom && DateTime.UtcNow - lastBackgroundSocial < TimeSpan.FromSeconds(15)) return;lastBackgroundSocial = DateTime.UtcNow;}if (cmd == "chatSend")@@ -399,26 +415,27 @@ public partial class LauncherForm}}- // Fresh snapshot for the page.- using var friends = await PostJson(server, "/v1/friends", new { me = name, key, action = "list" });- using var players = await GetJson(server, "/v1/online");+ // Fresh snapshot for the page. All requests at once: one after the other they took seconds on a far server.+ var friendsTask = PostJson(server, "/v1/friends", new { me = name, key, action = "list" });+ var playersTask = GetJson(server, "/v1/online");+ var roomsTask = PostJson(server, "/v1/rooms", new { me = name, key, action = "list" });+ var myRoomTask = PostJson(server, "/v1/rooms", new { me = name, key, action = "current" });+ var convosTask = PostJson(server, "/v1/textchat", new { me = name, key, action = "conversations" });+ var msgsTask = channel == "" ? Task.FromResult<JsonDocument?>(null)+ : PostJson(server, "/v1/textchat", new { me = name, key, action = "read", channel, since = m.TryGetProperty("since", out var s2) && s2.ValueKind == JsonValueKind.Number ? s2.GetInt64() : 0 });JsonDocument? convos = null, msgs = null;bool chatOff = false;try{- convos = await PostJson(server, "/v1/textchat", new { me = name, key, action = "conversations" });- if (channel != "")- {- long since = m.TryGetProperty("since", out var sv) && sv.ValueKind == JsonValueKind.Number ? sv.GetInt64() : 0;- if (cmd != "social") since = 0; // after sending, reload the channel from the page's last id- msgs = await PostJson(server, "/v1/textchat", new { me = name, key, action = "read", channel, since = m.TryGetProperty("since", out var s2) && s2.ValueKind == JsonValueKind.Number ? s2.GetInt64() : 0 });- }+ convos = await convosTask;+ msgs = await msgsTask;chatOff = convos == null && msgs == null; // either answer means the chat is there}catch (HttpRequestException) { chatOff = true; }-- using var rooms = await PostJson(server, "/v1/rooms", new { me = name, key, action = "list" });- using var myRoom = await PostJson(server, "/v1/rooms", new { me = name, key, action = "current" });+ using var friends = await friendsTask;+ using var players = await playersTask;+ using var rooms = await roomsTask;+ using var myRoom = await myRoomTask;var waited = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);if (players.RootElement.TryGetProperty("searching_list", out var sl) && sl.ValueKind == JsonValueKind.Array)foreach (var it in sl.EnumerateArray())@@ -454,6 +471,7 @@ public partial class LauncherFormpayload["rooms"] = JsonSerializer.Deserialize<object>(rl.GetRawText());if (myRoom != null && myRoom.RootElement.TryGetProperty("room", out var mr))payload["myRoom"] = JsonSerializer.Deserialize<object>(mr.GetRawText());+ inRoom = myRoom != null && myRoom.RootElement.TryGetProperty("room", out var mr3) && mr3.ValueKind == JsonValueKind.Object;OnRoomState(myRoom != null && myRoom.RootElement.TryGetProperty("room", out var mr2) ? mr2.Clone() : null);if (friends != null){diff --git a/Launcher/FifaStreetLauncher/RoomLaunch.cs b/Launcher/FifaStreetLauncher/RoomLaunch.csindex 8369405..4e738de 100644--- a/Launcher/FifaStreetLauncher/RoomLaunch.cs+++ b/Launcher/FifaStreetLauncher/RoomLaunch.cs@@ -19,6 +19,8 @@ public partial class LauncherFormif (players < seats || id == roomLaunchedFor || !onlineModeBox.Checked) return;BeginInvoke(async () =>{+ // Two overlapping refreshes can both see the full room: the second must not kill the game the first started.+ if (id == roomLaunchedFor) return;roomLaunchedFor = id;// A game that is already open sits on some menu the room driver cannot walk from (it starts at the// title screen), so the match is never created: close it and start it again for the room. The pagediff --git a/Launcher/FifaStreetLauncher/Updater.cs b/Launcher/FifaStreetLauncher/Updater.csindex 71645f2..22faf29 100644--- a/Launcher/FifaStreetLauncher/Updater.cs+++ b/Launcher/FifaStreetLauncher/Updater.cs@@ -10,7 +10,7 @@ namespace FifaStreetLauncher;// name, key and server, and reopens the launcher) and closes the launcher. Only installs that have the online patch.public partial class LauncherForm{- internal const string LauncherVersion = "2.0.3";+ internal const string LauncherVersion = "2.0.5";private const string ReleasesApi = "https://api.github.com/repos/samuelit0davila/fifa-street-pc-port/releases/latest";private static readonly HttpClient UpdateHttp = CreateUpdateHttp();private (string Version, string ExeUrl, string ShaUrl, string Notes)? pendingUpdate;