Skip to content

Commit

Permalink
[WIP] Add support for Starfield
Browse files Browse the repository at this point in the history
This is WIP because the libraries it depends on are unreleased, and there are no tests.
  • Loading branch information
Ortham committed Sep 4, 2023
1 parent 0a7efcb commit 2a88cc3
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 66 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ set(GTEST_LIBRARIES "${BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRAR

ExternalProject_Add(esplugin
PREFIX "external"
URL "https://github.com/Ortham/esplugin/archive/4.0.0.tar.gz"
URL_HASH "SHA256=e3aa21ffbfd8ce55e3398fbd789adb2aa0d2cceefc99bcc789f02ff95cc98b86"
URL "https://github.com/Ortham/esplugin/archive/starfield.tar.gz"
#URL_HASH "SHA256=e3aa21ffbfd8ce55e3398fbd789adb2aa0d2cceefc99bcc789f02ff95cc98b86"
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND cargo build --release --manifest-path ffi/Cargo.toml --target ${RUST_TARGET} &&
Expand All @@ -98,8 +98,8 @@ endif()

ExternalProject_Add(libloadorder
PREFIX "external"
URL "https://github.com/Ortham/libloadorder/archive/14.2.1.tar.gz"
URL_HASH "SHA256=4341844407f55ce9d96826a933ac35dfb22bbad14906e5dff742f910182eca93"
URL "https://github.com/Ortham/libloadorder/archive/starfield.tar.gz"
#URL_HASH "SHA256=4341844407f55ce9d96826a933ac35dfb22bbad14906e5dff742f910182eca93"
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND cargo build --release --manifest-path ffi/Cargo.toml --target ${RUST_TARGET} &&
Expand All @@ -116,8 +116,8 @@ endif()

ExternalProject_Add(loot-condition-interpreter
PREFIX "external"
URL "https://github.com/loot/loot-condition-interpreter/archive/3.0.0.tar.gz"
URL_HASH "SHA256=6492c19848f01f297537da6a561e8d0c0a79e7c15e3ddf958910dec7cdfe0abf"
URL "https://github.com/loot/loot-condition-interpreter/archive/starfield.tar.gz"
#URL_HASH "SHA256=6492c19848f01f297537da6a561e8d0c0a79e7c15e3ddf958910dec7cdfe0abf"
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND cargo build --release --manifest-path ffi/Cargo.toml --target ${RUST_TARGET} &&
Expand Down
2 changes: 2 additions & 0 deletions include/loot/enum/game_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ enum struct GameType : unsigned int {
tes5vr,
/** The Elder Scrolls III: Morrowind */
tes3,
/** Starfield */
starfield
};
}

Expand Down
13 changes: 13 additions & 0 deletions include/loot/plugin_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,26 @@ class PluginInterface {
*/
virtual bool IsLightPlugin() const = 0;

/**
* Check if the plugin is an override plugin.
* @return True if plugin is an override plugin, false otherwise.
*/
virtual bool IsOverridePlugin() const = 0;

/**
* Check if the plugin is or would be valid as a light plugin.
* @return True if the plugin is a valid light plugin or would be a valid
* light plugin, false otherwise.
*/
virtual bool IsValidAsLightPlugin() const = 0;

/**
* Check if the plugin is or would be valid as an override plugin.
* @return True if the plugin is a valid override plugin or would be a valid
* override plugin, false otherwise.
*/
virtual bool IsValidAsOverridePlugin() const = 0;

/**
* Check if the plugin contains any records other than its TES4 header.
* @return True if the plugin only contains a TES4 header, false otherwise.
Expand Down
2 changes: 2 additions & 0 deletions src/api/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const char* DescribeGameType(GameType gameType) {
return "The Elder Scrolls V: Skyrim VR";
case GameType::tes3:
return "The Elder Scrolls III: Morrowind";
case GameType::starfield:
return "Starfield";
default:
return "Unknown";
}
Expand Down
7 changes: 4 additions & 3 deletions src/api/bsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void StoreHashes(std::map<uint64_t, std::set<uint64_t>>& folderFileHashes,
}
}

// Normalise the path the same way that BA2 hashes do (it's thet same as for
// Normalise the path the same way that BA2 hashes do (it's the same as for
// BSAs).
void NormalisePath(std::string& filePath) {
for (size_t i = 0; i < filePath.size(); ++i) {
Expand Down Expand Up @@ -217,7 +217,8 @@ std::map<uint64_t, std::set<uint64_t>> GetAssetsInBA2(std::istream& in,
throw std::runtime_error("BA2 file header type ID is invalid");
}

if (header.version != 1) {
// The header version is 1 for Fallout 4 and 2 or 3 for Starfield.
if (header.version != 1 && header.version != 2 && header.version != 3) {
throw std::runtime_error("BA2 file header version is invalid");
}

Expand All @@ -237,7 +238,7 @@ std::map<uint64_t, std::set<uint64_t>> GetAssetsInBA2(std::istream& in,
bool ShouldWarnAboutHashCollisions(const std::filesystem::path& archivePath) {
const auto filename = archivePath.filename().u8string();

return !boost::iends_with(filename, ".ba2") ||
return !boost::iends_with(filename, BA2_FILE_EXTENSION) ||
(!boost::istarts_with(filename, "Fallout4 - ") &&
!boost::istarts_with(filename, "DLCUltraHighResolution - "));
}
Expand Down
3 changes: 3 additions & 0 deletions src/api/bsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include <vector>

namespace loot {
static constexpr const char* BSA_FILE_EXTENSION = ".bsa";
static constexpr const char* BA2_FILE_EXTENSION = ".ba2";

std::map<uint64_t, std::set<uint64_t>> GetAssetsInBethesdaArchive(
const std::filesystem::path& archivePath);

Expand Down
7 changes: 6 additions & 1 deletion src/api/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@ bool IsMicrosoftStoreInstall(const GameType gameType,
"appxmanifest.xml");
case GameType::tes5se:
case GameType::fo4:
case GameType::starfield:
return std::filesystem::exists(gamePath / "appxmanifest.xml");
default:
case GameType::tes5:
case GameType::tes5vr:
case GameType::fo4vr:
return false;
default:
throw std::logic_error("Unrecognised game type");
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/api/game/load_order_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ unsigned int mapGameId(GameType gameType) {
return LIBLO_GAME_FO4;
case GameType::fo4vr:
return LIBLO_GAME_FO4VR;
case GameType::starfield:
return LIBLO_GAME_STARFIELD;
default:
throw std::logic_error("Unexpected game type");
}
Expand Down
2 changes: 2 additions & 0 deletions src/api/metadata/condition_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ int mapGameType(GameType gameType) {
return LCI_GAME_FALLOUT_4;
case GameType::fo4vr:
return LCI_GAME_FALLOUT_4_VR;
case GameType::starfield:
return LCI_GAME_STARFIELD;
default:
throw std::runtime_error(
"Unrecognised game type encountered while mapping for condition "
Expand Down
Loading

0 comments on commit 2a88cc3

Please sign in to comment.