Commit graph

44 commits

Author SHA1 Message Date
turleypol
21577d8e5b
Clang Tidy concat namespaces (#855)
* tidy

* Automated clang-tidy change: modernize-concat-nested-namespaces

* compile test

* fix namespace

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>
2026-01-17 10:30:21 +01:00
turleypol
6cc0d1698b
Clang Tidy replace typedefs with more readable using (#854)
* trigger tidy

* Automated clang-tidy change: modernize-use-using

* compile test

* unnamed struct fix?

* more unnamed structs

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>
2026-01-16 18:45:47 +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
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
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
Kevin Eady
a953a37fa7 Support function reference calls with default parameters (#710)
* Support default args in funcref calls
- Simplify BFunctionRef by using funcref index
- Emit default args when visiting function reference

* Move default args gen to second-pass visit

* Better error message on param count errors

* Check for constructor in MTH_NEW

* Address self-review comments
- Update code comments

* Introduce ResourceManager to pol testsuite
- Create a new class-based resource manager for deleting resources
(item NPCs, multis) after each test.
- Migrate house_set_multiid test to use new ResourceManager.

* Move resource cleanup
2024-10-10 18:06:04 +02:00
Kevin Eady
d7cdcff383 Add classinst.function member; Add is binary operator; Add funcref MTH_NEW (#701)
* Update grammar

* Implement selfIs in BObjectImp

* Add tests

* Update grammar

* Support obj.function as a MemberAccess [1/2]
- AST generation changes

* Support obj.function as a MemberAccess [2/2]
- add funcref index to eprog class table ctor entry
- allow check_mro on non-class inst (skip ctor calls)

* Move address of funcref into funcref table

* Add funcref.new()
- Add class index to funcref table entry
- Add MTH_NEW

* Fix formatting

* Address self-review comments

* Some more tests

* Address self-review comments

* Update grammar

* Remove ObjMember read_only, hidden
No need to special-handle MBR_FUNCTION

* Addres GitHub CI annotations
- '=': conversion from 'size_t' to 'unsigned int', possible loss of data
2024-10-10 18:06:04 +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
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
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
turleypol
0e675c516a
use new formatter for ERROR_PRINT, added ERROR_PRINTLN (#595)
* use new formatter for ERROR_PRINT, added ERROR_PRINTLN

* remove old log define

* fix comments
2024-01-12 06:51:44 +01:00
Kevin Eady
3f82fbafb4
Add boat.set_alternate_multiid (#593)
* Fix unhandled exception in UBoat::create_component

* Return 0 on unsuccessful boat move with MoveBoat and MoveBoatRelative

* Add boat.set_alternate_multiid

* skip base multiid in alternates boat struct

* Add test for boat.set_alternate_id

* docs, core-changes

* use array equals in test
2024-01-10 11:34:40 +01:00
Kevin Eady
48c8a00476
Allow custom boat control script defined in boat item descriptor; Rename boat method setpilot to set_pilot (#591)
* Allow custom boat control script defined in boat item descriptor

* Rename boat.setpilot to boat.set_pilot
2024-01-08 18:46:01 +00:00
Kevin Eady
e5209a51ff
Add support for boat piloting via mouse movement (#558)
* Initial work on boat piloting changes
- Changed: Boat script is now registered as the boat's control script
- Added: Boat piloting via mouse movement
- Added: boatRef.pilot member
- Added: boatRef.pilot([charRef]) method

* add first test

* Fix boat control script attach on scripted create

* move boat move packet warnings to suspicious acts

* set pilot now errors when mutli has no process

* Add test, testclient support for boat move packet

* Touchup pilot members and methods
- Change `pilot` method to `setpilot`. This standarizes it a bit with
the same naming convention of `npc.setmaster`.
- Fix return values in `pilot` member, returning `0` if no pilot.

* Refactor to put functionality inside UBoat

* Address Discord comments
- Remove SuspecisionActs for no boat process.
- Add `relative_direction` to boat move sysevent.

* destroy boatmount on chr death; more error checks

* Fix compilation after master merge

* Fix relative_direction calculation

* wip tests

* Fix boat tests

* Address review comments
- Initialize UBoat::mountpiece

* Add HSA check to boat.setpilot

* Reject movement if boat mountpiece equipped

* docs; test cleanup

* add test for blocked movement

* Address Discord review comments
- Add suspicious acts notice for client movement while piloting
- Return error on attempting to script move a char that is piloting a boat

* Fix compiler warning
2024-01-06 18:01:31 +07:00
Peter Wedder
f404591b1d
Fix SetString packet hook method writing UTF-8 instead of CP-1252 (#442)
* Fix SetString packet hook method writing UTF-8 instead of CP-1252. Add a new method, SetUtf8String, for writing UTF-8.

* Add functions that operate on whole strings.

* Fix a couple of bugs and add unit tests.

* Do not convert if the string doesn't contain any UTF-8

* Convert 0x80..0x9f control characters, which don't exist in cp1252, to question marks

* Fix SetUtf8String writing too few bytes if the string contained multi-byte UTF-8 characters

* Remove extraneous parameter from TextCommandScript documentation

* Update changes and docs
2021-11-02 22:00:36 +01:00
turleypol
0aea78c405 added array.sorted_insert to insert into an already sorted array.
Added a few finals and defaults
2018-10-07 21:05:02 +02:00
Gabriele Tozzi
b72f725e02 Whitespace fixes 2018-04-03 04:13:03 +02:00
turleypol
0d04d5e19b Current FunctionRef status. Mixed with a few more cmake stuff 2018-02-03 19:05:22 +01:00
turleypol
dbb25bdb62
Include and buildsystem cleanup (#45)
Include cleanup
Reworked buildsystem (Linux only)
Removed dynamic libs, Linux now again uses static linking (like windows)
2018-01-29 21:55:48 +01:00
turley
189cad3479 Formating everything
Authors are not forced to use the clang-format setting, but should
atleast be inspired by the style.
The only thing which is now not allowed are tabs for ident/alignment!
2016-02-19 19:26:35 +01:00
Gabriele Tozzi
d1ac902926 Documentation: reformatted headers for DoxyGen 2016-01-28 14:52:40 +01:00
Gabriele Tozzi
7593188ff7 Merge branch 'master' into cmake 2015-12-05 09:17:28 +01:00
Gabriele Tozzi
05b2a3a6bc Buff Bar Support
The buff status is held in a new buffs_ property of Character. It is
modified via Character.addBuff(), Character.delBuff(),
Character.clearBuffs() functions. (Maybe also a readBuffs() function
could be useful in future?). Packets are automatically sent when on
a "when needed" basis.
2015-12-05 09:06:40 +01:00
Thomas Volkert
0a0d1974a8 Fixed Windows build for clib 2015-11-11 00:34:18 +01:00
turley
c755d44e75 Added: array.cycle([count])
will move array backwards or forwards in-place as it were a conveyor belt.
{1, 2, 3}.cycle()
Will make it:
{3, 1, 2}
Accepts a negative value as a shift to move different direction
Changed: string.format()
Now actually faster than string concatenation in eScript
Fixes a bug where {:d} formating could cause an arbitrary number shown instead of a real value
tag errors are slightly more intuitive and compact.
Note: Patches submitted by andenixa
2015-07-27 19:17:49 +02:00
turley
79dff37246 Splitted gamestate external. 2015-01-02 14:46:44 +01:00
turley
99d7dc3037 namespaces...finally :)
Hard part is finished every file is touched. Namespaces are currently rough named by directory name.
Maybe we could split it more
2013-12-21 09:10:46 +00:00
dsourc
ad5b5ddffa Added: character.DisableSkillsFor( duration ) method to disable skills that are started with start_skill_script or by scritps defined in attributes.cfg for duration ( seconds )
This method overrides the default Delay setting in attributes.cfg if used ( for example if on failing a skill you want no delay just set it to 0 )
             This can also be used to disable skills for example during an event or pvp
    Added:   item.name_suffix for adding crafter marks or such
             item.desc returns the formatted name and suffix added to it without formatting if it exists
             item.name does not include this suffix, so that can be used to get the item name without formatting and without suffix
2013-09-25 18:43:43 +00:00
frozenblit
4fed077538 Added string formatter from andenixa. Missing: write tests!
(http://forums.polserver.com/viewtopic.php?f=41&t=5078)
2013-08-27 22:11:09 +00:00
turley
3a37cd1006 Added: string methods:
str.length() : returns like len(str) the length of the string
str.upper() : returns like upper(str) the uppercase version and also modifies the str
str.lower() : returns like lower(str) the lowercase version and also modifies the str
str.find(Search,[Start]) : returns like Find(string, search, start) the index of the first occurance of 'search' after 'start' within str
but unlike the basic.em function the Start parameter is optional if not given it searches the whole string
str.join(array) : returns a string which is the concatenation of the array elements, seperated by str
2012-11-16 16:27:26 +00:00
dsourc
0b49173a9c Changed: MoveItemToContainer( item, container, x := -1, y := -1 ); to MoveItemToContainer( item, container, x := -1, y := -1, add_to_existing_stack := 0 );
Changed:    item.SplitStackInto( container, amount ) to item.SplitStackInto( container, amount, add_to_existing_stack := 0 )
  Note:       The optional add_to_existing_stack parameter defines if the items moved to the container will look for an existing stack and add to it or just add as a new item ( old behaviour )
              If add_to_existing_stack == 1 and there is no stack in the container, it will return Error "There is no existing stack", so its up to scripts to check this.
  Added:      item.HasExistingStack( container ) to allow scripts to check if there is an existing stack in a container or not, returns the ItemRef of the stack if it exists.
2012-08-27 11:06:41 +00:00
turley
9677a77c2c added XmlNode.clonenode()
since all NodeObjects get destroyed when the corresponding XmlFileObject is destroyed, use this method to store a Node for later use.
2012-01-02 13:44:52 +00:00
turley
c9cabbf9a2 Added: DestroyMulti(house) returns error "House currently being customized."
Added: house.cancelediting(chr, drop_changes) will stop editing mode.
drop_changes 1/0 if true drops all non committed changes
Errors: "House is not custom","House is currently not been edited","Character is not editing this house"
Added: Syshook CloseCustomHouse(mobile, house)
called after client quits editing, or when house.cancelediting() is called
return value is ignored
Added: servspecopt.cfg
"SpeedHack_MountRunDelay"  default 80 ms
"SpeedHack_MountWalkDelay" default 180 ms
"SpeedHack_FootRunDelay"   default 180 ms
"SpeedHack_FootWalkDelay"  default 380 ms
Change them on your own risk
2011-09-03 08:15:59 +00:00
AustinHeilman
235a204b46 Changed merchants to send a .shopping list with EVID_MERCHANT_SOLD containing an array of structs .item and .amount (script is responsible for breaking up stacks) - Scripts will be responsible for gold checks, etc when something is purchased.
Added item.SplitStackInto(container, amt) - Returns a reference to the new item stack or errors. Have spot for item.SplitStackAt(x, y, z, real, amt) next.
2011-08-09 00:02:14 +00:00
turley
11bd865d23 removed syshook and replaced it with a noncritical call of scripts/misc/customhousecommit.ecl 2011-05-28 06:29:43 +00:00
turley
7c44ca6613 added:
multi.house_parts
multi.house_editing
who.house_editing
multi.addhousepart(graphic,xoff,yoff,z)
multi.erasehousepart(graphic,xoff,yoff,z)
components get added to workingdesign during edit
2011-05-21 09:14:42 +00:00
turley
5470c07893 finished xml reading/writing 2010-09-06 12:35:46 +00:00
turley
161ec8c190 started xml file parsing/writing
currently only parsing works
2010-08-25 11:53:14 +00:00
turley
bd7c8e2189 more vartype cleanup
Added: (Tomi) chr priv "runwhilestealth" you can run while you are in stealth for as many stealthsteps you have
Added: (Tomi) new npcdesc entry "SaveOnExit" 0/1 ( defaults to 1 )
Note: this also means that SaveOnExit can be definied in the override_properties struct
Changed: vitals::ApplyDamage( mobile, damage, userepsys := DAMAGE_USE_REPSYS, send_damage := DAMAGE_USE_DEFAULT )
            vitals::ApplyRawDamage( character, hits, userepsys := DAMAGE_USE_REPSYS, send_damage := DAMAGE_USE_DEFAULT )
            const DAMAGE_NO_SHOW := 0;
            const DAMAGE_SHOW := 1;
            const DAMAGE_USE_DEFAULT := 2;
            DAMAGE_USE_DEFAULT uses the SendDamagePacket setting from combat.cfg (Tomi)
Added: uo::SendOverallSeason( season_id, playsound := 1 )
            Used to send the Season packet 0xBC to all clients logged on.
            This function doesnt resend the lightlevel or weather after it sends season, that has to be done by scripts.
            chr.setseason( season_id, playsound )
            Used to send the Season packet 0xBC to a single character.
            This method doesnt resend the lightlevel or weather after it sends season, that has to be done by scripts.
            (Tomi)
Changed: (Tomi) uo::SpeakPowerWords( who, spellid, font := _DEFAULT_TEXT_FONT, color := _DEFAULT_TEXT_COLOR) 
            font, color like every speech function
2010-01-15 09:55:20 +00:00
turley
e487c74e87 deafened not deafed 2009-10-14 10:24:18 +00:00
turley
5519dc9c0e Added: char.deaf(duration) - duration in seconds. -1=forever, 0=off
Added: char.deafed r/o
2009-10-14 10:11:14 +00:00
turley
4bf7f8f3e1 Added spellbook.addspell() & .removespell() methods 2009-10-10 08:26:56 +00:00
turley
aa73f9422c Added spellbook.spells() & .hasspell() methods 2009-10-09 08:27:15 +00:00
muaddib_pol
d032ee448f + POL is now, open source. 2009-09-03 19:44:42 +00:00