POL goes 100% cpu with ApplyRawDamage

Bug reports and feature requests. New features can only be added to the current development version. Bug-fixes may be back-ported.

Current release: 099 / Current development: 100
Post Reply
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am

POL goes 100% cpu with ApplyRawDamage

Post 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 :(
RusseL
Forum Regular
Posts: 375
Joined: Fri Feb 20, 2009 8:30 pm

Re: POL goes 100% cpu with ApplyRawDamage

Post 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
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: POL goes 100% cpu with ApplyRawDamage

Post 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.
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am

Re: POL goes 100% cpu with ApplyRawDamage

Post 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++
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: POL goes 100% cpu with ApplyRawDamage

Post by Turley »

mmmh damn it. that's a point. why ever the container points to itself.
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: POL goes 100% cpu with ApplyRawDamage

Post 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.
Zik
Novice Poster
Posts: 41
Joined: Sun Feb 07, 2010 9:39 am

Re: POL goes 100% cpu with ApplyRawDamage

Post 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?
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: POL goes 100% cpu with ApplyRawDamage

Post 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.
Zik
Novice Poster
Posts: 41
Joined: Sun Feb 07, 2010 9:39 am

Re: POL goes 100% cpu with ApplyRawDamage

Post 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
Post Reply