mirror of https://github.com/PrimeDecomp/prime.git
Minor correction to CInputStream::Get
This commit is contained in:
parent
2f39c70005
commit
7cd80cf53b
|
@ -7,7 +7,7 @@ class CInputStream;
|
||||||
template < typename T >
|
template < typename T >
|
||||||
struct TType {};
|
struct TType {};
|
||||||
template < typename T >
|
template < typename T >
|
||||||
inline T cinput_stream_helper(TType< T > type, CInputStream& in);
|
inline T cinput_stream_helper(const TType< T >& type, CInputStream& in);
|
||||||
|
|
||||||
class CInputStream {
|
class CInputStream {
|
||||||
public:
|
public:
|
||||||
|
@ -27,8 +27,8 @@ public:
|
||||||
void Get(void* dest, unsigned long len);
|
void Get(void* dest, unsigned long len);
|
||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
inline T Get() {
|
inline T Get(const TType<T>& type) {
|
||||||
return cinput_stream_helper(TType< T >(), *this);
|
return cinput_stream_helper(type, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -46,25 +46,29 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline s32 cinput_stream_helper(TType< s32 > type, CInputStream& in) {
|
inline s32 cinput_stream_helper(const TType< s32 >& type, CInputStream& in) {
|
||||||
return in.ReadLong();
|
return in.ReadLong();
|
||||||
}
|
}
|
||||||
template <>
|
template <>
|
||||||
inline u32 cinput_stream_helper(TType< u32 > type, CInputStream& in) {
|
inline u32 cinput_stream_helper(const TType< u32 >& type, CInputStream& in) {
|
||||||
return in.ReadLong();
|
return in.ReadLong();
|
||||||
}
|
}
|
||||||
template <>
|
template <>
|
||||||
inline unsigned long cinput_stream_helper(TType< unsigned long > type, CInputStream& in) {
|
inline unsigned long cinput_stream_helper(const TType< unsigned long >& type, CInputStream& in) {
|
||||||
return in.ReadLong();
|
return in.ReadLong();
|
||||||
}
|
}
|
||||||
|
template <>
|
||||||
|
inline float cinput_stream_helper(const TType< float >& type, CInputStream& in) {
|
||||||
|
return in.ReadFloat();
|
||||||
|
}
|
||||||
|
|
||||||
// rstl
|
// rstl
|
||||||
#include "rstl/pair.hpp"
|
#include "rstl/pair.hpp"
|
||||||
template < typename L, typename R >
|
template < typename L, typename R >
|
||||||
inline rstl::pair< L, R > cinput_stream_helper(TType< rstl::pair< L, R > > type, CInputStream& in) {
|
inline rstl::pair< L, R > cinput_stream_helper(const TType< rstl::pair< L, R > >& type, CInputStream& in) {
|
||||||
rstl::pair< L, R > result;
|
rstl::pair< L, R > result;
|
||||||
result.first = in.Get< L >();
|
result.first = in.Get(TType< L >());
|
||||||
result.second = in.Get< R >();
|
result.second = in.Get(TType< R >());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@ static const wchar_t skInvalidString[] = L"Invalid";
|
||||||
CStringTable::CStringTable(CInputStream& in) : x0_stringCount(0), x4_data(NULL) {
|
CStringTable::CStringTable(CInputStream& in) : x0_stringCount(0), x4_data(NULL) {
|
||||||
in.ReadLong();
|
in.ReadLong();
|
||||||
in.ReadLong();
|
in.ReadLong();
|
||||||
size_t langCount = in.Get< size_t >();
|
size_t langCount = in.Get(TType< size_t >());
|
||||||
x0_stringCount = in.Get< u32 >();
|
x0_stringCount = in.Get(TType< u32 >());
|
||||||
rstl::vector< rstl::pair< FourCC, u32 > > langOffsets(langCount);
|
rstl::vector< rstl::pair< FourCC, u32 > > langOffsets(langCount);
|
||||||
for (size_t i = 0; i < langCount; ++i) {
|
for (size_t i = 0; i < langCount; ++i) {
|
||||||
langOffsets.push_back(in.Get< rstl::pair< FourCC, u32 > >());
|
langOffsets.push_back(in.Get(TType< rstl::pair< FourCC, u32 > >()));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t offset = langOffsets.front().second;
|
size_t offset = langOffsets.front().second;
|
||||||
|
@ -29,7 +29,7 @@ CStringTable::CStringTable(CInputStream& in) : x0_stringCount(0), x4_data(NULL)
|
||||||
in.ReadChar();
|
in.ReadChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 dataLen = in.Get< u32 >();
|
u32 dataLen = in.Get(TType< u32 >());
|
||||||
x4_data = new u8[dataLen];
|
x4_data = new u8[dataLen];
|
||||||
in.ReadBytes(x4_data.get(), dataLen);
|
in.ReadBytes(x4_data.get(), dataLen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
#include "Kyoto/Streams/CInputStream.hpp"
|
#include "Kyoto/Streams/CInputStream.hpp"
|
||||||
|
|
||||||
CHUDMemoParms::CHUDMemoParms(CInputStream& in)
|
CHUDMemoParms::CHUDMemoParms(CInputStream& in)
|
||||||
: mDispTime(in.ReadFloat()), mClearMemoWindow(in.ReadBool()), mFadeOutOnly(false), mHintMemo(false) {}
|
: mDispTime(in.Get(TType<float>())), mClearMemoWindow(in.ReadBool()), mFadeOutOnly(false), mHintMemo(false) {}
|
||||||
|
|
Loading…
Reference in New Issue