mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 06:40:42 -07:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 750b1fea80 | |||
| 4c87078807 | |||
| 052698afa3 | |||
| 9e2b04d5db | |||
| 5641e06a19 | |||
| 88ec6dbcee | |||
| 1b614c94a7 | |||
| 37c5913f69 | |||
| 2eca668593 | |||
| aec1da9d16 | |||
| 548b441f1f | |||
| 98bc285d98 | |||
| 553c180bee |
@@ -1503,7 +1503,8 @@ namespace avs {
|
||||
" * Do NOT copy over random DLLs from another game installation; DLL must match game version\n"
|
||||
"\n"
|
||||
, DLL_NAME, MODULE_PATH.string()) };
|
||||
log_fatal("avs-ea3", "{}", info_str);
|
||||
log_warning("avs-ea3", "{}", info_str);
|
||||
log_fatal("avs-ea3", "Failed to find critical avs DLL on disk (avs2-core.dll OR {})", DLL_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,9 @@ namespace avs {
|
||||
" * Do NOT copy over random DLLs from another game installation; DLL must match game version\n"
|
||||
"\n"
|
||||
, DLL_NAME, MODULE_PATH.string()) };
|
||||
log_fatal("avs-ea3", "{}", info_str);
|
||||
|
||||
log_warning("avs-ea3", "{}", info_str);
|
||||
log_fatal("avs-ea3", "Failed to find critical ea3 DLL on disk (avs2-ea3.dll OR {})", DLL_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace avs {
|
||||
|
||||
// ddr gamemdx.dll user error
|
||||
if (avs::game::is_model("MDX") && DLL_NAME == "gamemdx.dll") {
|
||||
log_fatal(
|
||||
log_warning(
|
||||
"ddr",
|
||||
"BAD GAME DLL ERROR\n\n"
|
||||
"!!! !!!\n"
|
||||
@@ -107,6 +107,7 @@ namespace avs {
|
||||
"!!! remove -exec argument and try again. !!!\n"
|
||||
"!!! !!!\n"
|
||||
);
|
||||
log_fatal("ddr", "BAD GAME DLL ERROR (don't use -exec gamemdx.dll, that's the wrong DLL)");
|
||||
}
|
||||
|
||||
// file not found on disk
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
del /s /q .ccache
|
||||
del /s /q dist
|
||||
call build_docker.bat
|
||||
@@ -125,7 +125,7 @@ namespace games::ddr {
|
||||
|
||||
void DDRGame::pre_attach() {
|
||||
if (!cfg::CONFIGURATOR_STANDALONE && avs::game::is_model("TDX")) {
|
||||
log_fatal(
|
||||
log_warning(
|
||||
"ddr",
|
||||
"BAD MODEL NAME ERROR\n\n\n"
|
||||
"!!! model name set to TDX, this is WRONG and will break your game !!!\n"
|
||||
@@ -136,6 +136,8 @@ namespace games::ddr {
|
||||
"!!! !!!\n"
|
||||
"!!! model name set to TDX, this is WRONG and will break your game !!!\n\n\n"
|
||||
);
|
||||
|
||||
log_fatal("ddr", "BAD MODEL NAME ERROR - TDX specified, should be MDX instead");
|
||||
}
|
||||
|
||||
if (!cfg::CONFIGURATOR_STANDALONE && avs::game::DEST[0] == 'U') {
|
||||
|
||||
@@ -22,35 +22,31 @@
|
||||
static std::filesystem::path dll_path;
|
||||
static HMODULE iidx_module;
|
||||
static uintptr_t addr_hook_a = 0;
|
||||
static uintptr_t addr_hook_b = 0;
|
||||
static uintptr_t addr_textures = 0;
|
||||
static uintptr_t addr_camera_manager = 0;
|
||||
static uintptr_t addr_device_offset = 0;
|
||||
static uintptr_t addr_afp_texture_offset = 0;
|
||||
|
||||
typedef void **(__fastcall *camera_hook_a_t)(PBYTE);
|
||||
typedef LPDIRECT3DTEXTURE9 (*camera_hook_b_t)(void*, int);
|
||||
static camera_hook_a_t camera_hook_a_orig = nullptr;
|
||||
static camera_hook_b_t camera_hook_b_orig = nullptr;
|
||||
auto static hook_a_init = std::once_flag {};
|
||||
|
||||
static LPDIRECT3DDEVICE9EX device;
|
||||
static LPDIRECT3DTEXTURE9 *texture_a = nullptr;
|
||||
static LPDIRECT3DTEXTURE9 *texture_b = nullptr;
|
||||
static LPDIRECT3DTEXTURE9 *camera_texture_a = nullptr;
|
||||
static LPDIRECT3DTEXTURE9 *camera_texture_b = nullptr;
|
||||
static LPDIRECT3DTEXTURE9 *preview_texture_a = nullptr;
|
||||
static LPDIRECT3DTEXTURE9 *preview_texture_b = nullptr;
|
||||
|
||||
struct PredefinedHook {
|
||||
std::string pe_identifier;
|
||||
uintptr_t hook_a;
|
||||
uintptr_t hook_b;
|
||||
uintptr_t hook_textures;
|
||||
uintptr_t hook_camera_manager;
|
||||
uintptr_t hook_device_offset;
|
||||
uintptr_t hook_afp_texture_offset;
|
||||
};
|
||||
|
||||
PredefinedHook g_predefinedHooks[] =
|
||||
{
|
||||
// 27 003
|
||||
{ "5f713b52_6d4090", 0x005971b0, 0x005fb2c0, 0x04e49898, 0x000000d0 },
|
||||
// 27 010
|
||||
{ "5f713946_7f52b0", 0x006b89e0, 0x0071c950, 0x04fd08b8, 0x000000d0 },
|
||||
};
|
||||
PredefinedHook g_predefinedHooks[] = {};
|
||||
|
||||
const DWORD g_predefinedHooksLength = ARRAYSIZE(g_predefinedHooks);
|
||||
|
||||
@@ -75,8 +71,8 @@ namespace games::iidx {
|
||||
|
||||
if (sscanf(
|
||||
s.c_str(),
|
||||
"%i,%i,%i,%i",
|
||||
(int*)&addr_hook_a, (int*)&addr_hook_b, (int*)&addr_textures, (int*)&addr_device_offset) == 4) {
|
||||
"%i,%i,%i,%i,%i",
|
||||
(int*)&addr_hook_a, (int*)&addr_textures, (int*)&addr_camera_manager, (int*)&addr_device_offset, (int*)&addr_afp_texture_offset) == 5) {
|
||||
|
||||
return true;
|
||||
|
||||
@@ -101,8 +97,8 @@ namespace games::iidx {
|
||||
|
||||
// there are three different ways we try to hook the camera entry points
|
||||
// 1) user-provided override via cmd line
|
||||
// 2) predefined offsets using PE header matching (needed for iidx27 and few others)
|
||||
// 3) signature match (should work for most iidx28-31)
|
||||
// 2) predefined offsets using PE header matching
|
||||
// 3) signature match (should work for most iidx27-33)
|
||||
|
||||
// method 1: user provided
|
||||
if (TDJ_CAMERA_OVERRIDE.has_value() && parse_cmd_params()) {
|
||||
@@ -117,10 +113,11 @@ namespace games::iidx {
|
||||
for (DWORD i = 0; i < g_predefinedHooksLength; i++) {
|
||||
if (pe.compare(g_predefinedHooks[i].pe_identifier) == 0) {
|
||||
log_misc("iidx:camhook", "Found predefined addresses");
|
||||
addr_hook_a = g_predefinedHooks[i].hook_a;
|
||||
addr_hook_b = g_predefinedHooks[i].hook_b;
|
||||
addr_textures = g_predefinedHooks[i].hook_textures;
|
||||
addr_device_offset = g_predefinedHooks[i].hook_device_offset;
|
||||
addr_hook_a = g_predefinedHooks[i].hook_a;
|
||||
addr_textures = g_predefinedHooks[i].hook_textures;
|
||||
addr_camera_manager = g_predefinedHooks[i].hook_camera_manager;
|
||||
addr_device_offset = g_predefinedHooks[i].hook_device_offset;
|
||||
addr_afp_texture_offset = g_predefinedHooks[i].hook_afp_texture_offset;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -131,8 +128,8 @@ namespace games::iidx {
|
||||
// --- addr_hook_a ---
|
||||
uint8_t *addr_hook_a_ptr = reinterpret_cast<uint8_t *>(find_pattern(
|
||||
iidx_module,
|
||||
"488BC4565741564883EC5048C740D8FEFFFFFF",
|
||||
"XXXXXXXXXXXXXXXXXXX",
|
||||
"E800000000488B8F0000000048894D",
|
||||
"X????XXX????XXX",
|
||||
0, 0));
|
||||
|
||||
if (addr_hook_a_ptr == nullptr) {
|
||||
@@ -141,24 +138,10 @@ namespace games::iidx {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
addr_hook_a = (uint64_t) (addr_hook_a_ptr - (uint8_t*) iidx_module);
|
||||
|
||||
// addr_hook_b
|
||||
uint8_t* addr_hook_b_ptr = reinterpret_cast<uint8_t *>(find_pattern(
|
||||
iidx_module,
|
||||
"E8000000004885C07439E8",
|
||||
"X????XXXXXX",
|
||||
0, 0));
|
||||
|
||||
if (addr_hook_b_ptr == nullptr) {
|
||||
log_warning("iidx:camhook", "failed to find hook: addr_hook_b");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// displace with the content of wildcard bytes
|
||||
int32_t disp_b = *((int32_t *) (addr_hook_b_ptr + 1));
|
||||
int32_t disp_a = *((int32_t *) (addr_hook_a_ptr + 1));
|
||||
|
||||
addr_hook_b = (addr_hook_b_ptr - (uint8_t*) iidx_module) + disp_b + 5;
|
||||
addr_hook_a = (addr_hook_a_ptr - (uint8_t*) iidx_module) + disp_a + 5;
|
||||
|
||||
// --- addr_textures ---
|
||||
uint8_t* addr_textures_ptr = reinterpret_cast<uint8_t *>(find_pattern(
|
||||
@@ -194,6 +177,28 @@ namespace games::iidx {
|
||||
|
||||
addr_textures = (addr_textures_ptr - (uint8_t*) iidx_module) + disp_textures + 7;
|
||||
|
||||
// --- addr_camera_manager ---
|
||||
uint8_t *addr_camera_manager_ptr = reinterpret_cast<uint8_t *>(find_pattern(
|
||||
iidx_module,
|
||||
"E80000000033FF488B58",
|
||||
"X????XXXXX",
|
||||
0, 0));
|
||||
|
||||
if (addr_camera_manager_ptr == nullptr) {
|
||||
log_warning("iidx:camhook", "failed to find hook: addr_get_camera_manager");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// displace with the content of wildcard bytes
|
||||
int32_t disp_camera_manager = *((int32_t *) (addr_camera_manager_ptr + 1));
|
||||
|
||||
addr_camera_manager_ptr = addr_camera_manager_ptr + disp_camera_manager + 5;
|
||||
|
||||
// once more to get the final address
|
||||
disp_camera_manager = *((int32_t *) (addr_camera_manager_ptr + 3));
|
||||
|
||||
addr_camera_manager = (addr_camera_manager_ptr - (uint8_t*) iidx_module) + disp_camera_manager + 7;
|
||||
|
||||
// addr_device_offset
|
||||
search_from = (addr_hook_a_ptr - (uint8_t*) iidx_module);
|
||||
uint8_t *addr_device_ptr = reinterpret_cast<uint8_t *>(find_pattern_from(
|
||||
@@ -201,39 +206,47 @@ namespace games::iidx {
|
||||
"488B89",
|
||||
"XXX",
|
||||
3, 0, search_from));
|
||||
addr_device_offset = *addr_device_ptr;
|
||||
|
||||
if (addr_textures_ptr == nullptr) {
|
||||
log_warning("iidx:camhook", "failed to find hook: addr_textures (part 3)");
|
||||
if (addr_device_ptr == nullptr) {
|
||||
log_warning("iidx:camhook", "failed to find hook: addr_device_ptr");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
addr_device_offset = *addr_device_ptr;
|
||||
|
||||
// --- addr_afp_texture_offset ---
|
||||
uint8_t *addr_afp_texture_ptr = reinterpret_cast<uint8_t *>(find_pattern(
|
||||
iidx_module,
|
||||
"488B41004885C07400488D5424",
|
||||
"XXX?XXXX?XXXX",
|
||||
0, 0));
|
||||
|
||||
if (addr_afp_texture_ptr == nullptr) {
|
||||
log_warning("iidx:camhook", "failed to find hook: addr_afp_texture_offset");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
addr_afp_texture_offset = *(addr_afp_texture_ptr + 3);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void **__fastcall camera_hook_a(PBYTE a1) {
|
||||
std::call_once(hook_a_init, [&]{
|
||||
device = *reinterpret_cast<LPDIRECT3DDEVICE9EX*>(a1 + addr_device_offset);
|
||||
auto const textures = *reinterpret_cast<LPDIRECT3DTEXTURE9**>((uint8_t*)iidx_module + addr_textures);
|
||||
auto const preview = *reinterpret_cast<LPDIRECT3DTEXTURE9**>((uint8_t*)iidx_module + addr_textures);
|
||||
auto const manager = reinterpret_cast<Camera::CCameraManager2*>((uint8_t*)iidx_module + addr_camera_manager);
|
||||
|
||||
texture_a = textures;
|
||||
texture_b = textures + 2;
|
||||
camera_texture_a = manager->cameras->a->d3d9_texture(addr_afp_texture_offset);
|
||||
camera_texture_b = manager->cameras->b->d3d9_texture(addr_afp_texture_offset);
|
||||
preview_texture_a = preview;
|
||||
preview_texture_b = preview + 2;
|
||||
|
||||
init_local_camera();
|
||||
});
|
||||
return camera_hook_a_orig(a1);
|
||||
}
|
||||
|
||||
static LPDIRECT3DTEXTURE9 camera_hook_b(void* a1, int idx) {
|
||||
if (idx == 0 && top_camera) {
|
||||
return top_camera->GetTexture();
|
||||
}
|
||||
if (idx == 1 && front_camera) {
|
||||
return front_camera->GetTexture();
|
||||
}
|
||||
return camera_hook_b_orig(a1, idx);
|
||||
}
|
||||
|
||||
bool create_hooks() {
|
||||
auto *hook_a_ptr = reinterpret_cast<uint16_t *>(
|
||||
reinterpret_cast<intptr_t>(iidx_module) + addr_hook_a);
|
||||
@@ -246,17 +259,6 @@ namespace games::iidx {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
auto *hook_b_ptr = reinterpret_cast<uint16_t *>(
|
||||
reinterpret_cast<intptr_t>(iidx_module) + addr_hook_b);
|
||||
|
||||
if (!detour::trampoline(
|
||||
reinterpret_cast<camera_hook_b_t>(hook_b_ptr),
|
||||
camera_hook_b,
|
||||
&camera_hook_b_orig)) {
|
||||
log_warning("iidx:camhook", "failed to trampoline hook_b");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -443,7 +445,7 @@ namespace games::iidx {
|
||||
}
|
||||
|
||||
IIDXLocalCamera* add_top_camera(IMFActivate* pActivate) {
|
||||
auto top_camera = new IIDXLocalCamera("top", TDJ_CAMERA_PREFER_16_9, pActivate, s_pD3DManager, device, texture_a);
|
||||
auto top_camera = new IIDXLocalCamera("top", TDJ_CAMERA_PREFER_16_9, pActivate, s_pD3DManager, device, camera_texture_a, preview_texture_a);
|
||||
if (top_camera->m_initialized) {
|
||||
LOCAL_CAMERA_LIST.push_back(top_camera);
|
||||
} else {
|
||||
@@ -454,7 +456,7 @@ namespace games::iidx {
|
||||
}
|
||||
|
||||
IIDXLocalCamera* add_front_camera(IMFActivate* pActivate) {
|
||||
auto front_camera = new IIDXLocalCamera("front", TDJ_CAMERA_PREFER_16_9, pActivate, s_pD3DManager, device, texture_b);
|
||||
auto front_camera = new IIDXLocalCamera("front", TDJ_CAMERA_PREFER_16_9, pActivate, s_pD3DManager, device, camera_texture_b, preview_texture_b);
|
||||
if (front_camera->m_initialized) {
|
||||
LOCAL_CAMERA_LIST.push_back(front_camera);
|
||||
} else {
|
||||
@@ -469,8 +471,8 @@ namespace games::iidx {
|
||||
if (result) {
|
||||
log_misc(
|
||||
"iidx:camhook",
|
||||
"found hooks:\n hook_a 0x{:x}\n hook_b 0x{:x}\n textures 0x{:x}\n device_offset 0x{:x}",
|
||||
addr_hook_a, addr_hook_b, addr_textures, addr_device_offset);
|
||||
"found hooks:\n hook_a 0x{:x}\n textures 0x{:x}\n camera_manager 0x{:x}\n device_offset 0x{:x}\n afp_texture_offset 0x{:x}",
|
||||
addr_hook_a, addr_textures, addr_camera_manager, addr_device_offset, addr_afp_texture_offset);
|
||||
result = create_hooks();
|
||||
if (result) {
|
||||
init_mf_library();
|
||||
|
||||
@@ -428,7 +428,7 @@ namespace games::iidx {
|
||||
|
||||
// check bad model name
|
||||
if (!cfg::CONFIGURATOR_STANDALONE && avs::game::is_model("TDJ")) {
|
||||
log_fatal(
|
||||
log_warning(
|
||||
"iidx",
|
||||
"BAD MODEL NAME ERROR\n\n\n"
|
||||
"!!! model name set to TDJ, this is WRONG and will break your game !!!\n"
|
||||
@@ -446,6 +446,8 @@ namespace games::iidx {
|
||||
"!!! !!!\n"
|
||||
"!!! model name set to TDJ, this is WRONG and will break your game !!!\n\n\n"
|
||||
);
|
||||
|
||||
log_fatal("iidx", "BAD MODEL NAME ERROR - TDJ specified, must be LDJ instead");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,14 +46,17 @@ namespace games::iidx {
|
||||
IMFActivate *pActivate,
|
||||
IDirect3DDeviceManager9 *pD3DManager,
|
||||
LPDIRECT3DDEVICE9EX device,
|
||||
LPDIRECT3DTEXTURE9 *texture_target
|
||||
LPDIRECT3DTEXTURE9 *camera_texture_target,
|
||||
LPDIRECT3DTEXTURE9 *preview_texture_target
|
||||
):
|
||||
m_nRefCount(1),
|
||||
m_name(name),
|
||||
m_prefer_16_by_9(prefer_16_by_9),
|
||||
m_device(device),
|
||||
m_texture_target(texture_target),
|
||||
m_texture_original(*texture_target)
|
||||
m_camera_texture_target(camera_texture_target),
|
||||
m_preview_texture_target(preview_texture_target),
|
||||
m_camera_texture_original(*camera_texture_target),
|
||||
m_preview_texture_original(*preview_texture_target)
|
||||
{
|
||||
InitializeCriticalSection(&m_critsec);
|
||||
|
||||
@@ -691,7 +694,8 @@ namespace games::iidx {
|
||||
if (FAILED(hr)) { goto done; }
|
||||
|
||||
// Make the game use this new texture as camera stream source
|
||||
*m_texture_target = m_texture;
|
||||
*m_camera_texture_target = m_texture;
|
||||
*m_preview_texture_target = m_texture;
|
||||
m_active = TRUE;
|
||||
|
||||
// Create texture for colour conversion
|
||||
@@ -860,7 +864,8 @@ namespace games::iidx {
|
||||
|
||||
ULONG uCount = InterlockedDecrement(&m_nRefCount);
|
||||
|
||||
*m_texture_target = m_texture_original;
|
||||
*m_camera_texture_target = m_camera_texture_original;
|
||||
*m_preview_texture_target = m_preview_texture_original;
|
||||
|
||||
for (size_t i = 0; i < m_mediaTypeInfos.size(); i++) {
|
||||
SafeRelease(&(m_mediaTypeInfos.at(i).p_mediaType));
|
||||
|
||||
@@ -66,6 +66,25 @@ extern std::string CAMERA_CONTROL_LABELS[];
|
||||
extern std::string DRAW_MODE_LABELS[];
|
||||
|
||||
namespace games::iidx {
|
||||
namespace Camera {
|
||||
struct PlayVideoCamera {
|
||||
IDirect3DTexture9** d3d9_texture(const uintptr_t offset) {
|
||||
auto const afp_texture = *reinterpret_cast<uint8_t**>
|
||||
(reinterpret_cast<uint8_t*>(this) + offset);
|
||||
return reinterpret_cast<IDirect3DTexture9**>(afp_texture + 0x8);
|
||||
}
|
||||
};
|
||||
|
||||
struct CCameraManager2 {
|
||||
using camera_pointers = struct {
|
||||
PlayVideoCamera* a;
|
||||
PlayVideoCamera* b;
|
||||
};
|
||||
void* vftbl;
|
||||
camera_pointers* cameras;
|
||||
};
|
||||
}
|
||||
|
||||
class IIDXLocalCamera {
|
||||
protected:
|
||||
virtual ~IIDXLocalCamera() {};
|
||||
@@ -98,8 +117,9 @@ namespace games::iidx {
|
||||
// DirectX9 DeviceEx
|
||||
LPDIRECT3DDEVICE9EX m_device;
|
||||
|
||||
// Address to hook camera texture onto the game
|
||||
LPDIRECT3DTEXTURE9 *m_texture_target = nullptr;
|
||||
// Address to hook camera textures onto the game
|
||||
LPDIRECT3DTEXTURE9 *m_camera_texture_target = nullptr;
|
||||
LPDIRECT3DTEXTURE9 *m_preview_texture_target = nullptr;
|
||||
|
||||
// Target texture (to be shown in the game)
|
||||
LPDIRECT3DTEXTURE9 m_texture = nullptr;
|
||||
@@ -117,8 +137,9 @@ namespace games::iidx {
|
||||
LPDIRECT3DTEXTURE9 m_transformResultTexture = nullptr;
|
||||
IDirect3DSurface9 *m_pTransformResultSurf = nullptr;
|
||||
|
||||
// Storing original texture for clean up
|
||||
LPDIRECT3DTEXTURE9 m_texture_original = nullptr;
|
||||
// Storing original textures for clean up
|
||||
LPDIRECT3DTEXTURE9 m_camera_texture_original = nullptr;
|
||||
LPDIRECT3DTEXTURE9 m_preview_texture_original = nullptr;
|
||||
|
||||
IAMCameraControl *m_pCameraControl = nullptr;
|
||||
|
||||
@@ -154,7 +175,8 @@ namespace games::iidx {
|
||||
IMFActivate *pActivate,
|
||||
IDirect3DDeviceManager9 *pD3DManager,
|
||||
LPDIRECT3DDEVICE9EX device,
|
||||
LPDIRECT3DTEXTURE9 *texture_target
|
||||
LPDIRECT3DTEXTURE9 *camera_texture_target,
|
||||
LPDIRECT3DTEXTURE9 *preview_texture_target
|
||||
);
|
||||
LPDIRECT3DTEXTURE9 GetTexture();
|
||||
ULONG Release();
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace games::jb {
|
||||
const auto current_path = std::filesystem::current_path();
|
||||
log_misc("jubeat", "current working directory: {}", current_path.string());
|
||||
if (current_path.parent_path() == current_path.root_path()) {
|
||||
log_fatal(
|
||||
log_warning(
|
||||
"jubeat",
|
||||
"\n\nInvalid path error; jubeat cannot run from a directory in the drive root\n"
|
||||
"The game will overflow the stack and silently fail to boot\n\n"
|
||||
@@ -179,6 +179,10 @@ namespace games::jb {
|
||||
"To fix this, create a new directory and move ALL game files there.\n\n"
|
||||
"Your current working directory: {}\n",
|
||||
current_path.string());
|
||||
|
||||
log_fatal(
|
||||
"jubeat",
|
||||
"Invalid path error; jubeat cannot run from a directory in the drive root");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,6 +288,21 @@ namespace games::mfc {
|
||||
MFCGame::MFCGame() : Game("Mahjong Fight Club") {
|
||||
}
|
||||
|
||||
static bool spam_remover(void *user, const std::string &data, logger::Style style, std::string &out) {
|
||||
if (data.empty() || data[0] != '[') {
|
||||
return false;
|
||||
}
|
||||
if (data.find("W:mutex: lock: mid 00000000 != AVS_DTYPE_MUTEX") != std::string::npos) {
|
||||
out = "";
|
||||
return true;
|
||||
}
|
||||
if (data.find("W:mutex: unlock: mid 00000000 != AVS_DTYPE_MUTEX") != std::string::npos) {
|
||||
out = "";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MFCGame::attach() {
|
||||
Game::attach();
|
||||
|
||||
@@ -308,6 +323,13 @@ namespace games::mfc {
|
||||
auto allinone_module = libutils::try_module("allinone.dll");
|
||||
auto system_module = libutils::try_module("system.dll");
|
||||
|
||||
// Mahjong Fight Club - 2025?
|
||||
// they removed allinone.dll and moved i/o into system.dll
|
||||
if (allinone_module == nullptr) {
|
||||
log_misc("mfc", "using system.dll instead of allinone.dll for i/o hooks");
|
||||
allinone_module = system_module;
|
||||
}
|
||||
|
||||
// network fix
|
||||
detour::iat_try("?nic_dhcp_maybe_exist@@YAEXZ", nic_dhcp_maybe_exist, system_module);
|
||||
|
||||
@@ -378,5 +400,7 @@ namespace games::mfc {
|
||||
detour::inline_hook((void *) mouse_utl_step, libutils::try_proc(
|
||||
allinone_module, "?mouse_utl_step@@YAXXZ"));
|
||||
}
|
||||
|
||||
logger::hook_add(spam_remover, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +215,15 @@ namespace games::sdvx {
|
||||
deferredlogs::defer_error_messages(deferredlogs::SUPERSTEP_SOUND_ERROR_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
if (data.find("W:ea3-pos: ea3_report_posev: no such node:") != std::string::npos) {
|
||||
deferredlogs::defer_error_messages({
|
||||
"bad prop\\ea3-config.xml detected by game",
|
||||
std::string(" ") + data,
|
||||
" this will most likely cause Server Busy errors in certain conditions",
|
||||
" follow the FAQ to fix your ea3-config.xml and try again"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -268,7 +277,7 @@ namespace games::sdvx {
|
||||
AUTO_INSERT_CARD_COOLDOWN = 15.f;
|
||||
// check bad model name
|
||||
if (!cfg::CONFIGURATOR_STANDALONE && avs::game::is_model("UFC")) {
|
||||
log_fatal(
|
||||
log_warning(
|
||||
"sdvx",
|
||||
"BAD MODEL NAME ERROR\n\n\n"
|
||||
"!!! model name set to UFC, this is WRONG and will break your game !!!\n"
|
||||
@@ -278,6 +287,9 @@ namespace games::sdvx {
|
||||
"!!! !!!\n"
|
||||
"!!! model name set to UFC, this is WRONG and will break your game !!!\n\n\n"
|
||||
);
|
||||
log_fatal(
|
||||
"sdvx",
|
||||
"BAD MODEL NAME ERROR - model name set to UFC, must be KFC instead");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <ntstatus.h>
|
||||
|
||||
#include "avs/game.h"
|
||||
#include "games/iidx/iidx.h"
|
||||
#include "util/detour.h"
|
||||
#include "util/logging.h"
|
||||
#include "util/utils.h"
|
||||
@@ -22,6 +23,7 @@ static decltype(GetLocaleInfoEx) *GetLocaleInfoEx_orig = nullptr;
|
||||
|
||||
#ifdef SPICE64
|
||||
static decltype(GetSystemDefaultLCID) *GetSystemDefaultLCID_orig = nullptr;
|
||||
static decltype(IsDBCSLeadByte) *IsDBCSLeadByte_orig = nullptr;
|
||||
#endif
|
||||
|
||||
static NTSTATUS NTAPI RtlMultiByteToUnicodeN_hook(
|
||||
@@ -162,6 +164,17 @@ static int WINAPI GetLocaleInfoEx_hook (
|
||||
return GetLocaleInfoEx_orig(lpLocaleName, LCType, lpLCData, cchData);
|
||||
}
|
||||
|
||||
#ifdef SPICE64
|
||||
|
||||
static BOOL WINAPI IsDBCSLeadByte_hook (
|
||||
BYTE TestChar
|
||||
)
|
||||
{
|
||||
return IsDBCSLeadByteEx(CODEPAGE_SHIFT_JIS, TestChar);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void hooks::lang::early_init() {
|
||||
log_info("hooks::lang", "early initialization");
|
||||
|
||||
@@ -189,6 +202,19 @@ void hooks::lang::early_init() {
|
||||
GetLocaleInfoEx_hook,
|
||||
&GetLocaleInfoEx_orig);
|
||||
}
|
||||
|
||||
#ifdef SPICE64
|
||||
// for TDJ subscreen search keyboard
|
||||
if (avs::game::is_model("LDJ") && games::iidx::TDJ_MODE) {
|
||||
log_info("hooks::lang", "hooking IsDBCSLeadByte");
|
||||
detour::trampoline_try(
|
||||
"kernel32.dll",
|
||||
"IsDBCSLeadByte",
|
||||
IsDBCSLeadByte_hook,
|
||||
&IsDBCSLeadByte_orig);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void hooks::lang::init() {
|
||||
|
||||
@@ -299,22 +299,6 @@ int main_implementation(int argc, char *argv[]) {
|
||||
cfg::CONFIGURATOR_TYPE = cfg::ConfigType::Config;
|
||||
cfg_run = true;
|
||||
}
|
||||
|
||||
if (options[launcher::Options::EAmusementEmulation].value_bool() &&
|
||||
options[launcher::Options::ServiceURL].is_active() &&
|
||||
!cfg::CONFIGURATOR_STANDALONE) {
|
||||
log_fatal(
|
||||
"launcher",
|
||||
"BAD EAMUSE SETTINGS ERROR\n\n\n"
|
||||
"-------------------------------------------------------------------\n"
|
||||
"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING\n"
|
||||
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
||||
"A service URL is set **AND** E-Amusement emulation is enabled.\n"
|
||||
"Either remove the service URL, or disable E-Amusement emulation.\n"
|
||||
"Otherwise you may experience problems logging in.\n"
|
||||
"-------------------------------------------------------------------\n\n\n"
|
||||
);
|
||||
}
|
||||
if (options[launcher::Options::EAmusementEmulation].value_bool()) {
|
||||
avs::ea3::URL_SLASH = 1;
|
||||
easrv_port = 8080;
|
||||
@@ -1278,18 +1262,19 @@ int main_implementation(int argc, char *argv[]) {
|
||||
for (const auto &option : options) {
|
||||
if (option.conflicting && option.get_definition().type != OptionType::Bool) {
|
||||
conflicts += 1;
|
||||
const auto& value = option.get_definition().sensitive ? "*****" : option.value;
|
||||
if (launcher::USE_CMD_OVERRIDE) {
|
||||
log_warning(
|
||||
"launcher",
|
||||
"multiple values for -{}, command line args take precedence: {}",
|
||||
option.get_definition().name,
|
||||
option.value);
|
||||
value);
|
||||
} else {
|
||||
log_warning(
|
||||
"launcher",
|
||||
"multiple values for -{}, spicecfg values take precedence: {}",
|
||||
option.get_definition().name,
|
||||
option.value);
|
||||
value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1318,6 +1303,25 @@ int main_implementation(int argc, char *argv[]) {
|
||||
);
|
||||
}
|
||||
|
||||
if (options[launcher::Options::EAmusementEmulation].value_bool() &&
|
||||
options[launcher::Options::ServiceURL].is_active() &&
|
||||
!cfg::CONFIGURATOR_STANDALONE) {
|
||||
log_warning(
|
||||
"launcher",
|
||||
"BAD EAMUSE SETTINGS ERROR\n\n\n"
|
||||
"-------------------------------------------------------------------\n"
|
||||
"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING\n"
|
||||
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
||||
"A service URL is set **AND** E-Amusement emulation is enabled.\n"
|
||||
"Either remove the service URL, or disable E-Amusement emulation.\n"
|
||||
"Otherwise you may experience problems logging in.\n"
|
||||
"-------------------------------------------------------------------\n\n\n"
|
||||
);
|
||||
log_fatal(
|
||||
"launcher",
|
||||
"BAD EAMUSE SETTINGS ERROR: both -ea and -url are set");
|
||||
}
|
||||
|
||||
if (options[launcher::Options::FullscreenResolution].is_active()) {
|
||||
std::pair<uint32_t, uint32_t> result;
|
||||
if (parse_width_height(options[launcher::Options::FullscreenResolution].value_text(), result)) {
|
||||
@@ -1673,6 +1677,14 @@ int main_implementation(int argc, char *argv[]) {
|
||||
attach_io = true;
|
||||
attach_mfc = true;
|
||||
break;
|
||||
|
||||
// Mahjong Fight Club - 2025?
|
||||
// they removed allinone.dll and moved i/o into system.dll
|
||||
} else if (check_dll("system.dll") && fileutils::file_exists("data/mfc.ini")) {
|
||||
avs::game::DLL_NAME = "system.dll";
|
||||
attach_io = true;
|
||||
attach_mfc = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// FutureTomTom
|
||||
@@ -1817,7 +1829,7 @@ int main_implementation(int argc, char *argv[]) {
|
||||
// usage error
|
||||
if (!cfg::CONFIGURATOR_STANDALONE
|
||||
&& (!CHECK_DLL_IGNORE_ARCH)) {
|
||||
log_fatal(
|
||||
log_warning(
|
||||
"launcher",
|
||||
"module auto detection failed!\n\n"
|
||||
"This usually means one of the following:\n\n"
|
||||
@@ -1825,6 +1837,8 @@ int main_implementation(int argc, char *argv[]) {
|
||||
" 2. XML files in prop directory are malformed or missing, or\n"
|
||||
" 3. You passed in invalid options (usually, path overrides like -exec)\n\n"
|
||||
);
|
||||
|
||||
log_fatal("launcher", "module auto detection failed, see log.txt for troubleshooting");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -497,10 +497,10 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = {
|
||||
.display_name = "iidxcamhookoffset",
|
||||
.aliases = "iidxcamhookoffset",
|
||||
.desc = "Override DLL offsets for camera hook; "
|
||||
"format: 4 hex values separated by commas "
|
||||
"(offset_hook_a, offset_hook_b, offset_textures, offset_d3d_device)",
|
||||
"format: 5 hex values separated by commas "
|
||||
"(offset_hook_a, offset_textures, offset_camera_manager, offset_d3d_device, offset_afp_texture)",
|
||||
.type = OptionType::Text,
|
||||
.setting_name = "0x5817a0,0x5ea3b0,0x6fffbd8,0xe0",
|
||||
.setting_name = "0x5817a0,0x6fffbd8,0xbbae40,0xe0,0x30",
|
||||
.game_name = "Beatmania IIDX",
|
||||
.category = "Game Options (Advanced)",
|
||||
},
|
||||
|
||||
@@ -175,17 +175,8 @@ static LONG WINAPI TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *Exception
|
||||
log_warning("signal", "minidump creation function not available, skipping");
|
||||
}
|
||||
|
||||
// reduce sleep time since we will wait for the user to acknowledge the popup
|
||||
LOG_FATAL_SLEEP = 1;
|
||||
|
||||
// in 30 seconds, shut down (in case user can't dismiss popup)
|
||||
const auto f = std::async(std::launch::async, [] {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(30));
|
||||
log_fatal("signal", "end");
|
||||
});
|
||||
|
||||
// this will stall all UI threads for this process
|
||||
deferredlogs::show_popup_for_crash();
|
||||
show_popup_for_crash();
|
||||
|
||||
log_fatal("signal", "end");
|
||||
}
|
||||
|
||||
@@ -288,6 +288,12 @@ namespace overlay::windows {
|
||||
this->reload_local_patches();
|
||||
}
|
||||
|
||||
if (avs::game::DLL_NAME == "kamunity.dll") {
|
||||
ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "Patches are not supported for Unity-based games.");
|
||||
ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "Instead, look for downloads of pre-patched DLLs.");
|
||||
return;
|
||||
}
|
||||
|
||||
// game code info
|
||||
std::string identifiers;
|
||||
identifiers += avs::game::get_identifier() + "\n\n";
|
||||
|
||||
@@ -347,40 +347,38 @@ void rawinput::RawInputManager::devices_scan_rawinput(RAWINPUTDEVICELIST *device
|
||||
if (hid_handle != INVALID_HANDLE_VALUE) {
|
||||
|
||||
// check manufacturer string
|
||||
std::wstring man_ws;
|
||||
std::string man_ws;
|
||||
wchar_t man_str_buffer[256] {};
|
||||
if (HidD_GetManufacturerString(hid_handle, man_str_buffer, sizeof(man_str_buffer))) {
|
||||
man_ws = std::wstring(man_str_buffer);
|
||||
man_ws = wchar_to_u8(man_str_buffer);
|
||||
}
|
||||
|
||||
// get product string
|
||||
std::wstring prod_ws;
|
||||
std::string prod_ws;
|
||||
wchar_t prod_str_buffer[256] {};
|
||||
if (HidD_GetProductString(hid_handle, prod_str_buffer, sizeof(prod_str_buffer))) {
|
||||
prod_ws = std::wstring(prod_str_buffer);
|
||||
prod_ws = wchar_to_u8(prod_str_buffer);
|
||||
}
|
||||
|
||||
// For Bluetooth LE HID devices (e.g., newer Xbox controllers) HidD_GetProductString
|
||||
// and HidD_GetManufacturerString will return blank strings.
|
||||
// https://docs.microsoft.com/en-us/answers/questions/401236/hidd-getproductstring-with-ble-hid-device.html
|
||||
if (man_ws.empty() && prod_ws.empty()) {
|
||||
prod_ws = s2ws(device_description);
|
||||
prod_ws = device_description;
|
||||
}
|
||||
|
||||
// build desc string
|
||||
std::wstring desc_ws;
|
||||
std::string desc_ws;
|
||||
if (string_begins_with(prod_ws, man_ws)) {
|
||||
desc_ws = prod_ws;
|
||||
} else {
|
||||
desc_ws = man_ws;
|
||||
if (!man_ws.empty() && !prod_ws.empty()) {
|
||||
desc_ws += L" ";
|
||||
desc_ws += " ";
|
||||
}
|
||||
desc_ws += prod_ws;
|
||||
}
|
||||
|
||||
// convert to normal string
|
||||
new_device.desc = ws2s(desc_ws);
|
||||
new_device.desc = desc_ws;
|
||||
|
||||
// get attributes
|
||||
if (!HidD_GetAttributes(hid_handle, &hid_attributes)) {
|
||||
@@ -1148,7 +1146,7 @@ std::string rawinput::RawInputManager::rawinput_get_device_description(const raw
|
||||
|
||||
// get property
|
||||
DWORD desc_size = 0;
|
||||
if (SetupDiGetDeviceRegistryProperty(
|
||||
if (SetupDiGetDeviceRegistryPropertyW(
|
||||
devinfo, &devinfo_data, SPDRP_DEVICEDESC, nullptr, nullptr, 0, &desc_size))
|
||||
{
|
||||
continue;
|
||||
@@ -1160,14 +1158,14 @@ std::string rawinput::RawInputManager::rawinput_get_device_description(const raw
|
||||
// allocate buffer
|
||||
auto desc_data = std::make_unique<BYTE[]>(desc_size);
|
||||
|
||||
if (!SetupDiGetDeviceRegistryProperty(
|
||||
if (!SetupDiGetDeviceRegistryPropertyW(
|
||||
devinfo, &devinfo_data, SPDRP_DEVICEDESC, nullptr, desc_data.get(), desc_size, nullptr))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// kthxbye
|
||||
device_description = std::string(reinterpret_cast<char *>(desc_data.get()));
|
||||
device_description = wchar_to_u8(reinterpret_cast<PWCHAR>(desc_data.get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ developers when you can. Sources should be included, have fun!
|
||||
|
||||
spice2x fork maintainers:
|
||||
* sp2xdev team
|
||||
* the lab
|
||||
|
||||
SpiceTools original contributors:
|
||||
* cube, felix, dinsfire, nolm, s2, crazyredmachine (jotaro44), mon, nibs
|
||||
|
||||
@@ -49,8 +49,10 @@ namespace deferredlogs {
|
||||
|
||||
if (is_crash) {
|
||||
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 += " * 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 += " minidump should only be shared with people you trust as it may contain\n";
|
||||
msg += " sensitive data (PCBID, card ID, etc)\n";
|
||||
msg += "\n";
|
||||
}
|
||||
|
||||
@@ -72,25 +74,4 @@ namespace deferredlogs {
|
||||
log_warning("troubleshooter", "{}", msg);
|
||||
});
|
||||
}
|
||||
|
||||
void show_popup_for_crash() {
|
||||
static std::once_flag shown;
|
||||
std::call_once(shown, []() {
|
||||
const std::string title = "spice2x (" + to_string(VERSION_STRING_CFG) + ") - crash handler";
|
||||
std::string text;
|
||||
text += "Game has crashed.\n\n";
|
||||
text += "Check log.txt and look for error messages near the end of file.\n\n";
|
||||
text += "Unsure what to do next?\n";
|
||||
text += " * update spice2x to the latest version\n";
|
||||
text += " * check the FAQ on spice2x wiki on github\n";
|
||||
text += " * do NOT screenshot this, instead, share log.txt with someone and ask for help\n\n";
|
||||
text += "Press Enter, Esc, Alt+F4, or click OK to exit. Otherwise, game will close in 30 seconds.";
|
||||
|
||||
MessageBox(
|
||||
nullptr,
|
||||
text.c_str(),
|
||||
title.c_str(),
|
||||
MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,4 @@ namespace deferredlogs {
|
||||
|
||||
void defer_error_messages(std::initializer_list<std::string> messages);
|
||||
void dump_to_logger(bool is_crash=false);
|
||||
void show_popup_for_crash();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace {
|
||||
{
|
||||
"msvcr100.dll",
|
||||
"Visual Studio 2010 (VC++ 10.0) SP1 Redistributable",
|
||||
"Download and install VisualCppRedist_AIO_x86_x64.exe from https://github.com/abbodi1406/vcredist/releases/latest",
|
||||
"Download and install from https://github.com/spice2x/spice2x.github.io/wiki/Visual-Cpp-Redistributable-Runtimes",
|
||||
},
|
||||
{
|
||||
"d3dx9_43.dll",
|
||||
|
||||
@@ -43,7 +43,8 @@ static inline void load_library_fail(const std::string &file_name, bool fatal) {
|
||||
" b. http://www.dependencywalker.com/ (for old OS) \n"
|
||||
, file_name) };
|
||||
if (fatal) {
|
||||
log_fatal("libutils", "{}", info_str);
|
||||
log_warning("libutils", "{}", info_str);
|
||||
log_fatal("libutils", "DLL failed to load: {}, see log.txt for troubleshooting", file_name);
|
||||
} else {
|
||||
log_warning("libutils", "{}", info_str);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "logging.h"
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <future>
|
||||
|
||||
DWORD LOG_FATAL_SLEEP = 10000;
|
||||
#include "logging.h"
|
||||
#include "build/defs.h"
|
||||
#include "hooks/graphics/graphics.h"
|
||||
|
||||
std::string_view log_get_datetime() {
|
||||
return log_get_datetime(time(nullptr));
|
||||
@@ -14,3 +18,66 @@ std::string_view log_get_datetime(std::time_t now) {
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void show_popup(const std::string text) {
|
||||
static std::once_flag shown;
|
||||
std::call_once(shown, [text]() {
|
||||
|
||||
// minimize all windows
|
||||
// only needed because in multi-monitor full screen games, MessageBox fails to show above the game
|
||||
for (auto &hwnd : GRAPHICS_WINDOWS) {
|
||||
ShowWindow(hwnd, SW_FORCEMINIMIZE);
|
||||
}
|
||||
|
||||
// schedule a worker to terminate the game in 30 seconds in case user can't dismiss UI
|
||||
std::atomic_bool cancel_popup = false;
|
||||
auto worker = std::async(std::launch::async, [&cancel_popup]{
|
||||
for (int ms = 300; ms > 0; ms--) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
if (cancel_popup) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
launcher::stop_subsystems();
|
||||
launcher::kill();
|
||||
std::terminate();
|
||||
});
|
||||
|
||||
// MessageBox will block until user presses OK
|
||||
const std::string title = "spice2x (" + to_string(VERSION_STRING_CFG) + ")";
|
||||
MessageBox(
|
||||
nullptr,
|
||||
text.c_str(),
|
||||
title.c_str(),
|
||||
MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
|
||||
|
||||
// cancel the worker since the user acknowledged the popup
|
||||
cancel_popup = true;
|
||||
});
|
||||
}
|
||||
|
||||
void show_popup_for_crash() {
|
||||
std::string text;
|
||||
text += "Game has crashed.\n\n";
|
||||
text += "Check log.txt and look for error messages near the end of file.\n\n";
|
||||
text += "Unsure what to do next?\n";
|
||||
text += " * update spice2x to the latest version\n";
|
||||
text += " * check the FAQ on spice2x github wiki\n";
|
||||
text += " * do NOT screenshot this, instead, share log.txt with someone and ask for help\n\n";
|
||||
text += "Press Enter, Esc, Alt+F4, or click OK to exit. Otherwise, game will close in 30 seconds.";
|
||||
show_popup(text);
|
||||
}
|
||||
|
||||
void show_popup_for_fatal_error(std::string message) {
|
||||
std::string text;
|
||||
text += "A fatal error was encountered. For details, check log.txt.\n\n";
|
||||
text += "----------------------------------------------------------\n";
|
||||
text += message;
|
||||
text += "----------------------------------------------------------\n\n";
|
||||
text += "Unsure what to do next?\n";
|
||||
text += " * update spice2x to the latest version\n";
|
||||
text += " * check the FAQ on spice2x github wiki\n";
|
||||
text += " * do NOT screenshot this, instead, share log.txt with someone and ask for help\n\n";
|
||||
text += "Press Enter, Esc, Alt+F4, or click OK to exit. Otherwise, game will close in 30 seconds.";
|
||||
show_popup(text);
|
||||
}
|
||||
@@ -71,22 +71,28 @@ struct fmt::formatter<fmt_hresult> {
|
||||
}
|
||||
};
|
||||
|
||||
extern DWORD LOG_FATAL_SLEEP;
|
||||
void show_popup_for_crash();
|
||||
void show_popup_for_fatal_error(std::string message);
|
||||
|
||||
// misc log
|
||||
#define LOG_FORMAT(level, module, fmt_str, ...) fmt::format(FMT_COMPILE("{}" fmt_str "\n"), \
|
||||
fmt_log { std::time(nullptr), level, module }, ## __VA_ARGS__)
|
||||
|
||||
#define LOG_FORMAT_POPUP(module, fmt_str, ...) fmt::format(FMT_COMPILE("{}: " fmt_str "\n"), module, ## __VA_ARGS__)
|
||||
|
||||
#define log_misc(module, format_str, ...) logger::push( \
|
||||
LOG_FORMAT("M", module, format_str, ## __VA_ARGS__), logger::Style::GREY)
|
||||
|
||||
#define log_info(module, format_str, ...) logger::push( \
|
||||
LOG_FORMAT("I", module, format_str, ## __VA_ARGS__), logger::Style::DEFAULT)
|
||||
|
||||
#define log_warning(module, format_str, ...) logger::push( \
|
||||
LOG_FORMAT("W", module, format_str, ## __VA_ARGS__), logger::Style::YELLOW)
|
||||
|
||||
#define log_fatal(module, format_str, ...) { \
|
||||
logger::push(LOG_FORMAT("F", module, format_str, ## __VA_ARGS__), logger::Style::RED); \
|
||||
logger::push(LOG_FORMAT("F", "spice", "encountered a fatal error, you can close the window or press ctrl + c"), logger::Style::RED); \
|
||||
show_popup_for_fatal_error(LOG_FORMAT_POPUP(module, format_str, ## __VA_ARGS__)); \
|
||||
launcher::stop_subsystems(); \
|
||||
Sleep(LOG_FATAL_SLEEP); \
|
||||
launcher::kill(); \
|
||||
std::terminate(); \
|
||||
} ((void) 0 )
|
||||
|
||||
@@ -339,4 +339,14 @@ static inline bool parse_width_height(const std::string wh, std::pair<uint32_t,
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline std::string wchar_to_u8(const wchar_t* wstr) {
|
||||
int size = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
|
||||
if (size <= 1) {
|
||||
return "";
|
||||
}
|
||||
std::string out(size - 1, 0);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, out.data(), size - 1, nullptr, nullptr);
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user