[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;
|
int i;
|
||||||
Pilot* p;
|
Pilot* p;
|
||||||
int n, effect;
|
int n, effect;
|
||||||
double px, py, r, a, vx, vy;
|
double px, py, bvx, bvy, r, a, vx, vy;
|
||||||
|
|
||||||
p = pilot_get(pilot);
|
p = pilot_get(pilot);
|
||||||
|
|
||||||
n = MAX(1, RNG(quantity/10, quantity/5));
|
n = MAX(1, RNG(quantity/10, quantity/5));
|
||||||
px = p->solid->pos.x;
|
px = p->solid->pos.x;
|
||||||
py = p->solid->pos.y;
|
py = p->solid->pos.y;
|
||||||
|
bvx = p->solid->vel.x;
|
||||||
|
bvy = p->solid->vel.y;
|
||||||
|
|
||||||
for(i = 0; i < n; i++) {
|
for(i = 0; i < n; i++) {
|
||||||
effect = spfx_get("cargo");
|
effect = spfx_get("cargo");
|
||||||
@ -105,8 +107,8 @@ void commodity_Jettison(int pilot, Commodity* com, int quantity) {
|
|||||||
/* Radial distribution gives much nicer results. */
|
/* Radial distribution gives much nicer results. */
|
||||||
r = RNGF()*25 - 12.5;
|
r = RNGF()*25 - 12.5;
|
||||||
a = (double)RNG(0,259);
|
a = (double)RNG(0,259);
|
||||||
vx = r*cos(a);
|
vx = bvx + r*cos(a);
|
||||||
vy = r*sin(a);
|
vy = bvy + r*sin(a);
|
||||||
|
|
||||||
/* Add the cargo effect. */
|
/* Add the cargo effect. */
|
||||||
spfx_add(effect, px, py, vx, vy, SPFX_LAYER_BACK);
|
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) {
|
void gl_freeTexture(glTexture* texture) {
|
||||||
glTexList* cur, *last;
|
glTexList* cur, *last;
|
||||||
|
|
||||||
|
/* Shouldn't be NULL (won't segfault though). */
|
||||||
if(texture == NULL) {
|
if(texture == NULL) {
|
||||||
WARN("Attempting to free NULL texture!");
|
WARN("Attempting to free NULL texture!");
|
||||||
return;
|
return;
|
||||||
@ -471,12 +472,12 @@ void gl_freeTexture(glTexture* texture) {
|
|||||||
free(texture);
|
free(texture);
|
||||||
|
|
||||||
/* Free the list node. */
|
/* 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)
|
if(cur->next != NULL)
|
||||||
texture_list = cur->next;
|
texture_list = cur->next;
|
||||||
else /* Case it's the last texture. */
|
else /* Case it's the last texture. */
|
||||||
texture_list = NULL;
|
texture_list = NULL;
|
||||||
else
|
} else
|
||||||
last->next = cur->next;
|
last->next = cur->next;
|
||||||
free(cur);
|
free(cur);
|
||||||
}
|
}
|
||||||
@ -484,6 +485,18 @@ void gl_freeTexture(glTexture* texture) {
|
|||||||
}
|
}
|
||||||
last = cur;
|
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. */
|
/* Return true if pixel at pos (x,y) is transparent. */
|
||||||
|
Loading…
Reference in New Issue
Block a user