Skip to content

Commit

Permalink
[Linux]: Fix other crash in Gargage
Browse files Browse the repository at this point in the history
For some reason game sometimes crashes while in Garbage.
  • Loading branch information
sobkas committed Aug 28, 2023
1 parent d0792e7 commit 49e4e0e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/xrGame/quadtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class CQuadTree
virtual ~CFixedStorage() { xr_free(m_objects); }
IC T* get_object()
{
VERIFY(m_free);
if (!m_free)
return nullptr;

T* node = m_free;
m_free = m_free->next();
ZeroMemory(node, sizeof(T));
Expand Down
15 changes: 14 additions & 1 deletion src/xrGame/quadtree_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,16 @@ IC void CSQuadTree::insert(_object_type* object)
if (depth == m_max_depth)
{
CListItem* list_item = m_list_items->get_object();

if (!list_item)
return;

list_item->m_object = object;
list_item->m_next = (CListItem*)((void*)(*node));

if (!list_item->m_next )
return;

*node = (CQuadNode*)((void*)list_item);
++m_leaf_count;
return;
Expand All @@ -102,6 +110,9 @@ IC void CSQuadTree::insert(_object_type* object)
if (!*node)
*node = m_nodes->get_object();

if (!node)
return;

distance *= .5f;
u32 index = neighbour_index(object->position(), center, distance);
VERIFY(index < 4);
Expand Down Expand Up @@ -266,7 +277,9 @@ TEMPLATE_SPECIALIZATION
IC _object_type* CSQuadTree::remove(
const _object_type* object, CQuadNode*& node, Fvector center, float distance, int depth)
{
VERIFY(node);
if (!node)
return nullptr;

if (depth == m_max_depth)
{
CListItem*& node_leaf = ((CListItem*&)((void*&)(node)));
Expand Down

0 comments on commit 49e4e0e

Please sign in to comment.