Limit speed of hologram.setRaw a bit, to lower worst-case bandwidth use, but made it configurable.

Also moved hologram server-side settings to extra category in config.
This commit is contained in:
Florian Nücke 2015-04-19 13:05:33 +02:00
parent 7fc4d67dee
commit 30d722e19d
3 changed files with 58 additions and 39 deletions

View File

@ -67,26 +67,6 @@ opencomputers {
# may want to lower this a bit, to avoid it flickering too much.
hologramFlickerFrequency: 0.025
# This controls the maximum scales of holograms, by tier.
# The size at scale 1 is 3x2x3 blocks, at scale 3 the hologram will
# span up to 9x6x9 blocks. Unlike most other `client' settings, this
# value is only used for validation *on the server*, with the effects
# only being visible on the client.
# Warning: very large values may lead to rendering and/or performance
# issues due to the high view distance! Increase at your own peril.
hologramMaxScale: [
3
4
]
# This controls the maximum translation of holograms, by tier.
# The scale is in "hologram sizes", i.e. scale 1 allows offsetting a
# hologram once by its own size.
hologramMaxTranslation: [
0.25
0.5
]
# The color of monochrome text (i.e. displayed when in 1-bit color depth,
# e.g. tier one screens / GPUs, or higher tier set to 1-bit color depth).
# Defaults to white, feel free to make it some other color, tho!
@ -958,6 +938,37 @@ opencomputers {
printsHaveOpacity: false
}
hologram {
# This controls the maximum scales of holograms, by tier.
# The size at scale 1 is 3x2x3 blocks, at scale 3 the hologram will
# span up to 9x6x9 blocks. Unlike most other `client' settings, this
# value is only used for validation *on the server*, with the effects
# only being visible on the client.
# Warning: very large values may lead to rendering and/or performance
# issues due to the high view distance! Increase at your own peril.
maxScale: [
3
4
]
# This controls the maximum translation of holograms, by tier.
# The scale is in "hologram sizes", i.e. scale 1 allows offsetting a
# hologram once by its own size.
maxTranslation: [
0.25
0.5
]
# The delay forced on computers between calls to `hologram.setRaw`, in
# seconds. Lower this if you want faster updates, raise this if you're
# worried about bandwidth use; in *normal* use-cases this will never be
# an issue. When abused, `setRaw` can be used to generate network traffic
# due to changed data being sent to clients. With the default settings,
# the *worst case* is ~30KB/s/client. Again, for normal use-cases this
# is actually barely noticeable.
setRawDelay: 0.2
}
# Other settings that you might find useful to tweak.
misc {
# The maximum width of multi-block screens, in blocks.

View File

@ -33,20 +33,6 @@ class Settings(val config: Config) {
val hologramFadeStartDistance = config.getDouble("client.hologramFadeStartDistance") max 0
val hologramRenderDistance = config.getDouble("client.hologramRenderDistance") max 0
val hologramFlickerFrequency = config.getDouble("client.hologramFlickerFrequency") max 0
val hologramMaxScaleByTier = Array(config.getDoubleList("client.hologramMaxScale"): _*) match {
case Array(tier1, tier2) =>
Array((tier1: Double) max 1.0, (tier2: Double) max 1.0)
case _ =>
OpenComputers.log.warn("Bad number of hologram max scales, ignoring.")
Array(3.0, 4.0)
}
val hologramMaxTranslationByTier = Array(config.getDoubleList("client.hologramMaxTranslation"): _*) match {
case Array(tier1, tier2) =>
Array((tier1: Double) max 0.0, (tier2: Double) max 0.0)
case _ =>
OpenComputers.log.warn("Bad number of hologram max translations, ignoring.")
Array(0.25, 0.5)
}
val monochromeColor = Integer.decode(config.getString("client.monochromeColor"))
val fontRenderer = config.getString("client.fontRenderer")
val beepSampleRate = config.getInt("client.beepSampleRate")
@ -263,6 +249,24 @@ class Settings(val config: Config) {
val switchDefaultRelayAmount = config.getInt("switch.defaultRelayAmount") max 1
val switchRelayAmountUpgrade = config.getInt("switch.relayAmountUpgrade") max 0
// ----------------------------------------------------------------------- //
// hologram
val hologramMaxScaleByTier = Array(config.getDoubleList("hologram.maxScale"): _*) match {
case Array(tier1, tier2) =>
Array((tier1: Double) max 1.0, (tier2: Double) max 1.0)
case _ =>
OpenComputers.log.warn("Bad number of hologram max scales, ignoring.")
Array(3.0, 4.0)
}
val hologramMaxTranslationByTier = Array(config.getDoubleList("hologram.maxTranslation"): _*) match {
case Array(tier1, tier2) =>
Array((tier1: Double) max 0.0, (tier2: Double) max 0.0)
case _ =>
OpenComputers.log.warn("Bad number of hologram max translations, ignoring.")
Array(0.25, 0.5)
}
val hologramSetRawDelay = config.getDouble("hologram.setRawDelay") max 0
// ----------------------------------------------------------------------- //
// misc
val maxScreenWidth = config.getInt("misc.maxScreenWidth") max 1
@ -289,7 +293,8 @@ class Settings(val config: Config) {
val disassemblerBreakChance = config.getDouble("misc.disassemblerBreakChance") max 0 min 1
val hideOwnPet = config.getBoolean("misc.hideOwnSpecial")
val allowItemStackInspection = config.getBoolean("misc.allowItemStackInspection")
val databaseEntriesPerTier = Array(9, 25, 81) // Not configurable because of GUI design.
val databaseEntriesPerTier = Array(9, 25, 81)
// Not configurable because of GUI design.
val presentChance = config.getDouble("misc.presentChance") max 0 min 1
val assemblerBlacklist = config.getStringList("misc.assemblerBlacklist")
val threadPriority = config.getInt("misc.threadPriority")

View File

@ -166,12 +166,15 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
lbit |= (color & 1) << y
hbit |= ((color & 3) >>> 1) << y
}
volume(x + z * width) = lbit
volume(x + z * width + width * width) = hbit
val index = x + z * width
if (volume(index) != lbit || volume(index + width * width) != hbit) {
volume(index) = lbit
volume(index + width * width) = hbit
setDirty(x, z)
}
}
}
setDirty(0, 0)
setDirty(width - 1, width - 1)
context.pause(0.2)
null
}