diff --git a/premake5.lua b/premake5.lua index 06454952..ba814d55 100644 --- a/premake5.lua +++ b/premake5.lua @@ -82,6 +82,7 @@ group "" -- ======================== -- Projects -- ======================== +include "src/Common.lua" include "src/Crypto.lua" include "src/Linker.lua" include "src/Unlinker.lua" @@ -99,6 +100,7 @@ include "src/ObjWriting.lua" -- Components group: All projects assist or are part of a tool group "Components" + Common:project() Crypto:project() Utils:project() ZoneCode:project() diff --git a/src/Common.lua b/src/Common.lua new file mode 100644 index 00000000..d6be3d96 --- /dev/null +++ b/src/Common.lua @@ -0,0 +1,41 @@ +Common = {} + +function Common:include(includes) + if includes:handle(self:name()) then + Utils:include(includes) + includedirs { + path.join(ProjectFolder(), "Common") + } + end +end + +function Common:link(links) + links:add(self:name()) + links:linkto(Utils) +end + +function Common:use() + +end + +function Common:name() + return "Common" +end + +function Common:project() + local folder = ProjectFolder() + local includes = Includes:create() + + project(self:name()) + targetdir(TargetDirectoryLib) + location "%{wks.location}/src/%{prj.name}" + kind "StaticLib" + language "C++" + + files { + path.join(folder, "Common/**.h"), + path.join(folder, "Common/**.cpp") + } + + self:include(includes) +end diff --git a/src/ZoneCommon/Game/GameLanguage.h b/src/Common/Game/GameLanguage.h similarity index 100% rename from src/ZoneCommon/Game/GameLanguage.h rename to src/Common/Game/GameLanguage.h diff --git a/src/ZoneCommon/Game/IGame.h b/src/Common/Game/IGame.h similarity index 100% rename from src/ZoneCommon/Game/IGame.h rename to src/Common/Game/IGame.h diff --git a/src/ZoneCommon/Game/IW4/CommonIW4.cpp b/src/Common/Game/IW4/CommonIW4.cpp similarity index 100% rename from src/ZoneCommon/Game/IW4/CommonIW4.cpp rename to src/Common/Game/IW4/CommonIW4.cpp diff --git a/src/ZoneCommon/Game/IW4/CommonIW4.h b/src/Common/Game/IW4/CommonIW4.h similarity index 100% rename from src/ZoneCommon/Game/IW4/CommonIW4.h rename to src/Common/Game/IW4/CommonIW4.h diff --git a/src/ZoneCommon/Game/IW4/GameIW4.cpp b/src/Common/Game/IW4/GameIW4.cpp similarity index 100% rename from src/ZoneCommon/Game/IW4/GameIW4.cpp rename to src/Common/Game/IW4/GameIW4.cpp diff --git a/src/ZoneCommon/Game/IW4/GameIW4.h b/src/Common/Game/IW4/GameIW4.h similarity index 100% rename from src/ZoneCommon/Game/IW4/GameIW4.h rename to src/Common/Game/IW4/GameIW4.h diff --git a/src/ZoneCommon/Game/IW4/IW4.h b/src/Common/Game/IW4/IW4.h similarity index 100% rename from src/ZoneCommon/Game/IW4/IW4.h rename to src/Common/Game/IW4/IW4.h diff --git a/src/ZoneCommon/Game/IW4/IW4_Assets.h b/src/Common/Game/IW4/IW4_Assets.h similarity index 100% rename from src/ZoneCommon/Game/IW4/IW4_Assets.h rename to src/Common/Game/IW4/IW4_Assets.h diff --git a/src/ZoneCommon/Game/T6/CommonT6.cpp b/src/Common/Game/T6/CommonT6.cpp similarity index 100% rename from src/ZoneCommon/Game/T6/CommonT6.cpp rename to src/Common/Game/T6/CommonT6.cpp diff --git a/src/ZoneCommon/Game/T6/CommonT6.h b/src/Common/Game/T6/CommonT6.h similarity index 100% rename from src/ZoneCommon/Game/T6/CommonT6.h rename to src/Common/Game/T6/CommonT6.h diff --git a/src/ZoneCommon/Game/T6/GameT6.cpp b/src/Common/Game/T6/GameT6.cpp similarity index 100% rename from src/ZoneCommon/Game/T6/GameT6.cpp rename to src/Common/Game/T6/GameT6.cpp diff --git a/src/ZoneCommon/Game/T6/GameT6.h b/src/Common/Game/T6/GameT6.h similarity index 100% rename from src/ZoneCommon/Game/T6/GameT6.h rename to src/Common/Game/T6/GameT6.h diff --git a/src/ZoneCommon/Game/T6/T6.h b/src/Common/Game/T6/T6.h similarity index 100% rename from src/ZoneCommon/Game/T6/T6.h rename to src/Common/Game/T6/T6.h diff --git a/src/ZoneCommon/Game/T6/T6_Assets.h b/src/Common/Game/T6/T6_Assets.h similarity index 100% rename from src/ZoneCommon/Game/T6/T6_Assets.h rename to src/Common/Game/T6/T6_Assets.h diff --git a/src/ObjCommon/Image/DdsTypes.h b/src/Common/Image/DdsTypes.h similarity index 100% rename from src/ObjCommon/Image/DdsTypes.h rename to src/Common/Image/DdsTypes.h diff --git a/src/ObjCommon/Image/DxgiFormat.h b/src/Common/Image/DxgiFormat.h similarity index 100% rename from src/ObjCommon/Image/DxgiFormat.h rename to src/Common/Image/DxgiFormat.h diff --git a/src/ObjCommon/Image/ImageFormat.cpp b/src/Common/Image/ImageFormat.cpp similarity index 100% rename from src/ObjCommon/Image/ImageFormat.cpp rename to src/Common/Image/ImageFormat.cpp diff --git a/src/ObjCommon/Image/ImageFormat.h b/src/Common/Image/ImageFormat.h similarity index 100% rename from src/ObjCommon/Image/ImageFormat.h rename to src/Common/Image/ImageFormat.h diff --git a/src/ObjCommon/Image/IwiTypes.h b/src/Common/Image/IwiTypes.h similarity index 100% rename from src/ObjCommon/Image/IwiTypes.h rename to src/Common/Image/IwiTypes.h diff --git a/src/ObjCommon/Image/Texture.cpp b/src/Common/Image/Texture.cpp similarity index 100% rename from src/ObjCommon/Image/Texture.cpp rename to src/Common/Image/Texture.cpp diff --git a/src/ObjCommon/Image/Texture.h b/src/Common/Image/Texture.h similarity index 100% rename from src/ObjCommon/Image/Texture.h rename to src/Common/Image/Texture.h diff --git a/src/ObjCommon/Image/TextureConverter.cpp b/src/Common/Image/TextureConverter.cpp similarity index 100% rename from src/ObjCommon/Image/TextureConverter.cpp rename to src/Common/Image/TextureConverter.cpp diff --git a/src/ObjCommon/Image/TextureConverter.h b/src/Common/Image/TextureConverter.h similarity index 100% rename from src/ObjCommon/Image/TextureConverter.h rename to src/Common/Image/TextureConverter.h diff --git a/src/ZoneCommon/Zone/ZoneTypes.h b/src/Common/Zone/ZoneTypes.h similarity index 100% rename from src/ZoneCommon/Zone/ZoneTypes.h rename to src/Common/Zone/ZoneTypes.h diff --git a/src/ObjCommon.lua b/src/ObjCommon.lua index a7ccb245..2d591bbe 100644 --- a/src/ObjCommon.lua +++ b/src/ObjCommon.lua @@ -2,7 +2,7 @@ ObjCommon = {} function ObjCommon:include(includes) if includes:handle(self:name()) then - ZoneCommon:include(includes) + Common:include(includes) minizip:include(includes) includedirs { path.join(ProjectFolder(), "ObjCommon") @@ -13,7 +13,7 @@ end function ObjCommon:link(links) links:add(self:name()) links:linkto(Utils) - links:linkto(ZoneCommon) + links:linkto(Common) links:linkto(minizip) end diff --git a/src/ObjCommon/ObjContainer/ObjContainerReferenceable.cpp b/src/ObjCommon/ObjContainer/ObjContainerReferenceable.cpp index e8e184d4..9592c62e 100644 --- a/src/ObjCommon/ObjContainer/ObjContainerReferenceable.cpp +++ b/src/ObjCommon/ObjContainer/ObjContainerReferenceable.cpp @@ -1,13 +1,13 @@ #include "ObjContainerReferenceable.h" -void ObjContainerReferenceable::AddReference(Zone* referencer) +void ObjContainerReferenceable::AddReference(void* referencer) { m_references.insert(referencer); } -bool ObjContainerReferenceable::RemoveReference(Zone* zone) +bool ObjContainerReferenceable::RemoveReference(void* referencer) { - return m_references.erase(zone) > 0; + return m_references.erase(referencer) > 0; } bool ObjContainerReferenceable::IsReferenced() const diff --git a/src/ObjCommon/ObjContainer/ObjContainerReferenceable.h b/src/ObjCommon/ObjContainer/ObjContainerReferenceable.h index 1e7e92a1..2d51165f 100644 --- a/src/ObjCommon/ObjContainer/ObjContainerReferenceable.h +++ b/src/ObjCommon/ObjContainer/ObjContainerReferenceable.h @@ -1,16 +1,15 @@ #pragma once #include "IObjContainer.h" -#include "Zone/Zone.h" #include class ObjContainerReferenceable : public IObjContainer { - std::set m_references; + std::set m_references; public: - void AddReference(Zone* referencer); - bool RemoveReference(Zone* zone); + void AddReference(void* referencer); + bool RemoveReference(void* referencer); bool IsReferenced() const; }; diff --git a/src/ZoneCode.lua b/src/ZoneCode.lua index 6b2d6a84..aafed887 100644 --- a/src/ZoneCode.lua +++ b/src/ZoneCode.lua @@ -202,7 +202,7 @@ function ZoneCode:project() buildinputs { path.join(ProjectFolder(), "ZoneCode/Game/%{file.basename}/%{file.basename}.h"), path.join(ProjectFolder(), "ZoneCode/Game/%{file.basename}/%{file.basename}_Commands.txt"), - path.join(ProjectFolder(), "ZoneCommon/Game/%{file.basename}/%{file.basename}_Assets.h"), + path.join(ProjectFolder(), "Common/Game/%{file.basename}/%{file.basename}_Assets.h"), TargetDirectoryBin .. "/" .. ExecutableByOs('ZoneCodeGenerator') } filter {} diff --git a/src/ZoneCode/Game/IW4/IW4.h b/src/ZoneCode/Game/IW4/IW4.h index b15f0318..da61db12 100644 --- a/src/ZoneCode/Game/IW4/IW4.h +++ b/src/ZoneCode/Game/IW4/IW4.h @@ -3,6 +3,6 @@ // Entry point for IW4 code generation #include "../Common.h" -#include "../../../ZoneCommon/Game/IW4/IW4_Assets.h" +#include "../../../Common/Game/IW4/IW4_Assets.h" // EOF \ No newline at end of file diff --git a/src/ZoneCode/Game/T6/T6.h b/src/ZoneCode/Game/T6/T6.h index 5adc2463..eca6b0c0 100644 --- a/src/ZoneCode/Game/T6/T6.h +++ b/src/ZoneCode/Game/T6/T6.h @@ -3,6 +3,6 @@ // Entry point for T6 code generation #include "../Common.h" -#include "../../../ZoneCommon/Game/T6/T6_Assets.h" +#include "../../../Common/Game/T6/T6_Assets.h" // EOF \ No newline at end of file diff --git a/src/ZoneCommon.lua b/src/ZoneCommon.lua index a0da0eea..d6ba488b 100644 --- a/src/ZoneCommon.lua +++ b/src/ZoneCommon.lua @@ -2,17 +2,19 @@ ZoneCommon = {} function ZoneCommon:include(includes) if includes:handle(self:name()) then - Utils:include(includes) - ObjCommon:include(includes) includedirs { path.join(ProjectFolder(), "ZoneCommon") } + Utils:include(includes) + Common:include(includes) + ObjCommon:include(includes) end end function ZoneCommon:link(links) links:add(self:name()) links:linkto(Utils) + links:linkto(Common) links:linkto(ObjCommon) end diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h index 1d100d76..4d48c66d 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h @@ -4,7 +4,7 @@ #include "Pool/ZoneAssetPools.h" #include "Pool/AssetPool.h" -#include "IW4.h" +#include "Game/IW4/IW4.h" class GameAssetPoolIW4 final : public ZoneAssetPools { diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h index 13e6ac13..c1e196e7 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h @@ -2,7 +2,7 @@ #include "Pool/ZoneAssetPools.h" #include "Pool/AssetPool.h" -#include "T6.h" +#include "Game/T6/T6.h" class GameAssetPoolT6 final : public ZoneAssetPools { diff --git a/src/ZoneCommon/Zone/Zone.h b/src/ZoneCommon/Zone/Zone.h index 66c2635a..0d14c6d2 100644 --- a/src/ZoneCommon/Zone/Zone.h +++ b/src/ZoneCommon/Zone/Zone.h @@ -1,14 +1,15 @@ #pragma once -#include -#include "ZoneTypes.h" +#include +#include +#include + +#include "Zone/ZoneTypes.h" #include "Pool/ZoneAssetPools.h" #include "Game/IGame.h" #include "Game/GameLanguage.h" #include "Zone/XBlock.h" #include "ZoneMemory.h" -#include -#include class IGame; class ZoneAssetPools; diff --git a/src/ZoneLoading.lua b/src/ZoneLoading.lua index f564e064..940b2f6c 100644 --- a/src/ZoneLoading.lua +++ b/src/ZoneLoading.lua @@ -11,6 +11,7 @@ end function ZoneLoading:link(links) links:add(self:name()) + links:add("pthread") links:linkto(Crypto) links:linkto(Utils) links:linkto(ZoneCommon) diff --git a/test/ObjCommonTests/Image/ImageFormatTests.cpp b/test/ObjCommonTests/Image/ImageFormatTests.cpp index 9baef30f..b87a3d81 100644 --- a/test/ObjCommonTests/Image/ImageFormatTests.cpp +++ b/test/ObjCommonTests/Image/ImageFormatTests.cpp @@ -1,14 +1,16 @@ #include +#include + #include "Image/ImageFormat.h" namespace image::image_format { TEST_CASE("ImageFormat: EnsureAllFormatsArrayIndicesAreIds", "[image]") { - REQUIRE(static_cast(ImageFormatId::MAX) == _countof(ImageFormat::ALL_FORMATS)); + REQUIRE(static_cast(ImageFormatId::MAX) == std::extent::value); - for(unsigned i = 0; i < _countof(ImageFormat::ALL_FORMATS); i++) + for(unsigned i = 0; i < std::extent::value; i++) { REQUIRE(ImageFormat::ALL_FORMATS[i] != nullptr); REQUIRE(i == static_cast(ImageFormat::ALL_FORMATS[i]->GetId()));