Snapshot for release 2026.10.11.1 (internal 4eca83a)

This commit is contained in:
Tom Bohar 2026-10-11 15:00:53 -04:00
commit 08b80eed86
94 changed files with 11103 additions and 567 deletions

View file

@ -0,0 +1,28 @@
# Creature sizes
The monster HUD anchors a plate above a creature's head, so it needs the creature's height. The client keeps
that in memory (CPhysicsObj scale, CPartArray, CSetup height and selection sphere), but the engine does not map
those layouts, so the HUD used to guess from the creature type and name. This builds the real numbers from data.
A creature's top = max(model height, selection sphere top) x its default scale. The model (Setup, 0x02xxxxxx)
comes from `client_portal.dat`; the weenie's setup and default scale come from the ACE world database.
Output: `src/RynthCore.Engine/ImGui/MonsterHud/CreatureSizes.g.cs`, used through `CreatureSizes.TryGetTop(wcid)`.
## Regenerate
```powershell
# 1. creature-like weenies with a setup (add the Aelrynth custom weenie .sql exports after the world dump)
python parse_world.py C:\Projects\ACE-World-Database\ACE-World-Database-v0.9.293.sql -o out
# 2. each setup's height / radius / selection sphere / sorting sphere, from a folder holding client_portal.dat
dotnet run --project SetupDims -c Release -- <dat dir> out\setups.json out\setups_dims.json
# 3. the table
python gen_cs.py out\creatures.json out\setups_dims.json ..\..\src\RynthCore.Engine\ImGui\MonsterHud\CreatureSizes.g.cs
```
Pass full Windows paths to step 2 (it is a Windows program). A creature with no row (a custom weenie that was not in
the input, or a model with no height) falls back to the HUD's old estimate by creature type and name.
`tools/CreatureSizesTests` checks the lookup against the generated table.

View file

@ -0,0 +1,27 @@
using System.Globalization;
using System.Text;
using ACE.DatLoader;
using ACE.DatLoader.FileTypes;
// args: <dat dir> <setups.json> <out.json>
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
string datDir = args[0];
string[] ids = System.Text.Json.JsonSerializer.Deserialize<string[]>(
"[" + string.Join(",", System.Text.Json.JsonSerializer.Deserialize<uint[]>(File.ReadAllText(args[1]))!.Select(u => "\"" + u + "\"")) + "]")!;
DatManager.Initialize(datDir, keepOpen: true, loadCell: false);
var sb = new StringBuilder("{");
int ok = 0, bad = 0; bool first = true;
foreach (string s in ids)
{
uint id = uint.Parse(s);
SetupModel m = DatManager.PortalDat.ReadFromDat<SetupModel>(id);
if (m == null) { bad++; continue; }
if (!first) sb.Append(',');
first = false;
string F(float v) => v.ToString("0.####", CultureInfo.InvariantCulture);
sb.Append($"\"{id}\":[{F(m.Height)},{F(m.Radius)},{F(m.SelectionSphere.Origin.Z)},{F(m.SelectionSphere.Radius)},{F(m.SortingSphere.Origin.Z)},{F(m.SortingSphere.Radius)}]");
ok++;
}
sb.Append('}');
File.WriteAllText(args[2], sb.ToString());
Console.WriteLine($"read {ok} setups, {bad} missing");

View file

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Step 2 of the creature size table (see ..\README.md): reads each Setup (model) from client_portal.dat
with ACE's own dat reader. Needs a built ACE server; point AcBin at its bin folder if it is elsewhere. -->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PlatformTarget>x64</PlatformTarget>
<AcBin Condition="'$(AcBin)' == ''">C:\Projects\ACE\Source\ACE.Server\bin\x64\Release\net10.0</AcBin>
</PropertyGroup>
<ItemGroup>
<Reference Include="ACE.DatLoader"><HintPath>$(AcBin)\ACE.DatLoader.dll</HintPath></Reference>
<Reference Include="ACE.Common"><HintPath>$(AcBin)\ACE.Common.dll</HintPath></Reference>
<Reference Include="ACE.Entity"><HintPath>$(AcBin)\ACE.Entity.dll</HintPath></Reference>
<Reference Include="log4net"><HintPath>$(AcBin)\log4net.dll</HintPath></Reference>
</ItemGroup>
</Project>

View file

