Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## 5.3.0
## 5.3.1
- added commands for missing float math operations:
- **[FLOAT_ADD](https://library.sannybuilder.com/#/sa/script/extensions/math/2709)**
- **[FLOAT_SUB](https://library.sannybuilder.com/#/sa/script/extensions/math/270A)**
- **[FLOAT_MUL](https://library.sannybuilder.com/#/sa/script/extensions/math/270B)**
- **[FLOAT_DIV](https://library.sannybuilder.com/#/sa/script/extensions/math/270C)**

## 5.3.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer doing changelog in one pass before the release

- moved CLEO core and plugin settings into a shared configuration file (`CLEO\.cleo_config.ini`)
- improved compatibility with ModLoader
- refactored error handling and relaxed checks for non‑critical errors
Expand Down
52 changes: 52 additions & 0 deletions cleo_plugins/Math/Math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class Math
CLEO_RegisterOpcode(0x2706, opcode_2706); // pick_random_float
CLEO_RegisterOpcode(0x2707, opcode_2707); // pick_random_text
CLEO_RegisterOpcode(0x2708, opcode_2708); // random_chance
CLEO_RegisterOpcode(0x2709, opcode_2709); // x = a + b (float)
CLEO_RegisterOpcode(0x270A, opcode_270A); // x = a - b (float)
CLEO_RegisterOpcode(0x270B, opcode_270B); // x = a * b (float)
CLEO_RegisterOpcode(0x270C, opcode_270C); // x = a / b (float)
}

// 0A8E=3,%3d% = %1d% + %2d% ; int
Expand Down Expand Up @@ -522,4 +526,52 @@ class Math
OPCODE_CONDITION_RESULT(result);
return OR_CONTINUE;
}

// 2709=3,%3d% = %1d% + %2d% ; int
static OpcodeResult __stdcall opcode_2709(CRunningScript* thread)
{
auto a = OPCODE_READ_PARAM_FLOAT();
auto b = OPCODE_READ_PARAM_FLOAT();

auto result = a + b;

OPCODE_WRITE_PARAM_FLOAT(result);
return OR_CONTINUE;
}

// 270A=3,%3d% = %1d% - %2d% ; FLOAT
static OpcodeResult __stdcall opcode_270A(CRunningScript* thread)
{
auto a = OPCODE_READ_PARAM_FLOAT();
auto b = OPCODE_READ_PARAM_FLOAT();

auto result = a - b;

OPCODE_WRITE_PARAM_FLOAT(result);
return OR_CONTINUE;
}

// 270B=3,%3d% = %1d% * %2d% ; FLOAT
static OpcodeResult __stdcall opcode_270B(CRunningScript* thread)
{
auto a = OPCODE_READ_PARAM_FLOAT();
auto b = OPCODE_READ_PARAM_FLOAT();

auto result = a * b;

OPCODE_WRITE_PARAM_FLOAT(result);
return OR_CONTINUE;
}

// 270C=3,%3d% = %1d% / %2d% ; FLOAT
static OpcodeResult __stdcall opcode_270C(CRunningScript* thread)
{
auto a = OPCODE_READ_PARAM_FLOAT();
auto b = OPCODE_READ_PARAM_FLOAT();

auto result = a / b;

OPCODE_WRITE_PARAM_FLOAT(result);
return OR_CONTINUE;
}
} Instance;
22 changes: 22 additions & 0 deletions tests/cleo_tests/Math/0A8E.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name '0A8E'
test("0A8E (int_add)", tests)
terminate_this_custom_script


function tests
it("should sum two ints", test1)
return

function test1
int a = 10
int b = 40
int c = 80
c = a + b
assert_eq(a, 10)
assert_eq(b, 40)
assert_eq(c, 50)
end
end
22 changes: 22 additions & 0 deletions tests/cleo_tests/Math/0A8F.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name '0A8F'
test("0A8F (int_sub)", tests)
terminate_this_custom_script


function tests
it("should substract two ints", test1)
return

function test1
int a = 10
int b = 40
int c = 80
c = a - b
assert_eq(a, 10)
assert_eq(b, 40)
assert_eq(c, -30)
end
end
22 changes: 22 additions & 0 deletions tests/cleo_tests/Math/0A90.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name '0A90'
test("0A90 (int_mul)", tests)
terminate_this_custom_script


function tests
it("should multiply two ints", test1)
return

function test1
int a = 10
int b = 40
int c = 80
c = a * b
assert_eq(a, 10)
assert_eq(b, 40)
assert_eq(c, 400)
end
end
22 changes: 22 additions & 0 deletions tests/cleo_tests/Math/0A91.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name '0A91'
test("0A91 (int_div)", tests)
terminate_this_custom_script


function tests
it("should divide two ints", test1)
return

function test1
int a = 40
int b = 10
int c = 80
c = a / b
assert_eq(a, 40)
assert_eq(b, 10)
assert_eq(c, 4)
end
end
22 changes: 22 additions & 0 deletions tests/cleo_tests/Math/2709.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name '2709'
test("2709 (float_add)", tests)
terminate_this_custom_script


function tests
it("should sum two floats", test1)
return

function test1
float a = 10.0
float b = 40.0
float c = 80.0
2709: c = a + b
assert_eqf(a, 10.0)
assert_eqf(b, 40.0)
assert_eqf(c, 50.0)
end
end
22 changes: 22 additions & 0 deletions tests/cleo_tests/Math/270A.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name '270A'
test("270A (float_sub)", tests)
terminate_this_custom_script


function tests
it("should substract two floats", test1)
return

function test1
float a = 10.0
float b = 40.0
float c = 80.0
270A: c = a - b
assert_eqf(a, 10.0)
assert_eqf(b, 40.0)
assert_eqf(c, -30.0)
end
end
22 changes: 22 additions & 0 deletions tests/cleo_tests/Math/270B.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name '270B'
test("270B (float_mul)", tests)
terminate_this_custom_script


function tests
it("should multiply two floats", test1)
return

function test1
float a = 10.0
float b = 40.0
float c = 80.0
270B: c = a * b
assert_eqf(a, 10.0)
assert_eqf(b, 40.0)
assert_eqf(c, 400.0)
end
end
22 changes: 22 additions & 0 deletions tests/cleo_tests/Math/270C.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name '270C'
test("270C (float_div)", tests)
terminate_this_custom_script


function tests
it("should divide two floats", test1)
return

function test1
float a = 10.0
float b = 40.0
float c = 80.0
270C: c = a / b
assert_eqf(a, 10.0)
assert_eqf(b, 40.0)
assert_eqf(c, 0.25)
end
end
Loading