Merge branch 'clang-format-all' into 'master'

Apply clang-format project wide

See merge request OpenMW/openmw!2393
coverity_clang_test
psi29a 2 years ago
commit 6d3de520e8

@ -10,3 +10,8 @@
# Date: Fri Sep 16 00:53:24 2022 +0100
# Renormalise line endings
84f8a6848a8b05502d7618ca7af8cca74f2c3bae
# Author: clang-format-bot <bot@clang-format>
# Date: 9/22/2022 9:26:05 PM
# Apply clang-format to code base
ddb0522bbf2aa8aa7c9e139ff7395fb8ed6a841f

@ -123,12 +123,12 @@ Ubuntu_GCC:
Clang_Format:
extends: .Ubuntu_Image
stage: checks
# TODO: Remove this once the entire project is formatted.
allow_failure: true
cache:
key: Ubuntu_Clang_Format.ubuntu_22.04.v1
paths:
- apt-cache/
variables:
CLANG_FORMAT: clang-format-14
before_script:
- CI/install_debian_deps.sh openmw-clang-format
script:

@ -1,23 +1,25 @@
#!/bin/bash
CLANG_FORMAT="clang-format-14"
CLANG_FORMAT="${CLANG_FORMAT:-clang-format}"
HAS_DIFFS=0
check_format_file() {
local item=$1
"$CLANG_FORMAT" --dry-run -Werror "$item" &>/dev/null
if [[ $? = 1 ]]; then
"${CLANG_FORMAT}" "${item}" | git diff --color=always --no-index "${item}" -
HAS_DIFFS=1
fi
}
check_format() {
local path=$1
local tempfile=$(mktemp)
for item in $(find $path -type f -name "*");
find "$path" -type f -name "*" | while read item;
do
if [[ "$item" =~ .*\.(cpp|hpp|h) ]]; then
echo "Checking code formatting on $item"
$CLANG_FORMAT $item > $tempfile
git diff --color=always --no-index $item $tempfile
if [[ $? = 1 ]]; then
HAS_DIFFS=1
fi
check_format_file "$item"
fi;
done;
rm -f $tempfile
}
check_format "./apps"

@ -56,11 +56,16 @@ namespace
{
switch (index)
{
case 0: return AreaType_null;
case 1: return AreaType_water;
case 2: return AreaType_door;
case 3: return AreaType_pathgrid;
case 4: return AreaType_ground;
case 0:
return AreaType_null;
case 1:
return AreaType_water;
case 2:
return AreaType_door;
case 3:
return AreaType_pathgrid;
case 4:
return AreaType_ground;
}
return AreaType_null;
}
@ -97,7 +102,8 @@ namespace
if (distribution(random) < 0.939)
{
generateVertices(std::back_inserter(vertices), triangles * 2.467, random);
generateIndices(std::back_inserter(indices), static_cast<int>(vertices.size() / 3) - 1, vertices.size() * 1.279, random);
generateIndices(std::back_inserter(indices), static_cast<int>(vertices.size() / 3) - 1,
vertices.size() * 1.279, random);
generateAreaTypes(std::back_inserter(areaTypes), indices.size() / 3, random);
}
return Mesh(std::move(indices), std::move(vertices), std::move(areaTypes));
@ -113,10 +119,8 @@ namespace
result.mMinHeight = distribution(random);
result.mMaxHeight = result.mMinHeight + 1.0;
result.mLength = static_cast<std::uint8_t>(ESM::Land::LAND_SIZE);
std::generate_n(std::back_inserter(result.mHeights), ESM::Land::LAND_NUM_VERTS, [&]
{
return distribution(random);
});
std::generate_n(
std::back_inserter(result.mHeights), ESM::Land::LAND_NUM_VERTS, [&] { return distribution(random); });
result.mOriginalSize = ESM::Land::LAND_SIZE;
result.mMinX = 0;
result.mMinY = 0;
@ -147,8 +151,8 @@ namespace
Mesh mesh = generateMesh(triangles, random);
std::vector<CellWater> water;
generateWater(std::back_inserter(water), 1, random);
RecastMesh recastMesh(version, std::move(mesh), std::move(water),
{generateHeightfield(random)}, {generateFlatHeightfield(random)}, {});
RecastMesh recastMesh(version, std::move(mesh), std::move(water), { generateHeightfield(random) },
{ generateFlatHeightfield(random) }, {});
return Key{ AgentBounds{ agentShapeType, agentHalfExtents }, tilePosition, std::move(recastMesh) };
}
@ -168,8 +172,7 @@ namespace
while (true)
{
Key key = generateKey(trianglesPerTile, random);
cache.set(key.mAgentBounds, key.mTilePosition, key.mRecastMesh,
std::make_unique<PreparedNavMeshData>());
cache.set(key.mAgentBounds, key.mTilePosition, key.mRecastMesh, std::make_unique<PreparedNavMeshData>());
*out++ = std::move(key);
const std::size_t newSize = cache.getStats().mNavMeshCacheSize;
if (size >= newSize)
@ -250,8 +253,8 @@ namespace
while (state.KeepRunning())
{
const auto& key = keys[n++ % keys.size()];
const auto result = cache.set(key.mAgentBounds, key.mTilePosition, key.mRecastMesh,
std::make_unique<PreparedNavMeshData>());
const auto result = cache.set(
key.mAgentBounds, key.mTilePosition, key.mRecastMesh, std::make_unique<PreparedNavMeshData>());
benchmark::DoNotOptimize(result);
}
}

@ -1,15 +1,15 @@
#include <filesystem>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <vector>
#include <boost/program_options.hpp>
#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/algorithm.hpp>
#include <components/misc/strings/conversion.hpp>
#define BSATOOL_VERSION 1.1
@ -73,14 +73,12 @@ Allowed options)");
bpo::variables_map variables;
try
{
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
.options(all).positional(p).run();
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(all).positional(p).run();
bpo::store(valid_opts, variables);
}
catch (std::exception& e)
{
std::cout << "ERROR parsing arguments: " << e.what() << "\n\n"
<< desc << std::endl;
std::cout << "ERROR parsing arguments: " << e.what() << "\n\n" << desc << std::endl;
return false;
}
@ -98,28 +96,27 @@ Allowed options)");
}
if (!variables.count("mode"))
{
std::cout << "ERROR: no mode specified!\n\n"
<< desc << std::endl;
std::cout << "ERROR: no mode specified!\n\n" << desc << std::endl;
return false;
}
info.mode = variables["mode"].as<std::string>();
if (!(info.mode == "list" || info.mode == "extract" || info.mode == "extractall" || info.mode == "add" || info.mode == "create"))
if (!(info.mode == "list" || info.mode == "extract" || info.mode == "extractall" || info.mode == "add"
|| info.mode == "create"))
{
std::cout << std::endl << "ERROR: invalid mode \"" << info.mode << "\"\n\n"
<< desc << std::endl;
std::cout << std::endl << "ERROR: invalid mode \"" << info.mode << "\"\n\n" << desc << std::endl;
return false;
}
if (!variables.count("input-file"))
{
std::cout << "\nERROR: missing BSA archive\n\n"
<< desc << std::endl;
std::cout << "\nERROR: missing BSA archive\n\n" << desc << std::endl;
return false;
}
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.
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 = std::filesystem::current_path();
@ -128,28 +125,30 @@ Allowed options)");
{
if (inputFiles.size() < 2)
{
std::cout << "\nERROR: file to extract unspecified\n\n"
<< desc << std::endl;
std::cout << "\nERROR: file to extract unspecified\n\n" << desc << std::endl;
return false;
}
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.
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.
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 (inputFiles.empty())
{
std::cout << "\nERROR: file to add unspecified\n\n"
<< desc << std::endl;
std::cout << "\nERROR: file to add unspecified\n\n" << desc << std::endl;
return false;
}
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.
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 (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.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;
@ -221,14 +220,16 @@ 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: " << Files::pathToUnicodeString(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 " << Files::pathToUnicodeString(info.extractfile) << " to " << Files::pathToUnicodeString(target) << std::endl;
std::cout << "Extracting " << Files::pathToUnicodeString(info.extractfile) << " to "
<< Files::pathToUnicodeString(target) << std::endl;
out << stream->rdbuf();
out.close();

@ -1,11 +1,13 @@
#include <components/debug/debugging.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/esm3/readerscache.hpp>
#include <components/esmloader/esmdata.hpp>
#include <components/esmloader/load.hpp>
#include <components/fallback/fallback.hpp>
#include <components/fallback/validate.hpp>
#include <components/files/configurationmanager.hpp>
#include <components/platform/platform.hpp>
#include <components/resource/bulletshapemanager.hpp>
#include <components/resource/foreachbulletobject.hpp>
#include <components/resource/imagemanager.hpp>
@ -15,8 +17,6 @@
#include <components/version/version.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/registerarchives.hpp>
#include <components/esm3/readerscache.hpp>
#include <components/platform/platform.hpp>
#include <boost/program_options.hpp>
@ -27,7 +27,6 @@
#include <string>
#include <vector>
namespace
{
namespace bpo = boost::program_options;
@ -44,33 +43,41 @@ namespace
addOption("version", "print version information and quit");
addOption("data", bpo::value<Files::MaybeQuotedPathContainer>()->default_value(Files::MaybeQuotedPathContainer(), "data")
->multitoken()->composing(), "set data directories (later directories have higher priority)");
addOption("data",
bpo::value<Files::MaybeQuotedPathContainer>()
->default_value(Files::MaybeQuotedPathContainer(), "data")
->multitoken()
->composing(),
"set data directories (later directories have higher priority)");
addOption("data-local", bpo::value<Files::MaybeQuotedPathContainer::value_type>()->default_value(Files::MaybeQuotedPathContainer::value_type(), ""),
addOption("data-local",
bpo::value<Files::MaybeQuotedPathContainer::value_type>()->default_value(
Files::MaybeQuotedPathContainer::value_type(), ""),
"set local data directory (highest priority)");
addOption("fallback-archive", bpo::value<StringsVector>()->default_value(StringsVector(), "fallback-archive")
->multitoken()->composing(), "set fallback BSA archives (later archives have higher priority)");
addOption("fallback-archive",
bpo::value<StringsVector>()->default_value(StringsVector(), "fallback-archive")->multitoken()->composing(),
"set fallback BSA archives (later archives have higher priority)");
addOption("resources", bpo::value<Files::MaybeQuotedPath>()->default_value(Files::MaybeQuotedPath(), "resources"),
addOption("resources",
bpo::value<Files::MaybeQuotedPath>()->default_value(Files::MaybeQuotedPath(), "resources"),
"set resources directory");
addOption("content", bpo::value<StringsVector>()->default_value(StringsVector(), "")
->multitoken()->composing(), "content file(s): esm/esp, or omwgame/omwaddon/omwscripts");
addOption("content", bpo::value<StringsVector>()->default_value(StringsVector(), "")->multitoken()->composing(),
"content file(s): esm/esp, or omwgame/omwaddon/omwscripts");
addOption("fs-strict", bpo::value<bool>()->implicit_value(true)
->default_value(false), "strict file system handling (no case folding)");
addOption("fs-strict", bpo::value<bool>()->implicit_value(true)->default_value(false),
"strict file system handling (no case folding)");
addOption("encoding", bpo::value<std::string>()->
default_value("win1252"),
addOption("encoding", bpo::value<std::string>()->default_value("win1252"),
"Character encoding used in OpenMW game messages:\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, "
"Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n"
"\n\twin1252 - Western European (Latin) alphabet, used by default");
addOption("fallback", bpo::value<FallbackMap>()->default_value(FallbackMap(), "")
->multitoken()->composing(), "fallback values");
addOption("fallback", bpo::value<FallbackMap>()->default_value(FallbackMap(), "")->multitoken()->composing(),
"fallback values");
;
Files::ConfigurationManager::addCommonOptions(result);
@ -110,8 +117,7 @@ namespace
bpo::options_description desc = makeOptionsDescription();
bpo::parsed_options options = bpo::command_line_parser(argc, argv)
.options(desc).allow_unregistered().run();
bpo::parsed_options options = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
bpo::variables_map variables;
bpo::store(options, variables);
@ -168,25 +174,28 @@ namespace
query.mLoadGameSettings = true;
query.mLoadLands = true;
query.mLoadStatics = true;
const EsmLoader::EsmData esmData = EsmLoader::loadEsmData(query, contentFiles, fileCollections, readers, &encoder);
const EsmLoader::EsmData esmData
= EsmLoader::loadEsmData(query, contentFiles, fileCollections, readers, &encoder);
Resource::ImageManager imageManager(&vfs);
Resource::NifFileManager nifFileManager(&vfs);
Resource::SceneManager sceneManager(&vfs, &imageManager, &nifFileManager);
Resource::BulletShapeManager bulletShapeManager(&vfs, &sceneManager, &nifFileManager);
Resource::forEachBulletObject(readers, vfs, bulletShapeManager, esmData,
[] (const ESM::Cell& cell, const Resource::BulletObject& object)
{
Resource::forEachBulletObject(
readers, vfs, bulletShapeManager, esmData, [](const ESM::Cell& cell, const Resource::BulletObject& object) {
Log(Debug::Verbose) << "Found bullet object in " << (cell.isExterior() ? "exterior" : "interior")
<< " cell \"" << cell.getDescription() << "\":"
<< " fileName=\"" << object.mShape->mFileName << '"'
<< " fileHash=" << toHex(object.mShape->mFileHash)
<< " collisionShape=" << std::boolalpha << (object.mShape->mCollisionShape == nullptr)
<< " avoidCollisionShape=" << std::boolalpha << (object.mShape->mAvoidCollisionShape == nullptr)
<< " position=(" << WriteArray {object.mPosition.pos} << ')'
<< " rotation=(" << WriteArray {object.mPosition.rot} << ')'
<< " scale=" << std::setprecision(std::numeric_limits<float>::max_exponent10) << object.mScale;
<< " collisionShape=" << std::boolalpha
<< (object.mShape->mCollisionShape == nullptr)
<< " avoidCollisionShape=" << std::boolalpha
<< (object.mShape->mAvoidCollisionShape == nullptr) << " position=("
<< WriteArray{ object.mPosition.pos } << ')' << " rotation=("
<< WriteArray{ object.mPosition.rot } << ')'
<< " scale=" << std::setprecision(std::numeric_limits<float>::max_exponent10)
<< object.mScale;
});
Log(Debug::Info) << "Done";

@ -1,9 +1,9 @@
#ifndef OPENMW_ESMTOOL_ARGUMENTS_H
#define OPENMW_ESMTOOL_ARGUMENTS_H
#include <vector>
#include <optional>
#include <filesystem>
#include <optional>
#include <vector>
#include <components/esm/format.hpp>

@ -1,28 +1,28 @@
#include <iostream>
#include <vector>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <unordered_set>
#include <map>
#include <fstream>
#include <cmath>
#include <memory>
#include <optional>
#include <iomanip>
#include <unordered_set>
#include <vector>
#include <boost/program_options.hpp>
#include <components/esm/format.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/esm3/esmwriter.hpp>
#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 <components/files/openfile.hpp>
#include <components/misc/strings/algorithm.hpp>
#include "record.hpp"
#include "labels.hpp"
#include "arguments.hpp"
#include "labels.hpp"
#include "record.hpp"
#include "tes4.hpp"
namespace
@ -43,7 +43,6 @@ struct ESMData
// Value: (Reference, Deleted flag)
std::map<ESM::Cell*, std::deque<std::pair<ESM::CellRef, bool>>> mCellRefs;
std::map<int, int> mRecordStats;
};
bool parseOptions(int argc, char** argv, Arguments& info)
@ -68,23 +67,24 @@ Allowed options)");
addOption("type,t", bpo::value<std::vector<std::string>>(),
"Show only records of this type (four character record code). May "
"be specified multiple times. Only affects dump mode.");
addOption("name,n", bpo::value<std::string>(),
"Show only the record with this name. Only affects dump mode.");
addOption("plain,p", "Print contents of dialogs, books and scripts. "
addOption("name,n", bpo::value<std::string>(), "Show only the record with this name. Only affects dump mode.");
addOption("plain,p",
"Print contents of dialogs, books and scripts. "
"(skipped by default)"
"Only affects dump mode.");
addOption("quiet,q", "Suppress all record information. Useful for speed tests.");
addOption("loadcells,C", "Browse through contents of all cells.");
addOption( "encoding,e", bpo::value<std::string>(&(info.encoding))->
default_value("win1252"),
addOption("encoding,e", bpo::value<std::string>(&(info.encoding))->default_value("win1252"),
"Character encoding used in ESMTool:\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, "
"Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n"
"\n\twin1252 - Western European (Latin) alphabet, used by default")
;
"\n\twin1252 - Western European (Latin) alphabet, used by default");
std::string finalText = "\nIf no option is given, the default action is to parse all records in the archive\nand display diagnostic information.";
std::string finalText
= "\nIf no option is given, the default action is to parse all records in the archive\nand display "
"diagnostic information.";
// input-file is hidden and used as a positional argument
bpo::options_description hidden("Hidden Options");
@ -102,8 +102,7 @@ Allowed options)");
try
{
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
.options(all).positional(p).run();
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(all).positional(p).run();
bpo::store(valid_opts, variables);
}
@ -127,8 +126,7 @@ Allowed options)");
}
if (!variables.count("mode"))
{
std::cout << "No mode specified!\n\n"
<< desc << finalText << std::endl;
std::cout << "No mode specified!\n\n" << desc << finalText << std::endl;
return false;
}
@ -140,8 +138,7 @@ Allowed options)");
info.mode = variables["mode"].as<std::string>();
if (!(info.mode == "dump" || info.mode == "clone" || info.mode == "comp"))
{
std::cout << "\nERROR: invalid mode \"" << info.mode << "\"\n\n"
<< desc << finalText << std::endl;
std::cout << "\nERROR: invalid mode \"" << info.mode << "\"\n\n" << desc << finalText << std::endl;
return false;
}
@ -161,9 +158,11 @@ Allowed options)");
}*/
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.
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.
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>());
@ -237,7 +236,8 @@ void loadCell(const Arguments& info, ESM::Cell &cell, ESM::ESMReader &esm, ESMDa
// Loop through all the references
ESM::CellRef ref;
if(!quiet) std::cout << " References:\n";
if (!quiet)
std::cout << " References:\n";
bool deleted = false;
ESM::MovedCellRef movedCellRef;
@ -247,11 +247,13 @@ void loadCell(const Arguments& info, ESM::Cell &cell, ESM::ESMReader &esm, ESMDa
if (data != nullptr && save)
data->mCellRefs[&cell].push_back(std::make_pair(ref, deleted));
if(quiet) continue;
if (quiet)
continue;
std::cout << " - Refnum: " << ref.mRefNum.mIndex << '\n';
std::cout << " ID: " << ref.mRefID << '\n';
std::cout << " Position: (" << ref.mPos.pos[0] << ", " << ref.mPos.pos[1] << ", " << ref.mPos.pos[2] << ")\n";
std::cout << " Position: (" << ref.mPos.pos[0] << ", " << ref.mPos.pos[1] << ", " << ref.mPos.pos[2]
<< ")\n";
if (ref.mScale != 1.f)
std::cout << " Scale: " << ref.mScale << '\n';
if (!ref.mOwner.empty())
@ -276,8 +278,8 @@ void loadCell(const Arguments& info, ESM::Cell &cell, ESM::ESMReader &esm, ESMDa
std::cout << " Soul: " << ref.mSoul << '\n';
if (ref.mTeleport)
{
std::cout << " Destination position: (" << ref.mDoorDest.pos[0] << ", "
<< ref.mDoorDest.pos[1] << ", " << ref.mDoorDest.pos[2] << ")\n";
std::cout << " Destination position: (" << ref.mDoorDest.pos[0] << ", " << ref.mDoorDest.pos[1]
<< ", " << ref.mDoorDest.pos[2] << ")\n";
if (!ref.mDestCell.empty())
std::cout << " Destination cell: " << ref.mDestCell << '\n';
}
@ -308,8 +310,8 @@ void printRawTes3(const std::filesystem::path &path)
esm.skipHSub();
n = esm.retSubName();
std::ios::fmtflags f(std::cout.flags());
std::cout << " " << n.toStringView() << " - " << esm.getSubSize()
<< " bytes @ 0x" << std::hex << offs << '\n';
std::cout << " " << n.toStringView() << " - " << esm.getSubSize() << " bytes @ 0x" << std::hex
<< offs << '\n';
std::cout.flags(f);
}
}
@ -367,7 +369,8 @@ int loadTes3(const Arguments& info, std::unique_ptr<std::ifstream>&& stream, ESM
}
esm.skipRecord();
if (quiet) break;
if (quiet)
break;
std::cout << " Skipping\n";
continue;
@ -379,7 +382,8 @@ int loadTes3(const Arguments& info, std::unique_ptr<std::ifstream>&& stream, ESM
// Is the user interested in this record type?
bool interested = true;
if (!info.types.empty() && std::find(info.types.begin(), info.types.end(), n.toStringView()) == info.types.end())
if (!info.types.empty()
&& std::find(info.types.begin(), info.types.end(), n.toStringView()) == info.types.end())
interested = false;
if (!info.name.empty() && !Misc::StringUtils::ciEqual(info.name, record->getId()))
@ -426,7 +430,8 @@ int load(const Arguments& info, ESMData* data)
printRawTes3(info.filename);
break;
case ESM::Format::Tes4:
std::cout << "Printing raw TES4 file is not supported: " << Files::pathToUnicodeString(info.filename) << "\n";
std::cout << "Printing raw TES4 file is not supported: "
<< Files::pathToUnicodeString(info.filename) << "\n";
break;
}
return 0;
@ -520,7 +525,8 @@ int clone(const Arguments& info)
esm.startRecord(typeName, record->getFlags());
record->save(esm);
if (typeName.toInt() == ESM::REC_CELL) {
if (typeName.toInt() == ESM::REC_CELL)
{
ESM::Cell* ptr = &record->cast<ESM::Cell>()->get();
if (!data.mCellRefs[ptr].empty())
{
@ -570,14 +576,16 @@ int comp(const Arguments& info)
ESMData dataOne;
if (load(fileOne, &dataOne) != 0)
{
std::cout << "Failed to load " << Files::pathToUnicodeString(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 " << Files::pathToUnicodeString(info.outname) << ", aborting comparison." << std::endl;
std::cout << "Failed to load " << Files::pathToUnicodeString(info.outname) << ", aborting comparison."
<< std::endl;
return 1;
}

@ -243,11 +243,16 @@ std::string_view aiTypeLabel(ESM::AiPackageType type)
{
switch (type)
{
case ESM::AI_Wander: return "Wander";
case ESM::AI_Travel: return "Travel";
case ESM::AI_Follow: return "Follow";
case ESM::AI_Escort: return "Escort";
case ESM::AI_Activate: return "Activate";
case ESM::AI_Wander:
return "Wander";
case ESM::AI_Travel:
return "Travel";
case ESM::AI_Follow:
return "Follow";
case ESM::AI_Escort:
return "Escort";
case ESM::AI_Activate:
return "Activate";
}
return "Invalid";
}
@ -656,13 +661,15 @@ std::string_view ruleFunction(int idx)
std::string bodyPartFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::BodyPart::BPF_Female) properties += "Female ";
if (flags & ESM::BodyPart::BPF_NotPlayable) properties += "NotPlayable ";
int unused = (0xFFFFFFFF ^
(ESM::BodyPart::BPF_Female|
ESM::BodyPart::BPF_NotPlayable));
if (flags & unused) properties += "Invalid ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::BodyPart::BPF_Female)
properties += "Female ";
if (flags & ESM::BodyPart::BPF_NotPlayable)
properties += "NotPlayable ";
int unused = (0xFFFFFFFF ^ (ESM::BodyPart::BPF_Female | ESM::BodyPart::BPF_NotPlayable));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -670,20 +677,23 @@ std::string bodyPartFlags(int flags)
std::string cellFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::Cell::HasWater) properties += "HasWater ";
if (flags & ESM::Cell::Interior) properties += "Interior ";
if (flags & ESM::Cell::NoSleep) properties += "NoSleep ";
if (flags & ESM::Cell::QuasiEx) properties += "QuasiEx ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::Cell::HasWater)
properties += "HasWater ";
if (flags & ESM::Cell::Interior)
properties += "Interior ";
if (flags & ESM::Cell::NoSleep)
properties += "NoSleep ";
if (flags & ESM::Cell::QuasiEx)
properties += "QuasiEx ";
// This used value is not in the ESM component.
if (flags & 0x00000040) properties += "Unknown ";
int unused = (0xFFFFFFFF ^
(ESM::Cell::HasWater|
ESM::Cell::Interior|
ESM::Cell::NoSleep|
ESM::Cell::QuasiEx|
0x00000040));
if (flags & unused) properties += "Invalid ";
if (flags & 0x00000040)
properties += "Unknown ";
int unused = (0xFFFFFFFF
^ (ESM::Cell::HasWater | ESM::Cell::Interior | ESM::Cell::NoSleep | ESM::Cell::QuasiEx | 0x00000040));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -691,15 +701,17 @@ std::string cellFlags(int flags)
std::string containerFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::Container::Unknown) properties += "Unknown ";
if (flags & ESM::Container::Organic) properties += "Organic ";
if (flags & ESM::Container::Respawn) properties += "Respawn ";
int unused = (0xFFFFFFFF ^
(ESM::Container::Unknown|
ESM::Container::Organic|
ESM::Container::Respawn));
if (flags & unused) properties += "Invalid ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::Container::Unknown)
properties += "Unknown ";
if (flags & ESM::Container::Organic)
properties += "Organic ";
if (flags & ESM::Container::Respawn)
properties += "Respawn ";
int unused = (0xFFFFFFFF ^ (ESM::Container::Unknown | ESM::Container::Organic | ESM::Container::Respawn));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -707,25 +719,29 @@ std::string containerFlags(int flags)
std::string creatureFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::Creature::Base) properties += "Base ";
if (flags & ESM::Creature::Walks) properties += "Walks ";
if (flags & ESM::Creature::Swims) properties += "Swims ";
if (flags & ESM::Creature::Flies) properties += "Flies ";
if (flags & ESM::Creature::Bipedal) properties += "Bipedal ";
if (flags & ESM::Creature::Respawn) properties += "Respawn ";
if (flags & ESM::Creature::Weapon) properties += "Weapon ";
if (flags & ESM::Creature::Essential) properties += "Essential ";
int unused = (0xFFFFFFFF ^
(ESM::Creature::Base|
ESM::Creature::Walks|
ESM::Creature::Swims|
ESM::Creature::Flies|
ESM::Creature::Bipedal|
ESM::Creature::Respawn|
ESM::Creature::Weapon|
ESM::Creature::Essential));
if (flags & unused) properties += "Invalid ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::Creature::Base)
properties += "Base ";
if (flags & ESM::Creature::Walks)
properties += "Walks ";
if (flags & ESM::Creature::Swims)
properties += "Swims ";
if (flags & ESM::Creature::Flies)
properties += "Flies ";
if (flags & ESM::Creature::Bipedal)
properties += "Bipedal ";
if (flags & ESM::Creature::Respawn)
properties += "Respawn ";
if (flags & ESM::Creature::Weapon)
properties += "Weapon ";
if (flags & ESM::Creature::Essential)
properties += "Essential ";
int unused = (0xFFFFFFFF
^ (ESM::Creature::Base | ESM::Creature::Walks | ESM::Creature::Swims | ESM::Creature::Flies
| ESM::Creature::Bipedal | ESM::Creature::Respawn | ESM::Creature::Weapon | ESM::Creature::Essential));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%02X)", flags);
return properties;
}
@ -733,9 +749,12 @@ std::string creatureFlags(int flags)
std::string enchantmentFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::Enchantment::Autocalc) properties += "Autocalc ";
if (flags & (0xFFFFFFFF ^ ESM::Enchantment::Autocalc)) properties += "Invalid ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::Enchantment::Autocalc)
properties += "Autocalc ";
if (flags & (0xFFFFFFFF ^ ESM::Enchantment::Autocalc))
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -746,11 +765,16 @@ std::string landFlags(int flags)
// The ESM component says that this first four bits are used, but
// only the first three bits are used as far as I can tell.
// There's also no enumeration of the bit in the ESM component.
if (flags == 0) properties += "[None] ";
if (flags & 0x00000001) properties += "Unknown1 ";
if (flags & 0x00000004) properties += "Unknown3 ";
if (flags & 0x00000002) properties += "Unknown2 ";
if (flags & 0xFFFFFFF8) properties += "Invalid ";
if (flags == 0)
properties += "[None] ";
if (flags & 0x00000001)
properties += "Unknown1 ";
if (flags & 0x00000004)
properties += "Unknown3 ";
if (flags & 0x00000002)
properties += "Unknown2 ";
if (flags & 0xFFFFFFF8)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -758,13 +782,15 @@ std::string landFlags(int flags)
std::string itemListFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::ItemLevList::AllLevels) properties += "AllLevels ";
if (flags & ESM::ItemLevList::Each) properties += "Each ";
int unused = (0xFFFFFFFF ^
(ESM::ItemLevList::AllLevels|
ESM::ItemLevList::Each));
if (flags & unused) properties += "Invalid ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::ItemLevList::AllLevels)
properties += "AllLevels ";
if (flags & ESM::ItemLevList::Each)
properties += "Each ";
int unused = (0xFFFFFFFF ^ (ESM::ItemLevList::AllLevels | ESM::ItemLevList::Each));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -772,10 +798,13 @@ std::string itemListFlags(int flags)
std::string creatureListFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::CreatureLevList::AllLevels) properties += "AllLevels ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::CreatureLevList::AllLevels)
properties += "AllLevels ";
int unused = (0xFFFFFFFF ^ ESM::CreatureLevList::AllLevels);
if (flags & unused) properties += "Invalid ";
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -783,27 +812,31 @@ std::string creatureListFlags(int flags)
std::string lightFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::Light::Dynamic) properties += "Dynamic ";
if (flags & ESM::Light::Fire) properties += "Fire ";
if (flags & ESM::Light::Carry) properties += "Carry ";
if (flags & ESM::Light::Flicker) properties += "Flicker ";
if (flags & ESM::Light::FlickerSlow) properties += "FlickerSlow ";
if (flags & ESM::Light::Pulse) properties += "Pulse ";
if (flags & ESM::Light::PulseSlow) properties += "PulseSlow ";
if (flags & ESM::Light::Negative) properties += "Negative ";
if (flags & ESM::Light::OffDefault) properties += "OffDefault ";
int unused = (0xFFFFFFFF ^
(ESM::Light::Dynamic|
ESM::Light::Fire|
ESM::Light::Carry|
ESM::Light::Flicker|
ESM::Light::FlickerSlow|
ESM::Light::Pulse|
ESM::Light::PulseSlow|
ESM::Light::Negative|
ESM::Light::OffDefault));
if (flags & unused) properties += "Invalid ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::Light::Dynamic)
properties += "Dynamic ";
if (flags & ESM::Light::Fire)
properties += "Fire ";
if (flags & ESM::Light::Carry)
properties += "Carry ";
if (flags & ESM::Light::Flicker)
properties += "Flicker ";
if (flags & ESM::Light::FlickerSlow)
properties += "FlickerSlow ";
if (flags & ESM::Light::Pulse)
properties += "Pulse ";
if (flags & ESM::Light::PulseSlow)
properties += "PulseSlow ";
if (flags & ESM::Light::Negative)
properties += "Negative ";
if (flags & ESM::Light::OffDefault)
properties += "OffDefault ";
int unused = (0xFFFFFFFF
^ (ESM::Light::Dynamic | ESM::Light::Fire | ESM::Light::Carry | ESM::Light::Flicker | ESM::Light::FlickerSlow
| ESM::Light::Pulse | ESM::Light::PulseSlow | ESM::Light::Negative | ESM::Light::OffDefault));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -811,27 +844,47 @@ std::string lightFlags(int flags)
std::string magicEffectFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::MagicEffect::TargetAttribute) properties += "TargetAttribute ";
if (flags & ESM::MagicEffect::TargetSkill) properties += "TargetSkill ";
if (flags & ESM::MagicEffect::NoDuration) properties += "NoDuration ";
if (flags & ESM::MagicEffect::NoMagnitude) properties += "NoMagnitude ";
if (flags & ESM::MagicEffect::Harmful) properties += "Harmful ";
if (flags & ESM::MagicEffect::ContinuousVfx) properties += "ContinuousVFX ";
if (flags & ESM::MagicEffect::CastSelf) properties += "CastSelf ";
if (flags & ESM::MagicEffect::CastTouch) properties += "CastTouch ";
if (flags & ESM::MagicEffect::CastTarget) properties += "CastTarget ";
if (flags & ESM::MagicEffect::AppliedOnce) properties += "AppliedOnce ";
if (flags & ESM::MagicEffect::Stealth) properties += "Stealth ";
if (flags & ESM::MagicEffect::NonRecastable) properties += "NonRecastable ";
if (flags & ESM::MagicEffect::IllegalDaedra) properties += "IllegalDaedra ";
if (flags & ESM::MagicEffect::Unreflectable) properties += "Unreflectable ";
if (flags & ESM::MagicEffect::CasterLinked) properties += "CasterLinked ";
if (flags & ESM::MagicEffect::AllowSpellmaking) properties += "AllowSpellmaking ";
if (flags & ESM::MagicEffect::AllowEnchanting) properties += "AllowEnchanting ";
if (flags & ESM::MagicEffect::NegativeLight) properties += "NegativeLight ";
if (flags & 0xFFFC0000) properties += "Invalid ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::MagicEffect::TargetAttribute)
properties += "TargetAttribute ";
if (flags & ESM::MagicEffect::TargetSkill)
properties += "TargetSkill ";
if (flags & ESM::MagicEffect::NoDuration)
properties += "NoDuration ";
if (flags & ESM::MagicEffect::NoMagnitude)
properties += "NoMagnitude ";
if (flags & ESM::MagicEffect::Harmful)
properties += "Harmful ";
if (flags & ESM::MagicEffect::ContinuousVfx)
properties += "ContinuousVFX ";
if (flags & ESM::MagicEffect::CastSelf)
properties += "CastSelf ";
if (flags & ESM::MagicEffect::CastTouch)
properties += "CastTouch ";
if (flags & ESM::MagicEffect::CastTarget)
properties += "CastTarget ";
if (flags & ESM::MagicEffect::AppliedOnce)
properties += "AppliedOnce ";
if (flags & ESM::MagicEffect::Stealth)
properties += "Stealth ";
if (flags & ESM::MagicEffect::NonRecastable)
properties += "NonRecastable ";
if (flags & ESM::MagicEffect::IllegalDaedra)
properties += "IllegalDaedra ";
if (flags & ESM::MagicEffect::Unreflectable)
properties += "Unreflectable ";
if (flags & ESM::MagicEffect::CasterLinked)
properties += "CasterLinked ";
if (flags & ESM::MagicEffect::AllowSpellmaking)
properties += "AllowSpellmaking ";
if (flags & ESM::MagicEffect::AllowEnchanting)
properties += "AllowEnchanting ";
if (flags & ESM::MagicEffect::NegativeLight)
properties += "NegativeLight ";
if (flags & 0xFFFC0000)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -839,21 +892,24 @@ std::string magicEffectFlags(int flags)
std::string npcFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::NPC::Base) properties += "Base ";
if (flags & ESM::NPC::Autocalc) properties += "Autocalc ";
if (flags & ESM::NPC::Female) properties += "Female ";
if (flags & ESM::NPC::Respawn) properties += "Respawn ";
if (flags & ESM::NPC::Essential) properties += "Essential ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::NPC::Base)
properties += "Base ";
if (flags & ESM::NPC::Autocalc)
properties += "Autocalc ";
if (flags & ESM::NPC::Female)
properties += "Female ";
if (flags & ESM::NPC::Respawn)
properties += "Respawn ";
if (flags & ESM::NPC::Essential)
properties += "Essential ";
// Whether corpses persist is a bit that is unaccounted for,
// however relatively few NPCs have this bit set.
int unused = (0xFF ^
(ESM::NPC::Base|
ESM::NPC::Autocalc|
ESM::NPC::Female|
ESM::NPC::Respawn|
ESM::NPC::Essential));
if (flags & unused) properties += "Invalid ";
int unused
= (0xFF ^ (ESM::NPC::Base | ESM::NPC::Autocalc | ESM::NPC::Female | ESM::NPC::Respawn | ESM::NPC::Essential));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%02X)", flags);
return properties;
}
@ -861,14 +917,16 @@ std::string npcFlags(int flags)
std::string raceFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags == 0)
properties += "[None] ";
// All races have the playable flag set in Bethesda files.
if (flags & ESM::Race::Playable) properties += "Playable ";
if (flags & ESM::Race::Beast) properties += "Beast ";
int unused = (0xFFFFFFFF ^
(ESM::Race::Playable|
ESM::Race::Beast));
if (flags & unused) properties += "Invalid ";
if (flags & ESM::Race::Playable)
properties += "Playable ";
if (flags & ESM::Race::Beast)
properties += "Beast ";
int unused = (0xFFFFFFFF ^ (ESM::Race::Playable | ESM::Race::Beast));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -876,15 +934,17 @@ std::string raceFlags(int flags)
std::string spellFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::Spell::F_Autocalc) properties += "Autocalc ";
if (flags & ESM::Spell::F_PCStart) properties += "PCStart ";
if (flags & ESM::Spell::F_Always) properties += "Always ";
int unused = (0xFFFFFFFF ^
(ESM::Spell::F_Autocalc|
ESM::Spell::F_PCStart|
ESM::Spell::F_Always));
if (flags & unused) properties += "Invalid ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::Spell::F_Autocalc)
properties += "Autocalc ";
if (flags & ESM::Spell::F_PCStart)
properties += "PCStart ";
if (flags & ESM::Spell::F_Always)
properties += "Always ";
int unused = (0xFFFFFFFF ^ (ESM::Spell::F_Autocalc | ESM::Spell::F_PCStart | ESM::Spell::F_Always));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -892,16 +952,18 @@ std::string spellFlags(int flags)
std::string weaponFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags == 0)
properties += "[None] ";
// The interpretation of the flags are still unclear to me.
// Apparently you can't be Silver without being Magical? Many of
// the "Magical" weapons don't have enchantments of any sort.
if (flags & ESM::Weapon::Magical) properties += "Magical ";
if (flags & ESM::Weapon::Silver) properties += "Silver ";
int unused = (0xFFFFFFFF ^
(ESM::Weapon::Magical|
ESM::Weapon::Silver));
if (flags & unused) properties += "Invalid ";
if (flags & ESM::Weapon::Magical)
properties += "Magical ";
if (flags & ESM::Weapon::Silver)
properties += "Silver ";
int unused = (0xFFFFFFFF ^ (ESM::Weapon::Magical | ESM::Weapon::Silver));
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
@ -909,13 +971,19 @@ std::string weaponFlags(int flags)
std::string recordFlags(uint32_t flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::FLAG_Deleted) properties += "Deleted ";
if (flags & ESM::FLAG_Persistent) properties += "Persistent ";
if (flags & ESM::FLAG_Ignored) properties += "Ignored ";
if (flags & ESM::FLAG_Blocked) properties += "Blocked ";
if (flags == 0)
properties += "[None] ";
if (flags & ESM::FLAG_Deleted)
properties += "Deleted ";
if (flags & ESM::FLAG_Persistent)
properties += "Persistent ";
if (flags & ESM::FLAG_Ignored)
properties += "Ignored ";
if (flags & ESM::FLAG_Blocked)
properties += "Blocked ";
int unused = ~(ESM::FLAG_Deleted | ESM::FLAG_Persistent | ESM::FLAG_Ignored | ESM::FLAG_Blocked);
if (flags & unused) properties += "Invalid ";
if (flags & unused)
properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}

