Header lib: refactor inven_as_array and add proper jsdoc defs to all comments

- inven_as_array was allocating blocks of 100 items which was unnecessary
This commit is contained in:
NovaRain
2024-05-20 20:20:56 +08:00
parent 3c8ec03e30
commit 0746d6b483
6 changed files with 237 additions and 61 deletions
+15 -1
View File
@@ -16,9 +16,23 @@ end
#define math_max(x, y) (x if x > y else y)
#define math_min(x, y) (x if x < y else y)
/**
* Returns true if x is within range: [from, to]
* @arg {any} x
* @arg {any} from
* @arg {any} to
* @ret {bool}
*/
#define math_in_range(x, from, to) (x >= from and x <= to)
/**
* Returns: a if val < a, b if val > b, otherwise val.
* @arg {any} val
* @arg {any} a
* @arg {any} b
* @ret {any}
*/
procedure math_clamp(variable val, variable a, variable b) begin
variable min, max;
if (a < b) then begin