Consistency check for segment number in find_vector_intersection() and obj_create(); Added more debug output for invalid segment numberin get_seg_masks()

This commit is contained in:
zicodxx 2011-09-24 11:15:24 +02:00
parent 7a4d7e3bc4
commit 4e299e4f83
4 changed files with 23 additions and 2 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20110924
--------
main/fvi.c, main/gameseg.c, main/object.c: Consistency check for segment number in find_vector_intersection() and obj_create(); Added more debug output for invalid segment numberin get_seg_masks()
20110923
--------
main/state.c: When restoring Coop players and make turn them into ghosts perform a check if this player is actually a valid player so we do not just blindly use any object number from a possibly uninitialized player structure

View file

@ -644,6 +644,18 @@ int find_vector_intersection(fvi_query *fq,fvi_info *hit_data)
//check to make sure start point is in seg its supposed to be in
//Assert(check_point_in_seg(p0,startseg,0).centermask==0); //start point not in seg
// invalid segnum, so say there is no hit.
if(fq->startseg < 0 || fq->startseg > Highest_segment_index)
{
hit_data->hit_type = HIT_BAD_P0;
hit_data->hit_pnt = *fq->p0;
hit_data->hit_seg = hit_data->hit_side = hit_data->hit_object = 0;
hit_data->hit_side_seg = -1;
return hit_data->hit_type;
}
// Viewer is not in segment as claimed, so say there is no hit.
if(!(get_seg_masks(fq->p0,fq->startseg,0,__FILE__,__LINE__).centermask==0)) {

View file

@ -31,6 +31,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "wall.h"
#include "fuelcen.h"
#include "byteswap.h"
#include "mission.h"
#ifdef RCS
static char rcsid[] = "$Id: gameseg.c,v 1.1.1.1 2006/03/17 19:45:01 zicodxx Exp $";
@ -304,9 +305,10 @@ segmasks get_seg_masks(vms_vector *checkp,int segnum,fix rad,char *calling_file,
int num_faces;
int vertex_list[6];
segment *seg;
extern int Current_level_num;
if (segnum < 0 || segnum > Highest_segment_index)
Error("segnum == %i (%i) in get_seg_masks()\ncheckp: %i,%i,%i, rad: %i\nfrom file: %s, line: %i\nPlease report this bug.\n",segnum,Highest_segment_index,checkp->x,checkp->y,checkp->z,rad,calling_file,calling_linenum);
Error("segnum == %i (%i) in get_seg_masks() \ncheckp: %i,%i,%i, rad: %i \nfrom file: %s, line: %i \nMission: %s (%i) \nPlease report this bug.\n",segnum,Highest_segment_index,checkp->x,checkp->y,checkp->z,rad,calling_file,calling_linenum, Current_mission_filename, Current_level_num);
Assert((segnum <= Highest_segment_index) && (segnum >= 0));

View file

@ -1101,7 +1101,10 @@ int obj_create(ubyte type,ubyte id,int segnum,vms_vector *pos,
int objnum;
object *obj;
Assert((segnum <= Highest_segment_index) && (segnum >= 0));
// Some consistency checking. FIXME: Add more debug output here to probably trace all possible occurances back.
if (segnum < 0 || segnum > Highest_segment_index)
return -1;
Assert(ctype <= CT_CNTRLCEN);
if (type==OBJ_DEBRIS && Debris_object_count>=Max_debris_objects && !PERSISTENT_DEBRIS)