@ -11,8 +11,8 @@ namespace
void printAIPackage(const ESM::AIPackage& p)
{
std::cout << " AI Type: " << aiTypeLabel(p.mType)
<< " (" << Misc::StringUtils::format("0x%08X", p.mType) << ")" << std::endl;
std::cout << " AI Type: " << aiTypeLabel(p.mType) << " (" << Misc::StringUtils::format("0x%08X", p.mType)
<< ")" << std::endl;
if (p.mType == ESM::AI_Wander)
{
std::cout << " Distance: " << p.mWander.mDistance << std::endl;
@ -28,14 +28,14 @@ void printAIPackage(const ESM::AIPackage& p)
}
else if (p.mType == ESM::AI_Travel)
{
std::cout << " Travel Coordinates: (" << p.mTravel.mX << ","
<< p.mTravel.mY << "," << p.mTravel.mZ << ")" << std::endl;
std::cout << " Travel Coordinates: (" << p.mTravel.mX << "," << p.mTravel.mY << "," << p.mTravel.mZ
<< ")" << std::endl;
std::cout << " Should repeat: " << static_cast<bool>(p.mTravel.mShouldRepeat != 0) << std::endl;
}
else if (p.mType == ESM::AI_Follow || p.mType == ESM::AI_Escort)
{
std::cout << " Follow Coordinates: (" << p.mTarget.mX << ","
<< p.mTarget.mY << "," << p.mTarget.mZ << ")" << std::endl;
std::cout << " Follow Coordinates: (" << p.mTarget.mX << "," << p.mTarget.mY << "," << p.mTarget.mZ
<< ")" << std::endl;
std::cout << " Duration: " << p.mTarget.mDuration << std::endl;
std::cout << " Target ID: " << p.mTarget.mId.toString() << std::endl;
std::cout << " Should repeat: " << static_cast<bool>(p.mTarget.mShouldRepeat != 0) << std::endl;
@ -45,7 +45,8 @@ void printAIPackage(const ESM::AIPackage& p)
std::cout << " Name: " << p.mActivate.mName.toString() << std::endl;
std::cout << " Should repeat: " << static_cast<bool>(p.mActivate.mShouldRepeat != 0) << std::endl;
}
else {
else
{
std::cout << " BadPackage: " << Misc::StringUtils::format("0x%08X", p.mType) << std::endl;
}
@ -76,29 +77,64 @@ std::string ruleString(const ESM::DialInfo::SelectStruct& ss)
func_str = std::string(ruleFunction(func));
break;
case '2':
if (indicator == 's') type_str = "Global short";
else if (indicator == 'l') type_str = "Global long";
else if (indicator == 'f') type_str = "Global float";
if (indicator == 's')
type_str = "Global short";
else if (indicator == 'l')
type_str = "Global long";
else if (indicator == 'f')
type_str = "Global float";
break;
case '3':
if (indicator == 's') type_str = "Local short";
else if (indicator == 'l') type_str = "Local long";
else if (indicator == 'f') type_str = "Local float";
if (indicator == 's')
type_str = "Local short";
else if (indicator == 'l')
type_str = "Local long";
else if (indicator == 'f')
type_str = "Local float";
break;
case '4':
if (indicator == 'J')
type_str = "Journal";
break;
case '5':
if (indicator == 'I')
type_str = "Item type";
break;
case '6':
if (indicator == 'D')
type_str = "NPC Dead";
break;
case '7':
if (indicator == 'X')
type_str = "Not ID";
break;
case '8':
if (indicator == 'F')
type_str = "Not Faction";
break;
case '9':
if (indicator == 'C')
type_str = "Not Class";
break;
case 'A':
if (indicator == 'R')
type_str = "Not Race";
break;
case 'B':
if (indicator == 'L')
type_str = "Not Cell";
break;
case 'C':
if (indicator == 's')
type_str = "Not Local";
break;
default:
break;
case '4': if (indicator == 'J') type_str = "Journal"; break;
case '5': if (indicator == 'I') type_str = "Item type"; break;
case '6': if (indicator == 'D') type_str = "NPC Dead"; break;
case '7': if (indicator == 'X') type_str = "Not ID"; break;
case '8': if (indicator == 'F') type_str = "Not Faction"; break;
case '9': if (indicator == 'C') type_str = "Not Class"; break;
case 'A': if (indicator == 'R') type_str = "Not Race"; break;
case 'B': if (indicator == 'L') type_str = "Not Cell"; break;
case 'C': if (indicator == 's') type_str = "Not Local"; break;
default: break;
}
// Append the variable name to the function string if any.
if (type != '1') func_str = rule.substr(5);
if (type != '1')
func_str = rule.substr(5);
// In the previous switch, we assumed that the second char was X
// for all types not qual to one. If this wasn't true, go back to
@ -110,19 +146,33 @@ std::string ruleString(const ESM::DialInfo::SelectStruct& ss)
std::string oper_str = "??";
switch (oper)
{
case '0': oper_str = "=="; break;
case '1': oper_str = "!="; break;
case '2': oper_str = "> "; break;
case '3': oper_str = ">="; break;
case '4': oper_str = "< "; break;
case '5': oper_str = "<="; break;
default: break;
case '0':
oper_str = "==";
break;
case '1':
oper_str = "!=";
break;
case '2':
oper_str = "> ";
break;
case '3':
oper_str = ">=";
break;
case '4':
oper_str = "< ";
break;
case '5':
oper_str = "<=";
break;
default:
break;
}
std::ostringstream stream;
stream << ss.mValue;
std::string result = Misc::StringUtils::format("%-12s %-32s %2s %s", type_str, func_str, oper_str, stream.str());
std::string result
= Misc::StringUtils::format("%-12s %-32s %2s %s", type_str, func_str, oper_str, stream.str());
return result;
}
@ -131,16 +181,15 @@ void printEffectList(const ESM::EffectList& effects)
int i = 0;
for (const ESM::ENAMstruct& effect : effects.mList)
{
std::cout << " Effect[" << i << "]: " << magicEffectLabel(effect.mEffectID)
<< " (" << effect.mEffectID << ")" << std::endl;
std::cout << " Effect[" << i << "]: " << magicEffectLabel(effect.mEffectID) << " (" << effect.mEffectID
<< ")" << std::endl;
if (effect.mSkill != -1)
std::cout << " Skill: " << skillLabel(effect.mSkill)
<< " (" << (int)effect.mSkill << ")" << std::endl;
std::cout << " Skill: " << skillLabel(effect.mSkill) << " (" << (int)effect.mSkill << ")"
<< std::endl;
if (effect.mAttribute != -1)
std::cout << " Attribute: " << attributeLabel(effect.mAttribute)
<< " (" << (int)effect.mAttribute << ")" << std::endl;
std::cout << " Range: " << rangeTypeLabel(effect.mRange)
<< " (" << effect.mRange << ")" << std::endl;
std::cout << " Attribute: " << attributeLabel(effect.mAttribute) << " (" << (int)effect.mAttribute
<< ")" << std::endl;
std::cout << " Range: " << rangeTypeLabel(effect.mRange) << " (" << effect.mRange << ")" << std::endl;
// Area is always zero if range type is "Self"
if (effect.mRange != ESM::RT_Self)
std::cout << " Area: " << effect.mArea << std::endl;
@ -154,12 +203,10 @@ void printTransport(const std::vector<ESM::Transport::Dest>& transport)
{
for (const ESM::Transport::Dest& dest : transport)
{
std::cout << " Destination Position: "
<< Misc::StringUtils::format("%12.3f", dest.mPos.pos[0]) << ","
std::cout << " Destination Position: " << Misc::StringUtils::format("%12.3f", dest.mPos.pos[0]) << ","
<< Misc::StringUtils::format("%12.3f", dest.mPos.pos[1]) << ","
<< Misc::StringUtils::format("%12.3f", dest.mPos.pos[2]) << ")" << std::endl;
std::cout << " Destination Rotation: "
<< Misc::StringUtils::format("%9.6f", dest.mPos.rot[0]) << ","
std::cout << " Destination Rotation: " << Misc::StringUtils::format("%9.6f", dest.mPos.rot[0]) << ","
<< Misc::StringUtils::format("%9.6f", dest.mPos.rot[1]) << ","
<< Misc::StringUtils::format("%9.6f", dest.mPos.rot[2]) << ")" << std::endl;
if (!dest.mCellName.empty())
@ -169,7 +216,8 @@ void printTransport(const std::vector<ESM::Transport::Dest>& transport)
}
namespace EsmTool {
namespace EsmTool
{
std::unique_ptr<RecordBase> RecordBase::create(const ESM::NAME type)
{
@ -431,8 +479,7 @@ void Record<ESM::Armor>::print()
std::cout << " Script: " << mData.mScript << std::endl;
if (!mData.mEnchant.empty())
std::cout << " Enchantment: " << mData.mEnchant << std::endl;
std::cout << " Type: " << armorTypeLabel(mData.mData.mType)
<< " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Type: " << armorTypeLabel(mData.mData.mType) << " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Weight: " << mData.mData.mWeight << std::endl;
std::cout << " Value: " << mData.mData.mValue << std::endl;
std::cout << " Health: " << mData.mData.mHealth << std::endl;
@ -440,8 +487,7 @@ void Record<ESM::Armor>::print()
std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl;
for (const ESM::PartReference& part : mData.mParts.mParts)
{
std::cout << " Body Part: " << bodyPartLabel(part.mPart)
<< " (" << (int)(part.mPart) << ")" << std::endl;
std::cout << " Body Part: " << bodyPartLabel(part.mPart) << " (" << (int)(part.mPart) << ")" << std::endl;
std::cout << " Male Name: " << part.mMale << std::endl;
if (!part.mFemale.empty())
std::cout << " Female Name: " << part.mFemale << std::endl;
@ -457,8 +503,8 @@ void Record<ESM::Apparatus>::print()
std::cout << " Model: " << mData.mModel << std::endl;
std::cout << " Icon: " << mData.mIcon << std::endl;
std::cout << " Script: " << mData.mScript << std::endl;
std::cout << " Type: " << apparatusTypeLabel(mData.mData.mType)
<< " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Type: " << apparatusTypeLabel(mData.mData.mType) << " (" << mData.mData.mType << ")"
<< std::endl;
std::cout << " Weight: " << mData.mData.mWeight << std::endl;
std::cout << " Value: " << mData.mData.mValue << std::endl;
std::cout << " Quality: " << mData.mData.mQuality << std::endl;
@ -470,11 +516,11 @@ void Record<ESM::BodyPart>::print()
{
std::cout << " Race: " << mData.mRace << std::endl;
std::cout << " Model: " << mData.mModel << std::endl;
std::cout << " Type: " << meshTypeLabel(mData.mData.mType)
<< " (" << (int)mData.mData.mType << ")" << std::endl;
std::cout << " Type: " << meshTypeLabel(mData.mData.mType) << " (" << (int)mData.mData.mType << ")"
<< std::endl;
std::cout << " Flags: " << bodyPartFlags(mData.mData.mFlags) << std::endl;
std::cout << " Part: " << meshPartLabel(mData.mData.mPart)
<< " (" << (int)mData.mData.mPart << ")" << std::endl;
std::cout << " Part: " << meshPartLabel(mData.mData.mPart) << " (" << (int)mData.mData.mPart << ")"
<< std::endl;
std::cout << " Vampire: " << (int)mData.mData.mVampire << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl;
}
@ -529,11 +575,10 @@ void Record<ESM::Cell>::print()
std::cout << " Region: " << mData.mRegion << std::endl;
std::cout << " Flags: " << cellFlags(mData.mData.mFlags) << std::endl;
std::cout << " Coordinates: " << " (" << mData.getGridX() << ","
<< mData.getGridY() << ")" << std::endl;
std::cout << " Coordinates: "
<< " (" << mData.getGridX() << "," << mData.getGridY() << ")" << std::endl;
if (mData.mData.mFlags & ESM::Cell::Interior &&
!(mData.mData.mFlags & ESM::Cell::QuasiEx))
if (mData.mData.mFlags & ESM::Cell::Interior && !(mData.mData.mFlags & ESM::Cell::QuasiEx))
{
if (mData.hasAmbient())
{
@ -554,7 +599,6 @@ void Record<ESM::Cell>::print()
std::cout << " Water Level Int: " << mData.mWaterInt << std::endl;
std::cout << " RefId counter: " << mData.mRefNumCounter << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl;
}
template <>
@ -564,18 +608,18 @@ void Record<ESM::Class>::print()
std::cout << " Description: " << mData.mDescription << std::endl;
std::cout << " Playable: " << mData.mData.mIsPlayable << std::endl;
std::cout << " AutoCalc: " << mData.mData.mCalc << std::endl;
std::cout << " Attribute1: " << attributeLabel(mData.mData.mAttribute[0])
<< " (" << mData.mData.mAttribute[0] << ")" << std::endl;
std::cout << " Attribute2: " << attributeLabel(mData.mData.mAttribute[1])
<< " (" << mData.mData.mAttribute[1] << ")" << std::endl;
std::cout << " Specialization: " << specializationLabel(mData.mData.mSpecialization)
<< " (" << mData.mData.mSpecialization << ")" << std::endl;
std::cout << " Attribute1: " << attributeLabel(mData.mData.mAttribute[0]) << " (" << mData.mData.mAttribute[0]
<< ")" << std::endl;
std::cout << " Attribute2: " << attributeLabel(mData.mData.mAttribute[1]) << " (" << mData.mData.mAttribute[1]
<< ")" << std::endl;
std::cout << " Specialization: " << specializationLabel(mData.mData.mSpecialization) << " ("
<< mData.mData.mSpecialization << ")" << std::endl;
for (int i = 0; i != 5; i++)
std::cout << " Minor Skill: " << skillLabel(mData.mData.mSkills[i][0])
<< " (" << mData.mData.mSkills[i][0] << ")" << std::endl;
std::cout << " Minor Skill: " << skillLabel(mData.mData.mSkills[i][0]) << " (" << mData.mData.mSkills[i][0]
<< ")" << std::endl;
for (int i = 0; i != 5; i++)
std::cout << " Major Skill: " << skillLabel(mData.mData.mSkills[i][1])
<< " (" << mData.mData.mSkills[i][1] << ")" << std::endl;
std::cout << " Major Skill: " << skillLabel(mData.mData.mSkills[i][1]) << " (" << mData.mData.mSkills[i][1]
<< ")" << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl;
}
@ -589,15 +633,14 @@ void Record<ESM::Clothing>::print()
std::cout << " Script: " << mData.mScript << std::endl;
if (!mData.mEnchant.empty())
std::cout << " Enchantment: " << mData.mEnchant << std::endl;
std::cout << " Type: " << clothingTypeLabel(mData.mData.mType)
<< " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Type: " << clothingTypeLabel(mData.mData.mType) << " (" << mData.mData.mType << ")"
<< std::endl;
std::cout << " Weight: " << mData.mData.mWeight << std::endl;
std::cout << " Value: " << mData.mData.mValue << std::endl;
std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl;
for (const ESM::PartReference& part : mData.mParts.mParts)
{
std::cout << " Body Part: " << bodyPartLabel(part.mPart)
<< " (" << (int)(part.mPart) << ")" << std::endl;
std::cout << " Body Part: " << bodyPartLabel(part.mPart) << " (" << (int)(part.mPart) << ")" << std::endl;
std::cout << " Male Name: " << part.mMale << std::endl;
if (!part.mFemale.empty())
std::cout << " Female Name: " << part.mFemale << std::endl;
@ -631,8 +674,8 @@ void Record<ESM::Creature>::print()
std::cout << " Original: " << mData.mOriginal << std::endl;
std::cout << " Scale: " << mData.mScale << std::endl;
std::cout << " Type: " << creatureTypeLabel(mData.mData.mType)
<< " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Type: " << creatureTypeLabel(mData.mData.mType) << " (" << mData.mData.mType << ")"
<< std::endl;
std::cout << " Level: " << mData.mData.mLevel << std::endl;
std::cout << " Attributes:" << std::endl;
@ -652,12 +695,9 @@ void Record<ESM::Creature>::print()
std::cout << " Combat: " << mData.mData.mCombat << std::endl;
std::cout << " Magic: " << mData.mData.mMagic << std::endl;
std::cout << " Stealth: " << mData.mData.mStealth << std::endl;
std::cout << " Attack1: " << mData.mData.mAttack[0]
<< "-" << mData.mData.mAttack[1] << std::endl;
std::cout << " Attack2: " << mData.mData.mAttack[2]
<< "-" << mData.mData.mAttack[3] << std::endl;
std::cout << " Attack3: " << mData.mData.mAttack[4]
<< "-" << mData.mData.mAttack[5] << std::endl;
std::cout << " Attack1: " << mData.mData.mAttack[0] << "-" << mData.mData.mAttack[1] << std::endl;
std::cout << " Attack2: " << mData.mData.mAttack[2] << "-" << mData.mData.mAttack[3] << std::endl;
std::cout << " Attack3: " << mData.mData.mAttack[4] << "-" << mData.mData.mAttack[5] << std::endl;
std::cout << " Gold: " << mData.mData.mGold << std::endl;
for (const ESM::ContItem& item : mData.mInventory.mList)
@ -687,8 +727,7 @@ void Record<ESM::Creature>::print()
template <>
void Record<ESM::Dialogue>::print()
{
std::cout << " Type: " << dialogTypeLabel(mData.mType)
<< " (" << (int)mData.mType << ")" << std::endl;
std::cout << " Type: " << dialogTypeLabel(mData.mType) << " (" << (int)mData.mType << ")" << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl;
// Sadly, there are no DialInfos, because the loader dumps as it
// loads, rather than loading and then dumping. :-( Anyone mind if
@ -711,8 +750,7 @@ void Record<ESM::Door>::print()
template <>
void Record<ESM::Enchantment>::print()
{
std::cout << " Type: " << enchantTypeLabel(mData.mData.mType)
<< " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Type: " << enchantTypeLabel(mData.mData.mType) << " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Cost: " << mData.mData.mCost << std::endl;
std::cout << " Charge: " << mData.mData.mCharge << std::endl;
std::cout << " Flags: " << enchantmentFlags(mData.mData.mFlags) << std::endl;
@ -725,10 +763,10 @@ void Record<ESM::Faction>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Hidden: " << mData.mData.mIsHidden << std::endl;
std::cout << " Attribute1: " << attributeLabel(mData.mData.mAttribute[0])
<< " (" << mData.mData.mAttribute[0] << ")" << std::endl;
std::cout << " Attribute2: " << attributeLabel(mData.mData.mAttribute[1])
<< " (" << mData.mData.mAttribute[1] << ")" << std::endl;
std::cout << " Attribute1: " << attributeLabel(mData.mData.mAttribute[0]) << " (" << mData.mData.mAttribute[0]
<< ")" << std::endl;
std::cout << " Attribute2: " << attributeLabel(mData.mData.mAttribute[1]) << " (" << mData.mData.mAttribute[1]
<< ")" << std::endl;
for (int skill : mData.mData.mSkills)
if (skill != -1)
std::cout << " Skill: " << skillLabel(skill) << " (" << skill << ")" << std::endl;
@ -736,16 +774,11 @@ void Record<ESM::Faction>::print()
if (!mData.mRanks[i].empty())
{
std::cout << " Rank: " << mData.mRanks[i] << std::endl;
std::cout << " Attribute1 Requirement: "
<< mData.mData.mRankData[i].mAttribute1 << std::endl;
std::cout << " Attribute2 Requirement: "
<< mData.mData.mRankData[i].mAttribute2 << std::endl;
std::cout << " One Skill at Level: "
<< mData.mData.mRankData[i].mPrimarySkill << std::endl;
std::cout << " Two Skills at Level: "
<< mData.mData.mRankData[i].mFavouredSkill << std::endl;
std::cout << " Faction Reaction: "
<< mData.mData.mRankData[i].mFactReaction << std::endl;
std::cout << " Attribute1 Requirement: " << mData.mData.mRankData[i].mAttribute1 << std::endl;
std::cout << " Attribute2 Requirement: " << mData.mData.mRankData[i].mAttribute2 << std::endl;
std::cout << " One Skill at Level: " << mData.mData.mRankData[i].mPrimarySkill << std::endl;
std::cout << " Two Skills at Level: " << mData.mData.mRankData[i].mFavouredSkill << std::endl;
std::cout << " Faction Reaction: " << mData.mData.mRankData[i].mFactReaction << std::endl;
}
for (const auto& reaction : mData.mReactions)
std::cout << " Reaction: " << reaction.second << " = " << reaction.first << std::endl;
@ -799,9 +832,8 @@ void Record<ESM::DialInfo>::print()
if (!mData.mSound.empty())
std::cout << " Sound File: " << mData.mSound << std::endl;
std::cout << " Quest Status: " << questStatusLabel(mData.mQuestStatus)
<< " (" << mData.mQuestStatus << ")" << std::endl;
std::cout << " Quest Status: " << questStatusLabel(mData.mQuestStatus) << " (" << mData.mQuestStatus << ")"
<< std::endl;
std::cout << " Unknown1: " << mData.mData.mUnknown1 << std::endl;
std::cout << " Unknown2: " << (int)mData.mData.mUnknown2 << std::endl;
@ -838,13 +870,14 @@ void Record<ESM::Ingredient>::print()
for (int i = 0; i != 4; i++)
{
// A value of -1 means no effect
if (mData.mData.mEffectID[i] == -1) continue;
std::cout << " Effect: " << magicEffectLabel(mData.mData.mEffectID[i])
<< " (" << mData.mData.mEffectID[i] << ")" << std::endl;
std::cout << " Skill: " << skillLabel(mData.mData.mSkills[i])
<< " (" << mData.mData.mSkills[i] << ")" << std::endl;
std::cout << " Attribute: " << attributeLabel(mData.mData.mAttributes[i])
<< " (" << mData.mData.mAttributes[i] << ")" << std::endl;
if (mData.mData.mEffectID[i] == -1)
continue;
std::cout << " Effect: " << magicEffectLabel(mData.mData.mEffectID[i]) << " (" << mData.mData.mEffectID[i]
<< ")" << std::endl;
std::cout << " Skill: " << skillLabel(mData.mData.mSkills[i]) << " (" << mData.mData.mSkills[i] << ")"
<< std::endl;
std::cout << " Attribute: " << attributeLabel(mData.mData.mAttributes[i]) << " ("
<< mData.mData.mAttributes[i] << ")" << std::endl;
}
std::cout << " Deleted: " << mIsDeleted << std::endl;
}
@ -874,8 +907,7 @@ void Record<ESM::CreatureLevList>::print()
std::cout << " Flags: " << creatureListFlags(mData.mFlags) << std::endl;
std::cout << " Number of items: " << mData.mList.size() << std::endl;
for (const ESM::LevelledListBase::LevelItem& item : mData.mList)
std::cout << " Creature: Level: " << item.mLevel
<< " Creature: " << item.mId << std::endl;
std::cout << " Creature: Level: " << item.mLevel << " Creature: " << item.mId << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl;
}
@ -886,8 +918,7 @@ void Record<ESM::ItemLevList>::print()
std::cout << " Flags: " << itemListFlags(mData.mFlags) << std::endl;
std::cout << " Number of items: " << mData.mList.size() << std::endl;
for (const ESM::LevelledListBase::LevelItem& item : mData.mList)
std::cout << " Inventory: Level: " << item.mLevel
<< " Item: " << item.mId << std::endl;
std::cout << " Inventory: Level: " << item.mLevel << " Item: " << item.mId << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl;
}
@ -969,8 +1000,7 @@ void Record<ESM::LandTexture>::print()
template <>
void Record<ESM::MagicEffect>::print()
{
std::cout << " Index: " << magicEffectLabel(mData.mIndex)
<< " (" << mData.mIndex << ")" << std::endl;
std::cout << " Index: " << magicEffectLabel(mData.mIndex) << " (" << mData.mIndex << ")" << std::endl;
std::cout << " Description: " << mData.mDescription << std::endl;
std::cout << " Icon: " << mData.mIcon << std::endl;
std::cout << " Flags: " << magicEffectFlags(mData.mData.mFlags) << std::endl;
@ -991,16 +1021,15 @@ void Record<ESM::MagicEffect>::print()
std::cout << " Area Static: " << mData.mArea << std::endl;
if (!mData.mAreaSound.empty())
std::cout << " Area Sound: " << mData.mAreaSound << std::endl;
std::cout << " School: " << schoolLabel(mData.mData.mSchool)
<< " (" << mData.mData.mSchool << ")" << std::endl;
std::cout << " School: " << schoolLabel(mData.mData.mSchool) << " (" << mData.mData.mSchool << ")"
<< std::endl;
std::cout << " Base Cost: " << mData.mData.mBaseCost << std::endl;
std::cout << " Unknown 1: " << mData.mData.mUnknown1 << std::endl;
std::cout << " Speed: " << mData.mData.mSpeed << std::endl;
std::cout << " Unknown 2: " << mData.mData.mUnknown2 << std::endl;
std::cout << " RGB Color: " << "("
<< mData.mData.mRed << ","
<< mData.mData.mGreen << ","
<< mData.mData.mBlue << ")" << std::endl;
std::cout << " RGB Color: "
<< "(" << mData.mData.mRed << "," << mData.mData.mGreen << "," << mData.mData.mBlue << ")"
<< std::endl;
}
template <>
@ -1042,7 +1071,8 @@ void Record<ESM::NPC>::print()
std::cout << " Rank: " << (int)mData.mNpdt.mRank << std::endl;
std::cout << " Gold: " << mData.mNpdt.mGold << std::endl;
}
else {
else
{
std::cout << " Level: " << mData.mNpdt.mLevel << std::endl;
std::cout << " Reputation: " << (int)mData.mNpdt.mReputation << std::endl;
std::cout << " Disposition: " << (int)mData.mNpdt.mDisposition << std::endl;
@ -1060,8 +1090,7 @@ void Record<ESM::NPC>::print()
std::cout << " Skills:" << std::endl;
for (int i = 0; i != ESM::Skill::Length; i++)
std::cout << " " << skillLabel(i) << ": "
<< (int)(mData.mNpdt.mSkills[i]) << std::endl;
std::cout << " " << skillLabel(i) << ": " << (int)(mData.mNpdt.mSkills[i]) << std::endl;
std::cout << " Health: " << mData.mNpdt.mHealth << std::endl;
std::cout << " Magicka: " << mData.mNpdt.mMana << std::endl;
@ -1109,8 +1138,7 @@ void Record<ESM::Pathgrid>::print()
for (const ESM::Pathgrid::Point& point : mData.mPoints)
{
std::cout << " Point[" << i << "]:" << std::endl;
std::cout << " Coordinates: (" << point.mX << ","
<< point.mY << "," << point.mZ << ")" << std::endl;
std::cout << " Coordinates: (" << point.mX << "," << point.mY << "," << point.mZ << ")" << std::endl;
std::cout << " Auto-Generated: " << (int)point.mAutogenerated << std::endl;
std::cout << " Connections: " << (int)point.mConnectionNum << std::endl;
std::cout << " Unknown: " << point.mUnknown << std::endl;
@ -1132,11 +1160,8 @@ void Record<ESM::Pathgrid>::print()
template <>
void Record<ESM::Race>::print()
{
static const char *sAttributeNames[8] =
{
"Strength", "Intelligence", "Willpower", "Agility",
"Speed", "Endurance", "Personality", "Luck"
};
static const char* sAttributeNames[8]
= { "Strength", "Intelligence", "Willpower", "Agility", "Speed", "Endurance", "Personality", "Luck" };
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Description: " << mData.mDescription << std::endl;
@ -1149,8 +1174,8 @@ void Record<ESM::Race>::print()
std::cout << (male ? " Male:" : " Female:") << std::endl;
for (int j = 0; j < 8; ++j)
std::cout << " " << sAttributeNames[j] << ": "
<< mData.mData.mAttributeValues[j].getValue (male) << std::endl;
std::cout << " " << sAttributeNames[j] << ": " << mData.mData.mAttributeValues[j].getValue(male)
<< std::endl;
std::cout << " Height: " << mData.mData.mHeight.getValue(male) << std::endl;
std::cout << " Weight: " << mData.mData.mWeight.getValue(male) << std::endl;
@ -1159,10 +1184,8 @@ void Record<ESM::Race>::print()
for (int i = 0; i != 7; i++)
// Not all races have 7 skills.
if (mData.mData.mBonus[i].mSkill != -1)
std::cout << " Skill: "
<< skillLabel(mData.mData.mBonus[i].mSkill)
<< " (" << mData.mData.mBonus[i].mSkill << ") = "
<< mData.mData.mBonus[i].mBonus << std::endl;
std::cout << " Skill: " << skillLabel(mData.mData.mBonus[i].mSkill) << " ("
<< mData.mData.mBonus[i].mSkill << ") = " << mData.mData.mBonus[i].mBonus << std::endl;
for (const std::string& power : mData.mPowers.mList)
std::cout << " Power: " << power << std::endl;
@ -1230,13 +1253,12 @@ void Record<ESM::Script>::print()
template <>
void Record<ESM::Skill>::print()
{
std::cout << " ID: " << skillLabel(mData.mIndex)
<< " (" << mData.mIndex << ")" << std::endl;
std::cout << " ID: " << skillLabel(mData.mIndex) << " (" << mData.mIndex << ")" << std::endl;
std::cout << " Description: " << mData.mDescription << std::endl;
std::cout << " Governing Attribute: " << attributeLabel(mData.mData.mAttribute)
<< " (" << mData.mData.mAttribute << ")" << std::endl;
std::cout << " Specialization: " << specializationLabel(mData.mData.mSpecialization)
<< " (" << mData.mData.mSpecialization << ")" << std::endl;
std::cout << " Governing Attribute: " << attributeLabel(mData.mData.mAttribute) << " ("
<< mData.mData.mAttribute << ")" << std::endl;
std::cout << " Specialization: " << specializationLabel(mData.mData.mSpecialization) << " ("
<< mData.mData.mSpecialization << ")" << std::endl;
for (int i = 0; i != 4; i++)
std::cout << " UseValue[" << i << "]:" << mData.mData.mUseValue[i] << std::endl;
}
@ -1247,8 +1269,7 @@ void Record<ESM::SoundGenerator>::print()
if (!mData.mCreature.empty())
std::cout << " Creature: " << mData.mCreature << std::endl;
std::cout << " Sound: " << mData.mSound << std::endl;
std::cout << " Type: " << soundTypeLabel(mData.mType)
<< " (" << mData.mType << ")" << std::endl;
std::cout << " Type: " << soundTypeLabel(mData.mType) << " (" << mData.mType << ")" << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl;
}
@ -1258,8 +1279,7 @@ void Record<ESM::Sound>::print()
std::cout << " Sound: " << mData.mSound << std::endl;
std::cout << " Volume: " << (int)mData.mData.mVolume << std::endl;
if (mData.mData.mMinRange != 0 && mData.mData.mMaxRange != 0)
std::cout << " Range: " << (int)mData.mData.mMinRange << " - "
<< (int)mData.mData.mMaxRange << std::endl;
std::cout << " Range: " << (int)mData.mData.mMinRange << " - " << (int)mData.mData.mMaxRange << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl;
}
@ -1267,8 +1287,7 @@ template<>
void Record<ESM::Spell>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Type: " << spellTypeLabel(mData.mData.mType)
<< " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Type: " << spellTypeLabel(mData.mData.mType) << " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Flags: " << spellFlags(mData.mData.mFlags) << std::endl;
std::cout << " Cost: " << mData.mData.mCost << std::endl;
printEffectList(mData.mEffects);
@ -1303,8 +1322,7 @@ void Record<ESM::Weapon>::print()
std::cout << " Script: " << mData.mScript << std::endl;
if (!mData.mEnchant.empty())
std::cout << " Enchantment: " << mData.mEnchant << std::endl;
std::cout << " Type: " << weaponTypeLabel(mData.mData.mType)
<< " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Type: " << weaponTypeLabel(mData.mData.mType) << " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Flags: " << weaponFlags(mData.mData.mFlags) << std::endl;
std::cout << " Weight: " << mData.mData.mWeight << std::endl;
std::cout << " Value: " << mData.mData.mValue << std::endl;
@ -1313,14 +1331,11 @@ void Record<ESM::Weapon>::print()
std::cout << " Reach: " << mData.mData.mReach << std::endl;
std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl;
if (mData.mData.mChop[0] != 0 && mData.mData.mChop[1] != 0)
std::cout << " Chop: " << (int)mData.mData.mChop[0] << "-"
<< (int)mData.mData.mChop[1] << std::endl;
std::cout << " Chop: " << (int)mData.mData.mChop[0] << "-" << (int)mData.mData.mChop[1] << std::endl;
if (mData.mData.mSlash[0] != 0 && mData.mData.mSlash[1] != 0)
std::cout << " Slash: " << (int)mData.mData.mSlash[0] << "-"
<< (int)mData.mData.mSlash[1] << std::endl;
std::cout << " Slash: " << (int)mData.mData.mSlash[0] << "-" << (int)mData.mData.mSlash[1] << std::endl;
if (mData.mData.mThrust[0] != 0 && mData.mData.mThrust[1] != 0)
std::cout << " Thrust: " << (int)mData.mData.mThrust[0] << "-"
<< (int)mData.mData.mThrust[1] << std::endl;
std::cout << " Thrust: " << (int)mData.mData.mThrust[0] << "-" << (int)mData.mData.mThrust[1] << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl;
}

@ -1,8 +1,8 @@
#ifndef OPENMW_ESMTOOL_RECORD_H
#define OPENMW_ESMTOOL_RECORD_H
#include <string>
#include <memory>
#include <string>
#include <components/esm/records.hpp>
@ -14,7 +14,8 @@ namespace ESM
namespace EsmTool
{
template <class T> class Record;
template <class T>
class Record;
class RecordBase
{
@ -35,21 +36,13 @@ namespace EsmTool
virtual std::string getId() const = 0;
uint32_t getFlags() const {
return mFlags;
}
uint32_t getFlags() const { return mFlags; }
void setFlags(uint32_t flags) {
mFlags = flags;
}
void setFlags(uint32_t flags) { mFlags = flags; }
ESM::NAME getType() const {
return mType;
}
ESM::NAME getType() const { return mType; }
void setPrintPlain(bool plain) {
mPrintPlain = plain;
}
void setPrintPlain(bool plain) { mPrintPlain = plain; }
virtual void load(ESM::ESMReader& esm) = 0;
virtual void save(ESM::ESMWriter& esm) = 0;
@ -59,7 +52,8 @@ namespace EsmTool
// just make it a bit shorter
template <class T>
Record<T> *cast() {
Record<T>* cast()
{
return static_cast<Record<T>*>(this);
}
};
@ -73,75 +67,115 @@ namespace EsmTool
public:
Record()
: mIsDeleted(false)
{}
std::string getId() const override {
return mData.mId;
{
}
T &get() {
return mData;
}
std::string getId() const override { return mData.mId; }
void save(ESM::ESMWriter &esm) override {
mData.save(esm, mIsDeleted);
}
T& get() { return mData; }
void load(ESM::ESMReader &esm) override {
mData.load(esm, mIsDeleted);
}
void save(ESM::ESMWriter& esm) override { mData.save(esm, mIsDeleted); }
void load(ESM::ESMReader& esm) override { mData.load(esm, mIsDeleted); }
void print() override;
};
template<> std::string Record<ESM::Cell>::getId() const;
template<> std::string Record<ESM::Land>::getId() const;
template<> std::string Record<ESM::MagicEffect>::getId() const;
template<> std::string Record<ESM::Pathgrid>::getId() const;
template<> std::string Record<ESM::Skill>::getId() const;
template<> void Record<ESM::Activator>::print();
template<> void Record<ESM::Potion>::print();
template<> void Record<ESM::Armor>::print();
template<> void Record<ESM::Apparatus>::print();
template<> void Record<ESM::BodyPart>::print();
template<> void Record<ESM::Book>::print();
template<> void Record<ESM::BirthSign>::print();
template<> void Record<ESM::Cell>::print();
template<> void Record<ESM::Class>::print();
template<> void Record<ESM::Clothing>::print();
template<> void Record<ESM::Container>::print();
template<> void Record<ESM::Creature>::print();
template<> void Record<ESM::Dialogue>::print();
template<> void Record<ESM::Door>::print();
template<> void Record<ESM::Enchantment>::print();
template<> void Record<ESM::Faction>::print();
template<> void Record<ESM::Global>::print();
template<> void Record<ESM::GameSetting>::print();
template<> void Record<ESM::DialInfo>::print();
template<> void Record<ESM::Ingredient>::print();
template<> void Record<ESM::Land>::print();
template<> void Record<ESM::CreatureLevList>::print();
template<> void Record<ESM::ItemLevList>::print();
template<> void Record<ESM::Light>::print();
template<> void Record<ESM::Lockpick>::print();
template<> void Record<ESM::Probe>::print();
template<> void Record<ESM::Repair>::print();
template<> void Record<ESM::LandTexture>::print();
template<> void Record<ESM::MagicEffect>::print();
template<> void Record<ESM::Miscellaneous>::print();
template<> void Record<ESM::NPC>::print();
template<> void Record<ESM::Pathgrid>::print();
template<> void Record<ESM::Race>::print();
template<> void Record<ESM::Region>::print();
template<> void Record<ESM::Script>::print();
template<> void Record<ESM::Skill>::print();
template<> void Record<ESM::SoundGenerator>::print();
template<> void Record<ESM::Sound>::print();
template<> void Record<ESM::Spell>::print();
template<> void Record<ESM::StartScript>::print();
template<> void Record<ESM::Static>::print();
template<> void Record<ESM::Weapon>::print();
template <>
std::string Record<ESM::Cell>::getId() const;
template <>
std::string Record<ESM::Land>::getId() const;
template <>
std::string Record<ESM::MagicEffect>::getId() const;
template <>
std::string Record<ESM::Pathgrid>::getId() const;
template <>
std::string Record<ESM::Skill>::getId() const;
template <>
void Record<ESM::Activator>::print();
template <>
void Record<ESM::Potion>::print();
template <>
void Record<ESM::Armor>::print();
template <>
void Record<ESM::Apparatus>::print();
template <>
void Record<ESM::BodyPart>::print();
template <>
void Record<ESM::Book>::print();
template <>
void Record<ESM::BirthSign>::print();
template <>
void Record<ESM::Cell>::print();
template <>
void Record<ESM::Class>::print();
template <>
void Record<ESM::Clothing>::print();
template <>
void Record<ESM::Container>::print();
template <>
void Record<ESM::Creature>::print();
template <>
void Record<ESM::Dialogue>::print();
template <>
void Record<ESM::Door>::print();
template <>
void Record<ESM::Enchantment>::print();
template <>
void Record<ESM::Faction>::print();
template <>
void Record<ESM::Global>::print();
template <>
void Record<ESM::GameSetting>::print();
template <>
void Record<ESM::DialInfo>::print();
template <>
void Record<ESM::Ingredient>::print();
template <>
void Record<ESM::Land>::print();
template <>
void Record<ESM::CreatureLevList>::print();
template <>
void Record<ESM::ItemLevList>::print();
template <>
void Record<ESM::Light>::print();
template <>
void Record<ESM::Lockpick>::print();
template <>
void Record<ESM::Probe>::print();
template <>
void Record<ESM::Repair>::print();
template <>
void Record<ESM::LandTexture>::print();
template <>
void Record<ESM::MagicEffect>::print();
template <>
void Record<ESM::Miscellaneous>::print();
template <>
void Record<ESM::NPC>::print();
template <>
void Record<ESM::Pathgrid>::print();
template <>
void Record<ESM::Race>::print();
template <>
void Record<ESM::Region>::print();
template <>
void Record<ESM::Script>::print();
template <>
void Record<ESM::Skill>::print();
template <>
void Record<ESM::SoundGenerator>::print();
template <>
void Record<ESM::Sound>::print();
template <>
void Record<ESM::Spell>::print();
template <>
void Record<ESM::StartScript>::print();
template <>
void Record<ESM::Static>::print();
template <>
void Record<ESM::Weapon>::print();
}
#endif

@ -21,79 +21,115 @@ namespace EsmTool
explicit Params(const Arguments& info)
: mQuite(info.quiet_given || info.mode == "clone")
{}
{
}
};
std::string toString(ESM4::GroupType type)
{
switch (type)
{
case ESM4::Grp_RecordType: return "RecordType";
case ESM4::Grp_WorldChild: return "WorldChild";
case ESM4::Grp_InteriorCell: return "InteriorCell";
case ESM4::Grp_InteriorSubCell: return "InteriorSubCell";
case ESM4::Grp_ExteriorCell: return "ExteriorCell";
case ESM4::Grp_ExteriorSubCell: return "ExteriorSubCell";
case ESM4::Grp_CellChild: return "CellChild";
case ESM4::Grp_TopicChild: return "TopicChild";
case ESM4::Grp_CellPersistentChild: return "CellPersistentChild";
case ESM4::Grp_CellTemporaryChild: return "CellTemporaryChild";
case ESM4::Grp_CellVisibleDistChild: return "CellVisibleDistChild";
case ESM4::Grp_RecordType:
return "RecordType";
case ESM4::Grp_WorldChild:
return "WorldChild";
case ESM4::Grp_InteriorCell:
return "InteriorCell";
case ESM4::Grp_InteriorSubCell:
return "InteriorSubCell";
case ESM4::Grp_ExteriorCell:
return "ExteriorCell";
case ESM4::Grp_ExteriorSubCell:
return "ExteriorSubCell";
case ESM4::Grp_CellChild:
return "CellChild";
case ESM4::Grp_TopicChild:
return "TopicChild";
case ESM4::Grp_CellPersistentChild:
return "CellPersistentChild";
case ESM4::Grp_CellTemporaryChild:
return "CellTemporaryChild";
case ESM4::Grp_CellVisibleDistChild:
return "CellVisibleDistChild";
}
return "Unknown (" + std::to_string(type) + ")";
}
template <class T, class = std::void_t<>>
struct HasFormId : std::false_type {};
struct HasFormId : std::false_type
{
};
template <class T>
struct HasFormId<T, std::void_t<decltype(T::mFormId)>> : std::true_type {};
struct HasFormId<T, std::void_t<decltype(T::mFormId)>> : std::true_type
{
};
template <class T>
constexpr bool hasFormId = HasFormId<T>::value;
template <class T, class = std::void_t<>>
struct HasFlags : std::false_type {};
struct HasFlags : std::false_type
{
};
template <class T>
struct HasFlags<T, std::void_t<decltype(T::mFlags)>> : std::true_type {};
struct HasFlags<T, std::void_t<decltype(T::mFlags)>> : std::true_type
{
};
template <class T>
constexpr bool hasFlags = HasFlags<T>::value;
template <class T, class = std::void_t<>>
struct HasEditorId : std::false_type {};
struct HasEditorId : std::false_type
{
};
template <class T>
struct HasEditorId<T, std::void_t<decltype(T::mEditorId)>> : std::true_type {};
struct HasEditorId<T, std::void_t<decltype(T::mEditorId)>> : std::true_type
{
};
template <class T>
constexpr bool hasEditorId = HasEditorId<T>::value;
template <class T, class = std::void_t<>>
struct HasModel : std::false_type {};
struct HasModel : std::false_type
{
};
template <class T>
struct HasModel<T, std::void_t<decltype(T::mModel)>> : std::true_type {};
struct HasModel<T, std::void_t<decltype(T::mModel)>> : std::true_type
{
};
template <class T>
constexpr bool hasModel = HasModel<T>::value;
template <class T, class = std::void_t<>>
struct HasNif : std::false_type {};
struct HasNif : std::false_type
{
};
template <class T>
struct HasNif<T, std::void_t<decltype(T::mNif)>> : std::true_type {};
struct HasNif<T, std::void_t<decltype(T::mNif)>> : std::true_type
{
};
template <class T>
constexpr bool hasNif = HasNif<T>::value;
template <class T, class = std::void_t<>>
struct HasKf : std::false_type {};
struct HasKf : std::false_type
{
};
template <class T>
struct HasKf<T, std::void_t<decltype(T::mKf)>> : std::true_type {};
struct HasKf<T, std::void_t<decltype(T::mKf)>> : std::true_type
{
};
template <class T>
constexpr bool hasKf = HasKf<T>::value;
@ -150,148 +186,286 @@ namespace EsmTool
{
switch (static_cast<ESM4::RecordTypes>(reader.hdr().record.typeId))
{
case ESM4::REC_AACT: break;
case ESM4::REC_ACHR: return readTypedRecord<ESM4::ActorCharacter>(params, reader);
case ESM4::REC_ACRE: return readTypedRecord<ESM4::ActorCreature>(params, reader);
case ESM4::REC_ACTI: return readTypedRecord<ESM4::Activator>(params, reader);
case ESM4::REC_ADDN: break;
case ESM4::REC_ALCH: return readTypedRecord<ESM4::Potion>(params, reader);
case ESM4::REC_ALOC: return readTypedRecord<ESM4::MediaLocationController>(params, reader);
case ESM4::REC_AMMO: return readTypedRecord<ESM4::Ammunition>(params, reader);
case ESM4::REC_ANIO: return readTypedRecord<ESM4::AnimObject>(params, reader);
case ESM4::REC_APPA: return readTypedRecord<ESM4::Apparatus>(params, reader);
case ESM4::REC_ARMA: return readTypedRecord<ESM4::ArmorAddon>(params, reader);
case ESM4::REC_ARMO: return readTypedRecord<ESM4::Armor>(params, reader);
case ESM4::REC_ARTO: break;
case ESM4::REC_ASPC: return readTypedRecord<ESM4::AcousticSpace>(params, reader);
case ESM4::REC_ASTP: break;
case ESM4::REC_AVIF: break;
case ESM4::REC_BOOK: return readTypedRecord<ESM4::Book>(params, reader);
case ESM4::REC_BPTD: return readTypedRecord<ESM4::BodyPartData>(params, reader);
case ESM4::REC_CAMS: break;
case ESM4::REC_CCRD: break;
case ESM4::REC_CELL: return readTypedRecord<ESM4::Cell>(params, reader);
case ESM4::REC_CLAS: return readTypedRecord<ESM4::Class>(params, reader);
case ESM4::REC_CLFM: return readTypedRecord<ESM4::Colour>(params, reader);
case ESM4::REC_CLMT: break;
case ESM4::REC_CLOT: return readTypedRecord<ESM4::Clothing>(params, reader);
case ESM4::REC_CMNY: break;
case ESM4::REC_COBJ: break;
case ESM4::REC_COLL: break;
case ESM4::REC_CONT: return readTypedRecord<ESM4::Container>(params, reader);
case ESM4::REC_CPTH: break;
case ESM4::REC_CREA: return readTypedRecord<ESM4::Creature>(params, reader);
case ESM4::REC_CSTY: break;
case ESM4::REC_DEBR: break;
case ESM4::REC_DIAL: return readTypedRecord<ESM4::Dialogue>(params, reader);
case ESM4::REC_DLBR: break;
case ESM4::REC_DLVW: break;
case ESM4::REC_DOBJ: return readTypedRecord<ESM4::DefaultObj>(params, reader);
case ESM4::REC_DOOR: return readTypedRecord<ESM4::Door>(params, reader);
case ESM4::REC_DUAL: break;
case ESM4::REC_ECZN: break;
case ESM4::REC_EFSH: break;
case ESM4::REC_ENCH: break;
case ESM4::REC_EQUP: break;
case ESM4::REC_EXPL: break;
case ESM4::REC_EYES: return readTypedRecord<ESM4::Eyes>(params, reader);
case ESM4::REC_FACT: break;
case ESM4::REC_FLOR: return readTypedRecord<ESM4::Flora>(params, reader);
case ESM4::REC_FLST: return readTypedRecord<ESM4::FormIdList>(params, reader);
case ESM4::REC_FSTP: break;
case ESM4::REC_FSTS: break;
case ESM4::REC_FURN: return readTypedRecord<ESM4::Furniture>(params, reader);
case ESM4::REC_GLOB: return readTypedRecord<ESM4::GlobalVariable>(params, reader);
case ESM4::REC_GMST: break;
case ESM4::REC_GRAS: return readTypedRecord<ESM4::Grass>(params, reader);
case ESM4::REC_GRUP: break;
case ESM4::REC_HAIR: return readTypedRecord<ESM4::Hair>(params, reader);
case ESM4::REC_HAZD: break;
case ESM4::REC_HDPT: return readTypedRecord<ESM4::HeadPart>(params, reader);
case ESM4::REC_AACT:
break;
case ESM4::REC_ACHR:
return readTypedRecord<ESM4::ActorCharacter>(params, reader);
case ESM4::REC_ACRE:
return readTypedRecord<ESM4::ActorCreature>(params, reader);
case ESM4::REC_ACTI:
return readTypedRecord<ESM4::Activator>(params, reader);
case ESM4::REC_ADDN:
break;
case ESM4::REC_ALCH:
return readTypedRecord<ESM4::Potion>(params, reader);
case ESM4::REC_ALOC:
return readTypedRecord<ESM4::MediaLocationController>(params, reader);
case ESM4::REC_AMMO:
return readTypedRecord<ESM4::Ammunition>(params, reader);
case ESM4::REC_ANIO:
return readTypedRecord<ESM4::AnimObject>(params, reader);
case ESM4::REC_APPA:
return readTypedRecord<ESM4::Apparatus>(params, reader);
case ESM4::REC_ARMA:
return readTypedRecord<ESM4::ArmorAddon>(params, reader);
case ESM4::REC_ARMO:
return readTypedRecord<ESM4::Armor>(params, reader);
case ESM4::REC_ARTO:
break;
case ESM4::REC_ASPC:
return readTypedRecord<ESM4::AcousticSpace>(params, reader);
case ESM4::REC_ASTP:
break;
case ESM4::REC_AVIF:
break;
case ESM4::REC_BOOK:
return readTypedRecord<ESM4::Book>(params, reader);
case ESM4::REC_BPTD:
return readTypedRecord<ESM4::BodyPartData>(params, reader);
case ESM4::REC_CAMS:
break;
case ESM4::REC_CCRD:
break;
case ESM4::REC_CELL:
return readTypedRecord<ESM4::Cell>(params, reader);
case ESM4::REC_CLAS:
return readTypedRecord<ESM4::Class>(params, reader);
case ESM4::REC_CLFM:
return readTypedRecord<ESM4::Colour>(params, reader);
case ESM4::REC_CLMT:
break;
case ESM4::REC_CLOT:
return readTypedRecord<ESM4::Clothing>(params, reader);
case ESM4::REC_CMNY:
break;
case ESM4::REC_COBJ:
break;
case ESM4::REC_COLL:
break;
case ESM4::REC_CONT:
return readTypedRecord<ESM4::Container>(params, reader);
case ESM4::REC_CPTH:
break;
case ESM4::REC_CREA:
return readTypedRecord<ESM4::Creature>(params, reader);
case ESM4::REC_CSTY:
break;
case ESM4::REC_DEBR:
break;
case ESM4::REC_DIAL:
return readTypedRecord<ESM4::Dialogue>(params, reader);
case ESM4::REC_DLBR:
break;
case ESM4::REC_DLVW:
break;
case ESM4::REC_DOBJ:
return readTypedRecord<ESM4::DefaultObj>(params, reader);
case ESM4::REC_DOOR:
return readTypedRecord<ESM4::Door>(params, reader);
case ESM4::REC_DUAL:
break;
case ESM4::REC_ECZN:
break;
case ESM4::REC_EFSH:
break;
case ESM4::REC_ENCH:
break;
case ESM4::REC_EQUP:
break;
case ESM4::REC_EXPL:
break;
case ESM4::REC_EYES:
return readTypedRecord<ESM4::Eyes>(params, reader);
case ESM4::REC_FACT:
break;
case ESM4::REC_FLOR:
return readTypedRecord<ESM4::Flora>(params, reader);
case ESM4::REC_FLST:
return readTypedRecord<ESM4::FormIdList>(params, reader);
case ESM4::REC_FSTP:
break;
case ESM4::REC_FSTS:
break;
case ESM4::REC_FURN:
return readTypedRecord<ESM4::Furniture>(params, reader);
case ESM4::REC_GLOB:
return readTypedRecord<ESM4::GlobalVariable>(params, reader);
case ESM4::REC_GMST:
break;
case ESM4::REC_GRAS:
return readTypedRecord<ESM4::Grass>(params, reader);
case ESM4::REC_GRUP:
break;
case ESM4::REC_HAIR:
return readTypedRecord<ESM4::Hair>(params, reader);
case ESM4::REC_HAZD:
break;
case ESM4::REC_HDPT:
return readTypedRecord<ESM4::HeadPart>(params, reader);
case ESM4::REC_IDLE:
// FIXME: ESM4::IdleAnimation::load does not work with Oblivion.esm
// return readTypedRecord<ESM4::IdleAnimation>(params, reader);
break;
case ESM4::REC_IDLM: return readTypedRecord<ESM4::IdleMarker>(params, reader);
case ESM4::REC_IMAD: break;
case ESM4::REC_IMGS: break;
case ESM4::REC_IMOD: return readTypedRecord<ESM4::ItemMod>(params, reader);
case ESM4::REC_INFO: return readTypedRecord<ESM4::DialogInfo>(params, reader);
case ESM4::REC_INGR: return readTypedRecord<ESM4::Ingredient>(params, reader);
case ESM4::REC_IPCT: break;
case ESM4::REC_IPDS: break;
case ESM4::REC_KEYM: return readTypedRecord<ESM4::Key>(params, reader);
case ESM4::REC_KYWD: break;
case ESM4::REC_LAND: return readTypedRecord<ESM4::Land>(params, reader);
case ESM4::REC_LCRT: break;
case ESM4::REC_LCTN: break;
case ESM4::REC_LGTM: return readTypedRecord<ESM4::LightingTemplate>(params, reader);
case ESM4::REC_LIGH: return readTypedRecord<ESM4::Light>(params, reader);
case ESM4::REC_LSCR: break;
case ESM4::REC_LTEX: return readTypedRecord<ESM4::LandTexture>(params, reader);
case ESM4::REC_LVLC: return readTypedRecord<ESM4::LevelledCreature>(params, reader);
case ESM4::REC_LVLI: return readTypedRecord<ESM4::LevelledItem>(params, reader);
case ESM4::REC_LVLN: return readTypedRecord<ESM4::LevelledNpc>(params, reader);
case ESM4::REC_LVSP: break;
case ESM4::REC_MATO: return readTypedRecord<ESM4::Material>(params, reader);
case ESM4::REC_MATT: break;
case ESM4::REC_MESG: break;
case ESM4::REC_MGEF: break;
case ESM4::REC_MISC: return readTypedRecord<ESM4::MiscItem>(params, reader);
case ESM4::REC_MOVT: break;
case ESM4::REC_MSET: return readTypedRecord<ESM4::MediaSet>(params, reader);
case ESM4::REC_MSTT: return readTypedRecord<ESM4::MovableStatic>(params, reader);
case ESM4::REC_MUSC: return readTypedRecord<ESM4::Music>(params, reader);
case ESM4::REC_MUST: break;
case ESM4::REC_NAVI: return readTypedRecord<ESM4::Navigation>(params, reader);
case ESM4::REC_NAVM: return readTypedRecord<ESM4::NavMesh>(params, reader);
case ESM4::REC_NOTE: return readTypedRecord<ESM4::Note>(params, reader);
case ESM4::REC_NPC_: return readTypedRecord<ESM4::Npc>(params, reader);
case ESM4::REC_OTFT: return readTypedRecord<ESM4::Outfit>(params, reader);
case ESM4::REC_PACK: return readTypedRecord<ESM4::AIPackage>(params, reader);
case ESM4::REC_PERK: break;
case ESM4::REC_PGRD: return readTypedRecord<ESM4::Pathgrid>(params, reader);
case ESM4::REC_PGRE: return readTypedRecord<ESM4::PlacedGrenade>(params, reader);
case ESM4::REC_PHZD: break;
case ESM4::REC_PROJ: break;
case ESM4::REC_PWAT: return readTypedRecord<ESM4::PlaceableWater>(params, reader);
case ESM4::REC_QUST: return readTypedRecord<ESM4::Quest>(params, reader);
case ESM4::REC_RACE: return readTypedRecord<ESM4::Race>(params, reader);
case ESM4::REC_REFR: return readTypedRecord<ESM4::Reference>(params, reader);
case ESM4::REC_REGN: return readTypedRecord<ESM4::Region>(params, reader);
case ESM4::REC_RELA: break;
case ESM4::REC_REVB: break;
case ESM4::REC_RFCT: break;
case ESM4::REC_ROAD: return readTypedRecord<ESM4::Road>(params, reader);
case ESM4::REC_SBSP: return readTypedRecord<ESM4::SubSpace>(params, reader);
case ESM4::REC_SCEN: break;
case ESM4::REC_SCOL: return readTypedRecord<ESM4::StaticCollection>(params, reader);
case ESM4::REC_SCPT: return readTypedRecord<ESM4::Script>(params, reader);
case ESM4::REC_SCRL: return readTypedRecord<ESM4::Scroll>(params, reader);
case ESM4::REC_SGST: return readTypedRecord<ESM4::SigilStone>(params, reader);
case ESM4::REC_SHOU: break;
case ESM4::REC_SLGM: return readTypedRecord<ESM4::SoulGem>(params, reader);
case ESM4::REC_SMBN: break;
case ESM4::REC_SMEN: break;
case ESM4::REC_SMQN: break;
case ESM4::REC_SNCT: break;
case ESM4::REC_SNDR: return readTypedRecord<ESM4::SoundReference>(params, reader);
case ESM4::REC_SOPM: break;
case ESM4::REC_SOUN: return readTypedRecord<ESM4::Sound>(params, reader);
case ESM4::REC_SPEL: break;
case ESM4::REC_SPGD: break;
case ESM4::REC_STAT: return readTypedRecord<ESM4::Static>(params, reader);
case ESM4::REC_TACT: return readTypedRecord<ESM4::TalkingActivator>(params, reader);
case ESM4::REC_TERM: return readTypedRecord<ESM4::Terminal>(params, reader);
case ESM4::REC_TES4: return readTypedRecord<ESM4::Header>(params, reader);
case ESM4::REC_TREE: return readTypedRecord<ESM4::Tree>(params, reader);
case ESM4::REC_TXST: return readTypedRecord<ESM4::TextureSet>(params, reader);
case ESM4::REC_VTYP: break;
case ESM4::REC_WATR: break;
case ESM4::REC_WEAP: return readTypedRecord<ESM4::Weapon>(params, reader);
case ESM4::REC_WOOP: break;
case ESM4::REC_WRLD: return readTypedRecord<ESM4::World>(params, reader);
case ESM4::REC_WTHR: break;
case ESM4::REC_IDLM:
return readTypedRecord<ESM4::IdleMarker>(params, reader);
case ESM4::REC_IMAD:
break;
case ESM4::REC_IMGS:
break;
case ESM4::REC_IMOD:
return readTypedRecord<ESM4::ItemMod>(params, reader);
case ESM4::REC_INFO:
return readTypedRecord<ESM4::DialogInfo>(params, reader);
case ESM4::REC_INGR:
return readTypedRecord<ESM4::Ingredient>(params, reader);
case ESM4::REC_IPCT:
break;
case ESM4::REC_IPDS:
break;
case ESM4::REC_KEYM:
return readTypedRecord<ESM4::Key>(params, reader);
case ESM4::REC_KYWD:
break;
case ESM4::REC_LAND:
return readTypedRecord<ESM4::Land>(params, reader);
case ESM4::REC_LCRT:
break;
case ESM4::REC_LCTN:
break;
case ESM4::REC_LGTM:
return readTypedRecord<ESM4::LightingTemplate>(params, reader);
case ESM4::REC_LIGH:
return readTypedRecord<ESM4::Light>(params, reader);
case ESM4::REC_LSCR:
break;
case ESM4::REC_LTEX:
return readTypedRecord<ESM4::LandTexture>(params, reader);
case ESM4::REC_LVLC:
return readTypedRecord<ESM4::LevelledCreature>(params, reader);
case ESM4::REC_LVLI:
return readTypedRecord<ESM4::LevelledItem>(params, reader);
case ESM4::REC_LVLN:
return readTypedRecord<ESM4::LevelledNpc>(params, reader);
case ESM4::REC_LVSP:
break;
case ESM4::REC_MATO:
return readTypedRecord<ESM4::Material>(params, reader);
case ESM4::REC_MATT:
break;
case ESM4::REC_MESG:
break;
case ESM4::REC_MGEF:
break;
case ESM4::REC_MISC:
return readTypedRecord<ESM4::MiscItem>(params, reader);
case ESM4::REC_MOVT:
break;
case ESM4::REC_MSET:
return readTypedRecord<ESM4::MediaSet>(params, reader);
case ESM4::REC_MSTT:
return readTypedRecord<ESM4::MovableStatic>(params, reader);
case ESM4::REC_MUSC:
return readTypedRecord<ESM4::Music>(params, reader);
case ESM4::REC_MUST:
break;
case ESM4::REC_NAVI:
return readTypedRecord<ESM4::Navigation>(params, reader);
case ESM4::REC_NAVM:
return readTypedRecord<ESM4::NavMesh>(params, reader);
case ESM4::REC_NOTE:
return readTypedRecord<ESM4::Note>(params, reader);
case ESM4::REC_NPC_:
return readTypedRecord<ESM4::Npc>(params, reader);
case ESM4::REC_OTFT:
return readTypedRecord<ESM4::Outfit>(params, reader);
case ESM4::REC_PACK:
return readTypedRecord<ESM4::AIPackage>(params, reader);
case ESM4::REC_PERK:
break;
case ESM4::REC_PGRD:
return readTypedRecord<ESM4::Pathgrid>(params, reader);
case ESM4::REC_PGRE:
return readTypedRecord<ESM4::PlacedGrenade>(params, reader);
case ESM4::REC_PHZD:
break;
case ESM4::REC_PROJ:
break;
case ESM4::REC_PWAT:
return readTypedRecord<ESM4::PlaceableWater>(params, reader);
case ESM4::REC_QUST:
return readTypedRecord<ESM4::Quest>(params, reader);
case ESM4::REC_RACE:
return readTypedRecord<ESM4::Race>(params, reader);
case ESM4::REC_REFR:
return readTypedRecord<ESM4::Reference>(params, reader);
case ESM4::REC_REGN:
return readTypedRecord<ESM4::Region>(params, reader);
case ESM4::REC_RELA:
break;
case ESM4::REC_REVB:
break;
case ESM4::REC_RFCT:
break;
case ESM4::REC_ROAD:
return readTypedRecord<ESM4::Road>(params, reader);
case ESM4::REC_SBSP:
return readTypedRecord<ESM4::SubSpace>(params, reader);
case ESM4::REC_SCEN:
break;
case ESM4::REC_SCOL:
return readTypedRecord<ESM4::StaticCollection>(params, reader);
case ESM4::REC_SCPT:
return readTypedRecord<ESM4::Script>(params, reader);
case ESM4::REC_SCRL:
return readTypedRecord<ESM4::Scroll>(params, reader);
case ESM4::REC_SGST:
return readTypedRecord<ESM4::SigilStone>(params, reader);
case ESM4::REC_SHOU:
break;
case ESM4::REC_SLGM:
return readTypedRecord<ESM4::SoulGem>(params, reader);
case ESM4::REC_SMBN:
break;
case ESM4::REC_SMEN:
break;
case ESM4::REC_SMQN:
break;
case ESM4::REC_SNCT:
break;
case ESM4::REC_SNDR:
return readTypedRecord<ESM4::SoundReference>(params, reader);
case ESM4::REC_SOPM:
break;
case ESM4::REC_SOUN:
return readTypedRecord<ESM4::Sound>(params, reader);
case ESM4::REC_SPEL:
break;
case ESM4::REC_SPGD:
break;
case ESM4::REC_STAT:
return readTypedRecord<ESM4::Static>(params, reader);
case ESM4::REC_TACT:
return readTypedRecord<ESM4::TalkingActivator>(params, reader);
case ESM4::REC_TERM:
return readTypedRecord<ESM4::Terminal>(params, reader);
case ESM4::REC_TES4:
return readTypedRecord<ESM4::Header>(params, reader);
case ESM4::REC_TREE:
return readTypedRecord<ESM4::Tree>(params, reader);
case ESM4::REC_TXST:
return readTypedRecord<ESM4::TextureSet>(params, reader);
case ESM4::REC_VTYP:
break;
case ESM4::REC_WATR:
break;
case ESM4::REC_WEAP:
return readTypedRecord<ESM4::Weapon>(params, reader);
case ESM4::REC_WOOP:
break;
case ESM4::REC_WRLD:
return readTypedRecord<ESM4::World>(params, reader);
case ESM4::REC_WTHR:
break;
}
if (!params.mQuite)
@ -307,8 +481,8 @@ namespace EsmTool
const ESM4::RecordHeader& header = reader.hdr();
if (!params.mQuite)
std::cout << "\nGroup: " << toString(static_cast<ESM4::GroupType>(header.group.type))
<< " " << ESM::NAME(header.group.typeId).toStringView() << '\n';
std::cout << "\nGroup: " << toString(static_cast<ESM4::GroupType>(header.group.type)) << " "
<< ESM::NAME(header.group.typeId).toStringView() << '\n';
switch (static_cast<ESM4::GroupType>(header.group.type))
{

@ -1,6 +1,6 @@
#include <string>
#include <iostream>
#include <limits>
#include <string>
#include <components/misc/strings/lower.hpp>
@ -57,30 +57,27 @@ namespace ESSImport
void convertANIS(const ANIS& anis, ESM::AnimationState& state)
{
static const char* animGroups[] =
{
"Idle", "Idle2", "Idle3", "Idle4", "Idle5", "Idle6", "Idle7", "Idle8", "Idle9", "Idlehh", "Idle1h", "Idle2c",
"Idle2w", "IdleSwim", "IdleSpell", "IdleCrossbow", "IdleSneak", "IdleStorm", "Torch", "Hit1", "Hit2", "Hit3",
"Hit4", "Hit5", "SwimHit1", "SwimHit2", "SwimHit3", "Death1", "Death2", "Death3", "Death4", "Death5",
"DeathKnockDown", "DeathKnockOut", "KnockDown", "KnockOut", "SwimDeath", "SwimDeath2", "SwimDeath3",
"SwimDeathKnockDown", "SwimDeathKnockOut", "SwimKnockOut", "SwimKnockDown", "SwimWalkForward",
"SwimWalkBack", "SwimWalkLeft", "SwimWalkRight", "SwimRunForward", "SwimRunBack", "SwimRunLeft",
"SwimRunRight", "SwimTurnLeft", "SwimTurnRight", "WalkForward", "WalkBack", "WalkLeft", "WalkRight",
"TurnLeft", "TurnRight", "RunForward", "RunBack", "RunLeft", "RunRight", "SneakForward", "SneakBack",
"SneakLeft", "SneakRight", "Jump", "WalkForwardhh", "WalkBackhh", "WalkLefthh", "WalkRighthh",
"TurnLefthh", "TurnRighthh", "RunForwardhh", "RunBackhh", "RunLefthh", "RunRighthh", "SneakForwardhh",
"SneakBackhh", "SneakLefthh", "SneakRighthh", "Jumphh", "WalkForward1h", "WalkBack1h", "WalkLeft1h",
"WalkRight1h", "TurnLeft1h", "TurnRight1h", "RunForward1h", "RunBack1h", "RunLeft1h", "RunRight1h",
"SneakForward1h", "SneakBack1h", "SneakLeft1h", "SneakRight1h", "Jump1h", "WalkForward2c", "WalkBack2c",
"WalkLeft2c", "WalkRight2c", "TurnLeft2c", "TurnRight2c", "RunForward2c", "RunBack2c", "RunLeft2c",
"RunRight2c", "SneakForward2c", "SneakBack2c", "SneakLeft2c", "SneakRight2c", "Jump2c", "WalkForward2w",
"WalkBack2w", "WalkLeft2w", "WalkRight2w", "TurnLeft2w", "TurnRight2w", "RunForward2w", "RunBack2w",
"RunLeft2w", "RunRight2w", "SneakForward2w", "SneakBack2w", "SneakLeft2w", "SneakRight2w", "Jump2w",
"SpellCast", "SpellTurnLeft", "SpellTurnRight", "Attack1", "Attack2", "Attack3", "SwimAttack1",
static const char* animGroups[] = { "Idle", "Idle2", "Idle3", "Idle4", "Idle5", "Idle6", "Idle7", "Idle8",
"Idle9", "Idlehh", "Idle1h", "Idle2c", "Idle2w", "IdleSwim", "IdleSpell", "IdleCrossbow", "IdleSneak",
"IdleStorm", "Torch", "Hit1", "Hit2", "Hit3", "Hit4", "Hit5", "SwimHit1", "SwimHit2", "SwimHit3", "Death1",
"Death2", "Death3", "Death4", "Death5", "DeathKnockDown", "DeathKnockOut", "KnockDown", "KnockOut",
"SwimDeath", "SwimDeath2", "SwimDeath3", "SwimDeathKnockDown", "SwimDeathKnockOut", "SwimKnockOut",
"SwimKnockDown", "SwimWalkForward", "SwimWalkBack", "SwimWalkLeft", "SwimWalkRight", "SwimRunForward",
"SwimRunBack", "SwimRunLeft", "SwimRunRight", "SwimTurnLeft", "SwimTurnRight", "WalkForward", "WalkBack",
"WalkLeft", "WalkRight", "TurnLeft", "TurnRight", "RunForward", "RunBack", "RunLeft", "RunRight",
"SneakForward", "SneakBack", "SneakLeft", "SneakRight", "Jump", "WalkForwardhh", "WalkBackhh", "WalkLefthh",
"WalkRighthh", "TurnLefthh", "TurnRighthh", "RunForwardhh", "RunBackhh", "RunLefthh", "RunRighthh",
"SneakForwardhh", "SneakBackhh", "SneakLefthh", "SneakRighthh", "Jumphh", "WalkForward1h", "WalkBack1h",
"WalkLeft1h", "WalkRight1h", "TurnLeft1h", "TurnRight1h", "RunForward1h", "RunBack1h", "RunLeft1h",
"RunRight1h", "SneakForward1h", "SneakBack1h", "SneakLeft1h", "SneakRight1h", "Jump1h", "WalkForward2c",
"WalkBack2c", "WalkLeft2c", "WalkRight2c", "TurnLeft2c", "TurnRight2c", "RunForward2c", "RunBack2c",
"RunLeft2c", "RunRight2c", "SneakForward2c", "SneakBack2c", "SneakLeft2c", "SneakRight2c", "Jump2c",
"WalkForward2w", "WalkBack2w", "WalkLeft2w", "WalkRight2w", "TurnLeft2w", "TurnRight2w", "RunForward2w",
"RunBack2w", "RunLeft2w", "RunRight2w", "SneakForward2w", "SneakBack2w", "SneakLeft2w", "SneakRight2w",
"Jump2w", "SpellCast", "SpellTurnLeft", "SpellTurnRight", "Attack1", "Attack2", "Attack3", "SwimAttack1",
"SwimAttack2", "SwimAttack3", "HandToHand", "Crossbow", "BowAndArrow", "ThrowWeapon", "WeaponOneHand",
"WeaponTwoHand", "WeaponTwoWide", "Shield", "PickProbe", "InventoryHandToHand", "InventoryWeaponOneHand",
"InventoryWeaponTwoHand", "InventoryWeaponTwoWide"
};
"InventoryWeaponTwoHand", "InventoryWeaponTwoWide" };
if (anis.mGroupIndex < (sizeof(animGroups) / sizeof(*animGroups)))
{

@ -1,10 +1,10 @@
#ifndef OPENMW_ESSIMPORT_CONVERTACDT_H
#define OPENMW_ESSIMPORT_CONVERTACDT_H
#include <components/esm3/animationstate.hpp>
#include <components/esm3/creaturestats.hpp>
#include <components/esm3/npcstats.hpp>
#include <components/esm3/loadskil.hpp>
#include <components/esm3/animationstate.hpp>
#include <components/esm3/npcstats.hpp>
#include "importacdt.hpp"
@ -14,7 +14,6 @@ namespace ESSImport
// OpenMW uses Health,Magicka,Fatigue, MW uses Health,Fatigue,Magicka
int translateDynamicIndex(int mwIndex);
void convertACDT(const ACDT& acdt, ESM::CreatureStats& cStats);
void convertACSC(const ACSC& acsc, ESM::CreatureStats& cStats);

@ -1,17 +1,17 @@
#include "converter.hpp"
#include <stdexcept>
#include <algorithm>
#include <stdexcept>
#include <osgDB/WriteFile>
#include <components/esm3/creaturestate.hpp>
#include <components/esm3/containerstate.hpp>
#include <components/esm3/creaturestate.hpp>
#include <components/misc/constants.hpp>
#include "convertcrec.hpp"
#include "convertcntc.hpp"
#include "convertcrec.hpp"
#include "convertscri.hpp"
namespace
@ -27,7 +27,6 @@ namespace
osgDB::writeImageFile(*image, out);
}
void convertCellRef(const ESSImport::CellRef& cellref, ESM::ObjectState& objstate)
{
objstate.mEnabled = cellref.mEnabled;
@ -89,7 +88,6 @@ namespace
namespace ESSImport
{
struct MAPH
{
unsigned int size;
@ -177,7 +175,8 @@ namespace ESSImport
osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*image2, ostream);
if (!result.success())
{
std::cerr << "Error: can't write global map image: " << result.message() << " code " << result.status() << std::endl;
std::cerr << "Error: can't write global map image: " << result.message() << " code " << result.status()
<< std::endl;
return;
}
@ -252,7 +251,8 @@ namespace ESSImport
std::ostringstream filename;
filename << "fog_" << cell.mData.mX << "_" << cell.mData.mY << ".tga";
convertImage((char*)&newcell.mFogOfWar[0], newcell.mFogOfWar.size()*4, 16, 16, GL_RGBA, filename.str());
convertImage(
(char*)&newcell.mFogOfWar[0], newcell.mFogOfWar.size() * 4, 16, 16, GL_RGBA, filename.str());
}
}
@ -307,7 +307,6 @@ namespace ESSImport
newcell.mRefs = cellrefs;
if (cell.isExterior())
mExtCells[std::make_pair(cell.mData.mX, cell.mData.mY)] = newcell;
else
@ -359,8 +358,7 @@ namespace ESSImport
std::string idLower = Misc::StringUtils::lowerCase(out.mRefID);
auto npccIt = mContext->mNpcChanges.find(
std::make_pair(refIndex, out.mRefID));
auto npccIt = mContext->mNpcChanges.find(std::make_pair(refIndex, out.mRefID));
if (npccIt != mContext->mNpcChanges.end())
{
ESM::NpcState objstate;
@ -380,15 +378,15 @@ namespace ESSImport
convertCellRef(cellref, objstate);
objstate.mCreatureStats.mActorId = mContext->generateActorId();
mContext->mActorIdMap.insert(std::make_pair(std::make_pair(refIndex, out.mRefID), objstate.mCreatureStats.mActorId));
mContext->mActorIdMap.insert(
std::make_pair(std::make_pair(refIndex, out.mRefID), objstate.mCreatureStats.mActorId));
esm.writeHNT("OBJE", ESM::REC_NPC_);
objstate.save(esm);
continue;
}
auto cntcIt = mContext->mContainerChanges.find(
std::make_pair(refIndex, out.mRefID));
auto cntcIt = mContext->mContainerChanges.find(std::make_pair(refIndex, out.mRefID));
if (cntcIt != mContext->mContainerChanges.end())
{
ESM::ContainerState objstate;
@ -402,8 +400,7 @@ namespace ESSImport
continue;
}
auto crecIt = mContext->mCreatureChanges.find(
std::make_pair(refIndex, out.mRefID));
auto crecIt = mContext->mCreatureChanges.find(std::make_pair(refIndex, out.mRefID));
if (crecIt != mContext->mCreatureChanges.end())
{
ESM::CreatureState objstate;
@ -422,7 +419,8 @@ namespace ESSImport
convertCellRef(cellref, objstate);
objstate.mCreatureStats.mActorId = mContext->generateActorId();
mContext->mActorIdMap.insert(std::make_pair(std::make_pair(refIndex, out.mRefID), objstate.mCreatureStats.mActorId));
mContext->mActorIdMap.insert(
std::make_pair(std::make_pair(refIndex, out.mRefID), objstate.mCreatureStats.mActorId));
esm.writeHNT("OBJE", ESM::REC_CREA);
objstate.save(esm);
@ -486,7 +484,8 @@ namespace ESSImport
if (it == mContext->mActiveSpells.end())
{
std::cerr << "Warning: Skipped conversion for magic projectile \"" << pnam.mArrowId.toString() << "\" (invalid spell link)" << std::endl;
std::cerr << "Warning: Skipped conversion for magic projectile \"" << pnam.mArrowId.toString()
<< "\" (invalid spell link)" << std::endl;
continue;
}

@ -9,42 +9,42 @@
#include <components/esm3/esmreader.hpp>
#include <components/esm3/esmwriter.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/esm3/loadbook.hpp>
#include <components/esm3/loadclas.hpp>
#include <components/esm3/loadglob.hpp>
#include <components/esm3/cellstate.hpp>
#include <components/esm3/loadfact.hpp>
#include <components/esm3/dialoguestate.hpp>
#include <components/esm3/custommarkerstate.hpp>
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/weatherstate.hpp>
#include <components/esm3/dialoguestate.hpp>
#include <components/esm3/globalscript.hpp>
#include <components/esm3/loadbook.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/esm3/loadclas.hpp>
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadfact.hpp>
#include <components/esm3/loadglob.hpp>
#include <components/esm3/projectilestate.hpp>
#include <components/esm3/queststate.hpp>
#include <components/esm3/stolenitems.hpp>
#include <components/esm3/projectilestate.hpp>
#include <components/esm3/weatherstate.hpp>
#include <components/misc/strings/algorithm.hpp>
#include "importcrec.hpp"
#include "importcntc.hpp"
#include "importcrec.hpp"
#include "importercontext.hpp"
#include "importcellref.hpp"
#include "importklst.hpp"
#include "importdial.hpp"
#include "importercontext.hpp"
#include "importgame.hpp"
#include "importinfo.hpp"
#include "importdial.hpp"
#include "importques.hpp"
#include "importjour.hpp"
#include "importscpt.hpp"
#include "importklst.hpp"
#include "importproj.h"
#include "importques.hpp"
#include "importscpt.hpp"
#include "importsplm.h"
#include "convertacdt.hpp"
#include "convertnpcc.hpp"
#include "convertscpt.hpp"
#include "convertplayer.hpp"
#include "convertscpt.hpp"
namespace ESSImport
{
@ -61,16 +61,11 @@ public:
/// @note The load method of ESM records accept the deleted flag as a parameter.
/// I don't know can the DELE sub-record appear in saved games, so the deleted flag will be ignored.
virtual void read(ESM::ESMReader& esm)
{
}
virtual void read(ESM::ESMReader& esm) {}
/// Called after the input file has been read in completely, which may be necessary
/// if the conversion process relies on information in other records
virtual void write(ESM::ESMWriter& esm)
{
}
virtual void write(ESM::ESMWriter& esm) {}
protected:
Context* mContext;
@ -256,7 +251,8 @@ public:
for (unsigned int i = 0; i < invState.mItems.size(); ++i)
{
// FIXME: in case of conflict (multiple items with this refID) use the already equipped one?
if (Misc::StringUtils::ciEqual(invState.mItems[i].mRef.mRefID, refr.mActorData.mSelectedEnchantItem))
if (Misc::StringUtils::ciEqual(
invState.mItems[i].mRef.mRefID, refr.mActorData.mSelectedEnchantItem))
invState.mSelectedEnchantItem = i;
}
}
@ -267,6 +263,7 @@ public:
esm.writeHNString("ID__", mSelectedSpell);
esm.endRecord(ESM::REC_ASPL);
}
private:
std::string mSelectedSpell;
};
@ -275,17 +272,19 @@ class ConvertPCDT : public Converter
{
public:
ConvertPCDT()
: mFirstPersonCam(true),
mTeleportingEnabled(true),
mLevitationEnabled(true)
{}
: mFirstPersonCam(true)
, mTeleportingEnabled(true)
, mLevitationEnabled(true)
{
}
void read(ESM::ESMReader& esm) override
{
PCDT pcdt;
pcdt.load(esm);
convertPCDT(pcdt, mContext->mPlayer, mContext->mDialogueState.mKnownTopics, mFirstPersonCam, mTeleportingEnabled, mLevitationEnabled, mContext->mControlsState);
convertPCDT(pcdt, mContext->mPlayer, mContext->mDialogueState.mKnownTopics, mFirstPersonCam,
mTeleportingEnabled, mLevitationEnabled, mContext->mControlsState);
}
void write(ESM::ESMWriter& esm) override
{
@ -298,6 +297,7 @@ public:
esm.writeHNT("FIRS", mFirstPersonCam);
esm.endRecord(ESM::REC_CAM_);
}
private:
bool mFirstPersonCam;
bool mTeleportingEnabled;
@ -441,7 +441,8 @@ public:
// it needs a count argument. But for legacy savegames, we don't know
// this count, so must assume all items of that ID are stolen,
// like vanilla MW did.
,std::numeric_limits<int>::max()));
,
std::numeric_limits<int>::max()));
}
items.mStolenItems.insert(std::make_pair(it->first, owners));
@ -498,6 +499,7 @@ public:
esm.endRecord(ESM::REC_QUES);
}
}
private:
std::map<std::string, DIAL> mDials;
};
@ -593,6 +595,7 @@ public:
esm.endRecord(ESM::REC_GSCR);
}
}
private:
std::vector<ESM::GlobalScript> mScripts;
};
@ -604,6 +607,7 @@ public:
int getStage() override { return 2; }
void read(ESM::ESMReader& esm) override;
void write(ESM::ESMWriter& esm) override;
private:
void convertBaseState(ESM::BaseProjectileState& base, const PROJ::PNAM& pnam);
PROJ mProj;
@ -614,6 +618,7 @@ class ConvertSPLM : public Converter
public:
void read(ESM::ESMReader& esm) override;
void write(ESM::ESMWriter& esm) override;
private:
SPLM mSPLM;
};

