Erste Version

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 17:26:23 +01:00
co-authored by Claude Opus 5.5
commit 35f2d1330d
23 changed files with 1981 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
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: &lt;Spiel&gt;\BSO\BSO_Loader.txt.
/// </summary>
public static unsafe class Bootstrap
{
public const string ModVersion = "0.2.0";
static HostApi* host;
static int frameErrors;
/// <summary>Ordner von BSO.dll (&lt;Spiel&gt;\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();
PositionHud.Update();
}
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);
}
}
}