From 01f264e0c2e4445a2c3c3bf84a1d1c028708b32e Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Fri, 28 Oct 2022 10:35:22 +0300 Subject: [PATCH] Fix color setters --- src/interpreter_lib.cc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/interpreter_lib.cc b/src/interpreter_lib.cc index 47a9152..ca61997 100644 --- a/src/interpreter_lib.cc +++ b/src/interpreter_lib.cc @@ -1465,8 +1465,9 @@ static void opSetTextColor(Program* program) } for (int arg = 0; arg < 3; arg++) { - if (((value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_FLOAT && (value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_INT) - || value[arg].floatValue == 0.0) { + if ((value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_FLOAT + && (value[arg].opcode & VALUE_TYPE_MASK) == VALUE_TYPE_INT + && value[arg].integerValue != 0) { programFatalError("Invalid type given to settextcolor"); } } @@ -1492,8 +1493,9 @@ static void opSayOptionColor(Program* program) } for (int arg = 0; arg < 3; arg++) { - if (((value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_FLOAT && (value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_INT) - || value[arg].floatValue == 0.0) { + if ((value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_FLOAT + && (value[arg].opcode & VALUE_TYPE_MASK) == VALUE_TYPE_INT + && value[arg].integerValue != 0) { programFatalError("Invalid type given to sayoptioncolor"); } } @@ -1519,8 +1521,9 @@ static void opSayReplyColor(Program* program) } for (int arg = 0; arg < 3; arg++) { - if (((value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_FLOAT && (value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_INT) - || value[arg].floatValue == 0.0) { + if ((value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_FLOAT + && (value[arg].opcode & VALUE_TYPE_MASK) == VALUE_TYPE_INT + && value[arg].integerValue != 0) { programFatalError("Invalid type given to sayreplycolor"); } } @@ -1546,8 +1549,9 @@ static void opSetHighlightColor(Program* program) } for (int arg = 0; arg < 3; arg++) { - if (((value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_FLOAT && (value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_INT) - || value[arg].floatValue == 0.0) { + if ((value[arg].opcode & VALUE_TYPE_MASK) != VALUE_TYPE_FLOAT + && (value[arg].opcode & VALUE_TYPE_MASK) == VALUE_TYPE_INT + && value[arg].integerValue != 0) { programFatalError("Invalid type given to sayreplycolor"); } }