From d7c85737673ee5e8e9b56d5afefdfc96f6b3ed4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Mon, 21 Nov 2016 21:18:31 +0800 Subject: [PATCH] Avoid using unitialized var in corner cases (fixes cppcheck warning) --- Source/GameDraw.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index 3966a57..93766d3 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -461,10 +461,10 @@ int Game::DrawGLScene(StereoSide side) if (distance >= .5) { checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords; checkpoint.y += 1; - int i; - if (!Person::players[k]->occluded == 0) + int i = -1; + if (Person::players[k]->occluded != 0) i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded); - if (i == -1 || Person::players[k]->occluded == 0) + if (i == -1) i = checkcollide(viewer, checkpoint); if (i != -1) { Person::players[k]->occluded += 1; @@ -526,10 +526,10 @@ int Game::DrawGLScene(StereoSide side) if (distance >= .5) { checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords; checkpoint.y += 1; - int i; - if (!Person::players[k]->occluded == 0) + int i = -1; + if (Person::players[k]->occluded != 0) i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded); - if (i == -1 || Person::players[k]->occluded == 0) + if (i == -1) i = checkcollide(viewer, checkpoint); if (i != -1) { Person::players[k]->occluded += 1; -- 2.39.5