- Changed: Now conditional statements (IF/ELIF/ELSEIF) will perform a lazy evaluation of the conditional expression, whereas before they fully evaluated the whole expression.
Lazy evaluation means that the expression will be evaluated one piece (or, one subexpression) at a time. At each stage, if it's sure that the whole expression value (true or false) won't change
even if new subexpressions will be evaluated, the evaluation will stop there.
Example:
IF (<LINK.ISVALID> && (<LINK.TAG0.test> == 1))
Won't return an error if item's LINK is invalid or not set, because the evaluation will only halt to <LINK.ISVALID>.
Other than allowing more flexible IF tests in just one line, this change will grant faster evaluation times for complex IF tests.
Added errors on a few more invalid operations (r_Verb on invalid object).
- Changed: Now TRY can be used to explicitly "TRY" to execute a command or set a property on an object which may or may not exist.
If the object doesn't exist, no operation is done and no error is returned. It can't be used to TRY to retrieve a value (like <TRY FINDID.invalid_item.NAME>).
Its use is DISCOURAGED, but sometimes it might be an easy way to execute trivial operations without a lot of if/endif clauses.
This is a way to explicitly allow what Sphere already did by default in the past (not checking if the object is valid and not returning an error),
which is something that only sometimes we expect and we want, most of the times it caused obscure bugs.
If you just want to test the object (like <OBJ>), like always, 0 will be returned with no error if it's invalid.
Fixed: PacketContainer (0xF7) using wrong base class and constructor arguments.
Changed: restricted data types accepted by CUID methods, avoiding multiple misuse cases and unnecessary type conversions.
- Added: f_onchar_create_init function in core/serv_triggers.scp; it's called after the client sent the character creation data, but before
the character is created server-side (f_onchar_create is called after the creation, so the function arguments are read-only).
Function parameters:
Variables:
Read-Write:
ARGN1 --> Feature flags sent by client
ARGN2 --> Character profession (0=Advanced, 1=Warrior, 2=Mage, 3=Blacksmith, 4=Necromancer, 5=Paladin, 6=Samurai, 7=Ninja)
ARGN3 --> Character race (1=Human, 2=Elf, 3=Gargoyle)
Read-Only:
ARGS --> Account name
ARGO --> Client creating the character
Return:
0 --> Allow character creation (default action)
1 --> Deny character creation
- Fixed: @(Item)DropOn_Ground ARGS not being used, as indicated in the wiki.
- Changed: @(Item)DropOn_Ground now fires BEFORE the new P is set! The new P is stored in the ARGS of the trigger. Prior to this change, the triggers were called after the new P was set.
- Added: In @(Item)DropOn_Ground, ARGN2 value is now == 1 if the trigger is called during a BOUNCE check (the char is overloaded and the item is being dropped on ground).
- Fixed: @(Item)DropOn_Ground not firing when, during a BOUNCE check, the char was overloaded and the item was being dropped on ground (Issue #295).
Disabled Visual Studio 2019 static code analysis for 3rd party code (zlib, deelx, sqlite).
Fixed a couple of warnings reported by VS2019 code analysis.
- Fixed: WEIGHTREDUCTION not working correctly for items inside a container (Issue #289).
- Fixed: Retrieving a value from an unexistant LIST did not return -1; overwriting a LIST element generated an exception (Issue #290).
- Fixed: Profiler and worldsave message showing incorrect times (Issue #296).
- Fixed: Client listing showing the number of the online clients at the end of the list, instead of the top.
- Added: Doc file "Porting from 0.55 to 0.56.txt" (the content was posted years ago by XuN on the forum).
Changed GetPreciseSysTimeNano to GetPreciseSysTimeMicro, nanoseconds timer isn't so precise and it isn't even worth it.
Disabled DEBUGF_EXP log message when the delta exp is == 0.
Added class GlobalInitializer to initialize some global variables and do pre-server startup sanity checks and function calls.
Moved GetTimeMinDesc function from spheresvr.cpp to a static method of CServerTime.
Removed unused bFull parameter from CObjBase::CallPersonalTrigger.
Fixed a compilation error on Linux.
Cmake now works with manually defined toolchains, supports different build types (Release, Debug, Nightly), correctly define macros for them and supports manual build type override from command line (useful for Linux).
Copied REVISIONS* from main repo, renamed current changelog file and moved old to docs/past changelogs/.
Cleaned archivied folder of some imho useless files.
Fixed: Spawn items created with random COUNT property.
Changed: MoveNear functions now accept WORD iStep argument instead of int, since x and y coordinates are stored as WORD.
Added SKF_DISABLED, setting this flag on skills will not allow to use them by players or npcs
Added Skill_CanUse(skill) checking if the skill is disabled. Maybe this can be expanded to differ Players from NPCs , adding expansion & resdisp checks, etc.
WARNING: Following changes won't affect current scripts, but adapting them will remove the performance impact (Read NOTE for more tips about what to update).
CHANGED: Moved formulas for SpellEffect's damage above @SpellEffect trigger, so these formulas will be calculated regardless of the returns of the trigger,
this will allow working with precise numbers instead of wondering what ARGN1 may be and creating own formulas to handle it.
Also added for this trigger:
-local.dam with final damage received (if any).
-local.resist: Damage reduction to apply, it's set to 25 automatically when the spell is going to be resisted, then sysmessage <DEFMSG.RESISTMAGIC> will be shown. Setting it to 0 will result in no resist and no sysmessage. You can force or totally remove resists here.
NOTE: Since formulas will be calculated yes or yes from now, checks about spell's affecting this char or not should be moved to @SpellSuccess ( they should've been there from an start, but we all placed them in @SpellEffect :P) so @Effect won't even be called.
Fixed some spells not being correctly found in case of having multiple books since the code for GetSpellbook() returned the first found book, and this may not have the requested spell.
Script Pack:
-sphere_defs.scp: Added SKF_DISABLED
The previous sphere parser was limiting the last byte to 0e (dec: 14 / ASCII: 'n'), making it return wrong last byte on all old clients > 'n' (eg: 3.0.8q being read as 3.0.8n) or newest clients > '14' (eg: 7.0.47.62 being read as 7.0.47.14).
Now with this new parser it can set/get correctly all client version formats (1.25.35a, 2.0.0, 5.0.0a, 6.0.5.6, 7.0.47.62, etc), except enhanced clients which it still not being parsed correctly*
*enhanced clients send a strange client version to server (eg: enhanced client 4.0.47.62 reporting 67.0.47.0 to server). Maybe OSI changed some packet, or maybe it need some math magic to convert this number into correct value. I already searched about it but nothing found
Fixed: T_SPAWN_ITEM not automatically setting attr_invis, whereas it happened with T_SPAWN_CHAR.
Fixed: T_SPAWN_ITEM not removing spawned items when it got deleted.
Fixed: forced T_SPAWN_ITEM and T_SPAWN_CHAR to be unstackable through an internal workaround, stopping the Enhanced Client behaviour
of "unstacking" spawn items with amount > 1 when trying to move them. Did this via creating GetAmount(), GetAmount() and m_iAmount in CItemSpawn. These work with BYTE values, not WORD, because the max amount of spawnable objects per spawn item is actually UCHAR_MAX. More infos at the declarations in CObjBase.h.
Changed: T_SPAWN_ITEM now colours itself red, like t_spawn_char, and when initialized it changes the DispID to i_worldgem_lg, in order to differentiate it to worldgem bits related to resource gathering and to make it more visible.
Changed: the MORE2 of a T_SPAWN_CHAR does no more indicate the amount of chars spawned, for that there is the COUNT property, (read only, introduced time ago) which works also for T_SPAWN_ITEM.
COUNT is now stored, for both T_SPAWN_CHAR and T_SPAWN_ITEM in CItemSpawn:m_currentSpawned. There is the MOREM BYTE free in CItem but i feel it was messy to use it.
MORE2 is used only by T_SPAWN_ITEM to indicate the maximum pile amount of the spawned item (if this is 0, spawn up to the total amount). COUNT property does not sum the amount of each spawned item.
This resolves the ambiguity of MORE2 meaning and saves some space in the save files.
-IMPORTANT: this change means that if in your scripts you get the T_SPAWN_CHAR or T_SPAWN_ITEM amount of spawned chars with MORE2,
you should now reference to it with COUNT!
Fixed: MORE2 property for T_SPAWN_ITEM not working as intended.
Changed: now double clicking a T_SPAWN_ITEM spawnitem has the same effect it has on T_SPAWN_CHAR, that is resetting it (remove existing items spawned from it) if the timer is running, otherwise starting it (forcing the spawn to work and create some items).
[sphere_msgs.scp] Removed ITEMUSE_SPAWNCHAR_NEG, ITEMUSE_SPAWNCHAR_RESET, ITEMUSE_SPAWNITEM_TRIG and unified them as: ITEMUSE_SPAWN_NEG and ITEMUSE_SPAWN_RESET.
Added GetSight() to Char's range in NPC_LookAround to get a dynamic value of the VisualRange property, which was not working on NPCs.
Changed: ARGN1 = 1 in @Stroke trigger(s) calling UpdateDir on character against it's target instead of forcing it to always turn if SKF_GATHER was present.
Fixed: Ships moving but not updating the multi part on Enhanced Client with smooth sailing disabled.
Changed: Removed useless screen updates when smooth sailing is on, making sailing more fluid.
Changed: Removed declarations and calculations on unused variables in the sailing engine.
Fixed: Price of items sold by the vendor swapped on Enhanced Client.
Changed: Removed unnecessary casts and changed variable type from INT64 to LONG in CItemVendable::GetVendorPrice and CClient::Event_VendorSell.
Changed: Removed useless packets sent when opening vendor sell gump on Enhanced Client.
Replaced obsolete functions clock() [Win] and gettimeofday() [Linux] with recommended functions QueryPerformanceCounter() [Win] and clock_gettime() [Linux]
https://msdn.microsoft.com/en-us/library/ee417693(VS.85).aspx
These functions are more optimized and can handle values with microseconds precision, but I lowered this precision back to tenths of second to make it compatible with current script values like TIMERD/SERV.TIME/etc
PS: still need some testing on linux (I can't test it here because I don't use linux) :P
Changed: Many improvements on pet commands engine.
[sphere_speech.scp]: Added UNFRIEND line on speech lists.
[sphere_msgs.scp]: Added new messages 'npc_pet_confused' and 'npc_pet_targ_*'.