stream: Implement RamStream#229
Conversation
3ce1185 to
001db03
Compare
|
Update. I implemented |
|
Also required by |
RamStream RamStream
MonsterDruide1
left a comment
There was a problem hiding this comment.
@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");
german77
left a comment
There was a problem hiding this comment.
@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-onlyRamStreamfrom 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 flushNot 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.
MonsterDruide1
left a comment
There was a problem hiding this comment.
@MonsterDruide1 reviewed 1 file and all commit messages, made 1 comment, and resolved 5 discussions.
Reviewable status: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.
Required by
GameDataHolder::readFromSaveDataBufferCommonFileOnlyLanguageThis change is