Decompile 5 functions in Source/Utility/JsonCppLoader.cpp, Source/Utility/JsonCppLoader.h
Batch #7629 by secret: 0 byte-identical, 5 confirmed by peer review. - fn_00886 JsonCppLoader::GetIntValue: logic confirmed by peer review - fn_00887 JsonCppLoader::GetStringValue: logic confirmed by peer review - fn_00888 JsonCppLoader::GetMapStringIntValue: logic confirmed by peer review - fn_00892 JsonCppLoader::GetIntVectorValue: logic confirmed by peer review - fn_00893 JsonCppLoader::GetBoolValue: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, Yommy Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
parent
2d614f9b90
commit
73454eaa71
2 changed files with 113 additions and 0 deletions
|
|
@ -44,3 +44,100 @@ bool JsonCppLoader::GetMapStringBoolValue(const JsonValue& node, const std::stri
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
// OFFSET: 0x00508570
|
||||
// FUNCTION: fn_00886
|
||||
bool JsonCppLoader::GetIntValue(const JsonValue& node, const std::string& key, int* out) {
|
||||
JsonValue value;
|
||||
this->GetValue(value, key, node, JsonValue::INT64_VALUE);
|
||||
if (value.IsNull()) {
|
||||
this->Fail("key 에 해당하는 데이터를 찾지 못했습니다. (keyName : %s)", key.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
*out = value.AsInt();
|
||||
return true;
|
||||
}
|
||||
|
||||
// OFFSET: 0x005086D0
|
||||
// FUNCTION: fn_00887
|
||||
bool JsonCppLoader::GetStringValue(const JsonValue& node, const std::string& key, std::string* out) {
|
||||
JsonValue value;
|
||||
this->GetValue(value, key, node, JsonValue::STRING_VALUE);
|
||||
if (value.IsNull()) {
|
||||
this->Fail("key 에 해당하는 데이터를 찾지 못했습니다. (keyName : %s)", key.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
*out = value.AsString();
|
||||
return true;
|
||||
}
|
||||
|
||||
// OFFSET: 0x005087D0
|
||||
// FUNCTION: fn_00888
|
||||
bool JsonCppLoader::GetMapStringIntValue(const JsonValue& node, const std::string& key, std::map<std::string, int>* out) {
|
||||
JsonValue value;
|
||||
this->GetValue(value, key, node, JsonValue::OBJECT_VALUE);
|
||||
if (value.IsNull()) {
|
||||
this->Fail("key 에 해당하는 데이터를 찾지 못했습니다. (keyName : %s)", key.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
const JsonObject& members = value.GetObject();
|
||||
for (JsonObject::const_iterator member = members.begin(); member != members.end(); ++member) {
|
||||
std::string name = member->first;
|
||||
JsonValue element = member->second;
|
||||
if (element.GetType() != JsonValue::INT64_VALUE) {
|
||||
this->Fail("잘못된 데이터가 입력되었습니다. intValue 가 입력되어야 합니다. (keyName : %s)", key.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!out->insert(std::make_pair(name, element.AsInt())).second) {
|
||||
this->Fail("중복키가 입력되었습니다. (keyName : %s)", key.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// OFFSET: 0x00508BD0
|
||||
|
||||
// OFFSET: 0x00509130
|
||||
|
||||
// OFFSET: 0x00509D40
|
||||
// FUNCTION: fn_00892
|
||||
bool JsonCppLoader::GetIntVectorValue(const JsonValue& node, const std::string& key, std::vector<int>* out) {
|
||||
JsonValue value;
|
||||
this->GetValue(value, key, node, JsonValue::ARRAY_VALUE);
|
||||
if (value.IsNull()) {
|
||||
this->Fail("key 에 해당하는 데이터를 찾지 못했습니다. (keyName : %s)", key.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
const JsonArray& items = value.ArrayRange();
|
||||
for (JsonArray::const_iterator item = items.begin(); item != items.end(); ++item) {
|
||||
if (item->GetType() != JsonValue::INT64_VALUE) {
|
||||
this->Fail("잘못된 데이터가 입력되었습니다. intValue 가 입력되어야 합니다. (keyName : %s)", key.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
out->push_back(item->AsInt());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// OFFSET: 0x00509F70
|
||||
// FUNCTION: fn_00893
|
||||
bool JsonCppLoader::GetBoolValue(const JsonValue& node, const std::string& key, bool* out) {
|
||||
JsonValue value;
|
||||
this->GetValue(value, key, node, JsonValue::BOOL_VALUE);
|
||||
if (value.IsNull()) {
|
||||
this->Fail("key 에 해당하는 데이터를 찾지 못했습니다. (keyName : %s)", key.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
*out = value.AsBool();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public:
|
|||
std::string AsString() const;
|
||||
const JsonObject& GetObject() const;
|
||||
const JsonArray& GetArray() const;
|
||||
const JsonArray& ArrayRange() const;
|
||||
|
||||
/* 0000 */ unsigned char type;
|
||||
/* 0001 */ unsigned char unknown_0001;
|
||||
|
|
@ -157,12 +158,27 @@ inline const JsonArray& JsonValue::GetArray() const {
|
|||
return *static_cast<const JsonArray*>(this->Dereference()->pointer);
|
||||
}
|
||||
|
||||
inline const JsonArray& JsonValue::ArrayRange() const {
|
||||
if ((this->type & 0x0f) != 9) {
|
||||
throw std::domain_error("Not an array");
|
||||
}
|
||||
|
||||
return *static_cast<const JsonArray*>(this->pointer);
|
||||
}
|
||||
|
||||
class JsonCppLoader {
|
||||
public:
|
||||
JsonValue& GetValue(JsonValue& out, const std::string& key, const JsonValue& node, int expectedType);
|
||||
void Fail(const char* format, ...);
|
||||
|
||||
bool GetIntValue(const JsonValue& node, const std::string& key, int* out);
|
||||
bool GetStringValue(const JsonValue& node, const std::string& key, std::string* out);
|
||||
bool GetMapStringIntValue(const JsonValue& node, const std::string& key, std::map<std::string, int>* out);
|
||||
bool GetMapStringStringValue(const JsonValue& node, const std::string& key, std::map<std::string, std::string>* out);
|
||||
bool GetMapStringIntVectorValue(const JsonValue& node, const std::string& key, std::map<std::string, std::vector<int> >* out);
|
||||
bool GetMapStringBoolValue(const JsonValue& node, const std::string& key, std::map<std::string, bool>* out);
|
||||
bool GetIntVectorValue(const JsonValue& node, const std::string& key, std::vector<int>* out);
|
||||
bool GetBoolValue(const JsonValue& node, const std::string& key, bool* out);
|
||||
bool sub_4F3C70(std::vector<unsigned char>& buffer, bool bson);
|
||||
bool sub_50C2A0(std::map<std::string, EZ2STREffectRecord>* out);
|
||||
bool sub_50AE30(std::map<int, ReputeGroupRecord>* out);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue