mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
troubleshooter: add more detection (#397)
## Description of change Detect and log troubleshooter messages for: * (early) hook DLL load failure * data_mods folder without ifs_hook.dll * spice version (print out current version and add a link to github download) ## Testing
This commit is contained in:
@@ -97,6 +97,7 @@
|
||||
#include "touch/touch.h"
|
||||
#include "util/cpuutils.h"
|
||||
#include "util/crypt.h"
|
||||
#include "util/deferlog.h"
|
||||
#include "util/fileutils.h"
|
||||
#include "util/libutils.h"
|
||||
#include "util/logging.h"
|
||||
@@ -1375,7 +1376,11 @@ int main_implementation(int argc, char *argv[]) {
|
||||
log_info("launcher", "loading early hook DLL {}", hook);
|
||||
HMODULE module;
|
||||
if (!(module = libutils::try_library(hook))) {
|
||||
log_warning("launcher", "failed to load early hook {}", hook);
|
||||
log_warning("launcher", "failed to load early hook {}: {}", hook, get_last_error_string());
|
||||
deferredlogs::defer_error_messages({
|
||||
fmt::format("failed to load early hook {}:", hook),
|
||||
fmt::format(" {}", get_last_error_string())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2155,7 +2160,11 @@ int main_implementation(int argc, char *argv[]) {
|
||||
log_info("launcher", "loading hook DLL {}", hook);
|
||||
HMODULE module;
|
||||
if (!(module = libutils::try_library(hook))) {
|
||||
log_warning("launcher", "failed to load hook {}", hook);
|
||||
log_warning("launcher", "failed to load hook {}: {}", hook, get_last_error_string());
|
||||
deferredlogs::defer_error_messages({
|
||||
fmt::format("failed to load hook {}:", hook),
|
||||
fmt::format(" {}", get_last_error_string())
|
||||
});
|
||||
} else {
|
||||
bt5api_hook(module);
|
||||
}
|
||||
@@ -2164,9 +2173,13 @@ int main_implementation(int argc, char *argv[]) {
|
||||
// layeredfs
|
||||
if (fileutils::dir_exists("data_mods") &&
|
||||
GetModuleHandleA("ifs_hook.dll") == nullptr) {
|
||||
log_warning("launcher", "data_mods directory was found, but ifs_hook.dll is not present; your mods will not load");
|
||||
log_warning("launcher", "to fix this, download ifs_layeredfs and add it as a DLL hook (-k)");
|
||||
log_warning("launcher", "https://github.com/mon/ifs_layeredfs");
|
||||
log_warning("launcher", "data_mods directory found, but ifs_hook.dll is not present; mods will not load");
|
||||
deferredlogs::defer_error_messages({
|
||||
"data_mods directory was found, but ifs_hook.dll is not present",
|
||||
" your mods will not load",
|
||||
" to fix this, download ifs_layeredfs and add it as a DLL hook (-k)",
|
||||
" https://github.com/mon/ifs_layeredfs"
|
||||
});
|
||||
}
|
||||
|
||||
// apply patches
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
|
||||
#include "build/defs.h"
|
||||
#include "deferlog.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
@@ -39,27 +40,36 @@ namespace deferredlogs {
|
||||
errors = std::move(deferred_errors);
|
||||
}
|
||||
|
||||
log_warning("troubleshooter", "/------------------------ spice2x auto-troubleshooter ------------------------\\");
|
||||
log_warning("troubleshooter", "");
|
||||
std::string msg;
|
||||
msg += "\n\n";
|
||||
msg += "/-------------------------- spice2x auto-troubleshooter -----------------------\\\n";
|
||||
msg += "\n";
|
||||
msg += " spice2x version: " + to_string(VERSION_STRING_CFG) + "\n";
|
||||
msg += "\n";
|
||||
|
||||
if (is_crash) {
|
||||
log_warning("troubleshooter", " the game has crashed");
|
||||
log_warning("troubleshooter", " share this entire log file with someone for troubleshooting");
|
||||
log_warning("troubleshooter", " spice will also attempt to create a minidump (minidump.dmp)");
|
||||
log_warning("troubleshooter", "");
|
||||
msg += " the game has crashed\n";
|
||||
msg += " share this entire log file with someone for troubleshooting (log.txt)\n";
|
||||
msg += " spice will also attempt to create a minidump (minidump.dmp)\n";
|
||||
msg += "\n";
|
||||
}
|
||||
|
||||
for (auto messages : errors) {
|
||||
for (auto message : messages) {
|
||||
log_warning("troubleshooter", " {}", message);
|
||||
msg += " " + message + "\n";
|
||||
}
|
||||
log_warning("troubleshooter", "");
|
||||
msg += "\n";
|
||||
}
|
||||
|
||||
log_warning("troubleshooter", " unsure what to do next? check the FAQ:");
|
||||
log_warning("troubleshooter", " https://github.com/spice2x/spice2x.github.io/wiki/Known-issues");
|
||||
log_warning("troubleshooter", "");
|
||||
log_warning("troubleshooter", "\\------------------------ spice2x auto-troubleshooter -----------------------/");
|
||||
msg += " unsure what to do next?\n";
|
||||
msg += " * update to the latest version:\n";
|
||||
msg += " https://github.com/spice2x/spice2x.github.io/releases/latest\n";
|
||||
msg += " * check the FAQ:\n";
|
||||
msg += " https://github.com/spice2x/spice2x.github.io/wiki/Known-issues\n";
|
||||
msg += "\n";
|
||||
msg += "\\------------------------- spice2x auto-troubleshooter ------------------------/\n";
|
||||
|
||||
log_warning("troubleshooter", "{}", msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,8 @@ static inline std::string get_last_error_string() {
|
||||
LPSTR messageBuffer = nullptr;
|
||||
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
nullptr,
|
||||
error,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
@@ -292,7 +293,12 @@ static inline std::string get_last_error_string() {
|
||||
nullptr);
|
||||
|
||||
// return as string
|
||||
std::string message(messageBuffer, size);
|
||||
std::string message;
|
||||
if (size == 0) {
|
||||
message = fmt::format("(Win32 error {})", error);
|
||||
} else {
|
||||
message = fmt::format("{}(Win32 error {})", messageBuffer, error);
|
||||
}
|
||||
LocalFree(messageBuffer);
|
||||
|
||||
return message;
|
||||
|
||||
Reference in New Issue
Block a user