Fix crash with clear_sim if gravity not initialised, fix renderer

This commit is contained in:
Simon Robertshaw 2011-12-24 18:22:58 +00:00
parent b6d9d8d608
commit 835d9f1f3d
2 changed files with 25 additions and 15 deletions

View File

@ -10,17 +10,17 @@
#endif
float *gravmap;//Maps to be used by the main thread
float *gravp;
float *gravy;
float *gravx;
unsigned *gravmask;
float *gravmap = NULL;//Maps to be used by the main thread
float *gravp = NULL;
float *gravy = NULL;
float *gravx = NULL;
unsigned *gravmask = NULL;
float *th_ogravmap;// Maps to be processed by the gravity thread
float *th_gravmap;
float *th_gravx;
float *th_gravy;
float *th_gravp;
float *th_ogravmap = NULL;// Maps to be processed by the gravity thread
float *th_gravmap = NULL;
float *th_gravx = NULL;
float *th_gravy = NULL;
float *th_gravp = NULL;
int gravwl_timeout = 0;
int gravityMode = 0; // starts enabled in "vertical" mode...
@ -454,6 +454,8 @@ void gravity_mask()
unsigned maskvalue;
mask_el *t_mask_el = NULL;
mask_el *c_mask_el = NULL;
if(!gravmask)
return;
memset(checkmap, 0, sizeof(checkmap));
for(x = 0; x < XRES/CELL; x++)
{

View File

@ -1153,10 +1153,14 @@ void clear_sim(void)
memset(fire_r, 0, sizeof(fire_r));
memset(fire_g, 0, sizeof(fire_g));
memset(fire_b, 0, sizeof(fire_b));
memset(gravmask, 0xFFFFFFFF, (XRES/CELL)*(YRES/CELL)*sizeof(unsigned));
memset(gravy, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float));
memset(gravx, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float));
memset(gravp, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float));
if(gravmask)
memset(gravmask, 0xFFFFFFFF, (XRES/CELL)*(YRES/CELL)*sizeof(unsigned));
if(gravy)
memset(gravy, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float));
if(gravx)
memset(gravx, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float));
if(gravp)
memset(gravp, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float));
for(x = 0; x < XRES/CELL; x++){
for(y = 0; y < YRES/CELL; y++){
hv[y][x] = 273.15f+22.0f; //Set to room temperature
@ -1470,7 +1474,11 @@ int main(int argc, char *argv[])
pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
prepare_alpha(4, 1.0f);
prepare_alpha(CELL, 1.0f);
prepare_graphicscache();
flm_data = generate_gradient(flm_data_colours, flm_data_pos, flm_data_points, 200);
plasma_data = generate_gradient(plasma_data_colours, plasma_data_pos, plasma_data_points, 200);
player.elem = player2.elem = PT_DUST;
player.frames = player2.frames = 0;