mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Merge branch 'case.ext' into 'master'
Fix a regression and use more starts_with and ends_with See merge request OpenMW/openmw!3051
This commit is contained in:
commit
a61f955e9f
@ -545,17 +545,14 @@ void MwIniImporter::importGameFiles(
|
||||
if (it == ini.end())
|
||||
break;
|
||||
|
||||
for (std::vector<std::string>::const_iterator entry = it->second.begin(); entry != it->second.end(); ++entry)
|
||||
for (const std::string& file : it->second)
|
||||
{
|
||||
std::string filetype(entry->substr(entry->length() - 3));
|
||||
Misc::StringUtils::lowerCaseInPlace(filetype);
|
||||
|
||||
if (filetype.compare("esm") == 0 || filetype.compare("esp") == 0)
|
||||
if (Misc::StringUtils::ciEndsWith(file, "esm") || Misc::StringUtils::ciEndsWith(file, "esp"))
|
||||
{
|
||||
bool found = false;
|
||||
for (auto& dataPath : dataPaths)
|
||||
{
|
||||
std::filesystem::path path = dataPath / *entry;
|
||||
std::filesystem::path path = dataPath / file;
|
||||
std::time_t time = lastWriteTime(path, defaultTime);
|
||||
if (time != defaultTime)
|
||||
{
|
||||
@ -565,7 +562,7 @@ void MwIniImporter::importGameFiles(
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
std::cout << "Warning: " << *entry << " not found, ignoring" << std::endl;
|
||||
std::cout << "Warning: " << file << " not found, ignoring" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ namespace MWInput
|
||||
void ActionManager::screenshot()
|
||||
{
|
||||
const std::string& settingStr = Settings::Manager::getString("screenshot type", "Video");
|
||||
bool regularScreenshot = settingStr.size() == 0 || settingStr.compare("regular") == 0;
|
||||
bool regularScreenshot = settingStr.empty() || settingStr == "regular";
|
||||
|
||||
if (regularScreenshot)
|
||||
{
|
||||
|
@ -1835,7 +1835,7 @@ namespace MWMechanics
|
||||
mAnimation->disable(mAnimQueue.front().mGroup);
|
||||
mAnimQueue.pop_front();
|
||||
|
||||
bool loopfallback = (mAnimQueue.front().mGroup.compare(0, 4, "idle") == 0);
|
||||
bool loopfallback = mAnimQueue.front().mGroup.starts_with("idle");
|
||||
mAnimation->play(mAnimQueue.front().mGroup, Priority_Default, MWRender::Animation::BlendMask_All, false,
|
||||
1.0f, "start", "stop", 0.0f, mAnimQueue.front().mLoopCount, loopfallback);
|
||||
}
|
||||
@ -2463,7 +2463,7 @@ namespace MWMechanics
|
||||
clearStateAnimation(mCurrentIdle);
|
||||
mIdleState = CharState_SpecialIdle;
|
||||
|
||||
bool loopfallback = (mAnimQueue.front().mGroup.compare(0, 4, "idle") == 0);
|
||||
bool loopfallback = mAnimQueue.front().mGroup.starts_with("idle");
|
||||
mAnimation->play(anim.mGroup, Priority_Persistent, MWRender::Animation::BlendMask_All, false, 1.0f, "start",
|
||||
"stop", complete, anim.mLoopCount, loopfallback);
|
||||
}
|
||||
@ -2513,7 +2513,7 @@ namespace MWMechanics
|
||||
clearStateAnimation(mCurrentIdle);
|
||||
|
||||
mIdleState = CharState_SpecialIdle;
|
||||
bool loopfallback = (entry.mGroup.compare(0, 4, "idle") == 0);
|
||||
bool loopfallback = entry.mGroup.starts_with("idle");
|
||||
mAnimation->play(groupname, persist && groupname != "idle" ? Priority_Persistent : Priority_Default,
|
||||
MWRender::Animation::BlendMask_All, false, 1.0f, ((mode == 2) ? "loop start" : "start"), "stop", 0.0f,
|
||||
count - 1, loopfallback);
|
||||
|
@ -611,7 +611,7 @@ namespace MWRender
|
||||
{
|
||||
model = Misc::ResourceHelpers::correctActorModelPath(model, mSceneManager->getVFS());
|
||||
std::string kfname = Misc::StringUtils::lowerCase(model);
|
||||
if (kfname.size() > 4 && kfname.compare(kfname.size() - 4, 4, ".nif") == 0)
|
||||
if (kfname.size() > 4 && kfname.ends_with(".nif"))
|
||||
{
|
||||
kfname.replace(kfname.size() - 4, 4, ".kf");
|
||||
if (mSceneManager->getVFS()->exists(kfname))
|
||||
|
@ -166,17 +166,17 @@ namespace MWRender
|
||||
Screenshot360Type screenshotMapping = Spherical;
|
||||
|
||||
const std::string& settingStr = Settings::Manager::getString("screenshot type", "Video");
|
||||
std::vector<std::string> settingArgs;
|
||||
std::vector<std::string_view> settingArgs;
|
||||
Misc::StringUtils::split(settingStr, settingArgs);
|
||||
|
||||
if (settingArgs.size() > 0)
|
||||
{
|
||||
std::string typeStrings[4] = { "spherical", "cylindrical", "planet", "cubemap" };
|
||||
std::string_view typeStrings[4] = { "spherical", "cylindrical", "planet", "cubemap" };
|
||||
bool found = false;
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (settingArgs[0].compare(typeStrings[i]) == 0)
|
||||
if (settingArgs[0] == typeStrings[i])
|
||||
{
|
||||
screenshotMapping = static_cast<Screenshot360Type>(i);
|
||||
found = true;
|
||||
|
@ -125,9 +125,9 @@ namespace MWWorld
|
||||
Misc::StringUtils::lowerCaseInPlace(mesh);
|
||||
if (mesh[slashpos + 1] == 'x')
|
||||
{
|
||||
std::string kfname = mesh;
|
||||
if (kfname.size() > 4 && kfname.compare(kfname.size() - 4, 4, ".nif") == 0)
|
||||
if (mesh.size() > 4 && mesh.ends_with(".nif"))
|
||||
{
|
||||
std::string kfname = mesh;
|
||||
kfname.replace(kfname.size() - 4, 4, ".kf");
|
||||
if (mSceneManager->getVFS()->exists(kfname))
|
||||
mPreloadedObjects.insert(mKeyframeManager->get(kfname));
|
||||
|
@ -33,7 +33,7 @@ namespace MWWorld
|
||||
{
|
||||
std::string model = Misc::StringUtils::lowerCase(stat.mModel);
|
||||
std::replace(model.begin(), model.end(), '/', '\\');
|
||||
if (model.compare(0, prefix.size(), prefix) != 0)
|
||||
if (!model.starts_with(prefix))
|
||||
continue;
|
||||
mMeshCache[stat.mId] = Misc::ResourceHelpers::correctMeshPath(model, vfs);
|
||||
}
|
||||
@ -42,7 +42,7 @@ namespace MWWorld
|
||||
{
|
||||
std::string model = Misc::StringUtils::lowerCase(stat.mModel);
|
||||
std::replace(model.begin(), model.end(), '/', '\\');
|
||||
if (model.compare(0, prefix.size(), prefix) != 0)
|
||||
if (!model.starts_with(prefix))
|
||||
continue;
|
||||
mMeshCache[stat.mId] = Misc::ResourceHelpers::correctMeshPath(model, vfs);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ std::string Misc::ResourceHelpers::correctActorModelPath(const std::string& resP
|
||||
else
|
||||
mdlname.insert(mdlname.begin(), 'x');
|
||||
std::string kfname = mdlname;
|
||||
if (kfname.ends_with(".nif"))
|
||||
if (Misc::StringUtils::ciEndsWith(kfname, ".nif"))
|
||||
kfname.replace(kfname.size() - 4, 4, ".kf");
|
||||
|
||||
if (!vfs->exists(kfname))
|
||||
|
@ -217,7 +217,7 @@ namespace Nif
|
||||
"Gamebryo File Format",
|
||||
};
|
||||
const bool supportedHeader = std::any_of(verStrings.begin(), verStrings.end(),
|
||||
[&](const std::string& verString) { return head.compare(0, verString.size(), verString) == 0; });
|
||||
[&](const std::string& verString) { return head.starts_with(verString); });
|
||||
if (!supportedHeader)
|
||||
throw Nif::Exception("Invalid NIF header: " + head, filename);
|
||||
|
||||
@ -321,7 +321,7 @@ namespace Nif
|
||||
}
|
||||
|
||||
// Record separator. Some Havok records in Oblivion do not have it.
|
||||
if (hasRecordSeparators && rec.compare(0, 3, "bhk"))
|
||||
if (hasRecordSeparators && !rec.starts_with("bhk"))
|
||||
if (nif.getInt())
|
||||
Log(Debug::Warning) << "NIFFile Warning: Record number " << i << " out of " << recNum
|
||||
<< " is preceded by a non-zero separator. File: " << filename;
|
||||
|
@ -726,13 +726,9 @@ namespace NifOsg
|
||||
|
||||
if (isGeometry && !skipMeshes)
|
||||
{
|
||||
const std::string nodeName = Misc::StringUtils::lowerCase(nifNode->name);
|
||||
static const std::string markerName = "tri editormarker";
|
||||
static const std::string shadowName = "shadow";
|
||||
static const std::string shadowName2 = "tri shadow";
|
||||
const bool isMarker = hasMarkers && !nodeName.compare(0, markerName.size(), markerName);
|
||||
if (!isMarker && nodeName.compare(0, shadowName.size(), shadowName)
|
||||
&& nodeName.compare(0, shadowName2.size(), shadowName2))
|
||||
const bool isMarker = hasMarkers && Misc::StringUtils::ciStartsWith(nifNode->name, "tri editormarker");
|
||||
if (!isMarker && !Misc::StringUtils::ciStartsWith(nifNode->name, "shadow")
|
||||
&& !Misc::StringUtils::ciStartsWith(nifNode->name, "tri shadow"))
|
||||
{
|
||||
Nif::NiSkinInstancePtr skin = static_cast<const Nif::NiGeometry*>(nifNode)->skin;
|
||||
|
||||
|
@ -783,7 +783,7 @@ namespace Resource
|
||||
|
||||
// NPC skeleton files can not be optimized because of keyframes added in post
|
||||
// (most of them are usually named like 'xbase_anim.nif' anyway, but not all of them :( )
|
||||
if (basename.compare(0, 9, "base_anim") == 0 || basename.compare(0, 4, "skin") == 0)
|
||||
if (basename.starts_with("base_anim") || basename.starts_with("skin"))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -47,25 +47,25 @@ namespace Resource
|
||||
|
||||
const auto kw = kwList.substr(std::distance(kwList.begin(), kwBegin), std::distance(kwBegin, kwEnd));
|
||||
|
||||
if (kw.compare("gpu") == 0)
|
||||
if (kw == "gpu")
|
||||
collectStatGPU = true;
|
||||
else if (kw.compare("event") == 0)
|
||||
else if (kw == "event")
|
||||
collectStatEvent = true;
|
||||
else if (kw.compare("frame_rate") == 0)
|
||||
else if (kw == "frame_rate")
|
||||
collectStatFrameRate = true;
|
||||
else if (kw.compare("update") == 0)
|
||||
else if (kw == "update")
|
||||
collectStatUpdate = true;
|
||||
else if (kw.compare("engine") == 0)
|
||||
else if (kw == "engine")
|
||||
collectStatEngine = true;
|
||||
else if (kw.compare("rendering") == 0)
|
||||
else if (kw == "rendering")
|
||||
collectStatRendering = true;
|
||||
else if (kw.compare("cameraobjects") == 0)
|
||||
else if (kw == "cameraobjects")
|
||||
collectStatCameraObjects = true;
|
||||
else if (kw.compare("viewerobjects") == 0)
|
||||
else if (kw == "viewerobjects")
|
||||
collectStatViewerObjects = true;
|
||||
else if (kw.compare("resource") == 0)
|
||||
else if (kw == "resource")
|
||||
collectStatResource = true;
|
||||
else if (kw.compare("times") == 0)
|
||||
else if (kw == "times")
|
||||
{
|
||||
collectStatGPU = true;
|
||||
collectStatEvent = true;
|
||||
|
@ -51,8 +51,7 @@ namespace SceneUtil
|
||||
|
||||
bool operator()(const std::multimap<float, std::string>::value_type& value) const
|
||||
{
|
||||
return value.second.compare(0, mGroupName.size(), mGroupName) == 0
|
||||
&& value.second.compare(mGroupName.size(), 2, ": ") == 0;
|
||||
return value.second.starts_with(mGroupName) && value.second.compare(mGroupName.size(), 2, ": ") == 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user