Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit a4f71a9

Browse files
committed
Smashed bugs, upgraded config files
Solved issue #2 and confirmed solution for issue #4 Upgraded config file system to auto-upgrade.
1 parent 0b5ba7a commit a4f71a9

File tree

2 files changed

+81
-46
lines changed

2 files changed

+81
-46
lines changed

Config.h

Lines changed: 81 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,67 +21,83 @@ inline bool stob(std::string&s)
2121
return (s == "1" || s == "on" || s == "true") || false;
2222
}
2323

24-
struct UserConfig {
25-
double requestedMinFrameTime = 0;
26-
double requestedMinFrameTimeMenus = (double)1LL / (double)60LL;
27-
double requestedMinFrameTimeNoFocus = (double)1LL / (double)24LL;
28-
double mainThreadUpdateCoef = 2;
29-
float fov = 83;
24+
struct UserConfig
25+
{
26+
int version = -1;
27+
double requestedMinFrameTime = 90;
28+
double requestedMinFrameTimeMenus = 60;
29+
double requestedMinFrameTimeMovies = 60;
30+
double requestedMinFrameTimeNoFocus = 24;
31+
double mainThreadUpdateCoef = 1;
32+
float fov = 45;
3033
float gamma = 45;
3134
float igmState0Override = 1;
3235
float igmState1Override = 2;
3336
float igmState2Override = 4;
3437
float lockedMouseMulti = 1;
3538
bool bEnableFullSpeedMode = false;
36-
bool bEnableAdaptiveIGM = false;
39+
bool bEnableAdaptiveIGM = true;
3740
bool bEnableAdaptiveMouse = true;
3841
bool bEnableLockedMouseMulti = true;
3942
bool bEnableTransitionSpeedRamp = true;
4043
};
4144

4245
namespace Config {
46+
47+
int cVERSION = 1;
48+
49+
void newUserConfig(UserConfig&uConfig, std::fstream&config, const bool usePriorValues)
50+
{
51+
config.open("fpsconfig.ini", std::fstream::trunc | std::fstream::out);
52+
config.close();
53+
config.open("fpsconfig.ini", std::fstream::in | std::fstream::out);
54+
55+
config
56+
<< "#File version. Changing this will cause the config to update.\n"
57+
<< "version=" << cVERSION << "\n\n"
58+
<< "#In game frametime target. [Default: 60, Recommended: A limit that your PC can hit]\n"
59+
<< "requestedMinFrameTime=" << (usePriorValues ? uConfig.requestedMinFrameTime : 90) << "\n\n"
60+
<< "#Don't want superfast menus? [Default: 60, Recommended: Keep at 60]\n"
61+
<< "requestedMinFrameTimeMenus=" << (usePriorValues ? uConfig.requestedMinFrameTimeMenus : 60) << "\n\n"
62+
<< "#The frametime target when you are not tabbed into the game. [Default: 60, Recommended: <60]\n"
63+
<< "requestedMinFrameTimeNoFocus=" << (usePriorValues ? uConfig.requestedMinFrameTimeNoFocus : 24) << "\n\n"
64+
<< "#The frametime target when you are in a pre-rendered movie. [Default: 29.98, Reccomended: 29.98]\n"
65+
<< "requestedMinFrameTimeMovie=" << (usePriorValues ? uConfig.requestedMinFrameTimeMovies : 60) << "\n\n"
66+
<< "#The in-game field of view. [Default: 45, Recommended: User Preference]\n"
67+
<< "Fov=" << (usePriorValues ? uConfig.fov : 45) << "\n\n"
68+
<< "#The in game gamma (brightness). [Default: 45, Recommended: User Preference]\n"
69+
<< "gamma=" << (usePriorValues ? uConfig.gamma : 45) << "\n\n"
70+
<< "#How many times per frame should the main loop run? Raising this will increase the CPU usage of the program. If you're experiencing performance problems, consider lowering this.\n"
71+
<< "#I suggest not going below one, because that will make the program much less accurate. 0 will crash the program. [Recommended: User Preference]\n"
72+
<< "mainThreadUpdateCoef=" << (usePriorValues ? uConfig.mainThreadUpdateCoef : 1) << "\n\n"
73+
<< "#IGMState overrides change the base multiplier for each state. [Default: 0=1, 1=2, 2=4, Recommended: User Preference]\n"
74+
<< "igmState0Override=" << (usePriorValues ? uConfig.igmState0Override : 1) << "\n"
75+
<< "igmState1Override=" << (usePriorValues ? uConfig.igmState1Override : 2) << "\n"
76+
<< "igmState2Override=" << (usePriorValues ? uConfig.igmState2Override : 4) << "\n\n"
77+
<< "#This works in conjunction with bEnableLockedMouseMulti and bEnableAdaptiveMouse. At least one of them must be enabled for this to be used. [Recommended: User Preference]\n"
78+
<< "lockedMouseMulti=" << (usePriorValues ? uConfig.lockedMouseMulti : 1) << "\n\n"
79+
<< "#If you want to completely disable the speed limiter, enable this. Might have some bad side effects. Setting the minimum frametime to 0 has the same effect, but is theoretically safer. [Recommended: keep off]\n"
80+
<< "bEnableFullSpeedMode=" << (usePriorValues ? uConfig.bEnableFullSpeedMode : false) << "\n\n"
81+
<< "#If your in game animations are running at an incorrect speed, enabling this option may help. [Recommended: keep on]\n"
82+
<< "bEnableAdaptiveIGM=" << (usePriorValues ? uConfig.bEnableAdaptiveIGM : true) << "\n\n"
83+
<< "#If you like the game's default sensitivity scaling, disable this. Enables my relative mouse speed algorithm. [Recommended: User Preference]\n"
84+
<< "bEnableAdaptiveMouse=" << (usePriorValues ? uConfig.bEnableAdaptiveMouse : true) << "\n\n"
85+
<< "#Enabling this will disable the in game mouse sensitivity controller, and lock the relative sensitivity to a desired variable. [Recommended: User Preference]\n"
86+
<< "bEnableLockedMouseMulti=" << (usePriorValues ? uConfig.bEnableLockedMouseMulti : true) << "\n\n"
87+
<< "#This attempts to fix the slowdowns that happen when changing scenes and entering/exiting some menus. Not perfect. [Recommended: keep on]\n"
88+
<< "bEnableTransitionSpeedRamp=" << (usePriorValues ? uConfig.bEnableTransitionSpeedRamp : true) << "\n\n";
89+
90+
config.close();
91+
}
92+
4393
void UpdateUserConfig(UserConfig&uConfig)
4494
{
4595
std::fstream config;
4696
config.open("fpsconfig.ini", std::fstream::in | std::fstream::out);
4797
if (!config)
4898
{
4999
std::cout << "Config file not found! Writing a new one...\n\n";
50-
config.open("fpsconfig.ini", std::fstream::trunc | std::fstream::out);
51-
config.close();
52-
config.open("fpsconfig.ini", std::fstream::in | std::fstream::out);
53-
54-
config << "#In game frametime target. [Default: 60, Recommended: A limit that your PC can hit]\n"
55-
<< "requestedMinFrameTime=90\n\n"
56-
<< "#Don't want superfast menus? [Default: 60, Recommended: Keep at 60]\n"
57-
<< "requestedMinFrameTimeMenus=60\n\n"
58-
<< "#The frametime target when you are not tabbed into the game.[Default: 60, Recommended: <60]\n"
59-
<< "requestedMinFrameTimeNoFocus=24\n\n"
60-
<< "#The in-game field of view. [Default: 45, Recommended: User Preference]\n"
61-
<< "Fov=45\n\n"
62-
<< "#The in game gamma (brightness). [Default: 45, Recommended: User Preference]\n"
63-
<< "gamma=45\n\n"
64-
<< "#How many times per frame should the main loop run? Raising this will increase the CPU usage of the program. If you're experiencing performance problems, consider lowering this.\n"
65-
<< "#I suggest not going below one, because that will make the program much less accurate. 0 will crash the program. [Recommended: User Preference]\n"
66-
<< "mainThreadUpdateCoef=2\n\n"
67-
<< "#IGMState overrides change the base multiplier for each state. [Default: 0=1, 1=2, 2=4, Recommended: User Preference]\n"
68-
<< "igmState0Override=1\n"
69-
<< "igmState1Override=2\n"
70-
<< "igmState2Override=4\n\n"
71-
<< "#This works in conjunction with bEnableLockedMouseMulti and bEnableAdaptiveMouse. At least one of them must be enabled for this to be used. [Recommended: User Preference]\n"
72-
<< "lockedMouseMulti=1\n\n"
73-
<< "#If you want to completely disable the speed limiter, enable this. Might have some bad side effects. Setting the minimum frametime to 0 has the same effect, but is theoretically safer. [Recommended: keep off]\n"
74-
<< "bEnableFullSpeedMode=false\n\n"
75-
<< "#If your in game animations are running at an incorrect speed, enabling this option may help. [Recommended: keep on]\n"
76-
<< "bEnableAdaptiveIGM=true\n\n"
77-
<< "#If you like the game's default sensitivity scaling, disable this. Enables my relative mouse speed algorithm. [Recommended: User Preference]\n"
78-
<< "bEnableAdaptiveMouse=true\n\n"
79-
<< "#Enabling this will disable the in game mouse sensitivity controller, and lock the relative sensitivity to a desired variable. [Recommended: User Preference]\n"
80-
<< "bEnableLockedMouseMulti=true\n\n"
81-
<< "#This attempts to fix the slowdowns that happen when changing scenes and entering/exiting some menus. Not perfect. [Recommended: keep on]\n"
82-
<< "bEnableTransitionSpeedRamp=true\n\n";
83-
84-
config.close();
100+
newUserConfig(uConfig, config, false);
85101
}
86102
else
87103
{
@@ -93,7 +109,12 @@ namespace Config {
93109
{
94110
refLine = inLine.substr(0, inLine.find("=") + 1);
95111

96-
if (refLine == "requestedMinFrameTime=")
112+
if (refLine == "version=")
113+
{
114+
std::string val = inLine.substr(inLine.find("=") + 1);
115+
uConfig.version = std::stoi(val.c_str());
116+
}
117+
else if (refLine == "requestedMinFrameTime=")
97118
{
98119
std::string val = inLine.substr(inLine.find("=") + 1);
99120
uConfig.requestedMinFrameTime = stod(val.c_str());
@@ -103,6 +124,11 @@ namespace Config {
103124
std::string val = inLine.substr(inLine.find("=") + 1);
104125
uConfig.requestedMinFrameTimeMenus = stod(val.c_str());
105126
}
127+
else if (refLine == "requestedMinFrameTimeMovies=")
128+
{
129+
std::string val = inLine.substr(inLine.find("=") + 1);
130+
uConfig.requestedMinFrameTimeMovies = stod(val.c_str());
131+
}
106132
else if (refLine == "requestedMinFrameTimeNoFocus=")
107133
{
108134
std::string val = inLine.substr(inLine.find("=") + 1);
@@ -175,8 +201,11 @@ namespace Config {
175201
}
176202
config.close();
177203

178-
std::cout << "Loaded config \nrequestedMinFrameTime=" << uConfig.requestedMinFrameTime
204+
std::cout << "Loaded config..."
205+
<< "\nconfig version=" << uConfig.version << " cVersion=" << cVERSION
206+
<< "\nrequestedMinFrameTime=" << uConfig.requestedMinFrameTime
179207
<< "\nrequestedMinFrameTimeMenus=" << uConfig.requestedMinFrameTimeMenus
208+
<< "\nrequestedMinFrameTimeMovies=" << uConfig.requestedMinFrameTimeMovies
180209
<< "\nrequestedMinFrameTimeNoFocus=" << uConfig.requestedMinFrameTimeNoFocus
181210
<< "\nmainThreadUpdateCoef=" << uConfig.mainThreadUpdateCoef
182211
<< "\nfov=" << uConfig.fov
@@ -186,12 +215,18 @@ namespace Config {
186215
<< "\nigmState2Override=" << uConfig.igmState2Override
187216
<< "\nlockedMouseMulti=" << uConfig.lockedMouseMulti
188217
<< "\nbEnableFullSpeedMode=" << uConfig.bEnableFullSpeedMode
189-
<< "\nbEnableAdaptiveIGM=" << uConfig.bEnableAdaptiveIGM
218+
<< "\nbEnableAdaptiveIGM=" << uConfig.bEnableAdaptiveIGM
190219
<< "\nbEnableAdaptiveMouse=" << uConfig.bEnableAdaptiveMouse
191220
<< "\nbEnableLockedMouseMulti=" << uConfig.bEnableLockedMouseMulti
192221
<< "\nbEnableTransitionSpeedRamp=" << uConfig.bEnableTransitionSpeedRamp
193-
194222
<< std::endl << std::endl;
223+
224+
if (uConfig.version != cVERSION)
225+
{
226+
std::cout << "Config out of date! Updating...\n";
227+
newUserConfig(uConfig, config, true);
228+
}
229+
195230
}
196231
}
197232
}

FFXIITZAFPSU.cpp

-748 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)