Skip to content

Releases: IS4Code/PawnPlus

PawnPlus v1.2

10 Oct 11:34
Compare
Choose a tag to compare
  • list_sort_expr added for sorting lists based on an expression.
  • math_random_seed added to configure the random generator; the initial seed is also different each time.
  • pawn_add_filter pushes the addresses of arguments directly if possible.
  • Various fixes regarding callbacks, AMX initialization, and incorrect parameter counts.

PawnPlus v1.1

09 Aug 12:47
Compare
Choose a tag to compare

Additions

Pools

  • A new type of collection providing support for efficient storage of data using reusable integer indices.
  • When an element is added to a pool, it gets assigned an index which is then used to refer to the element.
  • Pools come in two versions with the same API – ordered (new indices are assigned in a specific order), and unordered. Ordered pools will always assign the lowest unused index to a newly added element.
  • A pool can grow to any size if there are no unused slots for new elements.

Expressions

  • Dynamic run-time representations of operations.
  • Can be constructed from components in a tree-like manner, or parsed from string with expr_parse.
  • The parser supports all standard Pawn operators and some PawnPlus-specific ones. It can also find and use non-public Pawn variables (via the debug API).
  • Expressions can be used in collections and new types of iterators to easily perform queries on multiple elements.

Async

  • async pseudo-attribute for functions using the async pattern (together with return async).
  • The await macro has an alternative definition supporting multiline expression, but requires additional configuration for all tags (enabled via PP_MULTILINE_AWAIT).
  • await_arr and await_var added.

Collections

  • The API is now more unified, so all collections have roughly the same functions with the same semantics.
  • The capacity of the underlying container can be obtained.

Strings

  • If {} is used in str_format and it doesn't correspond to a color code or a parameter selector, it is parsed and executed as a piece of code.
  • %f in str_format accepts a width parameter.
  • str_append_format added.

Pawn and AMX

  • pawn_create_callback can be used to create a new callback/public function and attach it to the current script. The function consists of an expression that is executed every time the public function is called.
  • Declarational initializers and finalizers added. Any public function whose name starts with _pp@on_init@ will be called first before every other function, when the script is loaded. Any function whose name starts with _pp@on_exit@ will be called last after all other functions, when the script is unloaded. Macros pawn_on_init and pawn_on_exit can be used for easy creation of these functions.
  • AMX guards introduced. While a Pawn guard protects the object for the duration of the current context (analogous to a local variable), an AMX guard protects it for the duration of the script (analogous to a global/static local variable).
  • Handling public function index incompatibility with SAMPGDK can be resolved by pp_public_min_index or pp_use_funcidx. Callback handlers can be registered for negative indices.
  • Captured arguments (in pawn_register_callback or pawn_add_hook) now accept v, h, and x as new types of values. v corresponds to a Variant: argument which is copied to the closure and loaded when it is restored, h corresponds to a Handle: argument which is prolonged by the closure (so the underlying object is not destroyed) and whose value is loaded when the closure is restored, and x corresponds to an Expression: argument containing an expression which is executed every time the argument is restored.

Error handling

  • Dynamically called external natives that raise a system error/signal do not crash the server, but are handled and reported via PawnPlus errors.

C API

  • Support for errors and serialization.

Changes

Error handling

  • pp_on_error is only called for a native called directly by the script. Errors in internally called natives are handled or propagated by the code that called them. pawn_try_call_native never invokes pp_on_error.

Collections

  • Iterators are invalidated on addition only when necessary (when the underlying buffer needs to be reallocated).

Variants

  • Calling operations on variables that are incompatible (different tags or sizes) now produces an error (used to return null).

Math

  • Dynamically called operations on signed: and unsigned: values can raise an error.

Pawn and AMX

  • Incorrect public function index caused by SAMPGDK is detected and warned about.

Fixes

Variants

  • collect operation is now correctly called in some places.

Async

  • When a context is stored after a call to an asynchronous function, reset_stk and reset_hea are now used to correctly restore the original values of stk and hea, fixing a memory leak that happened when a public function with parameters was stored (because the parameters were not taken into account when stk was restored).

Math

  • signed: and unsigned: subtraction fixed.

Error handling

  • Allocation of more data than the script supports is prevented.

Pawn and AMX

  • Removing a hook handler when it is running will not crash the server.

Examples

Format expressions

new val1 = 5, val2 = 10;
print_s(str_format("the sum of {val1} and {val2} is {val1 + val2}"));

Queries

new Map:m = map_new();
map_add(m, 1, 10);
map_add(m, 2, 21);
map_add(m, 3, 30);
map_add(m, 4, 41);
map_add(m, 5, 50);
    
map_remove_if(m, expr_parse("10*$key != $value")); //removes 2 and 4

Caching expressions

static Expression:expr;
if(!expr)
{
    expr = expr_parse("$value*$value");
    amx_guard(expr);
}

Declarational callback handler

