box_create(gs,cur,new_grid,entity_shape_pos(cur));// destroys next/prev fields on cur
cpVectnew_shape_position=entity_shape_pos(cur);
// leaks the allocated shape for the box so center of mass calcs from the original grid are correct. Shapes are freed when grid is destroyed after construction of new replacement grids
// important that a new entity isn't created for the shapes so entity references to those shapes are still valid
cpShapeSetUserData(cur->shape,NULL);
cur->shape=NULL;
box_create(gs,cur,new_grid,new_shape_position);// destroys next/prev fields on cur
cur=next;
cur=next;
}
}
// @BeforePatreon do the momentum stuff properly here so no matter which grid stays as the current grid,
// the *SAME RESULT* happens. VERY IMPORTANT for client side prediction to match what the server says.
// Tried to use something consistent on the server and client like current entity index but DID NOT WORK.
// IDEA: just make it so *all* of the boxes are in new grids instead of choosing one to stay the same
// This bug is triggered heavily with high ping by placing a box on a corner, so that it starts out in the grid but this logic is ran.