Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
jval

P_RadiusAttack() question

Recommended Posts

P_RadiusAttack() function in p_map.c line 1221 of linux Doom adds the damage parameter to MAXRADIUS and then left shifts the result of the addition 16 bits.

Damage parameter can take only the values 70 (called from A_VileAttack) and 128 (called from A_Explode).

MAXRADIUS is 32*FRACUNIT  as defined in p_local.h.

 

 

Questions:

  • I assume the intended code was dist = damage<<FRACBITS) + MAXRADIUS; , right?
  • Is there any work around?

 

Share this post


Link to post
3 hours ago, jval said:

I assume the intended code was dist = damage<<FRACBITS) + MAXRADIUS; , right?

 

Yeah seems that way - the effect of the mistake would be to cause MAXRADIUS to be ignored (via overflow), since it only lives in the upper 16-bits and is being shifted up by a further 16-bits.

 

3 hours ago, jval said:

Is there any work around?

 

This bug seems pretty harmless to me - probably not necessary. I think the 'MAXRADIUS' addition was intended to make the blockmap search area a little bigger just as a precaution/fudge but it seems unnecessary to me as it already pulls in blocks 'dist' units away (in radius). Since that's the area over which damage falls off (linearly) that should be enough as it is I think... You could even argue that the bug is helpful since it reduces the number of blockmap blocks visited in some cases :P

 

Share this post


Link to post

That 'dist' parameter is meant as fudging to compensate for the blockmap not linking the actors into all touching sectors. So the end result here will be similar to the famous 'missing hitscan' bug, i.e. not hit some potential targets whose center is in a different sector. Of course with something like explosive damage that's virtually impossible to detect by just playing the game - that's probably why nobody ever noticed.

 

 

Share this post


Link to post
1 hour ago, Graf Zahl said:

That 'dist' parameter is meant as fudging to compensate for the blockmap not linking the actors into all touching sectors. So the end result here will be similar to the famous 'missing hitscan' bug, i.e. not hit some potential targets whose center is in a different sector. Of course with something like explosive damage that's virtually impossible to detect by just playing the game - that's probably why nobody ever noticed.

 

Ah... you are correct. Initially I had thought the damage calculation was being done with respect to a point and not a volume (hence the hitscan bug would not apply) but reading the code in 'PIT_RadiusAttack ' a little more closely I see there is also an adjustment for radius. So yeah, in that case it would cause splash damage to be missed in certain circumstances.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×