Verbunden wird nur beim Start ueber die Lobby, bricht die Verbindung ab alle 10 s neu (nicht nach Ablehnung oder Konto-Problem). release.ps1 legt jetzt Gitea-Releases mit bso-release.json an. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
2.6 KiB
C#
84 lines
2.6 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
|
|
namespace BSO
|
|
{
|
|
/// <summary>Was der Loader (dinput8.dll) mitgibt - Gegenstueck zu HostApi in BSO.Loader\dinput8.cpp.</summary>
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public unsafe struct HostApi
|
|
{
|
|
public delegate* unmanaged<byte*, void> Log;
|
|
public char* GameDir;
|
|
public char* BsoDir;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Einstieg: der Loader startet .NET beim ersten DirectInput8Create und ruft Start auf, danach OnFrame einmal pro
|
|
/// Bild im Hauptthread des Spiels. Protokoll: <Spiel>\BSO\BSO_Loader.txt.
|
|
/// </summary>
|
|
public static unsafe class Bootstrap
|
|
{
|
|
public const string ModVersion = "0.5.1";
|
|
|
|
static HostApi* host;
|
|
static int frameErrors;
|
|
|
|
/// <summary>Ordner von BSO.dll (<Spiel>\BSO).</summary>
|
|
public static string Folder { get; private set; }
|
|
/// <summary>Ordner der Spiel-EXE (Bin_High_Win64).</summary>
|
|
public static string GameFolder { get; private set; }
|
|
|
|
[UnmanagedCallersOnly]
|
|
public static void Start(HostApi* api)
|
|
{
|
|
try
|
|
{
|
|
host = api;
|
|
Folder = new string(api->BsoDir);
|
|
GameFolder = new string(api->GameDir);
|
|
Log("BSO " + ModVersion + " gestartet (.NET " + Environment.Version + ")");
|
|
Log("Kommandozeile: " + Environment.CommandLine);
|
|
Config.Load();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log("Start fehlgeschlagen: " + e);
|
|
}
|
|
}
|
|
|
|
[UnmanagedCallersOnly]
|
|
public static void OnFrame()
|
|
{
|
|
try
|
|
{
|
|
Mem.NewFrame();
|
|
if (!Vision.Init()) return;
|
|
if (Vision.TimerAdvanced())
|
|
{
|
|
Input.Update();
|
|
BorderlessWindow.Update();
|
|
LocalPlayer.Update();
|
|
Multiplayer.Update();
|
|
RemotePlayers.Update();
|
|
PositionHud.Update();
|
|
}
|
|
RemotePlayers.Draw();
|
|
PositionHud.Draw();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// Nicht jedes Bild ins Protokoll schreiben
|
|
if (frameErrors++ < 5) Log("Fehler im Bild-Takt: " + e);
|
|
}
|
|
}
|
|
|
|
public static void Log(string line)
|
|
{
|
|
if (host == null) return;
|
|
byte[] bytes = Encoding.UTF8.GetBytes(line + "\0");
|
|
fixed (byte* p = bytes) host->Log(p);
|
|
}
|
|
}
|
|
}
|