Skip to content

Commit 5b04c44

Browse files
committed
Fixed editing float vars in anim events
1 parent 529bd83 commit 5b04c44

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

DarkSoulsAnimTool/jsonToTae.cpp

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,41 @@ using namespace TAE;
1212

1313
// For debugging unknowns that are written as "123 or 0.000"
1414
int getUnknown(json::JSON value) {
15+
if(value.ToString() == "1.000"){
16+
int bp=42;
17+
}
18+
1519
if (value.JSONType() == json::JSON::Class::Integral) {
1620
return value.ToInt();
21+
}else if (value.JSONType() == json::JSON::Class::Floating) {
22+
// fuck
23+
float floatValue = value.ToFloat();
24+
int intValue;
25+
*(reinterpret_cast<float*>(&intValue)) = floatValue;
26+
27+
return intValue;
1728
}
1829

1930
std::string text = value.ToString();
20-
for (size_t n = 0; n < text.size(); ++n) {
21-
if (text[n] == ' ') {
22-
text.resize(n);
23-
break;
31+
bool isFloat = text.find('.') != std::string::npos && text.find(' ') == std::string::npos;
32+
if(isFloat){
33+
float floatValue = (float)atof(text.c_str());
34+
int intValue;
35+
*(reinterpret_cast<float*>(&intValue)) = floatValue;
36+
37+
return intValue;
38+
}else{
39+
for (size_t n = 0; n < text.size(); ++n) {
40+
if (text[n] == ' ') {
41+
text.resize(n);
42+
break;
43+
}
2444
}
25-
}
2645

27-
int result = atoi(text.c_str());
46+
int result = atoi(text.c_str());
2847

29-
return result;
48+
return result;
49+
}
3050
}
3151

3252
void getUnknownArray(json::JSON array, int* source, size_t size) {

0 commit comments

Comments
 (0)