Fixed #668, wrong toArray being used by linked cards.

This commit is contained in:
Florian Nücke 2014-11-13 23:14:47 +01:00
parent 7c5aa37693
commit 73670f7282

View File

@ -1,15 +1,14 @@
package li.cil.oc.server.component
import li.cil.oc.Settings
import li.cil.oc.api.Network
import li.cil.oc.api.machine.Arguments
import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context
import li.cil.oc.api.machine.{Arguments, Callback, Context}
import li.cil.oc.api.network._
import li.cil.oc.api.prefab
import li.cil.oc.api.{Network, prefab}
import li.cil.oc.server.network.QuantumNetwork
import net.minecraft.nbt.NBTTagCompound
import scala.collection.convert.WrapAsScala._
class LinkedCard extends prefab.ManagedEnvironment {
override val node = Network.newNode(this, Visibility.Network).
withComponent("tunnel", Visibility.Neighbors).
@ -23,7 +22,8 @@ class LinkedCard extends prefab.ManagedEnvironment {
@Callback(doc = """function(data...) -- Sends the specified data to the card this one is linked to.""")
def send(context: Context, args: Arguments): Array[AnyRef] = {
val endpoints = QuantumNetwork.getEndpoints(tunnel).filter(_ != this)
val packet = Network.newPacket(node.address, null, 0, args.toArray)
// Cast to iterable to use Scala's toArray instead of the Arguments' one (which converts byte arrays to Strings).
val packet = Network.newPacket(node.address, null, 0, args.asInstanceOf[java.lang.Iterable[AnyRef]].toArray)
if (node.tryChangeBuffer(-(packet.size / 32.0 + Settings.get.wirelessCostPerRange * Settings.get.maxWirelessRange * 5))) {
for (card <- endpoints) {
card.receivePacket(packet)