summary refs log tree commit diff
path: root/src/GameInitDispose.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GameInitDispose.cpp')
-rw-r--r--src/GameInitDispose.cpp82
1 files changed, 16 insertions, 66 deletions
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp
index 782cf6a..b208df5 100644
--- a/src/GameInitDispose.cpp
+++ b/src/GameInitDispose.cpp
@@ -22,6 +22,7 @@
 
 #include <AL/alc.h>
 
+#include "config.h"
 #include "Textures.h"
 #include "Game.h"
 
@@ -57,9 +58,21 @@ extern int aimkey;
 extern int psychicaimkey;
 extern int psychickey;
 
-Game* makeGame()
+Game* makeGame(Config config)
 {
-	return new Game();
+	auto game = new Game();
+	game->screenwidth = config.screen_width;
+	game->screenheight = config.screen_height;
+	game->usermousesensitivity = config.mouse_sensitivity;
+	game->debug = config.debug;
+	game->vblsync = config.vsync;
+	blood = config.blood;
+	game->blurness = config.blur;
+	game->mainmenuness = config.menu;
+	game->customlevels = config.custom_levels;
+	game->musictoggle = config.music;
+	game->azertykeyboard = config.azerty;
+	return game;
 }
 
 void LoadSounds(bool musictoggle)
@@ -1781,69 +1794,6 @@ void initGl(Game* game)
 	// Config
 	game->mousesensitivity = 1.0f;
 	if (!game->initialized) {
-		ifstream ipstream {"config.txt"};
-		// If no config, write one
-		if (!ipstream) {
-			ofstream opstream("config.txt");
-			opstream << "Screenwidth:\n";
-			opstream << (game->screenwidth = 640);
-			opstream << "\nScreenheight:\n";
-			opstream << (game->screenheight = 480);
-			opstream << "\nMouse sensitivity:\n";
-			opstream << (game->usermousesensitivity = 0.7f);
-			opstream << "\nShow fps and other info:\n";
-			opstream << (game->debug = false);
-			opstream << "\nVBL sync:\n";
-			opstream << (game->vblsync = true);
-			opstream << "\nBlood:\n";
-			opstream << (blood = true);
-			opstream << "\nBlur:\n";
-			opstream << (game->blurness = false);
-			opstream << "\nMain Menu:\n";
-			opstream << (game->mainmenuness = true);
-			opstream << "\nCustom levels:\n";
-			opstream << (game->customlevels = false);
-			opstream << "\nMusic:\n";
-			opstream << (game->musictoggle = true);
-			opstream << "\azerty keyboard:\n";
-			opstream << (game->azertykeyboard = false) << endl;
-			opstream.close();
-		} else {
-			ipstream.ignore(256,'\n');
-			ipstream >> game->screenwidth;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> game->screenheight;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> game->usermousesensitivity;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> game->debug;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> game->vblsync;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> blood;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> game->blurness;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> game->mainmenuness;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> game->customlevels;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> game->musictoggle;
-			ipstream.ignore(256,'\n');
-			ipstream.ignore(256,'\n');
-			ipstream >> game->azertykeyboard;
-			ipstream.close();
-		}
-
 		// TODO: Read high score
 		ifstream ipstream2 {"highscore.txt"};
 		if (!ipstream2) {
@@ -1853,7 +1803,7 @@ void initGl(Game* game)
 			opstream.close();
 		} else {
 			ipstream2 >> game->highscore;
-			ipstream.ignore(256,'\n');
+			ipstream2.ignore(256,'\n');
 			ipstream2 >> game->beatgame;
 			ipstream2.close();
 		}