pawn_on_init[callback1]
{
    new id = pawn_create_callback("OnPlayerConnect", expr_const(0));
    pawn_register_callback(amx_encode_public(id), "MyOnPlayerConnect");
}

PawnPlus v1.1-pre2

21 Jul 19:28
Compare
Choose a tag to compare
PawnPlus v1.1-pre2 Pre-release
Pre-release

Containers

  • All containers received new functions used in combination with expressions like count_if, find_if, and remove_if.

Strings

  • str_append_format added, mainly for constructing dialogs from lines.

Miscellaneous

  • Incorrect public function index caused by SAMPGDK is detected and warned about.
  • pawn_create_callback is finally added to dynamically add public functions to the script.
  • amx_guard and co. added to complement pawn_guard etc. The guarded object is bound to the AMX instance and is deleted when the script is unloaded.

Variants

  • Calling operations on variables that are incompatible (different tags or sizes) now produces an error (used to return null).

Errors

  • pp_on_error is only called for a native called directly by the script. Errors in internally called natives are handled or propagated by the code that called them. pawn_try_call_native never invokes pp_on_error.
  • Dynamically called external natives that raise a system error/signal do not crash the server, but are handled and reported via PawnPlus errors.

Expression

  • The parser is now more configurable. Various pieces of syntax can be disabled.
  • Several intrinsic functions were added to the parser, like cast, concat, or eval.
  • Expressions can now return multiple values. expr_select and expr_where were added to work with multiple values. Comma operator returns all produced values or the last one, depending on context.
  • Native call expression recovers the original tag from native functions that work with variants.
  • Too deep recursion when executing expressions is detected and stopped.
  • The expression environment and AMX instance can be unset.
  • Environment maps are no longer kept alive by expressions or iterators.
  • Public variables are supported.
  • expr_func is available if YSI is included, allowing construction of expressions from inline functions/lambdas.

PawnPlus v1.1-pre

22 Jun 14:14
Compare
Choose a tag to compare
PawnPlus v1.1-pre Pre-release
Pre-release

Pools

  • A new data type optimized for fast access to a set of elements via a stable index.
  • Comes in two versions with the same API – ordered (new indices are assigned in a specific order), and unordered.
  • Unused slots are filled by newly created elemenets, or the pool grows to any capacity if no slots are available.

Expressions

  • Tree-like immutable structures for dynamic representations of operations on variants.
  • Supports various types of expressions and operations.
  • Expressions can be parsed from their string representations.
  • str_format is modified to accept a string expression which is parsed and executed.

Async

  • The await macro has an alternative definition supporting multiline expression, but requires additional configuration for all tags (enabled via PP_MULTILINE_AWAIT).
  • await_arr for obtaining arrays from tasks easily.
  • async pseudo-attribute for functions using the async pattern (together with return async).

