Page 1 of 1

POL goes 100% cpu with ApplyRawDamage

Posted: Sun Oct 13, 2013 1:53 am
by xeon
If I do ApplyRawDamage() on an merchant NPC spawned from a spawnpoint, POL freeze.

For example, ApplyRawDamage(mobile, 203)

If I kill a mobile created by for example createnpc, everything is fine

POL revision is 714

I haven't any log useful, POL just freeze :(

Re: POL goes 100% cpu with ApplyRawDamage

Posted: Sun Oct 13, 2013 2:33 am
by RusseL
it is really doesn't matter for core spawned your mob with spawner or created with createnpc, both use the same function
CreateNpcFromTemplate.

You should watch into your spawner script, there is a bug somewhere.
I think your spawner trying to respawn and gets infinite loop

Re: POL goes 100% cpu with ApplyRawDamage

Posted: Sun Oct 13, 2013 6:36 am
by Turley
I would second that. sounds a bit weird.
What also could be worse a look are your exported functions. since they are called blocking. if you have there a endless loop the server will freeze.

Re: POL goes 100% cpu with ApplyRawDamage

Posted: Sun Oct 13, 2013 8:26 am
by xeon
I've attached a debugger to POL, it goes in loop in this function:

containr.cpp
...
void UContainer::add_bulk( int item_count_delta, int weight_delta )
{
held_item_count_ += item_count_delta;

// passert( !gflag_enforce_container_limits || (held_weight_ + weight_delta <= MAX_WEIGHT) );

held_weight_ += static_cast<unsigned short>(weight_delta);
// cout << "Adding " << delta << " stones to container " << serial << endl;
if (container != NULL)
{
container->add_bulk( 0, weight_delta );
}
}
...
It continually call itself (add_bulk).

EDIT
Some more info, call stack is this:

pol.exe!UContainer::add_bulk(int item_count_delta, int weight_delta) Line 223 + 0x5 bytes C++
pol.exe!UContainer::add(Item * item) Line 202 + 0x15 bytes C++
pol.exe!UContainer::add_at_random_location(Item * item) Line 296 + 0xb bytes C++
pol.exe!Character::die() Line 2580 C++
pol.exe!Character::apply_raw_damage_hundredths(unsigned int amount, Character * source, bool userepsys, bool send_damage_packet) Line 1988 + 0x7 bytes C++

Re: POL goes 100% cpu with ApplyRawDamage

Posted: Sun Oct 13, 2013 10:11 am
by Turley
mmmh damn it. that's a point. why ever the container points to itself.

Re: POL goes 100% cpu with ApplyRawDamage

Posted: Fri Oct 25, 2013 10:45 am
by Turley
Should be fixed now, and thx again for the additional infos you gave me via PM to point me into the right direction.

Re: POL goes 100% cpu with ApplyRawDamage

Posted: Sun Nov 03, 2013 8:06 am
by Zik
A little problem with ApplyRawDamage too.
Does anyone have NPCs with 70-100k HP on their shard?

So ApplyRawDamage(targ, GetMaxHp(targ) +10); doesn't kill such NPCs, it doesn't even decrease their HP.
targ.kill() and applying lower damage values work great.
Is it a bug, or a feature? If so, what is a limit to damage value? 65536?

Re: POL goes 100% cpu with ApplyRawDamage

Posted: Sun Nov 03, 2013 10:39 am
by Turley
the limit is 65535.
+10 is a bit senseless since chars die with 0 HP. you can also use the method kill for a more direct way.

Re: POL goes 100% cpu with ApplyRawDamage

Posted: Sun Nov 03, 2013 12:47 pm
by Zik
Thank you Turley,
i do use .kill(), in fact it's needed only in few cases.

And about +10 (im most cases it's even +100), i think that is a meaningless scripting tradition on our shrad :D