mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 07:45:36 +00:00
Fix loading ESM3 QuickKeys
This commit is contained in:
parent
4b5de083d8
commit
2135eba103
3 changed files with 37 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <components/esm3/loadregn.hpp>
|
||||
#include <components/esm3/loadscpt.hpp>
|
||||
#include <components/esm3/player.hpp>
|
||||
#include <components/esm3/quickkeys.hpp>
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
@ -27,6 +28,11 @@ namespace ESM
|
|||
{
|
||||
return std::tie(value.mSound, value.mChance);
|
||||
}
|
||||
|
||||
auto tie(const ESM::QuickKeys::QuickKey& value)
|
||||
{
|
||||
return std::tie(value.mType, value.mId);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool operator==(const ESM::ContItem& lhs, const ESM::ContItem& rhs)
|
||||
|
@ -50,6 +56,16 @@ namespace ESM
|
|||
<< "}";
|
||||
}
|
||||
|
||||
inline bool operator==(const ESM::QuickKeys::QuickKey& lhs, const ESM::QuickKeys::QuickKey& rhs)
|
||||
{
|
||||
return tie(lhs) == tie(rhs);
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const ESM::QuickKeys::QuickKey& value)
|
||||
{
|
||||
return stream << "ESM::QuickKeys::QuickKey {.mType = '" << value.mType << "', .mId = " << value.mId << "}";
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace ::testing;
|
||||
|
@ -291,6 +307,25 @@ namespace ESM
|
|||
EXPECT_EQ(result.mData.mNumShorts, record.mData.mNumShorts);
|
||||
}
|
||||
|
||||
TEST_P(Esm3SaveLoadRecordTest, quickKeysShouldNotChange)
|
||||
{
|
||||
const QuickKeys record {
|
||||
.mKeys = {
|
||||
{
|
||||
.mType = 42,
|
||||
.mId = generateRandomRefId(32),
|
||||
},
|
||||
{
|
||||
.mType = 13,
|
||||
.mId = generateRandomRefId(32),
|
||||
},
|
||||
},
|
||||
};
|
||||
QuickKeys result;
|
||||
saveAndLoadRecord(record, GetParam(), result);
|
||||
EXPECT_EQ(result.mKeys, record.mKeys);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(FormatVersions, Esm3SaveLoadRecordTest, ValuesIn(formats));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,10 @@ namespace ESM
|
|||
{
|
||||
int keyType;
|
||||
esm.getHT(keyType);
|
||||
std::string id;
|
||||
id = esm.getHNString("ID__");
|
||||
|
||||
QuickKey key;
|
||||
key.mType = keyType;
|
||||
key.mId = ESM::RefId::stringRefId(id);
|
||||
key.mId = esm.getHNRefId("ID__");
|
||||
|
||||
mKeys.push_back(key);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define OPENMW_COMPONENTS_ESM_QUICKKEYS_H
|
||||
|
||||
#include "components/esm/refid.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
|
Loading…
Reference in a new issue