Skip to content

Commit cf8e194

Browse files
committed
add support for double value type
1 parent 42e90c4 commit cf8e194

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

SUWSF.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pattern="39 8E E3 3F"
1717
Offset=0
1818
; Value to write. Numbers or variables (aspectratio, width, height) are accepted. Bytes are accepted if ValueType="byte"
1919
Value="aspectratio"
20-
; Type of value. Accepted values are: "float", "int", "byte" (default: "float")
20+
; Type of value. Accepted values are: "float", "double", "int", "byte" (default: "float")
2121
ValueType="float"
2222
; Which match to write to. Accepted values are: number of match (starting from 1), last, all. (default: "all")
2323
Match="all"

SUWSF/GenericPatch.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ std::vector<GenericPatch::Config> GenericPatch::GetConfigs()
7373
{
7474
DBOUT("ValueType=" << params.second);
7575
config.valType = params.second;
76-
if (config.valType != "float" && config.valType != "byte" && config.valType != "int")
76+
if (config.valType != "float" && config.valType != "byte" && config.valType != "int" && config.valType != "double")
7777
{
7878
DBOUT("ValueType unsupported. Supported types are: float, byte...Skipping patch...");
7979
goto CONTINUE;
@@ -104,15 +104,15 @@ std::vector<GenericPatch::Config> GenericPatch::GetConfigs()
104104
DBOUT("No pattern found, skipping patch...");
105105
goto CONTINUE;
106106
}
107-
if (config.valType == "float" || config.valType == "int")
107+
if (config.valType == "float" || config.valType == "int" || config.valType == "double")
108108
{
109109
try
110110
{
111111
boost::replace_all(config.val, "width", std::to_string(UserSettings::config.width));
112112
boost::replace_all(config.val, "height", std::to_string(UserSettings::config.height));
113113
boost::replace_all(config.val, "aspectratio", std::to_string(UserSettings::config.aspectratio));
114114
int error = -1;
115-
float f = te_interp(config.val.c_str(), &error);
115+
double d = te_interp(config.val.c_str(), &error);
116116

117117
if (error != 0)
118118
{
@@ -122,13 +122,18 @@ std::vector<GenericPatch::Config> GenericPatch::GetConfigs()
122122

123123
if (config.valType == "float")
124124
{
125+
float f = static_cast<float>(d);
125126
config.val = hexStr(reinterpret_cast<BYTE*>(&f), sizeof(float));
126127
}
127128
else if (config.valType == "int")
128129
{
129-
int i = static_cast<int>(f);
130+
int i = static_cast<int>(d);
130131
config.val = hexStr(reinterpret_cast<BYTE*>(&i), sizeof(int));
131132
}
133+
else if (config.valType == "double")
134+
{
135+
config.val = hexStr(reinterpret_cast<BYTE*>(&d), sizeof(double));
136+
}
132137
}
133138
catch (std::exception const& e)
134139
{

SUWSF/UserSettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void UserSettings::SetConfig()
3333
config.width = std::stoi(resStrings.at(0));
3434
config.height = std::stoi(resStrings.at(1));
3535
}
36-
config.aspectratio = (float)config.width / config.height;
36+
config.aspectratio = (double)config.width / config.height;
3737
DBOUT("Detected width is " << config.width);
3838
DBOUT("Detected height is " << config.height);
3939
DBOUT("Detected aspect ratio is " << config.aspectratio);

SUWSF/UserSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class UserSettings
88
struct Config
99
{
1010
int width, height;
11-
float aspectratio;
11+
double aspectratio;
1212
bool enabled = true;
1313
};
1414
static Config config;

0 commit comments

Comments
 (0)