From 2a8efb3fd53409acf23e8610ddc024f374868267 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sun, 21 Jun 2020 12:03:24 +0100 Subject: [PATCH] Fix crashes when rendering monitors of varying sizes 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) --- gradle.properties | 2 +- .../client/render/TileEntityMonitorRenderer.java | 2 +- .../assets/computercraft/lua/rom/help/changelog.txt | 4 ++++ .../assets/computercraft/lua/rom/help/whatsnew.txt | 9 ++------- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 3fe94fba4..f71c4f6e1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Mod properties -mod_version=1.89.0 +mod_version=1.89.1 # Minecraft properties mc_version=1.12.2 diff --git a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java index 7dd003152..9e4620574 100644 --- a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java @@ -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 ); diff --git a/src/main/resources/assets/computercraft/lua/rom/help/changelog.txt b/src/main/resources/assets/computercraft/lua/rom/help/changelog.txt index 7c9eac4ce..97d223b6b 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/changelog.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/changelog.txt @@ -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. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt b/src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt index d715a80f5..ddb0a9fe9 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt @@ -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.