@ -8,9 +8,11 @@
namespace ESSImport
{
void convertPCDT(const PCDT& pcdt, ESM::Player& out, std::vector<std::string>& outDialogueTopics, bool& firstPersonCam, bool& teleportingEnabled, bool& levitationEnabled, ESM::ControlsState& controls)
void convertPCDT(const PCDT& pcdt, ESM::Player& out, std::vector<std::string>& outDialogueTopics,
bool& firstPersonCam, bool& teleportingEnabled, bool& levitationEnabled, ESM::ControlsState& controls)
{
out.mObject.mPosition.rot[0] = -atan2(pcdt.mPNAM.mVerticalRotation.mData[2][1], pcdt.mPNAM.mVerticalRotation.mData[2][2]);
out.mObject.mPosition.rot[0]
= -atan2(pcdt.mPNAM.mVerticalRotation.mData[2][1], pcdt.mPNAM.mVerticalRotation.mData[2][2]);
out.mBirthsign = pcdt.mBirthsign;
out.mObject.mNpcStats.mBounty = pcdt.mBounty;

@ -3,13 +3,14 @@
#include "importplayer.hpp"
#include <components/esm3/player.hpp>
#include <components/esm3/controlsstate.hpp>
#include <components/esm3/player.hpp>
namespace ESSImport
{
void convertPCDT(const PCDT& pcdt, ESM::Player& out, std::vector<std::string>& outDialogueTopics, bool& firstPersonCam, bool& teleportingEnabled, bool& levitationEnabled, ESM::ControlsState& controls);
void convertPCDT(const PCDT& pcdt, ESM::Player& out, std::vector<std::string>& outDialogueTopics,
bool& firstPersonCam, bool& teleportingEnabled, bool& levitationEnabled, ESM::ControlsState& controls);
}

@ -38,7 +38,8 @@ namespace ESSImport
float mDynamic[3][2];
unsigned char mUnknown3[16];
float mAttributes[8][2];
float mMagicEffects[27]; // Effect attributes: https://wiki.openmw.org/index.php?title=Research:Magic#Effect_attributes
float mMagicEffects[27]; // Effect attributes:
// https://wiki.openmw.org/index.php?title=Research:Magic#Effect_attributes
unsigned char mUnknown4[4];
unsigned int mGoldPool;
unsigned char mCountDown; // seen the same value as in ACSC.mCorpseClearCountdown, maybe

@ -14,7 +14,6 @@ namespace ESSImport
float scale;
esm.getHNOT(scale, "XSCL");
while (esm.isNextSub("AI_W") || esm.isNextSub("AI_E") || esm.isNextSub("AI_T") || esm.isNextSub("AI_F")
|| esm.isNextSub("AI_A"))
mAiPackages.add(esm);

@ -1,26 +1,26 @@
#include "importer.hpp"
#include <iomanip>
#include <filesystem>
#include <fstream>
#include <iomanip>
#include <osgDB/ReadFile>
#include <osg/ImageUtils>
#include <osgDB/ReadFile>
#include <components/esm/defs.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/esm3/esmwriter.hpp>
#include <components/esm/defs.hpp>
#include <components/esm3/savedgame.hpp>
#include <components/esm3/player.hpp>
#include <components/esm3/savedgame.hpp>
#include <components/esm3/loadalch.hpp>
#include <components/esm3/loadspel.hpp>
#include <components/esm3/loadarmo.hpp>
#include <components/esm3/loadweap.hpp>
#include <components/esm3/loadclot.hpp>
#include <components/esm3/loadench.hpp>
#include <components/esm3/loadlevlist.hpp>
#include <components/esm3/loadspel.hpp>
#include <components/esm3/loadweap.hpp>
#include <components/misc/constants.hpp>
@ -72,7 +72,8 @@ namespace
osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*image, ostream);
if (!result.success())
{
std::cerr << "Error: can't write screenshot: " << result.message() << " code " << result.status() << std::endl;
std::cerr << "Error: can't write screenshot: " << result.message() << " code " << result.status()
<< std::endl;
return;
}
@ -85,12 +86,12 @@ namespace
namespace ESSImport
{
Importer::Importer(const std::filesystem::path &essfile, const std::filesystem::path &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)
{
}
struct File
@ -190,7 +191,8 @@ namespace ESSImport
if (j >= rec2.mSubrecords.size())
{
std::ios::fmtflags f(std::cout.flags());
std::cout << "Subrecord in file1 not present in file2: (1) 0x" << std::hex << sub.mFileOffset << std::endl;
std::cout << "Subrecord in file1 not present in file2: (1) 0x" << std::hex << sub.mFileOffset
<< std::endl;
std::cout.flags(f);
return;
}
@ -200,8 +202,9 @@ namespace ESSImport
if (sub.mName != sub2.mName)
{
std::ios::fmtflags f(std::cout.flags());
std::cout << "Different subrecord name (" << rec.mName << "." << sub.mName << " vs. " << sub2.mName << ") at (1) 0x" << std::hex << sub.mFileOffset
<< " (2) 0x" << sub2.mFileOffset << std::endl;
std::cout << "Different subrecord name (" << rec.mName << "." << sub.mName << " vs. " << sub2.mName
<< ") at (1) 0x" << std::hex << sub.mFileOffset << " (2) 0x" << sub2.mFileOffset
<< std::endl;
std::cout.flags(f);
break; // TODO: try to recover
}
@ -213,8 +216,8 @@ namespace ESSImport
std::ios::fmtflags f(std::cout.flags());
std::cout << "Different subrecord data for " << rec.mName << "." << sub.mName << " at (1) 0x" << std::hex << sub.mFileOffset
<< " (2) 0x" << sub2.mFileOffset << std::endl;
std::cout << "Different subrecord data for " << rec.mName << "." << sub.mName << " at (1) 0x"
<< std::hex << sub.mFileOffset << " (2) 0x" << sub2.mFileOffset << std::endl;
std::cout << "Data 1:" << std::endl;
for (unsigned int k = 0; k < sub.mData.size(); ++k)
@ -333,7 +336,8 @@ namespace ESSImport
if (unknownRecords.insert(n.toInt()).second)
{
std::ios::fmtflags f(std::cerr.flags());
std::cerr << "Error: unknown record " << n.toString() << " (0x" << std::hex << esm.getFileOffset() << ")" << std::endl;
std::cerr << "Error: unknown record " << n.toString() << " (0x" << std::hex << esm.getFileOffset()
<< ")" << std::endl;
std::cerr.flags(f);
}
@ -385,8 +389,7 @@ namespace ESSImport
// Writing order should be Dynamic Store -> Cells -> Player,
// so that references to dynamic records can be recognized when loading
for (auto it = converters.begin();
it != converters.end(); ++it)
for (auto it = converters.begin(); it != converters.end(); ++it)
{
if (it->second->getStage() != 0)
continue;
@ -398,8 +401,7 @@ namespace ESSImport
context.mPlayerBase.save(writer);
writer.endRecord(ESM::REC_NPC_);
for (auto it = converters.begin();
it != converters.end(); ++it)
for (auto it = converters.begin(); it != converters.end(); ++it)
{
if (it->second->getStage() != 1)
continue;
@ -410,8 +412,10 @@ namespace ESSImport
if (context.mPlayer.mCellId.mPaged)
{
// exterior cell -> determine cell coordinates based on position
int cellX = static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[0] / Constants::CellSizeInUnits));
int cellY = static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[1] / Constants::CellSizeInUnits));
int cellX
= static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[0] / Constants::CellSizeInUnits));
int cellY
= static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[1] / Constants::CellSizeInUnits));
context.mPlayer.mCellId.mIndex.mX = cellX;
context.mPlayer.mCellId.mIndex.mY = cellY;
}
@ -423,8 +427,7 @@ namespace ESSImport
writer.endRecord(ESM::REC_ACTC);
// Stage 2 requires cell references to be written / actors IDs assigned
for (auto it = converters.begin();
it != converters.end(); ++it)
for (auto it = converters.begin(); it != converters.end(); ++it)
{
if (it->second->getStage() != 2)
continue;
@ -440,5 +443,4 @@ namespace ESSImport
writer.endRecord(ESM::REC_INPU);
}
}