Containers

  • All containers received functions for obtaining or changing their capacity.
  • Iterators to many containers are invalidated only when it is necessary (e.g. adding an element to a list when the buffer doesn't have to be reallocated).
  • New iterator types for filtering or projecting elements based on an expression.

Miscellaneous

  • Regular expressions can be cached by their address in the respective script (assuming they are constant).
  • collect operation is now correctly called in some places.
  • pp_tick for simulating server ticks.
  • Handling public function index incompatibility with SAMPGDK can be resolved by pp_public_min_index or pp_use_funcidx. Callback handlers can be registered for negative indices.

C API

  • Support for errors and serialization.

PawnPlus v1.0.1

18 Jun 10:04
Compare
Choose a tag to compare
  • Fixed an issue with callback handlers when a handled callback incorrectly restored the original arguments on the stack even though no other handler could be executed and pop them off.

PawnPlus v1.0.0

20 Apr 09:30
Compare
Choose a tag to compare

Miscellaneous

  • pp_version, pp_version_string, pp_raise_error, pp_module_name.
  • Locale-specific functions can be configured with pp_locale (affects things like str_to_upper and regex).
  • AMX subhook variables are no longer exported.
  • All natives that take an address inside the AMX memory check its validity.

Handles

  • Several new functions to control the activity of handles.
  • Handles are now immutable.
  • All GC-objects can provide their lifetime handle.

Pawn API

  • pawn_nameof macro can be used to convert a symbol or a tag name to a string (with checking).
  • pawn_cast macro (invokes implicit tag conversion operator).
  • pawn_try_call_native and pawn_try_call_public (suppress and return errors).
  • pawn_native_exists, pawn_native_imported, pawn_public_exists.

AMX API

  • amx_tailcall can replace the caller stack frame with the current stack frame.
  • amx_handle to control the lifetime of an AMX instance.
  • A function can be called in any AMX instance via amx_call_native/amx_call_public.
  • Additional support for native and public functions inspection.
  • Public and native functions names can be encoded in a two-cell packed string via amx_encode_public_name and amx_encode_native_name for faster calling. Custom values can also be specified.

Errors

  • Unhandled C++ exceptions in natives will be caught and reported.
  • Fixed several bugs related to error handling and conflicts with SAMPGDK.

Strings

  • Regular expressions (match, extraction, replacement).
  • str_format upgraded with new specifiers and syntax for positional arguments.
  • All functions now accept packed strings as well.
  • ConstAmxString added.

Variants

  • var_addr can be used for interop with native functions, similarly to str_addr.
  • Empty array variants are now recognized and produced instead of null variants.

Debug API

  • A multitude of functions to access the debug information produced by the Pawn compiler (at least -d2 is necessary).
  • Allows inspecing all variables and functions. Can be used to set variables (local or global) or to call any Pawn function.

Containers

  • Reduced unnecessary copying of objects.
  • Functions like list_new_args now store all the tags correctly.
  • list_resize, list_find, list_find_last, list_sort.
  • Variants and iterators have functions for both single-dimensional and multi-dimensional access to stored arrays.
  • Simple iterators: iter_range, iter_repeat, var_iter.
  • *_remove_deep and iter_erase_deep (removes the element and releases the object).
  • iter_swap, iter_can_reset, iter_can_insert, and iter_can_erase.

Tasks

  • task_detach useful for fire-and-forget calls. Creates a new context, so inner asynchronous calls will not pause the caller functions.

Threads

  • thread_fix to synchronise the function with the main thread, if called from another. Useful for code called from RCON or console.

Math API

  • Functions for signed and unsigned arithmetics (with overflow checks). signed: and unsigned: tags for simple usage.
  • math_random, math_random_float, math_round, math_floor, math_ceiling, math_truncate

C API

  • A simple mechanism for manipulating PawnPlus from other plugins.
  • Supports addons, tags, strings, variants, lists, linked lists, and maps.
  • Include ppcommon.h.

PawnPlus v1.0.0-pre4

17 Apr 00:46
Compare
Choose a tag to compare
PawnPlus v1.0.0-pre4 Pre-release
Pre-release
  • iter_range_str, iter_repeat_str.
  • iter_swap, iter_can_reset, iter_can_insert, iter_can_erase.
  • Iterator movement functions return ITER_NULL on failure. Other functions raise an error.
  • Debug functions for array manipulation.
  • amx_tailcall corrected.
  • Encoding additional values to public/native names.
  • *_clear_deep for containers.
  • bool: return tag removed from functions that didn't use it.
  • math_random_unsigned.
  • All regex functions received a pos parameter for easier iteration.
  • Regex replacement string accepts \ in addition to $.
  • Task and handle C API.

PawnPlus v1.0.0-pre3

07 Apr 23:56
Compare
Choose a tag to compare
PawnPlus v1.0.0-pre3 Pre-release
Pre-release
  • The Linux version is now correctly linked against GLIBCXX_3.4.20.
  • AMX functions for public and native inspection.
  • amx_encode_public_name and amx_encode_native_name can be used to produce a short string that identifies a public or a native function. Using the string instead of a function name bypasses name lookup.
  • Unaligned packed strings (coming from plugins) can now be used.
  • debug_symbol_indirect_call and debug_symbol_try_call (creates a new context).
  • {^:format} syntax for positional arguments in str_format.
  • str_format ignores valid color codes in the format string.
  • str_replace_list and str_replace_func that replaces different regex groups with a different value, or calls a function passing all groups to provide the replacement dynamically.
  • C API finished: strings, variants, and addons (pointers with a string key).
  • An incompatibility with SAMPGDK caused pp_on_error to be called even when not defined, suppressing errors.

PawnPlus v1.0.0-pre2

01 Apr 01:26
Compare
Choose a tag to compare
PawnPlus v1.0.0-pre2 Pre-release
Pre-release

News from v1.0.0-pre:

  • Natives for obtaining PawnPlus version.
  • print_s native implementation.
  • VAR_NULL, STRING_NULL, ITER_NULL, and HANDLE_NULL are usable in more places.
  • Added a distinction between empty variants and null variants; the former can be now returned from collections.
  • Natives for setting multidimensional arrays via iterators and changing a cell range inside a variant.
  • Packed strings are now accepted equally to unpacked ones in all places.
  • Natives for modifying the global locale settings; affect functions like str_to_lower and regex.
  • str_format and co. upgraded; now supports more specifiers, positional arguments, different formatting styles, and locale-based customisation.
  • Generic pawn_cast.
  • Invalid addresses passed to natives are checked and reported with better accuracy.
  • AMX hook system modified to (hopefully) prevent collisions on Linux with other plugins that use the same method.
  • Fixed a crash on Windows related to crashdetect not being present.
  • Fixed range checks of debug symbol index.

PawnPlus v1.0.0-pre

24 Mar 14:24
Compare
Choose a tag to compare
PawnPlus v1.0.0-pre Pre-release
Pre-release