// Copyright (c) 2025 Codemongous LLC. All Rights Reserved.

#pragma once

// Helper for ISCW_UE_VERSION_NEWER_THAN and ISCW_UE_VERSION_OLDER_THAN
#define ISCW_UE_GREATER_SORT(Value, ValueToBeGreaterThan, TieBreaker) \
	(((Value) > (ValueToBeGreaterThan)) || (((Value) == (ValueToBeGreaterThan)) && (TieBreaker)))

// Version comparison macro that is defined to true if the UE version is newer or equal than MajorVer.MinorVer.PatchVer 
// and false otherwise
// (a typical use is for backward compatible code)
#define ISCW_UE_VERSION_NEWER_THAN_OR_EQUAL(MajorVersion, MinorVersion, PatchVersion)\
	ISCW_UE_GREATER_SORT(ISCW_ENGINE_MAJOR_VERSION, MajorVersion, ISCW_UE_GREATER_SORT(ISCW_ENGINE_MINOR_VERSION, MinorVersion, ISCW_UE_GREATER_SORT(ISCW_ENGINE_PATCH_VERSION, PatchVersion, true)))

// Version comparison macro that is defined to true if the UE version is newer than MajorVer.MinorVer.PatchVer and false otherwise
// (a typical use is to alert integrators to revisit this code when upgrading to a new engine version)
#define ISCW_UE_VERSION_NEWER_THAN(MajorVersion, MinorVersion, PatchVersion) \
	ISCW_UE_GREATER_SORT(ISCW_ENGINE_MAJOR_VERSION, MajorVersion, ISCW_UE_GREATER_SORT(ISCW_ENGINE_MINOR_VERSION, MinorVersion, ISCW_UE_GREATER_SORT(ISCW_ENGINE_PATCH_VERSION, PatchVersion, false)))

// Version comparison macro that is defined to true if the UE version is older than MajorVer.MinorVer.PatchVer and false otherwise
// (use when making code that needs to be compatible with older engine versions)
#define ISCW_UE_VERSION_OLDER_THAN(MajorVersion, MinorVersion, PatchVersion) \
	ISCW_UE_GREATER_SORT(MajorVersion, ISCW_ENGINE_MAJOR_VERSION, ISCW_UE_GREATER_SORT(MinorVersion, ISCW_ENGINE_MINOR_VERSION, ISCW_UE_GREATER_SORT(PatchVersion, ISCW_ENGINE_PATCH_VERSION, false)))