Releases: IS4Code/PawnPlus
PawnPlus v1.5.1
PawnPlus v1.5
Locales
Locales and locale-based operations now play a much integral role in the plugin. See here for a more comprehensive guide of how locales are configured and used. Main changes:
- A custom format of the locale name is now used, allowing to specify the encoding and other parameters in addition to the locale name. This allows using Unicode-based locales as well as tweak details of how other operations behave, such as the interpretation of characters outside the ANSI range, the fallback character used when no mapping is available, and so on.
- In addition, the format supports
|
-separated alternatives, to form a single locale name that could be used on multiple platforms (e.g. both Windows and Linux) to select the appropriate supported locale. - This form of locale name can now be used in existing functions such as
str_to_lower
/str_to_upper
, as well as new functions likestr_count_chars
orstr_collation_key
. In practice, this means that different locale-based rules could be applied to individual calls, without usingpp_locale
to modify the global locale.
String formatting and conversions
Thanks to the new locale features, additional enhancements for string formatting and conversions were possible:
- The
str_convert
function can be used to convert from one encoding into another. This can be used to convert an ANSI-encoded string into Unicode, or vice versa. str_format
and other formatting functions now support changing the locale mid-string, in the form of{$enc:identifier}
, applying to the format specifiers that follow it. This can be used to set the default number formatting rules, to perform automaticstr_convert
for strings, etc.- New format selectors were added:
%m
(monetary value) and%t
(time), both using locale-based output format. In addition,x
now supports floats and produces a hex-float when used on a known float value.
Regular expressions
Existing regular expression capabilities were also enhanced with locale support, as well as as a new pattern-matching engine: Lex, inspired by Lua.
- The locale can be specified at the beginning of any pattern by using the syntax
($identifier)
. This affects how the pattern is parsed, as well as what rules are used for matching the pattern. - Support for classes and collations has been improved, taking use of locale-defined ones when possible.
- A new option
regex_percents
can be used, switching from\
to%
as the escape character for any pattern or replacement string. - The
regex_lex
options can be used, setting the alternative Lex engine and pattern syntax. This has several differences (from both usual patterns and Lua):\
is still used as the primary escape character, unlessregex_percents
is used.- Character classes must be used as
\a
,\g
,\c
,\p
,\l
,\u
, and\x
. No other locale-defined classes are possible. - Collation-based and case-insensitive matching is possible through the usual flags, unlike in Lua.
Other
- The project was updated to C++14 and will likely remain at that version for a long time.
- Added
pp_num_amx_vars
to obtain the number ofVar:
instances. - Dynamically calling native functions on the main thread protects against non-critical system errors/signals raised in them.
- Added a few missing functions to the C API, mainly for memory and containers.
- Using
pp_locale_name
on Windows no longer returns empty string afterpp_locale("")
and instead obtains the actual name of the system locale.
PawnPlus v1.4.3
- Added
str_capacity
andstr_reserve
to control the internal string's buffer capacity. str_addr
,var_addr
, and co. now have a second parameter specifying the particular behaviour of strings copied into the dynamic string viaamx_SetString
. For example,amx_buffer_string_auto_fit
allows resizing the string to fit any number of characters inside. Note that not all SA-MP functions useamx_SetString
, so this will only improve interop with those that do.- Added support for reading two special environment variables,
PAWNPLUS_NO_AMX_HOOKS
andPAWNPLUS_NO_FILE_HOOKS
. This allows circumventing Zeex/samp-plugin-crashdetect#127 if the server is launched viaPAWNPLUS_NO_FILE_HOOKS=1 ./samp03svr
orexport PAWNPLUS_NO_FILE_HOOKS=1 ./samp03svr
- Fixed
pawn_try_call_native_msg
and similar functions to correctly load their arguments.
PawnPlus v1.4.2
-
Unifies the result of
str_addr
andstr_buf_addr
(andvar_addr
andvar_buf_addr
) so that both functions can be used interchangeably.AmxStringBuffer:
(andstr_buf_addr
) should still be used in situations where the implementation of the native is known to rely on the value being an actual address of the character data, but it is valid to be used instead ofstr_addr
in all situations.Please note that the address returned from
str_addr
andstr_buf_addr
is meant to be temporary, only to be used for the native for which it was created for. and might become unusable sooner than in the previous versions. -
pp_max_recursion
now returns the old value. -
pp_toggle_exec_hook
can be used to disable modifications to the AMX execution, at the cost of making certain advanced features (like async, threading, custom callbacks etc.) unavailable.
PawnPlus v1.4.1
Additions
- (
task_
)await_str
(_s
) (#49 from @Se8870). handler_inverted_return
for compatibility with y_hooks (#52 from @AGraber).math_random_generator
(and therandom_generator
enum) to set the concrete generator for random functions.
Changes
pawn_on_init
andpawn_on_exit
use shorter names internally, allowing 7 characters longer identifiers. Scripts do not have to be recompiled.- Random generation was changed to guarantee consistency on both Windows and Linux. The default generator is now
generator_mt19937
(used to begenerator_minstd_rand0
on Linux). See this article for more details on how random number generation works between compilers. Consistency of generated numbers with previous versions is not guaranteed!
Fixes
- Fixed the use of
tagof
andsizeof
in parameters for older compilers with YSI (see #48). regex_cached_addr
verifies that the memory location was not destroyed.str_set_format
allows using the target string during the formatting before it is replaced.- Fixed the
amx_FindPublic
hook to hide new callbacks fromamx_NumPublics
called inside the original function. - Fixed custom callbacks calls when
amx_Exec
has nullretval
. (#53 from @AGraber).
Note: Starting from this release, the "-static" binary is compiled on a different machine than before and may not work on old systems.
PawnPlus v1.4
Additions
- Added the possibility to register and handle a custom format selector, including the
str_register_format
andstr_get_format_tag
functions and thetag_op_format
tag operation. More here. str_val_*
functions have a newformat
string parameter to use the format operation instead of string conversion. The value corresponds to a format specifier instr_format
.- An expression (in
{
,}
) instr_format
may be followed by a format specifier like an argument substitution. - Added
tag_set_op_expr
to allow handling a tag operation with an expression. - Added
regex_start_at_pos
to treat thepos
argument as an absolute start of the string (for^
). - All families of functions that accept variant parameters now also accept dynamic strings natively.
- Added
pp_daytime
to obtain the time of day in milliseconds.
Changes
- The
d
format selector does not necessarily imply signed integer conversion when applied on tagged values, only "decimal", meaning it can be used onFloat:
andunsigned:
. str_format
and similar functions treat a sole"%s"
format string specially and do not use a tag operation, primarily to speed-up the case of appending a single string viastr_append_format
.- Functions that do not return a meaningful value are marked with
unit:
in the include. This does not denote an actual tag, only that the function always returns 1 (or raises an error on failure). task_set_error
raises an error when used with a non-error code.var_delete
raises an error when used on an invalid variant reference.- The debug module on Windows now also hooks
CreateFileW
in addition toCreateFileA
to accomodate for different host environments. It is now also restricted to.amx
files. This could affect plugins that useCreateFileA
to open a file, then close the file and expect the file to be immediately available withCreateFileW
again, or that useCreateFileW
to open a file, close it and then try to open it in another thread. The lifetime of all prolonged handles still ends with the next tick, and now also when an AMX is fully loaded.
Fixes
ConstStringTag:
is used instead ofStringTag:
in a couple of places.- Fixed assertion error on an invalid format specifier.
- Clearing containers properly invalidates their iterators.
- Fixed a crash on exit related to unsetting the locale.
- Fixed assertion error when
regex_cached_addr
is used on a dynamic string. - Added missing
tag_uid_amx_guard
to the include. tag_call_op
now also supportstag_op_handle
.iter_set_*
is now regarded as cell-returning in metadata.- Fixed a potential memory leak on
amx_commit
(thanks @GermanAizek).
PawnPlus v1.3.2
- Newly added callback handlers are not called from the same callback handler for the current callback.
- Do not extend the lifetime of the last opened file (used by the debug module) indefinitely, preventing locking files for external access.
- Added fallback for trampoline creation for
CreateFileA
/fopen
, fixing crashes on some platforms.
PawnPlus v1.3.1
expr_parse
supports hex escape sequences for producing any character cell via its numeric value. The syntax is\xXX
or\uXXXXXXXX
.- Removing a callback handler from a callback handler no longer stops other handlers from executing or causes crashes when
false
is returned. pp_module_name
fixed for Linux.- subhook has been updated to the latest version, hopefully solving crashes on some platforms.
PawnPlus v1.3
Additions:
map_new
andpool_new
allow specifying the ordered state at creation.bool:stay
parameter foriter_erase
specifying the iterator shouldn't move to the next element. Usable in loops. Newiter_empty
function, also usable viaoperator!
.var_iter
accepts count like initer_repeat
.handle_iter
added.- Task-related optimizations.
Fixes:
- Cloning a pool doesn't reassign the indices.
- Cloning a map or a pool preserves its ordered state.
- Deep clear of some containers doesn't delete them anymore.
PawnPlus v1.2.1
math_try_round
,math_try_floor
,math_try_ceiling
, andmath_try_truncate
for when the result might not fit in a 32-bit integer.- Missing tags added to
PP_ALL_TAGS
. start
parameter instr_get
is actually used.- Fixed a potential crash when
*_delete_deep
is called on an ordered pool.