Skip to content

Commit

Permalink
Fix crashes when rendering monitors of varying sizes
Browse files Browse the repository at this point in the history
When calling .flip(), we limit the size of the buffer. However, this
limit is not reset when writing the next time, which means we get
out-of-bounds errors, even if the buffer is /technically/ big enough.

Clearing the buffer before drawing (rather than just resetting the
position) is enough to fix this.

Fixes #476 (and closes #477, which is a duplicate)
  • Loading branch information
SquidDev committed Jun 21, 2020
1 parent c0f3ca8 commit 2a8efb3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mod properties
mod_version=1.89.0
mod_version=1.89.1

# Minecraft properties
mc_version=1.12.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private static void renderTerminal( ClientMonitor monitor, float xMargin, float
}

ByteBuffer monitorBuffer = tboContents;
monitorBuffer.position( 0 );
monitorBuffer.clear();
for( int y = 0; y < height; y++ )
{
TextBuffer text = terminal.getLine( y ), textColour = terminal.getTextColourLine( y ), background = terminal.getBackgroundColourLine( y );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# New features in CC: Tweaked 1.89.1

* Fix crashes when rendering monitors of varying sizes.

# New features in CC: Tweaked 1.89.0

* Compress monitor data, reducing network traffic by a significant amount.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
New features in CC: Tweaked 1.89.0
New features in CC: Tweaked 1.89.1

* Compress monitor data, reducing network traffic by a significant amount.
* Allow limiting the bandwidth monitor updates use.
* Several optimisations to monitor rendering (@Lignum)

And several bug fixes:
* Fix settings.load failing on defined settings.
* Fix crashes when rendering monitors of varying sizes.

Type "help changelog" to see the full version history.

0 comments on commit 2a8efb3

Please sign in to comment.