@ -0,0 +1,50 @@
"""Step 3 of the creature size table (see README.md): writes CreatureSizes.g.cs.
usage: python gen_cs.py <creatures.json> <setups_dims.json> <out .cs>
A creature's top is max(model height, selection sphere top) x its default scale, in centimetres.
Entries with no usable height (under 20 cm) are left out, so the HUD falls back to its estimate.
A few creatures are scaled absurdly (a 400x "colossal" that is a trick, not a monster); tops
over 120 m are capped.
"""
import json
import sys
creatures = json.load(open(sys.argv[1]))
dims = json.load(open(sys.argv[2]))
rows = []
for wcid, c in creatures.items():
d = dims.get(str(c["setup"]))
if not d:
continue
height, radius, sel_z, sel_r, sort_z, sort_r = d
top = max(height, sel_z + sel_r) * c["scale"]
if top < 0.2:
continue
rows.append((int(wcid), min(int(round(top * 100)), 12000)))
rows.sort()
lines = [
"// <auto-generated> by tools/CreatureSizes (gen_cs.py); do not edit. </auto-generated>",
"// Weenie class id -> the creature's top in centimetres (model height x default scale).",
"namespace RynthCore.Engine.ImGuiBackend.Hud;",
"",
"internal static partial class CreatureSizes",
"{",
" private static readonly int[] Wcids =",
" {",
]
def chunk(values, per=12):
for i in range(0, len(values), per):
yield ", ".join(str(v) for v in values[i:i + per]) + ","
lines += [" " + l for l in chunk([r[0] for r in rows])]
lines += [" };", "", " private static readonly ushort[] TopCm =", " {"]
lines += [" " + l for l in chunk([r[1] for r in rows], 16)]
lines += [" };", "}", ""]
open(sys.argv[3], "w", encoding="utf-8", newline="\n").write("\n".join(lines))
print(len(rows), "creatures written to", sys.argv[3])

View file

@ -0,0 +1,62 @@
"""Step 1 of the creature size table (see README.md).
Reads the ACE world database dump and writes, to the output folder:
creatures.json {weenie class id: {name, wtype, setup, scale}} for every creature-like weenie
(creature, admin, vendor, cow, AI) that has a Setup (model) property
setups.json the distinct setup ids, for SetupDims
usage: python parse_world.py <ACE-World-Database.sql> [<more weenie .sql files>] -o <out dir>
The extra files are weenie exports in the same INSERT format (the Aelrynth custom weenies).
"""
import argparse
import json
import os
import re
ap = argparse.ArgumentParser()
ap.add_argument("sql", nargs="+")
ap.add_argument("-o", "--out", default=".")
args = ap.parse_args()
# weenie rows: (class_Id,'class_Name',type,'last_Modified')
WEENIE_ROW = re.compile(r"\((\d+),'((?:[^'\\]|\\.|'')*)',(\d+),'[^']*'\)")
PLAIN_ROW = re.compile(r"\(([^()]*)\)")
weenies, setup, scale = {}, {}, {}
for path in args.sql:
text = open(path, encoding="utf-8", errors="replace").read()
def inserts(table):
for m in re.finditer(r"INSERT INTO `%s` VALUES (.*?);\n" % table, text, re.S):
yield m.group(1)
for body in inserts("weenie"):
for r in WEENIE_ROW.finditer(body):
weenies[int(r.group(1))] = {"name": r.group(2), "wtype": int(r.group(3))}
# property rows: (id, object_Id, type, value). Setup = DataId property 1, DefaultScale = float property 39.
for body in inserts("weenie_properties_d_i_d"):
for r in PLAIN_ROW.finditer(body):
p = r.group(1).split(",")
if len(p) == 4 and p[2] == "1":
setup[int(p[1])] = int(p[3])
for body in inserts("weenie_properties_float"):
for r in PLAIN_ROW.finditer(body):
p = r.group(1).split(",")
if len(p) == 4 and p[2] == "39":
scale[int(p[1])] = float(p[3])
out = {}
for w, info in weenies.items():
if info["wtype"] not in (10, 11, 12, 15, 16): # creature, admin, vendor, cow, AI
continue
if w not in setup:
continue
out[w] = {"name": info["name"], "wtype": info["wtype"], "setup": setup[w], "scale": scale.get(w, 1.0)}
os.makedirs(args.out, exist_ok=True)
json.dump(out, open(os.path.join(args.out, "creatures.json"), "w"))
json.dump(sorted(set(v["setup"] for v in out.values())), open(os.path.join(args.out, "setups.json"), "w"))
print(len(weenies), "weenies;", len(out), "creature-like with a setup;",
len(set(v["setup"] for v in out.values())), "distinct setups;",
sum(1 for v in out.values() if v["scale"] != 1.0), "with a default scale")