View Single Post
Re: Bug-NUM_FOR_EDICT Error: Bad Pointer
Old
  (#6)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: Bug-NUM_FOR_EDICT Error: Bad Pointer - 05-05-2004

I think what your looking for can be found in the quake 1 source...

Code:
 int NUM_FOR_EDICT(edict_t *e)
 {
 	int		b;
 	
 	b = (byte *)e - (byte *)sv.edicts;
 	b = b / pr_edict_size;
 	
 	if (b < 0 || b >= sv.num_edicts)
 		Sys_Error ("NUM_FOR_EDICT: bad pointer");
 	return b;
 }
Basically make sure any calls to ENTINDEX are within range.