Skip to content

Commit

Permalink
Remove CStdStream and replace all CStdStream parameters with C4Group
Browse files Browse the repository at this point in the history
  • Loading branch information
Fulgen301 committed Sep 21, 2024
1 parent 277aa42 commit af49ad9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 35 deletions.
8 changes: 4 additions & 4 deletions src/C4Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const int GRPF_Inactive = 0,
GRPF_File = 1,
GRPF_Folder = 2;

class C4Group : public CStdStream
class C4Group
{
public:
C4Group();
Expand Down Expand Up @@ -223,8 +223,8 @@ class C4Group : public CStdStream
size_t *iSize = nullptr,
bool *fChild = nullptr,
bool fStartAtFilename = false);
bool Read(void *pBuffer, size_t iSize) override;
bool Advance(size_t iOffset) override;
bool Read(void *pBuffer, size_t iSize);
bool Advance(size_t iOffset);
void SetMaker(const char *szMaker);
void SetStdOutput(bool fStatus);
void MakeOriginal(bool fOriginal);
Expand All @@ -236,7 +236,7 @@ class C4Group : public CStdStream
StdStrBuf GetFullName() const;
int EntryCount(const char *szWildCard = nullptr);
int EntrySize(const char *szWildCard = nullptr);
size_t AccessedEntrySize() override { return iCurrFileSize; } // retrieve size of last accessed entry
size_t AccessedEntrySize() { return iCurrFileSize; } // retrieve size of last accessed entry
uint32_t EntryTime(const char *szFilename);
unsigned int EntryCRC32(const char *szWildCard = nullptr);
int32_t GetCreation();
Expand Down
6 changes: 3 additions & 3 deletions src/C4Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ bool C4Surface::AttachSfc(void *sfcSurface)
return true;
}