@ -9,7 +9,8 @@ namespace ESSImport
class Importer
{
public:
Importer(const std::filesystem::path &essfile, const std::filesystem::path &outfile, const std::string& encoding);
Importer(
const std::filesystem::path& essfile, const std::filesystem::path& outfile, const std::string& encoding);
void run();

@ -3,17 +3,16 @@
#include <map>
#include <components/esm3/loadnpc.hpp>
#include <components/esm3/player.hpp>
#include <components/esm3/controlsstate.hpp>
#include <components/esm3/dialoguestate.hpp>
#include <components/esm3/globalmap.hpp>
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadnpc.hpp>
#include <components/esm3/controlsstate.hpp>
#include <components/esm3/player.hpp>
#include "importnpcc.hpp"
#include "importcrec.hpp"
#include "importcntc.hpp"
#include "importcrec.hpp"
#include "importnpcc.hpp"
#include "importsplm.h"
namespace ESSImport
@ -64,10 +63,8 @@ namespace ESSImport
playerCellId.mPaged = true;
playerCellId.mIndex.mX = playerCellId.mIndex.mY = 0;
mPlayer.mCellId = playerCellId;
mPlayer.mLastKnownExteriorPosition[0]
= mPlayer.mLastKnownExteriorPosition[1]
= mPlayer.mLastKnownExteriorPosition[2]
= 0.0f;
mPlayer.mLastKnownExteriorPosition[0] = mPlayer.mLastKnownExteriorPosition[1]
= mPlayer.mLastKnownExteriorPosition[2] = 0.0f;
mPlayer.mHasMark = 0;
mPlayer.mCurrentCrimeId = -1; // TODO
mPlayer.mPaidCrimeId = -1;
@ -84,10 +81,7 @@ namespace ESSImport
mPlayerBase.blank();
}
int generateActorId()
{
return mNextActorId++;
}
int generateActorId() { return mNextActorId++; }
};
}

@ -1,11 +1,11 @@
#ifndef OPENMW_ESSIMPORT_IMPORTINVENTORY_H
#define OPENMW_ESSIMPORT_IMPORTINVENTORY_H
#include <vector>
#include <string>
#include <vector>
#include <components/esm3/cellref.hpp>
#include <components/esm/esmcommon.hpp>
#include <components/esm3/cellref.hpp>
#include "importscri.hpp"

