Skip to content

Commit

Permalink
RE BSResource::ArchiveStream
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Dec 19, 2024
1 parent b41d280 commit 6bce824
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set(SOURCES
include/RE/A/AnimationFileManagerSingleton.h
include/RE/A/AnimationObjects.h
include/RE/A/Archive.h
include/RE/A/ArchiveStream.h
include/RE/A/ArmorRatingVisitor.h
include/RE/A/ArmorRatingVisitorBase.h
include/RE/A/Array.h
Expand Down Expand Up @@ -503,6 +504,7 @@ set(SOURCES
include/RE/C/CommonTypeTraits.h
include/RE/C/CompactingStore.h
include/RE/C/CompiledScriptLoader.h
include/RE/C/CompressedArchiveStream.h
include/RE/C/ConcreteFormFactory.h
include/RE/C/ConcreteObjectFormFactory.h
include/RE/C/ConcussionEffect.h
Expand Down
43 changes: 43 additions & 0 deletions include/RE/A/ArchiveStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

#include "RE/S/Stream.h"

namespace RE
{
namespace BSResource
{
class ArchiveStream : public Stream
{
public:
inline static constexpr auto RTTI = RTTI_BSResource__ArchiveStream;
inline static constexpr auto VTABLE = VTABLE_BSResource__ArchiveStream;

~ArchiveStream() override; // 00

// override (Stream)
ErrorCode DoOpen() override; // 01
void DoClose() override; // 02
[[nodiscard]] std::uint64_t DoGetKey() const override; // 03
void DoClone(BSTSmartPointer<Stream>& a_out) const override; // 05
ErrorCode DoRead(void* a_buffer, std::uint64_t a_toRead, std::uint64_t& a_read) const override; // 06
ErrorCode DoWrite(const void* a_buffer, std::uint64_t a_toWrite, std::uint64_t& a_written) const override; // 07
ErrorCode DoSeek(std::uint64_t a_toSeek, SeekMode a_mode, std::uint64_t& a_sought) const override; // 08
bool DoGetName(BSFixedString& a_dst) const override; // 0A
ErrorCode DoCreateAsync(BSTSmartPointer<AsyncStream>& a_streamOut) const override; // 0B

// add
virtual std::uint32_t DoGetSize() const; // 0C

// members
BSTSmartPointer<Stream> source; // 10
std::uint32_t startOffset; // 18
std::uint32_t currentOffset; // 1C
BSFixedString name; // 20
};
#ifdef SKYRIM_SUPPORT_AE
static_assert(sizeof(ArchiveStream) == 0x30);
#else
static_assert(sizeof(ArchiveStream) == 0x28);
#endif
}
}
4 changes: 4 additions & 0 deletions include/RE/A/AsyncStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ namespace RE
std::uint32_t minPacketSize; // 10
std::uint32_t pad14; // 14
};
#ifdef SKYRIM_SUPPORT_AE
static_assert(sizeof(AsyncStream) == 0x20);
#else
static_assert(sizeof(AsyncStream) == 0x18);
#endif
}
}
37 changes: 37 additions & 0 deletions include/RE/C/CompressedArchiveStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include "RE/A/ArchiveStream.h"

namespace RE
{
namespace BSResource
{
class CompressedArchiveStream : public ArchiveStream
{
public:
inline static constexpr auto RTTI = RTTI_BSResource__CompressedArchiveStream;
inline static constexpr auto VTABLE = VTABLE_BSResource__CompressedArchiveStream;

~CompressedArchiveStream() override; // 00

// override (ArchiveStream)
ErrorCode DoOpen() override; // 01
void DoClose() override; // 02
void DoClone(BSTSmartPointer<Stream>& a_out) const override; // 05
ErrorCode DoRead(void* a_buffer, std::uint64_t a_toRead, std::uint64_t& a_read) const override; // 06
ErrorCode DoSeek(std::uint64_t a_toSeek, SeekMode a_mode, std::uint64_t& a_sought) const override; // 08
ErrorCode DoCreateAsync(BSTSmartPointer<AsyncStream>& a_streamOut) const override; // 0B
std::uint32_t DoGetSize() const override; // 0C

// members
std::uint64_t unk28; // 28
std::uint32_t unk30; // 30
std::uint32_t unk34; // 34
};
#ifdef SKYRIM_SUPPORT_AE
static_assert(sizeof(CompressedArchiveStream) == 0x40);
#else
static_assert(sizeof(CompressedArchiveStream) == 0x38);
#endif
}
}
4 changes: 4 additions & 0 deletions include/RE/D/DevNull.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ namespace RE
ErrorCode DoWrite(const void* a_buffer, std::uint64_t a_toWrite, std::uint64_t& a_written) const override; // 07
ErrorCode DoSeek(std::uint64_t a_toSeek, SeekMode a_mode, std::uint64_t& a_sought) const override; // 08
};
#ifdef SKYRIM_SUPPORT_AE
static_assert(sizeof(NullStream) == 0x18);
#else
static_assert(sizeof(NullStream) == 0x10);
#endif

~DevNull() override; // 00

Expand Down
4 changes: 4 additions & 0 deletions include/RE/S/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ namespace RE
virtual bool DoGetName(BSFixedString& a_dst) const; // 0A - { a_dst = ""; return false; }
virtual ErrorCode DoCreateAsync(BSTSmartPointer<AsyncStream>& a_streamOut) const; // 0B - { return ErrorCode::kUnsupported; }
};
#ifdef SKYRIM_SUPPORT_AE
static_assert(sizeof(Stream) == 0x18);
#else
static_assert(sizeof(Stream) == 0x10);
#endif
}
}
9 changes: 8 additions & 1 deletion include/RE/S/StreamBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ namespace RE

// members
std::uint32_t totalSize; // 08
std::uint32_t flags; // 0C
#ifdef SKYRIM_SUPPORT_AE
std::uint32_t unk0C; // 0C
#endif
std::uint32_t flags; // 10
};
#ifdef SKYRIM_SUPPORT_AE
static_assert(sizeof(StreamBase) == 0x18);
#else
static_assert(sizeof(StreamBase) == 0x10);
#endif
}
}
2 changes: 2 additions & 0 deletions include/RE/Skyrim.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "RE/A/AnimationFileManagerSingleton.h"
#include "RE/A/AnimationObjects.h"
#include "RE/A/Archive.h"
#include "RE/A/ArchiveStream.h"
#include "RE/A/ArmorRatingVisitor.h"
#include "RE/A/ArmorRatingVisitorBase.h"
#include "RE/A/Array.h"
Expand Down Expand Up @@ -505,6 +506,7 @@
#include "RE/C/CommonTypeTraits.h"
#include "RE/C/CompactingStore.h"
#include "RE/C/CompiledScriptLoader.h"
#include "RE/C/CompressedArchiveStream.h"
#include "RE/C/ConcreteFormFactory.h"
#include "RE/C/ConcreteObjectFormFactory.h"
#include "RE/C/ConcussionEffect.h"
Expand Down

0 comments on commit 6bce824

Please sign in to comment.