cleanup and fixes
This commit is contained in:
parent
2a454e096b
commit
2abdb74885
@ -355,41 +355,38 @@ namespace party
|
||||
|
||||
bool download_files(const game::netadr_s& target, const utils::info_string& info, bool allow_download);
|
||||
|
||||
int user_download_response(game::hks::lua_State* state)
|
||||
void user_download_response(bool response)
|
||||
{
|
||||
const auto response = state->m_apistack.base[0].v.boolean;
|
||||
if (!response)
|
||||
{
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
nlohmann::json obj = get_whitelist_json_object();
|
||||
if (obj == nullptr)
|
||||
{
|
||||
return 0;
|
||||
obj = {};
|
||||
}
|
||||
|
||||
obj.insert(obj.end(), target_ip_to_string(saved_info_response.host));
|
||||
utils::io::write_file_json(get_whitelist_json_path(), obj);
|
||||
obj.push_back(target_ip_to_string(saved_info_response.host));
|
||||
|
||||
utils::io::write_file(get_whitelist_json_path(), obj.dump(4));
|
||||
|
||||
download_files(saved_info_response.host, saved_info_response.info_string, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool should_user_confirm(const game::netadr_s& target, const utils::info_string& info)
|
||||
{
|
||||
nlohmann::json obj = get_whitelist_json_object();
|
||||
if (obj == nullptr)
|
||||
if (obj != nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto target_ip = target_ip_to_string(target);
|
||||
for (const auto& [key, value] : obj.items())
|
||||
{
|
||||
if (value.is_string() && value.get<std::string>() == target_ip)
|
||||
const auto target_ip = target_ip_to_string(target);
|
||||
for (const auto& [key, value] : obj.items())
|
||||
{
|
||||
return false;
|
||||
if (value.is_string() && value.get<std::string>() == target_ip)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,27 +19,6 @@ namespace utils::io
|
||||
return std::ifstream(file).good();
|
||||
}
|
||||
|
||||
bool write_file_json(const std::string& file, const nlohmann::json& object)
|
||||
{
|
||||
const auto pos = file.find_last_of("/\\");
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
create_directory(file.substr(0, pos));
|
||||
}
|
||||
|
||||
std::ofstream stream(
|
||||
file, std::ios::binary | std::ofstream::out);
|
||||
|
||||
if (stream.is_open())
|
||||
{
|
||||
stream << object;
|
||||
stream.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool write_file(const std::string& file, const std::string& data, const bool append)
|
||||
{
|
||||
const auto pos = file.find_last_of("/\\");
|
||||
|
@ -10,7 +10,6 @@ namespace utils::io
|
||||
bool remove_file(const std::string& file);
|
||||
bool move_file(const std::string& src, const std::string& target);
|
||||
bool file_exists(const std::string& file);
|
||||
bool write_file_json(const std::string& file, const nlohmann::json& object);
|
||||
bool write_file(const std::string& file, const std::string& data, bool append = false);
|
||||
bool read_file(const std::string& file, std::string* data);
|
||||
std::string read_file(const std::string& file);
|
||||
|
Loading…
Reference in New Issue
Block a user