Commit graph

465 commits

Author SHA1 Message Date
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
turleypol
29761c43d6
Disk full no longer crashes during WorldSave (#742)
* preparation
update boost
build stacktrace

* if worldsave i/o operations fail core terminates directly, allow
exceptions in SaveContext deconstructor to prevent this

* link with boost stackstrace

* print exception backtrace when buffering fails

* replaced other forced backtraces with actuals

* test throw

* revert test throw

* register terminate handler and print stacktrace
unsure if it collides with the other signals register

* StreamSaver can terminate in the deconstructor
added PolCore().last_worldsave which returns the gameclock of the last
successfull world save.
SaveWorldState() can now return error "Failed to save world" if the first critical
part fails. Since the second part runs async you have to check the new PolCore member when the last successfull save was.

* fixed cppdap checkout

* catch exceptions in the deconstructor and do not rethrow during stack
unwinding

* fix mac build

* fix apple builds

* helper lambda to get rid of repeating try/catch blocks per datafile
try to set promise in exception cases to guarantee the set
moved account storage into parallel tasks, comment about extra
thread is no longer valid.

* centralized stacktrace
renamed polcore member

* extended comment for clarification

* docs
2025-01-14 20:37:54 +01:00
Kevin Eady
0527692a78
Add Script object script method stacktrace (#739)
* Initial implementation, tests

* Enhance tests

* Add quiet to read_dbg_file

* Add pc to array format

* Add docs, core-changes

* fix bad PCs

* touchup on corechanges
2025-01-05 17:22:55 +01:00
turleypol
22b01b3b81
added multi prop/itemdesc items_decay (#735)
* added multi prop/itemdesc items_decay
added region cfg entry NoDecay
misc cleanup eg chr->equip sets position instead of calling side

* docs

* added future pos refactoring comment

* changed region NoDecay to ItemsDecay so it matches the other props
2024-11-14 06:58:18 +01:00
Lukáš Novotný
9be58c528e
Add realm decay setting (#734)
* Add realm decay setting

* fix crash on missing realm; recompute decay pause upon changing decay

* docs and corechanges
2024-11-10 00:33:04 +01:00
Jonathan Morland-Barrett
8df2f6515e
Added dynaprops for min and max attack range increase. (#511)
* Initial commit of min and max range increase dynaprops.

* Fixed documentation and reported style issues.

* More style check fixes.

* Update missing uobject and script objects for new props.

* Rectify missing code from uoscrobj which prevented assignment on mobiles.
Changed range logic from weapons to include some sanity checks.

* Add a simple test

---------

Co-authored-by: Jonathan Morland-Barrett <jonathan@veridiandynamics.com.au>
Co-authored-by: Kevin Eady <8634912+KevinEady@users.noreply.github.com>
2024-11-02 15:46:50 +01:00
turleypol
300a9ca47d
added ssopt AllowVisualRangeModification (#726)
* added ssopt AllowVisualRangeModification which allows clients to modiy
their LOS via pkt 0xC8

* added ssopt MinimumVisualRange and MaximumVisualRange to limit the range
a client can define.
added r/w script member client.visual_range
if set via script the updaterange can no longer be modified by the
client

* fixed typo

* missing include

* if via script the visual_range is set to 0 use the client given range
remove/add objects when the visual range changes
added test
fixed testclient 0xbf sub clienttype packet

* extra logic to send/remove objects only if they are now/no longer
visible due to range change
script can by pass the VisualRange limit
added docs

* core changes
2024-11-01 19:07:43 +01:00
Kevin Eady
ef5931bcc6
Correctly load packages in ecompile (#731) 2024-10-27 11:06:48 +00:00
Kevin Eady
2d0b675754
Fix super-scoped function resolution; Fix SourceLocation for scoped function calls (#730)
* Fix super-scoped function resolution

* Fix SourceLocation for scoped function calls
2024-10-25 11:20:41 +02:00
Lukáš Novotný
d56a6df251
Add moved_at and position_changed_at members to characters (#729)
* add moved_at and position_changed_at members to characters

* add core changes, docs

# Conflicts:
#	docs/docs.polserver.com/pol100/corechanges.xml
#	pol-core/doc/core-changes.txt

* fix docs
2024-10-23 20:27:56 +02:00
Kevin Eady
150d7982fb
Fix too-early fail on calling scoped variable as function (#728) 2024-10-20 17:42:07 +02:00
Lukáš Novotný
6acc69edc7
Configurable visual range (#715)
* configurable visual range

* visual range => default visual range

* fix code style

* move to ssopt
2024-10-19 15:42:50 +02:00
Kevin Eady
f45d12665d
Fix various case sensitivity issues in classes (#725) 2024-10-18 06:53:50 +02:00
turleypol
034f4687e3
SmoothBoat pkts: reduced pktsize even more 10% + extra margin (#724)
* SmoothBoat pkts: reduced pktsize even more 10% + extra margin

* no need to create 8000 items for the limit test
2024-10-17 22:51:49 +02:00
turleypol
2320a5dd35
Socket::has_incoming_data closes socket on error (#721)
* Socket::has_incomming_data closes socket on error
eg auxclient via OpenConnection had the problem that a closed connection
by the other side wasnt detected.
cleanup timeout params uses now milliseconds
removed old unused pollingwithselect
renamed pol.cfg entry for SingleThreadLoginServer socket timeout

* changed the default for the loginserver to single thread
Formatter defaults when no cfg can be loaded match the cfg case now.
added docs
2024-10-17 06:55:06 +02:00
turleypol
084a4e78e7
Removed PolLock when handling nonallowed pkts (#720)
* do not lock PolLock if a client sends a non-allowed pkt, this will be
only logged like undefine pkts and thus does not need the log.
added debug define to polsem.h which prints file/line of each PolLock

* extended SelectTimeout docs

* fixed debug define

* added cfg to disconnect clients if they send unknown/non-allowed pkts
during login phase

* docs
2024-10-15 17:23:02 +02:00
Kevin Eady
0fa1b893a0 Update core-changes, break-changes for classes support (#719)
* Format testsuite escript

* Format testsuite pol

* Update docs
Switch "attributes" to "members" to better align with Escript terms.

* Add core-changes, breaking-changes
2024-10-10 18:06:04 +02:00
Kevin Eady
0988c17f29 Add classes documentation (#717)
* Add escript guide docs for classes

* Add ClassInstanceRef to objref docs

* Use objref.dot to generate svg
2024-10-10 18:06:04 +02:00
turleypol
145eb8185b
fixed missing space when packing funcrefs (#714)
* fixed missing space when packing funcrefs
pack functioncall during group formatting without forcing a newline

* error if resulting format string is empty

* core changes

* do not start a newline when next part is a closing parenthesis during
groupformatting

* pkg loading is again quiet
2024-10-03 15:10:21 +02:00
turleypol
ba9ad6d1d5
more formatting improvements (#696)
* more formatting improvements:

replace inside of comments tabs with spaces if UseTabs is false
do not strip whitespaces at the beginning of linecomments
better handling of long lines eg string additions
"binpack":
  if an array fits equally into up to 3 lines use this instead of having each element in a newline
  struct/dicts get only packed if they fit into a single line, or half of the room for two lines
align comments in statements

* fixed linecomment forcing newline in simple splits
formatting of functionexpressions
```
@(blubb) {
  blah;
};
```

* fixed windows lineendings
fixed extra newline before long comment in certain situations
added option FormatterFormatInsideComments to deactivate trimming and
replacing of tabs

* fixed typo..
ecompile cfg is now FormatterIndentLevel

* FormatterBracketAttachToType: array{} vs array {}
FormatterAllowSingleLines: allow single line case/functionrefs

* align case label expressions
comments at the end still make the expression packable
other bugs

* better detection of case labels, by buffering the text. fixed more
problems with comments while packing lines

* do not allow more then 3 lines to be packed to a single one

* fixed hopefully last bug with comments and packing

removed FormatterAllowSingleLines
added
 FormatterAlignTrailingComments
 FormatterAlignConsecutiveShortCaseStatements
 FormatterAllowShortCaseLabelsOnASingleLine
 FormatterAllowShortFuncRefsOnASingleLine

* better linesplits when prefferedBreak is used (functions with params)

* fixed unalign lines with comments in arrays

* simplified ecompile code, use callback for compilation during iteration
through the directories.
use for pkgs recursive_directory_iterator

* core-changes

* onlinedocs

* onlinedocs-typo

* corrected cfg

* do not touch comments at all when disabled
detect aligned */

* fixed group formatting in var statements in more complicated situations

* when packing finishes right before the last element check if this
element also fit into the last line

* remaining ); or similar parts dont start a new line during group
formatting

* fixed edge cases of preferredBreak tactic with paranthesis alignment

* changed defaults, updated docs
2024-09-13 06:49:00 +02:00
Kevin Eady
ad4882821c
Use SLL parsing with ANTLR (#708)
* use SLL parsing

* Move listeners, fix error catching

* Move error listeners back

* fix warning

* docs
2024-08-31 09:16:14 +02:00
Reloecc
1da821f0f9
ssopt.MobilesBlockNpcMovement allows followers to stack on a tile (#702)
* ssopt.MobilesBlockNpcMovement = 2 allows followers to stack on single tile

* enum MOVEBLOCKMODE for ssopt.MobilesBlockNpcMovement

---------

Co-authored-by: jan.cernin <jan.cernin@3it.cz>
2024-08-29 07:54:11 +02:00
Kevin Eady
29bf643c06
Fix Z calculation for turning objects on boat (#700)
* Implementation

* Tests

* Docs
2024-08-24 09:27:05 +00:00
turleypol
50a6658883
Formatter variable declaration, align open parentheses (#691)
* Formatter: variable declaration list gets aligned with "var" breaked at
the comma.
if a linebreak happens while a paranthesis is open align next line with it

* added corechanges
2024-08-11 22:09:30 +02:00
Kevin Eady
88b4f9923d
Allow function reference calls across executors (#687)
* Allow function reference calls across executors

* Update core-changes

* Address review todos

* Change Globals2 to reference

* Revert "Change Globals2 to reference"

This reverts commit 37e37506be.

* Change Globals2 to shared pointer

* Address review comments
- Remove handled TODO comment
- Move arguments passed by value
2024-08-10 17:43:21 +02:00
Kevin Eady
a780712ec7
Add spread operator for array initializers, function calls, and method calls (#684)
* Update grammar

* Update parser and AST generator

* Update semantic analysis, tests

* Handle instruction generation

* Executor implementation
- Instruction `ins_storestackcount`
- Instruction `ins_spread`
- Update listfile tests for new `storestackcount`` instruction

* Add tests targetting resource tracker

* Revert "Executor implementation"

This reverts commit f0caede24179cb11b6d98c8cd1fecd91ce546148.

* New instruction implementation
- Introduce `BSpread` object to manage spreading an object at runtime.

* More tests

* Fix memory leak

* Add test spreading non-arrays

* Add failure reason to bfunc method call
Better than getting uninit

* Core changes; docs + accompanying tests for docs

* Resolve CI annotation warnings
- this statement may fall through

* Fix listfile snapshots due to base rebase, whoops
2024-08-06 23:34:24 +02:00
Kevin Eady
6ed593ac81
Add function reference table to EScriptProgram (#686)
* Introduce FunctionReferenceRegistrar
- Track function references created by functors
- Remove ValueStack-held attributes for functors
- Add Function References section to escript program
- Use Function References section in ins_functor
- Update escript version

* Update listfile snapshots
- Remove ValueStack-held attributes created by functors

* Add function reference tracking to function references
- `emit.function_reference` uses funcref registrar + emits that index
- `ins_funcref` uses parameter count + is variadic from prog funcref table
- update listfile snapshots

* Add core-changes
2024-08-06 20:29:02 +02:00
Kevin Eady
93645f0770
Add variable arguments to user functions (#679)
* Update grammar

* Update parser and AST generator

* Update semantic analysis

* Executor implementation
- Move Executor stack modification logic to BFunctionRef
- Handle user function calls
- Handle expression function calls

* Tests

* Update existing listfile snapshots
- Adds variadic boolean to instruction stack
- Changes instruction counts and offsets

* Fix test issue

* Better implementation of calling user functions

* Add var-args-captures test

* Refactor continuation handling + handle variadic args
- Move stack modifications from make/withContinuation into the executor's handling of the continuation
- Only trim args in continuation call if function is not variadic

* Add var-args-continuation test (via array.filter)

* update escriptguide + formatting, docs

* Fix CI annotations
- '=': conversion from 'size_t' to 'unsigned int', possible loss of data
- declaration of 'continuation' hides previous local declaration
2024-08-04 17:13:30 +02:00
Kevin Eady
cfd241bb93
Add support to change House multi id via house.set_multiid() (#677)
* Some changes
- add house `MTH_SET_MULTIID`
- `UMutli::multiid` protected, rename to `multiid_`
- Make setting `multi.graphic` a no-op

* implementation

* initial test

* add walkon, collision tests

* Address review comments
- Add nullptr check

* Add ability to pass string name; tests;

* Add docs

* update objref.xml datemodified
2024-08-03 15:08:43 +02:00
Kevin Eady
5daca73d65
Fix bad docs (#682) 2024-08-03 12:27:36 +00:00
Kevin Eady
d1a1bd3afe
Additional escript array functional methods (#674)
* Implementation change for continuation handling

* Implement array methods find, findIndex, map, reduce

* Add tests

* update filter test for coverage

* update docs

* change implementation to not copy

* update tests; add tests for "polyfill" comparison

* update escript guide
2024-08-02 20:39:32 +02:00
turleypol
814c80acc5
use xml text for description of methods/members (#678)
xslt copies text node, so that more style options are available
(br/code/...)
fix alternating color of lines
2024-08-01 22:49:37 +02:00
Kevin Eady
060814ec67
Fix function expression assignment to locals and captures (#676)
* implementation

* tests

* docs
2024-08-01 20:22:21 +02:00
Kevin Eady
e43cc86c19
Fix function expression captures to be byref (#675)
* implementation

* tests

* docs
2024-08-01 12:26:49 +02:00
turleypol
d2450b0508
improved escript formatter when formatting if's/function parameters (#673)
* improved escript formatter when formatting if's/function parameters

logical operators get now a preferred break style same for commas in
function/program parameters. split based on this flag the line

* when logical "and/or" and commas from function parameters are in one
line only split based on logical ones

* core changes
2024-08-01 08:00:35 +02:00
Kevin Eady
f381f46dc3
Add compiler support for function expressions (#671)
* initial poc of function expressions
- update grammar
- mock AST builder to return BBoolean(true) for a func expr
- update prettifier for skeleton implementation

* more skeleton work
create AST class FunctionExpression mimicking boolean value

* create ast UserFunction, add to workspace from functexpr

* can generate instructions

* reorg tests; add test for instructions

* can track FunctionDepth in Variable

* can get captures for funcexprs inside funcs.. tbd if this way of nesting works

* Implement create-functor instruction
- Move function depth from Variable to Variables
- Introduce stacking of `Variables` for function expresions via `FunctionVariableScope`
- Add `TOK_FUNCTOR` instruction for 'create-functor'
- Handle emitting a `FunctionExpression` AST node
- Update `emit.declare_variable` and `emit.access_variable` to account for function captures
- Remove `in_function` from instruction generator, as it is tracked via `UserFunction` stack
- Update tests

* Address Discord comments
- Swap pop param order

* Bubble up captured variables through nested functions

* Improve testing infrastructure; add some test cases

* Fix compilation error

* prepend captures to function parameters in funcref mth_call

* update tests

* move from function{} to @{}

* implementation fix

* some more tests

* update docs

* Some cleanup

* fix CI annotation warning
- 'argument': conversion from 'size_t' to 'VariableIndex', possible loss of data

* Address review comments
- Add `passert_always`
- Use better example in docs

* Some cleanup
- Remove unused functions
2024-07-29 22:30:52 +02:00
Kevin Eady
21fc580e66
Add filter method to escript arrays (#667)
* POC of calling user functions from core

* rename to BContinuation

* fix annotation warnings

* fix annotation warnings 2

* some cleanup, comments

* add more params to filter

* add more tests

* fix stack issues, wip determine what to do with printStack helper testing function

* print stack only for debug; increase OTContinuation to 100

* docs

* remove debugging leftovers
2024-07-28 22:51:04 +02:00
Kevin Eady
f47ce97d26
Add compiler support for expressions as function callee (#670)
* initial support for function calls with expression callee

* Add support for identifier-named callees

* add compilation failure test; better code docs

* Add core-changes

* Address compiler warnings
- conversion from 'size_t' to 'unsigned int', possible loss of data

* Update grammar

* implementation

* tests

* update core-changes

* Address CI warnings
- declaration of 'method' hides previous local declaration
2024-07-28 20:21:23 +02:00
Lukáš Novotný
fea0ed7a53
Fix status hp values upon realm change (#669)
* fix status hp values upon realm change

* update core changes
2024-07-21 20:17:57 +02:00
Kevin Eady
0b1bb4c2bf
Add source location to Print() messages sent to debugger (#664)
* Implementation

* Tests

* Update core-changes
2024-07-16 20:23:17 +02:00
Kevin Eady
271722af13
Send Print() messages to attached debugger (#663)
* Implementation

* Tests

* Update core-changes

* Implementation fixup
- do not copy message from executor
2024-07-16 12:41:55 +02:00