-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read mobtypes.txt and handle standard and custom creatures animations #1266
Conversation
…efault container from map of vectors to a multimap, also trying to delete elements as little as possible, to avoid cpu usage, reallocations and tree rebalancing). Added #define MT_ENGINES: it doesn't make sense to keep unneeded mutex locks, at least until (if ever) we'll have a fully multithreaded engine. Some advancement in making ASAN work on Windows with Clang. Added .cmake-format
Reduced CSector member data types as needed, to save memory. Added a security check to CSFile::r_Write, at shutdown there might be a request to write to an invalid file descriptor (tested on Linux, tried to write on fd -1). Added macro SECTORSIZE_DEFAULT instead of using 64 as a magic number.
…dynamically allocating memory for it each time, pre-allocate and request cached CWorldSearch instances. Use CWorldSearch::GetInstance(). Added cdrc external library (reference counted smart pointers, std::shared_ptr is too slow) and new CSReferenceCount sphere library. Cdrc has been slightly modified in order to be used and compiled in a multi-file project. See custom folder. Added HAS_FLAGS_STRICT and HAS_FLAGS_ANY macros. Fixed macOS compilation error.
CWorldSearchHolder now uses CSReferenceCount instead of rc_ptr, which is more complex and slightly slower. Modified some ADDTOCALLSTACK calls for frequently called functions. Changed some rand val generations in CCharFight to use the fast algorithm. Inlined some small functions.
Fixed some Linux compilation warnings and errors. MSVC will compile by default with SSE2 CPU extensions enabled on x86_64. Updated CMakeDetectArch.cmake with 3rd party code.
…significantly reduced CPU usage and (slightly) reduced startup time. - Fixed: RAM usage always increasing during uptime. Caused by a couple of memory leaks, the greatest happening because the cached map blocks were not properly released. - Fixed: adopted a more conservative memory allocation policy for strings, resulting in reduced RAM usage. - Changed: I_MEMORY (ITEMID_MEMORY) items won't have anymore the ComponentProps Faction, ItemChar, Item, reducing their memory footprint.
…umber with a different base (seconds or tenths of seconds or milliseconds) in different contexts. Now they expect in scripts only values in seconds. Fixed: crash when moving a char in an area full of teleporters, or whichever items made the char move multiple times in the same tick. Fixed: buffer read past the end in CCacheableScriptFile first reading. Fixed: if a char had the COMM_CRYSTAL flag enabled, it called ::OnHear on every item in range, without checking if the item is actually capable of hearing. Further optimized distance checks. Separated the Github workflows into different files, in order to get a different badge for each build platform/type. Dismissed AppVeyor build. Added sphere_library/sfastmath.h.
Fixeid an invalid memory read when reading the last script file line.
Added more log messages for Linux x86 build and Coverity upload workflow.
…ags. (Sphereserver#1237) Fixed duration of hallucination spell. Fixed wrong layer for potion delay. Fixed wrong sound id for changing monster sounds schema. Fixed Attacker_GetHighestThreat: return -1 would make the NPC threat lesser than the ATTACKER_THREAT_TOLDBYMASTER and make CChar::NPC_GetAttackMotivation not work correctly for attacking pets. Fixed NPC_Act_Follow use combat target even if the npc is not in combat.
Good job! Just want to link the related issue: #885 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an excellent one, thanks!
I'd suggest some little changes before merging it. One of them would be to add a ini setting to enable/disable mobtypes loading, so giving the choice to use the old behavior
src/game/uo_files/CUOMobtypes.cpp
Outdated
|
||
if (g_Install.OpenFile(csvMobTypes, "mobtypes.txt", (word)(OF_READ | OF_TEXT | OF_DEFAULTMODE))) | ||
{ | ||
_mobTypesEntries.resize(4096); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 4096 an arbitrary number or some hardcoded client limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the client max anim ID, normally it's 2048, some shards have extended it to 4096 or beyond.
I have already replaced 4096 with CREID_QTY for the next commit, because if you want to change the limit you have also to change it server-side.
src/game/uo_files/CUOMobtypes.cpp
Outdated
|
||
//Split the string | ||
char* pch; | ||
pch = strtok(tmpString.data(), " \t"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could check, if you like so, Str_Parse. It's a Sphere function which hasn't the drawbacks of strtok, mainly it's not thread safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this?
//Split the string
std::vector<tchar*> splitArray;
splitArray.resize(3);
size_t iQty = Str_ParseCmds(tmpString.data(), splitArray.data(), 3, " \t#");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, or you could just use tchar* ppColumns[3] in place of that vector
About the ini setting, I thought it wasn't required because the mobtypes file is not loaded (and in this case Sphere uses the old behavior to distinguish between monster and animal) unless it's in the mul folder. |
One could simply just want to use their full client folder also for sphere. In any case, i feel that an ini setting is more straightforward and simple to manage for people wishing to keep the old "buggy" behavior just because it's "classic sphere". |
0913018
to
7a9a90c
Compare
Done but how can I resolve merge conflicts now? Edit: done |
Manually merged, needed in order to fix conflicts. |
Read mobtypes.txt (if available among mul files) and cache it to check animations type when using creatures animations.
Now standard anims (SEA_MONSTER, ANIMAL, MONSTER) and UOP anims are handled correctly depending on which actions anim they have on anim files.
About the anims, i checked client latest version and writed down the info here: https://docs.google.com/spreadsheets/d/1kXHctxuHJIuv6yvsA_nzjov_A1IAYkeKpTqx5_c8yM8/edit?usp=sharing
Added alert anim on NPCs when they start combat, pillage anim when they loot something (items on ground or in bodies) and "summon" anim when they are summoned or added.
I'm still dubious about the SetTimeout command after summon action.
I added it to show the entire animation, because if the creature moves, the animation is interrupted.
Some monsters have 2-3 sec. animation but the timeout freezes them until is completed, so for example if a player summon a creature he can't command it until the timeout is completed.
What are your thoughts about this? Is there a bettere way to do it?
Now custom anims can be handled by scripts using ANIM command (It was almost useless before, so i decided to replace it) under CHARDEF, to set which anim actions they have/don't have, using the following flags.
MONSTER (H slot) default configuration is with actions: 0 (Walk), 1 (Stand), 2 (Die1), 3 (Die2), 4 (Attack1), 5 (Attack2), 6 (Attack3), 10 (GetHit), 11 (Pillage), 15 (Block Right), 16 (Block Left), 17 (Idle), 18 (Fidget)
No DIE2 action = 01,
No ATTACK1 action = 02,
No ATTACK2 action = 04,
No ATTACK3 action = 08,
No GETHIT action = 010,
No PILLAGE action = 020,
STOMP action = 040,
CAST2 action = 080,
CAST3 action = 0100,
No BLOCKR action = 0200,
No BLOCKL action = 0400,
No FIDGET1 action = 0800,
No FIDGET2 action = 01000,
FLY action = 02000,
Anims with Attacks 1-2-3 in actions 9,10,11 and with GetHit in action 20 (there are many custom WOW anims with this configuration) = 0x10000
ANIMAL (L slot) default configuration is with all actions: 1 - 12
No EAT action = 01,
No ALERT action = 02,
No ATTACK2 action = 04,
No GETHIT action = 08,
No FIDGET1 action = 010,
No FIDGET2 action = 020,
No LIEDOWN action = 040,
No DIE2 action = 080
So for example if you have a MONSTER (H slot) flying custom anim, with Cast2 action but not Pillage action you can set ANIM=020A0
If you have a custom anim with default configuration, you don't need to set ANIM= (i checked with my custom anims to use the most suitable config to don't have to change all chardefs)
Issue: #885