mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
Fix out of bounds access in dpGrid (#1106)
Fixes an issue where we would try to access an array out of the physics bounds
This commit is contained in:
parent
8ae1e1bc6b
commit
b589755655
@ -43,8 +43,8 @@ void dpGrid::Add(dpEntity* entity) {
|
|||||||
|
|
||||||
if (cellX < 0) cellX = 0;
|
if (cellX < 0) cellX = 0;
|
||||||
if (cellZ < 0) cellZ = 0;
|
if (cellZ < 0) cellZ = 0;
|
||||||
if (cellX > NUM_CELLS) cellX = NUM_CELLS;
|
if (cellX >= NUM_CELLS) cellX = NUM_CELLS - 1;
|
||||||
if (cellZ > NUM_CELLS) cellZ = NUM_CELLS;
|
if (cellZ >= NUM_CELLS) cellZ = NUM_CELLS - 1;
|
||||||
|
|
||||||
//Add to cell:
|
//Add to cell:
|
||||||
m_Cells[cellX][cellZ].push_front(entity);
|
m_Cells[cellX][cellZ].push_front(entity);
|
||||||
@ -87,8 +87,8 @@ void dpGrid::Delete(dpEntity* entity) {
|
|||||||
|
|
||||||
if (oldCellX < 0) oldCellX = 0;
|
if (oldCellX < 0) oldCellX = 0;
|
||||||
if (oldCellZ < 0) oldCellZ = 0;
|
if (oldCellZ < 0) oldCellZ = 0;
|
||||||
if (oldCellX > NUM_CELLS) oldCellX = NUM_CELLS;
|
if (oldCellX >= NUM_CELLS) oldCellX = NUM_CELLS - 1;
|
||||||
if (oldCellZ > NUM_CELLS) oldCellZ = NUM_CELLS;
|
if (oldCellZ >= NUM_CELLS) oldCellZ = NUM_CELLS - 1;
|
||||||
|
|
||||||
m_Cells[oldCellX][oldCellZ].remove(entity);
|
m_Cells[oldCellX][oldCellZ].remove(entity);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user