diff options
author | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-14 12:51:27 +0100 |
---|---|---|
committer | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-14 12:51:27 +0100 |
commit | 664676eedf15bfa9fcb339a32055ec86490d9934 (patch) | |
tree | e880957f65af0a24f94f93c065cd667e71558183 /src/ByteBuffer.cpp | |
parent | Fixed not getting XP from mobs. (diff) | |
parent | Merge pull request #419 from mc-server/redstoneloading (diff) | |
download | cuberite-664676eedf15bfa9fcb339a32055ec86490d9934.tar cuberite-664676eedf15bfa9fcb339a32055ec86490d9934.tar.gz cuberite-664676eedf15bfa9fcb339a32055ec86490d9934.tar.bz2 cuberite-664676eedf15bfa9fcb339a32055ec86490d9934.tar.lz cuberite-664676eedf15bfa9fcb339a32055ec86490d9934.tar.xz cuberite-664676eedf15bfa9fcb339a32055ec86490d9934.tar.zst cuberite-664676eedf15bfa9fcb339a32055ec86490d9934.zip |
Diffstat (limited to 'src/ByteBuffer.cpp')
-rw-r--r-- | src/ByteBuffer.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 29f3afbfc..64c03d0d3 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -773,6 +773,28 @@ void cByteBuffer::ReadAll(AString & a_Data) +bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, int a_NumBytes) +{ + if (!a_Dst.CanWriteBytes(a_NumBytes) || !CanReadBytes(a_NumBytes)) + { + // There's not enough source bytes or space in the dest BB + return false; + } + char buf[1024]; + while (a_NumBytes > 0) + { + int num = (a_NumBytes > sizeof(buf)) ? sizeof(buf) : a_NumBytes; + VERIFY(ReadBuf(buf, num)); + VERIFY(a_Dst.Write(buf, num)); + a_NumBytes -= num; + } + return true; +} + + + + + void cByteBuffer::CommitRead(void) { CHECK_THREAD; |