Renaming things in FileIO to match PWE's naming conventions

This commit is contained in:
parax0 2015-12-16 15:21:21 -07:00
parent 2db8d23516
commit 4eaf4d9440
85 changed files with 666 additions and 668 deletions

View File

@ -5,7 +5,7 @@ CColor::CColor()
{ {
} }
CColor::CColor(CInputStream& rInput, bool Integral /*= false*/) CColor::CColor(IInputStream& rInput, bool Integral /*= false*/)
{ {
if (Integral) if (Integral)
{ {
@ -47,7 +47,7 @@ void CColor::SetIntegral(u8 _r, u8 _g, u8 _b, u8 _a /*= 255*/)
a = _a / 255.f; a = _a / 255.f;
} }
void CColor::Write(COutputStream &rOutput, bool Integral /*= false*/) void CColor::Write(IOutputStream &rOutput, bool Integral /*= false*/)
{ {
if (Integral) if (Integral)
{ {

View File

@ -1,8 +1,8 @@
#ifndef CCOLOR_H #ifndef CCOLOR_H
#define CCOLOR_H #define CCOLOR_H
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
#include <FileIO/COutputStream.h> #include <FileIO/IOutputStream.h>
#include "types.h" #include "types.h"
class CColor class CColor
@ -11,27 +11,27 @@ public:
float r, g, b, a; float r, g, b, a;
CColor(); CColor();
CColor(CInputStream& src, bool Integral = false); CColor(IInputStream& rSrc, bool Integral = false);
CColor(float rgba); CColor(float rgba);
CColor(float _r, float _g, float _b, float _a = 1.f); CColor(float _r, float _g, float _b, float _a = 1.f);
void SetIntegral(u8 rgba); void SetIntegral(u8 rgba);
void SetIntegral(u8 _r, u8 _g, u8 _b, u8 _a = 255); void SetIntegral(u8 _r, u8 _g, u8 _b, u8 _a = 255);
void Write(COutputStream& Output, bool Integral = false); void Write(IOutputStream& rOutput, bool Integral = false);
long ToLongRGBA() const; long ToLongRGBA() const;
long ToLongARGB() const; long ToLongARGB() const;
bool operator==(const CColor& other) const; bool operator==(const CColor& rkOther) const;
bool operator!=(const CColor& other) const; bool operator!=(const CColor& rkOther) const;
CColor operator+(const CColor& other) const; CColor operator+(const CColor& rkOther) const;
void operator+=(const CColor& other); void operator+=(const CColor& rkOther);
CColor operator-(const CColor& other) const; CColor operator-(const CColor& rkOther) const;
void operator-=(const CColor& other); void operator-=(const CColor& rkOther);
CColor operator*(const CColor& other) const; CColor operator*(const CColor& rkOther) const;
void operator*=(const CColor& other); void operator*=(const CColor& rkOther);
CColor operator*(float other) const; CColor operator*(float other) const;
void operator*=(float other); void operator*=(float other);
CColor operator/(const CColor& other) const; CColor operator/(const CColor& rkOther) const;
void operator/=(const CColor& other); void operator/=(const CColor& rkOther);
// Static // Static
static CColor Integral(u8 rgba); static CColor Integral(u8 rgba);

View File

@ -21,13 +21,13 @@ CFourCC::CFourCC(u32 src)
*this = src; *this = src;
} }
CFourCC::CFourCC(CInputStream& src) CFourCC::CFourCC(IInputStream& src)
{ {
src.ReadBytes(&mFourCC[0], 4); src.ReadBytes(&mFourCC[0], 4);
} }
// ************ FUNCTIONALITY ************ // ************ FUNCTIONALITY ************
void CFourCC::Write(COutputStream &Output) void CFourCC::Write(IOutputStream &Output)
{ {
Output.WriteBytes(mFourCC, 4); Output.WriteBytes(mFourCC, 4);
} }

View File

@ -3,8 +3,8 @@
#include "types.h" #include "types.h"
#include "TString.h" #include "TString.h"
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
#include <FileIO/COutputStream.h> #include <FileIO/IOutputStream.h>
class CFourCC class CFourCC
{ {
@ -15,10 +15,10 @@ public:
CFourCC(const char *src); CFourCC(const char *src);
CFourCC(const TString& src); CFourCC(const TString& src);
CFourCC(u32 src); CFourCC(u32 src);
CFourCC(CInputStream& src); CFourCC(IInputStream& src);
// Functionality // Functionality
void Write(COutputStream& Output); void Write(IOutputStream& Output);
u32 ToLong() const; u32 ToLong() const;
TString ToString() const; TString ToString() const;
CFourCC ToUpper() const; CFourCC ToUpper() const;

View File

@ -6,9 +6,9 @@
#include <sstream> #include <sstream>
// this class probably isn't optimized! this may not be the best way to do things // this class probably isn't optimized! this may not be the best way to do things
using IOUtil::SystemEndianness; using IOUtil::kSystemEndianness;
using IOUtil::LittleEndian; using IOUtil::eLittleEndian;
using IOUtil::BigEndian; using IOUtil::eBigEndian;
CUniqueID::CUniqueID() CUniqueID::CUniqueID()
{ {
@ -36,7 +36,7 @@ CUniqueID::CUniqueID(u64 ID)
} }
// Reverse for Big Endian // Reverse for Big Endian
if (SystemEndianness == BigEndian) if (kSystemEndianness == eBigEndian)
Reverse(); Reverse();
} }
@ -53,13 +53,13 @@ CUniqueID::CUniqueID(const char* ID)
*this = CUniqueID::FromString(ID); *this = CUniqueID::FromString(ID);
} }
CUniqueID::CUniqueID(CInputStream& Input, EUIDLength Length) CUniqueID::CUniqueID(IInputStream& Input, EUIDLength Length)
{ {
memset(mID, 0, 16); memset(mID, 0, 16);
Input.ReadBytes(&mID[16 - Length], Length); Input.ReadBytes(&mID[16 - Length], Length);
if (Length != e128Bit) if (Length != e128Bit)
if (SystemEndianness == LittleEndian) if (kSystemEndianness == eLittleEndian)
Reverse(); Reverse();
mLength = Length; mLength = Length;
@ -67,7 +67,7 @@ CUniqueID::CUniqueID(CInputStream& Input, EUIDLength Length)
u32 CUniqueID::ToLong() const u32 CUniqueID::ToLong() const
{ {
if (SystemEndianness == LittleEndian) if (kSystemEndianness == eLittleEndian)
return *((u32*) mID); return *((u32*) mID);
else else
return *((u32*) &mID[12]); return *((u32*) &mID[12]);
@ -75,7 +75,7 @@ u32 CUniqueID::ToLong() const
u64 CUniqueID::ToLongLong() const u64 CUniqueID::ToLongLong() const
{ {
if (SystemEndianness == LittleEndian) if (kSystemEndianness == eLittleEndian)
return *((u64*) mID); return *((u64*) mID);
else else
return *((u64*) &mID[8]); return *((u64*) &mID[8]);
@ -240,7 +240,7 @@ CUniqueID CUniqueID::FromString(const TString& String)
u32 LongID = Name.ToInt32(); u32 LongID = Name.ToInt32();
if (SystemEndianness == LittleEndian) if (kSystemEndianness == eLittleEndian)
memcpy(ID.mID, &LongID, 4); memcpy(ID.mID, &LongID, 4);
else else
memcpy(&ID.mID[12], &LongID, 4); memcpy(&ID.mID[12], &LongID, 4);
@ -255,7 +255,7 @@ CUniqueID CUniqueID::FromString(const TString& String)
u64 LongID = Name.ToInt64(); u64 LongID = Name.ToInt64();
if (SystemEndianness == LittleEndian) if (kSystemEndianness == eLittleEndian)
memcpy(ID.mID, &LongID, 8); memcpy(ID.mID, &LongID, 8);
else else
memcpy(&ID.mID[8], &LongID, 8); memcpy(&ID.mID[8], &LongID, 8);

View File

@ -23,7 +23,7 @@ public:
CUniqueID(u64 ID); CUniqueID(u64 ID);
CUniqueID(u64 Part1, u64 Part2); CUniqueID(u64 Part1, u64 Part2);
CUniqueID(const char* ID); CUniqueID(const char* ID);
CUniqueID(CInputStream& Input, EUIDLength Length); CUniqueID(IInputStream& Input, EUIDLength Length);
u32 ToLong() const; u32 ToLong() const;
u64 ToLongLong() const; u64 ToLongLong() const;
TString ToString() const; TString ToString() const;

View File

@ -309,7 +309,7 @@ public:
u64 part1 = std::stoull(mInternalString.substr(0, 16), nullptr, base); u64 part1 = std::stoull(mInternalString.substr(0, 16), nullptr, base);
u64 part2 = std::stoull(mInternalString.substr(16, 16), nullptr, base); u64 part2 = std::stoull(mInternalString.substr(16, 16), nullptr, base);
if (IOUtil::SystemEndianness == IOUtil::LittleEndian) if (IOUtil::kSystemEndianness == IOUtil::eLittleEndian)
{ {
IOUtil::SwapBytes(part1); IOUtil::SwapBytes(part1);
IOUtil::SwapBytes(part2); IOUtil::SwapBytes(part2);

View File

@ -15,7 +15,7 @@ CAnimationParameters::CAnimationParameters()
mUnknown4 = 0; mUnknown4 = 0;
} }
CAnimationParameters::CAnimationParameters(CInputStream& SCLY, EGame game) CAnimationParameters::CAnimationParameters(IInputStream& SCLY, EGame game)
{ {
mGame = game; mGame = game;
mpCharSet = nullptr; mpCharSet = nullptr;

View File

@ -19,7 +19,7 @@ class CAnimationParameters
public: public:
CAnimationParameters(); CAnimationParameters();
CAnimationParameters(CInputStream& SCLY, EGame game); CAnimationParameters(IInputStream& SCLY, EGame game);
CModel* GetCurrentModel(s32 nodeIndex = -1); CModel* GetCurrentModel(s32 nodeIndex = -1);
// Getters // Getters

View File

@ -1,7 +1,7 @@
#ifndef CLIGHT_H #ifndef CLIGHT_H
#define CLIGHT_H #define CLIGHT_H
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
#include <Common/CColor.h> #include <Common/CColor.h>
#include <Math/CVector3f.h> #include <Math/CVector3f.h>

View File

@ -12,7 +12,7 @@
#include <Common/CColor.h> #include <Common/CColor.h>
#include <Common/EnumUtil.h> #include <Common/EnumUtil.h>
#include <Common/types.h> #include <Common/types.h>
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
class CMaterialSet; class CMaterialSet;

View File

@ -4,7 +4,7 @@
#include "CMaterial.h" #include "CMaterial.h"
#include "CTexture.h" #include "CTexture.h"
#include "EFormatVersion.h" #include "EFormatVersion.h"
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
class CMaterialSet class CMaterialSet
{ {

View File

@ -13,7 +13,7 @@ CPakFile::CPakFile()
pak = nullptr; pak = nullptr;
} }
CPakFile::CPakFile(CInputStream* pakfile) CPakFile::CPakFile(IInputStream* pakfile)
{ {
pak = pakfile; pak = pakfile;
if (!pak->IsValid()) return; if (!pak->IsValid()) return;
@ -154,7 +154,7 @@ bool CPakFile::decompress(u8 *src, u32 src_len, u8 *dst, u32 dst_len)
while ((src < src_end) && (dst < dst_end)) { while ((src < src_end) && (dst < dst_end)) {
short block_size; short block_size;
memcpy(&block_size, src, 2); memcpy(&block_size, src, 2);
if (IOUtil::SystemEndianness == IOUtil::LittleEndian) IOUtil::SwapBytes(block_size); if (IOUtil::kSystemEndianness == IOUtil::eLittleEndian) IOUtil::SwapBytes(block_size);
src += 2; src += 2;
ret = lzo1x_decompress(src, block_size, dst, &decmp, LZO1X_MEM_DECOMPRESS); ret = lzo1x_decompress(src, block_size, dst, &decmp, LZO1X_MEM_DECOMPRESS);

View File

@ -13,13 +13,13 @@ private:
u32 version; u32 version;
std::vector<SNamedResource> NamedResTable; std::vector<SNamedResource> NamedResTable;
std::vector<SResInfo> ResInfoTable; std::vector<SResInfo> ResInfoTable;
CInputStream* pak; IInputStream* pak;
bool decompress(u8 *src, u32 src_len, u8 *dst, u32 dst_len); bool decompress(u8 *src, u32 src_len, u8 *dst, u32 dst_len);
public: public:
CPakFile(); CPakFile();
CPakFile(CInputStream* pakfile); CPakFile(IInputStream* pakfile);
~CPakFile(); ~CPakFile();
std::vector<SNamedResource> getNamedResources(); std::vector<SNamedResource> getNamedResources();

View File

@ -62,7 +62,7 @@ void CResCache::SetFolder(TString path)
void CResCache::SetPak(const TString& path) void CResCache::SetPak(const TString& path)
{ {
CFileInStream *pakfile = new CFileInStream(path.ToStdString(), IOUtil::BigEndian); CFileInStream *pakfile = new CFileInStream(path.ToStdString(), IOUtil::eBigEndian);
if (!pakfile->IsValid()) if (!pakfile->IsValid())
{ {
Log::Error("Couldn't load pak file: " + path); Log::Error("Couldn't load pak file: " + path);
@ -115,7 +115,7 @@ CResource* CResCache::GetResource(CUniqueID ResID, CFourCC type)
else else
{ {
Source = mResSource.Path + ResID.ToString() + "." + type.ToString(); Source = mResSource.Path + ResID.ToString() + "." + type.ToString();
CFileInStream file(Source.ToStdString(), IOUtil::BigEndian); CFileInStream file(Source.ToStdString(), IOUtil::eBigEndian);
if (!file.IsValid()) if (!file.IsValid())
{ {
Log::Error("Couldn't open resource: " + ResID.ToString() + "." + type.ToString()); Log::Error("Couldn't open resource: " + ResID.ToString() + "." + type.ToString());
@ -129,7 +129,7 @@ CResource* CResCache::GetResource(CUniqueID ResID, CFourCC type)
if (!pBuffer) return nullptr; if (!pBuffer) return nullptr;
// Load resource // Load resource
CMemoryInStream mem(pBuffer->data(), pBuffer->size(), IOUtil::BigEndian); CMemoryInStream mem(pBuffer->data(), pBuffer->size(), IOUtil::eBigEndian);
mem.SetSourceString(*Source.GetFileName()); mem.SetSourceString(*Source.GetFileName());
CResource *Res = nullptr; CResource *Res = nullptr;
bool SupportedFormat = true; bool SupportedFormat = true;
@ -170,7 +170,7 @@ CResource* CResCache::GetResource(const TString& ResPath)
if (got != mResourceCache.end()) if (got != mResourceCache.end())
return got->second; return got->second;
CFileInStream file(ResPath.ToStdString(), IOUtil::BigEndian); CFileInStream file(ResPath.ToStdString(), IOUtil::eBigEndian);
if (!file.IsValid()) if (!file.IsValid())
{ {
Log::Error("Couldn't open resource: " + ResPath); Log::Error("Couldn't open resource: " + ResPath);

View File

@ -156,7 +156,7 @@ float CTexture::ReadTexelAlpha(const CVector2f& TexCoord)
if (mTexelFormat == eDXT1 && mBufferExists) if (mTexelFormat == eDXT1 && mBufferExists)
{ {
CMemoryInStream Buffer(mImgDataBuffer, mImgDataSize, IOUtil::SystemEndianness); CMemoryInStream Buffer(mImgDataBuffer, mImgDataSize, IOUtil::kSystemEndianness);
// 8 bytes per 4x4 16-pixel block, left-to-right top-to-bottom // 8 bytes per 4x4 16-pixel block, left-to-right top-to-bottom
u32 BlockIdxX = TexelX / 4; u32 BlockIdxX = TexelX / 4;
@ -190,7 +190,7 @@ float CTexture::ReadTexelAlpha(const CVector2f& TexCoord)
return 1.f; return 1.f;
} }
bool CTexture::WriteDDS(COutputStream& out) bool CTexture::WriteDDS(IOutputStream& out)
{ {
if (!out.IsValid()) return false; if (!out.IsValid()) return false;

View File

@ -38,7 +38,7 @@ public:
void Bind(u32 GLTextureUnit); void Bind(u32 GLTextureUnit);
void Resize(u32 Width, u32 Height); void Resize(u32 Width, u32 Height);
float ReadTexelAlpha(const CVector2f& TexCoord); float ReadTexelAlpha(const CVector2f& TexCoord);
bool WriteDDS(COutputStream& out); bool WriteDDS(IOutputStream& out);
// Getters // Getters
ETexelFormat TexelFormat(); ETexelFormat TexelFormat();

View File

@ -6,7 +6,7 @@ CMaterialCooker::CMaterialCooker()
mpMat = nullptr; mpMat = nullptr;
} }
void CMaterialCooker::WriteMatSetPrime(COutputStream& Out) void CMaterialCooker::WriteMatSetPrime(IOutputStream& Out)
{ {
// Gather texture list from the materials before starting // Gather texture list from the materials before starting
mTextureIDs.clear(); mTextureIDs.clear();
@ -64,13 +64,13 @@ void CMaterialCooker::WriteMatSetPrime(COutputStream& Out)
Out.Seek(MatsEnd, SEEK_SET); Out.Seek(MatsEnd, SEEK_SET);
} }
void CMaterialCooker::WriteMatSetCorruption(COutputStream&) void CMaterialCooker::WriteMatSetCorruption(IOutputStream&)
{ {
// Not using parameter 1 (COutputStream& - Out) // Not using parameter 1 (IOutputStream& - Out)
// todo // todo
} }
void CMaterialCooker::WriteMaterialPrime(COutputStream& Out) void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
{ {
// Gather data from the passes before we start writing // Gather data from the passes before we start writing
u32 TexFlags = 0; u32 TexFlags = 0;
@ -320,14 +320,14 @@ void CMaterialCooker::WriteMaterialPrime(COutputStream& Out)
// Done! // Done!
} }
void CMaterialCooker::WriteMaterialCorruption(COutputStream&) void CMaterialCooker::WriteMaterialCorruption(IOutputStream&)
{ {
// Not using parameter 1 (COutputStream& - Out) // Not using parameter 1 (IOutputStream& - Out)
// todo // todo
} }
// ************ STATIC ************ // ************ STATIC ************
void CMaterialCooker::WriteCookedMatSet(CMaterialSet *pSet, EGame Version, COutputStream &Out) void CMaterialCooker::WriteCookedMatSet(CMaterialSet *pSet, EGame Version, IOutputStream &Out)
{ {
CMaterialCooker Cooker; CMaterialCooker Cooker;
Cooker.mpSet = pSet; Cooker.mpSet = pSet;
@ -344,7 +344,7 @@ void CMaterialCooker::WriteCookedMatSet(CMaterialSet *pSet, EGame Version, COutp
} }
} }
void CMaterialCooker::WriteCookedMaterial(CMaterial *pMat, EGame Version, COutputStream &Out) void CMaterialCooker::WriteCookedMaterial(CMaterial *pMat, EGame Version, IOutputStream &Out)
{ {
CMaterialCooker Cooker; CMaterialCooker Cooker;
Cooker.mpMat = pMat; Cooker.mpMat = pMat;

View File

@ -14,14 +14,14 @@ class CMaterialCooker
std::vector<u64> mMaterialHashes; std::vector<u64> mMaterialHashes;
CMaterialCooker(); CMaterialCooker();
void WriteMatSetPrime(COutputStream& Out); void WriteMatSetPrime(IOutputStream& Out);
void WriteMatSetCorruption(COutputStream& Out); void WriteMatSetCorruption(IOutputStream& Out);
void WriteMaterialPrime(COutputStream& Out); void WriteMaterialPrime(IOutputStream& Out);
void WriteMaterialCorruption(COutputStream& Out); void WriteMaterialCorruption(IOutputStream& Out);
public: public:
static void WriteCookedMatSet(CMaterialSet *pSet, EGame Version, COutputStream& Out); static void WriteCookedMatSet(CMaterialSet *pSet, EGame Version, IOutputStream& Out);
static void WriteCookedMaterial(CMaterial *pMat, EGame Version, COutputStream& Out); static void WriteCookedMaterial(CMaterial *pMat, EGame Version, IOutputStream& Out);
}; };
#endif // CMATERIALCOOKER_H #endif // CMATERIALCOOKER_H

View File

@ -60,11 +60,11 @@ void CModelCooker::GenerateSurfaceData()
mNumVertices = mVertices.size(); mNumVertices = mVertices.size();
} }
void CModelCooker::WriteEditorModel(COutputStream& /*Out*/) void CModelCooker::WriteEditorModel(IOutputStream& /*Out*/)
{ {
} }
void CModelCooker::WriteModelPrime(COutputStream& Out) void CModelCooker::WriteModelPrime(IOutputStream& Out)
{ {
GenerateSurfaceData(); GenerateSurfaceData();
@ -232,7 +232,7 @@ void CModelCooker::WriteModelPrime(COutputStream& Out)
// Done! // Done!
} }
void CModelCooker::WriteCookedModel(CModel *pModel, EGame Version, COutputStream& CMDL) void CModelCooker::WriteCookedModel(CModel *pModel, EGame Version, IOutputStream& CMDL)
{ {
CModelCooker Cooker; CModelCooker Cooker;
Cooker.mpModel = pModel; Cooker.mpModel = pModel;
@ -249,7 +249,7 @@ void CModelCooker::WriteCookedModel(CModel *pModel, EGame Version, COutputStream
} }
} }
void CModelCooker::WriteUncookedModel(CModel* /*pModel*/, COutputStream& /*EMDL*/) void CModelCooker::WriteUncookedModel(CModel* /*pModel*/, IOutputStream& /*EMDL*/)
{ {
} }

View File

@ -18,12 +18,12 @@ class CModelCooker
CModelCooker(); CModelCooker();
void GenerateSurfaceData(); void GenerateSurfaceData();
void WriteEditorModel(COutputStream& Out); void WriteEditorModel(IOutputStream& Out);
void WriteModelPrime(COutputStream& Out); void WriteModelPrime(IOutputStream& Out);
public: public:
static void WriteCookedModel(CModel *pModel, EGame Version, COutputStream& Out); static void WriteCookedModel(CModel *pModel, EGame Version, IOutputStream& Out);
static void WriteUncookedModel(CModel *pModel, COutputStream& Out); static void WriteUncookedModel(CModel *pModel, IOutputStream& Out);
static u32 GetCMDLVersion(EGame Version); static u32 GetCMDLVersion(EGame Version);
}; };

View File

@ -13,20 +13,20 @@ void CSectionMgrOut::SetSectionCount(u32 Count)
mSectionSizes.resize(Count); mSectionSizes.resize(Count);
} }
void CSectionMgrOut::Init(const COutputStream& OutputStream) void CSectionMgrOut::Init(const IOutputStream& OutputStream)
{ {
mCurSectionStart = OutputStream.Tell(); mCurSectionStart = OutputStream.Tell();
mCurSectionIndex = 0; mCurSectionIndex = 0;
} }
void CSectionMgrOut::AddSize(COutputStream& OutputStream) void CSectionMgrOut::AddSize(IOutputStream& OutputStream)
{ {
mSectionSizes[mCurSectionIndex] = OutputStream.Tell() - mCurSectionStart; mSectionSizes[mCurSectionIndex] = OutputStream.Tell() - mCurSectionStart;
mCurSectionIndex++; mCurSectionIndex++;
mCurSectionStart = OutputStream.Tell(); mCurSectionStart = OutputStream.Tell();
} }
void CSectionMgrOut::WriteSizes(COutputStream& OutputStream) void CSectionMgrOut::WriteSizes(IOutputStream& OutputStream)
{ {
for (u32 iSec = 0; iSec < mSectionCount; iSec++) for (u32 iSec = 0; iSec < mSectionCount; iSec++)
OutputStream.WriteLong(mSectionSizes[iSec]); OutputStream.WriteLong(mSectionSizes[iSec]);

View File

@ -2,7 +2,7 @@
#define CBLOCKMGROUT_H #define CBLOCKMGROUT_H
#include <Common/types.h> #include <Common/types.h>
#include <FileIO/COutputStream.h> #include <FileIO/IOutputStream.h>
#include <vector> #include <vector>
// Small class to manage file sections for CMDL/MREA output // Small class to manage file sections for CMDL/MREA output
@ -16,9 +16,9 @@ class CSectionMgrOut
public: public:
CSectionMgrOut(); CSectionMgrOut();
void SetSectionCount(u32 Count); void SetSectionCount(u32 Count);
void Init(const COutputStream& OutputStream); void Init(const IOutputStream& OutputStream);
void AddSize(COutputStream& OutputStream); void AddSize(IOutputStream& OutputStream);
void WriteSizes(COutputStream& OutputStream); void WriteSizes(IOutputStream& OutputStream);
}; };
#endif // CBLOCKMGROUT_H #endif // CBLOCKMGROUT_H

View File

@ -6,7 +6,7 @@ CTextureEncoder::CTextureEncoder()
mpTexture = nullptr; mpTexture = nullptr;
} }
void CTextureEncoder::WriteTXTR(COutputStream& TXTR) void CTextureEncoder::WriteTXTR(IOutputStream& TXTR)
{ {
// Only DXT1->CMPR supported at the moment // Only DXT1->CMPR supported at the moment
TXTR.WriteLong(mOutputFormat); TXTR.WriteLong(mOutputFormat);
@ -16,7 +16,7 @@ void CTextureEncoder::WriteTXTR(COutputStream& TXTR)
u32 MipW = mpTexture->Width() / 4; u32 MipW = mpTexture->Width() / 4;
u32 MipH = mpTexture->Height() / 4; u32 MipH = mpTexture->Height() / 4;
CMemoryInStream Image(mpTexture->mImgDataBuffer, mpTexture->mImgDataSize, IOUtil::LittleEndian); CMemoryInStream Image(mpTexture->mImgDataBuffer, mpTexture->mImgDataSize, IOUtil::eLittleEndian);
u32 MipOffset = Image.Tell(); u32 MipOffset = Image.Tell();
for (u32 iMip = 0; iMip < mpTexture->mNumMipMaps; iMip++) for (u32 iMip = 0; iMip < mpTexture->mNumMipMaps; iMip++)
@ -45,7 +45,7 @@ void CTextureEncoder::DetermineBestOutputFormat()
// todo // todo
} }
void CTextureEncoder::ReadSubBlockCMPR(CInputStream& Source, COutputStream& Dest) void CTextureEncoder::ReadSubBlockCMPR(IInputStream& Source, IOutputStream& Dest)
{ {
Dest.WriteShort(Source.ReadShort()); Dest.WriteShort(Source.ReadShort());
Dest.WriteShort(Source.ReadShort()); Dest.WriteShort(Source.ReadShort());
@ -58,7 +58,7 @@ void CTextureEncoder::ReadSubBlockCMPR(CInputStream& Source, COutputStream& Dest
} }
// ************ STATIC ************ // ************ STATIC ************
void CTextureEncoder::EncodeTXTR(COutputStream& TXTR, CTexture *pTex) void CTextureEncoder::EncodeTXTR(IOutputStream& TXTR, CTexture *pTex)
{ {
if (pTex->mTexelFormat != eDXT1) if (pTex->mTexelFormat != eDXT1)
{ {
@ -73,7 +73,7 @@ void CTextureEncoder::EncodeTXTR(COutputStream& TXTR, CTexture *pTex)
Encoder.WriteTXTR(TXTR); Encoder.WriteTXTR(TXTR);
} }
void CTextureEncoder::EncodeTXTR(COutputStream& TXTR, CTexture *pTex, ETexelFormat /*OutputFormat*/) void CTextureEncoder::EncodeTXTR(IOutputStream& TXTR, CTexture *pTex, ETexelFormat /*OutputFormat*/)
{ {
// todo: support for encoding a specific format // todo: support for encoding a specific format
EncodeTXTR(TXTR, pTex); EncodeTXTR(TXTR, pTex);

View File

@ -13,13 +13,13 @@ class CTextureEncoder
ETexelFormat mOutputFormat; ETexelFormat mOutputFormat;
CTextureEncoder(); CTextureEncoder();
void WriteTXTR(COutputStream& TXTR); void WriteTXTR(IOutputStream& TXTR);
void DetermineBestOutputFormat(); void DetermineBestOutputFormat();
void ReadSubBlockCMPR(CInputStream& Source, COutputStream& Dest); void ReadSubBlockCMPR(IInputStream& Source, IOutputStream& Dest);
public: public:
static void EncodeTXTR(COutputStream& TXTR, CTexture *pTex); static void EncodeTXTR(IOutputStream& TXTR, CTexture *pTex);
static void EncodeTXTR(COutputStream& TXTR, CTexture *pTex, ETexelFormat OutputFormat); static void EncodeTXTR(IOutputStream& TXTR, CTexture *pTex, ETexelFormat OutputFormat);
static ETexelFormat GetGXFormat(ETexelFormat Format); static ETexelFormat GetGXFormat(ETexelFormat Format);
static ETexelFormat GetFormat(ETexelFormat Format); static ETexelFormat GetFormat(ETexelFormat Format);
}; };

View File

@ -6,7 +6,7 @@ CAnimSetLoader::CAnimSetLoader()
{ {
} }
CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(CInputStream& CHAR) CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& CHAR)
{ {
// For now, we only read enough to fetch the model // For now, we only read enough to fetch the model
CHAR.Seek(0x1, SEEK_CUR); CHAR.Seek(0x1, SEEK_CUR);
@ -18,7 +18,7 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(CInputStream& CHAR)
return set; return set;
} }
CAnimSet* CAnimSetLoader::LoadReturnsCHAR(CInputStream& CHAR) CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& CHAR)
{ {
// For now, we only read enough to fetch the model // For now, we only read enough to fetch the model
CHAR.Seek(0x16, SEEK_CUR); CHAR.Seek(0x16, SEEK_CUR);
@ -32,7 +32,7 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(CInputStream& CHAR)
return set; return set;
} }
void CAnimSetLoader::LoadPASDatabase(CInputStream& PAS4) void CAnimSetLoader::LoadPASDatabase(IInputStream& PAS4)
{ {
// For now, just parse the data; don't store it // For now, just parse the data; don't store it
PAS4.Seek(0x4, SEEK_CUR); // Skipping PAS4 FourCC PAS4.Seek(0x4, SEEK_CUR); // Skipping PAS4 FourCC
@ -72,7 +72,7 @@ void CAnimSetLoader::LoadPASDatabase(CInputStream& PAS4)
} }
// ************ STATIC ************ // ************ STATIC ************
CAnimSet* CAnimSetLoader::LoadANCS(CInputStream& ANCS) CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& ANCS)
{ {
if (!ANCS.IsValid()) return nullptr; if (!ANCS.IsValid()) return nullptr;
Log::Write("Loading " + ANCS.GetSourceString()); Log::Write("Loading " + ANCS.GetSourceString());
@ -169,7 +169,7 @@ CAnimSet* CAnimSetLoader::LoadANCS(CInputStream& ANCS)
return loader.set; return loader.set;
} }
CAnimSet* CAnimSetLoader::LoadCHAR(CInputStream &CHAR) CAnimSet* CAnimSetLoader::LoadCHAR(IInputStream &CHAR)
{ {
if (!CHAR.IsValid()) return nullptr; if (!CHAR.IsValid()) return nullptr;
Log::Write("Loading " + CHAR.GetSourceString()); Log::Write("Loading " + CHAR.GetSourceString());

View File

@ -12,13 +12,13 @@ class CAnimSetLoader
EGame mVersion; EGame mVersion;
CAnimSetLoader(); CAnimSetLoader();
CAnimSet* LoadCorruptionCHAR(CInputStream& CHAR); CAnimSet* LoadCorruptionCHAR(IInputStream& CHAR);
CAnimSet* LoadReturnsCHAR(CInputStream& CHAR); CAnimSet* LoadReturnsCHAR(IInputStream& CHAR);
void LoadPASDatabase(CInputStream& PAS4); void LoadPASDatabase(IInputStream& PAS4);
public: public:
static CAnimSet* LoadANCS(CInputStream& ANCS); static CAnimSet* LoadANCS(IInputStream& ANCS);
static CAnimSet* LoadCHAR(CInputStream& CHAR); static CAnimSet* LoadCHAR(IInputStream& CHAR);
}; };
#endif // CCHARACTERLOADER_H #endif // CCHARACTERLOADER_H

View File

@ -478,7 +478,7 @@ void CAreaLoader::Decompress()
} }
TString Source = mpMREA->GetSourceString(); TString Source = mpMREA->GetSourceString();
mpMREA = new CMemoryInStream(mDecmpBuffer, mTotalDecmpSize, IOUtil::BigEndian); mpMREA = new CMemoryInStream(mDecmpBuffer, mTotalDecmpSize, IOUtil::eBigEndian);
mpMREA->SetSourceString(Source.ToStdString()); mpMREA->SetSourceString(Source.ToStdString());
mBlockMgr->SetInputStream(mpMREA); mBlockMgr->SetInputStream(mpMREA);
mHasDecompressedBuffer = true; mHasDecompressedBuffer = true;
@ -540,7 +540,7 @@ void CAreaLoader::SetUpObjects()
} }
// ************ STATIC ************ // ************ STATIC ************
CGameArea* CAreaLoader::LoadMREA(CInputStream& MREA) CGameArea* CAreaLoader::LoadMREA(IInputStream& MREA)
{ {
CAreaLoader Loader; CAreaLoader Loader;

View File

@ -15,7 +15,7 @@ class CAreaLoader
// Area data // Area data
TResPtr<CGameArea> mpArea; TResPtr<CGameArea> mpArea;
CInputStream *mpMREA; IInputStream *mpMREA;
CBlockMgrIn *mBlockMgr; CBlockMgrIn *mBlockMgr;
EGame mVersion; EGame mVersion;
u32 mNumMeshes; u32 mNumMeshes;
@ -78,7 +78,7 @@ class CAreaLoader
void SetUpObjects(); void SetUpObjects();
public: public:
static CGameArea* LoadMREA(CInputStream& MREA); static CGameArea* LoadMREA(IInputStream& MREA);
static EGame GetFormatVersion(u32 version); static EGame GetFormatVersion(u32 version);
}; };

View File

@ -1,6 +1,6 @@
#include "CBlockMgrIn.h" #include "CBlockMgrIn.h"
CBlockMgrIn::CBlockMgrIn(unsigned long count, CInputStream* src) CBlockMgrIn::CBlockMgrIn(unsigned long count, IInputStream* src)
{ {
mpInputStream = src; mpInputStream = src;
mBlockCount = count; mBlockCount = count;
@ -52,7 +52,7 @@ long CBlockMgrIn::CurrentBlockSize()
return mBlockSizes[mCurBlock]; return mBlockSizes[mCurBlock];
} }
void CBlockMgrIn::SetInputStream(CInputStream *in) void CBlockMgrIn::SetInputStream(IInputStream *in)
{ {
mpInputStream = in; mpInputStream = in;
} }

View File

@ -1,13 +1,13 @@
#ifndef CBLOCKMGRIN_H #ifndef CBLOCKMGRIN_H
#define CBLOCKMGRIN_H #define CBLOCKMGRIN_H
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
#include <vector> #include <vector>
// The purpose of this class is to keep track of data block navigation - required to read CMDL and MREA files correctly // The purpose of this class is to keep track of data block navigation - required to read CMDL and MREA files correctly
class CBlockMgrIn class CBlockMgrIn
{ {
CInputStream *mpInputStream; IInputStream *mpInputStream;
unsigned long mBlockCount; unsigned long mBlockCount;
std::vector<unsigned long> mBlockSizes; std::vector<unsigned long> mBlockSizes;
unsigned long mCurBlock; unsigned long mCurBlock;
@ -15,14 +15,14 @@ class CBlockMgrIn
unsigned long mBlocksStart; unsigned long mBlocksStart;
public: public:
CBlockMgrIn(unsigned long count, CInputStream* src); CBlockMgrIn(unsigned long count, IInputStream* src);
void Init(); void Init();
void ToBlock(unsigned long block); void ToBlock(unsigned long block);
void ToNextBlock(); void ToNextBlock();
long NextOffset(); long NextOffset();
long CurrentBlock(); long CurrentBlock();
long CurrentBlockSize(); long CurrentBlockSize();
void SetInputStream(CInputStream *in); void SetInputStream(IInputStream *in);
}; };
#endif // CBLOCKMGRIN_H #endif // CBLOCKMGRIN_H

View File

@ -6,25 +6,22 @@ CCollisionLoader::CCollisionLoader()
{ {
} }
CCollisionMesh::CCollisionOctree* CCollisionLoader::ParseOctree(CInputStream&) CCollisionMesh::CCollisionOctree* CCollisionLoader::ParseOctree(IInputStream& /*src*/)
{ {
// Not using: Parameter 1 (CInputStream& - src)
return nullptr; return nullptr;
} }
CCollisionMesh::CCollisionOctree::SBranch* CCollisionLoader::ParseOctreeBranch(CInputStream&) CCollisionMesh::CCollisionOctree::SBranch* CCollisionLoader::ParseOctreeBranch(IInputStream& /*src*/)
{ {
// Not using: Parameter 1 (CInputStream& - src)
return nullptr; return nullptr;
} }
CCollisionMesh::CCollisionOctree::SLeaf* CCollisionLoader::ParseOctreeLeaf(CInputStream&) CCollisionMesh::CCollisionOctree::SLeaf* CCollisionLoader::ParseOctreeLeaf(IInputStream& /*src*/)
{ {
// Not using: Parameter 1 (CInputStream& - src)
return nullptr; return nullptr;
} }
void CCollisionLoader::ParseOBBNode(CInputStream& DCLN) void CCollisionLoader::ParseOBBNode(IInputStream& DCLN)
{ {
bool b = false; bool b = false;
@ -39,7 +36,7 @@ void CCollisionLoader::ParseOBBNode(CInputStream& DCLN)
DCLN.Seek(numFaces * 2, SEEK_CUR); DCLN.Seek(numFaces * 2, SEEK_CUR);
} }
void CCollisionLoader::ReadPropertyFlags(CInputStream& src) void CCollisionLoader::ReadPropertyFlags(IInputStream& src)
{ {
CCollisionMesh::SCollisionProperties property; CCollisionMesh::SCollisionProperties property;
@ -64,7 +61,7 @@ void CCollisionLoader::ReadPropertyFlags(CInputStream& src)
mProperties.push_back(property); mProperties.push_back(property);
} }
void CCollisionLoader::LoadCollisionIndices(CInputStream &file, bool buildAABox) void CCollisionLoader::LoadCollisionIndices(IInputStream &file, bool buildAABox)
{ {
// Properties // Properties
u32 propSetCount = file.ReadLong(); u32 propSetCount = file.ReadLong();
@ -131,7 +128,7 @@ void CCollisionLoader::LoadCollisionIndices(CInputStream &file, bool buildAABox)
} }
// ************ STATIC ************ // ************ STATIC ************
CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(CInputStream& MREA) CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(IInputStream& MREA)
{ {
if (!MREA.IsValid()) return nullptr; if (!MREA.IsValid()) return nullptr;
CCollisionLoader loader; CCollisionLoader loader;
@ -162,7 +159,7 @@ CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(CInputStream& MREA)
return loader.mpGroup; return loader.mpGroup;
} }
CCollisionMeshGroup* CCollisionLoader::LoadDCLN(CInputStream &DCLN) CCollisionMeshGroup* CCollisionLoader::LoadDCLN(IInputStream &DCLN)
{ {
if (!DCLN.IsValid()) return nullptr; if (!DCLN.IsValid()) return nullptr;

View File

@ -13,16 +13,16 @@ class CCollisionLoader
std::vector<CCollisionMesh::SCollisionProperties> mProperties; std::vector<CCollisionMesh::SCollisionProperties> mProperties;
CCollisionLoader(); CCollisionLoader();
CCollisionMesh::CCollisionOctree* ParseOctree(CInputStream& src); CCollisionMesh::CCollisionOctree* ParseOctree(IInputStream& src);
CCollisionMesh::CCollisionOctree::SBranch* ParseOctreeBranch(CInputStream& src); CCollisionMesh::CCollisionOctree::SBranch* ParseOctreeBranch(IInputStream& src);
CCollisionMesh::CCollisionOctree::SLeaf* ParseOctreeLeaf(CInputStream& src); CCollisionMesh::CCollisionOctree::SLeaf* ParseOctreeLeaf(IInputStream& src);
void ParseOBBNode(CInputStream& DCLN); void ParseOBBNode(IInputStream& DCLN);
void ReadPropertyFlags(CInputStream& src); void ReadPropertyFlags(IInputStream& src);
void LoadCollisionIndices(CInputStream& file, bool buildAABox); void LoadCollisionIndices(IInputStream& file, bool buildAABox);
public: public:
static CCollisionMeshGroup* LoadAreaCollision(CInputStream& MREA); static CCollisionMeshGroup* LoadAreaCollision(IInputStream& MREA);
static CCollisionMeshGroup* LoadDCLN(CInputStream& DCLN); static CCollisionMeshGroup* LoadDCLN(IInputStream& DCLN);
static EGame GetFormatVersion(u32 version); static EGame GetFormatVersion(u32 version);
}; };

View File

@ -6,7 +6,7 @@ CFontLoader::CFontLoader()
{ {
} }
CFont* CFontLoader::LoadFont(CInputStream& FONT) CFont* CFontLoader::LoadFont(IInputStream& FONT)
{ {
// If I seek past a value without reading it, then it's because I don't know what it is // If I seek past a value without reading it, then it's because I don't know what it is
mpFont->mUnknown = FONT.ReadLong(); mpFont->mUnknown = FONT.ReadLong();
@ -79,7 +79,7 @@ CFont* CFontLoader::LoadFont(CInputStream& FONT)
return mpFont; return mpFont;
} }
CFont* CFontLoader::LoadFONT(CInputStream& FONT) CFont* CFontLoader::LoadFONT(IInputStream& FONT)
{ {
if (!FONT.IsValid()) return nullptr; if (!FONT.IsValid()) return nullptr;
Log::Write("Loading " + FONT.GetSourceString()); Log::Write("Loading " + FONT.GetSourceString());

View File

@ -11,10 +11,10 @@ class CFontLoader
EGame mVersion; EGame mVersion;
CFontLoader(); CFontLoader();
CFont* LoadFont(CInputStream& FONT); CFont* LoadFont(IInputStream& FONT);
public: public:
static CFont* LoadFONT(CInputStream& FONT); static CFont* LoadFONT(IInputStream& FONT);
static EGame GetFormatVersion(u32 Version); static EGame GetFormatVersion(u32 Version);
}; };

View File

@ -591,7 +591,7 @@ CMaterial* CMaterialLoader::LoadAssimpMaterial(const aiMaterial *pAiMat)
} }
// ************ STATIC ************ // ************ STATIC ************
CMaterialSet* CMaterialLoader::LoadMaterialSet(CInputStream& Mat, EGame Version) CMaterialSet* CMaterialLoader::LoadMaterialSet(IInputStream& Mat, EGame Version)
{ {
CMaterialLoader Loader; CMaterialLoader Loader;
Loader.mpSet = new CMaterialSet(); Loader.mpSet = new CMaterialSet();

View File

@ -12,7 +12,7 @@ class CMaterialLoader
{ {
// Material data // Material data
CMaterialSet *mpSet; CMaterialSet *mpSet;
CInputStream *mpFile; IInputStream *mpFile;
EGame mVersion; EGame mVersion;
std::vector<TResPtr<CTexture>> mTextures; std::vector<TResPtr<CTexture>> mTextures;
bool mHasOPAC; bool mHasOPAC;
@ -38,7 +38,7 @@ class CMaterialLoader
// Static // Static
public: public:
static CMaterialSet* LoadMaterialSet(CInputStream& Mat, EGame Version); static CMaterialSet* LoadMaterialSet(IInputStream& Mat, EGame Version);
static CMaterialSet* ImportAssimpMaterials(const aiScene *pScene, EGame targetVersion); static CMaterialSet* ImportAssimpMaterials(const aiScene *pScene, EGame targetVersion);
}; };

View File

@ -12,7 +12,7 @@ CModelLoader::~CModelLoader()
{ {
} }
void CModelLoader::LoadWorldMeshHeader(CInputStream &Model) void CModelLoader::LoadWorldMeshHeader(IInputStream &Model)
{ {
// I don't really have any need for most of this data, so // I don't really have any need for most of this data, so
Model.Seek(0x34, SEEK_CUR); Model.Seek(0x34, SEEK_CUR);
@ -20,7 +20,7 @@ void CModelLoader::LoadWorldMeshHeader(CInputStream &Model)
mpBlockMgr->ToNextBlock(); mpBlockMgr->ToNextBlock();
} }
void CModelLoader::LoadAttribArrays(CInputStream& Model) void CModelLoader::LoadAttribArrays(IInputStream& Model)
{ {
// Positions // Positions
if (mFlags & eShortPositions) // Shorts (DKCR only) if (mFlags & eShortPositions) // Shorts (DKCR only)
@ -105,7 +105,7 @@ void CModelLoader::LoadAttribArrays(CInputStream& Model)
} }
} }
void CModelLoader::LoadSurfaceOffsets(CInputStream& Model) void CModelLoader::LoadSurfaceOffsets(IInputStream& Model)
{ {
mSurfaceCount = Model.ReadLong(); mSurfaceCount = Model.ReadLong();
mSurfaceOffsets.resize(mSurfaceCount); mSurfaceOffsets.resize(mSurfaceCount);
@ -116,7 +116,7 @@ void CModelLoader::LoadSurfaceOffsets(CInputStream& Model)
mpBlockMgr->ToNextBlock(); mpBlockMgr->ToNextBlock();
} }
SSurface* CModelLoader::LoadSurface(CInputStream& Model) SSurface* CModelLoader::LoadSurface(IInputStream& Model)
{ {
SSurface *pSurf = new SSurface; SSurface *pSurf = new SSurface;
@ -228,7 +228,7 @@ SSurface* CModelLoader::LoadSurface(CInputStream& Model)
return pSurf; return pSurf;
} }
void CModelLoader::LoadSurfaceHeaderPrime(CInputStream& Model, SSurface *pSurf) void CModelLoader::LoadSurfaceHeaderPrime(IInputStream& Model, SSurface *pSurf)
{ {
pSurf->CenterPoint = CVector3f(Model); pSurf->CenterPoint = CVector3f(Model);
pSurf->MaterialID = Model.ReadLong(); pSurf->MaterialID = Model.ReadLong();
@ -252,7 +252,7 @@ void CModelLoader::LoadSurfaceHeaderPrime(CInputStream& Model, SSurface *pSurf)
Model.SeekToBoundary(32); Model.SeekToBoundary(32);
} }
void CModelLoader::LoadSurfaceHeaderDKCR(CInputStream& Model, SSurface *pSurf) void CModelLoader::LoadSurfaceHeaderDKCR(IInputStream& Model, SSurface *pSurf)
{ {
pSurf->CenterPoint = CVector3f(Model); pSurf->CenterPoint = CVector3f(Model);
Model.Seek(0xE, SEEK_CUR); Model.Seek(0xE, SEEK_CUR);
@ -375,7 +375,7 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pMesh, CMaterialSet *pSet)
} }
// ************ STATIC ************ // ************ STATIC ************
CModel* CModelLoader::LoadCMDL(CInputStream& CMDL) CModel* CModelLoader::LoadCMDL(IInputStream& CMDL)
{ {
CModelLoader Loader; CModelLoader Loader;
Log::Write("Loading " + CMDL.GetSourceString()); Log::Write("Loading " + CMDL.GetSourceString());
@ -486,7 +486,7 @@ CModel* CModelLoader::LoadCMDL(CInputStream& CMDL)
return pModel; return pModel;
} }
CModel* CModelLoader::LoadWorldModel(CInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, EGame Version) CModel* CModelLoader::LoadWorldModel(IInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, EGame Version)
{ {
CModelLoader Loader; CModelLoader Loader;
Loader.mpBlockMgr = &BlockMgr; Loader.mpBlockMgr = &BlockMgr;
@ -519,7 +519,7 @@ CModel* CModelLoader::LoadWorldModel(CInputStream& MREA, CBlockMgrIn& BlockMgr,
return pModel; return pModel;
} }
CModel* CModelLoader::LoadCorruptionWorldModel(CInputStream &MREA, CBlockMgrIn &BlockMgr, CMaterialSet &MatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version) CModel* CModelLoader::LoadCorruptionWorldModel(IInputStream &MREA, CBlockMgrIn &BlockMgr, CMaterialSet &MatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version)
{ {
CModelLoader Loader; CModelLoader Loader;
Loader.mpBlockMgr = &BlockMgr; Loader.mpBlockMgr = &BlockMgr;

View File

@ -45,19 +45,19 @@ private:
CModelLoader(); CModelLoader();
~CModelLoader(); ~CModelLoader();
void LoadWorldMeshHeader(CInputStream& Model); void LoadWorldMeshHeader(IInputStream& Model);
void LoadAttribArrays(CInputStream& Model); void LoadAttribArrays(IInputStream& Model);
void LoadAttribArraysDKCR(CInputStream& Model); void LoadAttribArraysDKCR(IInputStream& Model);
void LoadSurfaceOffsets(CInputStream& Model); void LoadSurfaceOffsets(IInputStream& Model);
SSurface* LoadSurface(CInputStream& Model); SSurface* LoadSurface(IInputStream& Model);
void LoadSurfaceHeaderPrime(CInputStream& Model, SSurface *pSurf); void LoadSurfaceHeaderPrime(IInputStream& Model, SSurface *pSurf);
void LoadSurfaceHeaderDKCR(CInputStream& Model, SSurface *pSurf); void LoadSurfaceHeaderDKCR(IInputStream& Model, SSurface *pSurf);
SSurface* LoadAssimpMesh(const aiMesh *pMesh, CMaterialSet *pSet); SSurface* LoadAssimpMesh(const aiMesh *pMesh, CMaterialSet *pSet);
public: public:
static CModel* LoadCMDL(CInputStream& CMDL); static CModel* LoadCMDL(IInputStream& CMDL);
static CModel* LoadWorldModel(CInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, EGame Version); static CModel* LoadWorldModel(IInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, EGame Version);
static CModel* LoadCorruptionWorldModel(CInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version); static CModel* LoadCorruptionWorldModel(IInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version);
static CModel* ImportAssimpNode(const aiNode *pNode, const aiScene *pScene, CMaterialSet& matSet); static CModel* ImportAssimpNode(const aiNode *pNode, const aiScene *pScene, CMaterialSet& matSet);
static EGame GetFormatVersion(u32 Version); static EGame GetFormatVersion(u32 Version);
}; };

View File

@ -6,7 +6,7 @@ CScanLoader::CScanLoader()
{ {
} }
CScan* CScanLoader::LoadScanMP1(CInputStream &SCAN) CScan* CScanLoader::LoadScanMP1(IInputStream &SCAN)
{ {
// Basic support at the moment - don't read animation/scan image data // Basic support at the moment - don't read animation/scan image data
SCAN.Seek(0x4, SEEK_CUR); // Skip FRME ID SCAN.Seek(0x4, SEEK_CUR); // Skip FRME ID
@ -18,7 +18,7 @@ CScan* CScanLoader::LoadScanMP1(CInputStream &SCAN)
return mpScan; return mpScan;
} }
CScan* CScanLoader::LoadScanMP2(CInputStream& SCAN) CScan* CScanLoader::LoadScanMP2(IInputStream& SCAN)
{ {
// The SCAN format in MP2 embeds a SNFO object using the same format as SCLY // The SCAN format in MP2 embeds a SNFO object using the same format as SCLY
// However since the contents of the file are consistent there's no need to delegate to CScriptLoader // However since the contents of the file are consistent there's no need to delegate to CScriptLoader
@ -72,7 +72,7 @@ CScan* CScanLoader::LoadScanMP2(CInputStream& SCAN)
return mpScan; return mpScan;
} }
void CScanLoader::LoadParamsMP2(CInputStream& SCAN) void CScanLoader::LoadParamsMP2(IInputStream& SCAN)
{ {
// Function begins after the SNFO property count // Function begins after the SNFO property count
for (u32 iProp = 0; iProp < 20; iProp++) for (u32 iProp = 0; iProp < 20; iProp++)
@ -103,7 +103,7 @@ void CScanLoader::LoadParamsMP2(CInputStream& SCAN)
mpScan->mVersion = eEchoes; mpScan->mVersion = eEchoes;
} }
void CScanLoader::LoadParamsMP3(CInputStream& SCAN) void CScanLoader::LoadParamsMP3(IInputStream& SCAN)
{ {
// Function begins after the SNFO property count // Function begins after the SNFO property count
// Function is near-identical to the MP2 one, but when I add support // Function is near-identical to the MP2 one, but when I add support
@ -137,7 +137,7 @@ void CScanLoader::LoadParamsMP3(CInputStream& SCAN)
} }
// ************ STATIC/PUBLIC ************ // ************ STATIC/PUBLIC ************
CScan* CScanLoader::LoadSCAN(CInputStream &SCAN) CScan* CScanLoader::LoadSCAN(IInputStream &SCAN)
{ {
if (!SCAN.IsValid()) return nullptr; if (!SCAN.IsValid()) return nullptr;
Log::Write("Loading " + SCAN.GetSourceString()); Log::Write("Loading " + SCAN.GetSourceString());

View File

@ -10,13 +10,13 @@ class CScanLoader
EGame mVersion; EGame mVersion;
CScanLoader(); CScanLoader();
CScan* LoadScanMP1(CInputStream& SCAN); CScan* LoadScanMP1(IInputStream& SCAN);
CScan* LoadScanMP2(CInputStream& SCAN); CScan* LoadScanMP2(IInputStream& SCAN);
void LoadParamsMP2(CInputStream& SCAN); void LoadParamsMP2(IInputStream& SCAN);
void LoadParamsMP3(CInputStream& SCAN); void LoadParamsMP3(IInputStream& SCAN);
public: public:
static CScan* LoadSCAN(CInputStream& SCAN); static CScan* LoadSCAN(IInputStream& SCAN);
}; };
#endif // CSCANLOADER_H #endif // CSCANLOADER_H

View File

@ -10,7 +10,7 @@ CScriptLoader::CScriptLoader()
mpObj = nullptr; mpObj = nullptr;
} }
CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplate *pTemp) CPropertyStruct* CScriptLoader::LoadStructMP1(IInputStream& SCLY, CStructTemplate *pTemp)
{ {
u32 structStart = SCLY.Tell(); u32 structStart = SCLY.Tell();
CPropertyStruct *propStruct = new CPropertyStruct(); CPropertyStruct *propStruct = new CPropertyStruct();
@ -143,7 +143,7 @@ CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplat
return propStruct; return propStruct;
} }
CScriptObject* CScriptLoader::LoadObjectMP1(CInputStream& SCLY) CScriptObject* CScriptLoader::LoadObjectMP1(IInputStream& SCLY)
{ {
u32 objStart = SCLY.Tell(); u32 objStart = SCLY.Tell();
u8 type = SCLY.ReadByte(); u8 type = SCLY.ReadByte();
@ -192,7 +192,7 @@ CScriptObject* CScriptLoader::LoadObjectMP1(CInputStream& SCLY)
return mpObj; return mpObj;
} }
CScriptLayer* CScriptLoader::LoadLayerMP1(CInputStream &SCLY) CScriptLayer* CScriptLoader::LoadLayerMP1(IInputStream &SCLY)
{ {
u32 LayerStart = SCLY.Tell(); u32 LayerStart = SCLY.Tell();
@ -215,7 +215,7 @@ CScriptLayer* CScriptLoader::LoadLayerMP1(CInputStream &SCLY)
return mpLayer; return mpLayer;
} }
void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct, CStructTemplate *pTemp) void CScriptLoader::LoadStructMP2(IInputStream& SCLY, CPropertyStruct *pStruct, CStructTemplate *pTemp)
{ {
// Verify property count // Verify property count
u32 propCount = pTemp->Count(); u32 propCount = pTemp->Count();
@ -417,7 +417,7 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
} }
} }
CScriptObject* CScriptLoader::LoadObjectMP2(CInputStream& SCLY) CScriptObject* CScriptLoader::LoadObjectMP2(IInputStream& SCLY)
{ {
u32 ObjStart = SCLY.Tell(); u32 ObjStart = SCLY.Tell();
u32 ObjectID = SCLY.ReadLong(); u32 ObjectID = SCLY.ReadLong();
@ -464,7 +464,7 @@ CScriptObject* CScriptLoader::LoadObjectMP2(CInputStream& SCLY)
return mpObj; return mpObj;
} }
CScriptLayer* CScriptLoader::LoadLayerMP2(CInputStream& SCLY) CScriptLayer* CScriptLoader::LoadLayerMP2(IInputStream& SCLY)
{ {
CFourCC SCLY_Magic(SCLY); CFourCC SCLY_Magic(SCLY);
@ -496,7 +496,7 @@ CScriptLayer* CScriptLoader::LoadLayerMP2(CInputStream& SCLY)
return mpLayer; return mpLayer;
} }
CScriptLayer* CScriptLoader::LoadLayer(CInputStream &SCLY, CGameArea *pArea, EGame version) CScriptLayer* CScriptLoader::LoadLayer(IInputStream &SCLY, CGameArea *pArea, EGame version)
{ {
if (!SCLY.IsValid()) return nullptr; if (!SCLY.IsValid()) return nullptr;

View File

@ -17,18 +17,18 @@ class CScriptLoader
CScriptLoader(); CScriptLoader();
CPropertyStruct* LoadStructMP1(CInputStream& SCLY, CStructTemplate *tmp); CPropertyStruct* LoadStructMP1(IInputStream& SCLY, CStructTemplate *tmp);
CScriptObject* LoadObjectMP1(CInputStream& SCLY); CScriptObject* LoadObjectMP1(IInputStream& SCLY);
CScriptLayer* LoadLayerMP1(CInputStream& SCLY); CScriptLayer* LoadLayerMP1(IInputStream& SCLY);
void LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct, CStructTemplate *pTemp); void LoadStructMP2(IInputStream& SCLY, CPropertyStruct *pStruct, CStructTemplate *pTemp);
CScriptObject* LoadObjectMP2(CInputStream& SCLY); CScriptObject* LoadObjectMP2(IInputStream& SCLY);
CScriptLayer* LoadLayerMP2(CInputStream& SCLY); CScriptLayer* LoadLayerMP2(IInputStream& SCLY);
void SetupAttribs(); void SetupAttribs();
public: public:
static CScriptLayer* LoadLayer(CInputStream& SCLY, CGameArea *pArea, EGame version); static CScriptLayer* LoadLayer(IInputStream& SCLY, CGameArea *pArea, EGame version);
}; };
#endif // CSCRIPTLOADER_H #endif // CSCRIPTLOADER_H

View File

@ -5,7 +5,7 @@ CStringLoader::CStringLoader()
{ {
} }
void CStringLoader::LoadPrimeDemoSTRG(CInputStream& STRG) void CStringLoader::LoadPrimeDemoSTRG(IInputStream& STRG)
{ {
// This function starts at 0x4 in the file - right after the size // This function starts at 0x4 in the file - right after the size
// This STRG version only supports one language per file // This STRG version only supports one language per file
@ -32,7 +32,7 @@ void CStringLoader::LoadPrimeDemoSTRG(CInputStream& STRG)
} }
} }
void CStringLoader::LoadPrimeSTRG(CInputStream& STRG) void CStringLoader::LoadPrimeSTRG(IInputStream& STRG)
{ {
// This function starts at 0x8 in the file, after magic/version // This function starts at 0x8 in the file, after magic/version
// Header // Header
@ -80,7 +80,7 @@ void CStringLoader::LoadPrimeSTRG(CInputStream& STRG)
} }
} }
void CStringLoader::LoadCorruptionSTRG(CInputStream& STRG) void CStringLoader::LoadCorruptionSTRG(IInputStream& STRG)
{ {
// This function starts at 0x8 in the file, after magic/version // This function starts at 0x8 in the file, after magic/version
// Header // Header
@ -126,7 +126,7 @@ void CStringLoader::LoadCorruptionSTRG(CInputStream& STRG)
} }
} }
void CStringLoader::LoadNameTable(CInputStream& STRG) void CStringLoader::LoadNameTable(IInputStream& STRG)
{ {
// Name table header // Name table header
u32 NameCount = STRG.ReadLong(); u32 NameCount = STRG.ReadLong();
@ -158,7 +158,7 @@ void CStringLoader::LoadNameTable(CInputStream& STRG)
} }
// ************ STATIC ************ // ************ STATIC ************
CStringTable* CStringLoader::LoadSTRG(CInputStream& STRG) CStringTable* CStringLoader::LoadSTRG(IInputStream& STRG)
{ {
// Verify that this is a valid STRG // Verify that this is a valid STRG
if (!STRG.IsValid()) return nullptr; if (!STRG.IsValid()) return nullptr;

View File

@ -12,13 +12,13 @@ class CStringLoader
EGame mVersion; EGame mVersion;
CStringLoader(); CStringLoader();
void LoadPrimeDemoSTRG(CInputStream& STRG); void LoadPrimeDemoSTRG(IInputStream& STRG);
void LoadPrimeSTRG(CInputStream& STRG); void LoadPrimeSTRG(IInputStream& STRG);
void LoadCorruptionSTRG(CInputStream& STRG); void LoadCorruptionSTRG(IInputStream& STRG);
void LoadNameTable(CInputStream& STRG); void LoadNameTable(IInputStream& STRG);
public: public:
static CStringTable* LoadSTRG(CInputStream& STRG); static CStringTable* LoadSTRG(IInputStream& STRG);
static EGame GetFormatVersion(u32 Version); static EGame GetFormatVersion(u32 Version);
}; };

View File

@ -90,7 +90,7 @@ CTexture* CTextureDecoder::CreateTexture()
} }
// ************ STATIC ************ // ************ STATIC ************
CTexture* CTextureDecoder::LoadTXTR(CInputStream& TXTR) CTexture* CTextureDecoder::LoadTXTR(IInputStream& TXTR)
{ {
CTextureDecoder Decoder; CTextureDecoder Decoder;
Decoder.ReadTXTR(TXTR); Decoder.ReadTXTR(TXTR);
@ -98,7 +98,7 @@ CTexture* CTextureDecoder::LoadTXTR(CInputStream& TXTR)
return Decoder.CreateTexture(); return Decoder.CreateTexture();
} }
CTexture* CTextureDecoder::DoFullDecode(CInputStream &TXTR) CTexture* CTextureDecoder::DoFullDecode(IInputStream &TXTR)
{ {
CTextureDecoder Decoder; CTextureDecoder Decoder;
Decoder.ReadTXTR(TXTR); Decoder.ReadTXTR(TXTR);
@ -109,7 +109,7 @@ CTexture* CTextureDecoder::DoFullDecode(CInputStream &TXTR)
return pTexture; return pTexture;
} }
CTexture* CTextureDecoder::LoadDDS(CInputStream &DDS) CTexture* CTextureDecoder::LoadDDS(IInputStream &DDS)
{ {
CTextureDecoder Decoder; CTextureDecoder Decoder;
Decoder.ReadDDS(DDS); Decoder.ReadDDS(DDS);
@ -124,7 +124,7 @@ CTexture* CTextureDecoder::DoFullDecode(CTexture*)
} }
// ************ READ ************ // ************ READ ************
void CTextureDecoder::ReadTXTR(CInputStream& TXTR) void CTextureDecoder::ReadTXTR(IInputStream& TXTR)
{ {
// Read TXTR header // Read TXTR header
Log::Write("Loading " + TXTR.GetSourceString()); Log::Write("Loading " + TXTR.GetSourceString());
@ -144,12 +144,12 @@ void CTextureDecoder::ReadTXTR(CInputStream& TXTR)
mPalettes.resize(PaletteEntryCount * 2); mPalettes.resize(PaletteEntryCount * 2);
TXTR.ReadBytes(mPalettes.data(), mPalettes.size()); TXTR.ReadBytes(mPalettes.data(), mPalettes.size());
mPaletteInput.SetData(mPalettes.data(), mPalettes.size(), IOUtil::BigEndian); mPaletteInput.SetData(mPalettes.data(), mPalettes.size(), IOUtil::eBigEndian);
} }
else mHasPalettes = false; else mHasPalettes = false;
} }
void CTextureDecoder::ReadDDS(CInputStream& DDS) void CTextureDecoder::ReadDDS(IInputStream& DDS)
{ {
Log::Write("Loading " + DDS.GetSourceString()); Log::Write("Loading " + DDS.GetSourceString());
@ -202,7 +202,7 @@ void CTextureDecoder::ReadDDS(CInputStream& DDS)
} }
// ************ DECODE ************ // ************ DECODE ************
void CTextureDecoder::PartialDecodeGXTexture(CInputStream& TXTR) void CTextureDecoder::PartialDecodeGXTexture(IInputStream& TXTR)
{ {
// Get image data size, create output buffer // Get image data size, create output buffer
u32 ImageStart = TXTR.Tell(); u32 ImageStart = TXTR.Tell();
@ -214,7 +214,7 @@ void CTextureDecoder::PartialDecodeGXTexture(CInputStream& TXTR)
if ((mHasPalettes) && (mPaletteFormat == ePalette_RGB5A3)) mDataBufferSize *= 2; if ((mHasPalettes) && (mPaletteFormat == ePalette_RGB5A3)) mDataBufferSize *= 2;
mpDataBuffer = new u8[mDataBufferSize]; mpDataBuffer = new u8[mDataBufferSize];
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::SystemEndianness); CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
// Initializing more stuff before we start the mipmap loop // Initializing more stuff before we start the mipmap loop
u32 MipW = mWidth, MipH = mHeight; u32 MipW = mWidth, MipH = mHeight;
@ -275,7 +275,7 @@ void CTextureDecoder::PartialDecodeGXTexture(CInputStream& TXTR)
} }
} }
void CTextureDecoder::FullDecodeGXTexture(CInputStream& TXTR) void CTextureDecoder::FullDecodeGXTexture(IInputStream& TXTR)
{ {
// Get image data size, create output buffer // Get image data size, create output buffer
u32 ImageStart = TXTR.Tell(); u32 ImageStart = TXTR.Tell();
@ -286,7 +286,7 @@ void CTextureDecoder::FullDecodeGXTexture(CInputStream& TXTR)
mDataBufferSize = ImageSize * (32 / gskSourceBpp[mTexelFormat]); mDataBufferSize = ImageSize * (32 / gskSourceBpp[mTexelFormat]);
mpDataBuffer = new u8[mDataBufferSize]; mpDataBuffer = new u8[mDataBufferSize];
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::SystemEndianness); CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
// Initializing more stuff before we start the mipmap loop // Initializing more stuff before we start the mipmap loop
u32 MipW = mWidth, MipH = mHeight; u32 MipW = mWidth, MipH = mHeight;
@ -359,7 +359,7 @@ void CTextureDecoder::FullDecodeGXTexture(CInputStream& TXTR)
} }
} }
void CTextureDecoder::DecodeDDS(CInputStream &DDS) void CTextureDecoder::DecodeDDS(IInputStream &DDS)
{ {
// Get image data size, create output buffer // Get image data size, create output buffer
u32 ImageStart = DDS.Tell(); u32 ImageStart = DDS.Tell();
@ -373,7 +373,7 @@ void CTextureDecoder::DecodeDDS(CInputStream &DDS)
else mDataBufferSize *= 4; else mDataBufferSize *= 4;
mpDataBuffer = new u8[mDataBufferSize]; mpDataBuffer = new u8[mDataBufferSize];
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::SystemEndianness); CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
// Initializing more stuff before we start the mipmap loop // Initializing more stuff before we start the mipmap loop
u32 MipW = mWidth, MipH = mHeight; u32 MipW = mWidth, MipH = mHeight;
@ -470,7 +470,7 @@ void CTextureDecoder::DecodeDDS(CInputStream &DDS)
} }
// ************ READ PIXELS (PARTIAL DECODE) ************ // ************ READ PIXELS (PARTIAL DECODE) ************
void CTextureDecoder::ReadPixelsI4(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadPixelsI4(IInputStream& src, IOutputStream& dst)
{ {
u8 px = src.ReadByte(); u8 px = src.ReadByte();
dst.WriteByte(Extend4to8(px >> 4)); dst.WriteByte(Extend4to8(px >> 4));
@ -479,14 +479,14 @@ void CTextureDecoder::ReadPixelsI4(CInputStream& src, COutputStream& dst)
dst.WriteByte(Extend4to8(px)); dst.WriteByte(Extend4to8(px));
} }
void CTextureDecoder::ReadPixelI8(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadPixelI8(IInputStream& src, IOutputStream& dst)
{ {
u8 px = src.ReadByte(); u8 px = src.ReadByte();
dst.WriteByte(px); dst.WriteByte(px);
dst.WriteByte(px); dst.WriteByte(px);
} }
void CTextureDecoder::ReadPixelIA4(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadPixelIA4(IInputStream& src, IOutputStream& dst)
{ {
// this can be left as-is for DDS conversion, but opengl doesn't support two components in one byte... // this can be left as-is for DDS conversion, but opengl doesn't support two components in one byte...
u8 byte = src.ReadByte(); u8 byte = src.ReadByte();
@ -495,12 +495,12 @@ void CTextureDecoder::ReadPixelIA4(CInputStream& src, COutputStream& dst)
dst.WriteShort((l << 8) | a); dst.WriteShort((l << 8) | a);
} }
void CTextureDecoder::ReadPixelIA8(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadPixelIA8(IInputStream& src, IOutputStream& dst)
{ {
dst.WriteShort(src.ReadShort()); dst.WriteShort(src.ReadShort());
} }
void CTextureDecoder::ReadPixelsC4(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadPixelsC4(IInputStream& src, IOutputStream& dst)
{ {
// This isn't how C4 works, but due to the way Retro packed font textures (which use C4) // This isn't how C4 works, but due to the way Retro packed font textures (which use C4)
// this is the only way to get them to decode correctly for now. // this is the only way to get them to decode correctly for now.
@ -529,7 +529,7 @@ void CTextureDecoder::ReadPixelsC4(CInputStream& src, COutputStream& dst)
} }
} }
void CTextureDecoder::ReadPixelC8(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadPixelC8(IInputStream& src, IOutputStream& dst)
{ {
// DKCR fonts use C8 :| // DKCR fonts use C8 :|
u8 index = src.ReadByte(); u8 index = src.ReadByte();
@ -549,13 +549,13 @@ void CTextureDecoder::ReadPixelC8(CInputStream& src, COutputStream& dst)
else if (mPaletteFormat == ePalette_RGB5A3) ReadPixelRGB5A3(mPaletteInput, dst); else if (mPaletteFormat == ePalette_RGB5A3) ReadPixelRGB5A3(mPaletteInput, dst);
} }
void CTextureDecoder::ReadPixelRGB565(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadPixelRGB565(IInputStream& src, IOutputStream& dst)
{ {
// RGB565 can be used as-is. // RGB565 can be used as-is.
dst.WriteShort(src.ReadShort()); dst.WriteShort(src.ReadShort());
} }
void CTextureDecoder::ReadPixelRGB5A3(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadPixelRGB5A3(IInputStream& src, IOutputStream& dst)
{ {
u16 px = src.ReadShort(); u16 px = src.ReadShort();
u8 r, g, b, a; u8 r, g, b, a;
@ -580,7 +580,7 @@ void CTextureDecoder::ReadPixelRGB5A3(CInputStream& src, COutputStream& dst)
dst.WriteLong(c); dst.WriteLong(c);
} }
void CTextureDecoder::ReadPixelRGBA8(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadPixelRGBA8(IInputStream& src, IOutputStream& dst)
{ {
u16 ar = src.ReadShort(); u16 ar = src.ReadShort();
src.Seek(0x1E, SEEK_CUR); src.Seek(0x1E, SEEK_CUR);
@ -590,7 +590,7 @@ void CTextureDecoder::ReadPixelRGBA8(CInputStream& src, COutputStream& dst)
dst.WriteLong(px); dst.WriteLong(px);
} }
void CTextureDecoder::ReadSubBlockCMPR(CInputStream& src, COutputStream& dst) void CTextureDecoder::ReadSubBlockCMPR(IInputStream& src, IOutputStream& dst)
{ {
dst.WriteShort(src.ReadShort()); dst.WriteShort(src.ReadShort());
dst.WriteShort(src.ReadShort()); dst.WriteShort(src.ReadShort());
@ -629,7 +629,7 @@ CColor CTextureDecoder::DecodePixelIA8(u16 Short)
return CColor::Integral(Lum, Lum, Lum, Alpha); return CColor::Integral(Lum, Lum, Lum, Alpha);
} }
CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, CInputStream& PaletteStream) CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, IInputStream& PaletteStream)
{ {
if (WhichPixel == 1) Byte >>= 4; if (WhichPixel == 1) Byte >>= 4;
Byte &= 0xF; Byte &= 0xF;
@ -641,7 +641,7 @@ CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, CInputStream& Pale
else return CColor::skTransparentBlack; else return CColor::skTransparentBlack;
} }
CColor CTextureDecoder::DecodePixelC8(u8 Byte, CInputStream& PaletteStream) CColor CTextureDecoder::DecodePixelC8(u8 Byte, IInputStream& PaletteStream)
{ {
PaletteStream.Seek(Byte * 2, SEEK_SET); PaletteStream.Seek(Byte * 2, SEEK_SET);
if (mPaletteFormat == ePalette_IA8) return DecodePixelIA8(PaletteStream.ReadShort()); if (mPaletteFormat == ePalette_IA8) return DecodePixelIA8(PaletteStream.ReadShort());
@ -678,7 +678,7 @@ CColor CTextureDecoder::DecodePixelRGB5A3(u16 Short)
} }
} }
void CTextureDecoder::DecodeSubBlockCMPR(CInputStream& src, COutputStream& dst, u16 Width) void CTextureDecoder::DecodeSubBlockCMPR(IInputStream& src, IOutputStream& dst, u16 Width)
{ {
CColor Palettes[4]; CColor Palettes[4];
u16 PaletteA = src.ReadShort(); u16 PaletteA = src.ReadShort();
@ -713,7 +713,7 @@ void CTextureDecoder::DecodeSubBlockCMPR(CInputStream& src, COutputStream& dst,
} }
} }
void CTextureDecoder::DecodeBlockBC1(CInputStream& src, COutputStream& dst, u32 Width) void CTextureDecoder::DecodeBlockBC1(IInputStream& src, IOutputStream& dst, u32 Width)
{ {
// Very similar to the CMPR subblock function, but unfortunately a slight // Very similar to the CMPR subblock function, but unfortunately a slight
// difference in the order the pixel indices are read requires a separate function // difference in the order the pixel indices are read requires a separate function
@ -750,7 +750,7 @@ void CTextureDecoder::DecodeBlockBC1(CInputStream& src, COutputStream& dst, u32
} }
} }
void CTextureDecoder::DecodeBlockBC2(CInputStream& src, COutputStream& dst, u32 Width) void CTextureDecoder::DecodeBlockBC2(IInputStream& src, IOutputStream& dst, u32 Width)
{ {
CColor CPalettes[4]; CColor CPalettes[4];
u16 PaletteA = src.ReadShort(); u16 PaletteA = src.ReadShort();
@ -785,7 +785,7 @@ void CTextureDecoder::DecodeBlockBC2(CInputStream& src, COutputStream& dst, u32
} }
} }
void CTextureDecoder::DecodeBlockBC3(CInputStream& src, COutputStream& dst, u32 Width) void CTextureDecoder::DecodeBlockBC3(IInputStream& src, IOutputStream& dst, u32 Width)
{ {
CColor Palettes[4]; CColor Palettes[4];
u16 PaletteA = src.ReadShort(); u16 PaletteA = src.ReadShort();
@ -820,7 +820,7 @@ void CTextureDecoder::DecodeBlockBC3(CInputStream& src, COutputStream& dst, u32
} }
} }
CColor CTextureDecoder::DecodeDDSPixel(CInputStream& /*DDS*/) CColor CTextureDecoder::DecodeDDSPixel(IInputStream& /*DDS*/)
{ {
return CColor::skWhite; return CColor::skWhite;
} }

View File

@ -38,48 +38,48 @@ class CTextureDecoder
CTexture* CreateTexture(); CTexture* CreateTexture();
// Read // Read
void ReadTXTR(CInputStream& TXTR); void ReadTXTR(IInputStream& TXTR);
void ReadDDS(CInputStream& DDS); void ReadDDS(IInputStream& DDS);
// Decode // Decode
void PartialDecodeGXTexture(CInputStream& TXTR); void PartialDecodeGXTexture(IInputStream& TXTR);
void FullDecodeGXTexture(CInputStream& TXTR); void FullDecodeGXTexture(IInputStream& TXTR);
void DecodeDDS(CInputStream& DDS); void DecodeDDS(IInputStream& DDS);
// Decode Pixels (preserve compression) // Decode Pixels (preserve compression)
void ReadPixelsI4(CInputStream& src, COutputStream& dst); void ReadPixelsI4(IInputStream& src, IOutputStream& dst);
void ReadPixelI8(CInputStream& src, COutputStream& dst); void ReadPixelI8(IInputStream& src, IOutputStream& dst);
void ReadPixelIA4(CInputStream& src, COutputStream& dst); void ReadPixelIA4(IInputStream& src, IOutputStream& dst);
void ReadPixelIA8(CInputStream& src, COutputStream& dst); void ReadPixelIA8(IInputStream& src, IOutputStream& dst);
void ReadPixelsC4(CInputStream& src, COutputStream& dst); void ReadPixelsC4(IInputStream& src, IOutputStream& dst);
void ReadPixelC8(CInputStream& src, COutputStream& dst); void ReadPixelC8(IInputStream& src, IOutputStream& dst);
void ReadPixelRGB565(CInputStream& src, COutputStream& dst); void ReadPixelRGB565(IInputStream& src, IOutputStream& dst);
void ReadPixelRGB5A3(CInputStream& src, COutputStream& dst); void ReadPixelRGB5A3(IInputStream& src, IOutputStream& dst);
void ReadPixelRGBA8(CInputStream& src, COutputStream& dst); void ReadPixelRGBA8(IInputStream& src, IOutputStream& dst);
void ReadSubBlockCMPR(CInputStream& src, COutputStream& dst); void ReadSubBlockCMPR(IInputStream& src, IOutputStream& dst);
// Decode Pixels (convert to RGBA8) // Decode Pixels (convert to RGBA8)
CColor DecodePixelI4(u8 Byte, u8 WhichPixel); CColor DecodePixelI4(u8 Byte, u8 WhichPixel);
CColor DecodePixelI8(u8 Byte); CColor DecodePixelI8(u8 Byte);
CColor DecodePixelIA4(u8 Byte); CColor DecodePixelIA4(u8 Byte);
CColor DecodePixelIA8(u16 Short); CColor DecodePixelIA8(u16 Short);
CColor DecodePixelC4(u8 Byte, u8 WhichPixel, CInputStream& PaletteStream); CColor DecodePixelC4(u8 Byte, u8 WhichPixel, IInputStream& PaletteStream);
CColor DecodePixelC8(u8 Byte, CInputStream& PaletteStream); CColor DecodePixelC8(u8 Byte, IInputStream& PaletteStream);
CColor DecodePixelRGB565(u16 Short); CColor DecodePixelRGB565(u16 Short);
CColor DecodePixelRGB5A3(u16 Short); CColor DecodePixelRGB5A3(u16 Short);
CColor DecodePixelRGBA8(CInputStream& src, COutputStream& dst); CColor DecodePixelRGBA8(IInputStream& src, IOutputStream& dst);
void DecodeSubBlockCMPR(CInputStream& src, COutputStream& dst, u16 Width); void DecodeSubBlockCMPR(IInputStream& src, IOutputStream& dst, u16 Width);
void DecodeBlockBC1(CInputStream& src, COutputStream& dst, u32 Width); void DecodeBlockBC1(IInputStream& src, IOutputStream& dst, u32 Width);
void DecodeBlockBC2(CInputStream& src, COutputStream& dst, u32 Width); void DecodeBlockBC2(IInputStream& src, IOutputStream& dst, u32 Width);
void DecodeBlockBC3(CInputStream& src, COutputStream& dst, u32 Width); void DecodeBlockBC3(IInputStream& src, IOutputStream& dst, u32 Width);
CColor DecodeDDSPixel(CInputStream& DDS); CColor DecodeDDSPixel(IInputStream& DDS);
// Static // Static
public: public:
static CTexture* LoadTXTR(CInputStream& TXTR); static CTexture* LoadTXTR(IInputStream& TXTR);
static CTexture* LoadDDS(CInputStream& DDS); static CTexture* LoadDDS(IInputStream& DDS);
static CTexture* DoFullDecode(CInputStream& TXTR); static CTexture* DoFullDecode(IInputStream& TXTR);
static CTexture* DoFullDecode(CTexture *pTexture); static CTexture* DoFullDecode(CTexture *pTexture);
// Utility // Utility