bool C4Surface::Read(CStdStream &hGroup, bool fOwnPal)
bool C4Surface::Read(C4Group &hGroup, bool fOwnPal)
{
int lcnt, iLineRest;
CBitmap256Info BitmapInfo;
Expand Down Expand Up @@ -912,7 +912,7 @@ bool C4Surface::Load(C4Group &hGroup, const char *szFilename, bool fOwnPal, bool
return fSuccess;
}

bool C4Surface::ReadPNG(CStdStream &hGroup)
bool C4Surface::ReadPNG(C4Group &hGroup)
{
// create mem block
int iSize = hGroup.AccessedEntrySize();
Expand Down Expand Up @@ -1026,7 +1026,7 @@ bool C4Surface::Copy(C4Surface &fromSfc)
return true;
}

bool C4Surface::ReadJPEG(CStdStream &hGroup)
bool C4Surface::ReadJPEG(C4Group &hGroup)
{
// create mem block
size_t size = hGroup.AccessedEntrySize();
Expand Down
6 changes: 3 additions & 3 deletions src/C4Surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class C4Surface
void Default();
void Clip(int iX, int iY, int iX2, int iY2);
void NoClip();
bool Read(class CStdStream &hGroup, bool fOwnPal = false);
bool Read(C4Group &hGroup, bool fOwnPal = false);
bool SavePNG(const char *szFilename, bool fSaveAlpha, bool fApplyGamma, bool fSaveOverlayOnly, float scale = 1.0f);
bool Wipe(); // empty to transparent
bool GetSurfaceSize(int &irX, int &irY); // get surface size
Expand All @@ -116,8 +116,8 @@ class C4Surface
bool Load(C4Group &hGroup, const char *szFilename, bool fOwnPal = false, bool fNoErrIfNotFound = false);
bool SavePNG(C4Group &hGroup, const char *szFilename, bool fSaveAlpha = true, bool fApplyGamma = false, bool fSaveOverlayOnly = false);
bool Copy(C4Surface &fromSfc);
bool ReadPNG(CStdStream &hGroup);
bool ReadJPEG(CStdStream &hGroup);
bool ReadPNG(C4Group &hGroup);
bool ReadJPEG(C4Group &hGroup);

private:
bool CreateTextures(); // create ppTex-array
Expand Down
8 changes: 4 additions & 4 deletions src/C4SurfaceFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <C4Group.h>
#include "StdSurface8.h"

C4Surface *GroupReadSurface(CStdStream &hGroup, uint8_t *bpPalette)
C4Surface *GroupReadSurface(C4Group &hGroup, uint8_t *bpPalette)
{
// create surface
C4Surface *pSfc = new C4Surface();
Expand All @@ -33,7 +33,7 @@ C4Surface *GroupReadSurface(CStdStream &hGroup, uint8_t *bpPalette)
return pSfc;
}

CSurface8 *GroupReadSurface8(CStdStream &hGroup)
CSurface8 *GroupReadSurface8(C4Group &hGroup)
{
// create surface
CSurface8 *pSfc = new CSurface8();
Expand All @@ -44,7 +44,7 @@ CSurface8 *GroupReadSurface8(CStdStream &hGroup)
return pSfc;
}

CSurface8 *GroupReadSurfaceOwnPal8(CStdStream &hGroup)
CSurface8 *GroupReadSurfaceOwnPal8(C4Group &hGroup)
{
// create surface
CSurface8 *pSfc = new CSurface8();
Expand All @@ -55,7 +55,7 @@ CSurface8 *GroupReadSurfaceOwnPal8(CStdStream &hGroup)
return pSfc;
}

C4Surface *GroupReadSurfacePNG(CStdStream &hGroup)
C4Surface *GroupReadSurfacePNG(C4Group &hGroup)
{
// create surface
C4Surface *pSfc = new C4Surface();
Expand Down
9 changes: 4 additions & 5 deletions src/C4SurfaceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@

#include <cstdint>

class CStdStream;
class C4Surface;

C4Surface *GroupReadSurface(CStdStream &hGroup, uint8_t *bpPalette = nullptr);
CSurface8 *GroupReadSurface8(CStdStream &hGroup);
C4Surface *GroupReadSurfacePNG(CStdStream &hGroup);
CSurface8 *GroupReadSurfaceOwnPal8(CStdStream &hGroup);
C4Surface *GroupReadSurface(C4Group &hGroup, uint8_t *bpPalette = nullptr);
CSurface8 *GroupReadSurface8(C4Group &hGroup);
C4Surface *GroupReadSurfacePNG(C4Group &hGroup);
CSurface8 *GroupReadSurfaceOwnPal8(C4Group &hGroup);
18 changes: 4 additions & 14 deletions src/CStdFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,7 @@

constexpr unsigned int CStdFileBufSize = 4096;

class CStdStream
{
public:
virtual bool Read(void *pBuffer, size_t iSize) = 0;
virtual bool Advance(size_t iOffset) = 0;
// Get size. compatible with c4group!
virtual size_t AccessedEntrySize() = 0;
virtual ~CStdStream() {}
};

class CStdFile : public CStdStream
class CStdFile
{
public:
CStdFile();
Expand All @@ -58,12 +48,12 @@ class CStdFile : public CStdStream
bool Append(const char *szFilename); // append (uncompressed only)
bool Close();
bool Default();
bool Read(void *pBuffer, size_t iSize) override { return Read(pBuffer, iSize, nullptr); }
bool Read(void *pBuffer, size_t iSize) { return Read(pBuffer, iSize, nullptr); }
bool Read(void *pBuffer, size_t iSize, size_t *ipFSize);
bool Write(const void *pBuffer, size_t iSize);
bool WriteString(const char *szStr);
bool Rewind();
bool Advance(size_t iOffset) override;
bool Advance(size_t iOffset);
// Single line commands
bool Load(const char *szFileName, uint8_t **lpbpBuf,
size_t *ipSize = nullptr, int iAppendZeros = 0,
Expand All @@ -73,7 +63,7 @@ class CStdFile : public CStdStream
bool fCompressed = false);
// flush contents to disk
inline bool Flush() { if (ModeWrite && BufferLoad) return SaveBuffer(); else return true; }
size_t AccessedEntrySize() override;
size_t AccessedEntrySize();

protected:
void ClearBuffer();
Expand Down
2 changes: 1 addition & 1 deletion src/StdSurface8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ bool CSurface8::Create(int iWdt, int iHgt, bool fOwnPal)
return true;
}

bool CSurface8::Read(CStdStream &hGroup, bool fOwnPal)
bool CSurface8::Read(C4Group &hGroup, bool fOwnPal)
{
int cnt, lcnt, iLineRest;
CBitmap256Info BitmapInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/StdSurface8.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CSurface8
void Clear();
void Clip(int iX, int iY, int iX2, int iY2);
void NoClip();
bool Read(class CStdStream &hGroup, bool fOwnPal);
bool Read(C4Group &hGroup, bool fOwnPal);
bool Save(const char *szFilename, uint8_t *bpPalette = nullptr);
void GetSurfaceSize(int &irX, int &irY); // get surface size
void EnforceC0Transparency() { pPal->EnforceC0Transparency(); }
Expand Down

0 comments on commit af49ad9

Please sign in to comment.