From 56ca9d694b9828eec3da741891eeddd27f1d5a70 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Tue, 2 Jun 2015 18:39:17 +0200 Subject: [PATCH] Added a little bit of input validation. --- game/graphics.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/game/graphics.cc b/game/graphics.cc index d5a38d5..ef5fb98 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -21,9 +21,24 @@ Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, std::string screenContinuePath) { this->windowSize = windowSize; this->nearPlane = nearPlane; - this->farPlane = farPlane; - this->cube_size = cube_size; - this->maxShadowRenderCount = maxShadowRenderCount; + if (farPlane > 0) { + this->farPlane = farPlane; + } + else { + this->farPlane = 0; + } + if (cube_size > 0) { + this->cube_size = cube_size; + } + else { + this->cube_size = 0; + } + if (maxShadowRenderCount < 15) { + this->maxShadowRenderCount = maxShadowRenderCount; + } + else { + this->maxShadowRenderCount = 0; + } this->loadingScreenPath = screenPath; this->loadingScreenContinuePath = screenContinuePath; gameStart = false;