Skip to content

stream: Implement RamStream#229

Merged
MonsterDruide1 merged 2 commits intoopen-ead:masterfrom
german77:ramStream
Jan 14, 2026
Merged

stream: Implement RamStream#229
MonsterDruide1 merged 2 commits intoopen-ead:masterfrom
german77:ramStream

Conversation

@german77
Copy link
Contributor

@german77 german77 commented Nov 29, 2025

Required by GameDataHolder::readFromSaveDataBufferCommonFileOnlyLanguage


This change is Reviewable

@german77 german77 force-pushed the ramStream branch 3 times, most recently from 3ce1185 to 001db03 Compare November 29, 2025 17:50
@german77
Copy link
Contributor Author

Update. I implemented sead::Stream as well. Since I do kind of want to be a functional class.

@codeman4033
Copy link

Also required by al::YamlWriterToMemory
@MonsterDruide1 please approve this soon

@MonsterDruide1 MonsterDruide1 changed the title stream: Implement RamStream stream: Implement RamStream Jan 13, 2026
Copy link
Contributor

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MonsterDruide1 reviewed 7 files and all commit messages, and made 8 comments.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @german77).


modules/src/stream/seadRamStream.cpp line 63 at r1 (raw file):

RamReadStream::RamReadStream(const void* buffer, u32 buffer_size, Stream::Modes mode)
    : mSrc(const_cast<void*>(buffer), buffer_size)

Why...?
They should've split off a read-only RamStream from the RW-stream...


modules/src/stream/seadRamStream.cpp line 82 at r1 (raw file):

RamWriteStream::RamWriteStream(void* buffer, u32 buffer_size, Stream::Modes mode)
    : mSrc(const_cast<void*>(buffer), buffer_size)

Suggestion:

: mSrc(buffer, buffer_size)

modules/src/stream/seadRamStream.cpp line 89 at r1 (raw file):

RamWriteStream::RamWriteStream(void* buffer, u32 buffer_size, StreamFormat* format)
    : mSrc(const_cast<void*>(buffer), buffer_size)

Suggestion:

: mSrc(buffer, buffer_size)

modules/src/stream/seadRamStream.cpp line 98 at r1 (raw file):

{
    flush();
    setSrc(nullptr);

The following happens:

  • ~RamWriteStream: flush + src = nullptr
  • ~WriteStream: src is null, so no flush

Not sure if that's the best solution, but ... at least correct behaviour.

Code quote:

    flush();
    setSrc(nullptr);

modules/src/stream/seadStream.cpp line 22 at r1 (raw file):

    mSrc = src;
    mFormat = format;
}

Suggestion:

Stream::Stream(StreamSrc* src, StreamFormat* format) : mSrc(src), mFormat(format) {}

modules/src/stream/seadStream.cpp line 50 at r1 (raw file):

}

void Stream::setMode(Modes mode)

Modes being plural is a violation of conventions, but that's what Nintendo did 🤷‍♂️

Code quote:

void Stream::setMode(Modes mode)

modules/src/stream/seadStream.cpp line 247 at r1 (raw file):

    mFormat->writeDecorationText(mSrc, "/* ");
    mFormat->writeDecorationText(mSrc, comment);
    mFormat->writeDecorationText(mSrc, " */");

Suggestion:

    writeDecorationText(mSrc, "/* ");
    writeDecorationText(mSrc, comment);
    writeDecorationText(mSrc, " */");

modules/src/stream/seadStream.cpp line 254 at r1 (raw file):

    mFormat->writeDecorationText(mSrc, "// ");
    mFormat->writeDecorationText(mSrc, comment);
    mFormat->writeDecorationText(mSrc, "\n");

Suggestion:

    writeDecorationText(mSrc, "// ");
    writeDecorationText(mSrc, comment);
    writeDecorationText(mSrc, "\n");

Copy link
Contributor Author

@german77 german77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@german77 made 7 comments.
Reviewable status: 6 of 7 files reviewed, 5 unresolved discussions (waiting on @MonsterDruide1).


modules/src/stream/seadRamStream.cpp line 63 at r1 (raw file):

Previously, MonsterDruide1 wrote…

Why...?
They should've split off a read-only RamStream from the RW-stream...

Not sure either. But that's how is made


modules/src/stream/seadRamStream.cpp line 98 at r1 (raw file):

Previously, MonsterDruide1 wrote…

The following happens:

  • ~RamWriteStream: flush + src = nullptr
  • ~WriteStream: src is null, so no flush

Not sure if that's the best solution, but ... at least correct behaviour.

This one took me a while to match, I couldn't find why it did things like this. They could have left the dtor empty and it will flush properly anyways.


modules/src/stream/seadRamStream.cpp line 82 at r1 (raw file):

RamWriteStream::RamWriteStream(void* buffer, u32 buffer_size, Stream::Modes mode)
    : mSrc(const_cast<void*>(buffer), buffer_size)

Done.


modules/src/stream/seadRamStream.cpp line 89 at r1 (raw file):

RamWriteStream::RamWriteStream(void* buffer, u32 buffer_size, StreamFormat* format)
    : mSrc(const_cast<void*>(buffer), buffer_size)

Done.


modules/src/stream/seadStream.cpp line 22 at r1 (raw file):

    mSrc = src;
    mFormat = format;
}

This one is a trick question. mFormat goes before mSrc. Using a member initializer list swaps that order.


modules/src/stream/seadStream.cpp line 247 at r1 (raw file):

    mFormat->writeDecorationText(mSrc, "/* ");
    mFormat->writeDecorationText(mSrc, comment);
    mFormat->writeDecorationText(mSrc, " */");

This one breaks the match, is an obvious inline but somehow creates different code.


modules/src/stream/seadStream.cpp line 254 at r1 (raw file):

    mFormat->writeDecorationText(mSrc, "// ");
    mFormat->writeDecorationText(mSrc, comment);
    mFormat->writeDecorationText(mSrc, "\n");

Same case here.

Copy link
Contributor

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MonsterDruide1 reviewed 1 file and all commit messages, made 1 comment, and resolved 5 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @german77).


modules/src/stream/seadRamStream.cpp line 98 at r1 (raw file):

Previously, german77 (Narr the Reg) wrote…

This one took me a while to match, I couldn't find why it did things like this. They could have left the dtor empty and it will flush properly anyways.

Maybe being extra-safe and setting the src to nullptr, because the memory backing the pointer is being deallocated here - so to prevent a use-after-free or similar, set it to a nullptr. But if you just set it to a nullptr, it's never flushed, because WriteStream's dtor is executed after this one, so it's already nullptr at that point - so we need to flush it as well.

@MonsterDruide1 MonsterDruide1 merged commit 9df87a5 into open-ead:master Jan 14, 2026
4 checks passed
@german77 german77 deleted the ramStream branch January 14, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants