From b52bf90f2f05c9d42bb4e7cd558576d2e30ffda1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Pivo=C5=88ka?= Date: Tue, 31 Dec 2024 04:00:29 +0100 Subject: [PATCH] Make IsGameVersion virtual, specify MP4/TM2020 for ghosts --- Src/GBX.NET/Engines/Game/CGameCtnGhost.cs | 13 +++++++++++++ Src/GBX.NET/Engines/MwFoundations/CMwNod.cs | 16 +++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Src/GBX.NET/Engines/Game/CGameCtnGhost.cs b/Src/GBX.NET/Engines/Game/CGameCtnGhost.cs index 4fddd5bc5..235b2552f 100644 --- a/Src/GBX.NET/Engines/Game/CGameCtnGhost.cs +++ b/Src/GBX.NET/Engines/Game/CGameCtnGhost.cs @@ -206,4 +206,17 @@ public override string ToString() return $"{Time.ToTmString()} ({(Speed.HasValue ? $"{Speed}km/h, " : "")}{StuntsScore} pts.)"; } } + + public override bool IsGameVersion(GameVersion version, bool strict = false) + { + if (!base.IsGameVersion(version, strict)) + { + return false; + } + if (version == (GameVersion.MP4 | GameVersion.TM2020)) + { + return Chunks.Any(static x => x is Chunk03092029); + } + return true; + } } diff --git a/Src/GBX.NET/Engines/MwFoundations/CMwNod.cs b/Src/GBX.NET/Engines/MwFoundations/CMwNod.cs index f21d0da17..46a335137 100644 --- a/Src/GBX.NET/Engines/MwFoundations/CMwNod.cs +++ b/Src/GBX.NET/Engines/MwFoundations/CMwNod.cs @@ -670,6 +670,9 @@ protected void DeepCloneChunks(IClass dest) } } + /// + /// The version of the game where this node should be accepted without a game crash. + /// public GameVersion GameVersion { get @@ -685,13 +688,24 @@ public GameVersion GameVersion } } - public bool IsGameVersion(GameVersion version, bool strict = false) + /// + /// Checks if the node is accepted in the given game version without a game crash. + /// + /// Game version flags. + /// If enabled, checks for the exact flag match (if accepted in MP4 and TM2020, only MP4 | TM2020 will return true). + /// True if matches, false if not. + public virtual bool IsGameVersion(GameVersion version, bool strict = false) { return strict ? GameVersion == version : (GameVersion & version) == version; } + /// + /// Checks if the node could be accepted in the given game version. + /// + /// Game version flags. + /// True if matches, false if not. public bool CanBeGameVersion(GameVersion version) { return (GameVersion & version) != 0;