Found a potential performance issue that might need tweaking?

Added by Speedz almost 3 years ago

I found a section of code that endlessly loops if there are corpses within viewable area.
It loops for each corpse in view, I can see this being a potential problem that lends to
video lag/latency I have experienced in mass slaughters and OP wars.

Don't ask how I figured it out as a project I am working on led to this discovery.

// Set the bar
if (_Bars[HP]) {
sint value = (sint)_BatLength * barInfo.Score[SCORES::hit_points] / RZ_BARS_LENGTH;
if ( ! _Entity->isForageSource() ) {
if (value < 0) {
value = value;
_Bars[HP]
>setColorRGBA(BarColorHPNegative);
}
else {
_Bars[HP]->setColorRGBA(BarColor[HP]);
}
// if dead creature, force the hp to 0
if( _Entity->mode() == MBEHAV::DEATH && !_Entity->isPlayer() && !_Entity->isUser()) {
if( value > 0 ) {
value = 0;
}
}
}

It is the last if statement that loops or that showed me the signs of the looping.


Replies (2)

RE: Found a potential performance issue that might need tweaking? - Added by Speedz almost 3 years ago

Further testing showed me that the code I put in after

if( _Entity->mode() == MBEHAV::DEATH && !_Entity->isPlayer() && !_Entity->isUser()) {

may have caused it to keep rechecking mob hp or something like that.
It seems this part does not like to jumped out of then back in. (if that makes sense)

RE: Found a potential performance issue that might need tweaking? - Added by Speedz almost 3 years ago

Ok upon further testing it does indeed loop back on itself. Not sure how but it does some funny things with some mods I did in this area because of the loop.
I would like to find a better place that determines when a mob dies. Any thoughts? I am not having any luck finding it.

(1-2/2)