Skip to content

Commit d97d978

Browse files
committed
Add JMF flags to entities so JACK loads them properly
Fixes #49
1 parent 44068c4 commit d97d978

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

Sledge.Formats.Map/Formats/JackhamerJmfFormat.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,17 @@ private static void WriteEntities(MapFile map, Dictionary<Group, JmfGroup> group
663663

664664
WriteString(ent.ClassName, bw);
665665
bw.WriteVector3(ent.GetVectorProperty("origin", Vector3.Zero));
666-
bw.Write(0); // flags
666+
667+
// JACK needs at least the PointBased flag. The others are likely optional
668+
// but since we can derive most of them, might as well set them.
669+
var flags = JmfFlags.None;
670+
if (ent.Children.Count == 0) flags |= JmfFlags.PointBased;
671+
if (ent.GetIntProperty("rendermode", 0) != 0) flags |= JmfFlags.RenderMode;
672+
if (ent.ClassName == "worldspawn") flags |= JmfFlags.IsWorld;
673+
if (ent.ClassName.StartsWith("weapon_") || ent.ClassName.StartsWith("item_")) flags |= JmfFlags.WeaponOrItem;
674+
if (ent.ClassName.StartsWith("path_")) flags |= JmfFlags.PathEntity;
675+
bw.Write((int)flags);
676+
667677
bw.Write(GetGroupID(groups, egr.Group));
668678
bw.Write(GetGroupID(groups, egr.RootGroup));
669679
bw.WriteRGBAColour(ent.Color);
@@ -903,10 +913,14 @@ private enum JmfRendering : int
903913
private enum JmfFlags
904914
{
905915
None = 0x00,
906-
PointBased = 0x01, // Or maybe 'HasOrigin'?
916+
PointBased = 0x01, // Or maybe 'HasOrigin'?
907917
Selected = 0x02,
908918
Hidden = 0x08,
909-
RenderMode = 0x10, // Any other render mode than 'normal'
919+
RenderMode = 0x10, // Any other render mode than 'normal'
920+
IsWorld = 0x0020, // The special "worldspawn" entity
921+
WeaponOrItem = 0x0040, // Any entity whose name starts with "weapon" or "item_"
922+
PathEntity = 0x0080, // Any entity whose name starts with "path_"
923+
Unknown1 = 0x8000, // TODO: This appears to be related to models, and may have been introduced in a newer JACK version?
910924
}
911925
}
912926
}

Sledge.Formats.Map/Sledge.Formats.Map.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Authors>LogicAndTrick</Authors>
66
<Description>Parsers for map source files used by level editors. Currently supports MAP files in the idtech2 and valve formats, Worldcraft RMF v2.2, and partial support for Source Hammer VMF and Jackhammer/JACK JMF formats.</Description>
7-
<Copyright>2022 LogicAndTrick</Copyright>
7+
<Copyright>2025 LogicAndTrick</Copyright>
88
<PackageLicenseExpression>MIT</PackageLicenseExpression>
99
<PackageProjectUrl>https://github.com/LogicAndTrick/sledge-formats</PackageProjectUrl>
1010
<PackageIcon>sledge-logo.png</PackageIcon>
1111
<RepositoryUrl>https://github.com/LogicAndTrick/sledge-formats</RepositoryUrl>
1212
<RepositoryType>Git</RepositoryType>
1313
<PackageTags>half-life quake valve hammer worldcraft jackhammer jack rmf vmf map jmf</PackageTags>
14-
<PackageReleaseNotes>Update to System.Numerics.Vectors 4.6.1</PackageReleaseNotes>
15-
<Version>1.2.7</Version>
14+
<PackageReleaseNotes>Add JMF flags to entities so JACK loads them properly</PackageReleaseNotes>
15+
<Version>1.2.8</Version>
1616
<DebugType>full</DebugType>
1717
<DebugSymbols>true</DebugSymbols>
1818
</PropertyGroup>

0 commit comments

Comments
 (0)