From 7cf14ed7fdd1ed80df458dee1297dfdb1f87961b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 26 Nov 2013 21:41:43 +0100 Subject: [PATCH] charger texture and fixed power distributor synchronization when the max failed as well as when there are multiple distributors in a network --- assets/opencomputers/textures/blocks/charger.png | Bin 0 -> 761 bytes li/cil/oc/common/block/Charger.scala | 12 +++++++++--- li/cil/oc/server/component/PowerDistributor.scala | 9 +++++---- 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 assets/opencomputers/textures/blocks/charger.png diff --git a/assets/opencomputers/textures/blocks/charger.png b/assets/opencomputers/textures/blocks/charger.png new file mode 100644 index 0000000000000000000000000000000000000000..913e2512bcf6f945c62182432654197c489db887 GIT binary patch literal 761 zcmV2;qr)~C`MzL;FY^f2)~HC{o=3b1%P$M z5r?LBF}iy47F9@51wK{$-wfk;)vQnf;PQR%V5`0Qb_~DpL6rc!>AszfiL=3#4@`%= z6k1eT(z;%A)b@OOJQ7->jDl3^FgwtkyGQJKT_9yTpzHPDh5Bz`uGh6p%49Opk$7CY zo=@Va>zu%5rKhvo>5O^mu))0Jz-CPJeJ;j)c!B*q!+>d=gQLX}H2Dt)nGUnbvS! globalBufferSize * (5.0 / 100.0) + val fillRatio = sumBuffer / sumBufferSize + val shouldSend = (lastSentRatio - fillRatio).abs > (5.0 / 100.0) for (distributor <- distributors) distributor.synchronized { distributor.dirty = false distributor.globalBuffer = sumBuffer @@ -178,8 +179,8 @@ class PowerDistributor(val owner: PowerInformation) extends ManagedComponent { distributor.owner.globalBuffer = sumBuffer distributor.owner.globalBufferSize = sumBufferSize if (shouldSend) { - distributor.lastSentBuffer = sumBuffer - ServerPacketSender.sendPowerState(owner) + distributor.lastSentRatio = fillRatio + ServerPacketSender.sendPowerState(distributor.owner) } } }