View Single Post
Re: Traceline navigation
Old
  (#6)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Traceline navigation - 16-03-2004

erm, several reasons to crash here...

Before doing ANYTHING with an edict_t pointer, test it with FNullEnt(). From my own experience a null pointer test is never enough. FNullEnt() actually makes sure the address the pointer points to is really the address of a registered, active, entity.

You have to do this for:
pPlayer->pev->groundentity (can be null)
pEntity->pev->owner (can be null too: what if the owner dies ?)

Also you can save yourself the cost of the TraceLine: if the player is standing on the ground, his flags will be FL_ONGROUND (standing completely, i.e. origin is above) or FL_PARTIALGROUND (standing partially, one foot aside but one foot on it. Here the TraceLine would fail)
And pev->groundentity is reliable, when it is not NULL. If (ground flags && pev->groundentity && groundentity is hive) then you can inflict your player some damage.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote