Check game config before writing or reading it
This commit is contained in:
parent
b700ed3111
commit
e010cb356b
1 changed files with 4 additions and 0 deletions
|
@ -47,6 +47,8 @@ int toInt(const std::string &str) {
|
||||||
|
|
||||||
void readConfig() {
|
void readConfig() {
|
||||||
std::ifstream file("config.txt");
|
std::ifstream file("config.txt");
|
||||||
|
if(!file)
|
||||||
|
return;
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while(std::getline(file, line)) {
|
while(std::getline(file, line)) {
|
||||||
|
@ -72,6 +74,8 @@ void readConfig() {
|
||||||
|
|
||||||
void writeConfig() {
|
void writeConfig() {
|
||||||
std::ofstream file("config.txt");
|
std::ofstream file("config.txt");
|
||||||
|
if(!file)
|
||||||
|
return;
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
SDL_GetWindowPosition(window, &x, &y);
|
SDL_GetWindowPosition(window, &x, &y);
|
||||||
|
|
Reference in a new issue