[Fix] More correction in gl_freeTexture()
This commit is contained in:
		
							parent
							
								
									e1308dc570
								
							
						
					
					
						commit
						2f9c91d451
					
				| @ -91,13 +91,15 @@ void commodity_Jettison(int pilot, Commodity* com, int quantity) { | ||||
|   int i; | ||||
|   Pilot* p; | ||||
|   int n, effect; | ||||
|   double px, py, r, a, vx, vy; | ||||
|   double px, py, bvx, bvy, r, a, vx, vy; | ||||
| 
 | ||||
|   p = pilot_get(pilot); | ||||
| 
 | ||||
|   n = MAX(1, RNG(quantity/10, quantity/5)); | ||||
|   px = p->solid->pos.x; | ||||
|   py = p->solid->pos.y; | ||||
|   bvx = p->solid->vel.x; | ||||
|   bvy = p->solid->vel.y; | ||||
| 
 | ||||
|   for(i = 0; i < n; i++) { | ||||
|     effect = spfx_get("cargo"); | ||||
| @ -105,8 +107,8 @@ void commodity_Jettison(int pilot, Commodity* com, int quantity) { | ||||
|     /* Radial distribution gives much nicer results. */ | ||||
|     r = RNGF()*25 - 12.5; | ||||
|     a = (double)RNG(0,259); | ||||
|     vx = r*cos(a); | ||||
|     vy = r*sin(a); | ||||
|     vx = bvx + r*cos(a); | ||||
|     vy = bvy + r*sin(a); | ||||
| 
 | ||||
|     /* Add the cargo effect. */ | ||||
|     spfx_add(effect, px, py, vx, vy, SPFX_LAYER_BACK); | ||||
|  | ||||
							
								
								
									
										17
									
								
								src/opengl.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/opengl.c
									
									
									
									
									
								
							| @ -453,6 +453,7 @@ glTexture* gl_newSprite(const char* path, const int sx, const int sy) { | ||||
| void gl_freeTexture(glTexture* texture) { | ||||
|   glTexList* cur, *last; | ||||
| 
 | ||||
|   /* Shouldn't be NULL (won't segfault though). */ | ||||
|   if(texture == NULL) { | ||||
|     WARN("Attempting to free NULL texture!"); | ||||
|     return; | ||||
| @ -471,12 +472,12 @@ void gl_freeTexture(glTexture* texture) { | ||||
|         free(texture); | ||||
| 
 | ||||
|         /* Free the list node. */ | ||||
|         if(last == NULL) /* Case there's no texture before it. */ | ||||
|         if(last == NULL) { /* Case there's no texture before it. */ | ||||
|           if(cur->next != NULL) | ||||
|             texture_list = cur->next; | ||||
|           else /* Case it's the last texture. */ | ||||
|             texture_list = NULL; | ||||
|         else | ||||
|         } else | ||||
|           last->next = cur->next; | ||||
|         free(cur); | ||||
|       } | ||||
| @ -484,6 +485,18 @@ void gl_freeTexture(glTexture* texture) { | ||||
|     } | ||||
|     last = cur; | ||||
|   } | ||||
| 
 | ||||
|   /* Not found. */ | ||||
|   if(texture->name != NULL) /* Surface will have NULL names. */ | ||||
|     WARN("Attempring to free texture '%s' not found in stack!", texture->name); | ||||
| 
 | ||||
|   /* Free anyways. */ | ||||
|   glDeleteTextures(1, &texture->texture); | ||||
|   if(texture->trans != NULL)  free(texture->trans); | ||||
|   if(texture->name != NULL)   free(texture->name); | ||||
|   free(texture); | ||||
| 
 | ||||
|   gl_checkErr(); | ||||
| } | ||||
| 
 | ||||
| /* Return true if pixel at pos (x,y) is transparent. */ | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis