X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FUser%2FSettings.cpp;h=4890f45f1d7c883f302b03b0314c929d001b4753;hb=4dfbee7192000c0047a73d48fb10a33d39261d89;hp=e3f709e580691a58c3f17dca3822b47167ba1af6;hpb=8b6e8f3ad7390309795eb35c0959264cb7924402;p=lugaru.git diff --git a/Source/User/Settings.cpp b/Source/User/Settings.cpp index e3f709e..4890f45 100644 --- a/Source/User/Settings.cpp +++ b/Source/User/Settings.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2003, 2010 - Wolfire Games -Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) +Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. @@ -70,18 +70,18 @@ void DefaultSettings() void SaveSettings() { - if (newdetail < 0) + if (newdetail < 0) { newdetail = 0; - if (newdetail > 2) + } + if (newdetail > 2) { newdetail = 2; - if (newscreenwidth > 3000) - newscreenwidth = screenwidth; - if (newscreenwidth < 0) + } + if (newscreenwidth < minscreenwidth || newscreenwidth > maxscreenwidth) { newscreenwidth = screenwidth; - if (newscreenheight > 3000) - newscreenheight = screenheight; - if (newscreenheight < 0) + } + if (newscreenheight < minscreenheight || newscreenheight > maxscreenheight) { newscreenheight = screenheight; + } errno = 0; ofstream opstream(Folders::getConfigFilePath()); if (opstream.fail()) { @@ -121,8 +121,9 @@ void SaveSettings() opstream << "\nInvert mouse:\n"; opstream << invertmouse; opstream << "\nGamespeed:\n"; - if (oldgamespeed == 0) + if (oldgamespeed == 0) { oldgamespeed = 1; + } opstream << oldgamespeed; opstream << "\nDamage effects(blackout, doublevision):\n"; opstream << damageeffects; @@ -187,8 +188,9 @@ bool LoadSettings() // skip blank lines // assume lines starting with spaces are all blank - if (strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t') + if (strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t') { continue; + } //~ printf("setting : %s\n",setting); if (ipstream.eof() || ipstream.fail()) { @@ -199,8 +201,14 @@ bool LoadSettings() if (!strncmp(setting, "Screenwidth", 11)) { ipstream >> kContextWidth; + if (kContextWidth < (int)minscreenwidth || kContextWidth > (int)maxscreenwidth) { + kContextWidth = (int)minscreenwidth; + } } else if (!strncmp(setting, "Screenheight", 12)) { ipstream >> kContextHeight; + if (kContextHeight < (int)minscreenheight || kContextHeight > (int)maxscreenheight) { + kContextHeight = (int)minscreenheight; + } } else if (!strncmp(setting, "Fullscreen", 10)) { ipstream >> fullscreen; } else if (!strncmp(setting, "Mouse sensitivity", 17)) { @@ -302,14 +310,18 @@ bool LoadSettings() ipstream.close(); - if (detail > 2) + if (detail > 2) { detail = 2; - if (detail < 0) + } + if (detail < 0) { detail = 0; - if (screenwidth < 0) + } + if (screenwidth < minscreenwidth || screenwidth > maxscreenwidth) { screenwidth = 1024; - if (screenheight < 0) + } + if (screenheight < minscreenheight || screenheight > maxscreenheight) { screenheight = 768; + } newdetail = detail; return true;