mirror of https://github.com/PrimeDecomp/prime.git
parent
8db2425e27
commit
a889a5b919
|
@ -7,7 +7,7 @@ class CInputStream;
|
|||
template < typename T >
|
||||
struct TType {};
|
||||
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 {
|
||||
public:
|
||||
|
@ -27,8 +27,8 @@ public:
|
|||
void Get(void* dest, unsigned long len);
|
||||
|
||||
template < typename T >
|
||||
inline T Get() {
|
||||
return cinput_stream_helper(TType< T >(), *this);
|
||||
inline T Get(const TType<T>& type) {
|
||||
return cinput_stream_helper(type, *this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -46,25 +46,29 @@ private:
|
|||
};
|
||||
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
template <>
|
||||
inline float cinput_stream_helper(const TType< float >& type, CInputStream& in) {
|
||||
return in.ReadFloat();
|
||||
}
|
||||
|
||||
// rstl
|
||||
#include "rstl/pair.hpp"
|
||||
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;
|
||||
result.first = in.Get< L >();
|
||||
result.second = in.Get< R >();
|
||||
result.first = in.Get(TType< L >());
|
||||
result.second = in.Get(TType< R >());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ static const wchar_t skInvalidString[] = L"Invalid";
|
|||
CStringTable::CStringTable(CInputStream& in) : x0_stringCount(0), x4_data(NULL) {
|
||||
in.ReadLong();
|
||||
in.ReadLong();
|
||||
size_t langCount = in.Get< size_t >();
|
||||
x0_stringCount = in.Get< u32 >();
|
||||
size_t langCount = in.Get(TType< size_t >());
|
||||
x0_stringCount = in.Get(TType< u32 >());
|
||||
rstl::vector< rstl::pair< FourCC, u32 > > langOffsets(langCount);
|
||||
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;
|
||||
|
@ -29,7 +29,7 @@ CStringTable::CStringTable(CInputStream& in) : x0_stringCount(0), x4_data(NULL)
|
|||
in.ReadChar();
|
||||
}
|
||||
|
||||
u32 dataLen = in.Get< u32 >();
|
||||
u32 dataLen = in.Get(TType< u32 >());
|
||||
x4_data = new u8[dataLen];
|
||||
in.ReadBytes(x4_data.get(), dataLen);
|
||||
}
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
#include "Kyoto/Streams/CInputStream.hpp"
|
||||
|
||||
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