@ -1,8 +1,8 @@
#ifndef OPENMW_ESSIMPORT_KLST_H
#define OPENMW_ESSIMPORT_KLST_H
#include <string>
#include <map>
#include <string>
namespace ESM
{

@ -1,12 +1,12 @@
#ifndef OPENMW_ESSIMPORT_PLAYER_H
#define OPENMW_ESSIMPORT_PLAYER_H
#include <vector>
#include <string>
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm3/cellref.hpp>
#include <components/esm/esmcommon.hpp>
#include <components/esm3/cellref.hpp>
namespace ESM
{

@ -1,9 +1,9 @@
#ifndef OPENMW_ESSIMPORT_IMPORTPROJ_H
#define OPENMW_ESSIMPORT_IMPORTPROJ_H
#include <vector>
#include <components/esm/esmcommon.hpp>
#include <components/esm/util.hpp>
#include <vector>
namespace ESM
{

@ -2,7 +2,6 @@
#include <components/esm3/esmreader.hpp>
namespace ESSImport
{

@ -3,8 +3,8 @@
#include "importscri.hpp"
#include <components/esm3/loadscpt.hpp>
#include <components/esm/esmcommon.hpp>
#include <components/esm3/loadscpt.hpp>
namespace ESM
{

@ -2,7 +2,6 @@
#include <components/esm3/esmreader.hpp>
namespace ESSImport
{

@ -1,9 +1,9 @@
#ifndef OPENMW_ESSIMPORT_IMPORTSPLM_H
#define OPENMW_ESSIMPORT_IMPORTSPLM_H
#include <vector>
#include <components/esm/esmcommon.hpp>
#include <components/esm/util.hpp>
#include <vector>
namespace ESM
{
@ -55,7 +55,6 @@ struct SPLM
int mUnknown;
};
#pragma pack(pop)
struct ActiveEffect

@ -1,5 +1,5 @@
#include <iostream>
#include <filesystem>
#include <iostream>
#include <boost/program_options.hpp>
@ -9,7 +9,6 @@
namespace bpo = boost::program_options;
int main(int argc, char** argv)
{
try
@ -22,19 +21,18 @@ Allowed options)");
addOption("mwsave,m", bpo::value<Files::MaybeQuotedPath>(), "morrowind .ess save file");
addOption("output,o", bpo::value<Files::MaybeQuotedPath>(), "output file (.omwsave)");
addOption("compare,c", "compare two .ess files");
addOption("encoding", boost::program_options::value<std::string>()->default_value("win1252"), "encoding of the save file");
addOption("encoding", boost::program_options::value<std::string>()->default_value("win1252"),
"encoding of the save file");
p_desc.add("mwsave", 1).add("output", 1);
Files::ConfigurationManager::addCommonOptions(desc);
bpo::variables_map variables;
bpo::parsed_options parsed = bpo::command_line_parser(argc, argv)
.options(desc)
.positional(p_desc)
.run();
bpo::parsed_options parsed = bpo::command_line_parser(argc, argv).options(desc).positional(p_desc).run();
bpo::store(parsed, variables);
if(variables.count("help") || !variables.count("mwsave") || !variables.count("output")) {
if (variables.count("help") || !variables.count("mwsave") || !variables.count("output"))
{
std::cout << desc;
return 0;
}
@ -59,7 +57,8 @@ Allowed options)");
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?");
throw std::runtime_error(
"Output file already exists and does not end in .omwsave. Did you mean to use --compare?");
}
importer.run();
}

@ -1,16 +1,16 @@
#include "advancedpage.hpp"
#include <array>
#include <string>
#include <cmath>
#include <string>
#include <QFileDialog>
#include <QCompleter>
#include <QFileDialog>
#include <QString>
#include <components/config/gamesettings.hpp>
#include <components/contentselector/view/contentselector.hpp>
#include <components/contentselector/model/esmfile.hpp>
#include <components/contentselector/view/contentselector.hpp>
#include <components/detournavigator/collisionshapetype.hpp>
#include "utils/openalutil.hpp"
@ -37,14 +37,16 @@ Launcher::AdvancedPage::AdvancedPage(Config::GameSettings &gameSettings, QWidget
startDefaultCharacterAtField->setCompleter(&mCellNameCompleter);
}
void Launcher::AdvancedPage::loadCellsForAutocomplete(QStringList cellNames) {
void Launcher::AdvancedPage::loadCellsForAutocomplete(QStringList cellNames)
{
// Update the list of suggestions for the "Start default character at" field
mCellNameCompleterModel.setStringList(cellNames);
mCellNameCompleter.setCompletionMode(QCompleter::PopupCompletion);
mCellNameCompleter.setCaseSensitivity(Qt::CaseSensitivity::CaseInsensitive);
}
void Launcher::AdvancedPage::on_skipMenuCheckBox_stateChanged(int state) {
void Launcher::AdvancedPage::on_skipMenuCheckBox_stateChanged(int state)
{
startDefaultCharacterAtLabel->setEnabled(state == Qt::Checked);
startDefaultCharacterAtField->setEnabled(state == Qt::Checked);
}
@ -52,10 +54,7 @@ void Launcher::AdvancedPage::on_skipMenuCheckBox_stateChanged(int state) {
void Launcher::AdvancedPage::on_runScriptAfterStartupBrowseButton_clicked()
{
QString scriptFile = QFileDialog::getOpenFileName(
this,
QObject::tr("Select script file"),
QDir::currentPath(),
QString(tr("Text file (*.txt)")));
this, QObject::tr("Select script file"), QDir::currentPath(), QString(tr("Text file (*.txt)")));
if (scriptFile.isEmpty())
return;
@ -95,7 +94,8 @@ bool Launcher::AdvancedPage::loadSettings()
loadSettingBool(enchantedWeaponsMagicalCheckBox, "enchanted weapons are magical", "Game");
loadSettingBool(permanentBarterDispositionChangeCheckBox, "barter disposition change is permanent", "Game");
loadSettingBool(classicReflectedAbsorbSpellsCheckBox, "classic reflected absorb spells behavior", "Game");
loadSettingBool(requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game");
loadSettingBool(
requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game");
loadSettingBool(uncappedDamageFatigueCheckBox, "uncapped damage fatigue", "Game");
loadSettingBool(normaliseRaceSpeedCheckBox, "normalise race speed", "Game");
loadSettingBool(swimUpwardCorrectionCheckBox, "swim upward correction", "Game");
@ -124,7 +124,8 @@ bool Launcher::AdvancedPage::loadSettings()
loadSettingBool(bumpMapLocalLightingCheckBox, "apply lighting to environment maps", "Shaders");
loadSettingBool(softParticlesCheckBox, "soft particles", "Shaders");
loadSettingBool(antialiasAlphaTestCheckBox, "antialias alpha test", "Shaders");
if (Settings::Manager::getInt("antialiasing", "Video") == 0) {
if (Settings::Manager::getInt("antialiasing", "Video") == 0)
{
antialiasAlphaTestCheckBox->setCheckState(Qt::Unchecked);
}
loadSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game");
@ -140,7 +141,8 @@ bool Launcher::AdvancedPage::loadSettings()
const bool distantTerrain = Settings::Manager::getBool("distant terrain", "Terrain");
const bool objectPaging = Settings::Manager::getBool("object paging", "Terrain");
if (distantTerrain && objectPaging) {
if (distantTerrain && objectPaging)
{
distantLandCheckBox->setCheckState(Qt::Checked);
}
@ -210,7 +212,8 @@ bool Launcher::AdvancedPage::loadSettings()
// Bug fixes
{
loadSettingBool(preventMerchantEquippingCheckBox, "prevent merchant equipping", "Game");
loadSettingBool(trainersTrainingSkillsBasedOnBaseSkillCheckBox, "trainers training skills based on base skill", "Game");
loadSettingBool(
trainersTrainingSkillsBasedOnBaseSkillCheckBox, "trainers training skills based on base skill", "Game");
}
// Miscellaneous
@ -220,7 +223,8 @@ bool Launcher::AdvancedPage::loadSettings()
loadSettingInt(maximumQuicksavesComboBox, "max quicksaves", "Saves");
// Other Settings
QString screenshotFormatString = QString::fromStdString(Settings::Manager::getString("screenshot format", "General")).toUpper();
QString screenshotFormatString
= QString::fromStdString(Settings::Manager::getString("screenshot format", "General")).toUpper();
if (screenshotFormatComboBox->findText(screenshotFormatString) == -1)
screenshotFormatComboBox->addItem(screenshotFormatString);
screenshotFormatComboBox->setCurrentIndex(screenshotFormatComboBox->findText(screenshotFormatString));
@ -257,7 +261,8 @@ void Launcher::AdvancedPage::saveSettings()
saveSettingBool(enchantedWeaponsMagicalCheckBox, "enchanted weapons are magical", "Game");
saveSettingBool(permanentBarterDispositionChangeCheckBox, "barter disposition change is permanent", "Game");
saveSettingBool(classicReflectedAbsorbSpellsCheckBox, "classic reflected absorb spells behavior", "Game");
saveSettingBool(requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game");
saveSettingBool(
requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game");
saveSettingBool(uncappedDamageFatigueCheckBox, "uncapped damage fatigue", "Game");
saveSettingBool(normaliseRaceSpeedCheckBox, "normalise race speed", "Game");
saveSettingBool(swimUpwardCorrectionCheckBox, "swim upward correction", "Game");
@ -291,7 +296,8 @@ void Launcher::AdvancedPage::saveSettings()
const bool distantTerrain = Settings::Manager::getBool("distant terrain", "Terrain");
const bool objectPaging = Settings::Manager::getBool("object paging", "Terrain");
const bool wantDistantLand = distantLandCheckBox->checkState();
if (wantDistantLand != (distantTerrain && objectPaging)) {
if (wantDistantLand != (distantTerrain && objectPaging))
{
Settings::Manager::setBool("distant terrain", "Terrain", wantDistantLand);
Settings::Manager::setBool("object paging", "Terrain", wantDistantLand);
}
@ -377,7 +383,8 @@ void Launcher::AdvancedPage::saveSettings()
// Bug fixes
{
saveSettingBool(preventMerchantEquippingCheckBox, "prevent merchant equipping", "Game");
saveSettingBool(trainersTrainingSkillsBasedOnBaseSkillCheckBox, "trainers training skills based on base skill", "Game");
saveSettingBool(
trainersTrainingSkillsBasedOnBaseSkillCheckBox, "trainers training skills based on base skill", "Game");
}
// Miscellaneous

@ -8,7 +8,10 @@
#include <components/settings/settings.hpp>
namespace Config { class GameSettings; }
namespace Config
{
class GameSettings;
}
namespace Launcher
{

@ -2,13 +2,13 @@
#include "maindialog.hpp"
#include <QDebug>
#include <QPushButton>
#include <QMessageBox>
#include <QFileDialog>
#include <QMessageBox>
#include <QPushButton>
#include <thread>
#include <mutex>
#include <algorithm>
#include <mutex>
#include <thread>
#include <apps/launcher/utils/cellnameloader.hpp>
#include <components/files/configurationmanager.hpp>
@ -63,55 +63,38 @@ namespace Launcher
HandleNavMeshToolMessage operator()(NavMeshTool::ExpectedCells&& message) const
{
return HandleNavMeshToolMessage {
static_cast<int>(message.mCount),
mExpectedMaxProgress,
static_cast<int>(message.mCount) * 100,
mProgress
};
return HandleNavMeshToolMessage{ static_cast<int>(message.mCount), mExpectedMaxProgress,
static_cast<int>(message.mCount) * 100, mProgress };
}
HandleNavMeshToolMessage operator()(NavMeshTool::ProcessedCells&& message) const
{
return HandleNavMeshToolMessage {
mCellsCount,
mExpectedMaxProgress,
mMaxProgress,
std::max(mProgress, static_cast<int>(message.mCount))
};
return HandleNavMeshToolMessage{ mCellsCount, mExpectedMaxProgress, mMaxProgress,
std::max(mProgress, static_cast<int>(message.mCount)) };
}
HandleNavMeshToolMessage operator()(NavMeshTool::ExpectedTiles&& message) const
{
const int expectedMaxProgress = mCellsCount + static_cast<int>(message.mCount);
return HandleNavMeshToolMessage {
mCellsCount,
expectedMaxProgress,
std::max(mMaxProgress, expectedMaxProgress),
mProgress
};
return HandleNavMeshToolMessage{ mCellsCount, expectedMaxProgress,
std::max(mMaxProgress, expectedMaxProgress), mProgress };
}
HandleNavMeshToolMessage operator()(NavMeshTool::GeneratedTiles&& message) const
{
int progress = mCellsCount + static_cast<int>(message.mCount);
if (mExpectedMaxProgress < mMaxProgress)
progress += static_cast<int>(std::round(
(mMaxProgress - mExpectedMaxProgress)
* (static_cast<float>(progress) / static_cast<float>(mExpectedMaxProgress))
));
return HandleNavMeshToolMessage {
mCellsCount,
mExpectedMaxProgress,
mMaxProgress,
std::max(mProgress, progress)
};
progress += static_cast<int>(std::round((mMaxProgress - mExpectedMaxProgress)
* (static_cast<float>(progress) / static_cast<float>(mExpectedMaxProgress))));
return HandleNavMeshToolMessage{ mCellsCount, mExpectedMaxProgress, mMaxProgress,
std::max(mProgress, progress) };
}
};
int getMaxNavMeshDbFileSizeMiB()
{
return static_cast<int>(Settings::Manager::getInt64("max navmeshdb file size", "Navigator") / (1024 * 1024));
return static_cast<int>(
Settings::Manager::getInt64("max navmeshdb file size", "Navigator") / (1024 * 1024));
}
}
}
@ -134,10 +117,8 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
mNewProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this);
mCloneProfileDialog = new TextInputDialog(tr("Clone Content List"), tr("Content List name:"), this);
connect(mNewProfileDialog->lineEdit(), &LineEdit::textChanged,
this, &DataFilesPage::updateNewProfileOkButton);
connect(mCloneProfileDialog->lineEdit(), &LineEdit::textChanged,
this, &DataFilesPage::updateCloneProfileOkButton);
connect(mNewProfileDialog->lineEdit(), &LineEdit::textChanged, this, &DataFilesPage::updateNewProfileOkButton);
connect(mCloneProfileDialog->lineEdit(), &LineEdit::textChanged, this, &DataFilesPage::updateCloneProfileOkButton);
connect(ui.directoryAddSubdirsButton, &QPushButton::released, this, [this]() { this->addSubdirectories(true); });
connect(ui.directoryInsertButton, &QPushButton::released, this, [this]() { this->addSubdirectories(false); });
connect(ui.directoryUpButton, &QPushButton::released, this, [this]() { this->moveDirectory(-1); });
@ -145,15 +126,16 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
connect(ui.directoryRemoveButton, &QPushButton::released, this, [this]() { this->removeDirectory(); });
connect(ui.archiveUpButton, &QPushButton::released, this, [this]() { this->moveArchive(-1); });
connect(ui.archiveDownButton, &QPushButton::released, this, [this]() { this->moveArchive(1); });
connect(ui.directoryListWidget->model(), &QAbstractItemModel::rowsMoved, this, [this]() { this->sortDirectories(); });
connect(
ui.directoryListWidget->model(), &QAbstractItemModel::rowsMoved, this, [this]() { this->sortDirectories(); });
buildView();
loadSettings();
// Connect signal and slot after the settings have been loaded. We only care about the user changing
// the addons and don't want to get signals of the system doing it during startup.
connect(mSelector, &ContentSelectorView::ContentSelector::signalAddonDataChanged,
this, &DataFilesPage::slotAddonDataChanged);
connect(mSelector, &ContentSelectorView::ContentSelector::signalAddonDataChanged, this,
&DataFilesPage::slotAddonDataChanged);
// Call manually to indicate all changes to addon data during startup.
slotAddonDataChanged();
}
@ -179,24 +161,25 @@ void Launcher::DataFilesPage::buildView()
refreshButton->setDefaultAction(ui.refreshDataFilesAction);
// establish connections
connect (ui.profilesComboBox, qOverload<int>(&::ProfilesComboBox::currentIndexChanged),
this, &DataFilesPage::slotProfileChanged);
connect(ui.profilesComboBox, qOverload<int>(&::ProfilesComboBox::currentIndexChanged), this,
&DataFilesPage::slotProfileChanged);
connect (ui.profilesComboBox, &::ProfilesComboBox::profileRenamed,
this, &DataFilesPage::slotProfileRenamed);
connect(ui.profilesComboBox, &::ProfilesComboBox::profileRenamed, this, &DataFilesPage::slotProfileRenamed);
connect(ui.profilesComboBox, qOverload<const QString&, const QString&>(&::ProfilesComboBox::signalProfileChanged),
this, &DataFilesPage::slotProfileChangedByUser);
connect(ui.refreshDataFilesAction, &QAction::triggered,
this, &DataFilesPage::slotRefreshButtonClicked);
connect(ui.refreshDataFilesAction, &QAction::triggered, this, &DataFilesPage::slotRefreshButtonClicked);
connect(ui.updateNavMeshButton, &QPushButton::clicked, this, &DataFilesPage::startNavMeshTool);
connect(ui.cancelNavMeshButton, &QPushButton::clicked, this, &DataFilesPage::killNavMeshTool);
connect(mNavMeshToolInvoker->getProcess(), &QProcess::readyReadStandardOutput, this, &DataFilesPage::readNavMeshToolStdout);
connect(mNavMeshToolInvoker->getProcess(), &QProcess::readyReadStandardError, this, &DataFilesPage::readNavMeshToolStderr);
connect(mNavMeshToolInvoker->getProcess(), qOverload<int,QProcess::ExitStatus>(&QProcess::finished), this, &DataFilesPage::navMeshToolFinished);
connect(mNavMeshToolInvoker->getProcess(), &QProcess::readyReadStandardOutput, this,
&DataFilesPage::readNavMeshToolStdout);
connect(mNavMeshToolInvoker->getProcess(), &QProcess::readyReadStandardError, this,
&DataFilesPage::readNavMeshToolStderr);
connect(mNavMeshToolInvoker->getProcess(), qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this,
&DataFilesPage::navMeshToolFinished);
}
bool Launcher::DataFilesPage::loadSettings()
@ -267,7 +250,8 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
// deactivate data-local and global data directory: they are always included
const auto tmp = currentDir.toUtf8();
if (currentDir == mDataLocal || std::filesystem::path(Misc::StringUtils::stringToU8String(tmp)) == globalDataDir)
if (currentDir == mDataLocal
|| std::filesystem::path(Misc::StringUtils::stringToU8String(tmp)) == globalDataDir)
{
auto flags = item->flags();
item->setFlags(flags & ~(Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled));
@ -334,7 +318,8 @@ QStringList Launcher::DataFilesPage::filesInProfile(const QString& profileName,
void Launcher::DataFilesPage::saveSettings(const QString& profile)
{
if (const int value = ui.navMeshMaxSizeSpinBox->value(); value != getMaxNavMeshDbFileSizeMiB())
Settings::Manager::setInt64("max navmeshdb file size", "Navigator", static_cast<std::int64_t>(value) * 1024 * 1024);
Settings::Manager::setInt64(
"max navmeshdb file size", "Navigator", static_cast<std::int64_t>(value) * 1024 * 1024);
QString profileName = profile;
@ -584,7 +569,6 @@ QString Launcher::DataFilesPage::selectDirectory()
return {};
return QDir(fileDialog.selectedFiles()[0]).canonicalPath();
}
void Launcher::DataFilesPage::addSubdirectories(bool append)
@ -650,8 +634,8 @@ void Launcher::DataFilesPage::sortDirectories()
// Ensure disabled entries (aka default directories) are always at the top.
for (auto i = 1; i < ui.directoryListWidget->count(); ++i)
{
if (!(ui.directoryListWidget->item(i)->flags() & Qt::ItemIsEnabled) &&
(ui.directoryListWidget->item(i - 1)->flags() & Qt::ItemIsEnabled))
if (!(ui.directoryListWidget->item(i)->flags() & Qt::ItemIsEnabled)
&& (ui.directoryListWidget->item(i - 1)->flags() & Qt::ItemIsEnabled))
{
const auto item = ui.directoryListWidget->takeItem(i);
ui.directoryListWidget->insertItem(i - 1, item);
@ -743,8 +727,7 @@ bool Launcher::DataFilesPage::showDeleteMessageBox (const QString &text)
msgBox.setStandardButtons(QMessageBox::Cancel);
msgBox.setText(tr("Are you sure you want to delete <b>%1</b>?").arg(text));
QAbstractButton *deleteButton =
msgBox.addButton(tr("Delete"), QMessageBox::ActionRole);
QAbstractButton* deleteButton = msgBox.addButton(tr("Delete"), QMessageBox::ActionRole);
msgBox.exec();
@ -754,7 +737,8 @@ bool Launcher::DataFilesPage::showDeleteMessageBox (const QString &text)
void Launcher::DataFilesPage::slotAddonDataChanged()
{
QStringList selectedFiles = selectedFilePaths();
if (previousSelectedFiles != selectedFiles) {
if (previousSelectedFiles != selectedFiles)
{
previousSelectedFiles = selectedFiles;
// Loading cells for core Morrowind + Expansions takes about 0.2 seconds, which is enough to cause a
// barely perceptible UI lag. Splitting into its own thread to alleviate that.
@ -863,7 +847,8 @@ void Launcher::DataFilesPage::readNavMeshToolStdout()
void Launcher::DataFilesPage::navMeshToolFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
updateNavMeshProgress(0);
ui.navMeshLogPlainTextEdit->appendPlainText(QString::fromUtf8(mNavMeshToolInvoker->getProcess()->readAllStandardOutput()));
ui.navMeshLogPlainTextEdit->appendPlainText(
QString::fromUtf8(mNavMeshToolInvoker->getProcess()->readAllStandardOutput()));
if (exitCode == 0 && exitStatus == QProcess::ExitStatus::NormalExit)
ui.navMeshProgressBar->setValue(ui.navMeshProgressBar->maximum());
ui.cancelNavMeshButton->setEnabled(false);

@ -5,18 +5,27 @@
#include <components/process/processinvoker.hpp>
#include <QWidget>
#include <QDir>
#include <QStringList>
#include <QWidget>
class QSortFilterProxyModel;
class QAbstractItemModel;
class QMenu;
namespace Files { struct ConfigurationManager; }
namespace ContentSelectorView { class ContentSelector; }
namespace Config { class GameSettings;
class LauncherSettings; }
namespace Files
{
struct ConfigurationManager;
}
namespace ContentSelectorView
{
class ContentSelector;
}
namespace Config
{
class GameSettings;
class LauncherSettings;
}
namespace Launcher
{
@ -157,7 +166,6 @@ namespace Launcher
QString findNextPath() { return path(); }
private:
QString path()
{
bool success = false;
@ -180,7 +188,6 @@ namespace Launcher
return "";
}
};
QStringList filesInProfile(const QString& profileName, PathIterator& pathIterator);

@ -13,8 +13,8 @@
#include <SDL_video.h>
#include <numeric>
#include <array>
#include <numeric>
QString getAspect(int x, int y)
{
@ -42,7 +42,8 @@ Launcher::GraphicsPage::GraphicsPage(QWidget *parent)
customWidthSpinBox->setMaximum(res.width());
customHeightSpinBox->setMaximum(res.height());
connect(windowModeComboBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &GraphicsPage::slotFullScreenChanged);
connect(windowModeComboBox, qOverload<int>(&QComboBox::currentIndexChanged), this,
&GraphicsPage::slotFullScreenChanged);
connect(standardRadioButton, &QRadioButton::toggled, this, &GraphicsPage::slotStandardToggled);
connect(screenComboBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &GraphicsPage::screenChanged);
connect(framerateLimitCheckBox, &QCheckBox::toggled, this, &GraphicsPage::slotFramerateLimitToggled);
@ -65,7 +66,8 @@ bool Launcher::GraphicsPage::setupSDL()
msgBox.setWindowTitle(tr("Error receiving number of screens"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<br><b>SDL_GetNumVideoDisplays failed:</b><br><br>") + QString::fromUtf8(SDL_GetError()) + "<br>");
msgBox.setText(
tr("<br><b>SDL_GetNumVideoDisplays failed:</b><br><br>") + QString::fromUtf8(SDL_GetError()) + "<br>");
msgBox.exec();
return false;
}
@ -116,10 +118,13 @@ bool Launcher::GraphicsPage::loadSettings()
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
if (resIndex != -1) {
if (resIndex != -1)
{
standardRadioButton->toggle();
resolutionComboBox->setCurrentIndex(resIndex);
} else {
}
else
{
customRadioButton->toggle();
customWidthSpinBox->setValue(width);
customHeightSpinBox->setValue(height);
@ -152,8 +157,7 @@ bool Launcher::GraphicsPage::loadSettings()
if (Settings::Manager::getBool("enable indoor shadows", "Shadows"))
indoorShadowsCheckBox->setCheckState(Qt::Checked);
shadowComputeSceneBoundsComboBox->setCurrentIndex(
shadowComputeSceneBoundsComboBox->findText(
shadowComputeSceneBoundsComboBox->setCurrentIndex(shadowComputeSceneBoundsComboBox->findText(
QString(tr(Settings::Manager::getString("compute scene bounds", "Shadows").c_str()))));
int shadowDistLimit = Settings::Manager::getInt("maximum shadow map distance", "Shadows");
@ -199,13 +203,17 @@ void Launcher::GraphicsPage::saveSettings()
int cWidth = 0;
int cHeight = 0;
if (standardRadioButton->isChecked()) {
if (standardRadioButton->isChecked())
{
QRegExp resolutionRe(QString("(\\d+) x (\\d+).*"));
if (resolutionRe.exactMatch(resolutionComboBox->currentText().simplified())) {
if (resolutionRe.exactMatch(resolutionComboBox->currentText().simplified()))
{
cWidth = resolutionRe.cap(1).toInt();
cHeight = resolutionRe.cap(2).toInt();
}
} else {
}
else
{
cWidth = customWidthSpinBox->value();
cHeight = customHeightSpinBox->value();
}
@ -301,7 +309,8 @@ QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)
msgBox.setWindowTitle(tr("Error receiving resolutions"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<br><b>SDL_GetNumDisplayModes failed:</b><br><br>") + QString::fromUtf8(SDL_GetError()) + "<br>");
msgBox.setText(
tr("<br><b>SDL_GetNumDisplayModes failed:</b><br><br>") + QString::fromUtf8(SDL_GetError()) + "<br>");
msgBox.exec();
return result;
}
@ -314,7 +323,8 @@ QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)
msgBox.setWindowTitle(tr("Error receiving resolutions"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<br><b>SDL_GetDisplayMode failed:</b><br><br>") + QString::fromUtf8(SDL_GetError()) + "<br>");
msgBox.setText(
tr("<br><b>SDL_GetDisplayMode failed:</b><br><br>") + QString::fromUtf8(SDL_GetError()) + "<br>");
msgBox.exec();
return result;
}
@ -322,10 +332,12 @@ QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)
QString resolution = QString::number(mode.w) + QString(" x ") + QString::number(mode.h);
QString aspect = getAspect(mode.w, mode.h);
if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) {
if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10"))
{
resolution.append(tr("\t(Wide ") + aspect + ")");
} else if (aspect == QLatin1String("4:3")) {
}
else if (aspect == QLatin1String("4:3"))
{
resolution.append(tr("\t(Standard 4:3)"));
}
@ -353,7 +365,8 @@ QRect Launcher::GraphicsPage::getMaximumResolution()
void Launcher::GraphicsPage::screenChanged(int screen)
{
if (screen >= 0) {
if (screen >= 0)
{
resolutionComboBox->clear();
resolutionComboBox->addItems(mResolutionsPerScreen[screen]);
}
@ -361,13 +374,17 @@ void Launcher::GraphicsPage::screenChanged(int screen)
void Launcher::GraphicsPage::slotFullScreenChanged(int mode)
{
if (mode == static_cast<int>(Settings::WindowMode::Fullscreen) || mode == static_cast<int>(Settings::WindowMode::WindowedFullscreen)) {
if (mode == static_cast<int>(Settings::WindowMode::Fullscreen)
|| mode == static_cast<int>(Settings::WindowMode::WindowedFullscreen))
{
standardRadioButton->toggle();
customRadioButton->setEnabled(false);
customWidthSpinBox->setEnabled(false);
customHeightSpinBox->setEnabled(false);
windowBorderCheckBox->setEnabled(false);
} else {
}
else
{
customRadioButton->setEnabled(true);
customWidthSpinBox->setEnabled(true);
customHeightSpinBox->setEnabled(true);
@ -377,11 +394,14 @@ void Launcher::GraphicsPage::slotFullScreenChanged(int mode)
void Launcher::GraphicsPage::slotStandardToggled(bool checked)
{
if (checked) {
if (checked)
{
resolutionComboBox->setEnabled(true);
customWidthSpinBox->setEnabled(false);
customHeightSpinBox->setEnabled(false);
} else {
}
else
{
resolutionComboBox->setEnabled(false);
customWidthSpinBox->setEnabled(true);
customHeightSpinBox->setEnabled(true);

@ -5,7 +5,10 @@
#include <components/settings/settings.hpp>
namespace Files { struct ConfigurationManager; }
namespace Files
{
struct ConfigurationManager;
}
namespace Launcher
{

@ -1,7 +1,7 @@
#include <iostream>
#include <QTranslator>
#include <QDir>
#include <QTranslator>
#include <components/debug/debugging.hpp>
#include <components/platform/platform.hpp>

@ -1,14 +1,14 @@
#include "maindialog.hpp"
#include <components/version/version.hpp>
#include <components/misc/helpviewer.hpp>
#include <components/version/version.hpp>
#include <QTime>
#include <QDir>
#include <QCloseEvent>
#include <QDebug>
#include <QDir>
#include <QMessageBox>
#include <QCloseEvent>
#include <QTextCodec>
#include <QTime>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
@ -23,7 +23,8 @@
using namespace Process;
void cfgError(const QString& title, const QString& msg) {
void cfgError(const QString& title, const QString& msg)
{
QMessageBox msgBox;
msgBox.setWindowTitle(title);
msgBox.setIcon(QMessageBox::Critical);
@ -33,18 +34,18 @@ void cfgError(const QString& title, const QString& msg) {
}
Launcher::MainDialog::MainDialog(QWidget* parent)
: QMainWindow(parent), mGameSettings (mCfgMgr)
: QMainWindow(parent)
, mGameSettings(mCfgMgr)
{
setupUi(this);
mGameInvoker = new ProcessInvoker();
mWizardInvoker = new ProcessInvoker();
connect(mWizardInvoker->getProcess(), &QProcess::started,
this, &MainDialog::wizardStarted);
connect(mWizardInvoker->getProcess(), &QProcess::started, this, &MainDialog::wizardStarted);
connect(mWizardInvoker->getProcess(), qOverload<int,QProcess::ExitStatus>(&QProcess::finished),
this, &MainDialog::wizardFinished);
connect(mWizardInvoker->getProcess(), qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this,
&MainDialog::wizardFinished);
iconWidget->setViewMode(QListView::IconMode);
iconWidget->setWrapping(false);
@ -114,7 +115,6 @@ void Launcher::MainDialog::createIcons()
advancedButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
connect(iconWidget, &QListWidget::currentItemChanged, this, &MainDialog::changePage);
}
void Launcher::MainDialog::createPages()
@ -148,7 +148,8 @@ void Launcher::MainDialog::createPages()
connect(mPlayPage, &PlayPage::signalProfileChanged, mDataFilesPage, &DataFilesPage::slotProfileChanged);
connect(mDataFilesPage, &DataFilesPage::signalProfileChanged, mPlayPage, &PlayPage::setProfilesIndex);
// Using Qt::QueuedConnection because signal is emitted in a subthread and slot is in the main thread
connect(mDataFilesPage, &DataFilesPage::signalLoadedCellsChanged, mAdvancedPage, &AdvancedPage::slotLoadedCellsChanged, Qt::QueuedConnection);
connect(mDataFilesPage, &DataFilesPage::signalLoadedCellsChanged, mAdvancedPage,
&AdvancedPage::slotLoadedCellsChanged, Qt::QueuedConnection);
}
Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()
@ -158,14 +159,15 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()
// Dialog wizard and setup will fail if the config directory does not already exist
const auto& userConfigDir = mCfgMgr.getUserConfigPath();
if ( ! exists(userConfigDir) ) {
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(Files::pathToQString(canonical(userConfigDir)))
);
and try again.<br>")
.arg(Files::pathToQString(canonical(userConfigDir))));
return FirstRunDialogResultFailure;
}
}
@ -176,15 +178,15 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()
msgBox.setWindowTitle(tr("First run"));
msgBox.setIcon(QMessageBox::Question);
msgBox.setStandardButtons(QMessageBox::NoButton);
msgBox.setText(tr("<html><head/><body><p><b>Welcome to OpenMW!</b></p> \
msgBox.setText(
tr("<html><head/><body><p><b>Welcome to OpenMW!</b></p> \
<p>It is recommended to run the Installation Wizard.</p> \
<p>The Wizard will let you select an existing Morrowind installation, \
or install Morrowind for OpenMW to use.</p></body></html>"));
QAbstractButton *wizardButton =
msgBox.addButton(tr("Run &Installation Wizard"), QMessageBox::AcceptRole); // ActionRole doesn't work?!
QAbstractButton *skipButton =
msgBox.addButton(tr("Skip"), QMessageBox::RejectRole);
QAbstractButton* wizardButton
= msgBox.addButton(tr("Run &Installation Wizard"), QMessageBox::AcceptRole); // ActionRole doesn't work?!
QAbstractButton* skipButton = msgBox.addButton(tr("Skip"), QMessageBox::RejectRole);
msgBox.exec();
@ -202,7 +204,8 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()
return FirstRunDialogResultFailure;
}
if (!setup() || !setupGameData()) {
if (!setup() || !setupGameData())
{
return FirstRunDialogResultFailure;
}
return FirstRunDialogResultContinue;
@ -225,7 +228,8 @@ void Launcher::MainDialog::setVersionLabel()
// Add the compile date and time
auto compileDate = QLocale(QLocale::C).toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy"));
auto compileTime = QLocale(QLocale::C).toTime(QString(__TIME__).simplified(), QLatin1String("hh:mm:ss"));
versionLabel->setToolTip(tr("Compiled on %1 %2").arg(QLocale::system().toString(compileDate, QLocale::LongFormat),
versionLabel->setToolTip(tr("Compiled on %1 %2")
.arg(QLocale::system().toString(compileDate, QLocale::LongFormat),
QLocale::system().toString(compileTime, QLocale::ShortFormat)));
}
@ -307,12 +311,15 @@ bool Launcher::MainDialog::setupLauncherSettings()
{
qDebug() << "Loading config file:" << path.toUtf8().constData();
QFile file(path);
if (file.exists()) {
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
if (file.exists())
{
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
cfgError(tr("Error opening OpenMW configuration file"),
tr("<br><b>Could not open %0 for reading</b><br><br> \
Please make sure you have the right permissions \
and try again.<br>").arg(file.fileName()));
and try again.<br>")
.arg(file.fileName()));
return false;
}
QTextStream stream(&file);
@ -336,16 +343,19 @@ bool Launcher::MainDialog::setupGameSettings()
QFile file;
auto loadFile = [&] (const QString& path, bool(Config::GameSettings::*reader)(QTextStream&, bool), bool ignoreContent = false) -> std::optional<bool>
{
auto loadFile = [&](const QString& path, bool (Config::GameSettings::*reader)(QTextStream&, bool),
bool ignoreContent = false) -> std::optional<bool> {
qDebug() << "Loading config file:" << path.toUtf8().constData();
file.setFileName(path);
if (file.exists()) {
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
if (file.exists())
{
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
cfgError(tr("Error opening OpenMW configuration file"),
tr("<br><b>Could not open %0 for reading</b><br><br> \
Please make sure you have the right permissions \
and try again.<br>").arg(file.fileName()));
and try again.<br>")
.arg(file.fileName()));
return {};
}
QTextStream stream(&file);
@ -387,7 +397,10 @@ bool Launcher::MainDialog::setupGameData()
{
QDir dir(path3);
QStringList filters;
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";
filters << "*.esp"
<< "*.esm"
<< "*.omwgame"
<< "*.omwaddon";
if (!dir.entryList(filters).isEmpty())
dataDirs.append(path3);
@ -399,13 +412,12 @@ bool Launcher::MainDialog::setupGameData()
msgBox.setWindowTitle(tr("Error detecting Morrowind installation"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::NoButton);
msgBox.setText(tr("<br><b>Could not find the Data Files location</b><br><br> \
msgBox.setText(
tr("<br><b>Could not find the Data Files location</b><br><br> \
The directory containing the data files was not found."));
QAbstractButton *wizardButton =
msgBox.addButton(tr("Run &Installation Wizard..."), QMessageBox::ActionRole);
QAbstractButton *skipButton =
msgBox.addButton(tr("Skip"), QMessageBox::RejectRole);
QAbstractButton* wizardButton = msgBox.addButton(tr("Run &Installation Wizard..."), QMessageBox::ActionRole);
QAbstractButton* skipButton = msgBox.addButton(tr("Skip"), QMessageBox::RejectRole);
Q_UNUSED(skipButton); // Suppress compiler unused warning
@ -437,7 +449,8 @@ bool Launcher::MainDialog::setupGraphicsSettings()
{
cfgError(tr("Error reading OpenMW configuration files"),
tr("<br>The problem may be due to an incomplete installation of OpenMW.<br> \
Reinstalling OpenMW may resolve the problem.<br>") + e.what());
Reinstalling OpenMW may resolve the problem.<br>")
+ e.what());
return false;
}
}
@ -469,7 +482,6 @@ void Launcher::MainDialog::saveSettings()
mLauncherSettings.setValue(QString("General/MainWindow/posy"), posY);
mLauncherSettings.setValue(QString("General/firstrun"), QString("false"));
}
bool Launcher::MainDialog::writeSettings()
@ -483,12 +495,15 @@ bool Launcher::MainDialog::writeSettings()
const auto& userPath = mCfgMgr.getUserConfigPath();
if (!exists(userPath)) {
if (!create_directories(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(Files::pathToQString(userPath)));
and try again.<br>")
.arg(Files::pathToQString(userPath)));
return false;
}
}
@ -500,27 +515,30 @@ bool Launcher::MainDialog::writeSettings()
QFile file(Files::pathToQString(userPath / "openmw.cfg"));
#endif
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
if (!file.open(QIODevice::ReadWrite | QIODevice::Text))
{
// File cannot be opened or created
cfgError(tr("Error writing OpenMW configuration file"),
tr("<br><b>Could not open or create %0 for writing</b><br><br> \
Please make sure you have the right permissions \
and try again.<br>").arg(file.fileName()));
and try again.<br>")
.arg(file.fileName()));
return false;
}
mGameSettings.writeFileWithComments(file);
file.close();
// Graphics settings
const auto settingsPath = mCfgMgr.getUserConfigPath() / "settings.cfg";
try {
try
{
Settings::Manager::saveUser(settingsPath);
}
catch (std::exception& e) {
std::string msg = "<br><b>Error writing settings.cfg</b><br><br>" +
Files::pathToUnicodeString(settingsPath) + "<br><br>" + e.what();
catch (std::exception& e)
{
std::string msg = "<br><b>Error writing settings.cfg</b><br><br>" + Files::pathToUnicodeString(settingsPath)
+ "<br><br>" + e.what();
cfgError(tr("Error writing user settings file"), tr(msg.c_str()));
return false;
}
@ -528,12 +546,14 @@ bool Launcher::MainDialog::writeSettings()
// Launcher settings
file.setFileName(Files::pathToQString(userPath / Config::LauncherSettings::sLauncherConfigFileName));
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate))
{
// File cannot be opened or created
cfgError(tr("Error writing Launcher configuration file"),
tr("<br><b>Could not open or create %0 for writing</b><br><br> \
Please make sure you have the right permissions \
and try again.<br>").arg(file.fileName()));
and try again.<br>")
.arg(file.fileName()));
return false;
}
@ -575,12 +595,14 @@ void Launcher::MainDialog::play()
if (!writeSettings())
return qApp->quit();
if (!mGameSettings.hasMaster()) {
if (!mGameSettings.hasMaster())
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("No game file selected"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<br><b>You do not have a game file selected.</b><br><br> \
msgBox.setText(
tr("<br><b>You do not have a game file selected.</b><br><br> \
OpenMW will not start without a game file selected.<br>"));
msgBox.exec();
return;

@ -1,7 +1,6 @@
#ifndef MAINDIALOG_H
#define MAINDIALOG_H
#ifndef Q_MOC_RUN
#include <components/files/configurationmanager.hpp>
@ -77,7 +76,10 @@ namespace Launcher
void loadSettings();
void saveSettings();
inline bool startProgram(const QString &name, bool detached = false) { return startProgram(name, QStringList(), detached); }
inline bool startProgram(const QString& name, bool detached = false)
{
return startProgram(name, QStringList(), detached);
}
bool startProgram(const QString& name, const QStringList& arguments, bool detached = false);
void closeEvent(QCloseEvent* event) override;
@ -95,7 +97,6 @@ namespace Launcher
Config::GameSettings mGameSettings;
Config::LauncherSettings mLauncherSettings;
};
}
#endif

@ -2,7 +2,8 @@
#include <QListView>
Launcher::PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
Launcher::PlayPage::PlayPage(QWidget* parent)
: QWidget(parent)
{
setObjectName("PlayPage");
setupUi(this);
@ -11,7 +12,6 @@ Launcher::PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
connect(profilesComboBox, qOverload<int>(&QComboBox::activated), this, &PlayPage::signalProfileChanged);
connect(playButton, &QPushButton::clicked, this, &PlayPage::slotPlayClicked);
}
void Launcher::PlayPage::setProfilesModel(QAbstractItemModel* model)

@ -26,9 +26,6 @@ namespace Launcher
private slots:
void slotPlayClicked();
};
}
#endif

@ -1,20 +1,19 @@
#include "settingspage.hpp"
#include <QFileDialog>
#include <QMessageBox>
#include <QDebug>
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
#include <components/files/conversion.hpp>
#include <components/files/qtconversion.hpp>
#include "utils/textinputdialog.hpp"
#include "datafilespage.hpp"
#include "utils/textinputdialog.hpp"
using namespace Process;
Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager &cfg,
Config::GameSettings &gameSettings,
Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings,
Config::LauncherSettings& launcherSettings, MainDialog* parent)
: QWidget(parent)
, mCfgMgr(cfg)
@ -25,12 +24,7 @@ Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager &cfg,
setupUi(this);
QStringList languages;
languages << tr("English")
<< tr("French")
<< tr("German")
<< tr("Italian")
<< tr("Polish")
<< tr("Russian")
languages << tr("English") << tr("French") << tr("German") << tr("Italian") << tr("Polish") << tr("Russian")
<< tr("Spanish");
languageComboBox->addItems(languages);
@ -39,22 +33,19 @@ Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager &cfg,
mImporterInvoker = new ProcessInvoker();
resetProgressBar();
connect(mWizardInvoker->getProcess(), &QProcess::started,
this, &SettingsPage::wizardStarted);
connect(mWizardInvoker->getProcess(), &QProcess::started, this, &SettingsPage::wizardStarted);
connect(mWizardInvoker->getProcess(), qOverload<int,QProcess::ExitStatus>(&QProcess::finished),
this, &SettingsPage::wizardFinished);
connect(mWizardInvoker->getProcess(), qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this,
&SettingsPage::wizardFinished);
connect(mImporterInvoker->getProcess(), &QProcess::started,
this, &SettingsPage::importerStarted);
connect(mImporterInvoker->getProcess(), &QProcess::started, this, &SettingsPage::importerStarted);
connect(mImporterInvoker->getProcess(), qOverload<int,QProcess::ExitStatus>(&QProcess::finished),
this, &SettingsPage::importerFinished);
connect(mImporterInvoker->getProcess(), qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this,
&SettingsPage::importerFinished);
mProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this);
connect(mProfileDialog->lineEdit(), &LineEdit::textChanged,
this, &SettingsPage::updateOkButton);
connect(mProfileDialog->lineEdit(), &LineEdit::textChanged, this, &SettingsPage::updateOkButton);
// Detect Morrowind configuration files
QStringList iniPaths;
@ -76,10 +67,13 @@ Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager &cfg,
}
}
if (!iniPaths.isEmpty()) {
if (!iniPaths.isEmpty())
{
settingsComboBox->addItems(iniPaths);
importerButton->setEnabled(true);
} else {
}
else
{
importerButton->setEnabled(false);
}
@ -113,16 +107,20 @@ void Launcher::SettingsPage::on_importerButton_clicked()
QFile file(Files::pathToQString(path));
#endif
if (!file.exists()) {
if (!file.open(QIODevice::ReadWrite)) {
if (!file.exists())
{
if (!file.open(QIODevice::ReadWrite))
{
// File cannot be created
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error writing OpenMW configuration file"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<html><head/><body><p><b>Could not open or create %1 for writing </b></p> \
msgBox.setText(
tr("<html><head/><body><p><b>Could not open or create %1 for writing </b></p> \
<p>Please make sure you have the right permissions \
and try again.</p></body></html>").arg(file.fileName()));
and try again.</p></body></html>")
.arg(file.fileName()));
msgBox.exec();
return;
}
@ -159,13 +157,9 @@ void Launcher::SettingsPage::on_importerButton_clicked()
void Launcher::SettingsPage::on_browseButton_clicked()
{
QString iniFile = QFileDialog::getOpenFileName(
this,
QObject::tr("Select configuration file"),
QDir::currentPath(),
QString iniFile = QFileDialog::getOpenFileName(this, QObject::tr("Select configuration file"), QDir::currentPath(),
QString(tr("Morrowind configuration file (*.ini)")));
if (iniFile.isEmpty())
return;
@ -176,7 +170,8 @@ void Launcher::SettingsPage::on_browseButton_clicked()
const QString path(QDir::toNativeSeparators(info.absoluteFilePath()));
if (settingsComboBox->findText(path) == -1) {
if (settingsComboBox->findText(path) == -1)
{
settingsComboBox->addItem(path);
settingsComboBox->setCurrentIndex(settingsComboBox->findText(path));
importerButton->setEnabled(true);
@ -241,16 +236,15 @@ void Launcher::SettingsPage::resetProgressBar()
void Launcher::SettingsPage::updateOkButton(const QString& text)
{
// We do this here because we need to access the profiles
if (text.isEmpty()) {
if (text.isEmpty())
{
mProfileDialog->setOkButtonEnabled(false);
return;
}
const QStringList profiles(mLauncherSettings.getContentLists());
(profiles.contains(text))
? mProfileDialog->setOkButtonEnabled(false)
: mProfileDialog->setOkButtonEnabled(true);
(profiles.contains(text)) ? mProfileDialog->setOkButtonEnabled(false) : mProfileDialog->setOkButtonEnabled(true);
}
void Launcher::SettingsPage::saveSettings()
@ -259,11 +253,16 @@ void Launcher::SettingsPage::saveSettings()
mLauncherSettings.setValue(QLatin1String("Settings/language"), language);
if (language == QLatin1String("Polish")) {
if (language == QLatin1String("Polish"))
{
mGameSettings.setValue(QLatin1String("encoding"), QLatin1String("win1250"));
} else if (language == QLatin1String("Russian")) {
}
else if (language == QLatin1String("Russian"))
{
mGameSettings.setValue(QLatin1String("encoding"), QLatin1String("win1251"));
} else {
}
else
{
mGameSettings.setValue(QLatin1String("encoding"), QLatin1String("win1252"));
}
}

@ -7,9 +7,15 @@
#include "maindialog.hpp"
namespace Files { struct ConfigurationManager; }
namespace Config { class GameSettings;
class LauncherSettings; }
namespace Files
{
struct ConfigurationManager;
}
namespace Config
{
class GameSettings;
class LauncherSettings;
}
namespace Launcher
{
@ -45,7 +51,6 @@ namespace Launcher
void updateOkButton(const QString& text);
private:
Process::ProcessInvoker* mWizardInvoker;
Process::ProcessInvoker* mImporterInvoker;
@ -56,7 +61,6 @@ namespace Launcher
MainDialog* mMain;
TextInputDialog* mProfileDialog;
};
}

@ -1,7 +1,7 @@
#include "cellnameloader.hpp"
#include <components/esm3/loadcell.hpp>
#include <components/contentselector/view/contentselector.hpp>
#include <components/esm3/loadcell.hpp>
QSet<QString> CellNameLoader::getCellNames(QStringList& contentPaths)
{
@ -9,7 +9,8 @@ QSet<QString> CellNameLoader::getCellNames(QStringList &contentPaths)
ESM::ESMReader esmReader;
// Loop through all content files
for (auto &contentPath : contentPaths) {
for (auto& contentPath : contentPaths)
{
if (contentPath.endsWith(".omwscripts", Qt::CaseInsensitive))
continue;
esmReader.open(contentPath.toStdString());
@ -20,9 +21,11 @@ QSet<QString> CellNameLoader::getCellNames(QStringList &contentPaths)
ESM::NAME recordName = esmReader.getRecName();
esmReader.getRecHeader();
if (isCellRecord(recordName)) {
if (isCellRecord(recordName))
{
QString cellName = getCellName(esmReader);
if (!cellName.isEmpty()) {
if (!cellName.isEmpty())
{
cellNames.insert(cellName);
}
}
@ -48,4 +51,3 @@ QString CellNameLoader::getCellName(ESM::ESMReader &esmReader)
return QString::fromStdString(cell.mName);
}

@ -6,13 +6,20 @@
#include <components/esm3/esmreader.hpp>
namespace ESM {class ESMReader; struct Cell;}
namespace ContentSelectorView {class ContentSelector;}
class CellNameLoader {
namespace ESM
{
class ESMReader;
struct Cell;
}
namespace ContentSelectorView
{
class ContentSelector;
}
class CellNameLoader
{
public:
/**
* Returns the names of all cells contained within the given content files
* @param contentPaths the file paths of each content file to be examined
@ -36,5 +43,4 @@ private:
QString getCellName(ESM::ESMReader& esmReader);
};
#endif // OPENMW_CELLNAMELOADER_H

@ -23,8 +23,7 @@ void LineEdit::resizeEvent(QResizeEvent *)
{
QSize sz = mClearButton->sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
mClearButton->move(rect().right() - frameWidth - sz.width(),
(rect().bottom() + 1 - sz.height())/2);
mClearButton->move(rect().right() - frameWidth - sz.width(), (rect().bottom() + 1 - sz.height()) / 2);
}
void LineEdit::updateClearButton(const QString& text)

@ -38,4 +38,3 @@ protected:
};
#endif // LIENEDIT_H

@ -1,5 +1,5 @@
#include <vector>
#include <string>
#include <vector>
namespace Launcher
{

@ -1,13 +1,12 @@
#include <QString>
#include <QApplication>
#include <QString>
#include "profilescombobox.hpp"
ProfilesComboBox::ProfilesComboBox(QWidget *parent) :
ContentSelectorView::ComboBox(parent)
ProfilesComboBox::ProfilesComboBox(QWidget* parent)
: ContentSelectorView::ComboBox(parent)
{
connect(this, qOverload<int>(&ProfilesComboBox::activated),
this, &ProfilesComboBox::slotIndexChangedByUser);
connect(this, qOverload<int>(&ProfilesComboBox::activated), this, &ProfilesComboBox::slotIndexChangedByUser);
setInsertPolicy(QComboBox::NoInsert);
}
@ -17,7 +16,8 @@ void ProfilesComboBox::setEditEnabled(bool editable)
if (isEditable() == editable)
return;
if (!editable) {
if (!editable)
{
disconnect(lineEdit(), &QLineEdit::editingFinished, this, &ProfilesComboBox::slotEditingFinished);
disconnect(lineEdit(), &QLineEdit::textChanged, this, &ProfilesComboBox::slotTextChanged);
return setEditable(false);
@ -46,9 +46,12 @@ void ProfilesComboBox::slotTextChanged(const QString &text)
int index = findText(text);
if (text.isEmpty() || (index != -1 && index != currentIndex())) {
if (text.isEmpty() || (index != -1 && index != currentIndex()))
{
lineEdit()->setPalette(palette);
} else {
}
else
{
lineEdit()->setPalette(QApplication::palette());
}
}
@ -89,5 +92,6 @@ ProfilesComboBox::ComboBoxLineEdit::ComboBoxLineEdit (QWidget *parent)
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
setObjectName(QString("ComboBoxLineEdit"));
setStyleSheet(QString("ComboBoxLineEdit { background-color: transparent; padding-right: %1px; } ").arg(mClearButton->sizeHint().width() + frameWidth + 1));
setStyleSheet(QString("ComboBoxLineEdit { background-color: transparent; padding-right: %1px; } ")
.arg(mClearButton->sizeHint().width() + frameWidth + 1));
}

@ -20,7 +20,6 @@ public:
};
public:
explicit ProfilesComboBox(QWidget* parent = nullptr);
void setEditEnabled(bool editable);
void setCurrentProfile(int index)

@ -1,14 +1,14 @@
#include "textinputdialog.hpp"
#include <QDialogButtonBox>
#include <QApplication>
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QValidator>
#include <QLabel>
Launcher::TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWidget *parent) :
QDialog(parent)
Launcher::TextInputDialog::TextInputDialog(const QString& title, const QString& text, QWidget* parent)
: QDialog(parent)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
mButtonBox = new QDialogButtonBox(this);
@ -43,9 +43,7 @@ Launcher::TextInputDialog::TextInputDialog(const QString& title, const QString &
connect(mButtonBox, &QDialogButtonBox::rejected, this, &TextInputDialog::reject);
}
Launcher::TextInputDialog::~TextInputDialog()
{
}
Launcher::TextInputDialog::~TextInputDialog() {}
int Launcher::TextInputDialog::exec()
{
@ -62,9 +60,12 @@ void Launcher::TextInputDialog::setOkButtonEnabled(bool enabled)
QPalette palette;
palette.setColor(QPalette::Text, Qt::red);
if (enabled) {
if (enabled)
{
mLineEdit->setPalette(QApplication::palette());
} else {
}
else
{
// Existing profile name, make the text red
mLineEdit->setPalette(palette);
}

@ -14,7 +14,6 @@ namespace Launcher
Q_OBJECT
public:
explicit TextInputDialog(const QString& title, const QString& text, QWidget* parent = nullptr);
~TextInputDialog() override;
@ -24,10 +23,8 @@ namespace Launcher
int exec() override;
private:
QDialogButtonBox* mButtonBox;
LineEdit* mLineEdit;
};
}

File diff suppressed because it is too large Load Diff

@ -1,16 +1,17 @@
#ifndef MWINIIMPORTER_IMPORTER
#define MWINIIMPORTER_IMPORTER 1
#include <string>
#include <map>
#include <vector>
#include <exception>
#include <iosfwd>
#include <filesystem>
#include <iosfwd>
#include <map>
#include <string>
#include <vector>
#include <components/to_utf8/to_utf8.hpp>
class MwIniImporter {
class MwIniImporter
{
public:
typedef std::map<std::string, std::string> strmap;
typedef std::map<std::string, std::vector<std::string>> multistrmap;
@ -23,15 +24,15 @@ class MwIniImporter {
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 std::filesystem::path& iniFilename) const;
void importGameFiles(multistrmap& cfg, const multistrmap& ini, const std::filesystem::path& iniFilename) const;
void importArchives(multistrmap& cfg, const multistrmap& ini) const;
static void writeToFile(std::ostream& out, const multistrmap& cfg);
static std::vector<std::string> dependencySort(MwIniImporter::dependencyList source);
private:
static void dependencySortStep(std::string& element, MwIniImporter::dependencyList& source, std::vector<std::string>& result);
static void dependencySortStep(
std::string& element, MwIniImporter::dependencyList& source, std::vector<std::string>& result);
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);

@ -1,8 +1,8 @@
#include "importer.hpp"
#include <iostream>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <boost/program_options.hpp>
@ -13,7 +13,8 @@ namespace bpo = boost::program_options;
namespace sfs = std::filesystem;
#ifndef _WIN32
int main(int argc, char *argv[]) {
int main(int argc, char* argv[])
{
#else
// Include on Windows only
@ -22,13 +23,13 @@ int main(int argc, char *argv[]) {
class utf8argv
{
public:
utf8argv(int argc, wchar_t* wargv[])
{
args.reserve(argc);
argv = new const char*[argc];
for (int i = 0; i < argc; ++i) {
for (int i = 0; i < argc; ++i)
{
args.push_back(boost::locale::conv::utf_to_utf<char>(wargv[i]));
argv[i] = args.back().c_str();
}
@ -52,7 +53,8 @@ private:
For boost::filesystem::path::imbue see components/files/windowspath.cpp
*/
int wmain(int argc, wchar_t *wargv[]) {
int wmain(int argc, wchar_t* wargv[])
{
utf8argv converter(argc, wargv);
char** argv = converter.get();
#endif
@ -72,7 +74,8 @@ int wmain(int argc, wchar_t *wargv[]) {
addOption("no-archives,A", "disable bsa archives import");
addOption("encoding,e", bpo::value<std::string>()->default_value("win1252"),
"Character encoding used in OpenMW game messages:\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, "
"Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n"
"\n\twin1252 - Western European (Latin) alphabet, used by default");
;
@ -80,29 +83,39 @@ int wmain(int argc, wchar_t *wargv[]) {
bpo::variables_map vm;
bpo::parsed_options parsed = bpo::command_line_parser(argc, argv)
.options(desc)
.positional(p_desc)
.run();
bpo::parsed_options parsed = bpo::command_line_parser(argc, argv).options(desc).positional(p_desc).run();
bpo::store(parsed, vm);
if(vm.count("help") || !vm.count("ini") || !vm.count("cfg")) {
if (vm.count("help") || !vm.count("ini") || !vm.count("cfg"))
{
std::cout << desc;
return 0;
}
bpo::notify(vm);
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.
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::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<Files::MaybeQuotedPath>().u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
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<Files::MaybeQuotedPath>()
.u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due
// to implementation bugs.
}
if(!std::filesystem::exists(iniFile)) {
if (!std::filesystem::exists(iniFile))
{
std::cerr << "ini file does not exist" << std::endl;
return -3;
}
@ -129,11 +142,13 @@ int wmain(int argc, wchar_t *wargv[]) {
importer.merge(cfg, ini);
importer.mergeFallback(cfg, ini);
if(vm.count("game-files")) {
if (vm.count("game-files"))
{
importer.importGameFiles(cfg, ini, iniFile);
}
if(!vm.count("no-archives")) {
if (!vm.count("no-archives"))
{
importer.importArchives(cfg, ini);
}

@ -1,17 +1,21 @@
#include "worldspacedata.hpp"
#include "navmesh.hpp"
#include "worldspacedata.hpp"
#include <components/debug/debugging.hpp>
#include <components/detournavigator/agentbounds.hpp>
#include <components/detournavigator/navmeshdb.hpp>
#include <components/detournavigator/recastglobalallocator.hpp>
#include <components/detournavigator/settings.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/esm3/readerscache.hpp>
#include <components/esm3/variant.hpp>
#include <components/esmloader/esmdata.hpp>
#include <components/esmloader/load.hpp>
#include <components/fallback/fallback.hpp>
#include <components/fallback/validate.hpp>
#include <components/files/configurationmanager.hpp>
#include <components/files/conversion.hpp>
#include <components/platform/platform.hpp>
#include <components/resource/bulletshapemanager.hpp>
#include <components/resource/imagemanager.hpp>
#include <components/resource/niffilemanager.hpp>
@ -21,10 +25,6 @@
#include <components/version/version.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/registerarchives.hpp>
#include <components/esm3/readerscache.hpp>
#include <components/platform/platform.hpp>
#include <components/detournavigator/agentbounds.hpp>
#include <components/files/conversion.hpp>
#include <osg/Vec3f>
@ -40,7 +40,6 @@
#include <io.h>
#endif
namespace NavMeshTool
{
namespace
@ -59,45 +58,63 @@ namespace NavMeshTool
addOption("version", "print version information and quit");
addOption("data", bpo::value<Files::MaybeQuotedPathContainer>()->default_value(Files::MaybeQuotedPathContainer(), "data")
->multitoken()->composing(), "set data directories (later directories have higher priority)");
addOption("data",
bpo::value<Files::MaybeQuotedPathContainer>()
->default_value(Files::MaybeQuotedPathContainer(), "data")
->multitoken()
->composing(),
"set data directories (later directories have higher priority)");
addOption("data-local", bpo::value<Files::MaybeQuotedPathContainer::value_type>()->default_value(Files::MaybeQuotedPathContainer::value_type(), ""),
addOption("data-local",
bpo::value<Files::MaybeQuotedPathContainer::value_type>()->default_value(
Files::MaybeQuotedPathContainer::value_type(), ""),
"set local data directory (highest priority)");
addOption("fallback-archive", bpo::value<StringsVector>()->default_value(StringsVector(), "fallback-archive")
->multitoken()->composing(), "set fallback BSA archives (later archives have higher priority)");
addOption("fallback-archive",
bpo::value<StringsVector>()
->default_value(StringsVector(), "fallback-archive")
->multitoken()
->composing(),
"set fallback BSA archives (later archives have higher priority)");
addOption("resources", bpo::value<Files::MaybeQuotedPath>()->default_value(Files::MaybeQuotedPath(), "resources"),
addOption("resources",
bpo::value<Files::MaybeQuotedPath>()->default_value(Files::MaybeQuotedPath(), "resources"),
"set resources directory");
addOption("content", bpo::value<StringsVector>()->default_value(StringsVector(), "")
->multitoken()->composing(), "content file(s): esm/esp, or omwgame/omwaddon/omwscripts");
addOption("content",
bpo::value<StringsVector>()->default_value(StringsVector(), "")->multitoken()->composing(),
"content file(s): esm/esp, or omwgame/omwaddon/omwscripts");
addOption("fs-strict", bpo::value<bool>()->implicit_value(true)
->default_value(false), "strict file system handling (no case folding)");
addOption("fs-strict", bpo::value<bool>()->implicit_value(true)->default_value(false),
"strict file system handling (no case folding)");
addOption("encoding", bpo::value<std::string>()->
default_value("win1252"),
addOption("encoding", bpo::value<std::string>()->default_value("win1252"),
"Character encoding used in OpenMW game messages:\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, "
"Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n"
"\n\twin1252 - Western European (Latin) alphabet, used by default");
addOption("fallback", bpo::value<Fallback::FallbackMap>()->default_value(Fallback::FallbackMap(), "")
->multitoken()->composing(), "fallback values");
addOption("fallback",
bpo::value<Fallback::FallbackMap>()
->default_value(Fallback::FallbackMap(), "")
->multitoken()
->composing(),
"fallback values");
addOption("threads", bpo::value<std::size_t>()->default_value(std::max<std::size_t>(std::thread::hardware_concurrency() - 1, 1)),
addOption("threads",
bpo::value<std::size_t>()->default_value(
std::max<std::size_t>(std::thread::hardware_concurrency() - 1, 1)),
"number of threads for parallel processing");
addOption("process-interior-cells", bpo::value<bool>()->implicit_value(true)
->default_value(false), "build navmesh for interior cells");
addOption("process-interior-cells", bpo::value<bool>()->implicit_value(true)->default_value(false),
"build navmesh for interior cells");
addOption("remove-unused-tiles", bpo::value<bool>()->implicit_value(true)
->default_value(false), "remove tiles from cache that will not be used with current content profile");
addOption("remove-unused-tiles", bpo::value<bool>()->implicit_value(true)->default_value(false),
"remove tiles from cache that will not be used with current content profile");
addOption("write-binary-log", bpo::value<bool>()->implicit_value(true)
->default_value(false), "write progress in binary messages to be consumed by the launcher");
addOption("write-binary-log", bpo::value<bool>()->implicit_value(true)->default_value(false),
"write progress in binary messages to be consumed by the launcher");
Files::ConfigurationManager::addCommonOptions(result);
@ -110,8 +127,7 @@ namespace NavMeshTool
bpo::options_description desc = makeOptionsDescription();
bpo::parsed_options options = bpo::command_line_parser(argc, argv)
.options(desc).allow_unregistered().run();
bpo::parsed_options options = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
bpo::variables_map variables;
bpo::store(options, variables);
@ -175,10 +191,13 @@ namespace NavMeshTool
Settings::Manager settings;
settings.load(config);
const auto agentCollisionShape = DetourNavigator::toCollisionShapeType(Settings::Manager::getInt("actor collision shape type", "Game"));
const osg::Vec3f agentHalfExtents = Settings::Manager::getVector3("default actor pathfind half extents", "Game");
const auto agentCollisionShape = DetourNavigator::toCollisionShapeType(
Settings::Manager::getInt("actor collision shape type", "Game"));
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::uint64_t maxDbFileSize
= static_cast<std::uint64_t>(Settings::Manager::getInt64("max navmeshdb file size", "Navigator"));
const auto dbPath = Files::pathToUnicodeString(config.getUserDataPath() / "navmesh.db");
DetourNavigator::NavMeshDb db(dbPath, maxDbFileSize);
@ -192,7 +211,8 @@ namespace NavMeshTool
query.mLoadGameSettings = true;
query.mLoadLands = true;
query.mLoadStatics = true;
const EsmLoader::EsmData esmData = EsmLoader::loadEsmData(query, contentFiles, fileCollections, readers, &encoder);
const EsmLoader::EsmData esmData
= EsmLoader::loadEsmData(query, contentFiles, fileCollections, readers, &encoder);
Resource::ImageManager imageManager(&vfs);
Resource::NifFileManager nifFileManager(&vfs);
@ -200,10 +220,11 @@ namespace NavMeshTool
Resource::BulletShapeManager bulletShapeManager(&vfs, &sceneManager, &nifFileManager);
DetourNavigator::RecastGlobalAllocator::init();
DetourNavigator::Settings navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager();
navigatorSettings.mRecast.mSwimHeightScale = EsmLoader::getGameSetting(esmData.mGameSettings, "fSwimHeightScale").getFloat();
navigatorSettings.mRecast.mSwimHeightScale
= EsmLoader::getGameSetting(esmData.mGameSettings, "fSwimHeightScale").getFloat();
WorldspaceData cellsData = gatherWorldspaceData(navigatorSettings, readers, vfs, bulletShapeManager,
esmData, processInteriorCells, writeBinaryLog);
WorldspaceData cellsData = gatherWorldspaceData(
navigatorSettings, readers, vfs, bulletShapeManager, esmData, processInteriorCells, writeBinaryLog);
const Status status = generateAllNavMeshTiles(agentBounds, navigatorSettings, threadsNumber,
removeUnusedTiles, writeBinaryLog, cellsData, std::move(db));
@ -217,10 +238,12 @@ namespace NavMeshTool
Log(Debug::Warning) << "Cancelled";
break;
case Status::NotEnoughSpace:
Log(Debug::Warning) << "Navmesh generation is cancelled due to running out of disk space or limits "
Log(Debug::Warning)
<< "Navmesh generation is cancelled due to running out of disk space or limits "
<< "for navmesh db. Check disk space at the db location \"" << dbPath
<< "\". If there is enough space, adjust \"max navmeshdb file size\" setting (see "
<< "https://openmw.readthedocs.io/en/latest/reference/modding/settings/navigator.html?highlight=navmesh#max-navmeshdb-file-size).";
<< "https://openmw.readthedocs.io/en/latest/reference/modding/settings/"
"navigator.html?highlight=navmesh#max-navmeshdb-file-size).";
break;
}

@ -2,6 +2,7 @@
#include "worldspacedata.hpp"
#include <components/debug/debugging.hpp>
#include <components/debug/debuglog.hpp>
#include <components/detournavigator/generatenavmeshtile.hpp>
#include <components/detournavigator/gettilespositions.hpp>
@ -14,20 +15,19 @@
#include <components/detournavigator/settings.hpp>
#include <components/detournavigator/tileposition.hpp>
#include <components/misc/progressreporter.hpp>
#include <components/navmeshtool/protocol.hpp>
#include <components/sceneutil/workqueue.hpp>
#include <components/sqlite3/transaction.hpp>
#include <components/debug/debugging.hpp>
#include <components/navmeshtool/protocol.hpp>
#include <osg/Vec3f>
#include <atomic>
#include <chrono>
#include <cstddef>
#include <utility>
#include <vector>
#include <random>
#include <string_view>
#include <utility>
#include <vector>
namespace NavMeshTool
{
@ -35,17 +35,17 @@ namespace NavMeshTool
{
using DetourNavigator::AgentBounds;
using DetourNavigator::GenerateNavMeshTile;
using DetourNavigator::MeshSource;
using DetourNavigator::NavMeshDb;
using DetourNavigator::NavMeshTileInfo;
using DetourNavigator::PreparedNavMeshData;
using DetourNavigator::RecastMeshProvider;
using DetourNavigator::MeshSource;
using DetourNavigator::Settings;
using DetourNavigator::ShapeId;
using DetourNavigator::TileId;
using DetourNavigator::TilePosition;
using DetourNavigator::TileVersion;
using DetourNavigator::TilesPositionsRange;
using DetourNavigator::TileVersion;
using Sqlite3::Transaction;
void logGeneratedTiles(std::size_t provided, std::size_t expected)
@ -59,7 +59,8 @@ namespace NavMeshTool
void serializeToStderr(const T& value)
{
const std::vector<std::byte> data = serialize(value);
getLockedRawStderr()->write(reinterpret_cast<const char*>(data.data()), static_cast<std::streamsize>(data.size()));
getLockedRawStderr()->write(
reinterpret_cast<const char*>(data.data()), static_cast<std::streamsize>(data.size()));
}
void logGeneratedTilesMessage(std::size_t number)
@ -69,10 +70,7 @@ namespace NavMeshTool
struct LogGeneratedTiles
{
void operator()(std::size_t provided, std::size_t expected) const
{
logGeneratedTiles(provided, expected);
}
void operator()(std::size_t provided, std::size_t expected) const { logGeneratedTiles(provided, expected); }
};
class NavMeshTileConsumer final : public DetourNavigator::NavMeshTileConsumer
@ -87,7 +85,8 @@ namespace NavMeshTool
, mTransaction(mDb.startTransaction(Sqlite3::TransactionMode::Immediate))
, mNextTileId(mDb.getMaxTileId() + 1)
, mNextShapeId(mDb.getMaxShapeId() + 1)
{}
{
}
std::size_t getProvided() const { return mProvided.load(); }
@ -137,34 +136,37 @@ namespace NavMeshTool
if (mRemoveUnusedTiles)
{
std::lock_guard lock(mMutex);
mDeleted += static_cast<std::size_t>(mDb.deleteTilesAtExcept(worldspace, tilePosition, TileId {tileId}));
mDeleted += static_cast<std::size_t>(
mDb.deleteTilesAtExcept(worldspace, tilePosition, TileId{ tileId }));
}
report();
}
void insert(std::string_view worldspace, const TilePosition& tilePosition,
std::int64_t version, const std::vector<std::byte>& input, PreparedNavMeshData& data) override
void insert(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t version,
const std::vector<std::byte>& input, PreparedNavMeshData& data) override
{
{
std::lock_guard lock(mMutex);
if (mRemoveUnusedTiles)
mDeleted += static_cast<std::size_t>(mDb.deleteTilesAt(worldspace, tilePosition));
data.mUserId = static_cast<unsigned>(mNextTileId);
mDb.insertTile(mNextTileId, worldspace, tilePosition, TileVersion {version}, input, serialize(data));
mDb.insertTile(
mNextTileId, worldspace, tilePosition, TileVersion{ version }, input, serialize(data));
++mNextTileId;
}
++mInserted;
report();
}
void update(std::string_view worldspace, const TilePosition& tilePosition,
std::int64_t tileId, std::int64_t version, PreparedNavMeshData& data) override
void update(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t tileId,
std::int64_t version, PreparedNavMeshData& data) override
{
data.mUserId = static_cast<unsigned>(tileId);
{
std::lock_guard lock(mMutex);
if (mRemoveUnusedTiles)
mDeleted += static_cast<std::size_t>(mDb.deleteTilesAtExcept(worldspace, tilePosition, TileId {tileId}));
mDeleted += static_cast<std::size_t>(
mDb.deleteTilesAtExcept(worldspace, tilePosition, TileId{ tileId }));
mDb.updateTile(TileId{ tileId }, TileVersion{ version }, serialize(data));
}
++mUpdated;
@ -252,32 +254,29 @@ namespace NavMeshTool
};
}
Status generateAllNavMeshTiles(const AgentBounds& agentBounds, const Settings& settings,
std::size_t threadsNumber, bool removeUnusedTiles, bool writeBinaryLog, WorldspaceData& data,
NavMeshDb&& db)
Status generateAllNavMeshTiles(const AgentBounds& agentBounds, const Settings& settings, std::size_t threadsNumber,
bool removeUnusedTiles, bool writeBinaryLog, WorldspaceData& data, NavMeshDb&& db)
{
Log(Debug::Info) << "Generating navmesh tiles by " << threadsNumber << " parallel workers...";
SceneUtil::WorkQueue workQueue(threadsNumber);
auto navMeshTileConsumer = std::make_shared<NavMeshTileConsumer>(std::move(db), removeUnusedTiles, writeBinaryLog);
auto navMeshTileConsumer
= std::make_shared<NavMeshTileConsumer>(std::move(db), removeUnusedTiles, writeBinaryLog);
std::size_t tiles = 0;
std::mt19937_64 random;
for (const std::unique_ptr<WorldspaceNavMeshInput>& input : data.mNavMeshInputs)
{
const auto range = DetourNavigator::makeTilesPositionsRange(
Misc::Convert::toOsgXY(input->mAabb.m_min),
Misc::Convert::toOsgXY(input->mAabb.m_max),
settings.mRecast
);
const auto range = DetourNavigator::makeTilesPositionsRange(Misc::Convert::toOsgXY(input->mAabb.m_min),
Misc::Convert::toOsgXY(input->mAabb.m_max), settings.mRecast);
if (removeUnusedTiles)
navMeshTileConsumer->removeTilesOutsideRange(input->mWorldspace, range);
std::vector<TilePosition> worldspaceTiles;
DetourNavigator::getTilesPositions(range,
[&] (const TilePosition& tilePosition) { worldspaceTiles.push_back(tilePosition); });
DetourNavigator::getTilesPositions(
range, [&](const TilePosition& tilePosition) { worldspaceTiles.push_back(tilePosition); });
tiles += worldspaceTiles.size();
@ -289,14 +288,9 @@ namespace NavMeshTool
std::shuffle(worldspaceTiles.begin(), worldspaceTiles.end(), random);
for (const TilePosition& tilePosition : worldspaceTiles)
workQueue.addWorkItem(new GenerateNavMeshTile(
input->mWorldspace,
tilePosition,
RecastMeshProvider(input->mTileCachedRecastMeshManager),
agentBounds,
settings,
navMeshTileConsumer
));
workQueue.addWorkItem(new GenerateNavMeshTile(input->mWorldspace, tilePosition,
RecastMeshProvider(input->mTileCachedRecastMeshManager), agentBounds, settings,
navMeshTileConsumer));
}
const Status status = navMeshTileConsumer->wait();
@ -307,10 +301,8 @@ namespace NavMeshTool
const auto updated = navMeshTileConsumer->getUpdated();
const auto deleted = navMeshTileConsumer->getDeleted();
Log(Debug::Info) << "Generated navmesh for " << navMeshTileConsumer->getProvided() << " tiles, "
<< inserted << " are inserted, "
<< updated << " updated and "
<< deleted << " deleted";
Log(Debug::Info) << "Generated navmesh for " << navMeshTileConsumer->getProvided() << " tiles, " << inserted
<< " are inserted, " << updated << " updated and " << deleted << " deleted";
if (inserted + updated + deleted > 0)
{

@ -23,9 +23,9 @@ namespace NavMeshTool
NotEnoughSpace,
};
Status generateAllNavMeshTiles(const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Settings& settings,
std::size_t threadsNumber, bool removeUnusedTiles, bool writeBinaryLog, WorldspaceData& cellsData,
DetourNavigator::NavMeshDb&& db);
Status generateAllNavMeshTiles(const DetourNavigator::AgentBounds& agentBounds,
const DetourNavigator::Settings& settings, std::size_t threadsNumber, bool removeUnusedTiles,
bool writeBinaryLog, WorldspaceData& cellsData, DetourNavigator::NavMeshDb&& db);
}
#endif

@ -1,27 +1,27 @@
#include "worldspacedata.hpp"
#include <components/bullethelpers/aabb.hpp>
#include <components/debug/debugging.hpp>
#include <components/debug/debuglog.hpp>
#include <components/detournavigator/gettilespositions.hpp>
#include <components/detournavigator/objectid.hpp>
#include <components/detournavigator/recastmesh.hpp>
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
#include <components/detournavigator/settings.hpp>
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
#include <components/esm3/cellref.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/esm3/loadland.hpp>
#include <components/esm3/readerscache.hpp>
#include <components/esmloader/esmdata.hpp>
#include <components/esmloader/lessbyid.hpp>
#include <components/esmloader/record.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/misc/strings/lower.hpp>
#include <components/navmeshtool/protocol.hpp>
#include <components/resource/bulletshapemanager.hpp>
#include <components/settings/settings.hpp>
#include <components/vfs/manager.hpp>
#include <components/debug/debugging.hpp>
#include <components/navmeshtool/protocol.hpp>
#include <components/esm3/readerscache.hpp>
#include <LinearMath/btVector3.h>
@ -56,21 +56,28 @@ namespace NavMeshTool
float mScale;
ESM::Position mPos;
CellRef(ESM::RecNameInts type, ESM::RefNum refNum, std::string&& refId, float scale, const ESM::Position& pos)
: mType(type), mRefNum(refNum), mRefId(std::move(refId)), mScale(scale), mPos(pos) {}
CellRef(
ESM::RecNameInts type, ESM::RefNum refNum, std::string&& refId, float scale, const ESM::Position& pos)
: mType(type)
, mRefNum(refNum)
, mRefId(std::move(refId))
, mScale(scale)
, mPos(pos)
{
}
};
ESM::RecNameInts getType(const EsmLoader::EsmData& esmData, std::string_view refId)
{
const auto it = std::lower_bound(esmData.mRefIdTypes.begin(), esmData.mRefIdTypes.end(),
refId, EsmLoader::LessById {});
const auto it = std::lower_bound(
esmData.mRefIdTypes.begin(), esmData.mRefIdTypes.end(), refId, EsmLoader::LessById{});
if (it == esmData.mRefIdTypes.end() || it->mId != refId)
return {};
return it->mType;
}
std::vector<CellRef> loadCellRefs(const ESM::Cell& cell, const EsmLoader::EsmData& esmData,
ESM::ReadersCache& readers)
std::vector<CellRef> loadCellRefs(
const ESM::Cell& cell, const EsmLoader::EsmData& esmData, ESM::ReadersCache& readers)
{
std::vector<EsmLoader::Record<CellRef>> cellRefs;
@ -86,14 +93,15 @@ namespace NavMeshTool
const ESM::RecNameInts type = getType(esmData, cellRef.mRefID);
if (type == ESM::RecNameInts{})
continue;
cellRefs.emplace_back(deleted, type, cellRef.mRefNum, std::move(cellRef.mRefID),
cellRef.mScale, cellRef.mPos);
cellRefs.emplace_back(
deleted, type, cellRef.mRefNum, std::move(cellRef.mRefID), cellRef.mScale, cellRef.mPos);
}
}
Log(Debug::Debug) << "Loaded " << cellRefs.size() << " cell refs";
const auto getKey = [] (const EsmLoader::Record<CellRef>& v) -> const ESM::RefNum& { return v.mValue.mRefNum; };
const auto getKey
= [](const EsmLoader::Record<CellRef>& v) -> const ESM::RefNum& { return v.mValue.mRefNum; };
std::vector<CellRef> result = prepareRecords(cellRefs, getKey);
Log(Debug::Debug) << "Prepared " << result.size() << " unique cell refs";
@ -103,8 +111,7 @@ namespace NavMeshTool
template <class F>
void forEachObject(const ESM::Cell& cell, const EsmLoader::EsmData& esmData, const VFS::Manager& vfs,
Resource::BulletShapeManager& bulletShapeManager, ESM::ReadersCache& readers,
F&& f)
Resource::BulletShapeManager& bulletShapeManager, ESM::ReadersCache& readers, F&& f)
{
std::vector<CellRef> cellRefs = loadCellRefs(cell, esmData, readers);
@ -119,15 +126,15 @@ namespace NavMeshTool
if (cellRef.mType != ESM::REC_STAT)
model = Misc::ResourceHelpers::correctActorModelPath(model, &vfs);
osg::ref_ptr<const Resource::BulletShape> shape = [&]
{
osg::ref_ptr<const Resource::BulletShape> shape = [&] {
try
{
return bulletShapeManager.getShape(Misc::ResourceHelpers::correctMeshPath(model, &vfs));
}
catch (const std::exception& e)
{
Log(Debug::Warning) << "Failed to load cell ref \"" << cellRef.mRefId << "\" model \"" << model << "\": " << e.what();
Log(Debug::Warning) << "Failed to load cell ref \"" << cellRef.mRefId << "\" model \"" << model
<< "\": " << e.what();
return osg::ref_ptr<const Resource::BulletShape>();
}
}();
@ -135,7 +142,8 @@ namespace NavMeshTool
if (shape == nullptr || shape->mCollisionShape == nullptr)
continue;
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance(new Resource::BulletShapeInstance(std::move(shape)));
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance(
new Resource::BulletShapeInstance(std::move(shape)));
switch (cellRef.mType)
{
@ -158,35 +166,20 @@ namespace NavMeshTool
struct LessByXY
{
bool operator ()(const ESM::Land& lhs, const ESM::Land& rhs) const
{
return GetXY {}(lhs) < GetXY {}(rhs);
}
bool operator()(const ESM::Land& lhs, const ESM::Land& rhs) const { return GetXY{}(lhs) < GetXY{}(rhs); }
bool operator ()(const ESM::Land& lhs, const osg::Vec2i& rhs) const
{
return GetXY {}(lhs) < rhs;
}
bool operator()(const ESM::Land& lhs, const osg::Vec2i& rhs) const { return GetXY{}(lhs) < rhs; }
bool operator ()(const osg::Vec2i& lhs, const ESM::Land& rhs) const
{
return lhs < GetXY {}(rhs);
}
bool operator()(const osg::Vec2i& lhs, const ESM::Land& rhs) const { return lhs < GetXY{}(rhs); }
};
btAABB getAabb(const osg::Vec2i& cellPosition, btScalar minHeight, btScalar maxHeight)
{
btAABB aabb;
aabb.m_min = btVector3(
static_cast<btScalar>(cellPosition.x() * ESM::Land::REAL_SIZE),
static_cast<btScalar>(cellPosition.y() * ESM::Land::REAL_SIZE),
minHeight
);
aabb.m_max = btVector3(
static_cast<btScalar>((cellPosition.x() + 1) * ESM::Land::REAL_SIZE),
static_cast<btScalar>((cellPosition.y() + 1) * ESM::Land::REAL_SIZE),
maxHeight
);
aabb.m_min = btVector3(static_cast<btScalar>(cellPosition.x() * ESM::Land::REAL_SIZE),
static_cast<btScalar>(cellPosition.y() * ESM::Land::REAL_SIZE), minHeight);
aabb.m_max = btVector3(static_cast<btScalar>((cellPosition.x() + 1) * ESM::Land::REAL_SIZE),
static_cast<btScalar>((cellPosition.y() + 1) * ESM::Land::REAL_SIZE), maxHeight);
return aabb;
}
@ -206,7 +199,8 @@ namespace NavMeshTool
{
if (!land.has_value() || osg::Vec2i(land->mX, land->mY) != cellPosition
|| (land->mDataTypes & ESM::Land::DATA_VHGT) == 0)
return {HeightfieldPlane {ESM::Land::DEFAULT_HEIGHT}, ESM::Land::DEFAULT_HEIGHT, ESM::Land::DEFAULT_HEIGHT};
return { HeightfieldPlane{ ESM::Land::DEFAULT_HEIGHT }, ESM::Land::DEFAULT_HEIGHT,
ESM::Land::DEFAULT_HEIGHT };
ESM::Land::LandData& landData = *landDatas.emplace_back(std::make_unique<ESM::Land::LandData>());
land->loadData(ESM::Land::DATA_VHGT, &landData);
@ -227,7 +221,8 @@ namespace NavMeshTool
}
}
WorldspaceNavMeshInput::WorldspaceNavMeshInput(std::string worldspace, const DetourNavigator::RecastSettings& settings)
WorldspaceNavMeshInput::WorldspaceNavMeshInput(
std::string worldspace, const DetourNavigator::RecastSettings& settings)
: mWorldspace(std::move(worldspace))
, mTileCachedRecastMeshManager(settings)
{
@ -259,23 +254,25 @@ namespace NavMeshTool
if (writeBinaryLog)
serializeToStderr(ProcessedCells{ static_cast<std::uint64_t>(i + 1) });
Log(Debug::Info) << "Skipped interior"
<< " cell (" << (i + 1) << "/" << esmData.mCells.size() << ") \"" << cell.getDescription() << "\"";
<< " cell (" << (i + 1) << "/" << esmData.mCells.size() << ") \""
<< cell.getDescription() << "\"";
continue;
}
Log(Debug::Debug) << "Processing " << (exterior ? "exterior" : "interior")
<< " cell (" << (i + 1) << "/" << esmData.mCells.size() << ") \"" << cell.getDescription() << "\"";
Log(Debug::Debug) << "Processing " << (exterior ? "exterior" : "interior") << " cell (" << (i + 1) << "/"
<< esmData.mCells.size() << ") \"" << cell.getDescription() << "\"";
const osg::Vec2i cellPosition(cell.mData.mX, cell.mData.mY);
const std::size_t cellObjectsBegin = data.mObjects.size();
WorldspaceNavMeshInput& navMeshInput = [&] () -> WorldspaceNavMeshInput&
{
WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& {
auto it = navMeshInputs.find(cell.mCellId.mWorldspace);
if (it == navMeshInputs.end())
{
it = navMeshInputs.emplace(cell.mCellId.mWorldspace,
std::make_unique<WorldspaceNavMeshInput>(cell.mCellId.mWorldspace, settings.mRecast)).first;
it = navMeshInputs
.emplace(cell.mCellId.mWorldspace,
std::make_unique<WorldspaceNavMeshInput>(cell.mCellId.mWorldspace, settings.mRecast))
.first;
it->second->mTileCachedRecastMeshManager.setWorldspace(cell.mCellId.mWorldspace, nullptr);
}
return *it->second;
@ -285,28 +282,28 @@ namespace NavMeshTool
if (exterior)
{
const auto it = std::lower_bound(esmData.mLands.begin(), esmData.mLands.end(), cellPosition, LessByXY {});
const auto [heightfieldShape, minHeight, maxHeight] = makeHeightfieldShape(
it == esmData.mLands.end() ? std::optional<ESM::Land>() : *it,
cellPosition, data.mHeightfields, data.mLandData
);
const auto it
= std::lower_bound(esmData.mLands.begin(), esmData.mLands.end(), cellPosition, LessByXY{});
const auto [heightfieldShape, minHeight, maxHeight]
= makeHeightfieldShape(it == esmData.mLands.end() ? std::optional<ESM::Land>() : *it, cellPosition,
data.mHeightfields, data.mLandData);
mergeOrAssign(getAabb(cellPosition, minHeight, maxHeight),
navMeshInput.mAabb, navMeshInput.mAabbInitialized);
mergeOrAssign(
getAabb(cellPosition, minHeight, maxHeight), navMeshInput.mAabb, navMeshInput.mAabbInitialized);
navMeshInput.mTileCachedRecastMeshManager.addHeightfield(cellPosition, ESM::Land::REAL_SIZE, heightfieldShape, &guard);
navMeshInput.mTileCachedRecastMeshManager.addHeightfield(
cellPosition, ESM::Land::REAL_SIZE, heightfieldShape, &guard);
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, &guard);
navMeshInput.mTileCachedRecastMeshManager.addWater(
cellPosition, std::numeric_limits<int>::max(), cell.mWater, &guard);
}
forEachObject(cell, esmData, vfs, bulletShapeManager, readers,
[&] (BulletObject object)
{
forEachObject(cell, esmData, vfs, bulletShapeManager, readers, [&](BulletObject object) {
if (object.getShapeInstance()->mVisualCollisionType != Resource::VisualCollisionType::None)
return;
@ -317,16 +314,17 @@ namespace NavMeshTool
navMeshInput.mAabb.merge(BulletHelpers::getAabb(*avoid, transform));
const ObjectId objectId(++objectsCounter);
const CollisionShape shape(object.getShapeInstance(), *object.getCollisionObject().getCollisionShape(), object.getObjectTransform());
const CollisionShape shape(object.getShapeInstance(), *object.getCollisionObject().getCollisionShape(),
object.getObjectTransform());
navMeshInput.mTileCachedRecastMeshManager.addObject(objectId, shape, transform,
DetourNavigator::AreaType_ground, &guard);
navMeshInput.mTileCachedRecastMeshManager.addObject(
objectId, shape, transform, 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, &guard);
navMeshInput.mTileCachedRecastMeshManager.addObject(
objectId, avoidShape, transform, DetourNavigator::AreaType_null, &guard);
}
data.mObjects.emplace_back(std::move(object));
@ -337,17 +335,17 @@ namespace NavMeshTool
if (writeBinaryLog)
serializeToStderr(ProcessedCells{ static_cast<std::uint64_t>(i + 1) });
Log(Debug::Info) << "Processed " << (exterior ? "exterior" : "interior")
<< " cell (" << (i + 1) << "/" << esmData.mCells.size() << ") " << cellDescription
<< " with " << (data.mObjects.size() - cellObjectsBegin) << " objects";
Log(Debug::Info) << "Processed " << (exterior ? "exterior" : "interior") << " cell (" << (i + 1) << "/"
<< esmData.mCells.size() << ") " << cellDescription << " with "
<< (data.mObjects.size() - cellObjectsBegin) << " objects";
}
data.mNavMeshInputs.reserve(navMeshInputs.size());
std::transform(navMeshInputs.begin(), navMeshInputs.end(), std::back_inserter(data.mNavMeshInputs),
[](auto& v) { return std::move(v.second); });
Log(Debug::Info) << "Processed " << esmData.mCells.size() << " cells, added "
<< data.mObjects.size() << " objects and " << data.mHeightfields.size() << " height fields";
Log(Debug::Info) << "Processed " << esmData.mCells.size() << " cells, added " << data.mObjects.size()
<< " objects and " << data.mHeightfields.size() << " height fields";
return data;
}

@ -43,8 +43,8 @@ namespace DetourNavigator
namespace NavMeshTool
{
using DetourNavigator::TileCachedRecastMeshManager;
using DetourNavigator::ObjectTransform;
using DetourNavigator::TileCachedRecastMeshManager;
struct WorldspaceNavMeshInput
{
@ -63,11 +63,9 @@ namespace NavMeshTool
float localScaling)
: mShapeInstance(std::move(shapeInstance))
, mObjectTransform{ position, localScaling }
, mCollisionObject(BulletHelpers::makeCollisionObject(
mShapeInstance->mCollisionShape.get(),
, mCollisionObject(BulletHelpers::makeCollisionObject(mShapeInstance->mCollisionShape.get(),
Misc::Convert::toBullet(position.asVec3()),
Misc::Convert::toBullet(Misc::Convert::makeOsgQuat(position))
))
Misc::Convert::toBullet(Misc::Convert::makeOsgQuat(position))))
{
mShapeInstance->setLocalScaling(btVector3(localScaling, localScaling, localScaling));
}

@ -1,16 +1,16 @@
/// Program to test .nif files both on the FileSystem and in BSA archives.
#include <iostream>
#include <filesystem>
#include <iostream>
#include <components/files/configurationmanager.hpp>
#include <components/files/constrainedfilestream.hpp>
#include <components/files/conversion.hpp>
#include <components/misc/strings/algorithm.hpp>
#include <components/nif/niffile.hpp>
#include <components/files/constrainedfilestream.hpp>
#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 <components/vfs/manager.hpp>
#include <boost/program_options.hpp>
@ -45,7 +45,8 @@ void readVFS(std::unique_ptr<VFS::Archive>&& anArchive, const std::filesystem::p
for (const auto& name : myManager.getRecursiveDirectoryIterator(""))
{
try{
try
{
if (isNIF(name))
{
// std::cout << "Decoding: " << name << std::endl;
@ -88,8 +89,7 @@ Allowed options)");
bpo::variables_map variables;
try
{
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).
options(desc).positional(p).run();
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).positional(p).run();
bpo::store(valid_opts, variables);
bpo::notify(variables);
if (variables.count("help"))
@ -105,8 +105,7 @@ Allowed options)");
}
catch (std::exception& e)
{
std::cout << "ERROR parsing arguments: " << e.what() << "\n\n"
<< desc << std::endl;
std::cout << "ERROR parsing arguments: " << e.what() << "\n\n" << desc << std::endl;
return false;
}
@ -144,7 +143,8 @@ int main(int argc, char **argv)
}
else
{
std::cerr << "ERROR: \"" << Files::pathToUnicodeString(path) << "\" 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)

@ -26,9 +26,15 @@
using namespace Fallback;
CS::Editor::Editor(int argc, char** argv)
: mConfigVariables(readConfiguration()), mSettingsState (mCfgMgr), mDocumentManager (mCfgMgr),
mPid(""), mLock(), mMerge (mDocumentManager),
mIpcServerName ("org.openmw.OpenCS"), mServer(nullptr), mClientSocket(nullptr)
: mConfigVariables(readConfiguration())
, mSettingsState(mCfgMgr)
, mDocumentManager(mCfgMgr)
, mPid("")
, mLock()
, mMerge(mDocumentManager)
, mIpcServerName("org.openmw.OpenCS")
, mServer(nullptr)
, mClientSocket(nullptr)
{
std::pair<Files::PathContainer, std::vector<std::string>> config = readConfig();
@ -47,12 +53,10 @@ CS::Editor::Editor (int argc, char **argv)
mFileDialog.setLocalData(mLocal);
mMerge.setLocalData(mLocal);
connect (&mDocumentManager, &CSMDoc::DocumentManager::documentAdded,
this, &Editor::documentAdded);
connect (&mDocumentManager, &CSMDoc::DocumentManager::documentAboutToBeRemoved,
this, &Editor::documentAboutToBeRemoved);
connect (&mDocumentManager, &CSMDoc::DocumentManager::lastDocumentDeleted,
this, &Editor::lastDocumentDeleted);
connect(&mDocumentManager, &CSMDoc::DocumentManager::documentAdded, this, &Editor::documentAdded);
connect(
&mDocumentManager, &CSMDoc::DocumentManager::documentAboutToBeRemoved, this, &Editor::documentAboutToBeRemoved);
connect(&mDocumentManager, &CSMDoc::DocumentManager::lastDocumentDeleted, this, &Editor::lastDocumentDeleted);
connect(mViewManager, &CSVDoc::ViewManager::newGameRequest, this, &Editor::createGame);
connect(mViewManager, &CSVDoc::ViewManager::newAddonRequest, this, &Editor::createAddon);
@ -65,8 +69,8 @@ CS::Editor::Editor (int argc, char **argv)
connect(&mStartup, &CSVDoc::StartupDialogue::loadDocument, this, &Editor::loadDocument);
connect(&mStartup, &CSVDoc::StartupDialogue::editConfig, this, &Editor::showSettings);
connect (&mFileDialog, &CSVDoc::FileDialog::signalOpenFiles,
this, [this](const std::filesystem::path &savePath){ this->openFiles(savePath); });
connect(&mFileDialog, &CSVDoc::FileDialog::signalOpenFiles, 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);
@ -90,19 +94,32 @@ boost::program_options::variables_map CS::Editor::readConfiguration()
boost::program_options::options_description desc("Syntax: openmw-cs <options>\nAllowed options");
auto addOption = desc.add_options();
addOption("data", boost::program_options::value<Files::MaybeQuotedPathContainer>()->default_value(Files::MaybeQuotedPathContainer(), "data")->multitoken()->composing());
addOption("data-local", boost::program_options::value<Files::MaybeQuotedPathContainer::value_type>()->default_value(Files::MaybeQuotedPathContainer::value_type(), ""));
addOption("data",
boost::program_options::value<Files::MaybeQuotedPathContainer>()
->default_value(Files::MaybeQuotedPathContainer(), "data")
->multitoken()
->composing());
addOption("data-local",
boost::program_options::value<Files::MaybeQuotedPathContainer::value_type>()->default_value(
Files::MaybeQuotedPathContainer::value_type(), ""));
addOption("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false));
addOption("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
addOption("resources", boost::program_options::value<Files::MaybeQuotedPath>()->default_value(Files::MaybeQuotedPath(), "resources"));
addOption("fallback-archive", boost::program_options::value<std::vector<std::string>>()->
default_value(std::vector<std::string>(), "fallback-archive")->multitoken());
addOption("fallback", boost::program_options::value<FallbackMap>()->default_value(FallbackMap(), "")
->multitoken()->composing(), "fallback values");
addOption("script-blacklist", boost::program_options::value<std::vector<std::string>>()->default_value(std::vector<std::string>(), "")
->multitoken(), "exclude specified script from the verifier (if the use of the blacklist is enabled)");
addOption("script-blacklist-use", boost::program_options::value<bool>()->implicit_value(true)
->default_value(true), "enable script blacklisting");
addOption("resources",
boost::program_options::value<Files::MaybeQuotedPath>()->default_value(Files::MaybeQuotedPath(), "resources"));
addOption("fallback-archive",
boost::program_options::value<std::vector<std::string>>()
->default_value(std::vector<std::string>(), "fallback-archive")
->multitoken());
addOption("fallback",
boost::program_options::value<FallbackMap>()->default_value(FallbackMap(), "")->multitoken()->composing(),
"fallback values");
addOption("script-blacklist",
boost::program_options::value<std::vector<std::string>>()
->default_value(std::vector<std::string>(), "")
->multitoken(),
"exclude specified script from the verifier (if the use of the blacklist is enabled)");
addOption("script-blacklist-use", boost::program_options::value<bool>()->implicit_value(true)->default_value(true),
"enable script blacklisting");
Files::ConfigurationManager::addCommonOptions(desc);
boost::program_options::notify(variables);
@ -124,20 +141,26 @@ 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>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
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 (
variables["script-blacklist"].as<std::vector<std::string>>());
mDocumentManager.setBlacklistedScripts(variables["script-blacklist"].as<std::vector<std::string>>());
mFsStrict = variables["fs-strict"].as<bool>();
Files::PathContainer dataDirs, dataLocal;
if (!variables["data"].empty()) {
if (!variables["data"].empty())
{
dataDirs = asPathContainer(variables["data"].as<Files::MaybeQuotedPathContainer>());
}
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.
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())
{
std::filesystem::create_directories(local);
@ -154,7 +177,9 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
messageBox.setWindowTitle(tr("No local data path available"));
messageBox.setIcon(QMessageBox::Critical);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setText(tr("<br><b>OpenCS is unable to access the local data directory. This may indicate a faulty configuration or a broken install.</b>"));
messageBox.setText(
tr("<br><b>OpenCS is unable to access the local data directory. This may indicate a faulty configuration "
"or a broken install.</b>"));
messageBox.exec();
QApplication::exit(1);
@ -227,13 +252,15 @@ void CS::Editor::loadDocument()
mFileDialog.showDialog(CSVDoc::ContentAction_Edit);
}
void CS::Editor::openFiles (const std::filesystem::path &savePath, const std::vector<std::filesystem::path> &discoveredFiles)
void CS::Editor::openFiles(
const std::filesystem::path& savePath, const std::vector<std::filesystem::path>& discoveredFiles)
{
std::vector<std::filesystem::path> files;
if (discoveredFiles.empty())
{
for (const QString &path : mFileDialog.selectedFilePaths()) {
for (const QString& path : mFileDialog.selectedFilePaths())
{
files.emplace_back(Files::pathFromQString(path));
}
}
@ -251,7 +278,8 @@ void CS::Editor::createNewFile (const std::filesystem::path &savePath)
{
std::vector<std::filesystem::path> files;
for (const QString &path : mFileDialog.selectedFilePaths()) {
for (const QString& path : mFileDialog.selectedFilePaths())
{
files.emplace_back(Files::pathFromQString(path));
}

@ -6,10 +6,10 @@
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/program_options/variables_map.hpp>
#include <QObject>
#include <QString>
#include <QLocalServer>
#include <QLocalSocket>
#include <QObject>
#include <QString>
#ifndef Q_MOC_RUN
#include <components/files/configurationmanager.hpp>
@ -21,10 +21,10 @@
#include "model/prefs/state.hpp"
#include "view/doc/viewmanager.hpp"
#include "view/doc/startup.hpp"
#include "view/doc/filedialog.hpp"
#include "view/doc/newgame.hpp"
#include "view/doc/startup.hpp"
#include "view/doc/viewmanager.hpp"
#include "view/prefs/dialogue.hpp"
@ -62,7 +62,8 @@ namespace CS
std::string mEncodingName;
boost::program_options::variables_map readConfiguration();
///< Calls mCfgMgr.readConfiguration; should be used before initialization of mSettingsState as it depends on the configuration.
///< Calls mCfgMgr.readConfiguration; should be used before initialization of mSettingsState as it depends on
///< the configuration.
std::pair<Files::PathContainer, std::vector<std::string>> readConfig(bool quiet = false);
///< \return data paths
@ -71,7 +72,6 @@ namespace CS
Editor& operator=(const Editor&);
public:
Editor(int argc, char** argv);
~Editor();
@ -89,7 +89,8 @@ namespace CS
void cancelFileDialog();
void loadDocument();
void openFiles (const std::filesystem::path &path, const std::vector<std::filesystem::path> &discoveredFiles = {});
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);
@ -106,7 +107,6 @@ namespace CS
void mergeDocument(CSMDoc::Document* document);
private:
QString mIpcServerName;
QLocalServer* mServer;
QLocalSocket* mClientSocket;

@ -21,7 +21,6 @@ Q_DECLARE_METATYPE (std::string)
class Application : public QApplication
{
private:
bool notify(QObject* receiver, QEvent* event) override
{
try
@ -37,8 +36,10 @@ class Application : public QApplication
}
public:
Application (int& argc, char *argv[]) : QApplication (argc, argv) {}
Application(int& argc, char* argv[])
: QApplication(argc, argv)
{
}
};
int runApplication(int argc, char* argv[])
@ -78,7 +79,6 @@ int runApplication(int argc, char *argv[])
return editor.run();
}
int main(int argc, char* argv[])
{
return wrapApplication(&runApplication, argc, argv, "OpenMW-CS", false);

@ -6,18 +6,15 @@
bool CSMDoc::Blacklist::isBlacklisted(const CSMWorld::UniversalId& id) const
{
std::map<CSMWorld::UniversalId::Type, std::vector<std::string> >::const_iterator iter =
mIds.find (id.getType());
std::map<CSMWorld::UniversalId::Type, std::vector<std::string>>::const_iterator iter = mIds.find(id.getType());
if (iter == mIds.end())
return false;
return std::binary_search (iter->second.begin(), iter->second.end(),
Misc::StringUtils::lowerCase (id.getId()));
return std::binary_search(iter->second.begin(), iter->second.end(), Misc::StringUtils::lowerCase(id.getId()));
}
void CSMDoc::Blacklist::add (CSMWorld::UniversalId::Type type,
const std::vector<std::string>& ids)
void CSMDoc::Blacklist::add(CSMWorld::UniversalId::Type type, const std::vector<std::string>& ids)
{
std::vector<std::string>& list = mIds[type];
@ -25,6 +22,7 @@ void CSMDoc::Blacklist::add (CSMWorld::UniversalId::Type type,
list.resize(size + ids.size());
std::transform (ids.begin(), ids.end(), list.begin()+size, [](const std::string& s) { return Misc::StringUtils::lowerCase(s); } );
std::transform(ids.begin(), ids.end(), list.begin() + size,
[](const std::string& s) { return Misc::StringUtils::lowerCase(s); });
std::sort(list.begin(), list.end());
}

@ -2,8 +2,8 @@
#define CSM_DOC_BLACKLIST_H
#include <map>
#include <vector>
#include <string>
#include <vector>
#include "../world/universalid.hpp"
@ -15,7 +15,6 @@ namespace CSMDoc
std::map<CSMWorld::UniversalId::Type, std::vector<std::string>> mIds;
public:
bool isBlacklisted(const CSMWorld::UniversalId& id) const;
void add(CSMWorld::UniversalId::Type type, const std::vector<std::string>& ids);

@ -3,8 +3,8 @@
#include "state.hpp"
#include <cassert>
#include <memory>
#include <filesystem>
#include <memory>
#include <utility>
#include "../world/defaultgmsts.hpp"
@ -82,8 +82,7 @@ void CSMDoc::Document::addOptionalGmsts()
void CSMDoc::Document::addOptionalGlobals()
{
static const char *sGlobals[] =
{
static const char* sGlobals[] = {
"DaysPassed",
"PCWerewolf",
"PCYear",
@ -152,8 +151,7 @@ void CSMDoc::Document::addOptionalMagicEffect (const ESM::MagicEffect& magicEffe
void CSMDoc::Document::createBase()
{
static const char *sGlobals[] =
{
static const char* sGlobals[] = {
"Day",
"DaysPassed",
"GameHour",
@ -190,8 +188,7 @@ void CSMDoc::Document::createBase()
getData().getSkills().add(record);
}
static const char *sVoice[] =
{
static const char* sVoice[] = {
"Intruder",
"Attack",
"Hello",
@ -213,8 +210,7 @@ void CSMDoc::Document::createBase()
getData().getTopics().add(record);
}
static const char *sGreetings[] =
{
static const char* sGreetings[] = {
"Greeting 0",
"Greeting 1",
"Greeting 2",
@ -238,8 +234,7 @@ void CSMDoc::Document::createBase()
getData().getTopics().add(record);
}
static const char *sPersuasion[] =
{
static const char* sPersuasion[] = {
"Intimidate Success",
"Intimidate Fail",
"Service Refusal",
@ -276,19 +271,22 @@ void CSMDoc::Document::createBase()
}
}
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
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 (std::move(files)), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, resDir),
mTools (*this, encoding),
mProjectPath ((configuration.getUserDataPath() / "projects") /
(savePath.filename().u8string() + u8".project")),
mSavingOperation (*this, mProjectPath, encoding),
mSaving (&mSavingOperation),
mResDir(resDir), mRunner (mProjectPath),
mDirty (false), mIdCompletionManager(mData)
CSMDoc::Document::Document(const Files::ConfigurationManager& configuration, 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(std::move(files))
, mNew(new_)
, mData(encoding, fsStrict, dataPaths, archives, resDir)
, mTools(*this, encoding)
, mProjectPath((configuration.getUserDataPath() / "projects") / (savePath.filename().u8string() + u8".project"))
, mSavingOperation(*this, mProjectPath, encoding)
, mSaving(&mSavingOperation)
, mResDir(resDir)
, mRunner(mProjectPath)
, mDirty(false)
, mIdCompletionManager(mData)
{
if (mContentFiles.empty())
throw std::runtime_error("Empty content file sequence");
@ -332,8 +330,7 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
connect(&mTools, &CSMTools::Tools::done, this, &Document::operationDone2);
connect(&mTools, &CSMTools::Tools::mergeDone, this, &Document::mergeDone);
connect (&mSaving, &OperationHolder::progress,
this, qOverload<int, int, int>(&Document::progress));
connect(&mSaving, &OperationHolder::progress, this, qOverload<int, int, int>(&Document::progress));
connect(&mSaving, &OperationHolder::done, this, &Document::operationDone2);
connect(&mSaving, &OperationHolder::reportMessage, this, &Document::reportMessage);
@ -341,9 +338,7 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
connect(&mRunner, &Runner::runStateChanged, this, &Document::runStateChanged);
}
CSMDoc::Document::~Document()
{
}
CSMDoc::Document::~Document() {}
QUndoStack& CSMDoc::Document::getUndoStack()
{
@ -397,8 +392,7 @@ bool CSMDoc::Document::isNew() const
void CSMDoc::Document::save()
{
if (mSaving.isRunning())
throw std::logic_error (
"Failed to initiate save, because a save operation is already running.");
throw std::logic_error("Failed to initiate save, because a save operation is already running.");
mSaving.start();
@ -412,7 +406,6 @@ CSMWorld::UniversalId CSMDoc::Document::verify (const CSMWorld::UniversalId& rep
return id;
}
CSMWorld::UniversalId CSMDoc::Document::newSearch()
{
return mTools.newSearch();
@ -472,23 +465,21 @@ CSMTools::ReportModel *CSMDoc::Document::getReport (const CSMWorld::UniversalId&
return mTools.getReport(id);
}
bool CSMDoc::Document::isBlacklisted (const CSMWorld::UniversalId& id)
const
bool CSMDoc::Document::isBlacklisted(const CSMWorld::UniversalId& id) const
{
return mBlacklist.isBlacklisted(id);
}
void CSMDoc::Document::startRunning (const std::string& profile,
const std::string& startupInstruction)
void CSMDoc::Document::startRunning(const std::string& profile, const std::string& startupInstruction)
{
std::vector<std::filesystem::path> contentFiles;
for (const auto & mContentFile : mContentFiles) {
for (const auto& mContentFile : mContentFiles)
{
contentFiles.emplace_back(mContentFile.filename());
}
mRunner.configure (getData().getDebugProfiles().getRecord (profile).get(), contentFiles,
startupInstruction);
mRunner.configure(getData().getDebugProfiles().getRecord(profile).get(), contentFiles, startupInstruction);
int state = getState();

@ -3,8 +3,8 @@
#include <string>
#include <QUndoStack>
#include <QObject>
#include <QUndoStack>
#include <components/files/multidircollection.hpp>
#include <components/to_utf8/to_utf8.hpp>
@ -14,10 +14,10 @@
#include "../tools/tools.hpp"
#include "saving.hpp"
#include "blacklist.hpp"
#include "runner.hpp"
#include "operationholder.hpp"
#include "runner.hpp"
#include "saving.hpp"
class QAbstractItemModel;
@ -55,7 +55,6 @@ namespace CSMDoc
Q_OBJECT
private:
std::filesystem::path mSavePath;
std::vector<std::filesystem::path> mContentFiles;
bool mNew;
@ -71,8 +70,9 @@ namespace CSMDoc
CSMWorld::IdCompletionManager mIdCompletionManager;
// It is important that the undo stack is declared last, because on desctruction it fires a signal, that is connected to a slot, that is
// using other member variables. Unfortunately this connection is cut only in the QObject destructor, which is way too late.
// It is important that the undo stack is declared last, because on desctruction it fires a signal, that is
// connected to a slot, that is using other member variables. Unfortunately this connection is cut only in the
// QObject destructor, which is way too late.
QUndoStack mUndoStack;
// not implemented
@ -96,12 +96,10 @@ namespace CSMDoc
void addOptionalMagicEffect(const ESM::MagicEffect& effect);
public:
Document (const Files::ConfigurationManager& configuration,
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);
Document(const Files::ConfigurationManager& configuration, 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);
~Document();
@ -143,8 +141,7 @@ namespace CSMDoc
bool isBlacklisted(const CSMWorld::UniversalId& id) const;
void startRunning (const std::string& profile,
const std::string& startupInstruction = "");
void startRunning(const std::string& profile, const std::string& startupInstruction = "");
void stopRunning();

@ -9,7 +9,9 @@
#include "document.hpp"
CSMDoc::DocumentManager::DocumentManager(const Files::ConfigurationManager& configuration)
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mFsStrict(false)
: mConfiguration(configuration)
, mEncoding(ToUTF8::WINDOWS_1252)
, mFsStrict(false)
{
std::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
@ -19,20 +21,13 @@ CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& con
mLoader.moveToThread(&mLoaderThread);
mLoaderThread.start();
connect (&mLoader, &Loader::documentLoaded,
this, &DocumentManager::documentLoaded);
connect (&mLoader, &Loader::documentNotLoaded,
this, &DocumentManager::documentNotLoaded);
connect (this, &DocumentManager::loadRequest,
&mLoader, &Loader::loadDocument);
connect (&mLoader, &Loader::nextStage,
this, &DocumentManager::nextStage);
connect (&mLoader, &Loader::nextRecord,
this, &DocumentManager::nextRecord);
connect (this, &DocumentManager::cancelLoading,
&mLoader, &Loader::abortLoading);
connect (&mLoader, &Loader::loadMessage,
this, &DocumentManager::loadMessage);
connect(&mLoader, &Loader::documentLoaded, this, &DocumentManager::documentLoaded);
connect(&mLoader, &Loader::documentNotLoaded, this, &DocumentManager::documentNotLoaded);
connect(this, &DocumentManager::loadRequest, &mLoader, &Loader::loadDocument);
connect(&mLoader, &Loader::nextStage, this, &DocumentManager::nextStage);
connect(&mLoader, &Loader::nextRecord, this, &DocumentManager::nextRecord);
connect(this, &DocumentManager::cancelLoading, &mLoader, &Loader::abortLoading);
connect(&mLoader, &Loader::loadMessage, this, &DocumentManager::loadMessage);
}
CSMDoc::DocumentManager::~DocumentManager()
@ -51,26 +46,25 @@ bool CSMDoc::DocumentManager::isEmpty()
return mDocuments.empty();
}
void CSMDoc::DocumentManager::addDocument (const std::vector<std::filesystem::path>& files, const std::filesystem::path& savePath,
bool new_)
void CSMDoc::DocumentManager::addDocument(
const std::vector<std::filesystem::path>& files, const std::filesystem::path& savePath, bool new_)
{
Document* document = makeDocument(files, savePath, new_);
insertDocument(document);
}
CSMDoc::Document* CSMDoc::DocumentManager::makeDocument(
const std::vector< std::filesystem::path >& files,
const std::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);
return new Document(mConfiguration, files, new_, savePath, mResDir, mEncoding, mBlacklistedScripts, mFsStrict,
mDataPaths, mArchives);
}
void CSMDoc::DocumentManager::insertDocument(CSMDoc::Document* document)
{
mDocuments.push_back(document);
connect (document, SIGNAL (mergeDone (CSMDoc::Document*)),
this, SLOT (insertDocument (CSMDoc::Document*)));
connect(document, SIGNAL(mergeDone(CSMDoc::Document*)), this, SLOT(insertDocument(CSMDoc::Document*)));
emit loadRequest(document);
@ -122,7 +116,8 @@ void CSMDoc::DocumentManager::documentNotLoaded (Document *document, const std::
removeDocument(document);
}
void CSMDoc::DocumentManager::setFileData(bool strict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
void CSMDoc::DocumentManager::setFileData(
bool strict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
{
mFsStrict = strict;
mDataPaths = dataPaths;

@ -1,15 +1,15 @@
#ifndef CSM_DOC_DOCUMENTMGR_H
#define CSM_DOC_DOCUMENTMGR_H
#include <vector>
#include <string>
#include <vector>
#include <QObject>
#include <QThread>
#include <components/to_utf8/to_utf8.hpp>
#include <components/fallback/fallback.hpp>
#include <components/files/multidircollection.hpp>
#include <components/to_utf8/to_utf8.hpp>
#include "loader.hpp"
@ -48,13 +48,12 @@ namespace CSMDoc
DocumentManager& operator=(const DocumentManager&);
public:
DocumentManager(const Files::ConfigurationManager& configuration);
~DocumentManager();
void addDocument (const std::vector< std::filesystem::path >& files,
const std::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.
@ -64,8 +63,8 @@ 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< std::filesystem::path >& files,
const std::filesystem::path& savePath, bool new_);
Document* makeDocument(
const std::vector<std::filesystem::path>& files, const std::filesystem::path& savePath, bool new_);
void setResourceDir(const std::filesystem::path& parResDir);
@ -106,11 +105,9 @@ namespace CSMDoc
void lastDocumentDeleted();
void loadingStopped (CSMDoc::Document *document, bool completed,
const std::string& error);
void loadingStopped(CSMDoc::Document* document, bool completed, const std::string& error);
void nextStage (CSMDoc::Document *document, const std::string& name,
int totalRecords);
void nextStage(CSMDoc::Document* document, const std::string& name, int totalRecords);
void nextRecord(CSMDoc::Document* document, int records);

@ -8,8 +8,12 @@
#include "document.hpp"
CSMDoc::Loader::Stage::Stage() : mFile (0), mRecordsLoaded (0), mRecordsLeft (false) {}
CSMDoc::Loader::Stage::Stage()
: mFile(0)
, mRecordsLoaded(0)
, mRecordsLeft(false)
{
}
CSMDoc::Loader::Loader()
: mShouldStop(false)
@ -74,8 +78,8 @@ void CSMDoc::Loader::load()
CSMWorld::UniversalId log(CSMWorld::UniversalId::Type_LoadErrorLog, 0);
{ // silence a g++ warning
for (CSMDoc::Messages::Iterator messageIter (messages.begin());
messageIter!=messages.end(); ++messageIter)
for (CSMDoc::Messages::Iterator messageIter(messages.begin()); messageIter != messages.end();
++messageIter)
{
document->getReport(log)->add(*messageIter);
emit loadMessage(document, messageIter->mMessage);
@ -133,8 +137,7 @@ void CSMDoc::Loader::loadDocument (CSMDoc::Document *document)
void CSMDoc::Loader::abortLoading(CSMDoc::Document* document)
{
for (std::vector<std::pair<Document *, Stage> >::iterator iter = mDocuments.begin();
iter!=mDocuments.end(); ++iter)
for (std::vector<std::pair<Document*, Stage>>::iterator iter = mDocuments.begin(); iter != mDocuments.end(); ++iter)
{
if (iter->first == document)
{

@ -3,8 +3,8 @@
#include <vector>
#include <QObject>
#include <QMutex>
#include <QObject>
#include <QTimer>
#include <QWaitCondition>
@ -33,7 +33,6 @@ namespace CSMDoc
bool mShouldStop;
public:
Loader();
QWaitCondition& hasThingsToDo();
@ -63,8 +62,7 @@ namespace CSMDoc
///< Document load has been interrupted either because of a call to abortLoading
/// or a problem during loading). In the former case error will be an empty string.
void nextStage (CSMDoc::Document *document, const std::string& name,
int totalRecords);
void nextStage(CSMDoc::Document* document, const std::string& name, int totalRecords);
void nextRecord(CSMDoc::Document* document, int records);
///< \note This signal is only given once per group of records. The group size is

@ -1,33 +1,45 @@
#include "messages.hpp"
CSMDoc::Message::Message() : mSeverity(Severity_Default){}
CSMDoc::Message::Message()
: mSeverity(Severity_Default)
{
}
CSMDoc::Message::Message (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint, Severity severity)
: mId (id), mMessage (message), mHint (hint), mSeverity (severity)
{}
CSMDoc::Message::Message(
const CSMWorld::UniversalId& id, const std::string& message, const std::string& hint, Severity severity)
: mId(id)
, mMessage(message)
, mHint(hint)
, mSeverity(severity)
{
}
std::string CSMDoc::Message::toString(Severity severity)
{
switch (severity)
{
case CSMDoc::Message::Severity_Info: return "Information";
case CSMDoc::Message::Severity_Warning: return "Warning";
case CSMDoc::Message::Severity_Error: return "Error";
case CSMDoc::Message::Severity_SeriousError: return "Serious Error";
case CSMDoc::Message::Severity_Default: break;
case CSMDoc::Message::Severity_Info:
return "Information";
case CSMDoc::Message::Severity_Warning:
return "Warning";
case CSMDoc::Message::Severity_Error:
return "Error";
case CSMDoc::Message::Severity_SeriousError:
return "Serious Error";
case CSMDoc::Message::Severity_Default:
break;
}
return "";
}
CSMDoc::Messages::Messages(Message::Severity default_)
: mDefault(default_)
{}
{
}
void CSMDoc::Messages::add (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint, Message::Severity severity)
void CSMDoc::Messages::add(
const CSMWorld::UniversalId& id, const std::string& message, const std::string& hint, Message::Severity severity)
{
if (severity == Message::Severity_Default)
severity = mDefault;

@ -27,8 +27,8 @@ namespace CSMDoc
Message();
Message (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint, Severity severity);
Message(
const CSMWorld::UniversalId& id, const std::string& message, const std::string& hint, Severity severity);
static std::string toString(Severity severity);
};
@ -36,22 +36,18 @@ namespace CSMDoc
class Messages
{
public:
typedef std::vector<Message> Collection;
typedef Collection::const_iterator Iterator;
private:
Collection mMessages;
Message::Severity mDefault;
public:
Messages(Message::Severity default_);
void add (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint = "",
void add(const CSMWorld::UniversalId& id, const std::string& message, const std::string& hint = "",
Message::Severity severity = Message::Severity_Default);
Iterator begin() const;

@ -25,10 +25,18 @@ void CSMDoc::Operation::prepareStages()
}
CSMDoc::Operation::Operation(int type, bool ordered, bool finalAlways)
: mType (type), mStages(std::vector<std::pair<Stage *, int> >()), mCurrentStage(mStages.begin()),
mCurrentStep(0), mCurrentStepTotal(0), mTotalSteps(0), mOrdered (ordered),
mFinalAlways (finalAlways), mError(false), mConnected (false), mPrepared (false),
mDefaultSeverity (Message::Severity_Error)
: mType(type)
, mStages(std::vector<std::pair<Stage*, int>>())
, mCurrentStage(mStages.begin())
, mCurrentStep(0)
, mCurrentStepTotal(0)
, mTotalSteps(0)
, mOrdered(ordered)
, mFinalAlways(finalAlways)
, mError(false)
, mConnected(false)
, mPrepared(false)
, mDefaultSeverity(Message::Severity_Error)
{
mTimer = new QTimer(this);
}
@ -113,7 +121,8 @@ void CSMDoc::Operation::executeStage()
}
catch (const std::exception& e)
{
emit reportMessage (Message (CSMWorld::UniversalId(), e.what(), "", Message::Severity_SeriousError), mType);
emit reportMessage(
Message(CSMWorld::UniversalId(), e.what(), "", Message::Severity_SeriousError), mType);
abort();
}

@ -1,8 +1,8 @@
#ifndef CSM_DOC_OPERATION_H
#define CSM_DOC_OPERATION_H
#include <vector>
#include <map>
#include <vector>
#include <QObject>
#include <QTimer>
@ -39,7 +39,6 @@ namespace CSMDoc
void prepareStages();
public:
Operation(int type, bool ordered, bool finalAlways = false);
///< \param ordered Stages must be executed in the given order.
/// \param finalAlways Execute last stage even if an error occurred during earlier stages.

@ -15,14 +15,11 @@ void CSMDoc::OperationHolder::setOperation (Operation *operation)
mOperation = operation;
mOperation->moveToThread(&mThread);
connect (mOperation, &Operation::progress,
this, &OperationHolder::progress);
connect(mOperation, &Operation::progress, this, &OperationHolder::progress);
connect (mOperation, &Operation::reportMessage,
this, &OperationHolder::reportMessage);
connect(mOperation, &Operation::reportMessage, this, &OperationHolder::reportMessage);
connect (mOperation, &Operation::done,
this, &OperationHolder::doneSlot);
connect(mOperation, &Operation::done, this, &OperationHolder::doneSlot);
connect(this, &OperationHolder::abortSignal, mOperation, &Operation::abort);

@ -24,7 +24,6 @@ namespace CSMDoc
bool mRunning;
public:
OperationHolder(Operation* operation = nullptr);
void setOperation(Operation* operation);

@ -2,10 +2,10 @@
#include <utility>
#include <QCoreApplication>
#include <QDir>
#include <QTemporaryFile>
#include <QTextStream>
#include <QCoreApplication>
#include <components/files/conversion.hpp>
#include <components/files/qtconversion.hpp>
@ -13,13 +13,13 @@
#include "operationholder.hpp"
CSMDoc::Runner::Runner(std::filesystem::path projectPath)
: mRunning (false), mStartup (nullptr), mProjectPath (std::move(projectPath))
: mRunning(false)
, mStartup(nullptr)
, mProjectPath(std::move(projectPath))
{
connect (&mProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished),
this, &Runner::finished);
connect(&mProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this, &Runner::finished);
connect (&mProcess, &QProcess::readyReadStandardOutput,
this, &Runner::readyReadStandardOutput);
connect(&mProcess, &QProcess::readyReadStandardOutput, this, &Runner::readyReadStandardOutput);
mProcess.setProcessChannelMode(QProcess::MergedChannels);
@ -94,8 +94,7 @@ void CSMDoc::Runner::start (bool delayed)
arguments << "--content=" + Files::pathToQString(mContentFile);
}
arguments
<< "--content=" + Files::pathToQString(mProjectPath.filename());
arguments << "--content=" + Files::pathToQString(mProjectPath.filename());
mProcess.start(path, arguments);
}
@ -123,8 +122,8 @@ bool CSMDoc::Runner::isRunning() const
return mRunning;
}
void CSMDoc::Runner::configure (const ESM::DebugProfile& profile,
const std::vector<std::filesystem::path> &contentFiles, const std::string& startupInstruction)
void CSMDoc::Runner::configure(const ESM::DebugProfile& profile, const std::vector<std::filesystem::path>& contentFiles,
const std::string& startupInstruction)
{
mProfile = profile;
mContentFiles = contentFiles;
@ -144,13 +143,12 @@ QTextDocument *CSMDoc::Runner::getLog()
void CSMDoc::Runner::readyReadStandardOutput()
{
mLog.setPlainText (
mLog.toPlainText() + QString::fromUtf8 (mProcess.readAllStandardOutput()));
mLog.setPlainText(mLog.toPlainText() + QString::fromUtf8(mProcess.readAllStandardOutput()));
}
CSMDoc::SaveWatcher::SaveWatcher(Runner* runner, OperationHolder* operation)
: QObject (runner), mRunner (runner)
: QObject(runner)
, mRunner(runner)
{
connect(operation, &OperationHolder::done, this, &SaveWatcher::saveDone);
}

@ -1,8 +1,8 @@
#ifndef CSM_DOC_RUNNER_H
#define CSM_DOC_RUNNER_H
#include <vector>
#include <string>
#include <vector>
#include <QObject>
#include <QProcess>
@ -32,7 +32,6 @@ namespace CSMDoc
std::filesystem::path mProjectPath;
public:
Runner(std::filesystem::path projectPath);
~Runner();
@ -47,8 +46,7 @@ namespace CSMDoc
/// is not necessarily identical to the moment the child process is started.
bool isRunning() const;
void configure (const ESM::DebugProfile& profile,
const std::vector<std::filesystem::path> &contentFiles,
void configure(const ESM::DebugProfile& profile, const std::vector<std::filesystem::path>& contentFiles,
const std::string& startupInstruction);
QTextDocument* getLog();
@ -74,7 +72,6 @@ namespace CSMDoc
Runner* mRunner;
public:
/// *this attaches itself to runner
SaveWatcher(Runner* runner, OperationHolder* operation);

@ -3,13 +3,14 @@
#include "../world/data.hpp"
#include "../world/idcollection.hpp"
#include "state.hpp"
#include "savingstages.hpp"
#include "document.hpp"
#include "savingstages.hpp"
#include "state.hpp"
CSMDoc::Saving::Saving (Document& document, const std::filesystem::path& projectPath,
ToUTF8::FromType encoding)
: Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath, encoding)
CSMDoc::Saving::Saving(Document& document, const std::filesystem::path& projectPath, ToUTF8::FromType encoding)
: Operation(State_Saving, true, true)
, mDocument(document)
, mState(*this, projectPath, encoding)
{
// save project file
appendStage(new OpenSaveStage(mDocument, mState, true));
@ -32,53 +33,48 @@ CSMDoc::Saving::Saving (Document& document, const std::filesystem::path& project
appendStage(new WriteHeaderStage(mDocument, mState, false));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Global> >
(mDocument.getData().getGlobals(), mState));
appendStage(
new WriteCollectionStage<CSMWorld::IdCollection<ESM::Global>>(mDocument.getData().getGlobals(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::GameSetting> >
(mDocument.getData().getGmsts(), mState));
appendStage(
new WriteCollectionStage<CSMWorld::IdCollection<ESM::GameSetting>>(mDocument.getData().getGmsts(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Skill> >
(mDocument.getData().getSkills(), mState));
appendStage(new WriteCollectionStage<CSMWorld::IdCollection<ESM::Skill>>(mDocument.getData().getSkills(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Class> >
(mDocument.getData().getClasses(), mState));
appendStage(new WriteCollectionStage<CSMWorld::IdCollection<ESM::Class>>(mDocument.getData().getClasses(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Faction> >
(mDocument.getData().getFactions(), mState));
appendStage(
new WriteCollectionStage<CSMWorld::IdCollection<ESM::Faction>>(mDocument.getData().getFactions(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Race> >
(mDocument.getData().getRaces(), mState));
appendStage(new WriteCollectionStage<CSMWorld::IdCollection<ESM::Race>>(mDocument.getData().getRaces(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Sound> >
(mDocument.getData().getSounds(), mState));
appendStage(new WriteCollectionStage<CSMWorld::IdCollection<ESM::Sound>>(mDocument.getData().getSounds(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Script> >
(mDocument.getData().getScripts(), mState));
appendStage(
new WriteCollectionStage<CSMWorld::IdCollection<ESM::Script>>(mDocument.getData().getScripts(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Region> >
(mDocument.getData().getRegions(), mState));
appendStage(
new WriteCollectionStage<CSMWorld::IdCollection<ESM::Region>>(mDocument.getData().getRegions(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::BirthSign> >
(mDocument.getData().getBirthsigns(), mState));
appendStage(
new WriteCollectionStage<CSMWorld::IdCollection<ESM::BirthSign>>(mDocument.getData().getBirthsigns(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Spell> >
(mDocument.getData().getSpells(), mState));
appendStage(new WriteCollectionStage<CSMWorld::IdCollection<ESM::Spell>>(mDocument.getData().getSpells(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Enchantment> >
(mDocument.getData().getEnchantments(), mState));
appendStage(new WriteCollectionStage<CSMWorld::IdCollection<ESM::Enchantment>>(
mDocument.getData().getEnchantments(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::BodyPart> >
(mDocument.getData().getBodyParts(), mState));
appendStage(
new WriteCollectionStage<CSMWorld::IdCollection<ESM::BodyPart>>(mDocument.getData().getBodyParts(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::SoundGenerator> >
(mDocument.getData().getSoundGens(), mState));
appendStage(new WriteCollectionStage<CSMWorld::IdCollection<ESM::SoundGenerator>>(
mDocument.getData().getSoundGens(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::MagicEffect> >
(mDocument.getData().getMagicEffects(), mState));
appendStage(new WriteCollectionStage<CSMWorld::IdCollection<ESM::MagicEffect>>(
mDocument.getData().getMagicEffects(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::StartScript> >
(mDocument.getData().getStartScripts(), mState));
appendStage(new WriteCollectionStage<CSMWorld::IdCollection<ESM::StartScript>>(
mDocument.getData().getStartScripts(), mState));
appendStage(new WriteRefIdCollectionStage(mDocument, mState));

@ -18,10 +18,7 @@ namespace CSMDoc
SavingState mState;
public:
Saving (Document& document, const std::filesystem::path& projectPath,
ToUTF8::FromType encoding);
Saving(Document& document, const std::filesystem::path& projectPath, ToUTF8::FromType encoding);
};
}

@ -1,19 +1,22 @@
#include "savingstages.hpp"
#include <sstream>
#include <filesystem>
#include <sstream>
#include <components/esm3/loaddial.hpp>
#include <components/files/conversion.hpp>
#include "../world/infocollection.hpp"
#include "../world/cellcoordinates.hpp"
#include "../world/infocollection.hpp"
#include "document.hpp"
CSMDoc::OpenSaveStage::OpenSaveStage(Document& document, SavingState& state, bool projectFile)
: mDocument (document), mState (state), mProjectFile (projectFile)
{}
: mDocument(document)
, mState(state)
, mProjectFile(projectFile)
{
}
int CSMDoc::OpenSaveStage::setup()
{
@ -24,18 +27,18 @@ void CSMDoc::OpenSaveStage::perform (int stage, Messages& messages)
{
mState.start(mDocument, mProjectFile);
mState.getStream().open (
mProjectFile ? mState.getPath() : mState.getTmpPath(),
std::ios::binary);
mState.getStream().open(mProjectFile ? mState.getPath() : mState.getTmpPath(), std::ios::binary);
if (!mState.getStream().is_open())
throw std::runtime_error("failed to open stream for saving");
}
CSMDoc::WriteHeaderStage::WriteHeaderStage(Document& document, SavingState& state, bool simple)
: mDocument (document), mState (state), mSimple (simple)
{}
: mDocument(document)
, mState(state)
, mSimple(simple)
{
}
int CSMDoc::WriteHeaderStage::setup()
{
@ -61,17 +64,15 @@ void CSMDoc::WriteHeaderStage::perform (int stage, Messages& messages)
else
{
mDocument.getData().getMetaData().save(mState.getWriter());
mState.getWriter().setRecordCount (
mDocument.getData().count (CSMWorld::RecordBase::State_Modified) +
mDocument.getData().count (CSMWorld::RecordBase::State_ModifiedOnly) +
mDocument.getData().count (CSMWorld::RecordBase::State_Deleted));
mState.getWriter().setRecordCount(mDocument.getData().count(CSMWorld::RecordBase::State_Modified)
+ mDocument.getData().count(CSMWorld::RecordBase::State_ModifiedOnly)
+ mDocument.getData().count(CSMWorld::RecordBase::State_Deleted));
/// \todo refine dependency list (at least remove redundant dependencies)
std::vector<std::filesystem::path> dependencies = mDocument.getContentFiles();
std::vector<std::filesystem::path>::const_iterator end(--dependencies.end());
for (std::vector<std::filesystem::path>::const_iterator iter (dependencies.begin());
iter!=end; ++iter)
for (std::vector<std::filesystem::path>::const_iterator iter(dependencies.begin()); iter != end; ++iter)
{
auto name = Files::pathToUnicodeString(iter->filename());
auto size = std::filesystem::file_size(*iter);
@ -83,13 +84,12 @@ void CSMDoc::WriteHeaderStage::perform (int stage, Messages& messages)
mState.getWriter().save(mState.getStream());
}
CSMDoc::WriteDialogueCollectionStage::WriteDialogueCollectionStage (Document& document,
SavingState& state, bool journal)
: mState (state),
mTopics (journal ? document.getData().getJournals() : document.getData().getTopics()),
mInfos (journal ? document.getData().getJournalInfos() : document.getData().getTopicInfos())
{}
CSMDoc::WriteDialogueCollectionStage::WriteDialogueCollectionStage(Document& document, SavingState& state, bool journal)
: mState(state)
, mTopics(journal ? document.getData().getJournals() : document.getData().getTopics())
, mInfos(journal ? document.getData().getJournalInfos() : document.getData().getTopicInfos())
{
}
int CSMDoc::WriteDialogueCollectionStage::setup()
{
@ -174,10 +174,11 @@ void CSMDoc::WriteDialogueCollectionStage::perform (int stage, Messages& message
}
}
CSMDoc::WriteRefIdCollectionStage::WriteRefIdCollectionStage(Document& document, SavingState& state)
: mDocument (document), mState (state)
{}
: mDocument(document)
, mState(state)
{
}
int CSMDoc::WriteRefIdCollectionStage::setup()
{
@ -189,11 +190,11 @@ void CSMDoc::WriteRefIdCollectionStage::perform (int stage, Messages& messages)
mDocument.getData().getReferenceables().save(stage, mState.getWriter());
}
CSMDoc::CollectionReferencesStage::CollectionReferencesStage (Document& document,
SavingState& state)
: mDocument (document), mState (state)
{}
CSMDoc::CollectionReferencesStage::CollectionReferencesStage(Document& document, SavingState& state)
: mDocument(document)
, mState(state)
{
}
int CSMDoc::CollectionReferencesStage::setup()
{
@ -202,7 +203,8 @@ int CSMDoc::CollectionReferencesStage::setup()
int size = mDocument.getData().getReferences().getSize();
int steps = size / 100;
if (size%100) ++steps;
if (size % 100)
++steps;
return steps;
}
@ -213,16 +215,13 @@ void CSMDoc::CollectionReferencesStage::perform (int stage, Messages& messages)
for (int i = stage * 100; i < stage * 100 + 100 && i < size; ++i)
{
const CSMWorld::Record<CSMWorld::CellRef>& record =
mDocument.getData().getReferences().getRecord (i);
const CSMWorld::Record<CSMWorld::CellRef>& record = mDocument.getData().getReferences().getRecord(i);
if (record.isModified() || record.mState == CSMWorld::RecordBase::State_Deleted)
{
std::string cellId = record.get().mOriginalCell.empty() ?
record.get().mCell : record.get().mOriginalCell;
std::string cellId = record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell;
std::deque<int>& indices =
mState.getSubRecords()[Misc::StringUtils::lowerCase (cellId)];
std::deque<int>& indices = mState.getSubRecords()[Misc::StringUtils::lowerCase(cellId)];
// collect moved references at the end of the container
bool interior = cellId.substr(0, 1) != "#";
@ -236,8 +235,8 @@ void CSMDoc::CollectionReferencesStage::perform (int stage, Messages& messages)
// An empty mOriginalCell is meant to indicate that it is the same as
// the current cell. It is possible that a moved ref is moved again.
if ((record.get().mOriginalCell.empty() ?
record.get().mCell : record.get().mOriginalCell) != stream.str() && !interior && record.mState!=CSMWorld::RecordBase::State_ModifiedOnly && !record.get().mNew)
if ((record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell) != stream.str()
&& !interior && record.mState != CSMWorld::RecordBase::State_ModifiedOnly && !record.get().mNew)
indices.push_back(i);
else
indices.push_front(i);
@ -245,26 +244,25 @@ void CSMDoc::CollectionReferencesStage::perform (int stage, Messages& messages)
}
}
CSMDoc::WriteCellCollectionStage::WriteCellCollectionStage (Document& document,
SavingState& state)
: mDocument (document), mState (state)
{}
CSMDoc::WriteCellCollectionStage::WriteCellCollectionStage(Document& document, SavingState& state)
: mDocument(document)
, mState(state)
{
}
int CSMDoc::WriteCellCollectionStage::setup()
{
return mDocument.getData().getCells().getSize();
}
void CSMDoc::WriteCellCollectionStage::writeReferences (const std::deque<int>& references, bool interior, unsigned int& newRefNum)
void CSMDoc::WriteCellCollectionStage::writeReferences(
const std::deque<int>& references, bool interior, unsigned int& newRefNum)
{
ESM::ESMWriter& writer = mState.getWriter();
for (std::deque<int>::const_iterator iter (references.begin());
iter!=references.end(); ++iter)
for (std::deque<int>::const_iterator iter(references.begin()); iter != references.end(); ++iter)
{
const CSMWorld::Record<CSMWorld::CellRef>& ref =
mDocument.getData().getReferences().getRecord (*iter);
const CSMWorld::Record<CSMWorld::CellRef>& ref = mDocument.getData().getReferences().getRecord(*iter);
if (ref.isModified() || ref.mState == CSMWorld::RecordBase::State_Deleted)
{
@ -282,14 +280,14 @@ void CSMDoc::WriteCellCollectionStage::writeReferences (const std::deque<int>& r
stream << "#" << index.first << " " << index.second;
}
if (refRecord.mNew || refRecord.mRefNum.mIndex == 0 ||
(!interior && ref.mState==CSMWorld::RecordBase::State_ModifiedOnly &&
refRecord.mCell!=stream.str()))
if (refRecord.mNew || refRecord.mRefNum.mIndex == 0
|| (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly
&& refRecord.mCell != stream.str()))
{
refRecord.mRefNum.mIndex = newRefNum++;
}
else if ((refRecord.mOriginalCell.empty() ? refRecord.mCell : refRecord.mOriginalCell)
!= stream.str() && !interior)
else if ((refRecord.mOriginalCell.empty() ? refRecord.mCell : refRecord.mOriginalCell) != stream.str()
&& !interior)
{
// An empty mOriginalCell is meant to indicate that it is the same as
// the current cell. It is possible that a moved ref is moved again.
@ -322,12 +320,11 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
std::deque<int> tempRefs;
std::deque<int> persistentRefs;
std::map<std::string, std::deque<int> >::const_iterator references =
mState.getSubRecords().find (Misc::StringUtils::lowerCase (cell.get().mId));
std::map<std::string, std::deque<int>>::const_iterator references
= mState.getSubRecords().find(Misc::StringUtils::lowerCase(cell.get().mId));
if (cell.isModified() ||
cell.mState == CSMWorld::RecordBase::State_Deleted ||
references!=mState.getSubRecords().end())
if (cell.isModified() || cell.mState == CSMWorld::RecordBase::State_Deleted
|| references != mState.getSubRecords().end())
{
CSMWorld::Cell cellRecord = cell.get();
bool interior = cellRecord.mId.substr(0, 1) != "#";
@ -337,18 +334,16 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
if (references != mState.getSubRecords().end())
{
for (std::deque<int>::const_iterator iter (references->second.begin());
iter!=references->second.end(); ++iter)
for (std::deque<int>::const_iterator iter(references->second.begin()); iter != references->second.end();
++iter)
{
const CSMWorld::Record<CSMWorld::CellRef>& ref =
mDocument.getData().getReferences().getRecord (*iter);
const CSMWorld::Record<CSMWorld::CellRef>& ref = mDocument.getData().getReferences().getRecord(*iter);
CSMWorld::CellRef refRecord = ref.get();
CSMWorld::RefIdData::LocalIndex localIndex = refIdData.searchId(refRecord.mRefID);
unsigned int recordFlags = refIdData.getRecordFlags(refRecord.mRefID);
bool isPersistent = ((recordFlags & ESM::FLAG_Persistent) != 0)
|| refRecord.mTeleport
bool isPersistent = ((recordFlags & ESM::FLAG_Persistent) != 0) || refRecord.mTeleport
|| localIndex.second == CSMWorld::UniversalId::Type_Creature
|| localIndex.second == CSMWorld::UniversalId::Type_Npc;
@ -357,8 +352,8 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
else
tempRefs.push_back(*iter);
if (refRecord.mNew ||
(!interior && ref.mState==CSMWorld::RecordBase::State_ModifiedOnly &&
if (refRecord.mNew
|| (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly &&
/// \todo consider worldspace
CSMWorld::CellCoordinates(refRecord.getCellIndex()).getId("") != refRecord.mCell))
++cellRecord.mRefNumCounter;
@ -396,11 +391,11 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
}
}
CSMDoc::WritePathgridCollectionStage::WritePathgridCollectionStage (Document& document,
SavingState& state)
: mDocument (document), mState (state)
{}
CSMDoc::WritePathgridCollectionStage::WritePathgridCollectionStage(Document& document, SavingState& state)
: mDocument(document)
, mState(state)
{
}
int CSMDoc::WritePathgridCollectionStage::setup()
{
@ -410,8 +405,7 @@ int CSMDoc::WritePathgridCollectionStage::setup()
void CSMDoc::WritePathgridCollectionStage::perform(int stage, Messages& messages)
{
ESM::ESMWriter& writer = mState.getWriter();
const CSMWorld::Record<CSMWorld::Pathgrid>& pathgrid =
mDocument.getData().getPathgrids().getRecord (stage);
const CSMWorld::Record<CSMWorld::Pathgrid>& pathgrid = mDocument.getData().getPathgrids().getRecord(stage);
if (pathgrid.isModified() || pathgrid.mState == CSMWorld::RecordBase::State_Deleted)
{
@ -432,11 +426,11 @@ void CSMDoc::WritePathgridCollectionStage::perform (int stage, Messages& message
}
}
CSMDoc::WriteLandCollectionStage::WriteLandCollectionStage (Document& document,
SavingState& state)
: mDocument (document), mState (state)
{}
CSMDoc::WriteLandCollectionStage::WriteLandCollectionStage(Document& document, SavingState& state)
: mDocument(document)
, mState(state)
{
}
int CSMDoc::WriteLandCollectionStage::setup()
{
@ -446,8 +440,7 @@ int CSMDoc::WriteLandCollectionStage::setup()
void CSMDoc::WriteLandCollectionStage::perform(int stage, Messages& messages)
{
ESM::ESMWriter& writer = mState.getWriter();
const CSMWorld::Record<CSMWorld::Land>& land =
mDocument.getData().getLand().getRecord (stage);
const CSMWorld::Record<CSMWorld::Land>& land = mDocument.getData().getLand().getRecord(stage);
if (land.isModified() || land.mState == CSMWorld::RecordBase::State_Deleted)
{
@ -458,11 +451,11 @@ void CSMDoc::WriteLandCollectionStage::perform (int stage, Messages& messages)
}
}
CSMDoc::WriteLandTextureCollectionStage::WriteLandTextureCollectionStage (Document& document,
SavingState& state)
: mDocument (document), mState (state)
{}
CSMDoc::WriteLandTextureCollectionStage::WriteLandTextureCollectionStage(Document& document, SavingState& state)
: mDocument(document)
, mState(state)
{
}
int CSMDoc::WriteLandTextureCollectionStage::setup()
{
@ -472,8 +465,7 @@ int CSMDoc::WriteLandTextureCollectionStage::setup()
void CSMDoc::WriteLandTextureCollectionStage::perform(int stage, Messages& messages)
{
ESM::ESMWriter& writer = mState.getWriter();
const CSMWorld::Record<CSMWorld::LandTexture>& landTexture =
mDocument.getData().getLandTextures().getRecord (stage);
const CSMWorld::Record<CSMWorld::LandTexture>& landTexture = mDocument.getData().getLandTextures().getRecord(stage);
if (landTexture.isModified() || landTexture.mState == CSMWorld::RecordBase::State_Deleted)
{
@ -484,10 +476,10 @@ void CSMDoc::WriteLandTextureCollectionStage::perform (int stage, Messages& mess
}
}
CSMDoc::CloseSaveStage::CloseSaveStage(SavingState& state)
: mState(state)
{}
{
}
int CSMDoc::CloseSaveStage::setup()
{
@ -502,10 +494,11 @@ void CSMDoc::CloseSaveStage::perform (int stage, Messages& messages)
throw std::runtime_error("saving failed");
}
CSMDoc::FinalSavingStage::FinalSavingStage(Document& document, SavingState& state)
: mDocument (document), mState (state)
{}
: mDocument(document)
, mState(state)
{
}
int CSMDoc::FinalSavingStage::setup()
{

@ -3,8 +3,8 @@
#include "stage.hpp"
#include "../world/record.hpp"
#include "../world/idcollection.hpp"
#include "../world/record.hpp"
#include "../world/scope.hpp"
#include <components/esm/defs.hpp>
@ -33,7 +33,6 @@ namespace CSMDoc
bool mProjectFile;
public:
OpenSaveStage(Document& document, SavingState& state, bool projectFile);
///< \param projectFile Saving the project file instead of the content file.
@ -51,7 +50,6 @@ namespace CSMDoc
bool mSimple;
public:
WriteHeaderStage(Document& document, SavingState& state, bool simple);
///< \param simple Simplified header (used for project files).
@ -62,7 +60,6 @@ namespace CSMDoc
///< Messages resulting from this stage will be appended to \a messages.
};
template <class CollectionT>
class WriteCollectionStage : public Stage
{
@ -71,9 +68,8 @@ namespace CSMDoc
CSMWorld::Scope mScope;
public:
WriteCollectionStage (const CollectionT& collection, SavingState& state,
CSMWorld::Scope scope = CSMWorld::Scope_Content);
WriteCollectionStage(
const CollectionT& collection, SavingState& state, CSMWorld::Scope scope = CSMWorld::Scope_Content);
int setup() override;
///< \return number of steps
@ -83,10 +79,13 @@ namespace CSMDoc
};
template <class CollectionT>
WriteCollectionStage<CollectionT>::WriteCollectionStage (const CollectionT& collection,
SavingState& state, CSMWorld::Scope scope)
: mCollection (collection), mState (state), mScope (scope)
{}
WriteCollectionStage<CollectionT>::WriteCollectionStage(
const CollectionT& collection, SavingState& state, CSMWorld::Scope scope)
: mCollection(collection)
, mState(state)
, mScope(scope)
{
}
template <class CollectionT>
int WriteCollectionStage<CollectionT>::setup()
@ -104,9 +103,8 @@ namespace CSMDoc
CSMWorld::RecordBase::State state = mCollection.getRecord(stage).mState;
typename CollectionT::ESXRecord record = mCollection.getRecord(stage).get();
if (state == CSMWorld::RecordBase::State_Modified ||
state == CSMWorld::RecordBase::State_ModifiedOnly ||
state == CSMWorld::RecordBase::State_Deleted)
if (state == CSMWorld::RecordBase::State_Modified || state == CSMWorld::RecordBase::State_ModifiedOnly
|| state == CSMWorld::RecordBase::State_Deleted)
{
writer.startRecord(record.sRecordId, record.mRecordFlags);
record.save(writer, state == CSMWorld::RecordBase::State_Deleted);
@ -114,7 +112,6 @@ namespace CSMDoc
}
}
class WriteDialogueCollectionStage : public Stage
{
SavingState& mState;
@ -122,7 +119,6 @@ namespace CSMDoc
CSMWorld::InfoCollection& mInfos;
public:
WriteDialogueCollectionStage(Document& document, SavingState& state, bool journal);
int setup() override;
@ -132,14 +128,12 @@ namespace CSMDoc
///< Messages resulting from this stage will be appended to \a messages.
};
class WriteRefIdCollectionStage : public Stage
{
Document& mDocument;
SavingState& mState;
public:
WriteRefIdCollectionStage(Document& document, SavingState& state);
int setup() override;
@ -149,14 +143,12 @@ namespace CSMDoc
///< Messages resulting from this stage will be appended to \a messages.
};
class CollectionReferencesStage : public Stage
{
Document& mDocument;
SavingState& mState;
public:
CollectionReferencesStage(Document& document, SavingState& state);
int setup() override;
@ -174,7 +166,6 @@ namespace CSMDoc
void writeReferences(const std::deque<int>& references, bool interior, unsigned int& newRefNum);
public:
WriteCellCollectionStage(Document& document, SavingState& state);
int setup() override;
@ -184,14 +175,12 @@ namespace CSMDoc
///< Messages resulting from this stage will be appended to \a messages.
};
class WritePathgridCollectionStage : public Stage
{
Document& mDocument;
SavingState& mState;
public:
WritePathgridCollectionStage(Document& document, SavingState& state);
int setup() override;
@ -201,14 +190,12 @@ namespace CSMDoc
///< Messages resulting from this stage will be appended to \a messages.
};
class WriteLandCollectionStage : public Stage
{
Document& mDocument;
SavingState& mState;
public:
WriteLandCollectionStage(Document& document, SavingState& state);
int setup() override;
@ -218,14 +205,12 @@ namespace CSMDoc
///< Messages resulting from this stage will be appended to \a messages.
};
class WriteLandTextureCollectionStage : public Stage
{
Document& mDocument;
SavingState& mState;
public:
WriteLandTextureCollectionStage(Document& document, SavingState& state);
int setup() override;
@ -240,7 +225,6 @@ namespace CSMDoc
SavingState& mState;
public:
CloseSaveStage(SavingState& state);
int setup() override;
@ -256,7 +240,6 @@ namespace CSMDoc
SavingState& mState;
public:
FinalSavingStage(Document& document, SavingState& state);
int setup() override;

@ -3,12 +3,14 @@
#include <filesystem>
#include <utility>
#include "operation.hpp"
#include "document.hpp"
#include "operation.hpp"
CSMDoc::SavingState::SavingState (Operation& operation, std::filesystem::path projectPath,
ToUTF8::FromType encoding)
: mOperation (operation), mEncoder (encoding), mProjectPath (std::move(projectPath)), mProjectFile (false)
CSMDoc::SavingState::SavingState(Operation& operation, std::filesystem::path projectPath, ToUTF8::FromType encoding)
: mOperation(operation)
, mEncoder(encoding)
, mProjectPath(std::move(projectPath))
, mProjectFile(false)
{
mWriter.setEncoder(&mEncoder);
}

@ -1,10 +1,10 @@
#ifndef CSM_DOC_SAVINGSTATE_H
#define CSM_DOC_SAVINGSTATE_H
#include <fstream>
#include <map>
#include <deque>
#include <filesystem>
#include <fstream>
#include <map>
#include <components/esm3/esmwriter.hpp>
@ -28,9 +28,7 @@ namespace CSMDoc
std::map<std::string, std::deque<int>> mSubRecords; // record ID, list of subrecords
public:
SavingState (Operation& operation, std::filesystem::path projectPath,
ToUTF8::FromType encoding);
SavingState(Operation& operation, std::filesystem::path projectPath, ToUTF8::FromType encoding);
bool hasError() const;
@ -51,7 +49,6 @@ namespace CSMDoc
std::map<std::string, std::deque<int>>& getSubRecords();
};
}
#endif

@ -1,8 +1,8 @@
#ifndef CSM_DOC_STAGE_H
#define CSM_DOC_STAGE_H
#include <vector>
#include <string>
#include <vector>
#include "messages.hpp"
@ -13,7 +13,6 @@ namespace CSMDoc
class Stage
{
public:
virtual ~Stage();
virtual int setup() = 0;

@ -2,10 +2,10 @@
CSMFilter::AndNode::AndNode(const std::vector<std::shared_ptr<Node>>& nodes)
: NAryNode(nodes, "and")
{}
{
}
bool CSMFilter::AndNode::test (const CSMWorld::IdTableBase& table, int row,
const std::map<int, int>& columns) const
bool CSMFilter::AndNode::test(const CSMWorld::IdTableBase& table, int row, const std::map<int, int>& columns) const
{
int size = getSize();

@ -8,11 +8,9 @@ namespace CSMFilter
class AndNode : public NAryNode
{
public:
AndNode(const std::vector<std::shared_ptr<Node>>& nodes);
bool test (const CSMWorld::IdTableBase& table, int row,
const std::map<int, int>& columns) const override;
bool test(const CSMWorld::IdTableBase& table, int row, const std::map<int, int>& columns) const override;
///< \return Can the specified table row pass through to filter?
/// \param columns column ID to column index mapping
};

@ -1,9 +1,11 @@
#include "booleannode.hpp"
CSMFilter::BooleanNode::BooleanNode (bool true_) : mTrue (true_) {}
CSMFilter::BooleanNode::BooleanNode(bool true_)
: mTrue(true_)
{
}
bool CSMFilter::BooleanNode::test (const CSMWorld::IdTableBase& table, int row,
const std::map<int, int>& columns) const
bool CSMFilter::BooleanNode::test(const CSMWorld::IdTableBase& table, int row, const std::map<int, int>& columns) const
{
return mTrue;
}

@ -10,11 +10,9 @@ namespace CSMFilter
bool mTrue;
public:
BooleanNode(bool true_);
bool test (const CSMWorld::IdTableBase& table, int row,
const std::map<int, int>& columns) const override;
bool test(const CSMWorld::IdTableBase& table, int row, const std::map<int, int>& columns) const override;
///< \return Can the specified table row pass through to filter?
/// \param columns column ID to column index mapping
@ -22,7 +20,6 @@ namespace CSMFilter
///< Return a string that represents this node.
///
/// \param numericColumns Use numeric IDs instead of string to represent columns.
};
}

@ -4,4 +4,3 @@ std::vector<int> CSMFilter::LeafNode::getReferencedColumns() const
{
return std::vector<int>();
}

@ -10,7 +10,6 @@ namespace CSMFilter
class LeafNode : public Node
{
public:
std::vector<int> getReferencedColumns() const override;
///< Return a list of the IDs of the columns referenced by this node. The column mapping
/// passed into test as columns must contain all columns listed here.

@ -2,10 +2,11 @@
#include <sstream>
CSMFilter::NAryNode::NAryNode (const std::vector<std::shared_ptr<Node> >& nodes,
const std::string& name)
: mNodes (nodes), mName (name)
{}
CSMFilter::NAryNode::NAryNode(const std::vector<std::shared_ptr<Node>>& nodes, const std::string& name)
: mNodes(nodes)
, mName(name)
{
}
int CSMFilter::NAryNode::getSize() const
{
@ -21,8 +22,7 @@ std::vector<int> CSMFilter::NAryNode::getReferencedColumns() const
{
std::vector<int> columns;
for (std::vector<std::shared_ptr<Node> >::const_iterator iter (mNodes.begin());
iter!=mNodes.end(); ++iter)
for (std::vector<std::shared_ptr<Node>>::const_iterator iter(mNodes.begin()); iter != mNodes.end(); ++iter)
{
std::vector<int> columns2 = (*iter)->getReferencedColumns();
@ -55,5 +55,3 @@ std::string CSMFilter::NAryNode::toString (bool numericColumns) const
return stream.str();
}

@ -1,8 +1,8 @@
#ifndef CSM_FILTER_NARYNODE_H
#define CSM_FILTER_NARYNODE_H
#include <vector>
#include <string>
#include <vector>
#include "node.hpp"
@ -14,7 +14,6 @@ namespace CSMFilter
std::string mName;
public:
NAryNode(const std::vector<std::shared_ptr<Node>>& nodes, const std::string& name);
int getSize() const;

@ -1,9 +1,9 @@
#ifndef CSM_FILTER_NODE_H
#define CSM_FILTER_NODE_H
#include <string>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <QMetaType>
@ -26,13 +26,11 @@ namespace CSMFilter
Node& operator=(const Node&);
public:
Node();
virtual ~Node();
virtual bool test (const CSMWorld::IdTableBase& table, int row,
const std::map<int, int>& columns) const = 0;
virtual bool test(const CSMWorld::IdTableBase& table, int row, const std::map<int, int>& columns) const = 0;
///< \return Can the specified table row pass through to filter?
/// \param columns column ID to column index mapping

@ -1,9 +1,11 @@
#include "notnode.hpp"
CSMFilter::NotNode::NotNode (std::shared_ptr<Node> child) : UnaryNode (child, "not") {}
CSMFilter::NotNode::NotNode(std::shared_ptr<Node> child)
: UnaryNode(child, "not")
{
}
bool CSMFilter::NotNode::test (const CSMWorld::IdTableBase& table, int row,
const std::map<int, int>& columns) const
bool CSMFilter::NotNode::test(const CSMWorld::IdTableBase& table, int row, const std::map<int, int>& columns) const
{
return !getChild().test(table, row, columns);
}

@ -8,11 +8,9 @@ namespace CSMFilter
class NotNode : public UnaryNode
{
public:
NotNode(std::shared_ptr<Node> child);
bool test (const CSMWorld::IdTableBase& table, int row,
const std::map<int, int>& columns) const override;
bool test(const CSMWorld::IdTableBase& table, int row, const std::map<int, int>& columns) const override;
///< \return Can the specified table row pass through to filter?
/// \param columns column ID to column index mapping
};

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save