1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-17 10:10:23 +00:00

Merge branch 'esm_four_cc' into 'master'

Move fourCC to a separate file

See merge request OpenMW/openmw!2491
This commit is contained in:
psi29a 2022-11-07 13:12:20 +00:00
commit a2053a625e
4 changed files with 17 additions and 12 deletions

View File

@ -8,6 +8,7 @@
#include <osg/Vec3f>
#include "components/esm/fourcc.hpp"
#include <components/esm4/common.hpp>
namespace ESM

View File

@ -1,7 +1,7 @@
#ifndef COMPONENT_ESM_FORMAT_H
#define COMPONENT_ESM_FORMAT_H
#include "defs.hpp"
#include "components/esm/fourcc.hpp"
#include <cstdint>
#include <iosfwd>

13
components/esm/fourcc.hpp Normal file
View File

@ -0,0 +1,13 @@
#ifndef OPENMW_COMPONENTS_ESM_FOURCC_H
#define OPENMW_COMPONENTS_ESM_FOURCC_H
namespace ESM
{
inline constexpr unsigned int fourCC(const char (&name)[5])
{
return static_cast<unsigned char>(name[0]) | (static_cast<unsigned char>(name[1]) << 8)
| (static_cast<unsigned char>(name[2]) << 16) | (static_cast<unsigned char>(name[3]) << 24);
}
}
#endif // OPENMW_COMPONENTS_ESM_FOURCC_H

View File

@ -30,18 +30,9 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include "components/esm/fourcc.hpp"
namespace ESM
{
template <std::size_t len>
constexpr unsigned int fourCC(const char (&name)[len])
{
static_assert(len == 5, "Constant must be 4 characters long. (Plus null terminator)");
return static_cast<unsigned char>(name[0]) | (static_cast<unsigned char>(name[1]) << 8)
| (static_cast<unsigned char>(name[2]) << 16) | (static_cast<unsigned char>(name[3]) << 24);
}
}
#include "formid.hpp"
namespace ESM4
{