View File

@ -7,7 +7,7 @@ CWorldLoader::CWorldLoader()
{ {
} }
void CWorldLoader::LoadPrimeMLVL(CInputStream& MLVL) void CWorldLoader::LoadPrimeMLVL(IInputStream& MLVL)
{ {
/** /**
* This function loads MLVL files from Prime 1/2 * This function loads MLVL files from Prime 1/2
@ -218,7 +218,7 @@ void CWorldLoader::LoadPrimeMLVL(CInputStream& MLVL)
// todo: Layer ID support for MP3 // todo: Layer ID support for MP3
} }
void CWorldLoader::LoadReturnsMLVL(CInputStream& MLVL) void CWorldLoader::LoadReturnsMLVL(IInputStream& MLVL)
{ {
mpWorld->mpWorldName = gResCache.GetResource(MLVL.ReadLongLong(), "STRG"); mpWorld->mpWorldName = gResCache.GetResource(MLVL.ReadLongLong(), "STRG");
@ -280,7 +280,7 @@ void CWorldLoader::LoadReturnsMLVL(CInputStream& MLVL)
// todo: Layer ID support // todo: Layer ID support
} }
CWorld* CWorldLoader::LoadMLVL(CInputStream& MLVL) CWorld* CWorldLoader::LoadMLVL(IInputStream& MLVL)
{ {
if (!MLVL.IsValid()) return nullptr; if (!MLVL.IsValid()) return nullptr;
Log::Write("Loading " + MLVL.GetSourceString()); Log::Write("Loading " + MLVL.GetSourceString());

View File

@ -13,11 +13,11 @@ class CWorldLoader
EGame mVersion; EGame mVersion;
CWorldLoader(); CWorldLoader();
void LoadPrimeMLVL(CInputStream& MLVL); void LoadPrimeMLVL(IInputStream& MLVL);
void LoadReturnsMLVL(CInputStream& MLVL); void LoadReturnsMLVL(IInputStream& MLVL);
public: public:
static CWorld* LoadMLVL(CInputStream& MLVL); static CWorld* LoadMLVL(IInputStream& MLVL);
static EGame GetFormatVersion(u32 Version); static EGame GetFormatVersion(u32 Version);
}; };

View File

@ -714,7 +714,7 @@ void CModelEditorWindow::on_actionConvert_to_DDS_triggered()
TResPtr<CTexture> pTex = (CTexture*) gResCache.GetResource(TexFilename); TResPtr<CTexture> pTex = (CTexture*) gResCache.GetResource(TexFilename);
TString OutName = TexFilename.GetFilePathWithoutExtension() + ".dds"; TString OutName = TexFilename.GetFilePathWithoutExtension() + ".dds";
CFileOutStream Out(OutName.ToStdString(), IOUtil::LittleEndian); CFileOutStream Out(OutName.ToStdString(), IOUtil::eLittleEndian);
if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output DDS!"); if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output DDS!");
else else
@ -751,7 +751,7 @@ void CModelEditorWindow::on_actionSave_triggered()
return; return;
} }
CFileOutStream CMDLOut(mOutputFilename.toStdString(), IOUtil::BigEndian); CFileOutStream CMDLOut(mOutputFilename.toStdString(), IOUtil::eBigEndian);
CModelCooker::WriteCookedModel(mpCurrentModel, ePrime, CMDLOut); CModelCooker::WriteCookedModel(mpCurrentModel, ePrime, CMDLOut);
QMessageBox::information(this, "Saved", "Model saved!"); QMessageBox::information(this, "Saved", "Model saved!");
} }
@ -866,7 +866,7 @@ void CModelEditorWindow::on_actionConvert_DDS_to_TXTR_triggered()
if (Input.isEmpty()) return; if (Input.isEmpty()) return;
TString TexFilename = TO_TSTRING(Input); TString TexFilename = TO_TSTRING(Input);
CTexture *Tex = CTextureDecoder::LoadDDS(CFileInStream(TexFilename.ToStdString(), IOUtil::LittleEndian)); CTexture *Tex = CTextureDecoder::LoadDDS(CFileInStream(TexFilename.ToStdString(), IOUtil::eLittleEndian));
TString OutName = TexFilename.GetFilePathWithoutExtension() + ".txtr"; TString OutName = TexFilename.GetFilePathWithoutExtension() + ".txtr";
if ((Tex->TexelFormat() != eDXT1) || (Tex->NumMipMaps() > 1)) if ((Tex->TexelFormat() != eDXT1) || (Tex->NumMipMaps() > 1))
@ -874,7 +874,7 @@ void CModelEditorWindow::on_actionConvert_DDS_to_TXTR_triggered()
else else
{ {
CFileOutStream Out(OutName.ToStdString(), IOUtil::BigEndian); CFileOutStream Out(OutName.ToStdString(), IOUtil::eBigEndian);
if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output TXTR!"); if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output TXTR!");
else else

View File

@ -13,7 +13,7 @@ TestDialog::TestDialog(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
CTexture *pTex = CTextureDecoder::LoadDDS(CFileInStream("E:/test2.dds", IOUtil::LittleEndian)); CTexture *pTex = CTextureDecoder::LoadDDS(CFileInStream("E:/test2.dds", IOUtil::eLittleEndian));
ui->widget->SetTexture(pTex); ui->widget->SetTexture(pTex);
} }

View File

@ -2,28 +2,28 @@
CFileInStream::CFileInStream() CFileInStream::CFileInStream()
{ {
mFStream = nullptr; mpFStream = nullptr;
} }
CFileInStream::CFileInStream(std::string File) CFileInStream::CFileInStream(const std::string& rkFile)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(File, IOUtil::BigEndian); Open(rkFile, IOUtil::eBigEndian);
} }
CFileInStream::CFileInStream(std::string File, IOUtil::EEndianness FileEndianness) CFileInStream::CFileInStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(File, FileEndianness); Open(rkFile, FileEndianness);
} }
CFileInStream::CFileInStream(CFileInStream& src) CFileInStream::CFileInStream(const CFileInStream& rkSrc)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(src.mName, src.mDataEndianness); Open(rkSrc.mName, rkSrc.mDataEndianness);
if (src.IsValid()) if (rkSrc.IsValid())
Seek(src.Tell(), SEEK_SET); Seek(rkSrc.Tell(), SEEK_SET);
} }
CFileInStream::~CFileInStream() CFileInStream::~CFileInStream()
@ -32,13 +32,13 @@ CFileInStream::~CFileInStream()
Close(); Close();
} }
void CFileInStream::Open(std::string File, IOUtil::EEndianness FileEndianness) void CFileInStream::Open(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{ {
if (IsValid()) if (IsValid())
Close(); Close();
fopen_s(&mFStream, File.c_str(), "rb"); fopen_s(&mpFStream, rkFile.c_str(), "rb");
mName = File; mName = rkFile;
mDataEndianness = FileEndianness; mDataEndianness = FileEndianness;
if (IsValid()) if (IsValid())
@ -50,45 +50,45 @@ void CFileInStream::Open(std::string File, IOUtil::EEndianness FileEndianness)
else else
mFileSize = 0; mFileSize = 0;
size_t EndPath = File.find_last_of("\\/"); size_t EndPath = rkFile.find_last_of("\\/");
SetSourceString(File.substr(EndPath + 1, File.length() - EndPath)); SetSourceString(rkFile.substr(EndPath + 1, rkFile.length() - EndPath));
} }
void CFileInStream::Close() void CFileInStream::Close()
{ {
if (IsValid()) if (IsValid())
fclose(mFStream); fclose(mpFStream);
mFStream = nullptr; mpFStream = nullptr;
} }
void CFileInStream::ReadBytes(void *dst, unsigned long Count) void CFileInStream::ReadBytes(void *pDst, unsigned long Count)
{ {
if (!IsValid()) return; if (!IsValid()) return;
fread(dst, 1, Count, mFStream); fread(pDst, 1, Count, mpFStream);
} }
bool CFileInStream::Seek(long Offset, long Origin) bool CFileInStream::Seek(long Offset, long Origin)
{ {
if (!IsValid()) return false; if (!IsValid()) return false;
return (fseek(mFStream, Offset, Origin) != 0); return (fseek(mpFStream, Offset, Origin) != 0);
} }
bool CFileInStream::Seek64(long long Offset, long Origin) bool CFileInStream::Seek64(long long Offset, long Origin)
{ {
if (!IsValid()) return false; if (!IsValid()) return false;
return (_fseeki64(mFStream, Offset, Origin) != 0); return (_fseeki64(mpFStream, Offset, Origin) != 0);
} }
long CFileInStream::Tell() const long CFileInStream::Tell() const
{ {
if (!IsValid()) return 0; if (!IsValid()) return 0;
return ftell(mFStream); return ftell(mpFStream);
} }
long long CFileInStream::Tell64() const long long CFileInStream::Tell64() const
{ {
if (!IsValid()) return 0; if (!IsValid()) return 0;
return _ftelli64(mFStream); return _ftelli64(mpFStream);
} }
bool CFileInStream::EoF() const bool CFileInStream::EoF() const
@ -98,7 +98,7 @@ bool CFileInStream::EoF() const
bool CFileInStream::IsValid() const bool CFileInStream::IsValid() const
{ {
return (mFStream != 0); return (mpFStream != 0);
} }
long CFileInStream::Size() const long CFileInStream::Size() const

View File

@ -1,26 +1,26 @@
#ifndef CFILEINSTREAM_H #ifndef CFILEINSTREAM_H
#define CFILEINSTREAM_H #define CFILEINSTREAM_H
#include "CInputStream.h" #include "IInputStream.h"
#include "IOUtil.h" #include "IOUtil.h"
class CFileInStream : public CInputStream class CFileInStream : public IInputStream
{ {
private: private:
FILE *mFStream; FILE *mpFStream;
std::string mName; std::string mName;
long mFileSize; long mFileSize;
public: public:
CFileInStream(); CFileInStream();
CFileInStream(std::string file); CFileInStream(const std::string& rkFile);
CFileInStream(std::string file, IOUtil::EEndianness FileEndianness); CFileInStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
CFileInStream(CFileInStream& src); CFileInStream(const CFileInStream& rkSrc);
~CFileInStream(); ~CFileInStream();
void Open(std::string file, IOUtil::EEndianness FileEndianness); void Open(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
void Close(); void Close();
void ReadBytes(void *dst, unsigned long count); void ReadBytes(void *pDst, unsigned long count);
bool Seek(long offset, long origin); bool Seek(long offset, long origin);
bool Seek64(long long offset, long origin); bool Seek64(long long offset, long origin);
long Tell() const; long Tell() const;

View File

@ -2,29 +2,29 @@
CFileOutStream::CFileOutStream() CFileOutStream::CFileOutStream()
{ {
mFStream = nullptr; mpFStream = nullptr;
mSize = 0; mSize = 0;
} }
CFileOutStream::CFileOutStream(std::string File) CFileOutStream::CFileOutStream(const std::string& rkFile)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(File, IOUtil::BigEndian); Open(rkFile, IOUtil::eBigEndian);
} }
CFileOutStream::CFileOutStream(std::string File, IOUtil::EEndianness FileEndianness) CFileOutStream::CFileOutStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(File, FileEndianness); Open(rkFile, FileEndianness);
} }
CFileOutStream::CFileOutStream(CFileOutStream& src) CFileOutStream::CFileOutStream(const CFileOutStream& rkSrc)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(src.mName, src.mDataEndianness); Open(rkSrc.mName, rkSrc.mDataEndianness);
if (src.IsValid()) if (rkSrc.IsValid())
Seek(src.Tell(), SEEK_SET); Seek(rkSrc.Tell(), SEEK_SET);
} }
CFileOutStream::~CFileOutStream() CFileOutStream::~CFileOutStream()
@ -33,24 +33,24 @@ CFileOutStream::~CFileOutStream()
Close(); Close();
} }
void CFileOutStream::Open(std::string File, IOUtil::EEndianness FileEndianness) void CFileOutStream::Open(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{ {
if (IsValid()) if (IsValid())
Close(); Close();
fopen_s(&mFStream, File.c_str(), "wb"); fopen_s(&mpFStream, rkFile.c_str(), "wb");
mName = File; mName = rkFile;
mDataEndianness = FileEndianness; mDataEndianness = FileEndianness;
mSize = 0; mSize = 0;
} }
void CFileOutStream::Update(std::string File, IOUtil::EEndianness FileEndianness) void CFileOutStream::Update(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{ {
if (IsValid()) if (IsValid())
Close(); Close();
fopen_s(&mFStream, File.c_str(), "rb+"); fopen_s(&mpFStream, rkFile.c_str(), "rb+");
mName = File; mName = rkFile;
mDataEndianness = FileEndianness; mDataEndianness = FileEndianness;
Seek(0x0, SEEK_END); Seek(0x0, SEEK_END);
mSize = Tell(); mSize = Tell();
@ -60,40 +60,40 @@ void CFileOutStream::Update(std::string File, IOUtil::EEndianness FileEndianness
void CFileOutStream::Close() void CFileOutStream::Close()
{ {
if (IsValid()) if (IsValid())
fclose(mFStream); fclose(mpFStream);
mFStream = nullptr; mpFStream = nullptr;
mSize = 0; mSize = 0;
} }
void CFileOutStream::WriteBytes(void *src, unsigned long Count) void CFileOutStream::WriteBytes(void *pSrc, unsigned long Count)
{ {
if (!IsValid()) return; if (!IsValid()) return;
fwrite(src, 1, Count, mFStream); fwrite(pSrc, 1, Count, mpFStream);
if ((unsigned long) Tell() > mSize) mSize = Tell(); if ((unsigned long) Tell() > mSize) mSize = Tell();
} }
bool CFileOutStream::Seek(long Offset, long Origin) bool CFileOutStream::Seek(long Offset, long Origin)
{ {
if (!IsValid()) return false; if (!IsValid()) return false;
return (fseek(mFStream, Offset, Origin) != 0); return (fseek(mpFStream, Offset, Origin) != 0);
} }
bool CFileOutStream::Seek64(long long Offset, long Origin) bool CFileOutStream::Seek64(long long Offset, long Origin)
{ {
if (!IsValid()) return false; if (!IsValid()) return false;
return (_fseeki64(mFStream, Offset, Origin) != 0); return (_fseeki64(mpFStream, Offset, Origin) != 0);
} }
long CFileOutStream::Tell() const long CFileOutStream::Tell() const
{ {
if (!IsValid()) return 0; if (!IsValid()) return 0;
return ftell(mFStream); return ftell(mpFStream);
} }
long long CFileOutStream::Tell64() const long long CFileOutStream::Tell64() const
{ {
if (!IsValid()) return 0; if (!IsValid()) return 0;
return _ftelli64(mFStream); return _ftelli64(mpFStream);
} }
bool CFileOutStream::EoF() const bool CFileOutStream::EoF() const
@ -103,7 +103,7 @@ bool CFileOutStream::EoF() const
bool CFileOutStream::IsValid() const bool CFileOutStream::IsValid() const
{ {
return (mFStream != 0); return (mpFStream != 0);
} }
long CFileOutStream::Size() const long CFileOutStream::Size() const

View File

@ -1,27 +1,27 @@
#ifndef CFILEOUTSTREAM_H #ifndef CFILEOUTSTREAM_H
#define CFILEOUTSTREAM_H #define CFILEOUTSTREAM_H
#include "COutputStream.h" #include "IOutputStream.h"
#include "IOUtil.h" #include "IOUtil.h"
class CFileOutStream : public COutputStream class CFileOutStream : public IOutputStream
{ {
private: private:
FILE *mFStream; FILE *mpFStream;
std::string mName; std::string mName;
unsigned long mSize; unsigned long mSize;
public: public:
CFileOutStream(); CFileOutStream();
CFileOutStream(std::string file); CFileOutStream(const std::string& rkFile);
CFileOutStream(std::string file, IOUtil::EEndianness FileEndianness); CFileOutStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
CFileOutStream(CFileOutStream& src); CFileOutStream(const CFileOutStream& rkSrc);
~CFileOutStream(); ~CFileOutStream();
void Open(std::string file, IOUtil::EEndianness); void Open(const std::string& rkFile, IOUtil::EEndianness);
void Update(std::string file, IOUtil::EEndianness FileEndianness); void Update(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
void Close(); void Close();
void WriteBytes(void *src, unsigned long count); void WriteBytes(void *pSrc, unsigned long count);
bool Seek(long offset, long origin); bool Seek(long offset, long origin);
bool Seek64(long long offset, long origin); bool Seek64(long long offset, long origin);
long Tell() const; long Tell() const;

View File

@ -2,31 +2,31 @@
CMemoryInStream::CMemoryInStream() CMemoryInStream::CMemoryInStream()
{ {
mDataStart = nullptr; mpDataStart = nullptr;
mDataSize = 0; mDataSize = 0;
mPos = 0; mPos = 0;
} }
CMemoryInStream::CMemoryInStream(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness) CMemoryInStream::CMemoryInStream(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
{ {
SetData(Data, Size, DataEndianness); SetData(pData, Size, DataEndianness);
} }
CMemoryInStream::~CMemoryInStream() CMemoryInStream::~CMemoryInStream()
{ {
} }
void CMemoryInStream::SetData(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness) void CMemoryInStream::SetData(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
{ {
mDataStart = static_cast<char*>(Data); mpDataStart = static_cast<char*>(pData);
mDataSize = Size; mDataSize = Size;
mPos = 0; mPos = 0;
mDataEndianness = DataEndianness; mDataEndianness = DataEndianness;
} }
void CMemoryInStream::ReadBytes(void *dst, unsigned long Count) void CMemoryInStream::ReadBytes(void *pDst, unsigned long Count)
{ {
if (!IsValid()) return; if (!IsValid()) return;
memcpy(dst, mDataStart + mPos, Count); memcpy(pDst, mpDataStart + mPos, Count);
mPos += Count; mPos += Count;
} }
@ -76,7 +76,7 @@ bool CMemoryInStream::EoF() const
bool CMemoryInStream::IsValid() const bool CMemoryInStream::IsValid() const
{ {
return (mDataStart != nullptr); return (mpDataStart != nullptr);
} }
long CMemoryInStream::Size() const long CMemoryInStream::Size() const
@ -93,10 +93,10 @@ void CMemoryInStream::SetSize(unsigned long Size)
void* CMemoryInStream::Data() const void* CMemoryInStream::Data() const
{ {
return mDataStart; return mpDataStart;
} }
void* CMemoryInStream::DataAtPosition() const void* CMemoryInStream::DataAtPosition() const
{ {
return mDataStart + mPos; return mpDataStart + mPos;
} }

View File

@ -1,22 +1,22 @@
#ifndef CMEMORYINSTREAM_H #ifndef CMEMORYINSTREAM_H
#define CMEMORYINSTREAM_H #define CMEMORYINSTREAM_H
#include "CInputStream.h" #include "IInputStream.h"
#include "IOUtil.h" #include "IOUtil.h"
class CMemoryInStream : public CInputStream class CMemoryInStream : public IInputStream
{ {
char *mDataStart; char *mpDataStart;
long mDataSize; long mDataSize;
long mPos; long mPos;
public: public:
CMemoryInStream(); CMemoryInStream();
CMemoryInStream(void *Data, unsigned long Size, IOUtil::EEndianness dataEndianness); CMemoryInStream(void *pData, unsigned long Size, IOUtil::EEndianness dataEndianness);
~CMemoryInStream(); ~CMemoryInStream();
void SetData(void *Data, unsigned long Size, IOUtil::EEndianness dataEndianness); void SetData(void *pData, unsigned long Size, IOUtil::EEndianness dataEndianness);
void ReadBytes(void *dst, unsigned long Count); void ReadBytes(void *pDst, unsigned long Count);
bool Seek(long offset, long Origin); bool Seek(long offset, long Origin);
long Tell() const; long Tell() const;
bool EoF() const; bool EoF() const;

View File

@ -2,35 +2,35 @@
CMemoryOutStream::CMemoryOutStream() CMemoryOutStream::CMemoryOutStream()
{ {
mDataStart = nullptr; mpDataStart = nullptr;
mDataSize = 0; mDataSize = 0;
mPos = 0; mPos = 0;
mUsed = 0; mUsed = 0;
} }
CMemoryOutStream::CMemoryOutStream(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness) CMemoryOutStream::CMemoryOutStream(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
{ {
SetData(Data, Size, DataEndianness); SetData(pData, Size, DataEndianness);
} }
CMemoryOutStream::~CMemoryOutStream() CMemoryOutStream::~CMemoryOutStream()
{ {
} }
void CMemoryOutStream::SetData(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness) void CMemoryOutStream::SetData(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
{ {
mDataStart = static_cast<char*>(Data); mpDataStart = static_cast<char*>(pData);
mDataSize = Size; mDataSize = Size;
mPos = 0; mPos = 0;
mUsed = 0; mUsed = 0;
mDataEndianness = DataEndianness; mDataEndianness = DataEndianness;
} }
void CMemoryOutStream::WriteBytes(void *src, unsigned long Count) void CMemoryOutStream::WriteBytes(void *pSrc, unsigned long Count)
{ {
if (!IsValid()) return; if (!IsValid()) return;
memcpy(mDataStart + mPos, src, Count); memcpy(mpDataStart + mPos, pSrc, Count);
mPos += Count; mPos += Count;
if (mPos > mUsed) mUsed = mPos; if (mPos > mUsed) mUsed = mPos;
} }
@ -82,7 +82,7 @@ bool CMemoryOutStream::EoF() const
bool CMemoryOutStream::IsValid() const bool CMemoryOutStream::IsValid() const
{ {
return (mDataStart != nullptr); return (mpDataStart != nullptr);
} }
long CMemoryOutStream::Size() const long CMemoryOutStream::Size() const
@ -104,10 +104,10 @@ void CMemoryOutStream::SetSize(unsigned long Size)
void* CMemoryOutStream::Data() const void* CMemoryOutStream::Data() const
{ {
return mDataStart; return mpDataStart;
} }
void* CMemoryOutStream::DataAtPosition() const void* CMemoryOutStream::DataAtPosition() const
{ {
return mDataStart + mPos; return mpDataStart + mPos;
} }

View File

@ -1,22 +1,22 @@
#ifndef CMEMORYOUTSTREAM_H #ifndef CMEMORYOUTSTREAM_H
#define CMEMORYOUTSTREAM_H #define CMEMORYOUTSTREAM_H
#include "COutputStream.h" #include "IOutputStream.h"
class CMemoryOutStream : public COutputStream class CMemoryOutStream : public IOutputStream
{ {
char *mDataStart; char *mpDataStart;
long mDataSize; long mDataSize;
long mPos; long mPos;
long mUsed; long mUsed;
public: public:
CMemoryOutStream(); CMemoryOutStream();
CMemoryOutStream(void *Data, unsigned long Size, IOUtil::EEndianness mDataEndianness); CMemoryOutStream(void *pData, unsigned long Size, IOUtil::EEndianness mDataEndianness);
~CMemoryOutStream(); ~CMemoryOutStream();
void SetData(void *Data, unsigned long Size, IOUtil::EEndianness mDataEndianness); void SetData(void *pData, unsigned long Size, IOUtil::EEndianness mDataEndianness);
void WriteBytes(void *src, unsigned long count); void WriteBytes(void *pSrc, unsigned long count);
bool Seek(long offset, long origin); bool Seek(long offset, long origin);
long Tell() const; long Tell() const;
bool EoF() const; bool EoF() const;

View File

@ -1,114 +0,0 @@
#include "COutputStream.h"
COutputStream::~COutputStream()
{
}
void COutputStream::WriteByte(char Val)
{
WriteBytes(&Val, 1);
}
void COutputStream::WriteShort(short Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 2);
}
void COutputStream::WriteLong(long Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 4);
}
void COutputStream::WriteLongLong(long long Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 8);
}
void COutputStream::WriteFloat(float Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 4);
}
void COutputStream::WriteDouble(double Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 8);
}
void COutputStream::WriteString(std::string Val)
{
for (unsigned int i = 0; i < Val.size(); i++)
WriteByte(Val[i]);
if ((Val.empty()) || (Val.back() != '\0'))
WriteByte(0);
}
void COutputStream::WriteString(std::string Val, unsigned long Count, bool Terminate)
{
for (unsigned int i = 0; i < Count; i++)
WriteByte(Val[i]);
if (Terminate && (Val[Count-1] != '\0'))
WriteByte(0);
}
void COutputStream::WriteWString(std::wstring Val)
{
for (unsigned int i = 0; i < Val.size(); i++)
WriteShort(Val[i]);
if ((!Val.empty()) && (Val.back() != '\0'))
WriteShort(0);
}
void COutputStream::WriteWString(std::wstring Val, unsigned long Count, bool Terminate)
{
for (unsigned int i = 0; i < Count; i++)
WriteShort(Val[i]);
if (Terminate && (Val[Count-1] != 0))
WriteShort(0);
}
void COutputStream::WriteToBoundary(unsigned long Boundary, char Fill)
{
long Num = Boundary - (Tell() % Boundary);
if (Num == Boundary) return;
for (int i = 0; i < Num; i++)
WriteByte(Fill);
}
void COutputStream::SetEndianness(IOUtil::EEndianness Endianness)
{
mDataEndianness = Endianness;
}
void COutputStream::SetDestString(const std::string &Dest)
{
mDataDest = Dest;
}
IOUtil::EEndianness COutputStream::GetEndianness() const
{
return mDataEndianness;
}
std::string COutputStream::GetDestString() const
{
return mDataDest;
}
bool COutputStream::Seek64(long long Offset, long Origin)
{
return Seek((long) Offset, Origin);
}
long long COutputStream::Tell64() const
{
return (long long) (Tell());
}

View File

@ -2,19 +2,19 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
CTextInStream::CTextInStream(std::string File) CTextInStream::CTextInStream(const std::string& rkFile)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(File); Open(rkFile);
} }
CTextInStream::CTextInStream(CTextInStream& src) CTextInStream::CTextInStream(const CTextInStream& rkSrc)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(src.mFileName); Open(rkSrc.mFileName);
if (src.IsValid()) if (rkSrc.IsValid())
Seek(src.Tell(), SEEK_SET); Seek(rkSrc.Tell(), SEEK_SET);
} }
CTextInStream::~CTextInStream() CTextInStream::~CTextInStream()
@ -23,13 +23,13 @@ CTextInStream::~CTextInStream()
Close(); Close();
} }
void CTextInStream::Open(std::string File) void CTextInStream::Open(const std::string& rkFile)
{ {
if (IsValid()) if (IsValid())
Close(); Close();
fopen_s(&mFStream, File.c_str(), "r"); fopen_s(&mpFStream, rkFile.c_str(), "r");
mFileName = File; mFileName = rkFile;
if (IsValid()) if (IsValid())
{ {
@ -44,23 +44,23 @@ void CTextInStream::Open(std::string File)
void CTextInStream::Close() void CTextInStream::Close()
{ {
if (IsValid()) if (IsValid())
fclose(mFStream); fclose(mpFStream);
mFStream = nullptr; mpFStream = nullptr;
} }
void CTextInStream::Scan(const char *Format, ... ) void CTextInStream::Scan(const char *pkFormat, ... )
{ {
if (!IsValid()) return; if (!IsValid()) return;
va_list Args; va_list Args;
va_start(Args, Format); va_start(Args, pkFormat);
vfscanf(mFStream, Format, Args); vfscanf(mpFStream, pkFormat, Args);
} }
char CTextInStream::GetChar() char CTextInStream::GetChar()
{ {
if (!IsValid()) return 0; if (!IsValid()) return 0;
return (char) fgetc(mFStream); return (char) fgetc(mpFStream);
} }
std::string CTextInStream::GetString() std::string CTextInStream::GetString()
@ -68,20 +68,20 @@ std::string CTextInStream::GetString()
if (!IsValid()) return ""; if (!IsValid()) return "";
char Buf[0x1000]; char Buf[0x1000];
fgets(Buf, 0x1000, mFStream); fgets(Buf, 0x1000, mpFStream);
return std::string(Buf); return std::string(Buf);
} }
long CTextInStream::Seek(long Offset, long Origin) long CTextInStream::Seek(long Offset, long Origin)
{ {
if (!IsValid()) return 1; if (!IsValid()) return 1;
return fseek(mFStream, Offset, Origin); return fseek(mpFStream, Offset, Origin);
} }
long CTextInStream::Tell() const long CTextInStream::Tell() const
{ {
if (!IsValid()) return 0; if (!IsValid()) return 0;
return ftell(mFStream); return ftell(mpFStream);
} }
bool CTextInStream::EoF() const bool CTextInStream::EoF() const
@ -91,7 +91,7 @@ bool CTextInStream::EoF() const
bool CTextInStream::IsValid() const bool CTextInStream::IsValid() const
{ {
return (mFStream != 0); return (mpFStream != 0);
} }
long CTextInStream::Size() const long CTextInStream::Size() const

View File

@ -6,19 +6,19 @@
class CTextInStream class CTextInStream
{ {
FILE *mFStream; FILE *mpFStream;
std::string mFileName; std::string mFileName;
long mFileSize; long mFileSize;
public: public:
CTextInStream(); CTextInStream();
CTextInStream(std::string File); CTextInStream(const std::string& rkFile);
CTextInStream(CTextInStream& src); CTextInStream(const CTextInStream& rkSrc);
~CTextInStream(); ~CTextInStream();
void Open(std::string File); void Open(const std::string& rkFile);
void Close(); void Close();
void Scan(const char *Format, ... ); void Scan(const char *pkFormat, ... );
char GetChar(); char GetChar();
std::string GetString(); std::string GetString();

View File

@ -3,23 +3,23 @@
CTextOutStream::CTextOutStream() CTextOutStream::CTextOutStream()
{ {
mFStream = nullptr; mpFStream = nullptr;
mSize = 0; mSize = 0;
} }
CTextOutStream::CTextOutStream(std::string File) CTextOutStream::CTextOutStream(const std::string& rkFile)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(File.c_str()); Open(rkFile.c_str());
} }
CTextOutStream::CTextOutStream(CTextOutStream& src) CTextOutStream::CTextOutStream(const CTextOutStream& rkSrc)
{ {
mFStream = nullptr; mpFStream = nullptr;
Open(src.mFileName); Open(rkSrc.mFileName);
if (src.IsValid()) if (rkSrc.IsValid())
Seek(src.Tell(), SEEK_SET); Seek(rkSrc.Tell(), SEEK_SET);
} }
CTextOutStream::~CTextOutStream() CTextOutStream::~CTextOutStream()
@ -28,54 +28,54 @@ CTextOutStream::~CTextOutStream()
Close(); Close();
} }
void CTextOutStream::Open(std::string File) void CTextOutStream::Open(const std::string& rkFile)
{ {
fopen_s(&mFStream, File.c_str(), "w"); fopen_s(&mpFStream, rkFile.c_str(), "w");
mFileName = File; mFileName = rkFile;
mSize = 0; mSize = 0;
} }
void CTextOutStream::Close() void CTextOutStream::Close()
{ {
if (IsValid()) if (IsValid())
fclose(mFStream); fclose(mpFStream);
mFStream = nullptr; mpFStream = nullptr;
mSize = 0; mSize = 0;
} }
void CTextOutStream::Print(const char *Format, ... ) void CTextOutStream::Print(const char *pkFormat, ... )
{ {
if (!IsValid()) return; if (!IsValid()) return;
va_list Args; va_list Args;
va_start(Args, Format); va_start(Args, pkFormat);
vfprintf(mFStream, Format, Args); vfprintf(mpFStream, pkFormat, Args);
} }
void CTextOutStream::WriteChar(char c) void CTextOutStream::WriteChar(char c)
{ {
if (!IsValid()) return; if (!IsValid()) return;
fputc(c, mFStream); fputc(c, mpFStream);
if ((unsigned long) Tell() > mSize) mSize = Tell(); if ((unsigned long) Tell() > mSize) mSize = Tell();
} }
void CTextOutStream::WriteString(std::string Str) void CTextOutStream::WriteString(const std::string& rkStr)
{ {
if (!IsValid()) return; if (!IsValid()) return;
fputs(Str.c_str(), mFStream); fputs(rkStr.c_str(), mpFStream);
if ((unsigned long) Tell() > mSize) mSize = Tell(); if ((unsigned long) Tell() > mSize) mSize = Tell();
} }
bool CTextOutStream::Seek(long Offset, long Origin) bool CTextOutStream::Seek(long Offset, long Origin)
{ {
if (!IsValid()) return false; if (!IsValid()) return false;
return (fseek(mFStream, Offset, Origin) != 0); return (fseek(mpFStream, Offset, Origin) != 0);
} }
long CTextOutStream::Tell() const long CTextOutStream::Tell() const
{ {
if (!IsValid()) return 0; if (!IsValid()) return 0;
return ftell(mFStream); return ftell(mpFStream);
} }
bool CTextOutStream::EoF() const bool CTextOutStream::EoF() const
@ -85,7 +85,7 @@ bool CTextOutStream::EoF() const
bool CTextOutStream::IsValid() const bool CTextOutStream::IsValid() const
{ {
return (mFStream != 0); return (mpFStream != 0);
} }
long CTextOutStream::Size() const long CTextOutStream::Size() const

View File

@ -5,21 +5,21 @@
class CTextOutStream class CTextOutStream
{ {
FILE *mFStream; FILE *mpFStream;
std::string mFileName; std::string mFileName;
unsigned long mSize; unsigned long mSize;
public: public:
CTextOutStream(); CTextOutStream();
CTextOutStream(std::string File); CTextOutStream(const std::string& rkFile);
CTextOutStream(CTextOutStream& src); CTextOutStream(const CTextOutStream& rkSrc);
~CTextOutStream(); ~CTextOutStream();
void Open(std::string file); void Open(const std::string& file);
void Close(); void Close();
void Print(const char *Format, ... ); void Print(const char *pkFormat, ... );
void WriteChar(char c); void WriteChar(char c);
void WriteString(std::string Str); void WriteString(const std::string& Str);
bool Seek(long Offset, long Origin); bool Seek(long Offset, long Origin);
long Tell() const; long Tell() const;

View File

@ -2,7 +2,7 @@
CVectorOutStream::CVectorOutStream() CVectorOutStream::CVectorOutStream()
{ {
mDataEndianness = IOUtil::BigEndian; mDataEndianness = IOUtil::eBigEndian;
mPos = 0; mPos = 0;
mUsed = 0; mUsed = 0;
} }
@ -26,14 +26,14 @@ CVectorOutStream::~CVectorOutStream()
{ {
} }
void CVectorOutStream::WriteBytes(void *src, unsigned long Count) void CVectorOutStream::WriteBytes(void *pSrc, unsigned long Count)
{ {
if (!IsValid()) return; if (!IsValid()) return;
if ((mPos + Count) > mVector.size()) if ((mPos + Count) > mVector.size())
mVector.resize(mPos + Count); mVector.resize(mPos + Count);
memcpy(mVector.data() + mPos, src, Count); memcpy(mVector.data() + mPos, pSrc, Count);
mPos += Count; mPos += Count;
if (mPos > mUsed) mUsed = mPos; if (mPos > mUsed) mUsed = mPos;
} }

View File

@ -1,10 +1,10 @@
#ifndef CVECTOROUTSTREAM_H #ifndef CVECTOROUTSTREAM_H
#define CVECTOROUTSTREAM_H #define CVECTOROUTSTREAM_H
#include "COutputStream.h" #include "IOutputStream.h"
#include <vector> #include <vector>
class CVectorOutStream : public COutputStream class CVectorOutStream : public IOutputStream
{ {
std::vector<char> mVector; std::vector<char> mVector;
long mPos; long mPos;
@ -16,7 +16,7 @@ public:
CVectorOutStream(unsigned long InitialSize, IOUtil::EEndianness DataEndianness); CVectorOutStream(unsigned long InitialSize, IOUtil::EEndianness DataEndianness);
~CVectorOutStream(); ~CVectorOutStream();
void WriteBytes(void *src, unsigned long Count); void WriteBytes(void *pSrc, unsigned long Count);
bool Seek(long Offset, long Origin); bool Seek(long Offset, long Origin);
long Tell() const; long Tell() const;
bool EoF() const; bool EoF() const;

View File

@ -3,12 +3,12 @@
#include "IOUtil.h" #include "IOUtil.h"
#include "CInputStream.h" #include "IInputStream.h"
#include "CFileInStream.h" #include "CFileInStream.h"
#include "CMemoryInStream.h" #include "CMemoryInStream.h"
#include "CTextInStream.h" #include "CTextInStream.h"
#include "COutputStream.h" #include "IOutputStream.h"
#include "CFileOutStream.h" #include "CFileOutStream.h"
#include "CMemoryOutStream.h" #include "CMemoryOutStream.h"
#include "CVectorOutStream.h" #include "CVectorOutStream.h"

View File

@ -6,6 +6,7 @@
QT -= core gui QT -= core gui
QMAKE_CXXFLAGS += /WX QMAKE_CXXFLAGS += /WX
DEFINES += PWE_FILEIO
CONFIG += staticlib CONFIG += staticlib
TEMPLATE = lib TEMPLATE = lib
@ -32,25 +33,25 @@ CONFIG (release, debug|release) {
HEADERS += \ HEADERS += \
CFileInStream.h \ CFileInStream.h \
CFileOutStream.h \ CFileOutStream.h \
CInputStream.h \
CMemoryInStream.h \ CMemoryInStream.h \
CMemoryOutStream.h \ CMemoryOutStream.h \
COutputStream.h \
CTextInStream.h \ CTextInStream.h \
CTextOutStream.h \ CTextOutStream.h \
CVectorOutStream.h \ CVectorOutStream.h \
FileIO.h \ FileIO.h \
IOUtil.h IOUtil.h \
IInputStream.h \
IOutputStream.h
# Source Files # Source Files
SOURCES += \ SOURCES += \
CFileInStream.cpp \ CFileInStream.cpp \
CFileOutStream.cpp \ CFileOutStream.cpp \
CInputStream.cpp \
CMemoryInStream.cpp \ CMemoryInStream.cpp \
CMemoryOutStream.cpp \ CMemoryOutStream.cpp \
COutputStream.cpp \
CTextInStream.cpp \ CTextInStream.cpp \
CTextOutStream.cpp \ CTextOutStream.cpp \
CVectorOutStream.cpp \ CVectorOutStream.cpp \
IOUtil.cpp IOUtil.cpp \
IInputStream.cpp \
IOutputStream.cpp

View File

@ -1,57 +1,57 @@
#include "CInputStream.h" #include "IInputStream.h"
CInputStream::~CInputStream() IInputStream::~IInputStream()
{ {
} }
char CInputStream::ReadByte() char IInputStream::ReadByte()
{ {
char Val; char Val;
ReadBytes(&Val, 1); ReadBytes(&Val, 1);
return Val; return Val;
} }
short CInputStream::ReadShort() short IInputStream::ReadShort()
{ {
short Val; short Val;
ReadBytes(&Val, 2); ReadBytes(&Val, 2);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val; return Val;
} }
long CInputStream::ReadLong() long IInputStream::ReadLong()
{ {
long Val; long Val;
ReadBytes(&Val, 4); ReadBytes(&Val, 4);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val; return Val;
} }
long long CInputStream::ReadLongLong() long long IInputStream::ReadLongLong()
{ {
long long Val; long long Val;
ReadBytes(&Val, 8); ReadBytes(&Val, 8);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val; return Val;
} }
float CInputStream::ReadFloat() float IInputStream::ReadFloat()
{ {
float Val; float Val;
ReadBytes(&Val, 4); ReadBytes(&Val, 4);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val; return Val;
} }
double CInputStream::ReadDouble() double IInputStream::ReadDouble()
{ {
double Val; double Val;
ReadBytes(&Val, 8); ReadBytes(&Val, 8);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val; return Val;
} }
std::string CInputStream::ReadString() std::string IInputStream::ReadString()
{ {
std::string Str; std::string Str;
char c = 1; char c = 1;
@ -65,7 +65,7 @@ std::string CInputStream::ReadString()
return Str; return Str;
} }
std::string CInputStream::ReadString(unsigned long Count) std::string IInputStream::ReadString(unsigned long Count)
{ {
std::string Str(Count, 0); std::string Str(Count, 0);
@ -75,7 +75,7 @@ std::string CInputStream::ReadString(unsigned long Count)
return Str; return Str;
} }
std::wstring CInputStream::ReadWString() std::wstring IInputStream::ReadWString()
{ {
std::wstring WStr; std::wstring WStr;
short c = 1; short c = 1;
@ -89,7 +89,7 @@ std::wstring CInputStream::ReadWString()
return WStr; return WStr;
} }
std::wstring CInputStream::ReadWString(unsigned long Count) std::wstring IInputStream::ReadWString(unsigned long Count)
{ {
std::wstring WStr(Count, 0); std::wstring WStr(Count, 0);
@ -100,81 +100,81 @@ std::wstring CInputStream::ReadWString(unsigned long Count)
} }
char CInputStream::PeekByte() char IInputStream::PeekByte()
{ {
char Val = ReadByte(); char Val = ReadByte();
Seek(-1, SEEK_CUR); Seek(-1, SEEK_CUR);
return Val; return Val;
} }
short CInputStream::PeekShort() short IInputStream::PeekShort()
{ {
short Val = ReadShort(); short Val = ReadShort();
Seek(-2, SEEK_CUR); Seek(-2, SEEK_CUR);
return Val; return Val;
} }
long CInputStream::PeekLong() long IInputStream::PeekLong()
{ {
long Val = ReadLong(); long Val = ReadLong();
Seek(-4, SEEK_CUR); Seek(-4, SEEK_CUR);
return Val; return Val;
} }
long long CInputStream::PeekLongLong() long long IInputStream::PeekLongLong()
{ {
long long Val = ReadLongLong(); long long Val = ReadLongLong();
Seek(-8, SEEK_CUR); Seek(-8, SEEK_CUR);
return Val; return Val;
} }
float CInputStream::PeekFloat() float IInputStream::PeekFloat()
{ {
float Val = ReadFloat(); float Val = ReadFloat();
Seek(-4, SEEK_CUR); Seek(-4, SEEK_CUR);
return Val; return Val;
} }
double CInputStream::PeekDouble() double IInputStream::PeekDouble()
{ {
double Val = ReadDouble(); double Val = ReadDouble();
Seek(-8, SEEK_CUR); Seek(-8, SEEK_CUR);
return Val; return Val;
} }
void CInputStream::SeekToBoundary(unsigned long Boundary) void IInputStream::SeekToBoundary(unsigned long Boundary)
{ {
long Num = Boundary - (Tell() % Boundary); long Num = Boundary - (Tell() % Boundary);
if (Num == Boundary) return; if (Num == Boundary) return;
else Seek(Num, SEEK_CUR); else Seek(Num, SEEK_CUR);
} }
void CInputStream::SetEndianness(IOUtil::EEndianness Endianness) void IInputStream::SetEndianness(IOUtil::EEndianness Endianness)
{ {
mDataEndianness = Endianness; mDataEndianness = Endianness;
} }
void CInputStream::SetSourceString(const std::string& source) void IInputStream::SetSourceString(const std::string& rkSource)
{ {
mDataSource = source; mDataSource = rkSource;
} }
IOUtil::EEndianness CInputStream::GetEndianness() const IOUtil::EEndianness IInputStream::GetEndianness() const
{ {
return mDataEndianness; return mDataEndianness;
} }
std::string CInputStream::GetSourceString() const std::string IInputStream::GetSourceString() const
{ {
return mDataSource; return mDataSource;
} }
bool CInputStream::Seek64(long long Offset, long Origin) bool IInputStream::Seek64(long long Offset, long Origin)
{ {
return Seek((long) Offset, Origin); return Seek((long) Offset, Origin);
} }
long long CInputStream::Tell64() const long long IInputStream::Tell64() const
{ {
return (long long) Tell(); return (long long) Tell();
} }

View File

@ -1,11 +1,11 @@
#ifndef CINPUTSTREAM_H #ifndef IINPUTSTREAM_H
#define CINPUTSTREAM_H #define IINPUTSTREAM_H
#include "IOUtil.h" #include "IOUtil.h"
#include <string> #include <string>
#include <vector> #include <vector>
class CInputStream class IInputStream
{ {
protected: protected:
IOUtil::EEndianness mDataEndianness; IOUtil::EEndianness mDataEndianness;
@ -32,12 +32,12 @@ public:
void SeekToBoundary(unsigned long boundary); void SeekToBoundary(unsigned long boundary);
void SetEndianness(IOUtil::EEndianness endianness); void SetEndianness(IOUtil::EEndianness endianness);
void SetSourceString(const std::string& source); void SetSourceString(const std::string& rkSource);
IOUtil::EEndianness GetEndianness() const; IOUtil::EEndianness GetEndianness() const;
std::string GetSourceString() const; std::string GetSourceString() const;
virtual ~CInputStream(); virtual ~IInputStream();
virtual void ReadBytes(void *dst, unsigned long count) = 0; virtual void ReadBytes(void *pDst, unsigned long count) = 0;
virtual bool Seek(long offset, long origin) = 0; virtual bool Seek(long offset, long origin) = 0;
virtual bool Seek64(long long offset, long origin); virtual bool Seek64(long long offset, long origin);
virtual long Tell() const = 0; virtual long Tell() const = 0;
@ -47,4 +47,4 @@ public:
virtual long Size() const = 0; virtual long Size() const = 0;
}; };
#endif // CINPUTSTREAM_H #endif // IINPUTSTREAM_H

View File

@ -8,72 +8,72 @@ namespace IOUtil
// 0x01000000 - Little Endian // 0x01000000 - Little Endian
// 0x00000001 - Big Endian // 0x00000001 - Big Endian
long EndianTest = 1; long EndianTest = 1;
if (*(char*)&EndianTest == 1) return LittleEndian; if (*(char*)&EndianTest == 1) return eLittleEndian;
else return BigEndian; else return eBigEndian;
} }
const EEndianness SystemEndianness = FindSystemEndianness(); const EEndianness kSystemEndianness = FindSystemEndianness();
void SwapBytes(short& Val) void SwapBytes(short& rVal)
{ {
Val = (((Val & 0x00FF) << 8) | rVal = (((rVal & 0x00FF) << 8) |
((Val & 0xFF00) >> 8)); ((rVal & 0xFF00) >> 8));
} }
void SwapBytes(unsigned short& Val) void SwapBytes(unsigned short& rVal)
{ {
Val = (((Val & 0x00FF) << 8) | rVal = (((rVal & 0x00FF) << 8) |
((Val & 0xFF00) >> 8)); ((rVal & 0xFF00) >> 8));
} }
void SwapBytes(long& Val) void SwapBytes(long& rVal)
{ {
Val = (((Val & 0x000000FF) << 24) | rVal = (((rVal & 0x000000FF) << 24) |
((Val & 0x0000FF00) << 8) | ((rVal & 0x0000FF00) << 8) |
((Val & 0x00FF0000) >> 8) | ((rVal & 0x00FF0000) >> 8) |
((Val & 0xFF000000) >> 24)); ((rVal & 0xFF000000) >> 24));
} }
void SwapBytes(unsigned long& Val) void SwapBytes(unsigned long& rVal)
{ {
Val = (((Val & 0x000000FF) << 24) | rVal = (((rVal & 0x000000FF) << 24) |
((Val & 0x0000FF00) << 8) | ((rVal & 0x0000FF00) << 8) |
((Val & 0x00FF0000) >> 8) | ((rVal & 0x00FF0000) >> 8) |
((Val & 0xFF000000) >> 24)); ((rVal & 0xFF000000) >> 24));
} }
void SwapBytes(long long& Val) void SwapBytes(long long& rVal)
{ {
Val = (((Val & 0x00000000000000FF) << 56) | rVal = (((rVal & 0x00000000000000FF) << 56) |
((Val & 0x000000000000FF00) << 40) | ((rVal & 0x000000000000FF00) << 40) |
((Val & 0x0000000000FF0000) << 24) | ((rVal & 0x0000000000FF0000) << 24) |
((Val & 0x00000000FF000000) << 8) | ((rVal & 0x00000000FF000000) << 8) |
((Val & 0x000000FF00000000) >> 8) | ((rVal & 0x000000FF00000000) >> 8) |
((Val & 0x0000FF0000000000) >> 24) | ((rVal & 0x0000FF0000000000) >> 24) |
((Val & 0x00FF000000000000) >> 40) | ((rVal & 0x00FF000000000000) >> 40) |
((Val & 0xFF00000000000000) >> 56)); ((rVal & 0xFF00000000000000) >> 56));
} }
void SwapBytes(unsigned long long &Val) void SwapBytes(unsigned long long& rVal)
{ {
Val = (((Val & 0x00000000000000FF) << 56) | rVal = (((rVal & 0x00000000000000FF) << 56) |
((Val & 0x000000000000FF00) << 40) | ((rVal & 0x000000000000FF00) << 40) |
((Val & 0x0000000000FF0000) << 24) | ((rVal & 0x0000000000FF0000) << 24) |
((Val & 0x00000000FF000000) << 8) | ((rVal & 0x00000000FF000000) << 8) |
((Val & 0x000000FF00000000) >> 8) | ((rVal & 0x000000FF00000000) >> 8) |
((Val & 0x0000FF0000000000) >> 24) | ((rVal & 0x0000FF0000000000) >> 24) |
((Val & 0x00FF000000000000) >> 40) | ((rVal & 0x00FF000000000000) >> 40) |
((Val & 0xFF00000000000000) >> 56)); ((rVal & 0xFF00000000000000) >> 56));
} }
void SwapBytes(float& Val) void SwapBytes(float& rVal)
{ {
long* ptr = (long*) &Val; long* pPtr = (long*) &rVal;
SwapBytes(*ptr); SwapBytes(*pPtr);
} }
void SwapBytes(double& Val) void SwapBytes(double& rVal)
{ {
long long* ptr = (long long*) &Val; long long* pPtr = (long long*) &rVal;
SwapBytes(*ptr); SwapBytes(*pPtr);
} }
} }

View File

@ -4,19 +4,19 @@
namespace IOUtil namespace IOUtil
{ {
enum EEndianness { enum EEndianness {
LittleEndian, eLittleEndian,
BigEndian eBigEndian
}; };
extern const EEndianness SystemEndianness; extern const EEndianness kSystemEndianness;
void SwapBytes(short& Val); void SwapBytes(short& rVal);
void SwapBytes(unsigned short& Val); void SwapBytes(unsigned short& rVal);
void SwapBytes(long& Val); void SwapBytes(long& rVal);
void SwapBytes(unsigned long& Val); void SwapBytes(unsigned long& rVal);
void SwapBytes(long long& Val); void SwapBytes(long long& rVal);
void SwapBytes(unsigned long long& Val); void SwapBytes(unsigned long long& rVal);
void SwapBytes(float& Val); void SwapBytes(float& rVal);
void SwapBytes(double& Val); void SwapBytes(double& rVal);
} }
#endif // IOUTIL_H #endif // IOUTIL_H

View File

@ -0,0 +1,114 @@
#include "IOutputStream.h"
IOutputStream::~IOutputStream()
{
}
void IOutputStream::WriteByte(char Val)
{
WriteBytes(&Val, 1);
}
void IOutputStream::WriteShort(short Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 2);
}
void IOutputStream::WriteLong(long Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 4);
}
void IOutputStream::WriteLongLong(long long Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 8);
}
void IOutputStream::WriteFloat(float Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 4);
}
void IOutputStream::WriteDouble(double Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 8);
}
void IOutputStream::WriteString(const std::string& rkVal)
{
for (unsigned int i = 0; i < rkVal.size(); i++)
WriteByte(rkVal[i]);
if ((rkVal.empty()) || (rkVal.back() != '\0'))
WriteByte(0);
}
void IOutputStream::WriteString(const std::string& rkVal, unsigned long Count, bool Terminate)
{
for (unsigned int i = 0; i < Count; i++)
WriteByte(rkVal[i]);
if (Terminate && (rkVal[Count-1] != '\0'))
WriteByte(0);
}
void IOutputStream::WriteWideString(const std::wstring& rkVal)
{
for (unsigned int i = 0; i < rkVal.size(); i++)
WriteShort(rkVal[i]);
if ((!rkVal.empty()) && (rkVal.back() != '\0'))
WriteShort(0);
}
void IOutputStream::WriteWideString(const std::wstring& rkVal, unsigned long Count, bool Terminate)
{
for (unsigned int i = 0; i < Count; i++)
WriteShort(rkVal[i]);
if (Terminate && (rkVal[Count-1] != 0))
WriteShort(0);
}
void IOutputStream::WriteToBoundary(unsigned long Boundary, char Fill)
{
long Num = Boundary - (Tell() % Boundary);
if (Num == Boundary) return;
for (int i = 0; i < Num; i++)
WriteByte(Fill);
}
void IOutputStream::SetEndianness(IOUtil::EEndianness Endianness)
{
mDataEndianness = Endianness;
}
void IOutputStream::SetDestString(const std::string& rkDest)
{
mDataDest = rkDest;
}
IOUtil::EEndianness IOutputStream::GetEndianness() const
{
return mDataEndianness;
}
std::string IOutputStream::GetDestString() const
{
return mDataDest;
}
bool IOutputStream::Seek64(long long Offset, long Origin)
{
return Seek((long) Offset, Origin);
}
long long IOutputStream::Tell64() const
{
return (long long) (Tell());
}

View File

@ -1,10 +1,10 @@
#ifndef COUTPUTSTREAM_H #ifndef IOUTPUTSTREAM_H
#define COUTPUTSTREAM_H #define IOUTPUTSTREAM_H
#include "IOUtil.h" #include "IOUtil.h"
#include <string> #include <string>
class COutputStream class IOutputStream
{ {
protected: protected:
IOUtil::EEndianness mDataEndianness; IOUtil::EEndianness mDataEndianness;
@ -17,19 +17,19 @@ public:
void WriteLongLong(long long Val); void WriteLongLong(long long Val);
void WriteFloat(float Val); void WriteFloat(float Val);
void WriteDouble(double Val); void WriteDouble(double Val);
void WriteString(std::string Val); void WriteString(const std::string& rkVal);
void WriteString(std::string Val, unsigned long Count, bool Terminate = false); void WriteString(const std::string& rkVal, unsigned long Count, bool Terminate = false);
void WriteWString(std::wstring Val); void WriteWideString(const std::wstring& rkVal);
void WriteWString(std::wstring Val, unsigned long Count, bool Terminate = false); void WriteWideString(const std::wstring& rkVal, unsigned long Count, bool Terminate = false);
void WriteToBoundary(unsigned long Boundary, char Fill); void WriteToBoundary(unsigned long Boundary, char Fill);
void SetEndianness(IOUtil::EEndianness Endianness); void SetEndianness(IOUtil::EEndianness Endianness);
void SetDestString(const std::string& Dest); void SetDestString(const std::string& rkDest);
IOUtil::EEndianness GetEndianness() const; IOUtil::EEndianness GetEndianness() const;
std::string GetDestString() const; std::string GetDestString() const;
virtual ~COutputStream(); virtual ~IOutputStream();
virtual void WriteBytes(void *src, unsigned long Count) = 0; virtual void WriteBytes(void *pSrc, unsigned long Count) = 0;
virtual bool Seek(long Offset, long Origin) = 0; virtual bool Seek(long Offset, long Origin) = 0;
virtual bool Seek64(long long Offset, long Origin); virtual bool Seek64(long long Offset, long Origin);
virtual long Tell() const = 0; virtual long Tell() const = 0;

View File

@ -16,13 +16,13 @@ CAABox::CAABox(const CVector3f& Min, const CVector3f& Max)
mMax = Max; mMax = Max;
} }
CAABox::CAABox(CInputStream& input) CAABox::CAABox(IInputStream& input)
{ {
mMin = CVector3f(input); mMin = CVector3f(input);
mMax = CVector3f(input); mMax = CVector3f(input);
} }
void CAABox::Write(COutputStream& Output) void CAABox::Write(IOutputStream& Output)
{ {
mMin.Write(Output); mMin.Write(Output);
mMax.Write(Output); mMax.Write(Output);

View File

@ -2,8 +2,8 @@
#define CAABOX_H #define CAABOX_H
#include "CVector3f.h" #include "CVector3f.h"
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
#include <FileIO/COutputStream.h> #include <FileIO/IOutputStream.h>
#include <utility> #include <utility>
class CRay; class CRay;
@ -16,8 +16,8 @@ class CAABox
public: public:
CAABox(); CAABox();
CAABox(const CVector3f& Min, const CVector3f& Max); CAABox(const CVector3f& Min, const CVector3f& Max);
CAABox(CInputStream& input); CAABox(IInputStream& input);
void Write(COutputStream& Output); void Write(IOutputStream& Output);
CVector3f Center() const; CVector3f Center() const;
CVector3f Size() const; CVector3f Size() const;
CVector3f Min() const; CVector3f Min() const;

View File

@ -10,7 +10,7 @@ CTransform4f::CTransform4f()
*this = skIdentity; *this = skIdentity;
} }
CTransform4f::CTransform4f(CInputStream& input) CTransform4f::CTransform4f(IInputStream& input)
{ {
for (int v = 0; v < 12; v++) for (int v = 0; v < 12; v++)
_m[v] = input.ReadFloat(); _m[v] = input.ReadFloat();

View File

@ -20,7 +20,7 @@ class CTransform4f
public: public:
CTransform4f(); CTransform4f();
CTransform4f(CInputStream& input); CTransform4f(IInputStream& input);
CTransform4f(float v); CTransform4f(float v);
CTransform4f(float m00, float m01, float m02, float m03, CTransform4f(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13, float m10, float m11, float m12, float m13,

View File

@ -16,13 +16,13 @@ CVector2f::CVector2f(float _x, float _y)
y = _y; y = _y;
} }
CVector2f::CVector2f(CInputStream& Input) CVector2f::CVector2f(IInputStream& Input)
{ {
x = Input.ReadFloat(); x = Input.ReadFloat();
y = Input.ReadFloat(); y = Input.ReadFloat();
} }
void CVector2f::Write(COutputStream &Output) void CVector2f::Write(IOutputStream &Output)
{ {
Output.WriteFloat(x); Output.WriteFloat(x);
Output.WriteFloat(y); Output.WriteFloat(y);

View File

@ -1,8 +1,8 @@
#ifndef CVECTOR2F #ifndef CVECTOR2F
#define CVECTOR2F #define CVECTOR2F
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
#include <FileIO/COutputStream.h> #include <FileIO/IOutputStream.h>
class CVector2f class CVector2f
{ {
@ -11,8 +11,8 @@ public:
CVector2f(); CVector2f();
CVector2f(float xy); CVector2f(float xy);
CVector2f(float _x, float _y); CVector2f(float _x, float _y);
CVector2f(CInputStream& Input); CVector2f(IInputStream& Input);
void Write(COutputStream& Output); void Write(IOutputStream& Output);
float Magnitude() const; float Magnitude() const;
float SquaredMagnitude() const; float SquaredMagnitude() const;

View File

@ -1,8 +1,8 @@
#ifndef CVECTOR2I_H #ifndef CVECTOR2I_H
#define CVECTOR2I_H #define CVECTOR2I_H
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
#include <FileIO/COutputStream.h> #include <FileIO/IOutputStream.h>
class CVector2i class CVector2i
{ {

View File

@ -22,14 +22,14 @@ CVector3f::CVector3f(float _x, float _y, float _z)
z = _z; z = _z;
} }
CVector3f::CVector3f(CInputStream& Input) CVector3f::CVector3f(IInputStream& Input)
{ {
x = Input.ReadFloat(); x = Input.ReadFloat();
y = Input.ReadFloat(); y = Input.ReadFloat();
z = Input.ReadFloat(); z = Input.ReadFloat();
} }
void CVector3f::Write(COutputStream &Output) void CVector3f::Write(IOutputStream &Output)
{ {
Output.WriteFloat(x); Output.WriteFloat(x);
Output.WriteFloat(y); Output.WriteFloat(y);

View File

@ -1,8 +1,8 @@
#ifndef CVECTOR3F_H #ifndef CVECTOR3F_H
#define CVECTOR3F_H #define CVECTOR3F_H
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
#include <FileIO/COutputStream.h> #include <FileIO/IOutputStream.h>
#include <ostream> #include <ostream>
class CMatrix4f; class CMatrix4f;
@ -18,8 +18,8 @@ public:
CVector3f(); CVector3f();
CVector3f(float xyz); CVector3f(float xyz);
CVector3f(float _x, float _y, float _z); CVector3f(float _x, float _y, float _z);
CVector3f(CInputStream& Input); CVector3f(IInputStream& Input);
void Write(COutputStream& Output); void Write(IOutputStream& Output);
// Swizzle // Swizzle
CVector2f xy(); CVector2f xy();

View File

@ -45,7 +45,7 @@ CVector4f::CVector4f(const CVector3f& xyz, float _w)
w = _w; w = _w;
} }
CVector4f::CVector4f(CInputStream& Input) CVector4f::CVector4f(IInputStream& Input)
{ {
x = Input.ReadFloat(); x = Input.ReadFloat();
y = Input.ReadFloat(); y = Input.ReadFloat();
@ -53,7 +53,7 @@ CVector4f::CVector4f(CInputStream& Input)
w = Input.ReadFloat(); w = Input.ReadFloat();
} }
void CVector4f::Write(COutputStream &Output) void CVector4f::Write(IOutputStream &Output)
{ {
Output.WriteFloat(x); Output.WriteFloat(x);
Output.WriteFloat(y); Output.WriteFloat(y);

View File

@ -1,8 +1,8 @@
#ifndef CVECTOR4F #ifndef CVECTOR4F
#define CVECTOR4F #define CVECTOR4F
#include <FileIO/CInputStream.h> #include <FileIO/IInputStream.h>
#include <FileIO/COutputStream.h> #include <FileIO/IOutputStream.h>
class CMatrix4f; class CMatrix4f;
class CTransform4f; class CTransform4f;
@ -20,8 +20,8 @@ public:
CVector4f(const CVector2f& xy, float _z, float _w); CVector4f(const CVector2f& xy, float _z, float _w);
CVector4f(const CVector3f& xyz); CVector4f(const CVector3f& xyz);
CVector4f(const CVector3f& xyz, float _w); CVector4f(const CVector3f& xyz, float _w);
CVector4f(CInputStream& Input); CVector4f(IInputStream& Input);
void Write(COutputStream& Output); void Write(IOutputStream& Output);
// Swizzle // Swizzle
CVector3f xyz(); CVector3f xyz();