The bug with E4M2 of the DarkPlaces engine was fixed by a good russian programmer Berserker
DP_Patched.rar ������� � �����@Mail.Ru
The bug of the DarkPlaces engine on E4M2:
In the file svbsp.c were defined the limit for the poligon points:
#define MAX_SVBSP_POLYGONPOINTS 16
In this file:
typedef struct svbsp_polygon_s
{
float points[MAX_SVBSP_POLYGONPOINTS][3];
//unsigned char splitflags[MAX_SVBSP_POLYGONPOINTS];
int facesplitflag;
int numpoints;
}
svbsp_polygon_t;
And more:
int SVBSP_AddPolygon(svbsp_t *b, int numpoints, const float *points, int insertoccluder, void (*fragmentcallback)(void *fragmentcallback_pointer1, int fragmentcallback_number1, svbsp_t *b, int numpoints, const float *points), void *fragmentcallback_pointer1, int fragmentcallback_number1)
{
int i;
int nodenum;
svbsp_polygon_t poly;
// don't even consider an empty polygon
// note we still allow points and lines to be tested...
if (numpoints < 1)
return 0;
poly.numpoints = numpoints;
for (i = 0;i < numpoints;i++)
{
poly.points[0] = points[i*3+0];
poly.points[1] = points[i*3+1];
poly.points[2] = points[i*3+2];
//poly.splitflags = 0; // this edge is a valid BSP splitter - clipped edges are not (because they lie on a bsp plane)
poly.facesplitflag = 0; // this face is a valid BSP Splitter - if it lies on a bsp plane it is not
}
...
At the moment of the crash on E4M2 numpoints = 24, much higher than MAX_SVBSP_POLYGONPOINTS.
The solution is:
1) First way is to:
#define MAX_SVBSP_POLYGONPOINTS 32 /// Berserker: was 16
2) Second way is to add check:
int SVBSP_AddPolygon(svbsp_t *b, int numpoints, const float *points, int insertoccluder, void (*fragmentcallback)(void *fragmentcallback_pointer1, int fragmentcallback_number1, svbsp_t *b, int numpoints, const float *points), void *fragmentcallback_pointer1, int fragmentcallback_number1)
{
int i;
int nodenum;
svbsp_polygon_t poly;
// don't even consider an empty polygon
// note we still allow points and lines to be tested...
if (numpoints < 1)
return 0;
/// Berserker's fix: crash on E4M2
if (numpoints > MAX_SVBSP_POLYGONPOINTS)
return 0;
/// End of fix
poly.numpoints = numpoints;
for (i = 0;i < numpoints;i++)
{
poly.points[0] = points[i*3+0];
poly.points[1] = points[i*3+1];
poly.points[2] = points[i*3+2];
//poly.splitflags = 0; // this edge is a valid BSP splitter - clipped edges are not (because they lie on a bsp plane)
poly.facesplitflag = 0; // this face is a valid BSP Splitter - if it lies on a bsp plane it is not
}
...
You can download the source and exe files here:
DP_Patched.rar ������� � �����@Mail.Ru
DP_Patched.rar ������� � �����@Mail.Ru
The bug of the DarkPlaces engine on E4M2:
In the file svbsp.c were defined the limit for the poligon points:
#define MAX_SVBSP_POLYGONPOINTS 16
In this file:
typedef struct svbsp_polygon_s
{
float points[MAX_SVBSP_POLYGONPOINTS][3];
//unsigned char splitflags[MAX_SVBSP_POLYGONPOINTS];
int facesplitflag;
int numpoints;
}
svbsp_polygon_t;
And more:
int SVBSP_AddPolygon(svbsp_t *b, int numpoints, const float *points, int insertoccluder, void (*fragmentcallback)(void *fragmentcallback_pointer1, int fragmentcallback_number1, svbsp_t *b, int numpoints, const float *points), void *fragmentcallback_pointer1, int fragmentcallback_number1)
{
int i;
int nodenum;
svbsp_polygon_t poly;
// don't even consider an empty polygon
// note we still allow points and lines to be tested...
if (numpoints < 1)
return 0;
poly.numpoints = numpoints;
for (i = 0;i < numpoints;i++)
{
poly.points[0] = points[i*3+0];
poly.points[1] = points[i*3+1];
poly.points[2] = points[i*3+2];
//poly.splitflags = 0; // this edge is a valid BSP splitter - clipped edges are not (because they lie on a bsp plane)
poly.facesplitflag = 0; // this face is a valid BSP Splitter - if it lies on a bsp plane it is not
}
...
At the moment of the crash on E4M2 numpoints = 24, much higher than MAX_SVBSP_POLYGONPOINTS.
The solution is:
1) First way is to:
#define MAX_SVBSP_POLYGONPOINTS 32 /// Berserker: was 16
2) Second way is to add check:
int SVBSP_AddPolygon(svbsp_t *b, int numpoints, const float *points, int insertoccluder, void (*fragmentcallback)(void *fragmentcallback_pointer1, int fragmentcallback_number1, svbsp_t *b, int numpoints, const float *points), void *fragmentcallback_pointer1, int fragmentcallback_number1)
{
int i;
int nodenum;
svbsp_polygon_t poly;
// don't even consider an empty polygon
// note we still allow points and lines to be tested...
if (numpoints < 1)
return 0;
/// Berserker's fix: crash on E4M2
if (numpoints > MAX_SVBSP_POLYGONPOINTS)
return 0;
/// End of fix
poly.numpoints = numpoints;
for (i = 0;i < numpoints;i++)
{
poly.points[0] = points[i*3+0];
poly.points[1] = points[i*3+1];
poly.points[2] = points[i*3+2];
//poly.splitflags = 0; // this edge is a valid BSP splitter - clipped edges are not (because they lie on a bsp plane)
poly.facesplitflag = 0; // this face is a valid BSP Splitter - if it lies on a bsp plane it is not
}
...
You can download the source and exe files here:
DP_Patched.rar ������� � �����@Mail.Ru
Comment