diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-10-02 20:31:59 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-10-02 20:42:44 +0800 |
commit | 37d44efbfb9d73102b9452a7e3a7aff7c7ab46af (patch) | |
tree | 3dbb1ce24c7393d01e55405febf00a4874cc8477 | |
parent | 646a41e0edd22c254be4939c9fa4e54b29fdb502 (diff) | |
download | rich4-37d44efbfb9d73102b9452a7e3a7aff7c7ab46af.tar.xz |
deinit_game, deinit_font
-rw-r--r-- | csrc/font.c | 9 | ||||
-rw-r--r-- | csrc/main.c | 35 |
2 files changed, 41 insertions, 3 deletions
diff --git a/csrc/font.c b/csrc/font.c index f5f9351..6648669 100644 --- a/csrc/font.c +++ b/csrc/font.c @@ -255,3 +255,12 @@ void draw_some_text(a1, const char *str, int a3, int a4, int a5) fcn.004561be(0x4762e8, fmt_dim1.left, fmt_dim1.top, width, height, 0); IDirectDrawSurface_Unlock(NULL); } + +void deinit_font() +{ + if (gFont != NULL) + DeleteObject(gFont); + + if (pddrawsf3 != NULL) + IDirectDrawSurface_Release(pddrawsf3); +} diff --git a/csrc/main.c b/csrc/main.c index e046484..cd58500 100644 --- a/csrc/main.c +++ b/csrc/main.c @@ -33,7 +33,7 @@ LRESULT CALLBACK windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara { if (message < 0x1c) { if (message == WM_DESTROY) { - sub_UnhookWindowsHookEx_815(); + deinit_game(); PostQuitMessage(0); return 0; } @@ -228,6 +228,35 @@ int fcn_004029fd() return ebx; } +void deinit_game() +{ + if (mid_status[5] == 0) { + sub.WINMM.dll_timeGetTime_3c4(); + free(dw_474938); + sub.WINMM.dll_timeKillEvent_1b2(); + sub.WINMM.dll_mciSendStringA_8ef(); + unload_mkf(mkf_effect); + unload_mkf(mkf_panel); + unload_mkf(mkf_speaking); + unload_mkf(mkf_data); + sub.USER32.dll_KillTimer_228(); + deinit_font(); + UnhookWindowsHookEx(&ghook); + fcn.00454240(0x48231a); + fcn.00453d28(); + if (pddrawsf2 != NULL) { + IDirectDrawSurface_Release(pddrawsf2); + } + if (pddrawsf1 != NULL) { + IDirectDrawSurface_Release(pddrawsf1); + } + if (pddraw != NULL) { + IDirectDraw_Release(pddraw); + } + mid_status[5] = 1; + } +} + int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, @@ -291,7 +320,7 @@ switch_401cb8_case_1: sub_PostMessageA_981(1); break; case 3: - sub_UnhookWindowsHookEx_815(); + deinit_game(); DestroyWindow(gwindowHandle); break; default: @@ -355,7 +384,7 @@ loop_end: if (b_46caf9 == 0) goto start_msg_loop; fcn_00451b36(); - sub_UnhookWindowsHookEx_815(); + deinit_game(); DestroyWindow(gwindowHandle); goto start_msg_loop; } |