X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fglforestfire.c;h=5ee4c0b97f333b9371ccecf007a2c577d99f539c;hb=39809ded547bdbb08207d3e514950425215b4410;hp=3697b2e4b0b7148269ac32ba6a7e1625d0f74af6;hpb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;p=xscreensaver diff --git a/hacks/glx/glforestfire.c b/hacks/glx/glforestfire.c index 3697b2e4..5ee4c0b9 100644 --- a/hacks/glx/glforestfire.c +++ b/hacks/glx/glforestfire.c @@ -81,7 +81,6 @@ static const char sccsid[] = "@(#)fire.c 5.02 2001/09/26 xlockmore"; "*showFPS: False \n" \ "*wireframe: False \n" \ -# define refresh_fire 0 #define MODE_fire #include "xlockmore.h" /* from the xscreensaver distribution */ #include "gltrackball.h" @@ -621,13 +620,15 @@ static Bool inittree(ModeInfo * mi) return False; } /* initialise positions */ - for(i=0;inum_trees;i++) - do { - fs->treepos[i].x =vrnd()*TREEOUTR*2.0-TREEOUTR; - fs->treepos[i].y =0.0; - fs->treepos[i].z =vrnd()*TREEOUTR*2.0-TREEOUTR; - dist=sqrt(fs->treepos[i].x *fs->treepos[i].x +fs->treepos[i].z *fs->treepos[i].z ); - } while((distTREEOUTR)); + for(i=0;inum_trees;i++) { + do { + fs->treepos[i].x =vrnd()*TREEOUTR*2.0-TREEOUTR; + fs->treepos[i].y =0.0; + fs->treepos[i].z =vrnd()*TREEOUTR*2.0-TREEOUTR; + dist = sqrt(fs->treepos[i].x * fs->treepos[i].x + + fs->treepos[i].z * fs->treepos[i].z); + } while((distTREEOUTR)); + } return True; } @@ -885,9 +886,11 @@ static Bool Init(ModeInfo * mi) */ -static void -free_fire(firestruct *fs) +ENTRYPOINT void +free_fire(ModeInfo * mi) { + firestruct *fs = &fire[MI_SCREEN(mi)]; + if (mode_font != None && fs->fontbase != None) { glDeleteLists(fs->fontbase, mode_font->max_char_or_byte2 - mode_font->min_char_or_byte2 + 1); @@ -929,14 +932,7 @@ init_fire(ModeInfo * mi) { firestruct *fs; - /* allocate the main fire table if needed */ - if (fire == NULL) { - if ((fire = (firestruct *) calloc(MI_NUM_SCREENS(mi), - sizeof(firestruct))) == NULL) - return; - } - - /* initialise the per screen fire structure */ + MI_INIT (mi, fire); fs = &fire[MI_SCREEN(mi)]; fs->np = MI_COUNT(mi); fs->fog = do_fog; @@ -944,14 +940,14 @@ init_fire(ModeInfo * mi) /* initialise fire particles if any */ if ((fs->np)&&(fs->p == NULL)) { if ((fs->p = (part *) calloc(fs->np, sizeof(part))) == NULL) { - free_fire(fs); + free_fire(mi); return; } } else if (fs->r == NULL) { /* initialise rain particles if no fire particles */ if ((fs->r = (rain *) calloc(NUMPART, sizeof(part))) == NULL) { - free_fire(fs); + free_fire(mi); return; } } @@ -974,7 +970,7 @@ init_fire(ModeInfo * mi) #endif glDrawBuffer(GL_BACK); if (!Init(mi)) { - free_fire(fs); + free_fire(mi); return; } } else { @@ -1043,13 +1039,6 @@ ENTRYPOINT void draw_fire(ModeInfo * mi) ENTRYPOINT void release_fire(ModeInfo * mi) { - if (fire != NULL) { - int screen; - for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) - free_fire(&fire[screen]); - (void) free((void *) fire); - fire = (firestruct *) NULL; - } if (mode_font != None) { /* only free-ed when there are no more screens used */