From 3465956c4f1824e6b89febac5ee4778b98730603 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 23 Dec 2022 19:15:47 +0100 Subject: [PATCH] Fix EqualOperator and NotEqualOperator --- .../expression/operator/comparison/EqualOperator.java | 6 ++++++ .../expression/operator/comparison/NotEqualOperator.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/expression/operator/comparison/EqualOperator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/expression/operator/comparison/EqualOperator.java index 82933c36..09ab767c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/expression/operator/comparison/EqualOperator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/expression/operator/comparison/EqualOperator.java @@ -38,6 +38,12 @@ public class EqualOperator implements Operator { @Override public Value operate(Value value, Value value2) { + if (value instanceof Value.DoubleValue && value2 instanceof Value.LongValue) { + return new Value.BooleanValue(value.asDouble() == value2.asDouble()); + } + if (value instanceof Value.LongValue && value2 instanceof Value.DoubleValue) { + return new Value.BooleanValue(value.asDouble() == value2.asDouble()); + } if (!value.type().equals(value2.type())) { return new Value.BooleanValue(false); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/expression/operator/comparison/NotEqualOperator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/expression/operator/comparison/NotEqualOperator.java index 47618419..b41eea55 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/expression/operator/comparison/NotEqualOperator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/expression/operator/comparison/NotEqualOperator.java @@ -38,6 +38,12 @@ public class NotEqualOperator implements Operator { @Override public Value operate(Value value, Value value2) { + if (value instanceof Value.DoubleValue && value2 instanceof Value.LongValue) { + return new Value.BooleanValue(value.asDouble() != value2.asDouble()); + } + if (value instanceof Value.LongValue && value2 instanceof Value.DoubleValue) { + return new Value.BooleanValue(value.asDouble() != value2.asDouble()); + } if (!value.type().equals(value2.type())) { return new Value.BooleanValue(false); }