mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 23:06:41 +00:00
Remove redundant ESM::RefId member functions
This commit is contained in:
parent
fe57aec2a4
commit
755067f0f3
5 changed files with 23 additions and 39 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include "esmstore.hpp"
|
#include "esmstore.hpp"
|
||||||
#include "player.hpp"
|
#include "player.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
|
@ -932,7 +933,7 @@ namespace MWWorld
|
||||||
ESM::WeatherState state;
|
ESM::WeatherState state;
|
||||||
state.load(reader);
|
state.load(reader);
|
||||||
|
|
||||||
mCurrentRegion.swap(state.mCurrentRegion);
|
std::swap(mCurrentRegion, state.mCurrentRegion);
|
||||||
mTimePassed = state.mTimePassed;
|
mTimePassed = state.mTimePassed;
|
||||||
mFastForward = state.mFastForward;
|
mFastForward = state.mFastForward;
|
||||||
mWeatherUpdateTime = state.mWeatherUpdateTime;
|
mWeatherUpdateTime = state.mWeatherUpdateTime;
|
||||||
|
|
|
@ -16,11 +16,6 @@ namespace ESM
|
||||||
return Misc::StringUtils::ciLess(mId, rhs.mId);
|
return Misc::StringUtils::ciLess(mId, rhs.mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RefId::operator>(const RefId& rhs) const
|
|
||||||
{
|
|
||||||
return Misc::StringUtils::ciGreater(mId, rhs.mId);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const RefId& refId)
|
std::ostream& operator<<(std::ostream& os, const RefId& refId)
|
||||||
{
|
{
|
||||||
os << refId.getRefIdString();
|
os << refId.getRefIdString();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef OPENMW_COMPONENTS_ESM_REFID_HPP
|
#ifndef OPENMW_COMPONENTS_ESM_REFID_HPP
|
||||||
#define OPENMW_COMPONENTS_ESM_REFID_HPP
|
#define OPENMW_COMPONENTS_ESM_REFID_HPP
|
||||||
#include <compare>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -14,11 +14,12 @@ namespace ESM
|
||||||
struct RefId
|
struct RefId
|
||||||
{
|
{
|
||||||
const static RefId sEmpty;
|
const static RefId sEmpty;
|
||||||
|
|
||||||
bool empty() const { return mId.empty(); }
|
bool empty() const { return mId.empty(); }
|
||||||
void swap(RefId& rhs) { mId.swap(rhs.mId); }
|
|
||||||
bool operator==(const RefId& rhs) const;
|
bool operator==(const RefId& rhs) const;
|
||||||
|
|
||||||
bool operator<(const RefId& rhs) const;
|
bool operator<(const RefId& rhs) const;
|
||||||
bool operator>(const RefId& rhs) const;
|
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const RefId& dt);
|
friend std::ostream& operator<<(std::ostream& os, const RefId& dt);
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
#define COMPONENTS_ESM_MAGICEFFECTS_H
|
#define COMPONENTS_ESM_MAGICEFFECTS_H
|
||||||
|
|
||||||
#include <components/esm/refid.hpp>
|
#include <components/esm/refid.hpp>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
|
@ -29,30 +31,25 @@ namespace ESM
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const SummonKey& other) const
|
|
||||||
{
|
|
||||||
return mEffectId == other.mEffectId && mSourceId == other.mSourceId && mEffectIndex == other.mEffectIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<(const SummonKey& other) const
|
|
||||||
{
|
|
||||||
if (mEffectId < other.mEffectId)
|
|
||||||
return true;
|
|
||||||
if (mEffectId > other.mEffectId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (mSourceId < other.mSourceId)
|
|
||||||
return true;
|
|
||||||
if (mSourceId > other.mSourceId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return mEffectIndex < other.mEffectIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mEffectId;
|
int mEffectId;
|
||||||
ESM::RefId mSourceId;
|
ESM::RefId mSourceId;
|
||||||
int mEffectIndex;
|
int mEffectIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline auto makeTupleRef(const SummonKey& value) noexcept
|
||||||
|
{
|
||||||
|
return std::tie(value.mEffectId, value.mSourceId, value.mEffectIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator==(const SummonKey& l, const SummonKey& r) noexcept
|
||||||
|
{
|
||||||
|
return makeTupleRef(l) == makeTupleRef(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator<(const SummonKey& l, const SummonKey& r) noexcept
|
||||||
|
{
|
||||||
|
return makeTupleRef(l) < makeTupleRef(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,16 +20,6 @@ namespace Misc::StringUtils
|
||||||
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), CiCharLess());
|
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), CiCharLess());
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CiCharGreater
|
|
||||||
{
|
|
||||||
bool operator()(char x, char y) const { return toLower(x) > toLower(y); }
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool ciGreater(std::string_view x, std::string_view y)
|
|
||||||
{
|
|
||||||
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), CiCharGreater());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool ciEqual(std::string_view x, std::string_view y)
|
inline bool ciEqual(std::string_view x, std::string_view y)
|
||||||
{
|
{
|
||||||
if (std::size(x) != std::size(y))
|
if (std::size(x) != std::size(y))
|
||||||
|
|
Loading…
Reference in a new issue