There was a bug or oversight in that approach which caused my game to behave strangely and crash while debugging it:
Because of timing issues some entities might be (ptr_)removed already before you access the ent_pvs2 list which is why you will need to add an (or extend your) on_ent_remove event:
void on_ent_remove_event(ENTITY* ent)
{
int i,j;
for(j = 0; j < 2; j++)
{
for(i = 0; i < ent_pvs2_list_max[j]; i++)
{
if(ent == ent_pvs2_list[j][i])
{
ent_pvs2_list_max[j]--;
ent_pvs2_list[j][i] = ent_pvs2_list[j][ent_pvs2_list_max[j]];
ent_pvs2_list[j][ent_pvs2_list_max[j]] = NULL;
}
}
}
}
EDIT: And
"num > ent_pvs2_list_max[mode]"
has to be strictly greater than, otherwise you will skip the last element. Both issues have been fixed on the wiki page.