mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 01:36:41 +00:00
Merge branch 'master' into 'cellstore_refactor'
# Conflicts: # apps/openmw/mwworld/scene.cpp
This commit is contained in:
commit
29f3de30c2
236 changed files with 2829 additions and 2719 deletions
|
@ -1,5 +1,14 @@
|
|||
default:
|
||||
interruptible: true
|
||||
|
||||
# Merge requests have two pipelines, filter pipelines using branch and merge request event together.
|
||||
# See https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html#two-pipelines-when-pushing-to-a-branch
|
||||
workflow:
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
|
||||
# Note: We set `needs` on each job to control the job DAG.
|
||||
# See https://docs.gitlab.com/ee/ci/yaml/#needs
|
||||
|
@ -20,8 +29,6 @@ variables:
|
|||
- docker
|
||||
- linux
|
||||
image: ubuntu:22.04
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "push"
|
||||
|
||||
.Ubuntu:
|
||||
extends: .Ubuntu_Image
|
||||
|
@ -388,8 +395,6 @@ macOS12_Xcode13:
|
|||
.Windows_Ninja_Base:
|
||||
tags:
|
||||
- windows
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "push"
|
||||
before_script:
|
||||
- Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
||||
- choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1
|
||||
|
@ -491,8 +496,6 @@ macOS12_Xcode13:
|
|||
.Windows_MSBuild_Base:
|
||||
tags:
|
||||
- windows
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "push"
|
||||
before_script:
|
||||
- Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
||||
- choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1
|
||||
|
@ -590,9 +593,9 @@ Windows_MSBuild_RelWithDebInfo:
|
|||
rules:
|
||||
# run this for both pushes and schedules so 'latest successful pipeline for branch' always includes it
|
||||
- if: $CI_PIPELINE_SOURCE == "push"
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
- if: $CI_PIPELINE_SOURCE == "schedule"
|
||||
|
||||
|
||||
.Ubuntu_AndroidNDK_arm64-v8a:
|
||||
tags:
|
||||
- linux
|
||||
|
|
|
@ -20,6 +20,11 @@ if(POLICY CMP0092)
|
|||
cmake_policy(SET CMP0092 NEW)
|
||||
endif()
|
||||
|
||||
# set the timestamps of extracted contents to the time of extraction
|
||||
if(POLICY CMP0135)
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
endif()
|
||||
|
||||
project(OpenMW)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
#include <components/bsa/compressedbsafile.hpp>
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
|
||||
#define BSATOOL_VERSION 1.1
|
||||
|
||||
|
@ -17,10 +20,10 @@ namespace bpo = boost::program_options;
|
|||
struct Arguments
|
||||
{
|
||||
std::string mode;
|
||||
std::string filename;
|
||||
std::string extractfile;
|
||||
std::string addfile;
|
||||
std::string outdir;
|
||||
std::filesystem::path filename;
|
||||
std::filesystem::path extractfile;
|
||||
std::filesystem::path addfile;
|
||||
std::filesystem::path outdir;
|
||||
|
||||
bool longformat;
|
||||
bool fullpath;
|
||||
|
@ -55,7 +58,7 @@ bool parseOptions (int argc, char** argv, Arguments &info)
|
|||
|
||||
hidden.add_options()
|
||||
( "mode,m", bpo::value<std::string>(), "bsatool mode")
|
||||
( "input-file,i", bpo::value< std::vector<std::string> >(), "input file")
|
||||
( "input-file,i", bpo::value< Files::MaybeQuotedPathContainer >(), "input file")
|
||||
;
|
||||
|
||||
bpo::positional_options_description p;
|
||||
|
@ -112,37 +115,39 @@ bool parseOptions (int argc, char** argv, Arguments &info)
|
|||
<< desc << std::endl;
|
||||
return false;
|
||||
}
|
||||
info.filename = variables["input-file"].as< std::vector<std::string> >()[0];
|
||||
auto inputFiles = variables["input-file"].as< Files::MaybeQuotedPathContainer >();
|
||||
|
||||
info.filename = inputFiles[0].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
|
||||
// Default output to the working directory
|
||||
info.outdir = ".";
|
||||
info.outdir = std::filesystem::current_path();
|
||||
|
||||
if (info.mode == "extract")
|
||||
{
|
||||
if (variables["input-file"].as< std::vector<std::string> >().size() < 2)
|
||||
if (inputFiles.size() < 2)
|
||||
{
|
||||
std::cout << "\nERROR: file to extract unspecified\n\n"
|
||||
<< desc << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (variables["input-file"].as< std::vector<std::string> >().size() > 1)
|
||||
info.extractfile = variables["input-file"].as< std::vector<std::string> >()[1];
|
||||
if (variables["input-file"].as< std::vector<std::string> >().size() > 2)
|
||||
info.outdir = variables["input-file"].as< std::vector<std::string> >()[2];
|
||||
if (inputFiles.size() > 1)
|
||||
info.extractfile = inputFiles[1].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
if (inputFiles.size() > 2)
|
||||
info.outdir = inputFiles[2].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
}
|
||||
else if (info.mode == "add")
|
||||
{
|
||||
if (variables["input-file"].as< std::vector<std::string> >().size() < 1)
|
||||
if (inputFiles.empty())
|
||||
{
|
||||
std::cout << "\nERROR: file to add unspecified\n\n"
|
||||
<< desc << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (variables["input-file"].as< std::vector<std::string> >().size() > 1)
|
||||
info.addfile = variables["input-file"].as< std::vector<std::string> >()[1];
|
||||
if (inputFiles.size() > 1)
|
||||
info.addfile = inputFiles[1].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
}
|
||||
else if (variables["input-file"].as< std::vector<std::string> >().size() > 1)
|
||||
info.outdir = variables["input-file"].as< std::vector<std::string> >()[1];
|
||||
else if (inputFiles.size() > 1)
|
||||
info.outdir = inputFiles[1].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
|
||||
info.longformat = variables.count("long") != 0;
|
||||
info.fullpath = variables.count("full-path") != 0;
|
||||
|
@ -176,17 +181,17 @@ int list(std::unique_ptr<File>& bsa, Arguments& info)
|
|||
template<typename File>
|
||||
int extract(std::unique_ptr<File>& bsa, Arguments& info)
|
||||
{
|
||||
std::string archivePath = info.extractfile;
|
||||
Misc::StringUtils::replaceAll(archivePath, "/", "\\");
|
||||
auto archivePath = info.extractfile.u8string();
|
||||
Misc::StringUtils::replaceAll(archivePath, u8"/", u8"\\");
|
||||
|
||||
std::string extractPath = info.extractfile;
|
||||
Misc::StringUtils::replaceAll(extractPath, "\\", "/");
|
||||
auto extractPath = info.extractfile.u8string();
|
||||
Misc::StringUtils::replaceAll(extractPath, u8"\\", u8"/");
|
||||
|
||||
Files::IStreamPtr stream;
|
||||
// Get a stream for the file to extract
|
||||
for (auto it = bsa->getList().rbegin(); it != bsa->getList().rend(); ++it)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(std::string(it->name()), archivePath))
|
||||
if (Misc::StringUtils::ciEqual(Misc::StringUtils::stringToU8String(it->name()), archivePath))
|
||||
{
|
||||
stream = bsa->getFile(&*it);
|
||||
break;
|
||||
|
@ -194,20 +199,19 @@ int extract(std::unique_ptr<File>& bsa, Arguments& info)
|
|||
}
|
||||
if (!stream)
|
||||
{
|
||||
std::cout << "ERROR: file '" << archivePath << "' not found\n";
|
||||
std::cout << "In archive: " << info.filename << std::endl;
|
||||
std::cout << "ERROR: file '" << Misc::StringUtils::u8StringToString(archivePath) << "' not found\n";
|
||||
std::cout << "In archive: " << Files::pathToUnicodeString(info.filename) << std::endl;
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Get the target path (the path the file will be extracted to)
|
||||
std::filesystem::path relPath (extractPath);
|
||||
std::filesystem::path outdir (info.outdir);
|
||||
|
||||
std::filesystem::path target;
|
||||
if (info.fullpath)
|
||||
target = outdir / relPath;
|
||||
target = info.outdir / relPath;
|
||||
else
|
||||
target = outdir / relPath.filename();
|
||||
target = info.outdir / relPath.filename();
|
||||
|
||||
// Create the directory hierarchy
|
||||
std::filesystem::create_directories(target.parent_path());
|
||||
|
@ -215,14 +219,14 @@ int extract(std::unique_ptr<File>& bsa, Arguments& info)
|
|||
std::filesystem::file_status s = std::filesystem::status(target.parent_path());
|
||||
if (!std::filesystem::is_directory(s))
|
||||
{
|
||||
std::cout << "ERROR: " << target.parent_path() << " is not a directory." << std::endl;
|
||||
std::cout << "ERROR: " << Files::pathToUnicodeString(target.parent_path()) << " is not a directory." << std::endl;
|
||||
return 3;
|
||||
}
|
||||
|
||||
std::ofstream out(target, std::ios::binary);
|
||||
|
||||
// Write the file to disk
|
||||
std::cout << "Extracting " << info.extractfile << " to " << target << std::endl;
|
||||
std::cout << "Extracting " << Files::pathToUnicodeString(info.extractfile) << " to " << Files::pathToUnicodeString(target) << std::endl;
|
||||
|
||||
out << stream->rdbuf();
|
||||
out.close();
|
||||
|
@ -239,8 +243,8 @@ int extractAll(std::unique_ptr<File>& bsa, Arguments& info)
|
|||
Misc::StringUtils::replaceAll(extractPath, "\\", "/");
|
||||
|
||||
// Get the target path (the path the file will be extracted to)
|
||||
std::filesystem::path target (info.outdir);
|
||||
target /= extractPath;
|
||||
auto target = info.outdir;
|
||||
target /= Misc::StringUtils::stringToU8String(extractPath);
|
||||
|
||||
// Create the directory hierarchy
|
||||
std::filesystem::create_directories(target.parent_path());
|
||||
|
@ -257,7 +261,7 @@ int extractAll(std::unique_ptr<File>& bsa, Arguments& info)
|
|||
std::ofstream out(target, std::ios::binary);
|
||||
|
||||
// Write the file to disk
|
||||
std::cout << "Extracting " << target << std::endl;
|
||||
std::cout << "Extracting " << Files::pathToUnicodeString(target) << std::endl;
|
||||
out << data->rdbuf();
|
||||
out.close();
|
||||
}
|
||||
|
@ -269,7 +273,7 @@ template<typename File>
|
|||
int add(std::unique_ptr<File>& bsa, Arguments& info)
|
||||
{
|
||||
std::fstream stream(info.addfile, std::ios_base::binary | std::ios_base::out | std::ios_base::in);
|
||||
bsa->addFile(info.addfile, stream);
|
||||
bsa->addFile(Files::pathToUnicodeString(info.addfile), stream);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace
|
|||
|
||||
const auto fsStrict = variables["fs-strict"].as<bool>();
|
||||
const auto resDir = variables["resources"].as<Files::MaybeQuotedPath>();
|
||||
Version::Version v = Version::getOpenmwVersion(resDir.string());
|
||||
const auto v = Version::getOpenmwVersion(resDir);
|
||||
Log(Debug::Info) << v.describe();
|
||||
dataDirs.insert(dataDirs.begin(), resDir / "vfs");
|
||||
const auto fileCollections = Files::Collections(dataDirs, !fsStrict);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/esm/format.hpp>
|
||||
|
||||
|
@ -18,8 +18,8 @@ namespace EsmTool
|
|||
|
||||
std::string mode;
|
||||
std::string encoding;
|
||||
std::string filename;
|
||||
std::string outname;
|
||||
std::filesystem::path filename;
|
||||
std::filesystem::path outname;
|
||||
|
||||
std::vector<std::string> types;
|
||||
std::string name;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <components/esm/format.hpp>
|
||||
#include <components/files/openfile.hpp>
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include "record.hpp"
|
||||
#include "labels.hpp"
|
||||
|
@ -83,7 +85,7 @@ bool parseOptions (int argc, char** argv, Arguments &info)
|
|||
|
||||
hidden.add_options()
|
||||
( "mode,m", bpo::value<std::string>(), "esmtool mode")
|
||||
( "input-file,i", bpo::value< std::vector<std::string> >(), "input file")
|
||||
( "input-file,i", bpo::value< Files::MaybeQuotedPathContainer >(), "input file")
|
||||
;
|
||||
|
||||
bpo::positional_options_description p;
|
||||
|
@ -154,9 +156,10 @@ bool parseOptions (int argc, char** argv, Arguments &info)
|
|||
return false;
|
||||
}*/
|
||||
|
||||
info.filename = variables["input-file"].as< std::vector<std::string> >()[0];
|
||||
if (variables["input-file"].as< std::vector<std::string> >().size() > 1)
|
||||
info.outname = variables["input-file"].as< std::vector<std::string> >()[1];
|
||||
const auto inputFiles = variables["input-file"].as< Files::MaybeQuotedPathContainer >();
|
||||
info.filename = inputFiles[0].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
if (inputFiles.size() > 1)
|
||||
info.outname = inputFiles[1].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
|
||||
if (const auto it = variables.find("raw"); it != variables.end())
|
||||
info.mRawFormat = ESM::parseFormat(it->second.as<std::string>());
|
||||
|
@ -284,9 +287,9 @@ void loadCell(const Arguments& info, ESM::Cell &cell, ESM::ESMReader &esm, ESMDa
|
|||
}
|
||||
}
|
||||
|
||||
void printRawTes3(std::string_view path)
|
||||
void printRawTes3(const std::filesystem::path &path)
|
||||
{
|
||||
std::cout << "TES3 RAW file listing: " << path << '\n';
|
||||
std::cout << "TES3 RAW file listing: " << Files::pathToUnicodeString(path) << '\n';
|
||||
ESM::ESMReader esm;
|
||||
esm.openRaw(path);
|
||||
while(esm.hasMoreRecs())
|
||||
|
@ -419,7 +422,7 @@ int load(const Arguments& info, ESMData* data)
|
|||
printRawTes3(info.filename);
|
||||
break;
|
||||
case ESM::Format::Tes4:
|
||||
std::cout << "Printing raw TES4 file is not supported: " << info.filename << "\n";
|
||||
std::cout << "Printing raw TES4 file is not supported: " << Files::pathToUnicodeString(info.filename) << "\n";
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
@ -490,7 +493,7 @@ int clone(const Arguments& info)
|
|||
if (i % 3 != 0)
|
||||
std::cout << '\n';
|
||||
|
||||
std::cout << "\nSaving records to: " << info.outname << "...\n";
|
||||
std::cout << "\nSaving records to: " << Files::pathToUnicodeString(info.outname) << "...\n";
|
||||
|
||||
ESM::ESMWriter esm;
|
||||
ToUTF8::Utf8Encoder encoder (ToUTF8::calculateEncoding(info.encoding));
|
||||
|
@ -499,7 +502,7 @@ int clone(const Arguments& info)
|
|||
esm.setVersion(ESM::VER_13);
|
||||
esm.setRecordCount (recordCount);
|
||||
|
||||
std::fstream save(info.outname.c_str(), std::fstream::out | std::fstream::binary);
|
||||
std::fstream save(info.outname, std::fstream::out | std::fstream::binary);
|
||||
esm.save(save);
|
||||
|
||||
int saved = 0;
|
||||
|
@ -563,14 +566,14 @@ int comp(const Arguments& info)
|
|||
ESMData dataOne;
|
||||
if (load(fileOne, &dataOne) != 0)
|
||||
{
|
||||
std::cout << "Failed to load " << info.filename << ", aborting comparison." << std::endl;
|
||||
std::cout << "Failed to load " << Files::pathToUnicodeString(info.filename) << ", aborting comparison." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ESMData dataTwo;
|
||||
if (load(fileTwo, &dataTwo) != 0)
|
||||
{
|
||||
std::cout << "Failed to load " << info.outname << ", aborting comparison." << std::endl;
|
||||
std::cout << "Failed to load " << Files::pathToUnicodeString(info.outname) << ", aborting comparison." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <components/esm/esmcommon.hpp>
|
||||
#include <components/esm4/reader.hpp>
|
||||
#include <components/esm4/records.hpp>
|
||||
#include <components/to_utf8/to_utf8.hpp>
|
||||
|
||||
namespace EsmTool
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace
|
|||
namespace ESSImport
|
||||
{
|
||||
|
||||
Importer::Importer(const std::string &essfile, const std::string &outfile, const std::string &encoding)
|
||||
Importer::Importer(const std::filesystem::path &essfile, const std::filesystem::path &outfile, const std::string &encoding)
|
||||
: mEssFile(essfile)
|
||||
, mOutFile(outfile)
|
||||
, mEncoding(encoding)
|
||||
|
@ -112,7 +112,7 @@ namespace ESSImport
|
|||
std::vector<Record> mRecords;
|
||||
};
|
||||
|
||||
void read(const std::string& filename, File& file)
|
||||
void read(const std::filesystem::path &filename, File& file)
|
||||
{
|
||||
ESM::ESMReader esm;
|
||||
esm.open(filename);
|
||||
|
@ -345,7 +345,7 @@ namespace ESSImport
|
|||
|
||||
writer.setFormat (ESM::SavedGame::sCurrentFormat);
|
||||
|
||||
std::ofstream stream(std::filesystem::path(mOutFile), std::ios::out | std::ios::binary);
|
||||
std::ofstream stream(mOutFile, std::ios::out | std::ios::binary);
|
||||
// all unused
|
||||
writer.setVersion(0);
|
||||
writer.setType(0);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef OPENMW_ESSIMPORTER_IMPORTER_H
|
||||
#define OPENMW_ESSIMPORTER_IMPORTER_H
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
@ -9,15 +9,15 @@ namespace ESSImport
|
|||
class Importer
|
||||
{
|
||||
public:
|
||||
Importer(const std::string& essfile, const std::string& outfile, const std::string& encoding);
|
||||
Importer(const std::filesystem::path &essfile, const std::filesystem::path &outfile, const std::string& encoding);
|
||||
|
||||
void run();
|
||||
|
||||
void compare();
|
||||
|
||||
private:
|
||||
std::string mEssFile;
|
||||
std::string mOutFile;
|
||||
std::filesystem::path mEssFile;
|
||||
std::filesystem::path mOutFile;
|
||||
std::string mEncoding;
|
||||
};
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ int main(int argc, char** argv)
|
|||
bpo::positional_options_description p_desc;
|
||||
desc.add_options()
|
||||
("help,h", "produce help message")
|
||||
("mwsave,m", bpo::value<std::string>(), "morrowind .ess save file")
|
||||
("output,o", bpo::value<std::string>(), "output file (.omwsave)")
|
||||
("mwsave,m", bpo::value<Files::MaybeQuotedPath>(), "morrowind .ess save file")
|
||||
("output,o", bpo::value<Files::MaybeQuotedPath>(), "output file (.omwsave)")
|
||||
("compare,c", "compare two .ess files")
|
||||
("encoding", boost::program_options::value<std::string>()->default_value("win1252"), "encoding of the save file")
|
||||
;
|
||||
|
@ -45,8 +45,8 @@ int main(int argc, char** argv)
|
|||
Files::ConfigurationManager cfgManager(true);
|
||||
cfgManager.readConfiguration(variables, desc);
|
||||
|
||||
std::string essFile = variables["mwsave"].as<std::string>();
|
||||
std::string outputFile = variables["output"].as<std::string>();
|
||||
const auto essFile = variables["mwsave"].as<Files::MaybeQuotedPath>();
|
||||
const auto outputFile = variables["output"].as<Files::MaybeQuotedPath>();
|
||||
std::string encoding = variables["encoding"].as<std::string>();
|
||||
|
||||
ESSImport::Importer importer(essFile, outputFile, encoding);
|
||||
|
@ -55,9 +55,10 @@ int main(int argc, char** argv)
|
|||
importer.compare();
|
||||
else
|
||||
{
|
||||
const std::string& ext = ".omwsave";
|
||||
if (std::filesystem::exists(std::filesystem::path(outputFile))
|
||||
&& (outputFile.size() < ext.size() || outputFile.substr(outputFile.size()-ext.size()) != ext))
|
||||
static constexpr std::u8string_view ext{u8".omwsave"};
|
||||
const auto length = outputFile.native().size();
|
||||
if (std::filesystem::exists(outputFile)
|
||||
&& (length < ext.size() || outputFile.u8string().substr(length-ext.size()) != ext))
|
||||
{
|
||||
throw std::runtime_error("Output file already exists and does not end in .omwsave. Did you mean to use --compare?");
|
||||
}
|
||||
|
|
|
@ -19,13 +19,15 @@
|
|||
#include <components/config/gamesettings.hpp>
|
||||
#include <components/config/launchersettings.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/bsa/compressedbsafile.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
#include <components/navmeshtool/protocol.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/vfs/bsaarchive.hpp>
|
||||
|
||||
#include "utils/textinputdialog.hpp"
|
||||
#include "utils/profilescombobox.hpp"
|
||||
#include "utils/textinputdialog.hpp"
|
||||
|
||||
#include "ui_directorypicker.h"
|
||||
|
||||
|
@ -230,9 +232,9 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
|
|||
if (!mDataLocal.isEmpty())
|
||||
directories.insert(0, mDataLocal);
|
||||
|
||||
const auto globalDataDir = QString(mGameSettings.getGlobalDataDir().c_str());
|
||||
if (!globalDataDir.isEmpty())
|
||||
directories.insert(0, globalDataDir);
|
||||
const auto& globalDataDir = mGameSettings.getGlobalDataDir();
|
||||
if (!globalDataDir.empty())
|
||||
directories.insert(0, Files::pathToQString(globalDataDir));
|
||||
|
||||
// normalize user supplied directories: resolve symlink, convert to native separator, make absolute
|
||||
for (auto& currentDir : directories)
|
||||
|
@ -264,7 +266,8 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
|
|||
}
|
||||
|
||||
// deactivate data-local and global data directory: they are always included
|
||||
if (currentDir == mDataLocal || currentDir == globalDataDir)
|
||||
const auto tmp = currentDir.toUtf8();
|
||||
if (currentDir == mDataLocal || std::filesystem::path(Misc::StringUtils::stringToU8String(tmp)) == globalDataDir)
|
||||
{
|
||||
auto flags = item->flags();
|
||||
item->setFlags(flags & ~(Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled|Qt::ItemIsEnabled));
|
||||
|
|
|
@ -12,12 +12,14 @@
|
|||
|
||||
#include <boost/program_options/options_description.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "playpage.hpp"
|
||||
#include "graphicspage.hpp"
|
||||
#include "datafilespage.hpp"
|
||||
#include "settingspage.hpp"
|
||||
#include "advancedpage.hpp"
|
||||
#include "datafilespage.hpp"
|
||||
#include "graphicspage.hpp"
|
||||
#include "playpage.hpp"
|
||||
#include "settingspage.hpp"
|
||||
|
||||
using namespace Process;
|
||||
|
||||
|
@ -155,14 +157,14 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()
|
|||
return FirstRunDialogResultFailure;
|
||||
|
||||
// Dialog wizard and setup will fail if the config directory does not already exist
|
||||
QDir userConfigDir = QDir(QString::fromStdString(mCfgMgr.getUserConfigPath().string()));
|
||||
if ( ! userConfigDir.exists() ) {
|
||||
if ( ! userConfigDir.mkpath(".") )
|
||||
const auto& userConfigDir = mCfgMgr.getUserConfigPath();
|
||||
if ( ! exists(userConfigDir) ) {
|
||||
if ( ! create_directories(userConfigDir) )
|
||||
{
|
||||
cfgError(tr("Error opening OpenMW configuration file"),
|
||||
tr("<br><b>Could not create directory %0</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(userConfigDir.canonicalPath())
|
||||
and try again.<br>").arg(Files::pathToQString(canonical(userConfigDir)))
|
||||
);
|
||||
return FirstRunDialogResultFailure;
|
||||
}
|
||||
|
@ -295,7 +297,7 @@ bool Launcher::MainDialog::setupLauncherSettings()
|
|||
|
||||
mLauncherSettings.setMultiValueEnabled(true);
|
||||
|
||||
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
|
||||
const auto userPath = Files::pathToQString(mCfgMgr.getUserConfigPath());
|
||||
|
||||
QStringList paths;
|
||||
paths.append(QString(Config::LauncherSettings::sLauncherConfigFileName));
|
||||
|
@ -328,9 +330,9 @@ bool Launcher::MainDialog::setupGameSettings()
|
|||
{
|
||||
mGameSettings.clear();
|
||||
|
||||
QString localPath = QString::fromUtf8(mCfgMgr.getLocalPath().string().c_str());
|
||||
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
|
||||
QString globalPath = QString::fromUtf8(mCfgMgr.getGlobalPath().string().c_str());
|
||||
const auto localPath = Files::pathToQString(mCfgMgr.getLocalPath());
|
||||
const auto userPath = Files::pathToQString(mCfgMgr.getUserConfigPath());
|
||||
const auto globalPath = Files::pathToQString(mCfgMgr.getGlobalPath());
|
||||
|
||||
QFile file;
|
||||
|
||||
|
@ -479,21 +481,24 @@ bool Launcher::MainDialog::writeSettings()
|
|||
mSettingsPage->saveSettings();
|
||||
mAdvancedPage->saveSettings();
|
||||
|
||||
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
|
||||
QDir dir(userPath);
|
||||
const auto& userPath = mCfgMgr.getUserConfigPath();
|
||||
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkpath(userPath)) {
|
||||
if (!exists(userPath)) {
|
||||
if (!create_directories(userPath)) {
|
||||
cfgError(tr("Error creating OpenMW configuration directory"),
|
||||
tr("<br><b>Could not create %0</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(userPath));
|
||||
and try again.<br>").arg(Files::pathToQString(userPath)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Game settings
|
||||
QFile file(userPath + QString("openmw.cfg"));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QFile file(userPath / "openmw.cfg");
|
||||
#else
|
||||
QFile file(Files::pathToQString(userPath / "openmw.cfg"));
|
||||
#endif
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
||||
// File cannot be opened or created
|
||||
|
@ -509,19 +514,19 @@ bool Launcher::MainDialog::writeSettings()
|
|||
file.close();
|
||||
|
||||
// Graphics settings
|
||||
const std::string settingsPath = (mCfgMgr.getUserConfigPath() / "settings.cfg").string();
|
||||
const auto settingsPath = mCfgMgr.getUserConfigPath() / "settings.cfg";
|
||||
try {
|
||||
Settings::Manager::saveUser(settingsPath);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
std::string msg = "<br><b>Error writing settings.cfg</b><br><br>" +
|
||||
settingsPath + "<br><br>" + e.what();
|
||||
Files::pathToUnicodeString(settingsPath) + "<br><br>" + e.what();
|
||||
cfgError(tr("Error writing user settings file"), tr(msg.c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Launcher settings
|
||||
file.setFileName(userPath + QString(Config::LauncherSettings::sLauncherConfigFileName));
|
||||
file.setFileName(Files::pathToQString(userPath / Config::LauncherSettings::sLauncherConfigFileName));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
|
||||
// File cannot be opened or created
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "utils/textinputdialog.hpp"
|
||||
#include "datafilespage.hpp"
|
||||
|
||||
|
@ -102,9 +105,13 @@ void Launcher::SettingsPage::on_importerButton_clicked()
|
|||
mMain->writeSettings();
|
||||
|
||||
// Create the file if it doesn't already exist, else the importer will fail
|
||||
QString path(QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str()));
|
||||
path.append(QLatin1String("openmw.cfg"));
|
||||
auto path = mCfgMgr.getUserConfigPath();
|
||||
path /= "openmw.cfg";
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QFile file(path);
|
||||
#else
|
||||
QFile file(Files::pathToQString(path));
|
||||
#endif
|
||||
|
||||
if (!file.exists()) {
|
||||
if (!file.open(QIODevice::ReadWrite)) {
|
||||
|
@ -137,7 +144,7 @@ void Launcher::SettingsPage::on_importerButton_clicked()
|
|||
arguments.append(QString("--ini"));
|
||||
arguments.append(settingsComboBox->currentText());
|
||||
arguments.append(QString("--cfg"));
|
||||
arguments.append(path);
|
||||
arguments.append(Files::pathToQString(path));
|
||||
|
||||
qDebug() << "arguments " << arguments;
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ openmw_add_executable(openmw-iniimporter
|
|||
|
||||
target_link_libraries(openmw-iniimporter
|
||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
components
|
||||
)
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
#include "importer.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
#include <components/misc/strings/format.hpp>
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <components/misc/timeconvert.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
|
||||
namespace bfs = boost::filesystem;
|
||||
|
||||
|
||||
namespace sfs = std::filesystem;
|
||||
|
||||
MwIniImporter::MwIniImporter()
|
||||
: mVerbose(false)
|
||||
|
@ -654,12 +657,12 @@ void MwIniImporter::setVerbose(bool verbose) {
|
|||
mVerbose = verbose;
|
||||
}
|
||||
|
||||
MwIniImporter::multistrmap MwIniImporter::loadIniFile(const boost::filesystem::path& filename) const {
|
||||
std::cout << "load ini file: " << filename << std::endl;
|
||||
MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::filesystem::path& filename) const {
|
||||
std::cout << "load ini file: " << Files::pathToUnicodeString(filename) << std::endl;
|
||||
|
||||
std::string section("");
|
||||
MwIniImporter::multistrmap map;
|
||||
bfs::ifstream file((bfs::path(filename)));
|
||||
std::ifstream file(filename);
|
||||
ToUTF8::Utf8Encoder encoder(mEncoding);
|
||||
|
||||
std::string line;
|
||||
|
@ -715,11 +718,11 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const boost::filesystem::p
|
|||
return map;
|
||||
}
|
||||
|
||||
MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const boost::filesystem::path& filename) {
|
||||
std::cout << "load cfg file: " << filename << std::endl;
|
||||
MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const std::filesystem::path& filename) {
|
||||
std::cout << "load cfg file: " << Files::pathToUnicodeString(filename) << std::endl;
|
||||
|
||||
MwIniImporter::multistrmap map;
|
||||
bfs::ifstream file((bfs::path(filename)));
|
||||
std::ifstream file(filename);
|
||||
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
|
@ -861,7 +864,7 @@ std::vector<std::string>::iterator MwIniImporter::findString(std::vector<std::st
|
|||
});
|
||||
}
|
||||
|
||||
void MwIniImporter::addPaths(std::vector<boost::filesystem::path>& output, std::vector<std::string> input) {
|
||||
void MwIniImporter::addPaths(std::vector<std::filesystem::path>& output, std::vector<std::string> input) {
|
||||
for (auto& path : input)
|
||||
{
|
||||
if (path.front() == '"')
|
||||
|
@ -869,18 +872,18 @@ void MwIniImporter::addPaths(std::vector<boost::filesystem::path>& output, std::
|
|||
// Drop first and last characters - quotation marks
|
||||
path = path.substr(1, path.size() - 2);
|
||||
}
|
||||
output.emplace_back(path);
|
||||
output.emplace_back(Files::pathFromUnicodeString(path));
|
||||
}
|
||||
}
|
||||
|
||||
void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, const boost::filesystem::path& iniFilename) const
|
||||
void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, const std::filesystem::path& iniFilename) const
|
||||
{
|
||||
std::vector<std::pair<std::time_t, boost::filesystem::path>> contentFiles;
|
||||
std::vector<std::pair<std::time_t, std::filesystem::path>> contentFiles;
|
||||
std::string baseGameFile("Game Files:GameFile");
|
||||
std::time_t defaultTime = 0;
|
||||
ToUTF8::Utf8Encoder encoder(mEncoding);
|
||||
|
||||
std::vector<boost::filesystem::path> dataPaths;
|
||||
std::vector<std::filesystem::path> dataPaths;
|
||||
if (cfg.count("data"))
|
||||
addPaths(dataPaths, cfg["data"]);
|
||||
|
||||
|
@ -909,7 +912,7 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, co
|
|||
bool found = false;
|
||||
for (auto & dataPath : dataPaths)
|
||||
{
|
||||
boost::filesystem::path path = dataPath / *entry;
|
||||
std::filesystem::path path = dataPath / *entry;
|
||||
std::time_t time = lastWriteTime(path, defaultTime);
|
||||
if (time != defaultTime)
|
||||
{
|
||||
|
@ -936,13 +939,13 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, co
|
|||
reader.setEncoder(&encoder);
|
||||
for (auto& file : contentFiles)
|
||||
{
|
||||
reader.open(file.second.string());
|
||||
reader.open(file.second);
|
||||
std::vector<std::string> dependencies;
|
||||
for (auto& gameFile : reader.getGameFiles())
|
||||
{
|
||||
dependencies.push_back(gameFile.name);
|
||||
}
|
||||
unsortedFiles.emplace_back(boost::filesystem::path(reader.getName()).filename().string(), dependencies);
|
||||
unsortedFiles.emplace_back(Files::pathToUnicodeString(reader.getName().filename()), dependencies);
|
||||
reader.close();
|
||||
}
|
||||
|
||||
|
@ -983,13 +986,13 @@ void MwIniImporter::setInputEncoding(const ToUTF8::FromType &encoding)
|
|||
mEncoding = encoding;
|
||||
}
|
||||
|
||||
std::time_t MwIniImporter::lastWriteTime(const boost::filesystem::path& filename, std::time_t defaultTime)
|
||||
std::time_t MwIniImporter::lastWriteTime(const std::filesystem::path& filename, std::time_t defaultTime)
|
||||
{
|
||||
std::time_t writeTime(defaultTime);
|
||||
if (boost::filesystem::exists(filename))
|
||||
if (std::filesystem::exists(filename))
|
||||
{
|
||||
boost::filesystem::path resolved = boost::filesystem::canonical(filename);
|
||||
writeTime = boost::filesystem::last_write_time(resolved);
|
||||
std::filesystem::path resolved = std::filesystem::canonical(filename);
|
||||
writeTime = Misc::to_time_t(std::filesystem::last_write_time (resolved));
|
||||
|
||||
// print timestamp
|
||||
const int size=1024;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <vector>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/to_utf8/to_utf8.hpp>
|
||||
|
||||
|
@ -19,12 +19,12 @@ class MwIniImporter {
|
|||
MwIniImporter();
|
||||
void setInputEncoding(const ToUTF8::FromType& encoding);
|
||||
void setVerbose(bool verbose);
|
||||
multistrmap loadIniFile(const boost::filesystem::path& filename) const;
|
||||
static multistrmap loadCfgFile(const boost::filesystem::path& filename);
|
||||
multistrmap loadIniFile(const std::filesystem::path& filename) const;
|
||||
static multistrmap loadCfgFile(const std::filesystem::path& filename);
|
||||
void merge(multistrmap &cfg, const multistrmap &ini) const;
|
||||
void mergeFallback(multistrmap &cfg, const multistrmap &ini) const;
|
||||
void importGameFiles(multistrmap &cfg, const multistrmap &ini,
|
||||
const boost::filesystem::path& iniFilename) const;
|
||||
const std::filesystem::path& iniFilename) const;
|
||||
void importArchives(multistrmap &cfg, const multistrmap &ini) const;
|
||||
static void writeToFile(std::ostream &out, const multistrmap &cfg);
|
||||
|
||||
|
@ -35,10 +35,10 @@ class MwIniImporter {
|
|||
static std::vector<std::string>::iterator findString(std::vector<std::string>& source, const std::string& string);
|
||||
|
||||
static void insertMultistrmap(multistrmap &cfg, const std::string& key, const std::string& value);
|
||||
static void addPaths(std::vector<boost::filesystem::path>& output, std::vector<std::string> input);
|
||||
static void addPaths(std::vector<std::filesystem::path>& output, std::vector<std::string> input);
|
||||
|
||||
/// \return file's "last modified time", used in original MW to determine plug-in load order
|
||||
static std::time_t lastWriteTime(const boost::filesystem::path& filename, std::time_t defaultTime);
|
||||
static std::time_t lastWriteTime(const std::filesystem::path& filename, std::time_t defaultTime);
|
||||
|
||||
bool mVerbose;
|
||||
strmap mMergeMap;
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
#include "importer.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
namespace bfs = boost::filesystem;
|
||||
namespace sfs = std::filesystem;
|
||||
|
||||
#ifndef _WIN32
|
||||
int main(int argc, char *argv[]) {
|
||||
|
@ -52,7 +55,6 @@ private:
|
|||
int wmain(int argc, wchar_t *wargv[]) {
|
||||
utf8argv converter(argc, wargv);
|
||||
char **argv = converter.get();
|
||||
boost::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||
#endif
|
||||
|
||||
try
|
||||
|
@ -62,9 +64,9 @@ int wmain(int argc, wchar_t *wargv[]) {
|
|||
desc.add_options()
|
||||
("help,h", "produce help message")
|
||||
("verbose,v", "verbose output")
|
||||
("ini,i", bpo::value<std::string>(), "morrowind.ini file")
|
||||
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
|
||||
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
|
||||
("ini,i", bpo::value<Files::MaybeQuotedPath>(), "morrowind.ini file")
|
||||
("cfg,c", bpo::value<Files::MaybeQuotedPath>(), "openmw.cfg file")
|
||||
("output,o", bpo::value<Files::MaybeQuotedPath>()->default_value({}), "openmw.cfg file")
|
||||
("game-files,g", "import esm and esp files")
|
||||
("fonts,f", "import bitmap fonts")
|
||||
("no-archives,A", "disable bsa archives import")
|
||||
|
@ -92,20 +94,20 @@ int wmain(int argc, wchar_t *wargv[]) {
|
|||
|
||||
bpo::notify(vm);
|
||||
|
||||
boost::filesystem::path iniFile(vm["ini"].as<std::string>());
|
||||
boost::filesystem::path cfgFile(vm["cfg"].as<std::string>());
|
||||
std::filesystem::path iniFile(vm["ini"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
std::filesystem::path cfgFile(vm["cfg"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
|
||||
// if no output is given, write back to cfg file
|
||||
std::string outputFile(vm["output"].as<std::string>());
|
||||
std::filesystem::path outputFile = vm["output"].as<Files::MaybeQuotedPath>().u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
if(vm["output"].defaulted()) {
|
||||
outputFile = vm["cfg"].as<std::string>();
|
||||
outputFile = vm["cfg"].as<Files::MaybeQuotedPath>().u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
}
|
||||
|
||||
if(!boost::filesystem::exists(iniFile)) {
|
||||
if(!std::filesystem::exists(iniFile)) {
|
||||
std::cerr << "ini file does not exist" << std::endl;
|
||||
return -3;
|
||||
}
|
||||
if(!boost::filesystem::exists(cfgFile))
|
||||
if(!std::filesystem::exists(cfgFile))
|
||||
std::cerr << "cfg file does not exist" << std::endl;
|
||||
|
||||
MwIniImporter importer;
|
||||
|
@ -136,8 +138,8 @@ int wmain(int argc, wchar_t *wargv[]) {
|
|||
importer.importArchives(cfg, ini);
|
||||
}
|
||||
|
||||
std::cout << "write to: " << outputFile << std::endl;
|
||||
bfs::ofstream file((bfs::path(outputFile)));
|
||||
std::cout << "write to: " << Files::pathToUnicodeString(outputFile) << std::endl;
|
||||
std::ofstream file(outputFile);
|
||||
importer.writeToFile(file, cfg);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <components/esm3/readerscache.hpp>
|
||||
#include <components/platform/platform.hpp>
|
||||
#include <components/detournavigator/agentbounds.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
|
@ -143,7 +144,7 @@ namespace NavMeshTool
|
|||
|
||||
const auto fsStrict = variables["fs-strict"].as<bool>();
|
||||
const auto resDir = variables["resources"].as<Files::MaybeQuotedPath>();
|
||||
Version::Version v = Version::getOpenmwVersion(resDir.string());
|
||||
Version::Version v = Version::getOpenmwVersion(resDir);
|
||||
Log(Debug::Info) << v.describe();
|
||||
dataDirs.insert(dataDirs.begin(), resDir / "vfs");
|
||||
const auto fileCollections = Files::Collections(dataDirs, !fsStrict);
|
||||
|
@ -179,7 +180,7 @@ namespace NavMeshTool
|
|||
const osg::Vec3f agentHalfExtents = Settings::Manager::getVector3("default actor pathfind half extents", "Game");
|
||||
const DetourNavigator::AgentBounds agentBounds {agentCollisionShape, agentHalfExtents};
|
||||
const std::uint64_t maxDbFileSize = static_cast<std::uint64_t>(Settings::Manager::getInt64("max navmeshdb file size", "Navigator"));
|
||||
const std::string dbPath = (config.getUserDataPath() / "navmesh.db").string();
|
||||
const auto dbPath = Files::pathToUnicodeString(config.getUserDataPath() / "navmesh.db");
|
||||
|
||||
DetourNavigator::NavMeshDb db(dbPath, maxDbFileSize);
|
||||
|
||||
|
|
|
@ -276,11 +276,13 @@ namespace NavMeshTool
|
|||
{
|
||||
it = navMeshInputs.emplace(cell.mCellId.mWorldspace,
|
||||
std::make_unique<WorldspaceNavMeshInput>(cell.mCellId.mWorldspace, settings.mRecast)).first;
|
||||
it->second->mTileCachedRecastMeshManager.setWorldspace(cell.mCellId.mWorldspace);
|
||||
it->second->mTileCachedRecastMeshManager.setWorldspace(cell.mCellId.mWorldspace, nullptr);
|
||||
}
|
||||
return *it->second;
|
||||
} ();
|
||||
|
||||
const TileCachedRecastMeshManager::UpdateGuard guard(navMeshInput.mTileCachedRecastMeshManager);
|
||||
|
||||
if (exterior)
|
||||
{
|
||||
const auto it = std::lower_bound(esmData.mLands.begin(), esmData.mLands.end(), cellPosition, LessByXY {});
|
||||
|
@ -292,14 +294,14 @@ namespace NavMeshTool
|
|||
mergeOrAssign(getAabb(cellPosition, minHeight, maxHeight),
|
||||
navMeshInput.mAabb, navMeshInput.mAabbInitialized);
|
||||
|
||||
navMeshInput.mTileCachedRecastMeshManager.addHeightfield(cellPosition, ESM::Land::REAL_SIZE, heightfieldShape);
|
||||
navMeshInput.mTileCachedRecastMeshManager.addHeightfield(cellPosition, ESM::Land::REAL_SIZE, heightfieldShape, &guard);
|
||||
|
||||
navMeshInput.mTileCachedRecastMeshManager.addWater(cellPosition, ESM::Land::REAL_SIZE, -1);
|
||||
navMeshInput.mTileCachedRecastMeshManager.addWater(cellPosition, ESM::Land::REAL_SIZE, -1, &guard);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((cell.mData.mFlags & ESM::Cell::HasWater) != 0)
|
||||
navMeshInput.mTileCachedRecastMeshManager.addWater(cellPosition, std::numeric_limits<int>::max(), cell.mWater);
|
||||
navMeshInput.mTileCachedRecastMeshManager.addWater(cellPosition, std::numeric_limits<int>::max(), cell.mWater, &guard);
|
||||
}
|
||||
|
||||
forEachObject(cell, esmData, vfs, bulletShapeManager, readers,
|
||||
|
@ -318,13 +320,13 @@ namespace NavMeshTool
|
|||
const CollisionShape shape(object.getShapeInstance(), *object.getCollisionObject().getCollisionShape(), object.getObjectTransform());
|
||||
|
||||
navMeshInput.mTileCachedRecastMeshManager.addObject(objectId, shape, transform,
|
||||
DetourNavigator::AreaType_ground);
|
||||
DetourNavigator::AreaType_ground, &guard);
|
||||
|
||||
if (const btCollisionShape* avoid = object.getShapeInstance()->mAvoidCollisionShape.get())
|
||||
{
|
||||
const CollisionShape avoidShape(object.getShapeInstance(), *avoid, object.getObjectTransform());
|
||||
navMeshInput.mTileCachedRecastMeshManager.addObject(objectId, avoidShape, transform,
|
||||
DetourNavigator::AreaType_null);
|
||||
DetourNavigator::AreaType_null, &guard);
|
||||
}
|
||||
|
||||
data.mObjects.emplace_back(std::move(object));
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <components/vfs/manager.hpp>
|
||||
#include <components/vfs/bsaarchive.hpp>
|
||||
#include <components/vfs/filesystemarchive.hpp>
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
|
@ -16,26 +18,26 @@
|
|||
namespace bpo = boost::program_options;
|
||||
|
||||
///See if the file has the named extension
|
||||
bool hasExtension(std::string filename, std::string extensionToFind)
|
||||
bool hasExtension(const std::filesystem::path& filename, const std::string& extensionToFind)
|
||||
{
|
||||
std::string extension = filename.substr(filename.find_last_of('.')+1);
|
||||
const auto extension = Files::pathToUnicodeString(filename.extension());
|
||||
return Misc::StringUtils::ciEqual(extension, extensionToFind);
|
||||
}
|
||||
|
||||
///See if the file has the "nif" extension.
|
||||
bool isNIF(const std::string & filename)
|
||||
bool isNIF(const std::filesystem::path &filename)
|
||||
{
|
||||
return hasExtension(filename,"nif");
|
||||
}
|
||||
///See if the file has the "bsa" extension.
|
||||
bool isBSA(const std::string & filename)
|
||||
bool isBSA(const std::filesystem::path &filename)
|
||||
{
|
||||
return hasExtension(filename,"bsa");
|
||||
}
|
||||
|
||||
/// Check all the nif files in a given VFS::Archive
|
||||
/// \note Can not read a bsa file inside of a bsa file.
|
||||
void readVFS(std::unique_ptr<VFS::Archive>&& anArchive, std::string archivePath = "")
|
||||
void readVFS(std::unique_ptr<VFS::Archive>&& anArchive, const std::filesystem::path& archivePath = {})
|
||||
{
|
||||
VFS::Manager myManager(true);
|
||||
myManager.addArchive(std::move(anArchive));
|
||||
|
@ -47,14 +49,14 @@ void readVFS(std::unique_ptr<VFS::Archive>&& anArchive, std::string archivePath
|
|||
if(isNIF(name))
|
||||
{
|
||||
// std::cout << "Decoding: " << name << std::endl;
|
||||
Nif::NIFFile temp_nif(myManager.get(name),archivePath+name);
|
||||
Nif::NIFFile temp_nif(myManager.get(name),archivePath / name);
|
||||
}
|
||||
else if(isBSA(name))
|
||||
{
|
||||
if(!archivePath.empty() && !isBSA(archivePath))
|
||||
{
|
||||
// std::cout << "Reading BSA File: " << name << std::endl;
|
||||
readVFS(std::make_unique<VFS::BsaArchive>(archivePath + name), archivePath + name + "/");
|
||||
readVFS(std::make_unique<VFS::BsaArchive>(archivePath / name), archivePath / name);
|
||||
// std::cout << "Done with BSA File: " << name << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +68,7 @@ void readVFS(std::unique_ptr<VFS::Archive>&& anArchive, std::string archivePath
|
|||
}
|
||||
}
|
||||
|
||||
bool parseOptions (int argc, char** argv, std::vector<std::string>& files)
|
||||
bool parseOptions (int argc, char** argv, std::vector<Files::MaybeQuotedPath> &files)
|
||||
{
|
||||
bpo::options_description desc("Ensure that OpenMW can use the provided NIF and BSA files\n\n"
|
||||
"Usages:\n"
|
||||
|
@ -75,7 +77,7 @@ bool parseOptions (int argc, char** argv, std::vector<std::string>& files)
|
|||
"Allowed options");
|
||||
desc.add_options()
|
||||
("help,h", "print help message.")
|
||||
("input-file", bpo::value< std::vector<std::string> >(), "input file")
|
||||
("input-file", bpo::value< Files::MaybeQuotedPathContainer >(), "input file")
|
||||
;
|
||||
|
||||
//Default option if none provided
|
||||
|
@ -96,7 +98,7 @@ bool parseOptions (int argc, char** argv, std::vector<std::string>& files)
|
|||
}
|
||||
if (variables.count("input-file"))
|
||||
{
|
||||
files = variables["input-file"].as< std::vector<std::string> >();
|
||||
files = variables["input-file"].as< Files::MaybeQuotedPathContainer >();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -114,36 +116,34 @@ bool parseOptions (int argc, char** argv, std::vector<std::string>& files)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
std::vector<Files::MaybeQuotedPath> files;
|
||||
if(!parseOptions (argc, argv, files))
|
||||
return 1;
|
||||
|
||||
Nif::NIFFile::setLoadUnsupportedFiles(true);
|
||||
// std::cout << "Reading Files" << std::endl;
|
||||
for(auto it=files.begin(); it!=files.end(); ++it)
|
||||
for(const auto& path : files)
|
||||
{
|
||||
std::string name = *it;
|
||||
|
||||
try
|
||||
{
|
||||
if(isNIF(name))
|
||||
if(isNIF(path))
|
||||
{
|
||||
//std::cout << "Decoding: " << name << std::endl;
|
||||
Nif::NIFFile temp_nif(Files::openConstrainedFileStream(name), name);
|
||||
Nif::NIFFile temp_nif(Files::openConstrainedFileStream(path), path);
|
||||
}
|
||||
else if(isBSA(name))
|
||||
else if(isBSA(path))
|
||||
{
|
||||
// std::cout << "Reading BSA File: " << name << std::endl;
|
||||
readVFS(std::make_unique<VFS::BsaArchive>(name));
|
||||
readVFS(std::make_unique<VFS::BsaArchive>(path));
|
||||
}
|
||||
else if(std::filesystem::is_directory(std::filesystem::path(name)))
|
||||
else if(std::filesystem::is_directory(path))
|
||||
{
|
||||
// std::cout << "Reading All Files in: " << name << std::endl;
|
||||
readVFS(std::make_unique<VFS::FileSystemArchive>(name), name);
|
||||
readVFS(std::make_unique<VFS::FileSystemArchive>(path), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "ERROR: \"" << name << "\" is not a nif file, bsa file, or directory!" << std::endl;
|
||||
std::cerr << "ERROR: \"" << Files::pathToUnicodeString(path) << "\" is not a nif file, bsa file, or directory!" << std::endl;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
|
|
@ -224,8 +224,6 @@ target_link_libraries(openmw-cs
|
|||
${OSGTEXT_LIBRARIES}
|
||||
${OSG_LIBRARIES}
|
||||
${EXTERN_OSGQT_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
components_qt
|
||||
)
|
||||
|
|
|
@ -10,7 +10,10 @@
|
|||
#include <components/debug/debugging.hpp>
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/fallback/validate.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
#include <components/nifosg/nifloader.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
|
@ -63,7 +66,7 @@ CS::Editor::Editor (int argc, char **argv)
|
|||
connect (&mStartup, &CSVDoc::StartupDialogue::editConfig, this, &Editor::showSettings);
|
||||
|
||||
connect (&mFileDialog, &CSVDoc::FileDialog::signalOpenFiles,
|
||||
this, [this](const boost::filesystem::path &savePath){ this->openFiles(savePath); });
|
||||
this, [this](const std::filesystem::path &savePath){ this->openFiles(savePath); });
|
||||
connect (&mFileDialog, &CSVDoc::FileDialog::signalCreateNewFile, this, &Editor::createNewFile);
|
||||
connect (&mFileDialog, &CSVDoc::FileDialog::rejected, this, &Editor::cancelFileDialog);
|
||||
|
||||
|
@ -77,9 +80,8 @@ CS::Editor::~Editor ()
|
|||
|
||||
mPidFile.close();
|
||||
|
||||
if(mServer && boost::filesystem::exists(mPid))
|
||||
static_cast<void> ( // silence coverity warning
|
||||
remove(mPid.string().c_str())); // ignore any error
|
||||
if(mServer && std::filesystem::exists(mPid))
|
||||
std::filesystem::remove(mPid);
|
||||
}
|
||||
|
||||
boost::program_options::variables_map CS::Editor::readConfiguration()
|
||||
|
@ -107,7 +109,7 @@ boost::program_options::variables_map CS::Editor::readConfiguration()
|
|||
|
||||
mCfgMgr.readConfiguration(variables, desc, false);
|
||||
Settings::Manager::load(mCfgMgr, true);
|
||||
setupLogging(mCfgMgr.getLogPath().string(), "OpenMW-CS");
|
||||
setupLogging(mCfgMgr.getLogPath(), "OpenMW-CS");
|
||||
|
||||
return variables;
|
||||
}
|
||||
|
@ -122,7 +124,7 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
|||
mDocumentManager.setEncoding(ToUTF8::calculateEncoding(mEncodingName));
|
||||
mFileDialog.setEncoding (QString::fromUtf8(mEncodingName.c_str()));
|
||||
|
||||
mDocumentManager.setResourceDir (mResources = variables["resources"].as<Files::MaybeQuotedPath>());
|
||||
mDocumentManager.setResourceDir (mResources = variables["resources"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
|
||||
if (variables["script-blacklist-use"].as<bool>())
|
||||
mDocumentManager.setBlacklistedScripts (
|
||||
|
@ -135,10 +137,10 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
|||
dataDirs = asPathContainer(variables["data"].as<Files::MaybeQuotedPathContainer>());
|
||||
}
|
||||
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>());
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
if (!local.empty())
|
||||
{
|
||||
boost::filesystem::create_directories(local);
|
||||
std::filesystem::create_directories(local);
|
||||
dataLocal.push_back(local);
|
||||
}
|
||||
mCfgMgr.filterOutNonExistingPaths(dataDirs);
|
||||
|
@ -225,14 +227,15 @@ void CS::Editor::loadDocument()
|
|||
mFileDialog.showDialog (CSVDoc::ContentAction_Edit);
|
||||
}
|
||||
|
||||
void CS::Editor::openFiles (const boost::filesystem::path &savePath, const std::vector<boost::filesystem::path> &discoveredFiles)
|
||||
void CS::Editor::openFiles (const std::filesystem::path &savePath, const std::vector<std::filesystem::path> &discoveredFiles)
|
||||
{
|
||||
std::vector<boost::filesystem::path> files;
|
||||
std::vector<std::filesystem::path> files;
|
||||
|
||||
if(discoveredFiles.empty())
|
||||
{
|
||||
for (const QString &path : mFileDialog.selectedFilePaths())
|
||||
files.emplace_back(path.toUtf8().constData());
|
||||
for (const QString &path : mFileDialog.selectedFilePaths()) {
|
||||
files.emplace_back(Files::pathFromQString(path));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -244,12 +247,12 @@ void CS::Editor::openFiles (const boost::filesystem::path &savePath, const std::
|
|||
mFileDialog.hide();
|
||||
}
|
||||
|
||||
void CS::Editor::createNewFile (const boost::filesystem::path &savePath)
|
||||
void CS::Editor::createNewFile (const std::filesystem::path &savePath)
|
||||
{
|
||||
std::vector<boost::filesystem::path> files;
|
||||
std::vector<std::filesystem::path> files;
|
||||
|
||||
for (const QString &path : mFileDialog.selectedFilePaths()) {
|
||||
files.emplace_back(path.toUtf8().constData());
|
||||
files.emplace_back(Files::pathFromQString(path));
|
||||
}
|
||||
|
||||
files.push_back (savePath);
|
||||
|
@ -259,9 +262,9 @@ void CS::Editor::createNewFile (const boost::filesystem::path &savePath)
|
|||
mFileDialog.hide();
|
||||
}
|
||||
|
||||
void CS::Editor::createNewGame (const boost::filesystem::path& file)
|
||||
void CS::Editor::createNewGame (const std::filesystem::path& file)
|
||||
{
|
||||
std::vector<boost::filesystem::path> files;
|
||||
std::vector<std::filesystem::path> files;
|
||||
|
||||
files.push_back (file);
|
||||
|
||||
|
@ -292,13 +295,13 @@ bool CS::Editor::makeIPCServer()
|
|||
{
|
||||
try
|
||||
{
|
||||
mPid = boost::filesystem::temp_directory_path();
|
||||
mPid = std::filesystem::temp_directory_path();
|
||||
mPid /= "openmw-cs.pid";
|
||||
bool pidExists = boost::filesystem::exists(mPid);
|
||||
bool pidExists = std::filesystem::exists(mPid);
|
||||
|
||||
mPidFile.open(mPid);
|
||||
|
||||
mLock = boost::interprocess::file_lock(mPid.string().c_str());
|
||||
mLock = boost::interprocess::file_lock(mPid.c_str());
|
||||
if(!mLock.try_lock())
|
||||
{
|
||||
Log(Debug::Error) << "Error: OpenMW-CS is already running.";
|
||||
|
@ -321,12 +324,13 @@ bool CS::Editor::makeIPCServer()
|
|||
mServer->close();
|
||||
fullPath.remove(QRegExp("dummy$"));
|
||||
fullPath += mIpcServerName;
|
||||
if(boost::filesystem::exists(fullPath.toUtf8().constData()))
|
||||
const auto path = Files::pathFromQString(fullPath);
|
||||
if(exists(path))
|
||||
{
|
||||
// TODO: compare pid of the current process with that in the file
|
||||
Log(Debug::Info) << "Detected unclean shutdown.";
|
||||
// delete the stale file
|
||||
if(remove(fullPath.toUtf8().constData()))
|
||||
if(remove(path))
|
||||
Log(Debug::Error) << "Error: can not remove stale connection file.";
|
||||
}
|
||||
}
|
||||
|
@ -374,27 +378,24 @@ int CS::Editor::run()
|
|||
ESM::ESMReader fileReader;
|
||||
ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(mEncodingName));
|
||||
fileReader.setEncoder(&encoder);
|
||||
fileReader.open(mFileToLoad.string());
|
||||
fileReader.open(mFileToLoad);
|
||||
|
||||
std::vector<boost::filesystem::path> discoveredFiles;
|
||||
std::vector<std::filesystem::path> discoveredFiles;
|
||||
|
||||
for (std::vector<ESM::Header::MasterData>::const_iterator itemIter = fileReader.getGameFiles().begin();
|
||||
itemIter != fileReader.getGameFiles().end(); ++itemIter)
|
||||
for (const auto& item : fileReader.getGameFiles())
|
||||
{
|
||||
for (Files::PathContainer::const_iterator pathIter = mDataDirs.begin();
|
||||
pathIter != mDataDirs.end(); ++pathIter)
|
||||
for (const auto& path : mDataDirs)
|
||||
{
|
||||
const boost::filesystem::path masterPath = *pathIter / itemIter->name;
|
||||
if (boost::filesystem::exists(masterPath))
|
||||
if (auto masterPath = path / item.name; std::filesystem::exists(masterPath))
|
||||
{
|
||||
discoveredFiles.push_back(masterPath);
|
||||
discoveredFiles.emplace_back(std::move(masterPath));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
discoveredFiles.push_back(mFileToLoad);
|
||||
|
||||
QString extension = QString::fromStdString(mFileToLoad.extension().string()).toLower();
|
||||
const auto extension = Files::pathToQString(mFileToLoad.extension()).toLower();
|
||||
if (extension == ".esm")
|
||||
{
|
||||
mFileToLoad.replace_extension(".omwgame");
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#ifndef CS_EDITOR_H
|
||||
#define CS_EDITOR_H
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/interprocess/sync/file_lock.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
#include <QObject>
|
||||
|
@ -48,15 +49,15 @@ namespace CS
|
|||
CSVDoc::NewGameDialogue mNewGame;
|
||||
CSVPrefs::Dialogue mSettings;
|
||||
CSVDoc::FileDialog mFileDialog;
|
||||
boost::filesystem::path mLocal;
|
||||
boost::filesystem::path mResources;
|
||||
boost::filesystem::path mPid;
|
||||
std::filesystem::path mLocal;
|
||||
std::filesystem::path mResources;
|
||||
std::filesystem::path mPid;
|
||||
boost::interprocess::file_lock mLock;
|
||||
boost::filesystem::ofstream mPidFile;
|
||||
std::ofstream mPidFile;
|
||||
bool mFsStrict;
|
||||
CSVTools::Merge mMerge;
|
||||
CSVDoc::ViewManager* mViewManager;
|
||||
boost::filesystem::path mFileToLoad;
|
||||
std::filesystem::path mFileToLoad;
|
||||
Files::PathContainer mDataDirs;
|
||||
std::string mEncodingName;
|
||||
|
||||
|
@ -88,9 +89,9 @@ namespace CS
|
|||
void cancelFileDialog();
|
||||
|
||||
void loadDocument();
|
||||
void openFiles (const boost::filesystem::path &path, const std::vector<boost::filesystem::path> &discoveredFiles = std::vector<boost::filesystem::path>());
|
||||
void createNewFile (const boost::filesystem::path& path);
|
||||
void createNewGame (const boost::filesystem::path& file);
|
||||
void openFiles (const std::filesystem::path &path, const std::vector<std::filesystem::path> &discoveredFiles = {});
|
||||
void createNewFile (const std::filesystem::path& path);
|
||||
void createNewGame (const std::filesystem::path& file);
|
||||
|
||||
void showStartup();
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@ void CSMDoc::Blacklist::add (CSMWorld::UniversalId::Type type,
|
|||
|
||||
list.resize (size+ids.size());
|
||||
|
||||
std::transform (ids.begin(), ids.end(), list.begin()+size, Misc::StringUtils::lowerCase);
|
||||
std::transform (ids.begin(), ids.end(), list.begin()+size, [](const std::string& s) { return Misc::StringUtils::lowerCase(s); } );
|
||||
std::sort (list.begin(), list.end());
|
||||
}
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <filesystem>
|
||||
#include <utility>
|
||||
|
||||
#include "../world/defaultgmsts.hpp"
|
||||
|
||||
|
@ -15,6 +14,7 @@
|
|||
#endif
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
void CSMDoc::Document::addGmsts()
|
||||
{
|
||||
|
@ -277,14 +277,14 @@ void CSMDoc::Document::createBase()
|
|||
}
|
||||
|
||||
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
||||
const std::vector< boost::filesystem::path >& files,bool new_,
|
||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||
std::vector< std::filesystem::path > files,bool new_,
|
||||
const std::filesystem::path& savePath, const std::filesystem::path& resDir,
|
||||
ToUTF8::FromType encoding, const std::vector<std::string>& blacklistedScripts,
|
||||
bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
|
||||
: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, resDir),
|
||||
: mSavePath (savePath), mContentFiles (std::move(files)), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, resDir),
|
||||
mTools (*this, encoding),
|
||||
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
||||
(savePath.filename().string() + ".project")),
|
||||
(savePath.filename().u8string() + u8".project")),
|
||||
mSavingOperation (*this, mProjectPath, encoding),
|
||||
mSaving (&mSavingOperation),
|
||||
mResDir(resDir), mRunner (mProjectPath),
|
||||
|
@ -293,21 +293,21 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
|||
if (mContentFiles.empty())
|
||||
throw std::runtime_error ("Empty content file sequence");
|
||||
|
||||
if (mNew || !boost::filesystem::exists (mProjectPath))
|
||||
if (mNew || !std::filesystem::exists (mProjectPath))
|
||||
{
|
||||
boost::filesystem::path filtersPath (configuration.getUserDataPath() / "defaultfilters");
|
||||
auto filtersPath = configuration.getUserDataPath() / "defaultfilters";
|
||||
|
||||
boost::filesystem::ofstream destination(mProjectPath, std::ios::out | std::ios::binary);
|
||||
std::ofstream destination(mProjectPath, std::ios::out | std::ios::binary);
|
||||
if (!destination.is_open())
|
||||
throw std::runtime_error("Can not create project file: " + mProjectPath.string());
|
||||
throw std::runtime_error("Can not create project file: " + Files::pathToUnicodeString(mProjectPath));
|
||||
destination.exceptions(std::ios::failbit | std::ios::badbit);
|
||||
|
||||
if (!boost::filesystem::exists (filtersPath))
|
||||
if (!std::filesystem::exists (filtersPath))
|
||||
filtersPath = mResDir / "defaultfilters";
|
||||
|
||||
boost::filesystem::ifstream source(filtersPath, std::ios::in | std::ios::binary);
|
||||
std::ifstream source(filtersPath, std::ios::in | std::ios::binary);
|
||||
if (!source.is_open())
|
||||
throw std::runtime_error("Can not read filters file: " + filtersPath.string());
|
||||
throw std::runtime_error("Can not read filters file: " + Files::pathToUnicodeString(filtersPath));
|
||||
source.exceptions(std::ios::failbit | std::ios::badbit);
|
||||
|
||||
destination << source.rdbuf();
|
||||
|
@ -369,22 +369,22 @@ int CSMDoc::Document::getState() const
|
|||
return state;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& CSMDoc::Document::getResourceDir() const
|
||||
const std::filesystem::path& CSMDoc::Document::getResourceDir() const
|
||||
{
|
||||
return mResDir;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& CSMDoc::Document::getSavePath() const
|
||||
const std::filesystem::path& CSMDoc::Document::getSavePath() const
|
||||
{
|
||||
return mSavePath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& CSMDoc::Document::getProjectPath() const
|
||||
const std::filesystem::path& CSMDoc::Document::getProjectPath() const
|
||||
{
|
||||
return mProjectPath;
|
||||
}
|
||||
|
||||
const std::vector<boost::filesystem::path>& CSMDoc::Document::getContentFiles() const
|
||||
const std::vector<std::filesystem::path>& CSMDoc::Document::getContentFiles() const
|
||||
{
|
||||
return mContentFiles;
|
||||
}
|
||||
|
@ -481,11 +481,11 @@ bool CSMDoc::Document::isBlacklisted (const CSMWorld::UniversalId& id)
|
|||
void CSMDoc::Document::startRunning (const std::string& profile,
|
||||
const std::string& startupInstruction)
|
||||
{
|
||||
std::vector<std::string> contentFiles;
|
||||
std::vector<std::filesystem::path> contentFiles;
|
||||
|
||||
for (std::vector<boost::filesystem::path>::const_iterator iter (mContentFiles.begin());
|
||||
iter!=mContentFiles.end(); ++iter)
|
||||
contentFiles.push_back (iter->filename().string());
|
||||
for (const auto & mContentFile : mContentFiles) {
|
||||
contentFiles.emplace_back(mContentFile.filename());
|
||||
}
|
||||
|
||||
mRunner.configure (getData().getDebugProfiles().getRecord (profile).get(), contentFiles,
|
||||
startupInstruction);
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <QUndoStack>
|
||||
#include <QObject>
|
||||
|
||||
|
@ -58,15 +56,15 @@ namespace CSMDoc
|
|||
|
||||
private:
|
||||
|
||||
boost::filesystem::path mSavePath;
|
||||
std::vector<boost::filesystem::path> mContentFiles;
|
||||
std::filesystem::path mSavePath;
|
||||
std::vector<std::filesystem::path> mContentFiles;
|
||||
bool mNew;
|
||||
CSMWorld::Data mData;
|
||||
CSMTools::Tools mTools;
|
||||
boost::filesystem::path mProjectPath;
|
||||
std::filesystem::path mProjectPath;
|
||||
Saving mSavingOperation;
|
||||
OperationHolder mSaving;
|
||||
boost::filesystem::path mResDir;
|
||||
std::filesystem::path mResDir;
|
||||
Blacklist mBlacklist;
|
||||
Runner mRunner;
|
||||
bool mDirty;
|
||||
|
@ -100,8 +98,8 @@ namespace CSMDoc
|
|||
public:
|
||||
|
||||
Document (const Files::ConfigurationManager& configuration,
|
||||
const std::vector< boost::filesystem::path >& files, bool new_,
|
||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||
std::vector< std::filesystem::path > files, bool new_,
|
||||
const std::filesystem::path& savePath, const std::filesystem::path& resDir,
|
||||
ToUTF8::FromType encoding, const std::vector<std::string>& blacklistedScripts,
|
||||
bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);
|
||||
|
||||
|
@ -111,13 +109,13 @@ namespace CSMDoc
|
|||
|
||||
int getState() const;
|
||||
|
||||
const boost::filesystem::path& getResourceDir() const;
|
||||
const std::filesystem::path& getResourceDir() const;
|
||||
|
||||
const boost::filesystem::path& getSavePath() const;
|
||||
const std::filesystem::path& getSavePath() const;
|
||||
|
||||
const boost::filesystem::path& getProjectPath() const;
|
||||
const std::filesystem::path& getProjectPath() const;
|
||||
|
||||
const std::vector<boost::filesystem::path>& getContentFiles() const;
|
||||
const std::vector<std::filesystem::path>& getContentFiles() const;
|
||||
///< \attention The last element in this collection is the file that is being edited,
|
||||
/// but with its original path instead of the save path.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "documentmanager.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
@ -11,10 +11,10 @@
|
|||
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
||||
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mFsStrict(false)
|
||||
{
|
||||
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
||||
std::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
||||
|
||||
if (!boost::filesystem::is_directory (projectPath))
|
||||
boost::filesystem::create_directories (projectPath);
|
||||
if (!std::filesystem::is_directory (projectPath))
|
||||
std::filesystem::create_directories (projectPath);
|
||||
|
||||
mLoader.moveToThread (&mLoaderThread);
|
||||
mLoaderThread.start();
|
||||
|
@ -51,7 +51,7 @@ bool CSMDoc::DocumentManager::isEmpty()
|
|||
return mDocuments.empty();
|
||||
}
|
||||
|
||||
void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
||||
void CSMDoc::DocumentManager::addDocument (const std::vector<std::filesystem::path>& files, const std::filesystem::path& savePath,
|
||||
bool new_)
|
||||
{
|
||||
Document *document = makeDocument (files, savePath, new_);
|
||||
|
@ -59,8 +59,8 @@ void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::
|
|||
}
|
||||
|
||||
CSMDoc::Document *CSMDoc::DocumentManager::makeDocument (
|
||||
const std::vector< boost::filesystem::path >& files,
|
||||
const boost::filesystem::path& savePath, bool new_)
|
||||
const std::vector< std::filesystem::path >& files,
|
||||
const std::filesystem::path& savePath, bool new_)
|
||||
{
|
||||
return new Document (mConfiguration, files, new_, savePath, mResDir, mEncoding, mBlacklistedScripts, mFsStrict, mDataPaths, mArchives);
|
||||
}
|
||||
|
@ -93,9 +93,9 @@ void CSMDoc::DocumentManager::removeDocument (CSMDoc::Document *document)
|
|||
emit lastDocumentDeleted();
|
||||
}
|
||||
|
||||
void CSMDoc::DocumentManager::setResourceDir (const boost::filesystem::path& parResDir)
|
||||
void CSMDoc::DocumentManager::setResourceDir (const std::filesystem::path& parResDir)
|
||||
{
|
||||
mResDir = boost::filesystem::system_complete(parResDir);
|
||||
mResDir = std::filesystem::absolute(parResDir);
|
||||
}
|
||||
|
||||
void CSMDoc::DocumentManager::setEncoding (ToUTF8::FromType encoding)
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
|
||||
|
@ -40,7 +38,7 @@ namespace CSMDoc
|
|||
ToUTF8::FromType mEncoding;
|
||||
std::vector<std::string> mBlacklistedScripts;
|
||||
|
||||
boost::filesystem::path mResDir;
|
||||
std::filesystem::path mResDir;
|
||||
|
||||
bool mFsStrict;
|
||||
Files::PathContainer mDataPaths;
|
||||
|
@ -55,8 +53,8 @@ namespace CSMDoc
|
|||
|
||||
~DocumentManager();
|
||||
|
||||
void addDocument (const std::vector< boost::filesystem::path >& files,
|
||||
const boost::filesystem::path& savePath, bool new_);
|
||||
void addDocument (const std::vector< std::filesystem::path >& files,
|
||||
const std::filesystem::path& savePath, bool new_);
|
||||
///< \param new_ Do not load the last content file in \a files and instead create in an
|
||||
/// appropriate way.
|
||||
|
||||
|
@ -66,10 +64,10 @@ namespace CSMDoc
|
|||
///
|
||||
/// \param new_ Do not load the last content file in \a files and instead create in an
|
||||
/// appropriate way.
|
||||
Document *makeDocument (const std::vector< boost::filesystem::path >& files,
|
||||
const boost::filesystem::path& savePath, bool new_);
|
||||
Document *makeDocument (const std::vector< std::filesystem::path >& files,
|
||||
const std::filesystem::path& savePath, bool new_);
|
||||
|
||||
void setResourceDir (const boost::filesystem::path& parResDir);
|
||||
void setResourceDir (const std::filesystem::path& parResDir);
|
||||
|
||||
void setEncoding (ToUTF8::FromType encoding);
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "loader.hpp"
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "../tools/reportmodel.hpp"
|
||||
|
@ -87,13 +89,13 @@ void CSMDoc::Loader::load()
|
|||
|
||||
if (iter->second.mFile<size) // start loading the files
|
||||
{
|
||||
boost::filesystem::path path = document->getContentFiles()[iter->second.mFile];
|
||||
std::filesystem::path path = document->getContentFiles()[iter->second.mFile];
|
||||
|
||||
int steps = document->getData().startLoading (path, iter->second.mFile!=editedIndex, /*project*/false);
|
||||
iter->second.mRecordsLeft = true;
|
||||
iter->second.mRecordsLoaded = 0;
|
||||
|
||||
emit nextStage (document, path.filename().string(), steps);
|
||||
emit nextStage (document, Files::pathToUnicodeString(path.filename()), steps);
|
||||
}
|
||||
else if (iter->second.mFile==size) // start loading the last (project) file
|
||||
{
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
#include "runner.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QDir>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextStream>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "operationholder.hpp"
|
||||
|
||||
CSMDoc::Runner::Runner (const boost::filesystem::path& projectPath)
|
||||
: mRunning (false), mStartup (nullptr), mProjectPath (projectPath)
|
||||
CSMDoc::Runner::Runner (std::filesystem::path projectPath)
|
||||
: mRunning (false), mStartup (nullptr), mProjectPath (std::move(projectPath))
|
||||
{
|
||||
connect (&mProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished),
|
||||
this, &Runner::finished);
|
||||
|
@ -78,23 +83,21 @@ void CSMDoc::Runner::start (bool delayed)
|
|||
else
|
||||
arguments << "--new-game=1";
|
||||
|
||||
arguments << ("--script-run="+mStartup->fileName());
|
||||
arguments << ("--script-run=" + mStartup->fileName());
|
||||
|
||||
arguments <<
|
||||
QString::fromUtf8 (("--data=\""+mProjectPath.parent_path().string()+"\"").c_str());
|
||||
arguments << "--data=\"" + Files::pathToQString(mProjectPath.parent_path()) + "\"";
|
||||
|
||||
arguments << "--replace=content";
|
||||
|
||||
for (std::vector<std::string>::const_iterator iter (mContentFiles.begin());
|
||||
iter!=mContentFiles.end(); ++iter)
|
||||
for (const auto& mContentFile : mContentFiles)
|
||||
{
|
||||
arguments << QString::fromUtf8 (("--content="+*iter).c_str());
|
||||
arguments << "--content=" + Files::pathToQString(mContentFile);
|
||||
}
|
||||
|
||||
arguments
|
||||
<< QString::fromUtf8 (("--content="+mProjectPath.filename().string()).c_str());
|
||||
<< "--content=" + Files::pathToQString(mProjectPath.filename());
|
||||
|
||||
mProcess.start (path, arguments);
|
||||
mProcess.start(path, arguments);
|
||||
}
|
||||
|
||||
mRunning = true;
|
||||
|
@ -121,7 +124,7 @@ bool CSMDoc::Runner::isRunning() const
|
|||
}
|
||||
|
||||
void CSMDoc::Runner::configure (const ESM::DebugProfile& profile,
|
||||
const std::vector<std::string>& contentFiles, const std::string& startupInstruction)
|
||||
const std::vector<std::filesystem::path> &contentFiles, const std::string& startupInstruction)
|
||||
{
|
||||
mProfile = profile;
|
||||
mContentFiles = contentFiles;
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QTextDocument>
|
||||
|
||||
#include <components/esm3/debugprofile.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
class QTemporaryFile;
|
||||
|
||||
namespace CSMDoc
|
||||
|
@ -25,15 +25,15 @@ namespace CSMDoc
|
|||
QProcess mProcess;
|
||||
bool mRunning;
|
||||
ESM::DebugProfile mProfile;
|
||||
std::vector<std::string> mContentFiles;
|
||||
std::vector<std::filesystem::path> mContentFiles;
|
||||
std::string mStartupInstruction;
|
||||
QTemporaryFile *mStartup;
|
||||
QTextDocument mLog;
|
||||
boost::filesystem::path mProjectPath;
|
||||
std::filesystem::path mProjectPath;
|
||||
|
||||
public:
|
||||
|
||||
Runner (const boost::filesystem::path& projectPath);
|
||||
Runner (std::filesystem::path projectPath);
|
||||
|
||||
~Runner();
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace CSMDoc
|
|||
bool isRunning() const;
|
||||
|
||||
void configure (const ESM::DebugProfile& profile,
|
||||
const std::vector<std::string>& contentFiles,
|
||||
const std::vector<std::filesystem::path> &contentFiles,
|
||||
const std::string& startupInstruction);
|
||||
|
||||
QTextDocument *getLog();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "savingstages.hpp"
|
||||
#include "document.hpp"
|
||||
|
||||
CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& projectPath,
|
||||
CSMDoc::Saving::Saving (Document& document, const std::filesystem::path& projectPath,
|
||||
ToUTF8::FromType encoding)
|
||||
: Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath, encoding)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef CSM_DOC_SAVING_H
|
||||
#define CSM_DOC_SAVING_H
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <components/to_utf8/to_utf8.hpp>
|
||||
|
||||
#include "operation.hpp"
|
||||
|
@ -21,7 +19,7 @@ namespace CSMDoc
|
|||
|
||||
public:
|
||||
|
||||
Saving (Document& document, const boost::filesystem::path& projectPath,
|
||||
Saving (Document& document, const std::filesystem::path& projectPath,
|
||||
ToUTF8::FromType encoding);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "savingstages.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/esm3/loaddial.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include "../world/infocollection.hpp"
|
||||
#include "../world/cellcoordinates.hpp"
|
||||
|
@ -67,14 +67,14 @@ void CSMDoc::WriteHeaderStage::perform (int stage, Messages& messages)
|
|||
mDocument.getData().count (CSMWorld::RecordBase::State_Deleted));
|
||||
|
||||
/// \todo refine dependency list (at least remove redundant dependencies)
|
||||
std::vector<boost::filesystem::path> dependencies = mDocument.getContentFiles();
|
||||
std::vector<boost::filesystem::path>::const_iterator end (--dependencies.end());
|
||||
std::vector<std::filesystem::path> dependencies = mDocument.getContentFiles();
|
||||
std::vector<std::filesystem::path>::const_iterator end (--dependencies.end());
|
||||
|
||||
for (std::vector<boost::filesystem::path>::const_iterator iter (dependencies.begin());
|
||||
for (std::vector<std::filesystem::path>::const_iterator iter (dependencies.begin());
|
||||
iter!=end; ++iter)
|
||||
{
|
||||
std::string name = iter->filename().string();
|
||||
uint64_t size = boost::filesystem::file_size (*iter);
|
||||
auto name = Files::pathToUnicodeString(iter->filename());
|
||||
auto size = std::filesystem::file_size (*iter);
|
||||
|
||||
mState.getWriter().addMaster (name, size);
|
||||
}
|
||||
|
@ -519,15 +519,15 @@ void CSMDoc::FinalSavingStage::perform (int stage, Messages& messages)
|
|||
mState.getWriter().close();
|
||||
mState.getStream().close();
|
||||
|
||||
if (boost::filesystem::exists (mState.getTmpPath()))
|
||||
boost::filesystem::remove (mState.getTmpPath());
|
||||
if (std::filesystem::exists (mState.getTmpPath()))
|
||||
std::filesystem::remove (mState.getTmpPath());
|
||||
}
|
||||
else if (!mState.isProjectFile())
|
||||
{
|
||||
if (boost::filesystem::exists (mState.getPath()))
|
||||
boost::filesystem::remove (mState.getPath());
|
||||
if (std::filesystem::exists (mState.getPath()))
|
||||
std::filesystem::remove (mState.getPath());
|
||||
|
||||
boost::filesystem::rename (mState.getTmpPath(), mState.getPath());
|
||||
std::filesystem::rename (mState.getTmpPath(), mState.getPath());
|
||||
|
||||
mDocument.getUndoStack().setClean();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
#include "savingstate.hpp"
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <filesystem>
|
||||
#include <utility>
|
||||
|
||||
#include "operation.hpp"
|
||||
#include "document.hpp"
|
||||
|
||||
CSMDoc::SavingState::SavingState (Operation& operation, const boost::filesystem::path& projectPath,
|
||||
CSMDoc::SavingState::SavingState (Operation& operation, std::filesystem::path projectPath,
|
||||
ToUTF8::FromType encoding)
|
||||
: mOperation (operation), mEncoder (encoding), mProjectPath (projectPath), mProjectFile (false)
|
||||
: mOperation (operation), mEncoder (encoding), mProjectPath (std::move(projectPath)), mProjectFile (false)
|
||||
{
|
||||
mWriter.setEncoder (&mEncoder);
|
||||
}
|
||||
|
@ -33,24 +34,24 @@ void CSMDoc::SavingState::start (Document& document, bool project)
|
|||
else
|
||||
mPath = document.getSavePath();
|
||||
|
||||
boost::filesystem::path file (mPath.filename().string() + ".tmp");
|
||||
std::filesystem::path file (mPath.filename().u8string() + u8".tmp");
|
||||
|
||||
mTmpPath = mPath.parent_path();
|
||||
|
||||
mTmpPath /= file;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& CSMDoc::SavingState::getPath() const
|
||||
const std::filesystem::path& CSMDoc::SavingState::getPath() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& CSMDoc::SavingState::getTmpPath() const
|
||||
const std::filesystem::path& CSMDoc::SavingState::getTmpPath() const
|
||||
{
|
||||
return mTmpPath;
|
||||
}
|
||||
|
||||
boost::filesystem::ofstream& CSMDoc::SavingState::getStream()
|
||||
std::ofstream& CSMDoc::SavingState::getStream()
|
||||
{
|
||||
return mStream;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
#include <fstream>
|
||||
#include <map>
|
||||
#include <deque>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/esm3/esmwriter.hpp>
|
||||
|
||||
|
@ -20,18 +18,18 @@ namespace CSMDoc
|
|||
class SavingState
|
||||
{
|
||||
Operation& mOperation;
|
||||
boost::filesystem::path mPath;
|
||||
boost::filesystem::path mTmpPath;
|
||||
std::filesystem::path mPath;
|
||||
std::filesystem::path mTmpPath;
|
||||
ToUTF8::Utf8Encoder mEncoder;
|
||||
boost::filesystem::ofstream mStream;
|
||||
std::ofstream mStream;
|
||||
ESM::ESMWriter mWriter;
|
||||
boost::filesystem::path mProjectPath;
|
||||
std::filesystem::path mProjectPath;
|
||||
bool mProjectFile;
|
||||
std::map<std::string, std::deque<int> > mSubRecords; // record ID, list of subrecords
|
||||
|
||||
public:
|
||||
|
||||
SavingState (Operation& operation, const boost::filesystem::path& projectPath,
|
||||
SavingState (Operation& operation, std::filesystem::path projectPath,
|
||||
ToUTF8::FromType encoding);
|
||||
|
||||
bool hasError() const;
|
||||
|
@ -39,11 +37,11 @@ namespace CSMDoc
|
|||
void start (Document& document, bool project);
|
||||
///< \param project Save project file instead of content file.
|
||||
|
||||
const boost::filesystem::path& getPath() const;
|
||||
const std::filesystem::path& getPath() const;
|
||||
|
||||
const boost::filesystem::path& getTmpPath() const;
|
||||
const std::filesystem::path& getTmpPath() const;
|
||||
|
||||
boost::filesystem::ofstream& getStream();
|
||||
std::ofstream& getStream();
|
||||
|
||||
ESM::ESMWriter& getWriter();
|
||||
|
||||
|
|
|
@ -648,8 +648,7 @@ CSMPrefs::State::~State()
|
|||
|
||||
void CSMPrefs::State::save()
|
||||
{
|
||||
boost::filesystem::path user = mConfigurationManager.getUserConfigPath() / mConfigFile;
|
||||
Settings::Manager::saveUser (user.string());
|
||||
Settings::Manager::saveUser (mConfigurationManager.getUserConfigPath() / mConfigFile);
|
||||
}
|
||||
|
||||
CSMPrefs::State::Iterator CSMPrefs::State::begin()
|
||||
|
|
|
@ -40,11 +40,11 @@ void CSMTools::FinishMergedDocumentStage::perform (int stage, CSMDoc::Messages&
|
|||
// We know that the content file list contains at least two entries and that the first one
|
||||
// does exist on disc (otherwise it would have been impossible to initiate a merge on that
|
||||
// document).
|
||||
boost::filesystem::path path = mState.mSource.getContentFiles()[0];
|
||||
std::filesystem::path path = mState.mSource.getContentFiles()[0];
|
||||
|
||||
ESM::ESMReader reader;
|
||||
reader.setEncoder (&mEncoder);
|
||||
reader.open (path.string());
|
||||
reader.open (path);
|
||||
|
||||
CSMWorld::MetaData source;
|
||||
source.mId = "sys::meta";
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include "../doc/operationholder.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
|
|
|
@ -95,7 +95,9 @@ void CSMWorld::CommandDispatcher::setEditLock (bool locked)
|
|||
void CSMWorld::CommandDispatcher::setSelection (const std::vector<std::string>& selection)
|
||||
{
|
||||
mSelection = selection;
|
||||
std::for_each (mSelection.begin(), mSelection.end(), Misc::StringUtils::lowerCaseInPlace);
|
||||
for (auto& sel : mSelection) {
|
||||
Misc::StringUtils::lowerCaseInPlace(sel);
|
||||
}
|
||||
std::sort (mSelection.begin(), mSelection.end());
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec
|
|||
}
|
||||
|
||||
CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
|
||||
const std::vector<std::string>& archives, const boost::filesystem::path& resDir)
|
||||
const std::vector<std::string>& archives, const std::filesystem::path& resDir)
|
||||
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells),
|
||||
mReader (nullptr), mDialogue (nullptr), mReaderIndex(1),
|
||||
mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives)
|
||||
|
@ -88,7 +88,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat
|
|||
defines[define.first] = define.second;
|
||||
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines);
|
||||
|
||||
mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string());
|
||||
mResourceSystem->getSceneManager()->setShaderPath(resDir / "shaders");
|
||||
|
||||
int index = 0;
|
||||
|
||||
|
@ -958,7 +958,7 @@ void CSMWorld::Data::merge()
|
|||
mGlobals.merge();
|
||||
}
|
||||
|
||||
int CSMWorld::Data::getTotalRecords (const std::vector<boost::filesystem::path>& files)
|
||||
int CSMWorld::Data::getTotalRecords (const std::vector<std::filesystem::path>& files)
|
||||
{
|
||||
int records = 0;
|
||||
|
||||
|
@ -966,10 +966,10 @@ int CSMWorld::Data::getTotalRecords (const std::vector<boost::filesystem::path>&
|
|||
|
||||
for (unsigned int i = 0; i < files.size(); ++i)
|
||||
{
|
||||
if (!boost::filesystem::exists(files[i]))
|
||||
if (!std::filesystem::exists(files[i]))
|
||||
continue;
|
||||
|
||||
reader->open(files[i].string());
|
||||
reader->open(files[i]);
|
||||
records += reader->getRecordCount();
|
||||
reader->close();
|
||||
}
|
||||
|
@ -977,7 +977,7 @@ int CSMWorld::Data::getTotalRecords (const std::vector<boost::filesystem::path>&
|
|||
return records;
|
||||
}
|
||||
|
||||
int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base, bool project)
|
||||
int CSMWorld::Data::startLoading (const std::filesystem::path& path, bool base, bool project)
|
||||
{
|
||||
// Don't delete the Reader yet. Some record types store a reference to the Reader to handle on-demand loading
|
||||
std::shared_ptr<ESM::ESMReader> ptr(mReader);
|
||||
|
@ -989,9 +989,7 @@ int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base
|
|||
mReader = new ESM::ESMReader;
|
||||
mReader->setEncoder (&mEncoder);
|
||||
mReader->setIndex((project || !base) ? 0 : mReaderIndex++);
|
||||
mReader->open (path.string());
|
||||
|
||||
mContentFileNames.insert(std::make_pair(path.filename().string(), mReader->getIndex()));
|
||||
mReader->open (path);
|
||||
|
||||
mBase = base;
|
||||
mProject = project;
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <QObject>
|
||||
#include <QModelIndex>
|
||||
|
||||
|
@ -128,8 +126,6 @@ namespace CSMWorld
|
|||
|
||||
std::vector<std::shared_ptr<ESM::ESMReader> > mReaders;
|
||||
|
||||
std::map<std::string, int> mContentFileNames;
|
||||
|
||||
// not implemented
|
||||
Data (const Data&);
|
||||
Data& operator= (const Data&);
|
||||
|
@ -148,7 +144,7 @@ namespace CSMWorld
|
|||
public:
|
||||
|
||||
Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
|
||||
const std::vector<std::string>& archives, const boost::filesystem::path& resDir);
|
||||
const std::vector<std::string>& archives, const std::filesystem::path& resDir);
|
||||
|
||||
~Data() override;
|
||||
|
||||
|
@ -290,9 +286,9 @@ namespace CSMWorld
|
|||
void merge();
|
||||
///< Merge modified into base.
|
||||
|
||||
int getTotalRecords (const std::vector<boost::filesystem::path>& files); // for better loading bar
|
||||
int getTotalRecords (const std::vector<std::filesystem::path>& files); // for better loading bar
|
||||
|
||||
int startLoading (const boost::filesystem::path& path, bool base, bool project);
|
||||
int startLoading (const std::filesystem::path& path, bool base, bool project);
|
||||
///< Begin merging content of a file into base or modified.
|
||||
///
|
||||
/// \param project load project file instead of content file
|
||||
|
|
|
@ -169,7 +169,9 @@ void CSMWorld::RegionMap::updateRegions (const std::vector<std::string>& regions
|
|||
{
|
||||
std::vector<std::string> regions2 (regions);
|
||||
|
||||
std::for_each (regions2.begin(), regions2.end(), Misc::StringUtils::lowerCaseInPlace);
|
||||
for (auto& region2 : regions2) {
|
||||
Misc::StringUtils::lowerCaseInPlace(region2);
|
||||
}
|
||||
std::sort (regions2.begin(), regions2.end());
|
||||
|
||||
for (std::map<CellCoordinates, CellDescription>::const_iterator iter (mMap.begin());
|
||||
|
|
|
@ -94,7 +94,9 @@ bool CSMWorld::ScriptContext::isId (const std::string& name) const
|
|||
{
|
||||
mIds = mData.getIds();
|
||||
|
||||
std::for_each (mIds.begin(), mIds.end(), &Misc::StringUtils::lowerCaseInPlace);
|
||||
for (auto& id : mIds) {
|
||||
Misc::StringUtils::lowerCaseInPlace(id);
|
||||
}
|
||||
std::sort (mIds.begin(), mIds.end());
|
||||
|
||||
mIdsUpdated = true;
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
#include "adjusterwidget.hpp"
|
||||
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QStyle>
|
||||
|
||||
#include <components/files/qtconversion.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
|
||||
CSVDoc::AdjusterWidget::AdjusterWidget (QWidget *parent)
|
||||
: QWidget (parent), mValid (false), mAction (ContentAction_Undefined)
|
||||
{
|
||||
|
@ -33,12 +34,12 @@ void CSVDoc::AdjusterWidget::setAction (ContentAction action)
|
|||
mAction = action;
|
||||
}
|
||||
|
||||
void CSVDoc::AdjusterWidget::setLocalData (const boost::filesystem::path& localData)
|
||||
void CSVDoc::AdjusterWidget::setLocalData (const std::filesystem::path& localData)
|
||||
{
|
||||
mLocalData = localData;
|
||||
}
|
||||
|
||||
boost::filesystem::path CSVDoc::AdjusterWidget::getPath() const
|
||||
std::filesystem::path CSVDoc::AdjusterWidget::getPath() const
|
||||
{
|
||||
if (!mValid)
|
||||
throw std::logic_error ("invalid content file path");
|
||||
|
@ -69,14 +70,14 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
|||
}
|
||||
else
|
||||
{
|
||||
boost::filesystem::path path (name.toUtf8().data());
|
||||
auto path = Files::pathFromQString(name);
|
||||
|
||||
std::string extension = Misc::StringUtils::lowerCase(path.extension().string());
|
||||
const auto extension = Misc::StringUtils::lowerCase(path.extension().u8string());
|
||||
|
||||
bool isLegacyPath = (extension == ".esm" ||
|
||||
extension == ".esp");
|
||||
bool isLegacyPath = (extension == u8".esm" ||
|
||||
extension == u8".esp");
|
||||
|
||||
bool isFilePathChanged = (path.parent_path().string() != mLocalData.string());
|
||||
bool isFilePathChanged = (path.parent_path() != mLocalData);
|
||||
|
||||
if (isLegacyPath)
|
||||
path.replace_extension (addon ? ".omwaddon" : ".omwgame");
|
||||
|
@ -86,7 +87,7 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
|||
if (!isFilePathChanged && !isLegacyPath)
|
||||
{
|
||||
// path already points to the local data directory
|
||||
message = QString::fromUtf8 (("Will be saved as: " + path.string()).c_str());
|
||||
message = "Will be saved as: " + Files::pathToQString(path);
|
||||
mResultPath = path;
|
||||
}
|
||||
//in all other cases, ensure the path points to data-local and do an existing file check
|
||||
|
@ -96,10 +97,10 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
|||
if (isFilePathChanged)
|
||||
path = mLocalData / path.filename();
|
||||
|
||||
message = QString::fromUtf8 (("Will be saved as: " + path.string()).c_str());
|
||||
message = "Will be saved as: " + Files::pathToQString(path);
|
||||
mResultPath = path;
|
||||
|
||||
if (boost::filesystem::exists (path))
|
||||
if (std::filesystem::exists (path))
|
||||
{
|
||||
/// \todo add an user setting to make this an error.
|
||||
message += "<p>A file with the same name already exists. If you continue, it will be overwritten.";
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#ifndef CSV_DOC_ADJUSTERWIDGET_H
|
||||
#define CSV_DOC_ADJUSTERWIDGET_H
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
class QLabel;
|
||||
|
||||
namespace CSVDoc
|
||||
|
@ -22,11 +23,11 @@ namespace CSVDoc
|
|||
|
||||
public:
|
||||
|
||||
boost::filesystem::path mLocalData;
|
||||
std::filesystem::path mLocalData;
|
||||
QLabel *mMessage;
|
||||
QLabel *mIcon;
|
||||
bool mValid;
|
||||
boost::filesystem::path mResultPath;
|
||||
std::filesystem::path mResultPath;
|
||||
ContentAction mAction;
|
||||
bool mDoFilenameCheck;
|
||||
|
||||
|
@ -34,13 +35,13 @@ namespace CSVDoc
|
|||
|
||||
AdjusterWidget (QWidget *parent = nullptr);
|
||||
|
||||
void setLocalData (const boost::filesystem::path& localData);
|
||||
void setLocalData (const std::filesystem::path& localData);
|
||||
void setAction (ContentAction action);
|
||||
|
||||
void setFilenameCheck (bool doCheck);
|
||||
bool isValid() const;
|
||||
|
||||
boost::filesystem::path getPath() const;
|
||||
std::filesystem::path getPath() const;
|
||||
///< This function must not be called if there is no valid path.
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -20,7 +20,7 @@ CSVDoc::FileDialog::FileDialog(QWidget *parent) :
|
|||
mAdjusterWidget = new AdjusterWidget (this);
|
||||
}
|
||||
|
||||
void CSVDoc::FileDialog::addFiles(const std::vector<boost::filesystem::path>& dataDirs)
|
||||
void CSVDoc::FileDialog::addFiles(const std::vector<std::filesystem::path>& dataDirs)
|
||||
{
|
||||
for (auto iter = dataDirs.rbegin(); iter != dataDirs.rend(); ++iter)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ QStringList CSVDoc::FileDialog::selectedFilePaths()
|
|||
return filePaths;
|
||||
}
|
||||
|
||||
void CSVDoc::FileDialog::setLocalData (const boost::filesystem::path& localData)
|
||||
void CSVDoc::FileDialog::setLocalData (const std::filesystem::path& localData)
|
||||
{
|
||||
mAdjusterWidget->setLocalData (localData);
|
||||
}
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
|
||||
#ifndef Q_MOC_RUN
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include "adjusterwidget.hpp"
|
||||
|
||||
#ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||
#define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||
Q_DECLARE_METATYPE (boost::filesystem::path)
|
||||
#ifndef CS_QT_STD_FILESYSTEM_PATH_DECLARED
|
||||
#define CS_QT_STD_FILESYSTEM_PATH_DECLARED
|
||||
Q_DECLARE_METATYPE (std::filesystem::path)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -45,14 +44,14 @@ namespace CSVDoc
|
|||
explicit FileDialog(QWidget *parent = nullptr);
|
||||
void showDialog (ContentAction action);
|
||||
|
||||
void addFiles(const std::vector<boost::filesystem::path>& dataDirs);
|
||||
void addFiles(const std::vector<std::filesystem::path>& dataDirs);
|
||||
void setEncoding (const QString &encoding);
|
||||
void clearFiles ();
|
||||
|
||||
QString filename() const;
|
||||
QStringList selectedFilePaths();
|
||||
|
||||
void setLocalData (const boost::filesystem::path& localData);
|
||||
void setLocalData (const std::filesystem::path& localData);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -61,8 +60,8 @@ namespace CSVDoc
|
|||
|
||||
signals:
|
||||
|
||||
void signalOpenFiles (const boost::filesystem::path &path);
|
||||
void signalCreateNewFile (const boost::filesystem::path &path);
|
||||
void signalOpenFiles (const std::filesystem::path &path);
|
||||
void signalCreateNewFile (const std::filesystem::path &path);
|
||||
|
||||
void signalUpdateAcceptButton (bool, int);
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#include <QCloseEvent>
|
||||
#include <QListWidget>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
void CSVDoc::LoadingDocument::closeEvent (QCloseEvent *event)
|
||||
|
@ -19,7 +22,7 @@ void CSVDoc::LoadingDocument::closeEvent (QCloseEvent *event)
|
|||
CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
|
||||
: mDocument (document), mTotalRecordsLabel (0), mRecordsLabel (0), mAborted (false), mMessages (nullptr), mRecords(0)
|
||||
{
|
||||
setWindowTitle (QString::fromUtf8((std::string("Opening ") + document->getSavePath().filename().string()).c_str()));
|
||||
setWindowTitle ("Opening " + Files::pathToQString(document->getSavePath().filename()));
|
||||
|
||||
setMinimumWidth (400);
|
||||
|
||||
|
@ -89,16 +92,16 @@ void CSVDoc::LoadingDocument::nextStage (const std::string& name, int fileRecord
|
|||
mRecords = fileRecords;
|
||||
}
|
||||
|
||||
void CSVDoc::LoadingDocument::nextRecord (int records)
|
||||
void CSVDoc::LoadingDocument::nextRecord(int records)
|
||||
{
|
||||
if (records <= mRecords)
|
||||
{
|
||||
mTotalProgress->setValue (mTotalRecords+records);
|
||||
mTotalProgress->setValue(mTotalRecords + records);
|
||||
|
||||
mRecordProgress->setValue(records);
|
||||
|
||||
mRecordsLabel->setText(QString::fromStdString(
|
||||
"Records: "+std::to_string(records)+" of "+std::to_string(mRecords)));
|
||||
mRecordsLabel->setText(
|
||||
"Records: " + QString::number(records) + " of " + QString::number(mRecords));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ CSVDoc::NewGameDialogue::NewGameDialogue()
|
|||
move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y());
|
||||
}
|
||||
|
||||
void CSVDoc::NewGameDialogue::setLocalData (const boost::filesystem::path& localData)
|
||||
void CSVDoc::NewGameDialogue::setLocalData (const std::filesystem::path& localData)
|
||||
{
|
||||
mAdjusterWidget->setLocalData (localData);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#ifndef CSV_DOC_NEWGAME_H
|
||||
#define CSV_DOC_NEWGAME_H
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMetaType>
|
||||
|
||||
#ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||
#define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||
Q_DECLARE_METATYPE (boost::filesystem::path)
|
||||
#include <filesystem>
|
||||
|
||||
#ifndef CS_QT_STD_FILESYSTEM_PATH_DECLARED
|
||||
#define CS_QT_STD_FILESYSTEM_PATH_DECLARED
|
||||
Q_DECLARE_METATYPE (std::filesystem::path)
|
||||
#endif
|
||||
|
||||
class QPushButton;
|
||||
|
@ -30,11 +30,11 @@ namespace CSVDoc
|
|||
|
||||
NewGameDialogue();
|
||||
|
||||
void setLocalData (const boost::filesystem::path& localData);
|
||||
void setLocalData (const std::filesystem::path& localData);
|
||||
|
||||
signals:
|
||||
|
||||
void createRequest (const boost::filesystem::path& file);
|
||||
void createRequest (const std::filesystem::path& file);
|
||||
|
||||
void cancelCreateGame ();
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <components/misc/helpviewer.hpp>
|
||||
#include <components/version/version.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include "viewmanager.hpp"
|
||||
#include "operations.hpp"
|
||||
|
@ -387,7 +388,7 @@ void CSVDoc::View::updateTitle()
|
|||
{
|
||||
std::ostringstream stream;
|
||||
|
||||
stream << mDocument->getSavePath().filename().string();
|
||||
stream << Files::pathToUnicodeString(mDocument->getSavePath().filename());
|
||||
|
||||
if (mDocument->getState() & CSMDoc::State_Modified)
|
||||
stream << " *";
|
||||
|
@ -747,7 +748,7 @@ void CSVDoc::View::tutorial()
|
|||
void CSVDoc::View::infoAbout()
|
||||
{
|
||||
// Get current OpenMW version
|
||||
QString versionInfo = (Version::getOpenmwVersionDescription(mDocument->getResourceDir().string())+
|
||||
QString versionInfo = (Version::getOpenmwVersionDescription(mDocument->getResourceDir())+
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
" (64-bit)").c_str();
|
||||
#else
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "../../model/doc/documentmanager.hpp"
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/doc/documentmanager.hpp"
|
||||
#include "../../model/doc/state.hpp"
|
||||
|
||||
#include "../../model/world/columns.hpp"
|
||||
|
@ -261,7 +263,7 @@ bool CSVDoc::ViewManager::showModifiedDocumentMessageBox (CSVDoc::View *view)
|
|||
QMessageBox messageBox(view);
|
||||
CSMDoc::Document *document = view->getDocument();
|
||||
|
||||
messageBox.setWindowTitle (QString::fromUtf8(document->getSavePath().filename().string().c_str()));
|
||||
messageBox.setWindowTitle (Files::pathToQString(document->getSavePath().filename()));
|
||||
messageBox.setText ("The document has been modified.");
|
||||
messageBox.setInformativeText ("Do you want to save your changes?");
|
||||
messageBox.setStandardButtons (QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
|
||||
#include "merge.hpp"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QSplitter>
|
||||
#include <QPushButton>
|
||||
#include <QListWidget>
|
||||
#include <QLabel>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QSplitter>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/doc/documentmanager.hpp"
|
||||
|
@ -98,14 +101,14 @@ void CSVTools::Merge::configure (CSMDoc::Document *document)
|
|||
while (mFiles->count())
|
||||
delete mFiles->takeItem (0);
|
||||
|
||||
std::vector<boost::filesystem::path> files = document->getContentFiles();
|
||||
std::vector<std::filesystem::path> files = document->getContentFiles();
|
||||
|
||||
for (std::vector<boost::filesystem::path>::const_iterator iter (files.begin());
|
||||
for (std::vector<std::filesystem::path>::const_iterator iter (files.begin());
|
||||
iter!=files.end(); ++iter)
|
||||
mFiles->addItem (QString::fromUtf8 (iter->filename().string().c_str()));
|
||||
mFiles->addItem (Files::pathToQString(iter->filename()));
|
||||
}
|
||||
|
||||
void CSVTools::Merge::setLocalData (const boost::filesystem::path& localData)
|
||||
void CSVTools::Merge::setLocalData (const std::filesystem::path& localData)
|
||||
{
|
||||
mAdjuster->setLocalData (localData);
|
||||
}
|
||||
|
@ -125,7 +128,7 @@ void CSVTools::Merge::accept()
|
|||
{
|
||||
if ((mDocument->getState() & CSMDoc::State_Merging)==0)
|
||||
{
|
||||
std::vector< boost::filesystem::path > files (1, mAdjuster->getPath());
|
||||
std::vector< std::filesystem::path > files { mAdjuster->getPath() };
|
||||
|
||||
std::unique_ptr<CSMDoc::Document> target (
|
||||
mDocumentManager.makeDocument (files, files[0], true));
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#endif
|
||||
#include <filesystem>
|
||||
|
||||
class QPushButton;
|
||||
class QListWidget;
|
||||
|
@ -44,7 +42,7 @@ namespace CSVTools
|
|||
/// Configure dialogue for a new merge
|
||||
void configure (CSMDoc::Document *document);
|
||||
|
||||
void setLocalData (const boost::filesystem::path& localData);
|
||||
void setLocalData (const std::filesystem::path& localData);
|
||||
|
||||
CSMDoc::Document *getDocument() const;
|
||||
|
||||
|
|
|
@ -143,9 +143,6 @@ target_link_libraries(openmw
|
|||
${OSGDB_LIBRARIES}
|
||||
${OSGUTIL_LIBRARIES}
|
||||
${OSG_LIBRARIES}
|
||||
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
${OPENAL_LIBRARY}
|
||||
${FFmpeg_LIBRARIES}
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
#include "engine.hpp"
|
||||
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <filesystem>
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
#include <osgDB/WriteFile>
|
||||
|
@ -532,7 +528,7 @@ void OMW::Engine::enableFSStrict(bool fsStrict)
|
|||
void OMW::Engine::setDataDirs (const Files::PathContainer& dataDirs)
|
||||
{
|
||||
mDataDirs = dataDirs;
|
||||
mDataDirs.insert(mDataDirs.begin(), (mResDir / "vfs"));
|
||||
mDataDirs.insert(mDataDirs.begin(), mResDir / "vfs");
|
||||
mFileCollections = Files::Collections (mDataDirs, !mFSStrict);
|
||||
}
|
||||
|
||||
|
@ -542,7 +538,7 @@ void OMW::Engine::addArchive (const std::string& archive) {
|
|||
}
|
||||
|
||||
// Set resource dir
|
||||
void OMW::Engine::setResourceDir (const boost::filesystem::path& parResDir)
|
||||
void OMW::Engine::setResourceDir (const std::filesystem::path& parResDir)
|
||||
{
|
||||
mResDir = parResDir;
|
||||
}
|
||||
|
@ -712,7 +708,7 @@ void OMW::Engine::createWindow()
|
|||
void OMW::Engine::setWindowIcon()
|
||||
{
|
||||
std::ifstream windowIconStream;
|
||||
std::string windowIcon = (mResDir / "openmw.png").string();
|
||||
const auto windowIcon = mResDir / "openmw.png";
|
||||
windowIconStream.open(windowIcon, std::ios_base::in | std::ios_base::binary);
|
||||
if (windowIconStream.fail())
|
||||
Log(Debug::Error) << "Error: Failed to open " << windowIcon;
|
||||
|
@ -769,7 +765,7 @@ void OMW::Engine::prepareEngine()
|
|||
mScreenCaptureOperation = new SceneUtil::AsyncScreenCaptureOperation(
|
||||
mWorkQueue,
|
||||
new SceneUtil::WriteScreenshotToFileOperation(
|
||||
mCfgMgr.getScreenshotPath().string(),
|
||||
mCfgMgr.getScreenshotPath(),
|
||||
Settings::Manager::getString("screenshot format", "General"),
|
||||
Settings::Manager::getBool("notify on saved screenshot", "General")
|
||||
? std::function<void (std::string)>(ScheduleNonDialogMessageBox {})
|
||||
|
@ -781,35 +777,34 @@ void OMW::Engine::prepareEngine()
|
|||
|
||||
mViewer->addEventHandler(mScreenCaptureHandler);
|
||||
|
||||
mLuaManager = std::make_unique<MWLua::LuaManager>(mVFS.get(), (mResDir / "lua_libs").string());
|
||||
mLuaManager = std::make_unique<MWLua::LuaManager>(mVFS.get(), mResDir / "lua_libs");
|
||||
mEnvironment.setLuaManager(*mLuaManager);
|
||||
|
||||
// Create input and UI first to set up a bootstrapping environment for
|
||||
// showing a loading screen and keeping the window responsive while doing so
|
||||
|
||||
std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input_v3.xml").string();
|
||||
const auto keybinderUser = mCfgMgr.getUserConfigPath() / "input_v3.xml";
|
||||
bool keybinderUserExists = std::filesystem::exists(keybinderUser);
|
||||
if(!keybinderUserExists)
|
||||
{
|
||||
std::string input2 = (mCfgMgr.getUserConfigPath() / "input_v2.xml").string();
|
||||
const auto input2 = (mCfgMgr.getUserConfigPath() / "input_v2.xml");
|
||||
if(std::filesystem::exists(input2)) {
|
||||
std::filesystem::copy_file(input2, keybinderUser);
|
||||
keybinderUserExists = std::filesystem::exists(keybinderUser);
|
||||
keybinderUserExists = std::filesystem::copy_file(input2, keybinderUser);
|
||||
Log(Debug::Info) << "Loading keybindings file: " << keybinderUser;
|
||||
}
|
||||
}
|
||||
else
|
||||
Log(Debug::Info) << "Loading keybindings file: " << keybinderUser;
|
||||
|
||||
const std::string userdefault = mCfgMgr.getUserConfigPath().string() + "/gamecontrollerdb.txt";
|
||||
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/gamecontrollerdb.txt";
|
||||
const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/gamecontrollerdb.txt";
|
||||
const auto userdefault = mCfgMgr.getUserConfigPath() / "gamecontrollerdb.txt";
|
||||
const auto localdefault = mCfgMgr.getLocalPath() / "gamecontrollerdb.txt";
|
||||
const auto globaldefault = mCfgMgr.getGlobalPath() / "gamecontrollerdb.txt";
|
||||
|
||||
std::string userGameControllerdb;
|
||||
std::filesystem::path userGameControllerdb;
|
||||
if (std::filesystem::exists(userdefault))
|
||||
userGameControllerdb = userdefault;
|
||||
|
||||
std::string gameControllerdb;
|
||||
std::filesystem::path gameControllerdb;
|
||||
if (std::filesystem::exists(localdefault))
|
||||
gameControllerdb = localdefault;
|
||||
else if (std::filesystem::exists(globaldefault))
|
||||
|
@ -817,7 +812,7 @@ void OMW::Engine::prepareEngine()
|
|||
//else if it doesn't exist, pass in an empty string
|
||||
|
||||
// gui needs our shaders path before everything else
|
||||
mResourceSystem->getSceneManager()->setShaderPath((mResDir / "shaders").string());
|
||||
mResourceSystem->getSceneManager()->setShaderPath(mResDir / "shaders");
|
||||
|
||||
osg::ref_ptr<osg::GLExtensions> exts = osg::GLExtensions::Get(0, false);
|
||||
bool shadersSupported = exts && (exts->glslLanguageVersion >= 1.2f);
|
||||
|
@ -835,9 +830,9 @@ void OMW::Engine::prepareEngine()
|
|||
rootNode->addChild(guiRoot);
|
||||
|
||||
mWindowManager = std::make_unique<MWGui::WindowManager>(mWindow, mViewer, guiRoot, mResourceSystem.get(), mWorkQueue.get(),
|
||||
mCfgMgr.getLogPath().string() + std::string("/"),
|
||||
mCfgMgr.getLogPath(),
|
||||
mScriptConsoleMode, mTranslationDataStorage, mEncoding,
|
||||
Version::getOpenmwVersionDescription(mResDir.string()), shadersSupported);
|
||||
Version::getOpenmwVersionDescription(mResDir), shadersSupported);
|
||||
mEnvironment.setWindowManager(*mWindowManager);
|
||||
|
||||
mInputManager = std::make_unique<MWInput::InputManager>(mWindow, mViewer, mScreenCaptureHandler,
|
||||
|
@ -858,7 +853,7 @@ void OMW::Engine::prepareEngine()
|
|||
// Create the world
|
||||
mWorld = std::make_unique<MWWorld::World>(mViewer, rootNode, mResourceSystem.get(), mWorkQueue.get(), *mUnrefQueue,
|
||||
mFileCollections, mContentFiles, mGroundcoverFiles, mEncoder.get(), mActivationDistanceOverride, mCellName,
|
||||
mStartupScript, mResDir.string(), mCfgMgr.getUserDataPath().string());
|
||||
mStartupScript, mResDir, mCfgMgr.getUserDataPath());
|
||||
mWorld->setupPlayer();
|
||||
mWorld->setRandomSeed(mRandomSeed);
|
||||
mEnvironment.setWorld(*mWorld);
|
||||
|
@ -869,8 +864,8 @@ void OMW::Engine::prepareEngine()
|
|||
|
||||
//Load translation data
|
||||
mTranslationDataStorage.setEncoder(mEncoder.get());
|
||||
for (size_t i = 0; i < mContentFiles.size(); i++)
|
||||
mTranslationDataStorage.loadTranslationData(mFileCollections, mContentFiles[i]);
|
||||
for (auto & mContentFile : mContentFiles)
|
||||
mTranslationDataStorage.loadTranslationData(mFileCollections, mContentFile);
|
||||
|
||||
Compiler::registerExtensions (mExtensions);
|
||||
|
||||
|
@ -914,7 +909,7 @@ void OMW::Engine::prepareEngine()
|
|||
}
|
||||
|
||||
mLuaManager->init();
|
||||
mLuaManager->loadPermanentStorage(mCfgMgr.getUserConfigPath().string());
|
||||
mLuaManager->loadPermanentStorage(mCfgMgr.getUserConfigPath());
|
||||
}
|
||||
|
||||
class OMW::Engine::LuaWorker
|
||||
|
@ -1018,7 +1013,7 @@ void OMW::Engine::go()
|
|||
|
||||
Misc::Rng::init(mRandomSeed);
|
||||
|
||||
Settings::ShaderManager::get().load((mCfgMgr.getUserConfigPath() / "shaders.yaml").string());
|
||||
Settings::ShaderManager::get().load(mCfgMgr.getUserConfigPath() / "shaders.yaml");
|
||||
|
||||
MWClass::registerClasses();
|
||||
|
||||
|
@ -1036,8 +1031,18 @@ void OMW::Engine::go()
|
|||
|
||||
prepareEngine();
|
||||
|
||||
#ifdef _WIN32
|
||||
const auto* stats_file = _wgetenv(L"OPENMW_OSG_STATS_FILE");
|
||||
#else
|
||||
const auto* stats_file = std::getenv("OPENMW_OSG_STATS_FILE");
|
||||
#endif
|
||||
|
||||
std::filesystem::path path;
|
||||
if (stats_file != nullptr)
|
||||
path = stats_file;
|
||||
|
||||
std::ofstream stats;
|
||||
if (const auto path = std::getenv("OPENMW_OSG_STATS_FILE"))
|
||||
if (!path.empty())
|
||||
{
|
||||
stats.open(path, std::ios_base::out);
|
||||
if (stats.is_open())
|
||||
|
@ -1140,9 +1145,9 @@ void OMW::Engine::go()
|
|||
luaWorker.join();
|
||||
|
||||
// Save user settings
|
||||
Settings::Manager::saveUser((mCfgMgr.getUserConfigPath() / "settings.cfg").string());
|
||||
Settings::Manager::saveUser(mCfgMgr.getUserConfigPath() / "settings.cfg");
|
||||
Settings::ShaderManager::get().save();
|
||||
mLuaManager->savePermanentStorage(mCfgMgr.getUserConfigPath().string());
|
||||
mLuaManager->savePermanentStorage(mCfgMgr.getUserConfigPath());
|
||||
|
||||
Log(Debug::Info) << "Quitting peacefully.";
|
||||
}
|
||||
|
@ -1197,7 +1202,7 @@ void OMW::Engine::setScriptBlacklistUse (bool use)
|
|||
mScriptBlacklistUse = use;
|
||||
}
|
||||
|
||||
void OMW::Engine::setSaveGameFile(const std::string &savegame)
|
||||
void OMW::Engine::setSaveGameFile(const std::filesystem::path &savegame)
|
||||
{
|
||||
mSaveGameFile = savegame;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef ENGINE_H
|
||||
#define ENGINE_H
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/compiler/extensions.hpp>
|
||||
#include <components/files/collections.hpp>
|
||||
#include <components/translation/translation.hpp>
|
||||
|
@ -135,7 +137,7 @@ namespace OMW
|
|||
std::unique_ptr<ToUTF8::Utf8Encoder> mEncoder;
|
||||
Files::PathContainer mDataDirs;
|
||||
std::vector<std::string> mArchives;
|
||||
boost::filesystem::path mResDir;
|
||||
std::filesystem::path mResDir;
|
||||
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
||||
osg::ref_ptr<osgViewer::ScreenCaptureHandler> mScreenCaptureHandler;
|
||||
osg::ref_ptr<SceneUtil::AsyncScreenCaptureOperation> mScreenCaptureOperation;
|
||||
|
@ -156,7 +158,7 @@ namespace OMW
|
|||
bool mScriptConsoleMode;
|
||||
std::string mStartupScript;
|
||||
int mActivationDistanceOverride;
|
||||
std::string mSaveGameFile;
|
||||
std::filesystem::path mSaveGameFile;
|
||||
// Grab mouse?
|
||||
bool mGrab;
|
||||
|
||||
|
@ -203,7 +205,7 @@ namespace OMW
|
|||
void addArchive(const std::string& archive);
|
||||
|
||||
/// Set resource dir
|
||||
void setResourceDir(const boost::filesystem::path& parResDir);
|
||||
void setResourceDir(const std::filesystem::path& parResDir);
|
||||
|
||||
/// Set start cell name
|
||||
void setCell(const std::string& cellName);
|
||||
|
@ -254,7 +256,7 @@ namespace OMW
|
|||
void setScriptBlacklistUse (bool use);
|
||||
|
||||
/// Set the save game file to load after initialising the engine.
|
||||
void setSaveGameFile(const std::string& savegame);
|
||||
void setSaveGameFile(const std::filesystem::path &savegame);
|
||||
|
||||
void setRandomSeed(unsigned int seed);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
{
|
||||
cfgMgr.readConfiguration(variables, desc, true);
|
||||
|
||||
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::MaybeQuotedPath>().string());
|
||||
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
getRawStdout() << v.describe() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
@ -69,10 +69,10 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
cfgMgr.readConfiguration(variables, desc);
|
||||
Settings::Manager::load(cfgMgr);
|
||||
|
||||
setupLogging(cfgMgr.getLogPath().string(), "OpenMW");
|
||||
setupLogging(cfgMgr.getLogPath(), "OpenMW");
|
||||
MWGui::DebugWindow::startLogRecording();
|
||||
|
||||
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::MaybeQuotedPath>().string());
|
||||
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
Log(Debug::Info) << v.describe();
|
||||
|
||||
engine.setGrabMouse(!variables["no-grab"].as<bool>());
|
||||
|
@ -87,13 +87,13 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
|
||||
Files::PathContainer dataDirs(asPathContainer(variables["data"].as<Files::MaybeQuotedPathContainer>()));
|
||||
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>());
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
if (!local.empty())
|
||||
dataDirs.push_back(local);
|
||||
|
||||
cfgMgr.filterOutNonExistingPaths(dataDirs);
|
||||
|
||||
engine.setResourceDir(variables["resources"].as<Files::MaybeQuotedPath>());
|
||||
engine.setResourceDir(variables["resources"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
|
||||
engine.setDataDirs(dataDirs);
|
||||
|
||||
// fallback archives
|
||||
|
@ -150,7 +150,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
engine.setWarningsMode (variables["script-warn"].as<int>());
|
||||
engine.setScriptBlacklist (variables["script-blacklist"].as<StringsVector>());
|
||||
engine.setScriptBlacklistUse (variables["script-blacklist-use"].as<bool>());
|
||||
engine.setSaveGameFile (variables["load-savegame"].as<Files::MaybeQuotedPath>().string());
|
||||
engine.setSaveGameFile (variables["load-savegame"].as<Files::MaybeQuotedPath>().u8string());
|
||||
|
||||
// other settings
|
||||
Fallback::Map::init(variables["fallback"].as<FallbackMap>().mMap);
|
||||
|
|
|
@ -62,12 +62,12 @@ namespace MWBase
|
|||
///
|
||||
/// \note Slot must belong to the current character.
|
||||
|
||||
virtual void loadGame (const std::string& filepath) = 0;
|
||||
virtual void loadGame (const std::filesystem::path &filepath) = 0;
|
||||
///< Load a saved game directly from the given file path. This will search the CharacterManager
|
||||
/// for a Character containing this save file, and set this Character current if one was found.
|
||||
/// Otherwise, a new Character will be created.
|
||||
|
||||
virtual void loadGame (const MWState::Character *character, const std::string& filepath) = 0;
|
||||
virtual void loadGame (const MWState::Character *character, const std::filesystem::path &filepath) = 0;
|
||||
///< Load a saved game file belonging to the given character.
|
||||
|
||||
///Simple saver, writes over the file if already existing
|
||||
|
|
|
@ -639,7 +639,7 @@ namespace MWBase
|
|||
|
||||
/// Export scene graph to a file and return the filename.
|
||||
/// \param ptr object to export scene graph for (if empty, export entire scene graph)
|
||||
virtual std::string exportSceneGraph(const MWWorld::Ptr& ptr) = 0;
|
||||
virtual std::filesystem::path exportSceneGraph(const MWWorld::Ptr& ptr) = 0;
|
||||
|
||||
/// Preload VFX associated with this effect list
|
||||
virtual void preloadEffects(const ESM::EffectList* effectList) = 0;
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include <components/files/memorystream.hpp>
|
||||
#include <components/misc/timeconvert.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include <components/esm3/loadclas.hpp>
|
||||
|
||||
|
@ -199,7 +201,7 @@ namespace MWGui
|
|||
|
||||
if (mCurrentCharacter == &*it ||
|
||||
(!mCurrentCharacter && !mSaving && directory==Misc::StringUtils::lowerCase (
|
||||
it->begin()->mPath.parent_path().filename().string())))
|
||||
Files::pathToUnicodeString(it->begin()->mPath.parent_path().filename()))))
|
||||
{
|
||||
mCurrentCharacter = &*it;
|
||||
selectedIndex = mCharacterSelection->getItemCount()-1;
|
||||
|
@ -302,7 +304,7 @@ namespace MWGui
|
|||
else
|
||||
{
|
||||
assert (mCurrentCharacter && mCurrentSlot);
|
||||
MWBase::Environment::get().getStateManager()->loadGame (mCurrentCharacter, mCurrentSlot->mPath.string());
|
||||
MWBase::Environment::get().getStateManager()->loadGame (mCurrentCharacter, mCurrentSlot->mPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,7 +405,7 @@ namespace MWGui
|
|||
throw std::runtime_error("Can't find selected slot");
|
||||
|
||||
std::stringstream text;
|
||||
time_t time = mCurrentSlot->mTimeStamp;
|
||||
time_t time = Misc::to_time_t(mCurrentSlot->mTimeStamp);
|
||||
struct tm* timeinfo;
|
||||
timeinfo = localtime(&time);
|
||||
|
||||
|
@ -438,7 +440,7 @@ namespace MWGui
|
|||
const std::vector<char>& data = mCurrentSlot->mProfile.mScreenshot;
|
||||
if (!data.size())
|
||||
{
|
||||
Log(Debug::Warning) << "Selected save file '" << mCurrentSlot->mPath.filename().string() << "' has no savegame screenshot";
|
||||
Log(Debug::Warning) << "Selected save file '" << Files::pathToUnicodeString(mCurrentSlot->mPath.filename()) << "' has no savegame screenshot";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace MWGui
|
|||
{
|
||||
WindowManager::WindowManager(
|
||||
SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
|
||||
const std::string& logpath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
|
||||
const std::filesystem::path& logpath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
|
||||
ToUTF8::FromType encoding, const std::string& versionDescription, bool useShaders)
|
||||
: mOldUpdateMask(0)
|
||||
, mOldCullMask(0)
|
||||
|
@ -180,7 +180,7 @@ namespace MWGui
|
|||
mScalingFactor = std::clamp(Settings::Manager::getFloat("scaling factor", "GUI"), 0.5f, 8.f);
|
||||
mGuiPlatform = std::make_unique<osgMyGUI::Platform>(viewer, guiRoot, resourceSystem->getImageManager(),
|
||||
resourceSystem->getVFS(), mScalingFactor, "mygui",
|
||||
(std::filesystem::path(logpath) / "MyGUI.log").generic_string());
|
||||
logpath / "MyGUI.log");
|
||||
|
||||
mGui = std::make_unique<MyGUI::Gui>();
|
||||
mGui->initialise("");
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <MyGUI_Gui.h>
|
||||
#include <MyGUI_KeyCode.h>
|
||||
#include <MyGUI_Types.h>
|
||||
#include <filesystem>
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
|
@ -124,7 +125,7 @@ namespace MWGui
|
|||
typedef std::vector<Faction> FactionList;
|
||||
|
||||
WindowManager(SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
|
||||
const std::string& logpath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
|
||||
const std::filesystem::path& logpath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
|
||||
ToUTF8::FromType encoding, const std::string& versionDescription, bool useShaders);
|
||||
virtual ~WindowManager();
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <extern/oics/ICSInputControlSystem.h>
|
||||
|
||||
#include <components/sdlutil/sdlmappings.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/inputmanager.hpp"
|
||||
|
@ -43,8 +44,8 @@ namespace MWInput
|
|||
class InputControlSystem : public ICS::InputControlSystem
|
||||
{
|
||||
public:
|
||||
InputControlSystem(const std::string& bindingsFile)
|
||||
: ICS::InputControlSystem(bindingsFile, true, nullptr, nullptr, A_Last)
|
||||
InputControlSystem(const std::filesystem::path &bindingsFile)
|
||||
: ICS::InputControlSystem(Files::pathToUnicodeString(bindingsFile), true, nullptr, nullptr, A_Last)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -167,11 +168,11 @@ namespace MWInput
|
|||
bool mDetectingKeyboard;
|
||||
};
|
||||
|
||||
BindingsManager::BindingsManager(const std::string& userFile, bool userFileExists)
|
||||
BindingsManager::BindingsManager(const std::filesystem::path &userFile, bool userFileExists)
|
||||
: mUserFile(userFile)
|
||||
, mDragDrop(false)
|
||||
{
|
||||
std::string file = userFileExists ? userFile : "";
|
||||
const auto file = userFileExists ? userFile : std::filesystem::path();
|
||||
mInputBinder = std::make_unique<InputControlSystem>(file);
|
||||
mListener = std::make_unique<BindingsListener>(mInputBinder.get(), this);
|
||||
mInputBinder->setDetectingBindingListener(mListener.get());
|
||||
|
@ -192,7 +193,7 @@ namespace MWInput
|
|||
|
||||
BindingsManager::~BindingsManager()
|
||||
{
|
||||
mInputBinder->save(mUserFile);
|
||||
mInputBinder->save(Files::pathToUnicodeString(mUserFile));
|
||||
}
|
||||
|
||||
void BindingsManager::update(float dt)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/sdlutil/events.hpp>
|
||||
|
||||
|
@ -15,7 +16,7 @@ namespace MWInput
|
|||
class BindingsManager
|
||||
{
|
||||
public:
|
||||
BindingsManager(const std::string& userFile, bool userFileExists);
|
||||
BindingsManager(const std::filesystem::path &userFile, bool userFileExists);
|
||||
|
||||
virtual ~BindingsManager();
|
||||
|
||||
|
@ -70,7 +71,7 @@ namespace MWInput
|
|||
std::unique_ptr<InputControlSystem> mInputBinder;
|
||||
std::unique_ptr<BindingsListener> mListener;
|
||||
|
||||
std::string mUserFile;
|
||||
std::filesystem::path mUserFile;
|
||||
|
||||
bool mDragDrop;
|
||||
};
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/sdlutil/sdlmappings.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/inputmanager.hpp"
|
||||
|
@ -27,8 +28,8 @@ namespace MWInput
|
|||
ControllerManager::ControllerManager(BindingsManager* bindingsManager,
|
||||
ActionManager* actionManager,
|
||||
MouseManager* mouseManager,
|
||||
const std::string& userControllerBindingsFile,
|
||||
const std::string& controllerBindingsFile)
|
||||
const std::filesystem::path &userControllerBindingsFile,
|
||||
const std::filesystem::path &controllerBindingsFile)
|
||||
: mBindingsManager(bindingsManager)
|
||||
, mActionManager(actionManager)
|
||||
, mMouseManager(mouseManager)
|
||||
|
@ -43,12 +44,12 @@ namespace MWInput
|
|||
{
|
||||
if (!controllerBindingsFile.empty())
|
||||
{
|
||||
SDL_GameControllerAddMappingsFromFile(controllerBindingsFile.c_str());
|
||||
SDL_GameControllerAddMappingsFromFile(Files::pathToUnicodeString(controllerBindingsFile).c_str());
|
||||
}
|
||||
|
||||
if (!userControllerBindingsFile.empty())
|
||||
{
|
||||
SDL_GameControllerAddMappingsFromFile(userControllerBindingsFile.c_str());
|
||||
SDL_GameControllerAddMappingsFromFile(Files::pathToUnicodeString(userControllerBindingsFile).c_str());
|
||||
}
|
||||
|
||||
// Open all presently connected sticks
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/sdlutil/events.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
namespace MWInput
|
||||
{
|
||||
|
@ -18,8 +19,8 @@ namespace MWInput
|
|||
ControllerManager(BindingsManager* bindingsManager,
|
||||
ActionManager* actionManager,
|
||||
MouseManager* mouseManager,
|
||||
const std::string& userControllerBindingsFile,
|
||||
const std::string& controllerBindingsFile);
|
||||
const std::filesystem::path &userControllerBindingsFile,
|
||||
const std::filesystem::path &controllerBindingsFile);
|
||||
|
||||
virtual ~ControllerManager() = default;
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ namespace MWInput
|
|||
osg::ref_ptr<osgViewer::Viewer> viewer,
|
||||
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler,
|
||||
osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation,
|
||||
const std::string& userFile, bool userFileExists, const std::string& userControllerBindingsFile,
|
||||
const std::string& controllerBindingsFile, bool grab)
|
||||
const std::filesystem::path &userFile, bool userFileExists, const std::filesystem::path &userControllerBindingsFile,
|
||||
const std::filesystem::path &controllerBindingsFile, bool grab)
|
||||
: mControlsDisabled(false)
|
||||
, mInputWrapper(std::make_unique<SDLUtil::InputWrapper>(window, viewer, grab))
|
||||
, mBindingsManager(std::make_unique<BindingsManager>(userFile, userFileExists))
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/sdlutil/events.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#include "../mwbase/inputmanager.hpp"
|
||||
|
||||
|
@ -52,9 +53,9 @@ namespace MWInput
|
|||
osg::ref_ptr<osgViewer::Viewer> viewer,
|
||||
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler,
|
||||
osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation,
|
||||
const std::string& userFile, bool userFileExists,
|
||||
const std::string& userControllerBindingsFile,
|
||||
const std::string& controllerBindingsFile, bool grab);
|
||||
const std::filesystem::path &userFile, bool userFileExists,
|
||||
const std::filesystem::path &userControllerBindingsFile,
|
||||
const std::filesystem::path &controllerBindingsFile, bool grab);
|
||||
|
||||
~InputManager() final;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
namespace MWLua
|
||||
{
|
||||
|
||||
LuaManager::LuaManager(const VFS::Manager* vfs, const std::string& libsDir)
|
||||
LuaManager::LuaManager(const VFS::Manager* vfs, const std::filesystem::path &libsDir)
|
||||
: mLua(vfs, &mConfiguration)
|
||||
, mUiResourceManager(vfs)
|
||||
, mL10n(vfs, &mLua)
|
||||
|
@ -110,21 +110,20 @@ namespace MWLua
|
|||
return mL10n.translate(contextName, key);
|
||||
}
|
||||
|
||||
void LuaManager::loadPermanentStorage(const std::string& userConfigPath)
|
||||
void LuaManager::loadPermanentStorage(const std::filesystem::path &userConfigPath)
|
||||
{
|
||||
auto globalPath = std::filesystem::path(userConfigPath) / "global_storage.bin";
|
||||
auto playerPath = std::filesystem::path(userConfigPath) / "player_storage.bin";
|
||||
const auto globalPath = userConfigPath / "global_storage.bin";
|
||||
const auto playerPath = userConfigPath / "player_storage.bin";
|
||||
if (std::filesystem::exists(globalPath))
|
||||
mGlobalStorage.load(globalPath.string());
|
||||
mGlobalStorage.load(globalPath);
|
||||
if (std::filesystem::exists(playerPath))
|
||||
mPlayerStorage.load(playerPath.string());
|
||||
mPlayerStorage.load(playerPath);
|
||||
}
|
||||
|
||||
void LuaManager::savePermanentStorage(const std::string& userConfigPath)
|
||||
void LuaManager::savePermanentStorage(const std::filesystem::path &userConfigPath)
|
||||
{
|
||||
std::filesystem::path confDir(userConfigPath);
|
||||
mGlobalStorage.save((confDir / "global_storage.bin").string());
|
||||
mPlayerStorage.save((confDir / "player_storage.bin").string());
|
||||
mGlobalStorage.save(userConfigPath / "global_storage.bin");
|
||||
mPlayerStorage.save(userConfigPath / "player_storage.bin");
|
||||
}
|
||||
|
||||
void LuaManager::update()
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <components/lua_ui/resources.hpp>
|
||||
|
||||
#include <components/misc/color.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#include "../mwbase/luamanager.hpp"
|
||||
|
||||
|
@ -26,7 +27,7 @@ namespace MWLua
|
|||
class LuaManager : public MWBase::LuaManager
|
||||
{
|
||||
public:
|
||||
LuaManager(const VFS::Manager* vfs, const std::string& libsDir);
|
||||
LuaManager(const VFS::Manager* vfs, const std::filesystem::path &libsDir);
|
||||
|
||||
// Called by engine.cpp before UI setup.
|
||||
void initL10n();
|
||||
|
@ -34,8 +35,8 @@ namespace MWLua
|
|||
// Called by engine.cpp when the environment is fully initialized.
|
||||
void init();
|
||||
|
||||
void loadPermanentStorage(const std::string& userConfigPath);
|
||||
void savePermanentStorage(const std::string& userConfigPath);
|
||||
void loadPermanentStorage(const std::filesystem::path &userConfigPath);
|
||||
void savePermanentStorage(const std::filesystem::path &userConfigPath);
|
||||
|
||||
// Called by engine.cpp every frame. For performance reasons it works in a separate
|
||||
// thread (in parallel with osg Cull). Can not use scene graph.
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <components/vfs/manager.hpp>
|
||||
#include <components/stereo/multiview.hpp>
|
||||
#include <components/stereo/stereomanager.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -217,12 +218,12 @@ namespace MWRender
|
|||
{
|
||||
for (const auto& name : mVFS->getRecursiveDirectoryIterator(fx::Technique::sSubdir))
|
||||
{
|
||||
std::filesystem::path path = name;
|
||||
std::string fileExt = Misc::StringUtils::lowerCase(path.extension().string());
|
||||
std::filesystem::path path = Files::pathFromUnicodeString(name);
|
||||
std::string fileExt = Misc::StringUtils::lowerCase(Files::pathToUnicodeString(path.extension()));
|
||||
if (!path.parent_path().has_parent_path() && fileExt == fx::Technique::sExt)
|
||||
{
|
||||
auto absolutePath = std::filesystem::path(mVFS->getAbsoluteFileName(name));
|
||||
mTechniqueFileMap[absolutePath.stem().string()] = absolutePath;
|
||||
const auto absolutePath = mVFS->getAbsoluteFileName(path);
|
||||
mTechniqueFileMap[Files::pathToUnicodeString(absolutePath.stem())] = absolutePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -387,7 +388,7 @@ namespace MWRender
|
|||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
|
||||
if (technique->compile())
|
||||
Log(Debug::Info) << "Reloaded technique : " << mTechniqueFileMap[technique->getName()].string();
|
||||
Log(Debug::Info) << "Reloaded technique : " << mTechniqueFileMap[technique->getName()];
|
||||
|
||||
mReload = technique->isValid();
|
||||
}
|
||||
|
|
|
@ -173,6 +173,7 @@ namespace MWRender
|
|||
stateset->addUniform(new osg::Uniform("far", 0.f));
|
||||
stateset->addUniform(new osg::Uniform("skyBlendingStart", 0.f));
|
||||
stateset->addUniform(new osg::Uniform("screenRes", osg::Vec2f{}));
|
||||
stateset->addUniform(new osg::Uniform("isReflection", false));
|
||||
if (mUsePlayerUniforms)
|
||||
{
|
||||
stateset->addUniform(new osg::Uniform("windSpeed", 0.0f));
|
||||
|
@ -368,7 +369,7 @@ namespace MWRender
|
|||
};
|
||||
|
||||
RenderingManager::RenderingManager(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode,
|
||||
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::string& resourcePath,
|
||||
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::filesystem::path& resourcePath,
|
||||
DetourNavigator::Navigator& navigator, const MWWorld::GroundcoverStore& groundcoverStore,
|
||||
SceneUtil::UnrefQueue& unrefQueue)
|
||||
: mSkyBlending(Settings::Manager::getBool("sky blending", "Fog"))
|
||||
|
@ -1525,7 +1526,7 @@ namespace MWRender
|
|||
updateProjectionMatrix();
|
||||
}
|
||||
}
|
||||
void RenderingManager::exportSceneGraph(const MWWorld::Ptr &ptr, const std::string &filename, const std::string &format)
|
||||
void RenderingManager::exportSceneGraph(const MWWorld::Ptr &ptr, const std::filesystem::path& filename, const std::string &format)
|
||||
{
|
||||
osg::Node* node = mViewer->getSceneData();
|
||||
if (!ptr.isEmpty())
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace MWRender
|
|||
{
|
||||
public:
|
||||
RenderingManager(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode,
|
||||
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::string& resourcePath,
|
||||
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::filesystem::path& resourcePath,
|
||||
DetourNavigator::Navigator& navigator, const MWWorld::GroundcoverStore& groundcoverStore,
|
||||
SceneUtil::UnrefQueue& unrefQueue);
|
||||
~RenderingManager();
|
||||
|
@ -232,7 +232,7 @@ namespace MWRender
|
|||
|
||||
osg::Vec3f getHalfExtents(const MWWorld::ConstPtr& object) const;
|
||||
|
||||
void exportSceneGraph(const MWWorld::Ptr& ptr, const std::string& filename, const std::string& format);
|
||||
void exportSceneGraph(const MWWorld::Ptr& ptr, const std::filesystem::path& filename, const std::string& format);
|
||||
|
||||
LandManager* getLandManager() const;
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ private:
|
|||
float mRainIntensity;
|
||||
};
|
||||
|
||||
osg::ref_ptr<osg::Image> readPngImage (const std::string& file)
|
||||
osg::ref_ptr<osg::Image> readPngImage (const std::filesystem::path& file)
|
||||
{
|
||||
std::ifstream inStream;
|
||||
inStream.open(file, std::ios_base::in | std::ios_base::binary);
|
||||
|
@ -351,6 +351,9 @@ public:
|
|||
camera->setName("ReflectionCamera");
|
||||
camera->addCullCallback(new InheritViewPointCallback);
|
||||
|
||||
// Inform the shader that we're in a reflection
|
||||
camera->getOrCreateStateSet()->addUniform(new osg::Uniform("isReflection", true));
|
||||
|
||||
// XXX: should really flip the FrontFace on each renderable instead of forcing clockwise.
|
||||
osg::ref_ptr<osg::FrontFace> frontFace(new osg::FrontFace);
|
||||
frontFace->setMode(osg::FrontFace::CLOCKWISE);
|
||||
|
@ -441,7 +444,7 @@ public:
|
|||
};
|
||||
|
||||
Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem *resourceSystem,
|
||||
osgUtil::IncrementalCompileOperation *ico, const std::string& resourcePath)
|
||||
osgUtil::IncrementalCompileOperation *ico, const std::filesystem::path& resourcePath)
|
||||
: mRainIntensityUpdater(nullptr)
|
||||
, mParent(parent)
|
||||
, mSceneRoot(sceneRoot)
|
||||
|
@ -474,7 +477,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem
|
|||
geom2->setNodeMask(Mask_SimpleWater);
|
||||
geom2->setName("Simple Water Geometry");
|
||||
mWaterNode->addChild(geom2);
|
||||
|
||||
|
||||
mSceneRoot->addChild(mWaterNode);
|
||||
|
||||
setHeight(mTop);
|
||||
|
@ -692,7 +695,7 @@ void Water::createShaderWaterStateSet(osg::Node* node, Reflection* reflection, R
|
|||
osg::ref_ptr<osg::Shader> fragmentShader(shaderMgr.getShader("water_fragment.glsl", defineMap, osg::Shader::FRAGMENT));
|
||||
osg::ref_ptr<osg::Program> program = shaderMgr.getProgram(vertexShader, fragmentShader);
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> normalMap(new osg::Texture2D(readPngImage(mResourcePath + "/shaders/water_nm.png")));
|
||||
osg::ref_ptr<osg::Texture2D> normalMap(new osg::Texture2D(readPngImage(mResourcePath / "shaders" / "water_nm.png")));
|
||||
|
||||
if (normalMap->getImage())
|
||||
normalMap->getImage()->flipVertical();
|
||||
|
@ -701,7 +704,7 @@ void Water::createShaderWaterStateSet(osg::Node* node, Reflection* reflection, R
|
|||
normalMap->setMaxAnisotropy(16);
|
||||
normalMap->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR);
|
||||
normalMap->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
|
||||
|
||||
|
||||
|
||||
mRainIntensityUpdater = new RainIntensityUpdater();
|
||||
node->setUpdateCallback(mRainIntensityUpdater);
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace MWRender
|
|||
osg::ref_ptr<Refraction> mRefraction;
|
||||
osg::ref_ptr<Reflection> mReflection;
|
||||
|
||||
const std::string mResourcePath;
|
||||
const std::filesystem::path mResourcePath;
|
||||
|
||||
bool mEnabled;
|
||||
bool mToggled;
|
||||
|
@ -90,7 +90,7 @@ namespace MWRender
|
|||
public:
|
||||
Water(osg::Group* parent, osg::Group* sceneRoot,
|
||||
Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico,
|
||||
const std::string& resourcePath);
|
||||
const std::filesystem::path& resourcePath);
|
||||
~Water();
|
||||
|
||||
void setCullCallback(osg::Callback* callback);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <components/esm3/loaddoor.hpp>
|
||||
|
||||
#include <components/vfs/manager.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
@ -1529,8 +1530,8 @@ namespace MWScript
|
|||
runtime.getContext().report("Exporting the entire scene graph will result in a large file. Confirm this action using 'showscenegraph 1' or select an object instead.");
|
||||
else
|
||||
{
|
||||
const std::string& filename = MWBase::Environment::get().getWorld()->exportSceneGraph(ptr);
|
||||
runtime.getContext().report("Wrote '" + filename + "'");
|
||||
const auto filename = MWBase::Environment::get().getWorld()->exportSceneGraph(ptr);
|
||||
runtime.getContext().report("Wrote '" + Files::pathToUnicodeString(filename) + "'");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace MWScript
|
|||
mScriptBlacklist.resize (scriptBlacklist.size());
|
||||
|
||||
std::transform (scriptBlacklist.begin(), scriptBlacklist.end(),
|
||||
mScriptBlacklist.begin(), Misc::StringUtils::lowerCase);
|
||||
mScriptBlacklist.begin(), [](const std::string& s) { return Misc::StringUtils::lowerCase(s); });
|
||||
std::sort (mScriptBlacklist.begin(), mScriptBlacklist.end());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#include "character.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/esm/defs.hpp>
|
||||
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/misc/utf8stream.hpp>
|
||||
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
|
@ -27,14 +26,14 @@ std::string MWState::getFirstGameFile(const std::vector<std::string>& contentFil
|
|||
return "";
|
||||
}
|
||||
|
||||
void MWState::Character::addSlot (const boost::filesystem::path& path, const std::string& game)
|
||||
void MWState::Character::addSlot (const std::filesystem::path& path, const std::string& game)
|
||||
{
|
||||
Slot slot;
|
||||
slot.mPath = path;
|
||||
slot.mTimeStamp = boost::filesystem::last_write_time (path);
|
||||
slot.mTimeStamp = std::filesystem::last_write_time (path);
|
||||
|
||||
ESM::ESMReader reader;
|
||||
reader.open (slot.mPath.string());
|
||||
reader.open (slot.mPath);
|
||||
|
||||
if (reader.getRecName()!=ESM::REC_SAVE)
|
||||
return; // invalid save file -> ignore
|
||||
|
@ -71,35 +70,32 @@ void MWState::Character::addSlot (const ESM::SavedGame& profile)
|
|||
|
||||
// Append an index if necessary to ensure a unique file
|
||||
int i=0;
|
||||
while (boost::filesystem::exists(slot.mPath))
|
||||
while (std::filesystem::exists(slot.mPath))
|
||||
{
|
||||
const std::string test = stream.str() + " - " + std::to_string(++i);
|
||||
slot.mPath = mPath / (test + ext);
|
||||
}
|
||||
|
||||
slot.mProfile = profile;
|
||||
slot.mTimeStamp = std::time (nullptr);
|
||||
slot.mTimeStamp = std::filesystem::file_time_type ();
|
||||
|
||||
mSlots.push_back (slot);
|
||||
}
|
||||
|
||||
MWState::Character::Character (const boost::filesystem::path& saves, const std::string& game)
|
||||
: mPath (saves)
|
||||
MWState::Character::Character (std::filesystem::path saves, const std::string& game)
|
||||
: mPath (std::move(saves))
|
||||
{
|
||||
if (!boost::filesystem::is_directory (mPath))
|
||||
if (!std::filesystem::is_directory (mPath))
|
||||
{
|
||||
boost::filesystem::create_directories (mPath);
|
||||
std::filesystem::create_directories (mPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (boost::filesystem::directory_iterator iter (mPath);
|
||||
iter!=boost::filesystem::directory_iterator(); ++iter)
|
||||
for (const auto& iter : std::filesystem::directory_iterator (mPath))
|
||||
{
|
||||
boost::filesystem::path slotPath = *iter;
|
||||
|
||||
try
|
||||
{
|
||||
addSlot (slotPath, game);
|
||||
addSlot (iter, game);
|
||||
}
|
||||
catch (...) {} // ignoring bad saved game files for now
|
||||
}
|
||||
|
@ -110,15 +106,15 @@ MWState::Character::Character (const boost::filesystem::path& saves, const std::
|
|||
|
||||
void MWState::Character::cleanup()
|
||||
{
|
||||
if (mSlots.size() == 0)
|
||||
if (mSlots.empty())
|
||||
{
|
||||
// All slots are gone, no need to keep the empty directory
|
||||
if (boost::filesystem::is_directory (mPath))
|
||||
if (std::filesystem::is_directory (mPath))
|
||||
{
|
||||
// Extra safety check to make sure the directory is empty (e.g. slots failed to parse header)
|
||||
boost::filesystem::directory_iterator it(mPath);
|
||||
if (it == boost::filesystem::directory_iterator())
|
||||
boost::filesystem::remove_all(mPath);
|
||||
std::filesystem::directory_iterator it(mPath);
|
||||
if (it == std::filesystem::directory_iterator())
|
||||
std::filesystem::remove_all(mPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +136,7 @@ void MWState::Character::deleteSlot (const Slot *slot)
|
|||
throw std::logic_error ("slot not found");
|
||||
}
|
||||
|
||||
boost::filesystem::remove(slot->mPath);
|
||||
std::filesystem::remove(slot->mPath);
|
||||
|
||||
mSlots.erase (mSlots.begin()+index);
|
||||
}
|
||||
|
@ -157,7 +153,7 @@ const MWState::Slot *MWState::Character::updateSlot (const Slot *slot, const ESM
|
|||
|
||||
Slot newSlot = *slot;
|
||||
newSlot.mProfile = profile;
|
||||
newSlot.mTimeStamp = std::time (nullptr);
|
||||
newSlot.mTimeStamp = std::filesystem::file_time_type ();
|
||||
|
||||
mSlots.erase (mSlots.begin()+index);
|
||||
|
||||
|
@ -195,7 +191,7 @@ ESM::SavedGame MWState::Character::getSignature() const
|
|||
return slot.mProfile;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& MWState::Character::getPath() const
|
||||
const std::filesystem::path& MWState::Character::getPath() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef GAME_STATE_CHARACTER_H
|
||||
#define GAME_STATE_CHARACTER_H
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/esm3/savedgame.hpp>
|
||||
|
||||
|
@ -9,9 +9,9 @@ namespace MWState
|
|||
{
|
||||
struct Slot
|
||||
{
|
||||
boost::filesystem::path mPath;
|
||||
std::filesystem::path mPath;
|
||||
ESM::SavedGame mProfile;
|
||||
std::time_t mTimeStamp;
|
||||
std::filesystem::file_time_type mTimeStamp;
|
||||
};
|
||||
|
||||
bool operator< (const Slot& left, const Slot& right);
|
||||
|
@ -26,16 +26,16 @@ namespace MWState
|
|||
|
||||
private:
|
||||
|
||||
boost::filesystem::path mPath;
|
||||
std::filesystem::path mPath;
|
||||
std::vector<Slot> mSlots;
|
||||
|
||||
void addSlot (const boost::filesystem::path& path, const std::string& game);
|
||||
void addSlot (const std::filesystem::path& path, const std::string& game);
|
||||
|
||||
void addSlot (const ESM::SavedGame& profile);
|
||||
|
||||
public:
|
||||
|
||||
Character (const boost::filesystem::path& saves, const std::string& game);
|
||||
Character (std::filesystem::path saves, const std::string& game);
|
||||
|
||||
void cleanup();
|
||||
///< Delete the directory we used, if it is empty
|
||||
|
@ -60,7 +60,7 @@ namespace MWState
|
|||
|
||||
SlotIterator end() const;
|
||||
|
||||
const boost::filesystem::path& getPath() const;
|
||||
const std::filesystem::path& getPath() const;
|
||||
|
||||
ESM::SavedGame getSignature() const;
|
||||
///< Return signature information for this character.
|
||||
|
|
|
@ -2,27 +2,27 @@
|
|||
|
||||
#include <cctype>
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <filesystem>
|
||||
#include <utility>
|
||||
|
||||
#include <components/misc/utf8stream.hpp>
|
||||
|
||||
MWState::CharacterManager::CharacterManager (const boost::filesystem::path& saves,
|
||||
MWState::CharacterManager::CharacterManager (std::filesystem::path saves,
|
||||
const std::vector<std::string>& contentFiles)
|
||||
: mPath (saves), mCurrent (nullptr), mGame (getFirstGameFile(contentFiles))
|
||||
: mPath (std::move(saves)), mCurrent (nullptr), mGame (getFirstGameFile(contentFiles))
|
||||
{
|
||||
if (!boost::filesystem::is_directory (mPath))
|
||||
if (!std::filesystem::is_directory (mPath))
|
||||
{
|
||||
boost::filesystem::create_directories (mPath);
|
||||
std::filesystem::create_directories (mPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (boost::filesystem::directory_iterator iter (mPath);
|
||||
iter!=boost::filesystem::directory_iterator(); ++iter)
|
||||
for (std::filesystem::directory_iterator iter (mPath);
|
||||
iter!=std::filesystem::directory_iterator(); ++iter)
|
||||
{
|
||||
boost::filesystem::path characterDir = *iter;
|
||||
std::filesystem::path characterDir = *iter;
|
||||
|
||||
if (boost::filesystem::is_directory (characterDir))
|
||||
if (std::filesystem::is_directory (characterDir))
|
||||
{
|
||||
Character character (characterDir, mGame);
|
||||
|
||||
|
@ -69,11 +69,11 @@ MWState::Character* MWState::CharacterManager::createCharacter(const std::string
|
|||
stream << '_';
|
||||
}
|
||||
|
||||
boost::filesystem::path path = mPath / stream.str();
|
||||
std::filesystem::path path = mPath / stream.str();
|
||||
|
||||
// Append an index if necessary to ensure a unique directory
|
||||
int i=0;
|
||||
while (boost::filesystem::exists(path))
|
||||
while (std::filesystem::exists(path))
|
||||
{
|
||||
std::ostringstream test;
|
||||
test << stream.str();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#ifndef GAME_STATE_CHARACTERMANAGER_H
|
||||
#define GAME_STATE_CHARACTERMANAGER_H
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
#include <list>
|
||||
|
||||
#include "character.hpp"
|
||||
|
||||
|
@ -9,7 +10,7 @@ namespace MWState
|
|||
{
|
||||
class CharacterManager
|
||||
{
|
||||
boost::filesystem::path mPath;
|
||||
std::filesystem::path mPath;
|
||||
|
||||
// Uses std::list, so that mCurrent stays valid when characters are deleted
|
||||
std::list<Character> mCharacters;
|
||||
|
@ -29,7 +30,7 @@ namespace MWState
|
|||
|
||||
public:
|
||||
|
||||
CharacterManager (const boost::filesystem::path& saves, const std::vector<std::string>& contentFiles);
|
||||
CharacterManager (std::filesystem::path saves, const std::vector<std::string>& contentFiles);
|
||||
|
||||
Character *getCurrentCharacter ();
|
||||
///< @note May return null
|
||||
|
|
|
@ -13,14 +13,12 @@
|
|||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include <osg/Image>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/journal.hpp"
|
||||
|
@ -91,7 +89,7 @@ std::map<int, int> MWState::StateManager::buildContentFileIndexMap (const ESM::E
|
|||
return map;
|
||||
}
|
||||
|
||||
MWState::StateManager::StateManager (const boost::filesystem::path& saves, const std::vector<std::string>& contentFiles)
|
||||
MWState::StateManager::StateManager (const std::filesystem::path& saves, const std::vector<std::string>& contentFiles)
|
||||
: mQuitRequest (false), mAskLoadRecent(false), mState (State_NoGame), mCharacterManager (saves, contentFiles), mTimePlayed (0)
|
||||
{
|
||||
|
||||
|
@ -301,14 +299,14 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
|||
throw std::runtime_error("Write operation failed (memory stream)");
|
||||
|
||||
// All good, write to file
|
||||
boost::filesystem::ofstream filestream (slot->mPath, std::ios::binary);
|
||||
std::ofstream filestream (slot->mPath, std::ios::binary);
|
||||
filestream << stream.rdbuf();
|
||||
|
||||
if (filestream.fail())
|
||||
throw std::runtime_error("Write operation failed (file stream)");
|
||||
|
||||
Settings::Manager::setString ("character", "Saves",
|
||||
slot->mPath.parent_path().filename().string());
|
||||
Files::pathToUnicodeString(slot->mPath.parent_path().filename()));
|
||||
|
||||
const auto finish = std::chrono::steady_clock::now();
|
||||
|
||||
|
@ -327,7 +325,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
|||
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(error.str(), buttons);
|
||||
|
||||
// If no file was written, clean up the slot
|
||||
if (character && slot && !boost::filesystem::exists(slot->mPath))
|
||||
if (character && slot && !std::filesystem::exists(slot->mPath))
|
||||
{
|
||||
character->deleteSlot(slot);
|
||||
character->cleanup();
|
||||
|
@ -367,15 +365,15 @@ void MWState::StateManager::quickSave (std::string name)
|
|||
saveGame(name, saveFinder.getNextQuickSaveSlot());
|
||||
}
|
||||
|
||||
void MWState::StateManager::loadGame(const std::string& filepath)
|
||||
void MWState::StateManager::loadGame(const std::filesystem::path &filepath)
|
||||
{
|
||||
for (const auto& character : mCharacterManager)
|
||||
{
|
||||
for (const auto& slot : character)
|
||||
{
|
||||
if (slot.mPath == boost::filesystem::path(filepath))
|
||||
if (slot.mPath == filepath)
|
||||
{
|
||||
loadGame(&character, slot.mPath.string());
|
||||
loadGame(&character, slot.mPath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -385,13 +383,13 @@ void MWState::StateManager::loadGame(const std::string& filepath)
|
|||
loadGame(character, filepath);
|
||||
}
|
||||
|
||||
void MWState::StateManager::loadGame (const Character *character, const std::string& filepath)
|
||||
void MWState::StateManager::loadGame (const Character *character, const std::filesystem::path &filepath)
|
||||
{
|
||||
try
|
||||
{
|
||||
cleanup();
|
||||
|
||||
Log(Debug::Info) << "Reading save file " << std::filesystem::path(filepath).filename().string();
|
||||
Log(Debug::Info) << "Reading save file " << filepath.filename();
|
||||
|
||||
ESM::ESMReader reader;
|
||||
reader.open (filepath);
|
||||
|
@ -524,7 +522,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
|
|||
|
||||
if (character)
|
||||
Settings::Manager::setString ("character", "Saves",
|
||||
character->getPath().filename().string());
|
||||
Files::pathToUnicodeString(character->getPath().filename()));
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->setNewGame(false);
|
||||
MWBase::Environment::get().getWorld()->saveLoaded();
|
||||
|
@ -596,7 +594,7 @@ void MWState::StateManager::quickLoad()
|
|||
{
|
||||
if (currentCharacter->begin() == currentCharacter->end())
|
||||
return;
|
||||
loadGame (currentCharacter, currentCharacter->begin()->mPath.string()); //Get newest save
|
||||
loadGame (currentCharacter, currentCharacter->begin()->mPath); //Get newest save
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -635,7 +633,7 @@ void MWState::StateManager::update (float duration)
|
|||
//Load last saved game for current character
|
||||
|
||||
MWState::Slot lastSave = *curCharacter->begin();
|
||||
loadGame(curCharacter, lastSave.mPath.string());
|
||||
loadGame(curCharacter, lastSave.mPath);
|
||||
}
|
||||
else if(iButton==1)
|
||||
{
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
#define GAME_STATE_STATEMANAGER_H
|
||||
|
||||
#include <map>
|
||||
#include <filesystem>
|
||||
|
||||
#include "../mwbase/statemanager.hpp"
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include "charactermanager.hpp"
|
||||
|
||||
namespace MWState
|
||||
|
@ -31,7 +30,7 @@ namespace MWState
|
|||
|
||||
public:
|
||||
|
||||
StateManager (const boost::filesystem::path& saves, const std::vector<std::string>& contentFiles);
|
||||
StateManager (const std::filesystem::path& saves, const std::vector<std::string>& contentFiles);
|
||||
|
||||
void requestQuit() override;
|
||||
|
||||
|
@ -67,12 +66,12 @@ namespace MWState
|
|||
/** Used for quickload **/
|
||||
void quickLoad() override;
|
||||
|
||||
void loadGame (const std::string& filepath) override;
|
||||
void loadGame (const std::filesystem::path &filepath) override;
|
||||
///< Load a saved game directly from the given file path. This will search the CharacterManager
|
||||
/// for a Character containing this save file, and set this Character current if one was found.
|
||||
/// Otherwise, a new Character will be created.
|
||||
|
||||
void loadGame (const Character *character, const std::string &filepath) override;
|
||||
void loadGame (const Character *character, const std::filesystem::path &filepath) override;
|
||||
///< Load a saved game file belonging to the given character.
|
||||
|
||||
Character *getCurrentCharacter () override;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef CONTENTLOADER_HPP
|
||||
#define CONTENTLOADER_HPP
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
namespace Loading
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ struct ContentLoader
|
|||
{
|
||||
virtual ~ContentLoader() = default;
|
||||
|
||||
virtual void load(const boost::filesystem::path& filepath, int& index, Loading::Listener* listener) = 0;
|
||||
virtual void load(const std::filesystem::path& filepath, int& index, Loading::Listener* listener) = 0;
|
||||
};
|
||||
|
||||
} /* namespace MWWorld */
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/esm3/readerscache.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
@ -16,19 +17,19 @@ EsmLoader::EsmLoader(MWWorld::ESMStore& store, ESM::ReadersCache& readers, ToUTF
|
|||
{
|
||||
}
|
||||
|
||||
void EsmLoader::load(const boost::filesystem::path& filepath, int& index, Loading::Listener* listener)
|
||||
void EsmLoader::load(const std::filesystem::path& filepath, int& index, Loading::Listener* listener)
|
||||
{
|
||||
const ESM::ReadersCache::BusyItem reader = mReaders.get(static_cast<std::size_t>(index));
|
||||
|
||||
reader->setEncoder(mEncoder);
|
||||
reader->setIndex(index);
|
||||
reader->open(filepath.string());
|
||||
reader->open(filepath);
|
||||
reader->resolveParentFileIndices(mReaders);
|
||||
|
||||
assert(reader->getGameFiles().size() == reader->getParentFileIndices().size());
|
||||
for (std::size_t i = 0, n = reader->getParentFileIndices().size(); i < n; ++i)
|
||||
if (i == static_cast<std::size_t>(reader->getIndex()))
|
||||
throw std::runtime_error("File " + reader->getName() + " asks for parent file "
|
||||
throw std::runtime_error("File " + Files::pathToUnicodeString(reader->getName()) + " asks for parent file "
|
||||
+ reader->getGameFiles()[i].name
|
||||
+ ", but it is not available or has been loaded in the wrong order. "
|
||||
"Please run the launcher to fix this issue.");
|
||||
|
@ -36,8 +37,8 @@ void EsmLoader::load(const boost::filesystem::path& filepath, int& index, Loadin
|
|||
mESMVersions[index] = reader->getVer();
|
||||
mStore.load(*reader, listener, mDialogue);
|
||||
|
||||
if (!mMasterFileFormat.has_value() && (Misc::StringUtils::ciEndsWith(reader->getName(), ".esm")
|
||||
|| Misc::StringUtils::ciEndsWith(reader->getName(), ".omwgame")))
|
||||
if (!mMasterFileFormat.has_value() && (Misc::StringUtils::ciEndsWith(reader->getName().u8string(), u8".esm")
|
||||
|| Misc::StringUtils::ciEndsWith(reader->getName().u8string(), u8".omwgame")))
|
||||
mMasterFileFormat = reader->getFormat();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define ESMLOADER_HPP
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "contentloader.hpp"
|
||||
|
||||
|
@ -27,7 +28,7 @@ struct EsmLoader : public ContentLoader
|
|||
|
||||
std::optional<int> getMasterFileFormat() const { return mMasterFileFormat; }
|
||||
|
||||
void load(const boost::filesystem::path& filepath, int& index, Loading::Listener* listener) override;
|
||||
void load(const std::filesystem::path& filepath, int& index, Loading::Listener* listener) override;
|
||||
|
||||
private:
|
||||
ESM::ReadersCache& mReaders;
|
||||
|
|
|
@ -321,13 +321,13 @@ ESM::LuaScriptsCfg ESMStore::getLuaScriptsCfg() const
|
|||
ESM::LuaScriptsCfg cfg;
|
||||
for (const LuaContent& c : mLuaContent)
|
||||
{
|
||||
if (std::holds_alternative<std::string>(c))
|
||||
if (std::holds_alternative<std::filesystem::path>(c))
|
||||
{
|
||||
// *.omwscripts are intentionally reloaded every time when `getLuaScriptsCfg` is called.
|
||||
// It is important for the `reloadlua` console command.
|
||||
try
|
||||
{
|
||||
auto file = std::ifstream(std::get<std::string>(c));
|
||||
auto file = std::ifstream(std::get<std::filesystem::path>(c));
|
||||
std::string fileContent(std::istreambuf_iterator<char>(file), {});
|
||||
LuaUtil::parseOMWScripts(cfg, fileContent);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <stdexcept>
|
||||
#include <unordered_map>
|
||||
#include <tuple>
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/esm/luascripts.hpp>
|
||||
#include <components/esm3/loadgmst.hpp>
|
||||
|
@ -159,11 +160,11 @@ namespace MWWorld
|
|||
|
||||
using LuaContent = std::variant<
|
||||
ESM::LuaScriptsCfg, // data from an omwaddon
|
||||
std::string>; // path to an omwscripts file
|
||||
std::filesystem::path>; // path to an omwscripts file
|
||||
std::vector<LuaContent> mLuaContent;
|
||||
|
||||
public:
|
||||
void addOMWScripts(std::string filePath) { mLuaContent.push_back(std::move(filePath)); }
|
||||
void addOMWScripts(std::filesystem::path filePath) { mLuaContent.push_back(std::move(filePath)); }
|
||||
ESM::LuaScriptsCfg getLuaScriptsCfg() const;
|
||||
|
||||
/// \todo replace with SharedIterator<StoreBase>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <components/detournavigator/agentbounds.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
#include <components/detournavigator/heightfieldshape.hpp>
|
||||
#include <components/detournavigator/navigatorimpl.hpp>
|
||||
#include <components/esm/records.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -136,7 +137,7 @@ namespace
|
|||
}
|
||||
|
||||
void addObject(const MWWorld::Ptr& ptr, const MWWorld::World& world, const MWPhysics::PhysicsSystem& physics,
|
||||
DetourNavigator::Navigator& navigator)
|
||||
DetourNavigator::Navigator& navigator, const DetourNavigator::UpdateGuard* navigatorUpdateGuard = nullptr)
|
||||
{
|
||||
if (const auto object = physics.getObject(ptr))
|
||||
{
|
||||
|
@ -174,7 +175,8 @@ namespace
|
|||
navigator.addObject(
|
||||
DetourNavigator::ObjectId(object),
|
||||
DetourNavigator::DoorShapes(object->getShapeInstance(), objectTransform, connectionStart, connectionEnd),
|
||||
transform
|
||||
transform,
|
||||
navigatorUpdateGuard
|
||||
);
|
||||
}
|
||||
else if (object->getShapeInstance()->mVisualCollisionType == Resource::VisualCollisionType::None)
|
||||
|
@ -182,7 +184,8 @@ namespace
|
|||
navigator.addObject(
|
||||
DetourNavigator::ObjectId(object),
|
||||
DetourNavigator::ObjectShapes(object->getShapeInstance(), objectTransform),
|
||||
object->getTransform()
|
||||
object->getTransform(),
|
||||
navigatorUpdateGuard
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -321,7 +324,7 @@ namespace MWWorld
|
|||
preloadCells(duration);
|
||||
}
|
||||
|
||||
void Scene::unloadCell(CellStore* cell)
|
||||
void Scene::unloadCell(CellStore* cell, const DetourNavigator::UpdateGuard* navigatorUpdateGuard)
|
||||
{
|
||||
if (mActiveCells.find(cell) == mActiveCells.end())
|
||||
return;
|
||||
|
@ -336,7 +339,7 @@ namespace MWWorld
|
|||
if (const auto object = mPhysics->getObject(ptr))
|
||||
{
|
||||
if (object->getShapeInstance()->mVisualCollisionType == Resource::VisualCollisionType::None)
|
||||
mNavigator.removeObject(DetourNavigator::ObjectId(object));
|
||||
mNavigator.removeObject(DetourNavigator::ObjectId(object), navigatorUpdateGuard);
|
||||
mPhysics->remove(ptr);
|
||||
ptr.mRef->mData.mPhysicsPostponed = false;
|
||||
}
|
||||
|
@ -355,13 +358,13 @@ namespace MWWorld
|
|||
if (cell->getCell()->isExterior())
|
||||
{
|
||||
if (mPhysics->getHeightField(cellX, cellY) != nullptr)
|
||||
mNavigator.removeHeightfield(osg::Vec2i(cellX, cellY));
|
||||
mNavigator.removeHeightfield(osg::Vec2i(cellX, cellY), navigatorUpdateGuard);
|
||||
|
||||
mPhysics->removeHeightField(cellX, cellY);
|
||||
}
|
||||
|
||||
if (cell->getCell()->hasWater())
|
||||
mNavigator.removeWater(osg::Vec2i(cellX, cellY));
|
||||
mNavigator.removeWater(osg::Vec2i(cellX, cellY), navigatorUpdateGuard);
|
||||
|
||||
if (const auto pathgrid = mWorld.getStore().get<ESM::Pathgrid>().search(*cell->getCell()))
|
||||
mNavigator.removePathgrid(*pathgrid);
|
||||
|
@ -380,7 +383,8 @@ namespace MWWorld
|
|||
mRendering.notifyWorldSpaceChanged();
|
||||
}
|
||||
|
||||
void Scene::loadCell(CellStore *cell, Loading::Listener* loadingListener, bool respawn, const osg::Vec3f& position)
|
||||
void Scene::loadCell(CellStore *cell, Loading::Listener* loadingListener, bool respawn, const osg::Vec3f& position,
|
||||
const DetourNavigator::UpdateGuard* navigatorUpdateGuard)
|
||||
{
|
||||
using DetourNavigator::HeightfieldShape;
|
||||
|
||||
|
@ -429,7 +433,7 @@ namespace MWWorld
|
|||
return heights;
|
||||
}
|
||||
} ();
|
||||
mNavigator.addHeightfield(cellPosition, ESM::Land::REAL_SIZE, shape);
|
||||
mNavigator.addHeightfield(cellPosition, ESM::Land::REAL_SIZE, shape, navigatorUpdateGuard);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,7 +447,7 @@ namespace MWWorld
|
|||
if (respawn)
|
||||
cell->respawn();
|
||||
|
||||
insertCell(*cell, loadingListener);
|
||||
insertCell(*cell, loadingListener, navigatorUpdateGuard);
|
||||
|
||||
mRendering.addCell(cell);
|
||||
|
||||
|
@ -459,18 +463,18 @@ namespace MWWorld
|
|||
if (cell->getCell()->isExterior())
|
||||
{
|
||||
if (const auto heightField = mPhysics->getHeightField(cellX, cellY))
|
||||
mNavigator.addWater(osg::Vec2i(cellX, cellY), ESM::Land::REAL_SIZE, waterLevel);
|
||||
mNavigator.addWater(osg::Vec2i(cellX, cellY), ESM::Land::REAL_SIZE, waterLevel,
|
||||
navigatorUpdateGuard);
|
||||
}
|
||||
else
|
||||
{
|
||||
mNavigator.addWater(osg::Vec2i(cellX, cellY), std::numeric_limits<int>::max(), waterLevel);
|
||||
mNavigator.addWater(osg::Vec2i(cellX, cellY), std::numeric_limits<int>::max(), waterLevel,
|
||||
navigatorUpdateGuard);
|
||||
}
|
||||
}
|
||||
else
|
||||
mPhysics->disableWater();
|
||||
|
||||
mNavigator.update(position);
|
||||
|
||||
if (!cell->isExterior() && !(cell->getCell()->mData.mFlags & ESM::Cell::QuasiEx))
|
||||
mRendering.configureAmbient(cell->getCell());
|
||||
|
||||
|
@ -479,11 +483,13 @@ namespace MWWorld
|
|||
|
||||
void Scene::clear()
|
||||
{
|
||||
auto navigatorUpdateGuard = mNavigator.makeUpdateGuard();
|
||||
for (auto iter = mActiveCells.begin(); iter!=mActiveCells.end(); )
|
||||
{
|
||||
auto* cell = *iter++;
|
||||
unloadCell (cell);
|
||||
unloadCell(cell, navigatorUpdateGuard.get());
|
||||
}
|
||||
navigatorUpdateGuard.reset();
|
||||
assert(mActiveCells.empty());
|
||||
mCurrentCell = nullptr;
|
||||
|
||||
|
@ -526,6 +532,8 @@ namespace MWWorld
|
|||
|
||||
void Scene::changeCellGrid (const osg::Vec3f &pos, int playerCellX, int playerCellY, bool changeEvent)
|
||||
{
|
||||
auto navigatorUpdateGuard = mNavigator.makeUpdateGuard();
|
||||
|
||||
for (auto iter = mActiveCells.begin(); iter != mActiveCells.end(); )
|
||||
{
|
||||
auto* cell = *iter++;
|
||||
|
@ -534,14 +542,15 @@ namespace MWWorld
|
|||
const auto dx = std::abs(playerCellX - cell->getCell()->getGridX());
|
||||
const auto dy = std::abs(playerCellY - cell->getCell()->getGridY());
|
||||
if (dx > mHalfGridSize || dy > mHalfGridSize)
|
||||
unloadCell(cell);
|
||||
unloadCell(cell, navigatorUpdateGuard.get());
|
||||
}
|
||||
else
|
||||
unloadCell (cell);
|
||||
unloadCell(cell, navigatorUpdateGuard.get());
|
||||
}
|
||||
|
||||
mNavigator.setWorldspace(mWorld.getExterior(playerCellX, playerCellY)->getCell()->mCellId.mWorldspace);
|
||||
mNavigator.updateBounds(pos);
|
||||
mNavigator.setWorldspace(mWorld.getExterior(playerCellX, playerCellY)->getCell()->mCellId.mWorldspace,
|
||||
navigatorUpdateGuard.get());
|
||||
mNavigator.updateBounds(pos, navigatorUpdateGuard.get());
|
||||
|
||||
mCurrentGridCenter = osg::Vec2i(playerCellX, playerCellY);
|
||||
osg::Vec4i newGrid = gridCenterToBounds(mCurrentGridCenter);
|
||||
|
@ -602,10 +611,14 @@ namespace MWWorld
|
|||
if (!isCellInCollection(x, y, mActiveCells))
|
||||
{
|
||||
CellStore *cell = mWorld.getExterior(x, y);
|
||||
loadCell(cell, loadingListener, changeEvent, pos);
|
||||
loadCell(cell, loadingListener, changeEvent, pos, navigatorUpdateGuard.get());
|
||||
}
|
||||
}
|
||||
|
||||
mNavigator.update(pos, navigatorUpdateGuard.get());
|
||||
|
||||
navigatorUpdateGuard.reset();
|
||||
|
||||
CellStore* current = mWorld.getExterior(playerCellX, playerCellY);
|
||||
MWBase::Environment::get().getWindowManager()->changeCell(current);
|
||||
|
||||
|
@ -654,15 +667,21 @@ namespace MWWorld
|
|||
|
||||
MWWorld::Store<ESM::Cell>::iterator it = cells.extBegin();
|
||||
int i = 1;
|
||||
auto navigatorUpdateGuard = mNavigator.makeUpdateGuard();
|
||||
for (; it != cells.extEnd(); ++it)
|
||||
{
|
||||
loadingListener->setLabel("Testing exterior cells ("+std::to_string(i)+"/"+std::to_string(cells.getExtSize())+")...");
|
||||
|
||||
CellStore *cell = mWorld.getExterior(it->mData.mX, it->mData.mY);
|
||||
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace);
|
||||
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get());
|
||||
const osg::Vec3f position = osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits;
|
||||
mNavigator.updateBounds(position);
|
||||
loadCell(cell, nullptr, false, position);
|
||||
mNavigator.updateBounds(position, navigatorUpdateGuard.get());
|
||||
loadCell(cell, nullptr, false, position, navigatorUpdateGuard.get());
|
||||
|
||||
mNavigator.update(position, navigatorUpdateGuard.get());
|
||||
navigatorUpdateGuard.reset();
|
||||
mNavigator.wait(DetourNavigator::WaitConditionType::requiredTilesPresent, nullptr);
|
||||
navigatorUpdateGuard = mNavigator.makeUpdateGuard();
|
||||
|
||||
auto iter = mActiveCells.begin();
|
||||
while (iter != mActiveCells.end())
|
||||
|
@ -670,7 +689,7 @@ namespace MWWorld
|
|||
if (it->isExterior() && it->mData.mX == (*iter)->getCell()->getGridX() &&
|
||||
it->mData.mY == (*iter)->getCell()->getGridY())
|
||||
{
|
||||
unloadCell(*iter);
|
||||
unloadCell(*iter, navigatorUpdateGuard.get());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -702,16 +721,22 @@ namespace MWWorld
|
|||
|
||||
int i = 1;
|
||||
MWWorld::Store<ESM::Cell>::iterator it = cells.intBegin();
|
||||
auto navigatorUpdateGuard = mNavigator.makeUpdateGuard();
|
||||
for (; it != cells.intEnd(); ++it)
|
||||
{
|
||||
loadingListener->setLabel("Testing interior cells ("+std::to_string(i)+"/"+std::to_string(cells.getIntSize())+")...");
|
||||
|
||||
CellStore *cell = mWorld.getInterior(it->mName);
|
||||
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace);
|
||||
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get());
|
||||
ESM::Position position;
|
||||
mWorld.findInteriorPosition(it->mName, position);
|
||||
mNavigator.updateBounds(position.asVec3());
|
||||
loadCell(cell, nullptr, false, position.asVec3());
|
||||
mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get());
|
||||
loadCell(cell, nullptr, false, position.asVec3(), navigatorUpdateGuard.get());
|
||||
|
||||
mNavigator.update(position.asVec3(), navigatorUpdateGuard.get());
|
||||
navigatorUpdateGuard.reset();
|
||||
mNavigator.wait(DetourNavigator::WaitConditionType::requiredTilesPresent, nullptr);
|
||||
navigatorUpdateGuard = mNavigator.makeUpdateGuard();
|
||||
|
||||
auto iter = mActiveCells.begin();
|
||||
while (iter != mActiveCells.end())
|
||||
|
@ -720,7 +745,7 @@ namespace MWWorld
|
|||
|
||||
if (it->mName == (*iter)->getCell()->mName)
|
||||
{
|
||||
unloadCell(*iter);
|
||||
unloadCell(*iter, navigatorUpdateGuard.get());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -839,22 +864,26 @@ namespace MWWorld
|
|||
|
||||
Log(Debug::Info) << "Changing to interior";
|
||||
|
||||
auto navigatorUpdateGuard = mNavigator.makeUpdateGuard();
|
||||
|
||||
// unload
|
||||
for (auto iter = mActiveCells.begin(); iter!=mActiveCells.end(); )
|
||||
{
|
||||
auto* cellToUnload = *iter++;
|
||||
unloadCell(cellToUnload);
|
||||
unloadCell(cellToUnload, navigatorUpdateGuard.get());
|
||||
}
|
||||
assert(mActiveCells.empty());
|
||||
|
||||
loadingListener->setProgressRange(cell->count());
|
||||
|
||||
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace);
|
||||
mNavigator.updateBounds(position.asVec3());
|
||||
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get());
|
||||
mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get());
|
||||
|
||||
// Load cell.
|
||||
mPagedRefs.clear();
|
||||
loadCell(cell, loadingListener, changeEvent, position.asVec3());
|
||||
loadCell(cell, loadingListener, changeEvent, position.asVec3(), navigatorUpdateGuard.get());
|
||||
|
||||
navigatorUpdateGuard.reset();
|
||||
|
||||
changePlayerCell(cell, position, adjustPlayerPos);
|
||||
|
||||
|
@ -905,12 +934,13 @@ namespace MWWorld
|
|||
mCellChanged = false;
|
||||
}
|
||||
|
||||
void Scene::insertCell (CellStore &cell, Loading::Listener* loadingListener)
|
||||
void Scene::insertCell(CellStore &cell, Loading::Listener* loadingListener,
|
||||
const DetourNavigator::UpdateGuard* navigatorUpdateGuard)
|
||||
{
|
||||
InsertVisitor insertVisitor(cell, loadingListener);
|
||||
cell.forEach (insertVisitor);
|
||||
insertVisitor.insert([&] (const MWWorld::Ptr& ptr) { addObject(ptr, mWorld, mPagedRefs, *mPhysics, mRendering); });
|
||||
insertVisitor.insert([&] (const MWWorld::Ptr& ptr) { addObject(ptr, mWorld, *mPhysics, mNavigator); });
|
||||
insertVisitor.insert([&] (const MWWorld::Ptr& ptr) { addObject(ptr, mWorld, *mPhysics, mNavigator, navigatorUpdateGuard); });
|
||||
}
|
||||
|
||||
void Scene::addObjectToScene (const Ptr& ptr)
|
||||
|
@ -939,7 +969,7 @@ namespace MWWorld
|
|||
if (const auto object = mPhysics->getObject(ptr))
|
||||
{
|
||||
if (object->getShapeInstance()->mVisualCollisionType == Resource::VisualCollisionType::None)
|
||||
mNavigator.removeObject(DetourNavigator::ObjectId(object));
|
||||
mNavigator.removeObject(DetourNavigator::ObjectId(object), nullptr);
|
||||
}
|
||||
else if (mPhysics->getActor(ptr))
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace Loading
|
|||
namespace DetourNavigator
|
||||
{
|
||||
struct Navigator;
|
||||
class UpdateGuard;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
|
@ -110,7 +111,9 @@ namespace MWWorld
|
|||
|
||||
std::optional<ChangeCellGridRequest> mChangeCellGridRequest;
|
||||
|
||||
void insertCell(CellStore &cell, Loading::Listener* loadingListener);
|
||||
void insertCell(CellStore &cell, Loading::Listener* loadingListener,
|
||||
const DetourNavigator::UpdateGuard* navigatorUpdateGuard);
|
||||
|
||||
osg::Vec2i mCurrentGridCenter;
|
||||
|
||||
// Load and unload cells as necessary to create a cell grid with "X" and "Y" in the center
|
||||
|
@ -128,8 +131,9 @@ namespace MWWorld
|
|||
osg::Vec4i gridCenterToBounds(const osg::Vec2i ¢erCell) const;
|
||||
osg::Vec2i getNewGridCenter(const osg::Vec3f &pos, const osg::Vec2i *currentGridCenter = nullptr) const;
|
||||
|
||||
void unloadCell(CellStore* cell);
|
||||
void loadCell(CellStore *cell, Loading::Listener* loadingListener, bool respawn, const osg::Vec3f& position);
|
||||
void unloadCell(CellStore* cell, const DetourNavigator::UpdateGuard* navigatorUpdateGuard);
|
||||
void loadCell(CellStore *cell, Loading::Listener* loadingListener, bool respawn, const osg::Vec3f& position,
|
||||
const DetourNavigator::UpdateGuard* navigatorUpdateGuard);
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -43,8 +43,10 @@
|
|||
#include <components/detournavigator/settings.hpp>
|
||||
#include <components/detournavigator/agentbounds.hpp>
|
||||
#include <components/detournavigator/stats.hpp>
|
||||
#include <components/detournavigator/navigatorimpl.hpp>
|
||||
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
|
@ -103,21 +105,21 @@ namespace MWWorld
|
|||
mLoaders.emplace(std::move(extension), &loader);
|
||||
}
|
||||
|
||||
void load(const boost::filesystem::path& filepath, int& index, Loading::Listener* listener) override
|
||||
void load(const std::filesystem::path& filepath, int& index, Loading::Listener* listener) override
|
||||
{
|
||||
const auto it = mLoaders.find(Misc::StringUtils::lowerCase(filepath.extension().string()));
|
||||
const auto it = mLoaders.find(Misc::StringUtils::lowerCase( Files::pathToUnicodeString(filepath.extension())));
|
||||
if (it != mLoaders.end())
|
||||
{
|
||||
const std::string filename = filepath.filename().string();
|
||||
const auto filename = filepath.filename();
|
||||
Log(Debug::Info) << "Loading content file " << filename;
|
||||
if (listener != nullptr)
|
||||
listener->setLabel(MyGUI::TextIterator::toTagsString(filename));
|
||||
listener->setLabel(MyGUI::TextIterator::toTagsString(Files::pathToUnicodeString(filename)));
|
||||
it->second->load(filepath, index, listener);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg("Cannot load file: ");
|
||||
msg += filepath.string();
|
||||
msg += Files::pathToUnicodeString(filepath);
|
||||
throw std::runtime_error(msg.c_str());
|
||||
}
|
||||
}
|
||||
|
@ -130,9 +132,9 @@ namespace MWWorld
|
|||
{
|
||||
ESMStore& mStore;
|
||||
OMWScriptsLoader(ESMStore& store) : mStore(store) {}
|
||||
void load(const boost::filesystem::path& filepath, int& /*index*/, Loading::Listener* /*listener*/) override
|
||||
void load(const std::filesystem::path& filepath, int& /*index*/, Loading::Listener* /*listener*/) override
|
||||
{
|
||||
mStore.addOMWScripts(filepath.string());
|
||||
mStore.addOMWScripts(filepath);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -157,7 +159,7 @@ namespace MWWorld
|
|||
const std::vector<std::string>& groundcoverFiles,
|
||||
ToUTF8::Utf8Encoder* encoder, int activationDistanceOverride,
|
||||
const std::string& startCell, const std::string& startupScript,
|
||||
const std::string& resourcePath, const std::string& userDataPath)
|
||||
const std::filesystem::path& resourcePath, const std::filesystem::path& userDataPath)
|
||||
: mResourceSystem(resourceSystem), mLocalScripts(mStore),
|
||||
mCells(mStore, mReaders), mSky(true),
|
||||
mGodMode(false), mScriptsEnabled(true), mDiscardMovements(true), mContentFiles (contentFiles),
|
||||
|
@ -1543,28 +1545,32 @@ namespace MWWorld
|
|||
|
||||
void World::updateNavigator()
|
||||
{
|
||||
auto navigatorUpdateGuard = mNavigator->makeUpdateGuard();
|
||||
|
||||
mPhysics->forEachAnimatedObject([&] (const auto& pair)
|
||||
{
|
||||
const auto [object, changed] = pair;
|
||||
if (changed)
|
||||
updateNavigatorObject(*object);
|
||||
updateNavigatorObject(*object, navigatorUpdateGuard.get());
|
||||
});
|
||||
|
||||
for (const auto& door : mDoorStates)
|
||||
if (const auto object = mPhysics->getObject(door.first))
|
||||
updateNavigatorObject(*object);
|
||||
updateNavigatorObject(*object, navigatorUpdateGuard.get());
|
||||
|
||||
mNavigator->update(getPlayerPtr().getRefData().getPosition().asVec3());
|
||||
mNavigator->update(getPlayerPtr().getRefData().getPosition().asVec3(), navigatorUpdateGuard.get());
|
||||
}
|
||||
|
||||
void World::updateNavigatorObject(const MWPhysics::Object& object)
|
||||
void World::updateNavigatorObject(const MWPhysics::Object& object,
|
||||
const DetourNavigator::UpdateGuard* navigatorUpdateGuard)
|
||||
{
|
||||
if (object.getShapeInstance()->mVisualCollisionType != Resource::VisualCollisionType::None)
|
||||
return;
|
||||
const MWWorld::Ptr ptr = object.getPtr();
|
||||
const DetourNavigator::ObjectShapes shapes(object.getShapeInstance(),
|
||||
DetourNavigator::ObjectTransform {ptr.getRefData().getPosition(), ptr.getCellRef().getScale()});
|
||||
mNavigator->updateObject(DetourNavigator::ObjectId(&object), shapes, object.getTransform());
|
||||
mNavigator->updateObject(DetourNavigator::ObjectId(&object), shapes, object.getTransform(),
|
||||
navigatorUpdateGuard);
|
||||
}
|
||||
|
||||
const MWPhysics::RayCastingInterface* World::getRayCasting() const
|
||||
|
@ -1856,8 +1862,8 @@ namespace MWWorld
|
|||
|
||||
if (mWorldScene->hasCellLoaded())
|
||||
{
|
||||
mNavigator->wait(*MWBase::Environment::get().getWindowManager()->getLoadingScreen(),
|
||||
DetourNavigator::WaitConditionType::requiredTilesPresent);
|
||||
mNavigator->wait(DetourNavigator::WaitConditionType::requiredTilesPresent,
|
||||
MWBase::Environment::get().getWindowManager()->getLoadingScreen());
|
||||
mWorldScene->resetCellLoaded();
|
||||
}
|
||||
}
|
||||
|
@ -2960,8 +2966,8 @@ namespace MWWorld
|
|||
int idx = 0;
|
||||
for (const std::string &file : content)
|
||||
{
|
||||
boost::filesystem::path filename(file);
|
||||
const Files::MultiDirCollection& col = fileCollections.getCollection(filename.extension().string());
|
||||
const auto filename = Files::pathFromUnicodeString( file);
|
||||
const Files::MultiDirCollection& col = fileCollections.getCollection(Files::pathToUnicodeString(filename.extension()));
|
||||
if (col.doesExist(file))
|
||||
{
|
||||
gameContentLoader.load(col.getPath(file), idx, listener);
|
||||
|
@ -3691,9 +3697,9 @@ namespace MWWorld
|
|||
return mPhysics->getHalfExtents(object);
|
||||
}
|
||||
|
||||
std::string World::exportSceneGraph(const Ptr &ptr)
|
||||
std::filesystem::path World::exportSceneGraph(const Ptr& ptr)
|
||||
{
|
||||
std::string file = mUserDataPath + "/openmw.osgt";
|
||||
auto file = mUserDataPath / "openmw.osgt";
|
||||
if (!ptr.isEmpty())
|
||||
{
|
||||
mRendering->pagingBlacklistObject(mStore.find(ptr.getCellRef().getRefId()), ptr);
|
||||
|
|
|
@ -109,7 +109,7 @@ namespace MWWorld
|
|||
bool mDiscardMovements;
|
||||
std::vector<std::string> mContentFiles;
|
||||
|
||||
std::string mUserDataPath;
|
||||
std::filesystem::path mUserDataPath;
|
||||
|
||||
osg::Vec3f mDefaultHalfExtents;
|
||||
DetourNavigator::CollisionShapeType mDefaultActorCollisionShapeType;
|
||||
|
@ -166,7 +166,8 @@ namespace MWWorld
|
|||
|
||||
void updateNavigator();
|
||||
|
||||
void updateNavigatorObject(const MWPhysics::Object& object);
|
||||
void updateNavigatorObject(const MWPhysics::Object& object,
|
||||
const DetourNavigator::UpdateGuard* navigatorUpdateGuard = nullptr);
|
||||
|
||||
void ensureNeededRecords();
|
||||
|
||||
|
@ -202,7 +203,7 @@ namespace MWWorld
|
|||
const std::vector<std::string>& groundcoverFiles,
|
||||
ToUTF8::Utf8Encoder* encoder, int activationDistanceOverride,
|
||||
const std::string& startCell, const std::string& startupScript,
|
||||
const std::string& resourcePath, const std::string& userDataPath);
|
||||
const std::filesystem::path& resourcePath, const std::filesystem::path& userDataPath);
|
||||
|
||||
virtual ~World();
|
||||
|
||||
|
@ -729,7 +730,7 @@ namespace MWWorld
|
|||
|
||||
/// Export scene graph to a file and return the filename.
|
||||
/// \param ptr object to export scene graph for (if empty, export entire scene graph)
|
||||
std::string exportSceneGraph(const MWWorld::Ptr& ptr) override;
|
||||
std::filesystem::path exportSceneGraph(const MWWorld::Ptr& ptr) override;
|
||||
|
||||
/// Preload VFX associated with this effect list
|
||||
void preloadEffects(const ESM::EffectList* effectList) override;
|
||||
|
|
|
@ -75,6 +75,7 @@ file(GLOB UNITTEST_SRC_FILES
|
|||
esmloader/record.cpp
|
||||
|
||||
files/hash.cpp
|
||||
files/conversion_tests.cpp
|
||||
|
||||
toutf8/toutf8.cpp
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace
|
|||
void addHeightFieldPlane(TileCachedRecastMeshManager& recastMeshManager, const osg::Vec2i cellPosition = osg::Vec2i(0, 0))
|
||||
{
|
||||
const int cellSize = 8192;
|
||||
recastMeshManager.addHeightfield(cellPosition, cellSize, HeightfieldPlane {0});
|
||||
recastMeshManager.addHeightfield(cellPosition, cellSize, HeightfieldPlane {0}, nullptr);
|
||||
}
|
||||
|
||||
void addObject(const btBoxShape& shape, TileCachedRecastMeshManager& recastMeshManager)
|
||||
|
@ -42,7 +42,7 @@ namespace
|
|||
osg::ref_ptr<Resource::BulletShapeInstance>(new Resource::BulletShapeInstance(bulletShape)),
|
||||
shape, objectTransform
|
||||
);
|
||||
recastMeshManager.addObject(id, collisionShape, btTransform::getIdentity(), AreaType_ground);
|
||||
recastMeshManager.addObject(id, collisionShape, btTransform::getIdentity(), AreaType_ground, nullptr);
|
||||
}
|
||||
|
||||
struct DetourNavigatorAsyncNavMeshUpdaterTest : Test
|
||||
|
@ -60,43 +60,43 @@ namespace
|
|||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, for_all_jobs_done_when_empty_wait_should_terminate)
|
||||
{
|
||||
AsyncNavMeshUpdater updater {mSettings, mRecastMeshManager, mOffMeshConnectionsManager, nullptr};
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, for_required_tiles_present_when_empty_wait_should_terminate)
|
||||
{
|
||||
AsyncNavMeshUpdater updater(mSettings, mRecastMeshManager, mOffMeshConnectionsManager, nullptr);
|
||||
updater.wait(mListener, WaitConditionType::requiredTilesPresent);
|
||||
updater.wait(WaitConditionType::requiredTilesPresent, &mListener);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, post_should_generate_navmesh_tile)
|
||||
{
|
||||
mRecastMeshManager.setWorldspace(mWorldspace);
|
||||
mRecastMeshManager.setWorldspace(mWorldspace, nullptr);
|
||||
addHeightFieldPlane(mRecastMeshManager);
|
||||
AsyncNavMeshUpdater updater(mSettings, mRecastMeshManager, mOffMeshConnectionsManager, nullptr);
|
||||
const auto navMeshCacheItem = std::make_shared<GuardedNavMeshCacheItem>(makeEmptyNavMesh(mSettings), 1);
|
||||
const std::map<TilePosition, ChangeType> changedTiles {{TilePosition {0, 0}, ChangeType::add}};
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
EXPECT_NE(navMeshCacheItem->lockConst()->getImpl().getTileRefAt(0, 0, 0), 0u);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, repeated_post_should_lead_to_cache_hit)
|
||||
{
|
||||
mRecastMeshManager.setWorldspace(mWorldspace);
|
||||
mRecastMeshManager.setWorldspace(mWorldspace, nullptr);
|
||||
addHeightFieldPlane(mRecastMeshManager);
|
||||
AsyncNavMeshUpdater updater(mSettings, mRecastMeshManager, mOffMeshConnectionsManager, nullptr);
|
||||
const auto navMeshCacheItem = std::make_shared<GuardedNavMeshCacheItem>(makeEmptyNavMesh(mSettings), 1);
|
||||
const std::map<TilePosition, ChangeType> changedTiles {{TilePosition {0, 0}, ChangeType::add}};
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
{
|
||||
const auto stats = updater.getStats();
|
||||
ASSERT_EQ(stats.mCache.mGetCount, 1);
|
||||
ASSERT_EQ(stats.mCache.mHitCount, 0);
|
||||
}
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
{
|
||||
const auto stats = updater.getStats();
|
||||
EXPECT_EQ(stats.mCache.mGetCount, 2);
|
||||
|
@ -106,20 +106,20 @@ namespace
|
|||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, post_for_update_change_type_should_not_update_cache)
|
||||
{
|
||||
mRecastMeshManager.setWorldspace(mWorldspace);
|
||||
mRecastMeshManager.setWorldspace(mWorldspace, nullptr);
|
||||
addHeightFieldPlane(mRecastMeshManager);
|
||||
AsyncNavMeshUpdater updater(mSettings, mRecastMeshManager, mOffMeshConnectionsManager, nullptr);
|
||||
const auto navMeshCacheItem = std::make_shared<GuardedNavMeshCacheItem>(makeEmptyNavMesh(mSettings), 1);
|
||||
const std::map<TilePosition, ChangeType> changedTiles {{TilePosition {0, 0}, ChangeType::update}};
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
{
|
||||
const auto stats = updater.getStats();
|
||||
ASSERT_EQ(stats.mCache.mGetCount, 1);
|
||||
ASSERT_EQ(stats.mCache.mHitCount, 0);
|
||||
}
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
{
|
||||
const auto stats = updater.getStats();
|
||||
EXPECT_EQ(stats.mCache.mGetCount, 2);
|
||||
|
@ -129,7 +129,7 @@ namespace
|
|||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, post_should_write_generated_tile_to_db)
|
||||
{
|
||||
mRecastMeshManager.setWorldspace(mWorldspace);
|
||||
mRecastMeshManager.setWorldspace(mWorldspace, nullptr);
|
||||
addHeightFieldPlane(mRecastMeshManager);
|
||||
addObject(mBox, mRecastMeshManager);
|
||||
auto db = std::make_unique<NavMeshDb>(":memory:", std::numeric_limits<std::uint64_t>::max());
|
||||
|
@ -139,7 +139,7 @@ namespace
|
|||
const TilePosition tilePosition {0, 0};
|
||||
const std::map<TilePosition, ChangeType> changedTiles {{tilePosition, ChangeType::add}};
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
updater.stop();
|
||||
const auto recastMesh = mRecastMeshManager.getMesh(mWorldspace, tilePosition);
|
||||
ASSERT_NE(recastMesh, nullptr);
|
||||
|
@ -155,7 +155,7 @@ namespace
|
|||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, post_when_writing_to_db_disabled_should_not_write_tiles)
|
||||
{
|
||||
mRecastMeshManager.setWorldspace(mWorldspace);
|
||||
mRecastMeshManager.setWorldspace(mWorldspace, nullptr);
|
||||
addHeightFieldPlane(mRecastMeshManager);
|
||||
addObject(mBox, mRecastMeshManager);
|
||||
auto db = std::make_unique<NavMeshDb>(":memory:", std::numeric_limits<std::uint64_t>::max());
|
||||
|
@ -166,7 +166,7 @@ namespace
|
|||
const TilePosition tilePosition {0, 0};
|
||||
const std::map<TilePosition, ChangeType> changedTiles {{tilePosition, ChangeType::add}};
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
updater.stop();
|
||||
const auto recastMesh = mRecastMeshManager.getMesh(mWorldspace, tilePosition);
|
||||
ASSERT_NE(recastMesh, nullptr);
|
||||
|
@ -180,7 +180,7 @@ namespace
|
|||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, post_when_writing_to_db_disabled_should_not_write_shapes)
|
||||
{
|
||||
mRecastMeshManager.setWorldspace(mWorldspace);
|
||||
mRecastMeshManager.setWorldspace(mWorldspace, nullptr);
|
||||
addHeightFieldPlane(mRecastMeshManager);
|
||||
addObject(mBox, mRecastMeshManager);
|
||||
auto db = std::make_unique<NavMeshDb>(":memory:", std::numeric_limits<std::uint64_t>::max());
|
||||
|
@ -191,7 +191,7 @@ namespace
|
|||
const TilePosition tilePosition {0, 0};
|
||||
const std::map<TilePosition, ChangeType> changedTiles {{tilePosition, ChangeType::add}};
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
updater.stop();
|
||||
const auto recastMesh = mRecastMeshManager.getMesh(mWorldspace, tilePosition);
|
||||
ASSERT_NE(recastMesh, nullptr);
|
||||
|
@ -202,7 +202,7 @@ namespace
|
|||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, post_should_read_from_db_on_cache_miss)
|
||||
{
|
||||
mRecastMeshManager.setWorldspace(mWorldspace);
|
||||
mRecastMeshManager.setWorldspace(mWorldspace, nullptr);
|
||||
addHeightFieldPlane(mRecastMeshManager);
|
||||
mSettings.mMaxNavMeshTilesCacheSize = 0;
|
||||
AsyncNavMeshUpdater updater(mSettings, mRecastMeshManager, mOffMeshConnectionsManager,
|
||||
|
@ -210,7 +210,7 @@ namespace
|
|||
const auto navMeshCacheItem = std::make_shared<GuardedNavMeshCacheItem>(makeEmptyNavMesh(mSettings), 1);
|
||||
const std::map<TilePosition, ChangeType> changedTiles {{TilePosition {0, 0}, ChangeType::add}};
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
{
|
||||
const auto stats = updater.getStats();
|
||||
ASSERT_EQ(stats.mCache.mGetCount, 1);
|
||||
|
@ -220,7 +220,7 @@ namespace
|
|||
ASSERT_EQ(stats.mDbGetTileHits, 0);
|
||||
}
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
{
|
||||
const auto stats = updater.getStats();
|
||||
EXPECT_EQ(stats.mCache.mGetCount, 2);
|
||||
|
@ -233,24 +233,24 @@ namespace
|
|||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, on_changing_player_tile_post_should_remove_tiles_out_of_range)
|
||||
{
|
||||
mRecastMeshManager.setWorldspace(mWorldspace);
|
||||
mRecastMeshManager.setWorldspace(mWorldspace, nullptr);
|
||||
addHeightFieldPlane(mRecastMeshManager);
|
||||
AsyncNavMeshUpdater updater(mSettings, mRecastMeshManager, mOffMeshConnectionsManager, nullptr);
|
||||
const auto navMeshCacheItem = std::make_shared<GuardedNavMeshCacheItem>(makeEmptyNavMesh(mSettings), 1);
|
||||
const std::map<TilePosition, ChangeType> changedTilesAdd {{TilePosition {0, 0}, ChangeType::add}};
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTilesAdd);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
ASSERT_NE(navMeshCacheItem->lockConst()->getImpl().getTileRefAt(0, 0, 0), 0u);
|
||||
const std::map<TilePosition, ChangeType> changedTilesRemove {{TilePosition {0, 0}, ChangeType::remove}};
|
||||
const TilePosition playerTile(100, 100);
|
||||
updater.post(mAgentBounds, navMeshCacheItem, playerTile, mWorldspace, changedTilesRemove);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
EXPECT_EQ(navMeshCacheItem->lockConst()->getImpl().getTileRefAt(0, 0, 0), 0u);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, should_stop_writing_to_db_when_size_limit_is_reached)
|
||||
{
|
||||
mRecastMeshManager.setWorldspace(mWorldspace);
|
||||
mRecastMeshManager.setWorldspace(mWorldspace, nullptr);
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
addHeightFieldPlane(mRecastMeshManager, osg::Vec2i(x, y));
|
||||
|
@ -264,7 +264,7 @@ namespace
|
|||
for (int y = -5; y <= 5; ++y)
|
||||
changedTiles.emplace(TilePosition {x, y}, ChangeType::add);
|
||||
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
|
||||
updater.wait(mListener, WaitConditionType::allJobsDone);
|
||||
updater.wait(WaitConditionType::allJobsDone, &mListener);
|
||||
updater.stop();
|
||||
const std::set<TilePosition> present {
|
||||
TilePosition(-2, 0),
|
||||
|
|
|
@ -155,9 +155,11 @@ namespace
|
|||
const int cellSize = mHeightfieldTileSize * (surface.mSize - 1);
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::requiredTilesPresent);
|
||||
auto updateGuard = mNavigator->makeUpdateGuard();
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, updateGuard.get());
|
||||
mNavigator->update(mPlayerPosition, updateGuard.get());
|
||||
updateGuard.reset();
|
||||
mNavigator->wait(WaitConditionType::requiredTilesPresent, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::Success);
|
||||
|
@ -207,9 +209,9 @@ namespace
|
|||
compound.shape().addChildShape(btTransform(btMatrix3x3::getIdentity(), btVector3(0, 0, 0)), new btBoxShape(btVector3(20, 20, 100)));
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::Success);
|
||||
|
@ -239,9 +241,12 @@ namespace
|
|||
Vec3fEq(460, 56.66666412353515625, 1.99998295307159423828125)
|
||||
)) << mPath;
|
||||
|
||||
mNavigator->addObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
{
|
||||
auto updateGuard = mNavigator->makeUpdateGuard();
|
||||
mNavigator->addObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform, updateGuard.get());
|
||||
mNavigator->update(mPlayerPosition, updateGuard.get());
|
||||
}
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mPath.clear();
|
||||
mOut = std::back_inserter(mPath);
|
||||
|
@ -291,10 +296,10 @@ namespace
|
|||
compound.shape().addChildShape(btTransform(btMatrix3x3::getIdentity(), btVector3(0, 0, 0)), new btBoxShape(btVector3(20, 20, 100)));
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->addObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->addObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::Success);
|
||||
|
@ -327,9 +332,9 @@ namespace
|
|||
|
||||
compound.shape().updateChildTransform(0, btTransform(btMatrix3x3::getIdentity(), btVector3(1000, 0, 0)));
|
||||
|
||||
mNavigator->updateObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->updateObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mPath.clear();
|
||||
mOut = std::back_inserter(mPath);
|
||||
|
@ -385,10 +390,10 @@ namespace
|
|||
heightfield2.shape().setLocalScaling(btVector3(128, 128, 1));
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addObject(ObjectId(&heightfield1.shape()), ObjectShapes(heightfield1.instance(), mObjectTransform), mTransform);
|
||||
mNavigator->addObject(ObjectId(&heightfield2.shape()), ObjectShapes(heightfield2.instance(), mObjectTransform), mTransform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addObject(ObjectId(&heightfield1.shape()), ObjectShapes(heightfield1.instance(), mObjectTransform), mTransform, nullptr);
|
||||
mNavigator->addObject(ObjectId(&heightfield2.shape()), ObjectShapes(heightfield2.instance(), mObjectTransform), mTransform, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::Success);
|
||||
|
@ -442,15 +447,15 @@ namespace
|
|||
const int cellSize2 = mHeightfieldTileSize * (surface2.mSize - 1);
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize1, surface1);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize1, surface1, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
const Version version = mNavigator->getNavMesh(mAgentBounds)->lockConst()->getVersion();
|
||||
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize2, surface2);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize2, surface2, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(mNavigator->getNavMesh(mAgentBounds)->lockConst()->getVersion(), version);
|
||||
}
|
||||
|
@ -484,9 +489,9 @@ namespace
|
|||
osg::ref_ptr<const Resource::BulletShapeInstance> instance(new Resource::BulletShapeInstance(bulletShape));
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addObject(ObjectId(instance->mCollisionShape.get()), ObjectShapes(instance, mObjectTransform), mTransform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addObject(ObjectId(instance->mCollisionShape.get()), ObjectShapes(instance, mObjectTransform), mTransform, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::Success);
|
||||
|
@ -531,10 +536,10 @@ namespace
|
|||
const int cellSize = mHeightfieldTileSize * (surface.mSize - 1);
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addWater(mCellPosition, cellSize, 300);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addWater(mCellPosition, cellSize, 300, nullptr);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mStart.x() = 256;
|
||||
mStart.z() = 300;
|
||||
|
@ -579,10 +584,10 @@ namespace
|
|||
const int cellSize = mHeightfieldTileSize * (surface.mSize - 1);
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addWater(mCellPosition, cellSize, -25);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addWater(mCellPosition, cellSize, -25, nullptr);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mStart.x() = 256;
|
||||
mEnd.x() = 256;
|
||||
|
@ -625,10 +630,10 @@ namespace
|
|||
const int cellSize = mHeightfieldTileSize * (surface.mSize - 1);
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->addWater(mCellPosition, std::numeric_limits<int>::max(), -25);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->addWater(mCellPosition, std::numeric_limits<int>::max(), -25, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mStart.x() = 256;
|
||||
mEnd.x() = 256;
|
||||
|
@ -671,10 +676,10 @@ namespace
|
|||
const int cellSize = mHeightfieldTileSize * (surface.mSize - 1);
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addWater(mCellPosition, cellSize, -25);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addWater(mCellPosition, cellSize, -25, nullptr);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mStart.x() = 256;
|
||||
mEnd.x() = 256;
|
||||
|
@ -715,17 +720,17 @@ namespace
|
|||
heightfield.shape().setLocalScaling(btVector3(128, 128, 1));
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addObject(ObjectId(&heightfield.shape()), ObjectShapes(heightfield.instance(), mObjectTransform), mTransform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addObject(ObjectId(&heightfield.shape()), ObjectShapes(heightfield.instance(), mObjectTransform), mTransform, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mNavigator->removeObject(ObjectId(&heightfield.shape()));
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->removeObject(ObjectId(&heightfield.shape()), nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mNavigator->addObject(ObjectId(&heightfield.shape()), ObjectShapes(heightfield.instance(), mObjectTransform), mTransform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addObject(ObjectId(&heightfield.shape()), ObjectShapes(heightfield.instance(), mObjectTransform), mTransform, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::Success);
|
||||
|
@ -769,17 +774,17 @@ namespace
|
|||
const int cellSize = mHeightfieldTileSize * (surface.mSize - 1);
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mNavigator->removeHeightfield(mCellPosition);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->removeHeightfield(mCellPosition, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::Success);
|
||||
|
@ -824,9 +829,9 @@ namespace
|
|||
const int cellSize = mHeightfieldTileSize * (surface.mSize - 1);
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
Misc::Rng::init(42);
|
||||
|
||||
|
@ -862,12 +867,12 @@ namespace
|
|||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
|
||||
for (std::size_t i = 0; i < boxes.size(); ++i)
|
||||
{
|
||||
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(shift.x() + i * 10, shift.y() + i * 10, i * 10));
|
||||
mNavigator->addObject(ObjectId(&boxes[i].shape()), ObjectShapes(boxes[i].instance(), mObjectTransform), transform);
|
||||
mNavigator->addObject(ObjectId(&boxes[i].shape()), ObjectShapes(boxes[i].instance(), mObjectTransform), transform, nullptr);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||
|
@ -875,11 +880,11 @@ namespace
|
|||
for (std::size_t i = 0; i < boxes.size(); ++i)
|
||||
{
|
||||
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(shift.x() + i * 10 + 1, shift.y() + i * 10 + 1, i * 10 + 1));
|
||||
mNavigator->updateObject(ObjectId(&boxes[i].shape()), ObjectShapes(boxes[i].instance(), mObjectTransform), transform);
|
||||
mNavigator->updateObject(ObjectId(&boxes[i].shape()), ObjectShapes(boxes[i].instance(), mObjectTransform), transform, nullptr);
|
||||
}
|
||||
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::Success);
|
||||
|
@ -921,27 +926,27 @@ namespace
|
|||
for (std::size_t i = 0; i < shapes.size(); ++i)
|
||||
{
|
||||
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(i * 32, i * 32, i * 32));
|
||||
mNavigator->addObject(ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform);
|
||||
mNavigator->addObject(ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform, nullptr);
|
||||
}
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
const auto start = std::chrono::steady_clock::now();
|
||||
for (std::size_t i = 0; i < shapes.size(); ++i)
|
||||
{
|
||||
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(i * 32 + 1, i * 32 + 1, i * 32 + 1));
|
||||
mNavigator->updateObject(ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform);
|
||||
mNavigator->updateObject(ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform, nullptr);
|
||||
}
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
for (std::size_t i = 0; i < shapes.size(); ++i)
|
||||
{
|
||||
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(i * 32 + 2, i * 32 + 2, i * 32 + 2));
|
||||
mNavigator->updateObject(ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform);
|
||||
mNavigator->updateObject(ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform, nullptr);
|
||||
}
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
const auto duration = std::chrono::steady_clock::now() - start;
|
||||
|
||||
|
@ -962,9 +967,9 @@ namespace
|
|||
const int cellSize = mHeightfieldTileSize * (surface.mSize - 1);
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
const osg::Vec3f start(57, 460, 1);
|
||||
const osg::Vec3f end(460, 57, 1);
|
||||
|
@ -991,14 +996,14 @@ namespace
|
|||
CollisionShapeInstance borderBox(std::make_unique<btBoxShape>(btVector3(50, 50, 50)));
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->addObject(ObjectId(&oscillatingBox.shape()), ObjectShapes(oscillatingBox.instance(), mObjectTransform),
|
||||
btTransform(btMatrix3x3::getIdentity(), oscillatingBoxShapePosition));
|
||||
btTransform(btMatrix3x3::getIdentity(), oscillatingBoxShapePosition), nullptr);
|
||||
// add this box to make navmesh bound box independent from oscillatingBoxShape rotations
|
||||
mNavigator->addObject(ObjectId(&borderBox.shape()), ObjectShapes(borderBox.instance(), mObjectTransform),
|
||||
btTransform(btMatrix3x3::getIdentity(), oscillatingBoxShapePosition + btVector3(0, 0, 200)));
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
btTransform(btMatrix3x3::getIdentity(), oscillatingBoxShapePosition + btVector3(0, 0, 200)), nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
const Version expectedVersion {1, 4};
|
||||
|
||||
|
@ -1010,9 +1015,9 @@ namespace
|
|||
{
|
||||
const btTransform transform(btQuaternion(btVector3(0, 0, 1), n * 2 * osg::PI / 10),
|
||||
oscillatingBoxShapePosition);
|
||||
mNavigator->updateObject(ObjectId(&oscillatingBox.shape()), ObjectShapes(oscillatingBox.instance(), mObjectTransform), transform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->updateObject(ObjectId(&oscillatingBox.shape()), ObjectShapes(oscillatingBox.instance(), mObjectTransform), transform, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
}
|
||||
|
||||
ASSERT_EQ(navMeshes.size(), 1);
|
||||
|
@ -1025,9 +1030,9 @@ namespace
|
|||
const int cellSize = mHeightfieldTileSize * 4;
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, plane);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::requiredTilesPresent);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, plane, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::requiredTilesPresent, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::Success);
|
||||
|
@ -1075,10 +1080,10 @@ namespace
|
|||
new btBoxShape(btVector3(200, 200, 1000)));
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->addObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->addObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(findPath(*mNavigator, mAgentBounds, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mEndTolerance, mOut),
|
||||
Status::PartialPath);
|
||||
|
@ -1114,10 +1119,10 @@ namespace
|
|||
new btBoxShape(btVector3(100, 100, 1000)));
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface);
|
||||
mNavigator->addObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addHeightfield(mCellPosition, cellSize, surface, nullptr);
|
||||
mNavigator->addObject(ObjectId(&compound.shape()), ObjectShapes(compound.instance(), mObjectTransform), mTransform, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
const float endTolerance = 1000.0f;
|
||||
|
||||
|
@ -1154,15 +1159,15 @@ namespace
|
|||
const float level2 = 2;
|
||||
|
||||
mNavigator->addAgent(mAgentBounds);
|
||||
mNavigator->addWater(mCellPosition, cellSize1, level1);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addWater(mCellPosition, cellSize1, level1, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
const Version version = mNavigator->getNavMesh(mAgentBounds)->lockConst()->getVersion();
|
||||
|
||||
mNavigator->addWater(mCellPosition, cellSize2, level2);
|
||||
mNavigator->update(mPlayerPosition);
|
||||
mNavigator->wait(mListener, WaitConditionType::allJobsDone);
|
||||
mNavigator->addWater(mCellPosition, cellSize2, level2, nullptr);
|
||||
mNavigator->update(mPlayerPosition, nullptr);
|
||||
mNavigator->wait(WaitConditionType::allJobsDone, &mListener);
|
||||
|
||||
EXPECT_EQ(mNavigator->getNavMesh(mAgentBounds)->lockConst()->getVersion(), version);
|
||||
}
|
||||
|
|
|
@ -43,20 +43,12 @@ namespace
|
|||
EXPECT_EQ(manager.getRevision(), 0);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, for_each_tile_position_for_empty_should_call_none)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
std::size_t calls = 0;
|
||||
manager.forEachTile([&] (const TilePosition&, const CachedRecastMeshManager&) { ++calls; });
|
||||
EXPECT_EQ(calls, 0);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_for_new_object_should_return_true)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
EXPECT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
EXPECT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_for_existing_object_should_return_false)
|
||||
|
@ -64,17 +56,17 @@ namespace
|
|||
TileCachedRecastMeshManager manager(mSettings);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
EXPECT_FALSE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_FALSE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_should_add_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
for (int x = -1; x < 1; ++x)
|
||||
for (int y = -1; y < 1; ++y)
|
||||
ASSERT_NE(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
|
||||
|
@ -88,9 +80,9 @@ namespace
|
|||
TileBounds bounds;
|
||||
bounds.mMin = osg::Vec2f(182, 182);
|
||||
bounds.mMax = osg::Vec2f(1000, 1000);
|
||||
manager.setBounds(bounds);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
EXPECT_THAT(manager.takeChangedTiles(), ElementsAre(std::pair(TilePosition(0, 0), ChangeType::add)));
|
||||
manager.setBounds(bounds, nullptr);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_THAT(manager.takeChangedTiles(nullptr), ElementsAre(std::pair(TilePosition(0, 0), ChangeType::add)));
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, update_object_for_changed_object_should_add_changed_tiles)
|
||||
|
@ -102,11 +94,11 @@ namespace
|
|||
TileBounds bounds;
|
||||
bounds.mMin = osg::Vec2f(-1000, -1000);
|
||||
bounds.mMax = osg::Vec2f(1000, 1000);
|
||||
manager.setBounds(bounds);
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground);
|
||||
manager.takeChangedTiles();
|
||||
EXPECT_TRUE(manager.updateObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
EXPECT_THAT(manager.takeChangedTiles(), ElementsAre(
|
||||
manager.setBounds(bounds, nullptr);
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
|
||||
manager.takeChangedTiles(nullptr);
|
||||
EXPECT_TRUE(manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
EXPECT_THAT(manager.takeChangedTiles(nullptr), ElementsAre(
|
||||
std::pair(TilePosition(-1, -1), ChangeType::add),
|
||||
std::pair(TilePosition(-1, 0), ChangeType::add),
|
||||
std::pair(TilePosition(0, -1), ChangeType::update),
|
||||
|
@ -121,10 +113,10 @@ namespace
|
|||
TileCachedRecastMeshManager manager(mSettings);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.takeChangedTiles();
|
||||
EXPECT_FALSE(manager.updateObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
EXPECT_THAT(manager.takeChangedTiles(), IsEmpty());
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
manager.takeChangedTiles(nullptr);
|
||||
EXPECT_FALSE(manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
EXPECT_THAT(manager.takeChangedTiles(nullptr), IsEmpty());
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_object_should_return_add_changed_tiles)
|
||||
|
@ -135,20 +127,20 @@ namespace
|
|||
TileBounds bounds;
|
||||
bounds.mMin = osg::Vec2f(182, 182);
|
||||
bounds.mMax = osg::Vec2f(1000, 1000);
|
||||
manager.setBounds(bounds);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.takeChangedTiles();
|
||||
manager.removeObject(ObjectId(&boxShape));
|
||||
EXPECT_THAT(manager.takeChangedTiles(), ElementsAre(std::pair(TilePosition(0, 0), ChangeType::remove)));
|
||||
manager.setBounds(bounds, nullptr);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
manager.takeChangedTiles(nullptr);
|
||||
manager.removeObject(ObjectId(&boxShape), nullptr);
|
||||
EXPECT_THAT(manager.takeChangedTiles(nullptr), ElementsAre(std::pair(TilePosition(0, 0), ChangeType::remove)));
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_after_add_object_should_return_recast_mesh_for_each_used_tile)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
||||
|
@ -158,10 +150,10 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_after_add_object_should_return_nullptr_for_unused_tile)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
|
||||
}
|
||||
|
||||
|
@ -171,20 +163,20 @@ namespace
|
|||
TileBounds bounds;
|
||||
bounds.mMin = osg::Vec2f(-1000, -1000);
|
||||
bounds.mMax = osg::Vec2f(1000, 1000);
|
||||
manager.setBounds(bounds);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setBounds(bounds, nullptr);
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(getTileSize(mSettings) / mSettings.mRecastScaleFactor, 0, 0));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(1, -1)), nullptr);
|
||||
|
||||
manager.updateObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
||||
|
@ -194,17 +186,17 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_moved_object_should_return_nullptr_for_unused_tile)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(getTileSize(mSettings) / mSettings.mRecastScaleFactor, 0, 0));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
||||
|
||||
manager.updateObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, -1)), nullptr);
|
||||
}
|
||||
|
@ -212,11 +204,11 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_removed_object_should_return_nullptr_for_all_previously_used_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.removeObject(ObjectId(&boxShape));
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
manager.removeObject(ObjectId(&boxShape), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
||||
|
@ -226,17 +218,17 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_not_changed_object_after_update_should_return_recast_mesh_for_same_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
|
||||
|
||||
manager.updateObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
||||
|
@ -249,7 +241,7 @@ namespace
|
|||
const auto initialRevision = manager.getRevision();
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_EQ(manager.getRevision(), initialRevision + 1);
|
||||
}
|
||||
|
||||
|
@ -258,9 +250,9 @@ namespace
|
|||
TileCachedRecastMeshManager manager(mSettings);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
const auto beforeAddRevision = manager.getRevision();
|
||||
EXPECT_FALSE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
EXPECT_FALSE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
EXPECT_EQ(manager.getRevision(), beforeAddRevision);
|
||||
}
|
||||
|
||||
|
@ -270,21 +262,21 @@ namespace
|
|||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(getTileSize(mSettings) / mSettings.mRecastScaleFactor, 0, 0));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
|
||||
const auto beforeUpdateRevision = manager.getRevision();
|
||||
manager.updateObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_EQ(manager.getRevision(), beforeUpdateRevision + 1);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_revision_after_update_not_changed_object_should_return_same_value)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
const auto beforeUpdateRevision = manager.getRevision();
|
||||
manager.updateObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_EQ(manager.getRevision(), beforeUpdateRevision);
|
||||
}
|
||||
|
||||
|
@ -293,9 +285,9 @@ namespace
|
|||
TileCachedRecastMeshManager manager(mSettings);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
const auto beforeRemoveRevision = manager.getRevision();
|
||||
manager.removeObject(ObjectId(&boxShape));
|
||||
manager.removeObject(ObjectId(&boxShape), nullptr);
|
||||
EXPECT_EQ(manager.getRevision(), beforeRemoveRevision + 1);
|
||||
}
|
||||
|
||||
|
@ -303,7 +295,7 @@ namespace
|
|||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
const auto beforeRemoveRevision = manager.getRevision();
|
||||
manager.removeObject(ObjectId(&manager));
|
||||
manager.removeObject(ObjectId(&manager), nullptr);
|
||||
EXPECT_EQ(manager.getRevision(), beforeRemoveRevision);
|
||||
}
|
||||
|
||||
|
@ -312,8 +304,8 @@ namespace
|
|||
TileCachedRecastMeshManager manager(mSettings);
|
||||
const osg::Vec2i cellPosition(0, 0);
|
||||
const int cellSize = 8192;
|
||||
manager.addWater(cellPosition, cellSize, 0.0f);
|
||||
const auto changedTiles = manager.takeChangedTiles();
|
||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||
const auto changedTiles = manager.takeChangedTiles(nullptr);
|
||||
EXPECT_EQ(changedTiles.begin()->first, TilePosition(-1, -1));
|
||||
EXPECT_EQ(changedTiles.rbegin()->first, TilePosition(11, 11));
|
||||
for (const auto& [k, v] : changedTiles)
|
||||
|
@ -323,10 +315,10 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_water_for_not_max_int_should_add_new_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const osg::Vec2i cellPosition(0, 0);
|
||||
const int cellSize = 8192;
|
||||
manager.addWater(cellPosition, cellSize, 0.0f);
|
||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||
for (int x = -1; x < 12; ++x)
|
||||
for (int y = -1; y < 12; ++y)
|
||||
ASSERT_NE(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
|
||||
|
@ -335,13 +327,13 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_water_for_max_int_should_not_add_new_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
const osg::Vec2i cellPosition(0, 0);
|
||||
const int cellSize = std::numeric_limits<int>::max();
|
||||
manager.addWater(cellPosition, cellSize, 0.0f);
|
||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||
for (int x = -6; x < 6; ++x)
|
||||
for (int y = -6; y < 6; ++y)
|
||||
ASSERT_EQ(manager.getMesh("worldspace", TilePosition(x, y)) != nullptr, -1 <= x && x <= 0 && -1 <= y && y <= 0);
|
||||
|
@ -350,8 +342,8 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_absent_cell_should_not_add_changed_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.removeWater(osg::Vec2i(0, 0));
|
||||
EXPECT_THAT(manager.takeChangedTiles(), ElementsAre());
|
||||
manager.removeWater(osg::Vec2i(0, 0), nullptr);
|
||||
EXPECT_THAT(manager.takeChangedTiles(nullptr), ElementsAre());
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_add_changed_tiles)
|
||||
|
@ -359,10 +351,10 @@ namespace
|
|||
TileCachedRecastMeshManager manager(mSettings);
|
||||
const osg::Vec2i cellPosition(0, 0);
|
||||
const int cellSize = 8192;
|
||||
manager.addWater(cellPosition, cellSize, 0.0f);
|
||||
manager.takeChangedTiles();
|
||||
manager.removeWater(cellPosition);
|
||||
const auto changedTiles = manager.takeChangedTiles();
|
||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||
manager.takeChangedTiles(nullptr);
|
||||
manager.removeWater(cellPosition, nullptr);
|
||||
const auto changedTiles = manager.takeChangedTiles(nullptr);
|
||||
EXPECT_EQ(changedTiles.begin()->first, TilePosition(-1, -1));
|
||||
EXPECT_EQ(changedTiles.rbegin()->first, TilePosition(11, 11));
|
||||
for (const auto& [k, v] : changedTiles)
|
||||
|
@ -372,11 +364,11 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_remove_empty_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const osg::Vec2i cellPosition(0, 0);
|
||||
const int cellSize = 8192;
|
||||
manager.addWater(cellPosition, cellSize, 0.0f);
|
||||
manager.removeWater(cellPosition);
|
||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||
manager.removeWater(cellPosition, nullptr);
|
||||
for (int x = -6; x < 6; ++x)
|
||||
for (int y = -6; y < 6; ++y)
|
||||
ASSERT_EQ(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
|
||||
|
@ -385,14 +377,14 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_leave_not_empty_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
const osg::Vec2i cellPosition(0, 0);
|
||||
const int cellSize = 8192;
|
||||
manager.addWater(cellPosition, cellSize, 0.0f);
|
||||
manager.removeWater(cellPosition);
|
||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||
manager.removeWater(cellPosition, nullptr);
|
||||
for (int x = -6; x < 6; ++x)
|
||||
for (int y = -6; y < 6; ++y)
|
||||
ASSERT_EQ(manager.getMesh("worldspace", TilePosition(x, y)) != nullptr, -1 <= x && x <= 0 && -1 <= y && y <= 0);
|
||||
|
@ -401,14 +393,14 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_object_should_not_remove_tile_with_water)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const osg::Vec2i cellPosition(0, 0);
|
||||
const int cellSize = 8192;
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
manager.addWater(cellPosition, cellSize, 0.0f);
|
||||
manager.removeObject(ObjectId(&boxShape));
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||
manager.removeObject(ObjectId(&boxShape), nullptr);
|
||||
for (int x = -1; x < 12; ++x)
|
||||
for (int y = -1; y < 12; ++y)
|
||||
ASSERT_NE(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
|
||||
|
@ -417,11 +409,11 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, set_new_worldspace_should_remove_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace("worldspace");
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(nullptr, boxShape, mObjectTransform);
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground));
|
||||
manager.setWorldspace("other");
|
||||
ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||
manager.setWorldspace("other", nullptr);
|
||||
for (int x = -1; x < 1; ++x)
|
||||
for (int y = -1; y < 1; ++y)
|
||||
ASSERT_EQ(manager.getMesh("other", TilePosition(x, y)), nullptr);
|
||||
|
@ -435,13 +427,13 @@ namespace
|
|||
TileBounds bounds;
|
||||
bounds.mMin = osg::Vec2f(182, 0);
|
||||
bounds.mMax = osg::Vec2f(1000, 1000);
|
||||
manager.setBounds(bounds);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground);
|
||||
manager.setBounds(bounds, nullptr);
|
||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
bounds.mMin = osg::Vec2f(-1000, -1000);
|
||||
bounds.mMax = osg::Vec2f(0, -182);
|
||||
manager.takeChangedTiles();
|
||||
manager.setBounds(bounds);
|
||||
EXPECT_THAT(manager.takeChangedTiles(), ElementsAre(
|
||||
manager.takeChangedTiles(nullptr);
|
||||
manager.setBounds(bounds, nullptr);
|
||||
EXPECT_THAT(manager.takeChangedTiles(nullptr), ElementsAre(
|
||||
std::pair(TilePosition(-1, -1), ChangeType::add),
|
||||
std::pair(TilePosition(0, 0), ChangeType::remove)
|
||||
));
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace
|
|||
const Files::PathContainer mDataDirs {{std::string(OPENMW_DATA_DIR)}};
|
||||
const Files::Collections mFileCollections {mDataDirs, true};
|
||||
const std::string mContentFile = "template.omwgame";
|
||||
const std::string mContentFilePath = mFileCollections.getCollection(".omwgame").getPath(mContentFile).string();
|
||||
const std::filesystem::path mContentFilePath = mFileCollections.getCollection(".omwgame").getPath(mContentFile);
|
||||
};
|
||||
|
||||
TEST_F(ESM3ReadersCacheWithContentFile, shouldKeepOpenReleasedOpenReader)
|
||||
|
|
25
apps/openmw_test_suite/files/conversion_tests.cpp
Normal file
25
apps/openmw_test_suite/files/conversion_tests.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <components/files/conversion.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace testing;
|
||||
using namespace Files;
|
||||
|
||||
constexpr auto test_path_u8 = u8"./tmp/ÒĎƎɠˠΏЌԹעڨ/ऊঋਐઊଊ/ஐఋಋഊ/ฎນ༈ႩᄇḮὯ⁂₁₩ℒ/Ⅷ↝∑/☝✌〥ぐズ㌎丕.갔3갛";
|
||||
constexpr auto test_path = "./tmp/ÒĎƎɠˠΏЌԹעڨ/ऊঋਐઊଊ/ஐఋಋഊ/ฎນ༈ႩᄇḮὯ⁂₁₩ℒ/Ⅷ↝∑/☝✌〥ぐズ㌎丕.갔3갛";
|
||||
|
||||
TEST(OpenMWConversion, should_support_unicode_string_to_path)
|
||||
{
|
||||
auto p = Files::pathFromUnicodeString(test_path);
|
||||
EXPECT_EQ(Misc::StringUtils::u8StringToString(p.u8string()), Misc::StringUtils::u8StringToString(test_path_u8));
|
||||
}
|
||||
|
||||
TEST(OpenMWConversion, should_support_path_to_unicode_string)
|
||||
{
|
||||
std::filesystem::path p{ test_path_u8 };
|
||||
EXPECT_EQ(Files::pathToUnicodeString(p), test_path);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue