Commit graph

505 commits

Author SHA1 Message Date
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
Kevin Eady
1bf7a2a937
Fix memory leak caused by (un)equipped_by parameter addition (#783) 2025-06-22 13:16:22 +02:00
Kevin Eady
749414715c
Add can clothe capabilities to paperdoll, (un)equip(test) scripts (#782)
* implementation

* add tests, testclient support for wear_item todo

* add UpdateConfiguration to ResourceManager for tests

* add test that can only move equipped items

* add docs, core-changes

* add macro defs for Lord British, Blackthorn, Dupre

* update doc xmls' datemodified

* add test for paperdoll flags

* fix test_equip_npc_dragdrop race condition
2025-06-22 12:01:54 +02:00
Kevin Eady
000b7f100b
Fix Array method findIndex changing array content (#780)
* fix implementation

* add tests

* add core-changes
2025-05-24 17:21:24 +02:00
Kevin Eady
192a0a163f
Fix various crashes handling gotten item with deleted shadow realm (#779)
* Fix gotten_item crash caused by realm change from deleted shadow realm

* Fix crash with deleted shadow realms during undo item movement

* Add tests

* Add core-changes

* Add test to check for undo move from deleted realm
2025-05-16 23:36:07 +02:00
Kevin Eady
d03e1c80b6
uoconvert improvements for supporting MultiCollections.uop (#776)
- Add uoconvert support for MultiCollection.uop
- Allow multiple elements in MultiTypes and Mounts in uoconvert.cfg
- Simplify entries in uoconvert.cfg to remove House and Stairs properties in the MultiTypes element
2025-04-15 12:03:35 +02:00
AsY!um-
e493d081d5
Update multi elements graphic checks (#774)
* Update multi elements graphic checks

* Add a comment.
2025-03-05 21:38:37 +01:00
Kevin Eady
52dfc44ae1
Fix display of corpse body items (hair, face, beard) on human death (#770)
* Support better test filters in coretest

* add test

* Implementation

* docs

* better comments for test

* maybe fix logfacility no-pch build
2025-02-27 23:30:32 +01:00
turleypol
4f0e6ac548
Modulus operations with doubles (#769)
* implemented modulus operator % and %= for doubles
int%dbl=dbl
dbl%int=dbl
dbl%dbl=dbl
...

* added missing test for ins_set_member_id_consume_divideequal

* more tests
docs
2025-02-23 16:06:52 +01:00
turleypol
d7ec86bad6
Datafile save fixes (#768)
* create datafile directory if it does not exists during worldsave, before
writing the likely empty file

* check existing of datafiles during startup.
added test for just creating a datafile without adding content

* breaking changes added
2025-02-20 22:14:31 +01:00
Kevin Eady
6c7a2b0a30
Add support for spread operator in dictionary and struct initializers; FormatterEllipsisSpacing formatter option (#763)
* update grammar

* implementation

* formatting

* executor implementation, tests

* docs, core-changes

* fix warning introduced in #760

* add format option FormatterEllipsisSpacing

* update core-changes
2025-02-19 18:33:56 +01:00
Kevin Eady
ec344a395d
Add support for sequence and index bindings (#760)
* update grammar

* add ast nodes; ast building

* Rename to unpacking

* semantic analysis

* executor work part 1, unpacking indices

* renamings; implement index binding

* small cleanup

* use multi_index; more tests

* use multi_index only for rest, otherwise list

* initial formatting

* add missing token decoding

* address self-review comments

* formatting tweaks

* add test for var binding in classes

* add StringIterator

* fix spread tests

* add cfgfile iterator; add cfgelem opersubscript; tests

* add iterator for SQLResultSet and SQLRow; tests

* Copy value in take global/local

* Allow any iterable can index rest unpacking
Always use dictionary as rest object in index unpacking

* add docs, core-changes, doc tests

* formatting changes...

* address self-review comments

* update formatter, format all binding test srcs

* address review comments
- unset var scope

* add cfgfile/cfgelem docs

* reformat objref svg
2025-02-17 21:59:42 +01:00
AsY!um-
3854882364
Fix saving banned state of an account (#762)
* Fix saving banned state of an account.

* Update account test

* Now make the test pass.
2025-02-17 10:24:35 +01:00
turleypol
9f96b071bf
AccountExpansion should use the B9 flags from its set expansion (#759)
removed ServerExpansion B9Flag, not needed and confusing
2025-02-12 07:24:12 +01:00
turleypol
0fdd03316b
Worldsave further improvements (#758)
* directly use the capi for file writing
could improve performance

* docs

* file i/o error checking also during writing
2025-02-06 20:41:12 +01:00
turleypol
c588c51a33
Expansion helper classes for central handling of features (#756)
* use uoexpansion enums for A9, B9 flags
added TOL to uoexpansion
currently unsure where this will end

simplified account initialisation, added errorcheck

* Expansion classes for server and account
fixed flags

* use of AccountExpansion,ServerExpansion
extended tests
splitted unittest file
added missing test for Min/MaxAttackRange

* more micro performance for world saving
use all 4 cores in CI builds
fix compiler flag warning on windows

* save test for weight_multiplier

* enable gothic,rustictiles when using HSA expansion

* removed ancient unused files

* addressed comments
renamed ServerExpansion to ServerFeatures
added method for expansion name

* got rid of client UOExpansionFlag which is the same as the accout
expansion

* updated core-changes and docs

* updated generated ssopt

* test for tooltips
changed method names
removed/clarified comments

* npc hitchance was never saved
added missing npc save tests

* hitchance bug exists also for items...
added missing test for movemode
2025-02-05 19:02:25 +01:00
Jakub Kalita
c94ff9d4cf
Fix directory traversal in ecompile (#757)
* Fix directory traversal in ecompile

* Update core-changes
2025-02-04 19:52:19 +00:00
Kevin Eady
fdc8268dbb
Add hidden flag to invisible items (#755)
* implementation

* tests

* docs

* update tests
2025-02-01 13:06:54 +01:00
Jakub Kalita
807df09678
Add missing attack range properties to itemdesc (#754)
* Add missing attack range properties to itemdesc.

* Add comments.

* Update core changes.
2025-01-31 06:44:34 +01:00
turleypol
8e9a044776
WorldSave performance (#753)
* directly write to stream

* quickfix just disabled orphan console print

* now?

* debug timer for each file

* removed pointer indirection
use defined underlying buffer size
reactivated orphans

* missing files

* optimized away dynamic allocations during formatting by using buffer

* debug print thread id used
stop timer of blocking part

* wake up all threads, if the producer thread is faster only one thread
will wake up...
extended debug logging

* after reading the standard...
notify_* is atomic thus multiple calls to notify_one will always wake up
a different thread.
So notify_one is correct here and notify_all pessimistic

* increased the buffer
ordered savefiles roughly by size

* use compile time strings to optimize formatting
added a few shortcuts
optimized hexint by adding a string_view version with threadlocal buffer

* cleanup

* readded terminate protection

* docs

* StreamWriter needs to be destroyed before printing the stream
2025-01-29 06:48:05 +01:00
Kevin Eady
1ce1a16f5d
Add allow_negatives to module function util::RandomDiceRoll (#748)
* implementation

* tests

* docs, core-changes

* address review comments
- no need for negative check with clamping
2025-01-21 15:33:22 +01:00
turleypol
b28626432d
Fixed potential overrun/underrun problems using script member setters (#747)
* Clib::clamp_convert is now able to convert between equal sized types.
fixed tons of overflow/underflow problems in script member setters

* fix coverage CI
added docs
fixed warning

* finally got it right?
massively extended tests

* removed unneeded special handling
better comments
2025-01-20 21:26:45 +00:00
turleypol
c7254916d1
Script member item.hp underflow/overflow (#746)
* fixed overflow/underflow of hp scriptmember access.

* docs
2025-01-17 23:41:43 +01:00
turleypol
04beb4f0c6
Suspend worldsave script (#745)
* SaveWorldState(): if possible the script will be suspended until the
async part is finished, added to the returning struct
`ElapsedMillisecondsTotal` for the complete time it takes.

* readded removed header

* extended test by calling save without beeing able to suspend

* fixed function name

* do not suspend script during worldsave when its critical
since testscripts are fast make sure via sleep that the gameclock
changes

* docs
2025-01-17 18:43:46 +01:00