You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Watch how number of doAttacking (or checkCreatureAttack) executions per second grows over time (OTS Stats or add 'std::cout' in that function)
You can make it go high faster by running around. Each step of attacked/attacking player adds 1 extra event.
Expected behaviour
Server checks players attacks every getAttackSpeed() - once, not multiple times.
Actual behaviour
Server adds new checkCreatureAttack event to Scheduler every second (onThink) and every player step. Each event is recurring, if target cannot be hit by player.
Server generates infinite number of Scheduler events and CPU goes 100% after few minutes/hours.
Environment
Tested on TFS 1.4, but master code looks the same.
Fix
In player.h under:
uint32_t walkTaskEvent = 0;
add:
uint32_t classicAttackEvent = 0;
In player.cpp in function void Player::doAttacking(uint32_t) replace:
Steps to reproduce
classicAttackSpeed
inconfig.lua
doAttacking
(orcheckCreatureAttack
) executions per second grows over time (OTS Stats or add 'std::cout' in that function)You can make it go high faster by running around. Each step of attacked/attacking player adds 1 extra event.
Expected behaviour
Server checks players attacks every
getAttackSpeed()
- once, not multiple times.Actual behaviour
Server adds new
checkCreatureAttack
event to Scheduler every second (onThink) and every player step. Each event is recurring, if target cannot be hit by player.Server generates infinite number of Scheduler events and CPU goes 100% after few minutes/hours.
Environment
Tested on TFS 1.4, but master code looks the same.
Fix
player.h
under:add:
player.cpp
in functionvoid Player::doAttacking(uint32_t)
replace:with:
It will limit number of
checkCreatureAttack
events to 1 per player.The text was updated successfully, but these errors were encountered: