From e010cb356b4b4e650206169ede1129e6594f4c33 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 17 Oct 2018 17:19:38 -0400 Subject: [PATCH] Check game config before writing or reading it --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index cdf40d3..8610d83 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,6 +47,8 @@ int toInt(const std::string &str) { void readConfig() { std::ifstream file("config.txt"); + if(!file) + return; std::string line; while(std::getline(file, line)) { @@ -72,6 +74,8 @@ void readConfig() { void writeConfig() { std::ofstream file("config.txt"); + if(!file) + return; int x, y; SDL_GetWindowPosition(window, &x, &y);