Reset LastError in some functions for game devs that can't code.

This commit is contained in:
Mr_Goldberg 2022-08-11 20:52:02 -04:00
parent 0c16f1942a
commit 3abc5976e0
No known key found for this signature in database
GPG key ID: 8597D87419DEF278
4 changed files with 14 additions and 0 deletions

View file

@ -99,6 +99,11 @@ inline std::wstring utf8_decode(const std::string &str)
return wstrTo;
}
inline void reset_LastError()
{
SetLastError(0);
}
#elif defined(__LINUX__)
#include <arpa/inet.h>
@ -129,6 +134,7 @@ inline std::wstring utf8_decode(const std::string &str)
#define PATH_SEPARATOR "/"
#define utf8_decode(a) a
#define reset_LastError()
#endif
//#define PRINT_DEBUG(...) fprintf(stdout, __VA_ARGS__)
#ifdef EMU_RELEASE_BUILD

View file

@ -112,6 +112,7 @@ static void load_old_interface_versions()
PRINT_DEBUG("networking: %s\n", old_networking);
PRINT_DEBUG("html surface: %s\n", old_html_surface);
PRINT_DEBUG("utils: %s\n", old_utils);
reset_LastError();
loaded = true;
}

View file

@ -261,6 +261,7 @@ static std::vector<struct File_Data> get_filenames_recursive_w(std::wstring base
//printf("Failed to find path: %s", strPath.c_str());
}
reset_LastError();
return output;
}
@ -569,6 +570,7 @@ int Local_Storage::get_file_data(std::string full_path, char *data, unsigned int
myfile.seekg (offset, std::ios::beg);
myfile.read (data, max_length);
myfile.close();
reset_LastError();
return myfile.gcount();
}
@ -726,6 +728,7 @@ bool Local_Storage::load_json(std::string full_path, nlohmann::json& json)
PRINT_DEBUG("Couldn't open file \"%s\" to read json\n", full_path.c_str());
}
reset_LastError();
return false;
}
@ -759,6 +762,7 @@ bool Local_Storage::write_json_file(std::string folder, std::string const&file,
PRINT_DEBUG("Couldn't open file \"%s\" to write json\n", full_path.c_str());
reset_LastError();
return false;
}
@ -774,6 +778,8 @@ std::vector<image_pixel_t> Local_Storage::load_image(std::string const& image_pa
stbi_image_free(img);
}
reset_LastError();
return res;
}

View file

@ -588,6 +588,7 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
*settings_server_out = settings_server;
*local_storage_out = local_storage;
reset_LastError();
return appid;
}