MCPcopy Create free account
hub / github.com/Hopson97/MineCraft-One-Week-Challenge / loadConfig

Function loadConfig

Source/Main.cpp:35–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34namespace {
35void loadConfig(Config &config)
36{
37 std::ifstream configFile("config.txt");
38 std::string key;
39
40 if (configFile.is_open()) {
41 while (configFile >> key) {
42 if (key == "renderdistance") {
43 configFile >> config.renderDistance;
44 std::cout << "Config: Render Distance: "
45 << config.renderDistance << '\n';
46 }
47 else if (key == "fullscreen") {
48 configFile >> config.isFullscreen;
49 std::cout << "Config: Full screen mode: " << std::boolalpha
50 << config.isFullscreen << '\n';
51 }
52 else if (key == "windowsize") {
53 configFile >> config.windowX >> config.windowY;
54 std::cout << "Config: Window Size: " << config.windowX << " x "
55 << config.windowY << '\n';
56 }
57 else if (key == "fov") {
58 configFile >> config.fov;
59 std::cout << "Config: Field of Vision: " << config.fov << '\n';
60 }
61 }
62 }
63 else {
64 std::cerr << "Error: Could not find config.txt file! Using defaults.\n";
65 }
66}
67
68void displayInfo()
69{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected