mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-11 07:42:18 +00:00
[renderer] Clear the visibility components on scene reset
I don't know why it didn't happen during the demo loop, but going from the start map to e1m1 caused a segfault due to the efrags for a lava ball getting double freed (however, I do think it might be because the ball passed through at least two leafs, while entities in the demos did not). The double free was because SCR_NewScene (indirectly) freed all the efrags without removing them from entities, and then the client code deleting the entities caused the visibility components to get deleted and thus the efrags freed a second time. Using ECS_RemoveEntities on the visibility component ensures the entities don't have a visibility component to remove when they are later deleted.
This commit is contained in:
parent
ac0079f872
commit
06f410b0b6
2 changed files with 6 additions and 5 deletions
|
@ -102,15 +102,13 @@ R_ClearEfragChain (efrag_t *ef)
|
|||
|
||||
while (ef) {
|
||||
prev = &ef->leaf->efrags;
|
||||
while (1) {
|
||||
walk = *prev;
|
||||
if (!walk)
|
||||
break;
|
||||
while ((walk = *prev)) {
|
||||
if (walk == ef) { // remove this fragment
|
||||
*prev = ef->leafnext;
|
||||
break;
|
||||
} else
|
||||
} else {
|
||||
prev = &walk->leafnext;
|
||||
}
|
||||
}
|
||||
|
||||
old = ef;
|
||||
|
|
|
@ -470,6 +470,9 @@ SCR_Init (void)
|
|||
void
|
||||
SCR_NewScene (scene_t *scene)
|
||||
{
|
||||
if (scr_scene) {
|
||||
ECS_RemoveEntities (scr_scene->reg, scene_visibility);
|
||||
}
|
||||
scr_scene = scene;
|
||||
if (scene) {
|
||||
mod_brush_t *brush = &scr_scene->worldmodel->brush;
|
||||
|
|
Loading…
Reference in a new issue