Trying to prevent #1684, #1685.

This commit is contained in:
Florian Nücke 2016-03-12 13:34:22 +01:00
parent c3b5741cea
commit 6b073bfa36
3 changed files with 8 additions and 7 deletions

View File

@ -46,7 +46,7 @@ abstract class TextureFontRenderer {
// Background first. We try to merge adjacent backgrounds of the same
// color to reduce the number of quads we have to draw.
GL11.glBegin(GL11.GL_QUADS)
for (y <- 0 until viewportHeight) {
for (y <- 0 until (viewportHeight min buffer.height)) {
val color = buffer.color(y)
var cbg = 0x000000
var x = 0
@ -74,7 +74,7 @@ abstract class TextureFontRenderer {
// Foreground second. We only have to flush when the color changes, so
// unless every char has a different color this should be quite efficient.
for (y <- 0 until viewportHeight) {
for (y <- 0 until (viewportHeight min buffer.height)) {
val line = buffer.buffer(y)
val color = buffer.color(y)
val ty = y * charHeight

View File

@ -244,8 +244,9 @@ class TextBuffer(val host: EnvironmentHost) extends prefab.ManagedEnvironment wi
proxy.onBufferResolutionChange(w, h)
// Force set viewport to new resolution. This is partially for
// backwards compatibility, and partially to enforce a valid one.
// Binary or to evaluate both, negated setViewport to only send signal once.
if ((data.size = (w, h)) | !setViewport(w, h)) {
val sizeChanged = data.size = (w, h)
val viewportChanged = setViewport(w, h)
if (sizeChanged && !viewportChanged) {
if (node != null) {
node.sendToReachable("computer.signal", "screen_resized", Int.box(w), Int.box(h))
}

View File

@ -215,9 +215,9 @@ class TextBuffer(var width: Int, var height: Int, initialFormat: PackedColor.Col
}
def load(nbt: NBTTagCompound): Unit = {
val maxResolution = math.max(Settings.screenResolutionsByTier(2)._1, Settings.screenResolutionsByTier(2)._2)
val w = nbt.getInteger("width") max 1 min maxResolution
val h = nbt.getInteger("height") max 1 min maxResolution
val maxResolution = math.max(Settings.screenResolutionsByTier.last._1, Settings.screenResolutionsByTier.last._2)
val w = nbt.getInteger("width") min maxResolution max 1
val h = nbt.getInteger("height") min maxResolution max 1
size = (w, h)
val b = nbt.getTagList("buffer", NBT.TAG_STRING)