Skip to content

Commit

Permalink
Don't automatically load the 'origin' keyvalue for non-point entities
Browse files Browse the repository at this point in the history
  • Loading branch information
LogicAndTrick committed Jul 29, 2023
1 parent 8def831 commit c11028f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Sledge.Formats.Map/Formats/JackhamerJmfFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ private List<JmfEntity> ReadEntities(MapFile map, BinaryReader br)
};

var origin = br.ReadVector3();
ent.Entity.Properties["origin"] = $"{origin.X} {origin.Y} {origin.Z}";

ent.Flags = br.ReadInt32();
ent.GroupID = br.ReadInt32();
Expand Down Expand Up @@ -292,6 +291,9 @@ private List<JmfEntity> ReadEntities(MapFile map, BinaryReader br)
ent.Solids.Add(ReadSolid(map, br));
}

// Don't add the origin key for brush entities, we use origin brushes for that
if (!ent.Solids.Any()) ent.Entity.Properties["origin"] = $"{origin.X} {origin.Y} {origin.Z}";

entities.Add(ent);
}

Expand Down
8 changes: 8 additions & 0 deletions Sledge.Formats.Map/Formats/QuakeMapFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,14 @@ private static void WriteEntityWithSolids(StreamWriter sw, Entity e, IEnumerable

WriteProperty(sw, "classname", e.ClassName);

if (e.ClassName == "worldspawn")
{
if (styleHint != "idTech2" && styleHint != "idTech3" && styleHint != "idTech4")
{
WriteProperty(sw, "mapversion", "220");
}
}

if (e.SpawnFlags != 0)
{
WriteProperty(sw, "spawnflags", e.SpawnFlags.ToString(CultureInfo.InvariantCulture));
Expand Down
7 changes: 5 additions & 2 deletions Sledge.Formats.Map/Formats/WorldcraftRmfFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ private static Entity ReadEntity(MapFile map, RmfVersion version, BinaryReader b
ReadMapBase(map, version, ent, br);
ReadEntityData(version, ent, br);
br.ReadBytes(2); // Unused

// Don't add the origin key for brush entities, we use origin brushes for that
var origin = br.ReadVector3();
ent.Properties["origin"] = $"{origin.X.ToString("0.000", CultureInfo.InvariantCulture)} {origin.Y.ToString("0.000", CultureInfo.InvariantCulture)} {origin.Z.ToString("0.000", CultureInfo.InvariantCulture)}";
if (!ent.Children.Any()) ent.Properties["origin"] = $"{origin.X.ToString("0.000", CultureInfo.InvariantCulture)} {origin.Y.ToString("0.000", CultureInfo.InvariantCulture)} {origin.Z.ToString("0.000", CultureInfo.InvariantCulture)}";

br.ReadBytes(4); // Unused
return ent;
}
Expand Down Expand Up @@ -471,7 +474,7 @@ private static void WriteEntityData(Entity data, BinaryWriter bw)
bw.Write(new byte[4]); // Unused
bw.Write(data.SpawnFlags);

var props = data.SortedProperties.Where(x => !String.IsNullOrWhiteSpace(x.Key)).ToList();
var props = data.SortedProperties.Where(x => !String.IsNullOrWhiteSpace(x.Key) && x.Key != "origin").ToList();
bw.Write(props.Count);
foreach (var p in props)
{
Expand Down
4 changes: 2 additions & 2 deletions Sledge.Formats.Map/Sledge.Formats.Map.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<RepositoryUrl>https://github.com/LogicAndTrick/sledge-formats</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageTags>half-life quake valve hammer worldcraft jackhammer jack rmf vmf map jmf</PackageTags>
<PackageReleaseNotes>Don't allow backslash escapes in map file strings</PackageReleaseNotes>
<Version>1.1.2</Version>
<PackageReleaseNotes>Don't automatically load the 'origin' keyvalue for non-point entities</PackageReleaseNotes>
<Version>1.1.3</Version>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
Expand Down

0 comments on commit c11028f

Please sign in to comment.