Commit graph

356 commits

Author SHA1 Message Date
turleypol
7ff9d877a8
Funcrefs do not detect pid change (#889)
* test for sending a function to the same program

* store executor pid inside funcrefs and classes

* docs
2026-05-31 11:45:35 +02:00
turleypol
552248917b
Fixed leak when a class/funcref is a global (#887)
* store globals as weakptr in class/funcs to prevent memleak when stored
as global WIP

* let it crash if globals are no longer valid?

* typo

* removed debug prints

* let only the current executor crash

* fixed logic

* added and corrected tests

* cleanup

* use emplace_back

* classes also need to switch to weakptr

* docs
2026-05-27 08:02:19 +02:00
Kevin Eady
6d748af2df
Add module function party::ListParties() (#886)
* implementation

* tests

* docs
2026-05-23 08:27:16 +02:00
turleypol
19f1049973
fixed problem when sending vitals bigger then 0xffff to other clients (#877)
* fixed problem when sending vitals bigger then 0xffff to other clients.
The percent value was calculated based on the already capped values

* directly use the correct type

* docs
2026-05-14 11:41:09 +02:00
AsY!um-
04a8a2ba11
Restore NPC cold_resist_cap from its own orig value on refresh_ar (#880)
* Restore NPC cold_resist_cap from its own orig on refresh_ar - tests

* Restore NPC cold_resist_cap from its own orig on refresh_ar - actual fix

* Update core-changes and make comments more concise
2026-05-10 15:43:03 +00:00
turleypol
2451034279
print starting line number when loading fails (#876) 2026-04-22 20:42:20 +02:00
turleypol
71c77723b6
Don't send statmsg pkt on every equipped item when refreshing ar (#875)
* do not send full_statmsg for each equipped item while refreshing armor

* added test

* docs
2026-04-22 14:52:48 +02:00
turleypol
a1864581a0
Use mariadb connector as a replacement for mysqlconnector (#872)
* silence cppdap lib

* refornat curl flags for readabilty

* zlib was build with the wrong runtime mode. Updated version

* use mariadb connector instead of mysql

* removed mysql define

* removed mysql

* removed installation of mysqlclient in workflow runs

* fixed curl install dir

* missing zstd on macos

* fixed module parsing for cmake 4.x

* docs

* added mariadb build to tidy_pr_check

* test sql on all platforms
some plugins need to included on windows
2026-03-30 22:50:24 +02:00
turleypol
5bd71ae8ee
Non blocking gump cmd (#871)
* refactor gump pkt creation

* testclient returns buttonid 1 pressed when 'button' is contained in the
commands

* extended test

* cleanup destructor mess a bit

* store gumps as pair to decide if the executor needs to be revived
more refactoring

* disallow copy, if used creates nasty bugs

* helper method to convert imp to character

* gumpevent

* new non-blocking dialog function, sends event instead

* test closegump

* test if serialnumber gets correctly converted and invalid entries get
skipped

* removed unused BApplicPtr class
added BApplicObjBase to impptrIf convert function

* use impptrIf

* CloseGump accepts now also an array of characters
extended tests

* moved deleted copy constructor to the public part

* by default clang tidy will check .inc files, removed this filter

* the last tidy run with modernize-loop wasnt added to the PR check

* keep vector with chr and gumpid per uomod
to prevent growing dont add to the cache if same chr with same id
already exists.

* docs

* core-changes
2026-03-16 08:11:43 +01:00
Kevin Eady
a4ef957803
Fix handling of AlternateMultiID in boat item descriptor structs (#869) 2026-03-09 17:22:13 +01:00
turleypol
f1787dea78
dont use a static buffer for reading cfgfile to be threadsafe (#868)
* dont use a static buffer for reading cfgfile to be threadsafe

eg config/www.cfg can load in the background
cleanup the file: deleted ancient define, simplified logic

* docs
2026-03-07 13:01:56 +01:00
turleypol
97fb7ffb04
Uoconvert the wrong coordinates where shown when a block contains more then the allowed number of items (#866)
* uoconvert: fixed wrong coordinates error msgs when too many static items exist in a
block

* fix gcc?

* since we have it.. use the correct literal

* fixed wrong format and warning

* docs and slightly changed msgs

* addressed comments
2026-02-23 06:59:08 +01:00
turleypol
593f547b73
active development is now 100.3 (#865) 2026-02-16 20:37:42 +00:00
turleypol
db532435d2
Release Pol v100.2.0 (#864) 2026-02-16 19:40:49 +00:00
turleypol
da2943acb8
Tidy copy initialization (#859)
* trigger tidy

* copy&move BApplicPtr obj
always commit tidy changes

* move PolObject

* fix house add_component

* Automated clang-tidy change: performance-unnecessary-copy-initialization,performance-unnecessary-value-param

* Revert "Automated clang-tidy change: performance-unnecessary-copy-initialization,performance-unnecessary-value-param"

This reverts commit bb6aab13dbdfa4aaf420cdaafaf22940f241fc5b.

* performance-unnecessary-value-param gives some weird suggestions

* Automated clang-tidy change: performance-unnecessary-copy-initialization

* minor performance improvements

* added used tidy check

* missing dependency

* renamed build so its no longer requires?

* better add docs for the sneaky fix

* silence pr check, not all headers can be compiled seperatly

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>
2026-01-19 08:17:28 +01:00
Lukáš Novotný
cf0346780b
do not include full program in funcref memory estimate (#856) 2026-01-17 18:44:02 +01:00
turleypol
0259f11475
Class method if it's a method_id call now works if parameters are given (#849)
* modifed test to trigger the failure

* getParams modifies the ValueStack and thus cannot be called twice.

* docs
2026-01-10 18:12:09 +01:00
turleypol
37bbf0acd2
Fixed method_id call for class methods (#840)
* method-id calls on classes need to be redirected to non-id instruction

* added corechanges

* fixed compiler warning
2026-01-10 10:18:58 +00:00
turleypol
9daf269db5
Dynamic items with height 0 didn't block los like the static version (#848)
* dynamic items with height 0 (floor) didnt blocked LOS like static items
does
optimized los check by using multimap for faster lookup of dynamic items
added test

* revert multimap usage, benchmark showed that the original solution is
way faster

* docs
2026-01-10 10:52:03 +01:00
turleypol
bf4ec1951d
Write filenames and lines into ecompile .lst files (again) (#846)
* ListingWriter prints filepath, filelineno and source line
the old compiler did it, now again in the new compiler
since shortcircuit the original sourcelines are available during compilation

* remove listfile.inc function from test result

* prefix output

* custom formatting

* docs
2026-01-07 22:19:25 +01:00
turleypol
58a6db75be
Integer overflow when using GetConfigInt (#844)
* impptr_if now accepts also const BObjectImp*

* cfg::GetConfigInt returns error if the value would produce an overflow
code cleanup of cfgmod
added tests

* increase test coverage

* added comment why the exception should be catched without reaction
fixed member_id test

* added corechanges
its 2026
removed else
2026-01-04 13:22:11 +01:00
Lukáš Novotný
ec90c8e669
do not send warmode change to clients who cant see the character (#839)
* do not send warmode change to clients who cant see the character

* update corechanges
2026-01-01 12:10:07 +01:00
Fernando Rozenblit
c9eeba30f7
Add https to docs links (#838) 2025-12-29 09:46:15 +01:00
Kevin Eady
0790397c8a
Fix parsing issue introduced with regular expressions when using floating-point dividends (#832)
* do not allow regex after a float token

* docs
2025-12-14 19:44:13 +01:00
Reloecc
d0df64becf
DiscardedWaterTiles config for uoconvert (#830) (#831)
Added uoconvert.cfg element StaticOptions extended by DiscardedWaterTiles. Lists
the tiles that will be discarded during the processing of solid statics, where
the map is at or below the same Z level as the static, allowing boats to bump
into shores. Defaults to tiles in the range from 0x1796 to 0x17B2 if not present
in the config file.
2025-12-14 17:55:55 +01:00
turleypol
e6340689d7
Fix sending of new objects for boat travellers and observers (#829)
* added debugs for boatmove

* log component send

* added option to resend components

* compilation fix

* activate by default

* cleanup fix no1
more debug logs

* test client now ignores/removes objects out of range
lets see what explodes

* syntax fix

* syntax fix..

* need a copy of the keys

* handle equipped items

* handle server side view range change

* test char on boat and move to npc

* compilation fix?

* more logs

* corrected logs

* the boat needs to move more

* change order, first smooth move then new objects

* correct fix I think
send new objects for all newer clients on the boat after the boat pkt is
send (which also updates the position for the client)

* cleanup, fixed first test by sending also the playerposition when a new
obj appears

* test for item on boat

* need to move the boat further so that components are in range

* is the test wrong or is it a bug?

* move further

* ability to disable auto delete of objects to be able to test serverside
remove pkts

* change start position of the boat

* cleanup and fixed tests?

* more cleanup

* docs
2025-12-14 11:58:48 +01:00
Kevin Eady
7bc59bb2fa
Pass OfflineCharacterRef for equip, unequip scripts character parameters (#827)
* use offline char ref for equip, unequip scripts

* add Character script member logged_in; docs; tests

* update core-changes for Character script member logged_in

* Add breaking-changes note
2025-11-19 14:22:39 +01:00
Kevin Eady
5cf6949ea7
Add support for regular expressions (#818)
* implementation

* tests

* maybe fix windows compilation?

* undo change of match_flag_type

* switch to boost regex

* move flags to BRegExp object

* fix tests due to cmake 4 update

* update grammar

* update prettifier

* move flag parsing to BRegExp ctor

* add AST nodes, update instr generation and execution

* copy tests but use regular expression literals

* fix grammar for handling division correctly

* modify return values a bit, update tests
- string.match: make groups hold structs of matched, offset
- string.match: add offset
- string.replace: use a groups array like string.match vs individual arguments

* bundle of changes

- standardize error messages
- add more tests for coverage
- move BRegExp creation to static method:  previous implementation had
  ctor throwing, which was no good inside executor since it didn't have
  a try/catch

* more tests; add OT_REGEXP to basic.em

* move string regex stuff to bregexp and support regex/wregex via std::visit

* maybe fix compilation errors?

* add unicode escape sequence handling

* really maybe fix compilation error?

* fix compiler warnings

* refactor a bit to remove duplicate code

* address discord comments
- just return wstring, no need for vector<wchar_t> method

* Add string.split by string and regexp

* Use Max_Split instead of Limit
This makes it match basic::SplitWords

* add support for empty string delim in SplitWords

* remove duplicate code across string.split and mf_SplitWords

* Squashed commit of the following:

commit b3148e069f
Author: turleypol <turley@polserver.com>
Date:   Sat Sep 27 17:02:22 2025 +0200

    memorylocation of input string is not allowed to changed, switched back
    to uniqueptr

commit 5a4d1c8fcb
Author: turleypol <turley@polserver.com>
Date:   Sat Sep 27 10:18:01 2025 +0200

    no need to use ptr for input

commit 90fa0edc66
Author: turleypol <turley@polserver.com>
Date:   Sat Sep 27 09:56:29 2025 +0200

    fixed typo

commit bed4ff3ac9
Author: turleypol <turley@polserver.com>
Date:   Sat Sep 27 09:47:36 2025 +0200

    make Callback for BContinuation move only

* use uninit when group isn't matched

* fix multiline flag handling; add test

* add docs and doc example tests

* some cleanup

* address review comments
- allow move assignment

* add core-changes
2025-11-17 18:02:45 +01:00
Fernando Rozenblit
77f6b2cc0d
Add error if a config file property has curly braces on its name (#825)
Fixes #445
2025-11-03 19:36:48 +00:00
Fernando Rozenblit
0688e4b8cd
Fix Pushthrough hook description #823 (#824) 2025-11-02 14:07:05 +01:00
Kevin Eady
59046fdc7c
Normalize TypeOf and TypeOfInt return value for ClassInstanceRef (#821)
* implementation

* tests

* docs and core changes

* fix tests due to cmake 4 update
2025-09-29 08:55:48 +02:00
Kevin Eady
c286b49858
Fix handling of byref, rest, and default parameters in uninitialized functions (#814)
* Update grammar

* update prettifier

* Update semantic analysis
- Move checks for 'super' and non-static to semantic analyzer
- Add checks for byref and default

* Add, update tests

* update escript guide, add tests for examples in guide

* update core-changes

* Address Discord comments
- Update core-changes to explicitly talk about default parameters
2025-09-06 17:26:06 +02:00
Kevin Eady
ddc1b5d26b
Add Escript support for uninitialized class functions (#808)
* update grammar

* AST nodes and test

* Address self-review comments
- Replace `super` comment with something more explanatory
- Rename `make_user_function`

* add class analysis for uninit functions

* fix ast test after disallowing static uninit funcs

* use std::ranges::find_if

* add tests

* use SUPER constant; add test

* Remove unreachable code leftover from #809

Since #809, the super function is only generated for a class when
registering a parent class, and therefore it will always have a body. A
"No base class defines a constructor" will only occur if super was never
generated, and is handled in the "No function linked through
FunctionResolver" section of semantic analyzer.

* Address review comments
- use std::ranges::move instead of move iterators
- use std::is_same_v<> vs std::is_same<>::value
- use switch vs chained ternary conditionals

* update escript guide, create tests that are in escript guide

* add core-changes

* Error on uninit and defined constructor

* Move methods' FunctionLink construction to builder

This allows the error message for the uninit function to have a "See
Also" that point to the defined function.

* Move error checks for uninit and defined functions

These semantic checks should be in the ... SemanticAnalyzer.

* fix typo in core-changes
2025-09-05 23:23:59 +02:00
Kevin Eady
e26f356678
Fix generated function (constructor, super) registration (#809)
* move compiler-generated ctor registration to within class declaration registration; update test error messages

* add more ctor inheritance tests

* skip "Unknown identifier" error for calling undefined ctor

* add test for actual, previously crashing source

* add test for actual, previously crashing source

* move compiler-generator super registration to within class declaration registration

* add super local var test

* make register_available_generated_function private

* remove ClassDeclaration::has_super_ctor

This property was based on if FunctionResolver created the function, so
the logic can be moved to FunctionResolver.

* add core-changes

* use constant for "super" string
2025-09-04 17:37:40 +00:00
turleypol
aac4b7dd43
Default script priority changed (#806)
* profile cleanup, time measurement for script scheduler

* missing file

* profiling npc template search makes I think no longer sense

* renamed variable

* fixed namespace

* typo

* maybe now?

* scheduler != tasks ...

* use correct macro

* convert to double

* fixed runlist stats, correctly log delay

* reset statistics each minute

* log standard deviation instead of variance

* mean instruction time

* pol.cfg "DefaultPriority" (default 1)

* changed the correct file and removed leftover files

* reduced output

* changed default prio to 10 and added docs

* online docs

* fixed warning

* removed more leftovers
2025-09-04 18:40:58 +02:00
Kevin Eady
a6d81bbaec
Fix issue with unresolved base class static methods (#807)
* implementation

* tests

* docs
2025-08-24 21:18:17 +02:00
Kevin Eady
0fcc5060af
Enum class fixes (#805)
* fix enum classes entries without initializer

* docs

* update grammar to support scoped identifiers in case labels

* add support for enum class constants in case statements

* add ScopableName to ConstDeclaration; formatting fixes; tests

* update docs
2025-08-19 09:07:02 +02:00
Kevin Eady
003274de55
Add Escript support for enum class (#804)
* update grammar

* implementation

* tests

* docs and core-changes

* cleanup old .cot files

* add error on duplicate class, enum class definition; tests

* Fix compiler warnings

* add test for unscoped identifier failure
2025-08-18 20:50:18 +02:00
Kevin Eady
c029ca4283
Add module function util::RandomUUID() (#803)
* implementation

* tests

* docs

* add uuid_nil, uuid_max

* add support for v4 or v7 uuid generation
2025-08-16 13:39:34 +02:00
turleypol
ba47821156
further optimize shortcircuits (#800)
* further optimize shortcircuits
combine jumps if possible
dont emit logicalconvert instructions if the next instruction is another shortcircuit jump

* docs
2025-08-12 08:52:50 +02:00
turleypol
461c68bf58
fixed order of pkts when changing client view range (#802)
the client should be first informed about the new range, otherwise the
client could drop the newly send objects
2025-08-02 13:19:18 +00:00
turleypol
7090c64840
Short Circuit Optimizer (#797)
* first working short curcuit for && and or
creates jumps after each expressions to skip the following

* fixed valuestack when short circuit jmp does not jump

* use specialized instructions for short circuit && and ||

1: lhs
2: logical jump if false/true goto 4 <- if jmp do logical convert
3: rhs
4: logical convert
5: rest

logical convert is needed since "normal" && || operations convert isTrue
to BLong

added BObjectRef BObjectImp set specialization to remove noise

* fixed converted objimp when jump on false values

* first version of short circuit warning
should be moved to analyzer
added whitelist of module functions which have no sideeffect to reduce
the number of warnings

* moved warning visitor to analyzer and added it as extra compile step
fixed sourceline print and cache the content

* missing include, unused member

* included the correct header

* ecompile.cfg to activate and warn
ecompile cmdline arg to activate it
run all tests also with it active
fixed that only the most right side statement was checked

* ecompile cmdline

* increase ecompile version
cleanup

* compilation error

* missing header

* allow -S- to deactivate shortcircuit like the other params do

* extended whitelist functions

* revert fileformat version increase
fixed escript test cmake

* use the correct arg

* escript testoutput can now be different if shortcircuit is active

* docs

* additional test

* addressed comments
2025-07-28 21:48:34 +02:00
Kevin Eady
87e0c534f4
Add ecompile flag -Z to print AST (#796)
* Add -Z option to print string tree

* Simple test to print an AST

* Make CompiledScript owner of the tree

* some refactoring
- rename ecompile.cfg option
- rename AST generator class

* core-changes, docs

* fix warnings
2025-07-23 23:00:34 +02:00
turleypol
c0bfd2f820
Escript Optimizer more types and operator (#794)
* compile time optimization:
int with doubles and strings
doubles with ints and strings
strings with ints and doubles

* bool with other types, more unary ops, float branch optimizer

* more tests
fixed bool to dbl compare

* output cleanup
more tests

* optimize string values in if statements, optimize ternary operator

* optimize elvis, addes missing files, code cleanup

* use array to keep unoptimized if branch in funcexpr tests

* missing include

* better readable testdata

* removed file

* optimize while and dowhile loops if predicate is a compile time known
value

* cleaner variant of loop optimization?

* added ConstantPredicateLoop Node used by the optimizer for constant loop
predicates
optimize repeat until loop
change tests to run the loops more then once to be sure they work
correctly

* test break/continue with label for constant-loop

* docs
2025-07-10 22:32:29 +02:00
Kevin Eady
1ad7d240eb
Add module function os::SendEmail (#793)
* wip implementation

* maybe add tests...

* fix dependencies

* fix windows and mac deps

* attempt #3 for mac deps

* add --break-system-packages because WHY NOT

* add raii wrapper for curl_slist and curl_mime

* add content_type; fix incorrect recipient variable; more tests

* put smtpd log in file; add curl_easy_setopt_return_error; fix parsing email from display string

* remove some debugging

* catch exceptions in polsys::ReloadConfiguration; tests; smtpd cleanup

* Fix xslt validation erorrs in osem.xml
- `HTTPRequest`` did not have the `<code>` block inside `<explain>` so
it was not rendered.
- `LoadExportedScript` needed `<return>` after `<explain>`
- `GetEnvironmentVariable` needed `<return>` after `<explain>`

* Address review comments
- remove openssl test dep by generating cert, valid for 100 years
- only run test if asiosmtpd module is installed

* Address review comments
- remove `pChild`
- remove `curl_easy_setopt_return_error` macro
- return `new BLong( 0 )` for temp object replaced by background thread

* Address review comments
- use `Clib::localtime` + `fmt::format` for date header

* Address review comments
- Early exit on failures

* Address review comments
- Move suspend to immediately before background thread creation

* Address review comments
- better handling of curl_slist and curl_mimes

* Address Discord comments
- remove env check in test_email program

* attempt to fix timezone issue in date header

* additional tests for invalid params

* add docs, core changes

* smtpd: fix event loop, only run if not filtered out

* put stacktrace in "no signal received" error

* fix stacktrace call in testutil; add default param to os.environ.get in smtpd
2025-07-03 21:33:36 +02:00
Kevin Eady
bc5e650ea6
Fix undoitem when item was equipped on another mobile (#792)
* implementation

* tests

* docs
2025-06-30 22:06:15 +02:00
Kevin Eady
f1ac282f44
Add double support to os::Wait_For_Event (#789)
* implementation

* tests

* docs

* Address review comments
- document resolution of 10ms (ie. 0.01)
- use clamp_convert vs. static_cast
- use impptrIf vs. isa
2025-06-28 14:49:22 +02:00
Kevin Eady
c8e242312e
Allow drag-drop directly onto NPC's backpack with MasterCanAccessNPCsBackpack (#790)
* implementation

* tests

* docs

* actually test what I meant to test
2025-06-28 13:53:47 +02:00
Kevin Eady
bccdd39e4c
Add servspecopt MasterCanAccessNPCsBackpack (#788)
* implementation

* tests

* docs

* fix compiler warnings
2025-06-27 11:41:48 +02:00
Kevin Eady
9a19423b0e
Add Packet script method assign( Packet other ) (#784)
* implementation

* tests

* docs

* remove improper check for is_variable_length in SetInt8
`SetSize` returns false for non-varlength packets

* address Discord comments
- use std::max for packet `newsize`
- use vector assignment operator for copying
2025-06-23 21:21:11 +02:00