Skip to content

Commit 018a0d3

Browse files
committed
Check if buffer char array has at least one element before clearing it
1 parent 214c21f commit 018a0d3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/actors/Grid.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,17 @@ void Grid::ProcessInput(int mouseX, int mouseY)
107107
currentTime += deltaTime;
108108
if (currentTime > MAX_TIME)
109109
{
110-
// Clear out the buffer
111-
for (char & i : buffer)
110+
// Check if buffer char array has at least one element
111+
if (bufferIndex > 0)
112112
{
113-
i = '\0';
113+
printf("Clearing buffer char array\n");
114+
// Clear out the buffer
115+
for (char & i : buffer)
116+
{
117+
i = '\0';
118+
}
119+
bufferIndex = 0;
114120
}
115-
bufferIndex = 0;
116121
currentTime = 0.f;
117122
}
118123
}

0 commit comments

Comments
 (0)