Mercurial > mm7
changeset 1039:682ba1c83fd3
Merge
author | Nomad |
---|---|
date | Thu, 23 May 2013 03:32:36 +0200 |
parents | 39f42990698f (diff) ff2d888f8033 (current diff) |
children | 0744f8665045 |
files | Events.cpp UIHouses.cpp mm7_5.cpp |
diffstat | 27 files changed, 734 insertions(+), 3461 deletions(-) [+] |
line wrap: on
line diff
--- a/Arcomage.cpp Wed May 22 22:26:31 2013 +0400 +++ b/Arcomage.cpp Thu May 23 03:32:36 2013 +0200 @@ -267,7 +267,7 @@ TranslateMessage(&pArcomageGame->msg); DispatchMessageA(&pArcomageGame->msg); } - if (pAsyncMouse) + /*if (pAsyncMouse) { EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); v4 = *((unsigned int *)pAsyncMouse + 7); @@ -297,7 +297,7 @@ if ( !*((unsigned char *)pAsyncMouse + 90) ) pArcomageGame->field_F6 = 1; LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); - } + }*/ memcpy(v2, &pArcomageGame->stru1, 0xCu); return pArcomageGame->stru1.field_0 != 0; } @@ -1423,11 +1423,7 @@ ++v3; } while ( (signed int)v3 < (signed int)&unk_5052C8 ); - if (pAsyncMouse) - { - pAsyncMouse->_409E3D(*((unsigned char *)pAsyncMouse + 103)); - pAsyncMouse->_46B944(); - } + pArcomageGame->pGameBackground.Release(); pArcomageGame->pSprites.Release(); pArcomageGame->bGameInProgress = 0; @@ -5754,8 +5750,6 @@ int pXY[2]; // [sp+18h] [bp-Ch]@5 int v10; // [sp+20h] [bp-4h]@3 - if (pAsyncMouse) - pAsyncMouse->_409E3D(1); pAudioPlayer->StopChannels(-1, -1); strcpy(pArcomageGame->pPlayer1Name, pArcomagePlayer1Name); strcpy(pArcomageGame->pPlayer2Name, pArcomagePlayer2Name);
--- a/CShow.cpp Wed May 22 22:26:31 2013 +0400 +++ b/CShow.cpp Thu May 23 03:32:36 2013 +0200 @@ -9,9 +9,6 @@ { if (bNoVideo) return; - if (pAsyncMouse) - pAsyncMouse->Suspend(); - switch (eVideo) { case MOVIE_3DOLogo: VideoPlayer::MovieLoop("3dologo", 0, 0, 1); break; @@ -26,9 +23,5 @@ assert(false && "Invalid movie requested in " __FUNCTION__); break; } - - if (bShowMouseAfterPlayback) - if (pAsyncMouse) - pAsyncMouse->Resume(); }
--- a/Events.cpp Wed May 22 22:26:31 2013 +0400 +++ b/Events.cpp Thu May 23 03:32:36 2013 +0200 @@ -375,8 +375,7 @@ pVideoPlayer->Unload(); pVideoPlayer->bStopBeforeSchedule = 0; pVideoPlayer->pResetflag = 0; - if (pAsyncMouse) - pAsyncMouse->Suspend(); + v128 = pCurrentScreen; //v13 = &pSomeEVT[v9]; //v14 = (unsigned __int8)v13[5]; @@ -400,8 +399,7 @@ if ( v128 == 13 ) pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); } - if (pAsyncMouse) - pAsyncMouse->Resume(); + ++curr_seq_num; v4 = v124; @@ -423,8 +421,6 @@ if ( v128 == 13 ) pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); } - if (pAsyncMouse) - pAsyncMouse->Resume(); ++curr_seq_num; v4 = v124; @@ -447,8 +443,6 @@ if ( v128 == 13 ) pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); } - if (pAsyncMouse) - pAsyncMouse->Resume(); ++curr_seq_num; v4 = v124;
--- a/GUIProgressBar.cpp Wed May 22 22:26:31 2013 +0400 +++ b/GUIProgressBar.cpp Thu May 23 03:32:36 2013 +0200 @@ -43,8 +43,6 @@ } //v2 = this; - if (pAsyncMouse) - pAsyncMouse->Suspend(); if (pLoadingBg.pPixels) return false; @@ -145,8 +143,6 @@ int v3; // edi@7 v1 = this; - if (pAsyncMouse) - pAsyncMouse->Resume(); if ( v1->uType == 1 ) { if ( !v1->pLoadingBg.pPixels )
--- a/GUIWindow.cpp Wed May 22 22:26:31 2013 +0400 +++ b/GUIWindow.cpp Thu May 23 03:32:36 2013 +0200 @@ -35,6 +35,22 @@ struct GUIMessageQueue *pMessageQueue_50CBD0 = new GUIMessageQueue; struct GUIMessageQueue *pMessageQueue_50C9E8 = new GUIMessageQueue; + + + + + + +//----- (004141CA) -------------------------------------------------------- +void ModalWindow(const char *pStr, int a4) +{ + pEventTimer->Pause(); + dword_506F0C[0] = pCurrentScreen; + ptr_507BDC = GUIWindow::Create(0, 0, 640, 480, WINDOW_FinalWindow, a4, (int)pStr); + pCurrentScreen = SCREEN_PRESS_ESCAPE_MESSAGE; +} +// 4E28F8: using guessed type int pCurrentScreen; + // inlined //----- (mm6c::00420520) -------------------------------------------------- void GUIMessageQueue::Flush() @@ -296,7 +312,7 @@ { pIcons_LOD->SyncLoadedFilesCount(); pCurrentScreen = pMainScreenNum; - pKeyActionMap->_459ED1(3); + pKeyActionMap->SetWindowInputStatus(3); break; } case WINDOW_HouseInterior:
--- a/GUIWindow.h Wed May 22 22:26:31 2013 +0400 +++ b/GUIWindow.h Thu May 23 03:32:36 2013 +0200 @@ -307,6 +307,12 @@ struct GUIButton; struct Texture; + +#define WINDOW_INPUT_NONE 0 +#define WINDOW_INPUT_IN_PROGRESS 1 +#define WINDOW_INPUT_CONFIRMED 2 +#define WINDOW_INPUT_CANCELLED 3 + /* 155 */ #pragma pack(push, 1) struct GUIWindow @@ -354,7 +360,7 @@ int field_34; int pStartingPosActiveItem; int numVisibleWindows; - int field_40; + int receives_keyboard_input_2; // 0 no input 1 currently typing 2 enter pressed 3 escape pressed int receives_keyboard_input; char *Hint; GUIButton *pControlsHead; @@ -543,7 +549,7 @@ void InitializeBookFonts(); void DrawSpellBookContent(Player *player); unsigned int __cdecl DrawLloydBeaconsScreen(); -void DrawTownPortalScreen(); +void BookUI_DrawTownPortalMap(); void LoadSpellbook(unsigned int uID); // idb void DrawSpellDescriptionPopup(int spell_index); void sub_41140B();
--- a/Game.cpp Wed May 22 22:26:31 2013 +0400 +++ b/Game.cpp Thu May 23 03:32:36 2013 +0200 @@ -319,10 +319,7 @@ dword_6BE340 = 2; // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; pCurrentScreen = SCREEN_GAME; - if (pAsyncMouse) - pAsyncMouse->Resume(); - if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard ) - pAsyncKeyboard->Resume(); + if ( pRenderer->pRenderD3D ) pGame->pVisInstance->_4C1A02(); @@ -351,8 +348,6 @@ pRenderer->Present(); continue; } - if (pAsyncMouse) - pAsyncMouse->_46B736_consume_click_lists(1); if ( pVideoPlayer->pSmackerMovie && !SmackWait(pVideoPlayer->pSmackerMovie) ) { pRenderer->BeginScene(); @@ -760,10 +755,7 @@ { struct tagRECT Rect; // [sp+0h] [bp-10h]@6 - if (pAsyncMouse) - pAsyncMouse->Suspend(); - if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard) - pAsyncKeyboard->Suspend(); + WriteWindowsRegistryInt("startinwindow", pRenderer->bWindowMode); if ( GetWindowRect(hWnd, &Rect) && pRenderer->bWindowMode ) { @@ -773,10 +765,7 @@ WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); pItemsTable->Release(); pNPCStats->Release(); - if (pAsyncKeyboard) - pAsyncKeyboard->Release(); - if (pAsyncMouse) - pAsyncMouse->Release(); + if (pMouse) pMouse->Deactivate();
--- a/Keyboard.cpp Wed May 22 22:26:31 2013 +0400 +++ b/Keyboard.cpp Thu May 23 03:32:36 2013 +0200 @@ -113,7 +113,7 @@ } //----- (00459E5A) -------------------------------------------------------- -void KeyboardActionMapping::EnterText(int a2, int pNumWord, GUIWindow *pWindow) +void KeyboardActionMapping::EnterText(int a2, int max_string_len, GUIWindow *pWindow) { KeyboardActionMapping *v4; // esi@1 @@ -124,29 +124,17 @@ v4->field_204 = 2; else v4->field_204 = 1; - v4->field_FC = pNumWord; + v4->max_input_string_len = max_string_len; v4->pWindow = pWindow; - pWindow->field_40 = 1; - if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) ) - { - if ( pAsyncKeyboard ) - pAsyncKeyboard->Suspend(); - } + pWindow->receives_keyboard_input_2 = WINDOW_INPUT_IN_PROGRESS; } //----- (00459ED1) -------------------------------------------------------- -void KeyboardActionMapping::_459ED1(int a2) +void KeyboardActionMapping::SetWindowInputStatus(int a2) { - KeyboardActionMapping *v2; // esi@1 - GUIWindow *v3; // esi@4 - - v2 = this; - if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard) - pAsyncKeyboard->Resume(); - v2->field_204 = 0; - v3 = v2->pWindow; - if ( v3 ) - v3->field_40 = a2; + field_204 = 0; + if ( pWindow ) + pWindow->receives_keyboard_input_2 = a2; } //----- (00459F10) -------------------------------------------------------- @@ -167,7 +155,7 @@ goto LABEL_3; if ( a2 == 27 ) goto LABEL_15; - if ( this->uNumKeysPressed >= this->field_FC ) + if ( this->uNumKeysPressed >= this->max_input_string_len ) return 1; pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = a2; ++pKeyActionMap->uNumKeysPressed; @@ -188,7 +176,7 @@ { if ( (signed int)a2 >= 48 && (signed int)a2 <= 57 ) { - if ( pKeyActionMap->uNumKeysPressed < this->field_FC ) + if ( pKeyActionMap->uNumKeysPressed < this->max_input_string_len ) { pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = a2; ++pKeyActionMap->uNumKeysPressed; @@ -212,7 +200,7 @@ LABEL_3: v3 = 2; LABEL_4: - pKeyActionMap->_459ED1(v3); + pKeyActionMap->SetWindowInputStatus(v3); return 1; } // 506E68: using guessed type int uGameMenuUI_CurentlySelectedKeyIdx; @@ -651,7 +639,7 @@ const char *v28; // eax@1 const char *v29; // eax@1 - v2 = GetVKeyDisplayName(this->pVirtualKeyCodesMapping[0]); + v2 = GetVKeyDisplayName(pVirtualKeyCodesMapping[0]); WriteWindowsRegistryString("KEY_FORWARD", v2); v3 = GetVKeyDisplayName(pVirtualKeyCodesMapping[1]); WriteWindowsRegistryString("KEY_BACKWARD", v3); @@ -948,893 +936,22 @@ //----- (0045B019) -------------------------------------------------------- void Keyboard::EnterCriticalSection() { - if (bUsingAsynKeyboard) - AsyncKeyboard::EnterCriticalSection(); } //----- (0045B06E) -------------------------------------------------------- bool Keyboard::IsShiftHeld() { - if (bUsingAsynKeyboard) - { - if ( pAsyncKeyboard->_45B4EC(0x2Au) ) - { - return true; - } - return pAsyncKeyboard->_45B4EC(0x36u) != 0; - } - else - return GetAsyncKeyState(VK_SHIFT); + return GetAsyncKeyState(VK_SHIFT); } //----- (0045B0A9) -------------------------------------------------------- bool Keyboard::IsKeyBeingHeld(int vKey) { - void *v2; // esi@2 - char v3; // bl@2 - bool result; - - if (bUsingAsynKeyboard) - { - __debugbreak(); - /* - v2 = pAsyncKeyboard; - EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - v3 = *((unsigned char *)v2 + (unsigned __int8)AsyncKeyboard::map_key(v2, vKey) + 265) >> 7; - LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - return v3;*/ - } - else - //return (GetAsyncKeyState(vKey) & 0x8001) != 0; - result = GetAsyncKeyState(vKey); - return result; + return GetAsyncKeyState(vKey) & 0x8001; } //----- (0045B0CE) -------------------------------------------------------- bool Keyboard::WasKeyPressed(int vKey) { - void *v2; // esi@2 - char v3; // bl@2 - bool result; // eax@2 - - if ( this->bUsingAsynKeyboard ) - { - __debugbreak(); - /*v2 = pAsyncKeyboard; - EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - v3 = *((unsigned char *)v2 + (unsigned __int8)AsyncKeyboard::map_key(v2, vKey) + 521) >> 7; - LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - LOBYTE(result) = v3;*/ - } - else - { - result = GetAsyncKeyState(vKey); - //LOBYTE(result) = result & 1; - } - return result; -} - -//----- (0045B10A) -------------------------------------------------------- -AsyncKeyboard::AsyncKeyboard() -{ - *(unsigned int *)(this + 4) = 0; - *(unsigned char *)(this + 8) = 0; - - if (!Initialize()) - MessageBoxW(nullptr, L"Could not initialize asynchronos keyboard object", nullptr, 0); -} -// 4D86B8: using guessed type int (__stdcall *AsyncKeyboard_pvdtor)(char); -// 4DBD94: using guessed type int dword_4DBD94; - - -//----- (0045B15E) -------------------------------------------------------- -AsyncKeyboard::~AsyncKeyboard() -{ - __debugbreak(); - /* - void *v1; // esi@1 - char *v2; // edi@1 - int v3; // ecx@1 - - v1 = this; - v2 = (char *)this + 1804; - v3 = *((unsigned int *)this + 451); - if ( v3 ) - (**(void (__stdcall ***)(unsigned int))v3)(1); - *(unsigned int *)v2 = 0; - return TerminateThread(*((HANDLE *)v1 + 1), 0x1F4u);*/ -} -// 4D86B8: using guessed type int (__stdcall *AsyncKeyboard_pvdtor)(char); - -//----- (0045B18E) -------------------------------------------------------- -bool AsyncKeyboard::Initialize() -{ - _45B1B1(); - if (_45B229()) - return CreateDirectInputKeyboard() != 0; - return false; -} - -//----- (0045B1B1) -------------------------------------------------------- -void AsyncKeyboard::_45B1B1() -{ - void *v1; // esi@1 - - v1 = this; - memset((char *)this + 9, 0, 0x100u); - memset((char *)v1 + 265, 0, 0x100u); - memset((char *)v1 + 521, 0, 0x100u); - memset((char *)v1 + 780, 0, 0x400u); -} - -//----- (0045B1FD) -------------------------------------------------------- -void AsyncKeyboard::EnterCriticalSection() -{ - __debugbreak(); - //EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); -} - -//----- (0045B213) -------------------------------------------------------- -void AsyncKeyboard::LeaveCriticalSection() -{ - __debugbreak(); - //LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); -} - -//----- (0045B229) -------------------------------------------------------- -char AsyncKeyboard::_45B229() -{ - __debugbreak(); - return 0; - /*void *v1; // esi@1 - HANDLE v2; // eax@1 - char result; // al@2 - DWORD ThreadId; // [sp+0h] [bp-4h]@1 - - ThreadId = (DWORD)this; - v1 = this; - v2 = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)AsyncKeyboardThread, this, 4u, &ThreadId); - *((unsigned int *)v1 + 1) = v2; - if ( v2 ) - result = SetThreadPriority(v2, 15) != 0; - else - result = 0; - return result;*/ -} - -//----- (0045B260) -------------------------------------------------------- -char AsyncKeyboard::CreateDirectInputKeyboard() -{ - __debugbreak(); - return 0; - /*v1 = this; - v2 = new DirectInputKeyboard; - *((void **)v1 + 451) = v2; - - return v2 != 0;*/ -} - -//----- (0045B2A7) -------------------------------------------------------- -void AsyncKeyboard::Resume() -{ - __debugbreak(); - /*void *v1; // esi@1 - std::string v2; // [sp-18h] [bp-24h]@2 - const char *v3; // [sp-8h] [bp-14h]@2 - int v4; // [sp-4h] [bp-10h]@2 - std::string *v5; // [sp+4h] [bp-8h]@2 - int a3; // [sp+Bh] [bp-1h]@2 - - v1 = this; - if ( *((unsigned int *)this + 451) ) - { - EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - _45B1B1(); - DirectInputKeyboard::set_acquire(*((DirectInputKeyboard **)v1 + 451), (int *)1); - ResumeThread(*((HANDLE *)v1 + 1)); - LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - } - else - { - MessageBoxW(nullptr, L"Invalid DI_Keyboard, bailing out of resume()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\KeyboardAsync.cpp:97", 0); - }*/ -} - -//----- (0045B329) -------------------------------------------------------- -void AsyncKeyboard::Suspend() -{ - __debugbreak(); - /*void *v1; // esi@1 - std::string v2; // [sp-18h] [bp-24h]@2 - const char *v3; // [sp-8h] [bp-14h]@2 - int v4; // [sp-4h] [bp-10h]@2 - std::string *v5; // [sp+4h] [bp-8h]@2 - int a3; // [sp+Bh] [bp-1h]@2 - - v1 = this; - if ( *((unsigned int *)this + 451) ) - { - EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - SuspendThread(*((HANDLE *)v1 + 1)); - DirectInputKeyboard::set_acquire(*((DirectInputKeyboard **)v1 + 451), 0); - LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - } - else - { - MessageBoxW(nullptr, L"Invalid DI_Keyboard, bailing out of suspend()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\KeyboardAsync.cpp:115", 0); - }*/ -} - -//----- (0045B3A4) -------------------------------------------------------- -char AsyncKeyboard::_45B3A4() -{ - __debugbreak(); - return 0; - /**((unsigned char *)this + 8) = 1; - Sleep(0x85u); - return 1;*/ -} - - -//----- (00465C53) -------------------------------------------------------- -void AsyncKeyboard::Release() -{ - __debugbreak(); - /*if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) ) - { - if ( pAsyncKeyboard ) - { - pAsyncKeyboard->Suspend(); - if ( pAsyncKeyboard ) - (**(void (__stdcall ***)(int))pAsyncKeyboard)(1); - } - pAsyncKeyboard = 0; - }*/ -} - -//----- (0045B3B6) -------------------------------------------------------- -void AsyncKeyboard::Thread() -{ - __debugbreak(); - /*void *v1; // esi@1 - signed int v2; // ecx@3 - int v3; // eax@3 - DWORD v4; // edx@6 - std::string v5; // [sp-18h] [bp-2Ch]@2 - const char *v6; // [sp-8h] [bp-1Ch]@2 - int v7; // [sp-4h] [bp-18h]@2 - DWORD v8; // [sp+Ch] [bp-8h]@2 - int a3; // [sp+13h] [bp-1h]@2 - - v1 = this; - if ( *((unsigned int *)this + 451) ) - { - ::EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - v8 = timeGetTime(); - memcpy((char *)v1 + 9, (const void *)(*((unsigned int *)v1 + 451) + 29), 0x100u); - (*((DirectInputKeyboard **)v1 + 451)->_43B8EC(); - memcpy((char *)v1 + 265, (const void *)(*((unsigned int *)v1 + 451) + 29), 0x100u); - v2 = 0; - v3 = (int)((char *)v1 + 780); - do - { - if ( *((unsigned char *)v1 + v2 + 265) & 0x80 ) - { - if ( v8 - *(unsigned int *)v3 > 0xC8 ) - { - v4 = v8; - *((unsigned char *)v1 + v2 + 521) |= 0x80u; - *(unsigned int *)v3 = v4; - } - } - ++v2; - v3 += 4; - } - while ( v2 < 256 ); - ::LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - } - else - { - MessageBoxW(nullptr, L"Invalid DI_Keyboard, bailing out of update_keyboard_data()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\KeyboardAsync.cpp:169", 0); - }*/ -} - -//----- (0045B4EC) -------------------------------------------------------- -char AsyncKeyboard::_45B4EC(unsigned __int8 a2) -{ - __debugbreak(); - return 0; - /*void *v2; // esi@1 - char v3; // bl@1 - - v2 = this; - EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - v3 = *((unsigned char *)v2 + a2 + 265) >> 7; - LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncKeyboard); - return v3;*/ + return GetAsyncKeyState(vKey) & 1; } - -//----- (0045B57D) -------------------------------------------------------- -char AsyncKeyboard::map_key(int key) -{ - __debugbreak(); - return 0; - /*char result; // al@2 - std::string v3; // [sp-18h] [bp-1Ch]@99 - const char *v4; // [sp-8h] [bp-Ch]@99 - int v5; // [sp-4h] [bp-8h]@99 - void *v6; // [sp+0h] [bp-4h]@1 - - v6 = this; - switch ( key ) - { - case 8: - result = 14; - break; - case 9: - result = 15; - break; - case 13: - result = 28; - break; - case 16: - case 161: - result = 54; - break; - case 160: - result = 42; - break; - case 17: - case 163: - result = -99; - break; - case 162: - result = 29; - break; - case 18: - result = -72; - break; - case 20: - result = 58; - break; - case 21: - result = 112; - break; - case 25: - result = -108; - break; - case 27: - result = 1; - break; - case 28: - result = 121; - break; - case 29: - result = 123; - break; - case 32: - result = 57; - break; - case 33: - result = -55; - break; - case 34: - result = -47; - break; - case 35: - result = -49; - break; - case 36: - result = -57; - break; - case 37: - result = -53; - break; - case 38: - result = -56; - break; - case 39: - result = -51; - break; - case 40: - result = -48; - break; - case 42: - result = -73; - break; - case 45: - result = -46; - break; - case 46: - result = -45; - break; - case 48: - result = 11; - break; - case 49: - result = 2; - break; - case 50: - result = 3; - break; - case 51: - result = 4; - break; - case 52: - result = 5; - break; - case 53: - result = 6; - break; - case 54: - result = 7; - break; - case 55: - result = 8; - break; - case 56: - result = 9; - break; - case 57: - result = 10; - break; - case 65: - result = 30; - break; - case 66: - result = 48; - break; - case 67: - result = 46; - break; - case 68: - result = 32; - break; - case 69: - result = 18; - break; - case 70: - result = 33; - break; - case 71: - result = 34; - break; - case 72: - result = 35; - break; - case 73: - result = 23; - break; - case 74: - result = 36; - break; - case 75: - result = 37; - break; - case 76: - result = 38; - break; - case 77: - result = 50; - break; - case 78: - result = 49; - break; - case 79: - result = 24; - break; - case 80: - result = 25; - break; - case 81: - result = 16; - break; - case 82: - result = 19; - break; - case 83: - result = 31; - break; - case 84: - result = 20; - break; - case 85: - result = 22; - break; - case 86: - result = 47; - break; - case 87: - result = 17; - break; - case 88: - result = 45; - break; - case 89: - result = 21; - break; - case 90: - result = 44; - break; - case 91: - result = -37; - break; - case 92: - result = -36; - break; - case 93: - result = -35; - break; - case 96: - result = 82; - break; - case 97: - result = 79; - break; - case 98: - result = 80; - break; - case 99: - result = 81; - break; - case 100: - result = 75; - break; - case 101: - result = 76; - break; - case 102: - result = 77; - break; - case 103: - result = 71; - break; - case 104: - result = 72; - break; - case 105: - result = 73; - break; - case 106: - result = 55; - break; - case 107: - result = 78; - break; - case 109: - result = 74; - break; - case 110: - result = 83; - break; - case 111: - result = -75; - break; - case 112: - result = 59; - break; - case 113: - result = 60; - break; - case 114: - result = 61; - break; - case 115: - result = 62; - break; - case 116: - result = 63; - break; - case 117: - result = 64; - break; - case 118: - result = 65; - break; - case 119: - result = 66; - break; - case 120: - result = 67; - break; - case 121: - result = 68; - break; - case 122: - result = 87; - break; - case 123: - result = 88; - break; - case 124: - result = 100; - break; - case 125: - result = 101; - break; - case 126: - result = 102; - break; - case 144: - result = 69; - break; - case 145: - result = 70; - break; - default: - MessageBoxW(nullptr, L"Uknown key detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\KeyboardAsync.cpp:999", 0); - goto LABEL_100; - case 1: - case 2: - case 3: - case 4: - case 12: - case 19: - case 23: - case 24: - case 30: - case 31: - case 41: - case 43: - case 44: - case 47: - case 108: - case 127: - case 128: - case 129: - case 130: - case 131: - case 132: - case 133: - case 134: - case 135: -LABEL_100: - result = -1; - break; - } - return result;*/ -} - -//----- (0045BA60) -------------------------------------------------------- -int __stdcall AsyncKeyboard::ThreadStarter(AsyncKeyboard *pInstance) -{ - __debugbreak(); - return 0; - /*while ( 1 ) - { - while ( !pAsyncKeyboard ) - ; - if ( *((unsigned char *)pAsyncKeyboard + 8) ) - ExitThread(0); - pAsyncKeyboard->Thread(); - Sleep(0x21u); - }*/ -} - - - - - - - - -/* -//----- (0043B76D) -------------------------------------------------------- -DirectInputKeyboard *__thiscall DirectInputKeyboard::DirectInputKeyboard(DirectInputKeyboard *this) -{ - DirectInputKeyboard *v1; // esi@1 - HRESULT v2; // eax@5 - unsigned int uVersion; // [sp-18h] [bp-20h]@3 - IDirectInput **ppDirectInput; // [sp-14h] [bp-1Ch]@3 - int v6; // [sp-10h] [bp-18h]@3 - const char *v7; // [sp-Ch] [bp-14h]@3 - int v8; // [sp-8h] [bp-10h]@3 - unsigned int v9; // [sp-4h] [bp-Ch]@3 - CheckHRESULT_stru0 v10; // [sp+4h] [bp-4h]@5 - - v1 = this; - this->field_8 = 0; - LOBYTE(this->field_1C) = 0; - this->vdestructor_ptr = &pDirectInputKeyboard_pvdtor; - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) - { - v9 = 1; - v8 = 28; - v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp"; - v6 = 0; - ppDirectInput = &this->pDirectInput; - uVersion = 0x500u; - } - else - { - v9 = 1; - v8 = 26; - v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp"; - v6 = 0; - ppDirectInput = &this->pDirectInput; - uVersion = 0x300u; - } - v2 = DirectInputCreateA(hInstance, uVersion, ppDirectInput, v6); - CheckHRESULT(&v10, v2, v7, v8, v9); - DirectInputKeyboard::CreateDevice(v1); - DirectInputKeyboard::43B87B(v1); - return v1; -} -// 4C8880: using guessed type int __stdcall DirectInputCreateA(int, int, int, int); - -//----- (0043B7E3) -------------------------------------------------------- -void __thiscall DirectInputKeyboard::vdtor(DirectInputKeyboard *this, bool a2) -{ - void *v2; // esi@1 - - v2 = this; - DirectInputKeyboard::dtor(this); - if ( a2 & 1 ) - free(v2); -} - -//----- (0043B7FF) -------------------------------------------------------- -void __thiscall DirectInputKeyboard::dtor(DirectInputKeyboard *this) -{ - DirectInputKeyboard *v1; // esi@1 - int v2; // eax@1 - - v1 = this; - v2 = this->field_8; - this->vdestructor_ptr = &pDirectInputKeyboard_pvdtor; - if ( v2 ) - { - (*(void (__stdcall **)(int))(*(int *)v2 + 32))(v2); - (*(void (__stdcall **)(int))(*(int *)v1->field_8 + 8))(v1->field_8); - v1->field_8 = 0; - } - v1->pDirectInput->lpVtbl->Release(v1->pDirectInput); - v1->pDirectInput = 0; -} - -//----- (0043B831) -------------------------------------------------------- -void __thiscall DirectInputKeyboard::CreateDevice(DirectInputKeyboard *this) -{ - DirectInputKeyboard *v1; // esi@1 - HRESULT v2; // eax@1 - int v3; // [sp+4h] [bp-4h]@1 - - v1 = this; - v2 = ((int (__stdcall *)(IDirectInput *, signed int, int (__stdcall *)(int, int), DirectInputKeyboard *, signed int))this->pDirectInput->lpVtbl->field_10)( - this->pDirectInput, - 3, - DirectInputKeyboard_enumerator_43B9B9, - this, - 1); - CheckHRESULT((CheckHRESULT_stru0 *)&v3, v2, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp", 52, 1u); - if ( !LOBYTE(v1->field_1C) ) - { - v3 = (int)"Error: No keyboard found"; - _CxxThrowException((int)&v3, (int)&dword_4DBD94); - } -} -// 43B9B9: using guessed type int __stdcall DirectInputKeyboard_enumerator_43B9B9(int, int); -// 4DBD94: using guessed type int dword_4DBD94; - -//----- (0043B87B) -------------------------------------------------------- -void __thiscall DirectInputKeyboard::43B87B(DirectInputKeyboard *ecx0) -{ - char *v1; // esi@1 - HRESULT v2; // eax@1 - HRESULT v3; // eax@1 - HRESULT v4; // eax@1 - unsigned int v5; // [sp+0h] [bp-Ch]@0 - char this; // [sp+8h] [bp-4h]@1 - - v1 = (char *)&ecx0->field_8; - v2 = ((int (__stdcall *)(IDirectInput *, int *, int *, int, int))ecx0->pDirectInput->lpVtbl->field_C)( - ecx0->pDirectInput, - &ecx0->field_C, - &ecx0->field_8, - 0, - "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp"); - CheckHRESULT((CheckHRESULT_stru0 *)&this, v2, (const char *)0x3C, 1, v5); - v3 = (*(int (__stdcall **)(int, int))(**(int **)v1 + 44))(*(int *)v1, dword_4C9890); - CheckHRESULT((CheckHRESULT_stru0 *)&this, v3, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp", 63, 1u); - v4 = (*(int (__stdcall **)(int, HWND, signed int))(**(int **)v1 + 52))(*(int *)v1, hWnd, 6); - CheckHRESULT((CheckHRESULT_stru0 *)&this, v4, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp", 64, 1u); - (*(void (__cdecl **)(int))(**(int **)v1 + 28))(*(int *)v1); -} -// 4C9890: using guessed type int dword_4C9890[10]; - -//----- (0043B8EC) -------------------------------------------------------- -char __thiscall DirectInputKeyboard::43B8EC(DirectInputKeyboard *this) -{ - DirectInputKeyboard *v1; // esi@1 - int v2; // eax@1 - char result; // al@2 - char *v4; // ebx@3 - int v5; // esi@5 - HRESULT v6; // eax@5 - std::string v7; // [sp-18h] [bp-2Ch]@2 - int v8; // [sp-Ch] [bp-20h]@5 - const char *v9; // [sp-8h] [bp-1Ch]@2 - int v10; // [sp-4h] [bp-18h]@2 - std::string *v13; // [sp+Ch] [bp-8h]@2 - int a3; // [sp+13h] [bp-1h]@2 - - v1 = this; - v2 = this->field_8; - if ( v2 ) - { - v4 = (char *)&this->field_1C + 1; - if ( (*(int (__stdcall **)(int, signed int, char *))(*(int *)v2 + 36))(v2, 256, (char *)&this->field_1C + 1) == -2147024866 ) - { - if ( !(*(int (__stdcall **)(int))(*(int *)v1->field_8 + 28))(v1->field_8) ) - { - v5 = v1->field_8; - v10 = 1; - v9 = (const char *)79; - v8 = (int)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp"; - v6 = (*(int (__stdcall **)(int, signed int, char *))(*(int *)v5 + 36))(v5, 256, v4); - CheckHRESULT((CheckHRESULT_stru0 *)&v13, v6, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp", 79, 1u); - } - } - result = 1; - } - else - { - MessageBoxW(nullptr, L"Invalid Device pointer, bailing out of update_data()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp:72", 0); - result = 0; - } - return result; -} - -//----- (0043B96E) -------------------------------------------------------- -char __thiscall DirectInputKeyboard::set_acquire(DirectInputKeyboard *this, int *a2) -{ - int v2; // eax@1 - char result; // al@2 - int v4; // ecx@3 - std::string v5; // [sp-18h] [bp-1Ch]@2 - const char *v6; // [sp-8h] [bp-Ch]@2 - int v7; // [sp-4h] [bp-8h]@2 - DirectInputKeyboard *v8; // [sp+0h] [bp-4h]@1 - - v8 = this; - v2 = this->field_8; - if ( v2 ) - { - v4 = *(int *)v2; - v7 = v2; - if ( (char)a2 ) - (*(void (__stdcall **)(int))(v4 + 28))(v7); - else - (*(void (__stdcall **)(int))(v4 + 32))(v7); - result = 1; - } - else - { - MessageBoxW(nullptr, L"Invalid Device pointer, bailing out of set_acquire()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputKeyboard.cpp:89", 0); - result = 0; - } - return result; -} - -//----- (0043B9B9) -------------------------------------------------------- -signed int __stdcall DirectInputKeyboard_enumerator_43B9B9(int a1, int a2) -{ - signed int result; // eax@2 - - if ( *(char *)(a1 + 36) & 3 ) - { - *(int *)(a2 + 12) = *(int *)(a1 + 4); - *(int *)(a2 + 16) = *(int *)(a1 + 8); - *(int *)(a2 + 20) = *(int *)(a1 + 12); - *(int *)(a2 + 24) = *(int *)(a1 + 16); - *(char *)(a2 + 28) = 1; - result = 0; - } - else - { - result = 1; - } - return result; -} -// 43B9B9: using guessed type int __stdcall DirectInputKeyboard_enumerator_43B9B9(int, int); -*/ \ No newline at end of file
--- a/Keyboard.h Wed May 22 22:26:31 2013 +0400 +++ b/Keyboard.h Thu May 23 03:32:36 2013 +0200 @@ -56,8 +56,8 @@ void ReadMappings(); void StoreMappings(); bool _459F10(unsigned int a2); - void _459ED1(int a2); - void EnterText(int a2, int a3, struct GUIWindow *pWindow); + void SetWindowInputStatus(int a2); + void EnterText(int a2, int max_string_len, struct GUIWindow *pWindow); void ResetKeys(); void SetDefaultMapping(); @@ -66,7 +66,7 @@ int field_8; unsigned int pVirtualKeyCodesMapping[30]; KeyToggleType pToggleTypes[30]; - int field_FC; + int max_input_string_len; unsigned __int8 pPressedKeysBuffer[257]; unsigned __int8 uNumKeysPressed; char field_202; @@ -91,30 +91,6 @@ #pragma pack(pop) -#pragma pack(push, 1) -struct AsyncKeyboard -{ - AsyncKeyboard(); - ~AsyncKeyboard(); - - bool Initialize(); - char map_key(int key); - char _45B4EC(unsigned __int8 a2); - void Thread(); - char _45B3A4(); - void Suspend(); - void Resume(); - char CreateDirectInputKeyboard(); - char _45B229(); - void _45B1B1(); - void Release(); - - static int __stdcall ThreadStarter(AsyncKeyboard *pInstance); - static void EnterCriticalSection(); - static void LeaveCriticalSection(); -}; -#pragma pack(pop) -extern struct KeyboardActionMapping *pKeyActionMap; -extern struct AsyncKeyboard *pAsyncKeyboard; \ No newline at end of file +extern struct KeyboardActionMapping *pKeyActionMap; \ No newline at end of file
--- a/Mouse.cpp Wed May 22 22:26:31 2013 +0400 +++ b/Mouse.cpp Thu May 23 03:32:36 2013 +0200 @@ -15,7 +15,6 @@ Mouse *pMouse; -AsyncMouse *pAsyncMouse; @@ -24,19 +23,8 @@ //----- (00469860) -------------------------------------------------------- void Mouse::GetClickPos(unsigned int *pX, unsigned int *pY) { - unsigned int v3; // eax@2 - - if (pAsyncMouse) - { - *pX = *((int *)pAsyncMouse + 6); - v3 = *((int *)pAsyncMouse + 7); - } - else - { - *pX = this->uMouseClickX; - v3 = this->uMouseClickY; - } - *pY = v3; + *pX = uMouseClickX; + *pY = uMouseClickY; } //----- (004698A6) -------------------------------------------------------- @@ -64,7 +52,7 @@ { Mouse *v2; // esi@1 HCURSOR v3; // eax@10 - int v4; // ecx@10 + //int v4; // ecx@10 double v5; // st7@11 float v6; // ST04_4@12 LONG v7; // eax@14 @@ -106,21 +94,18 @@ { v3 = LoadCursorA(GetModuleHandleW(nullptr), "Arrow"); SetClassLongA(hWnd, GCL_HCURSOR, (LONG)v3); - v4 = (int)pAsyncMouse; - if (pAsyncMouse) + /*if (pAsyncMouse) { v10 = 0.0; v5 = 0.0; //LABEL_12: v6 = v5; - pAsyncMouse->SetHotspot(v6, v10); - if ( !pAsyncMouse || (pAsyncMouse->LoadCursor(pName), !pAsyncMouse) ) - { + GetCursorPos(&Point); SetCursorPos(Point.x, Point.y); - } + return; - } + }*/ GetCursorPos(&Point); ClientToScreen(hWnd,&Point); SetCursorPos(Point.x, Point.y); @@ -130,8 +115,7 @@ { v7 = (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Target"); SetClassLongA(hWnd, -12, v7); - v4 = (int)pAsyncMouse; - if (pAsyncMouse) + /*if (pAsyncMouse) { v10 = 14.0; v5 = 14.0; @@ -143,7 +127,7 @@ SetCursorPos(Point.x, Point.y); } return; - } + }*/ //LABEL_20: GetCursorPos(&Point); SetCursorPos(Point.x, Point.y); @@ -155,11 +139,9 @@ SetClassLongA(hWnd, -12, v8); } //LABEL_18: - if ( !pAsyncMouse || (pAsyncMouse->LoadCursor(pName), !pAsyncMouse) ) - { + GetCursorPos(&Point); SetCursorPos(Point.x, Point.y); - } } // 506128: using guessed type int areWeLoadingTexture; @@ -173,26 +155,26 @@ v1 = this; this->field_8 = 1; - if (pAsyncMouse) + /*if (pAsyncMouse) { v2 = *((int *)pAsyncMouse + 6); Point.x = *((int *)pAsyncMouse + 6); result = *((int *)pAsyncMouse + 7); } else - { + {*/ GetCursorPos(&Point); if ( pRenderer->bWindowMode ) ScreenToClient(hWnd, &Point); result = Point.y; v2 = Point.x; - } + //} v1->uMouseClickX = v2; v1->uMouseClickY = result; if ( pRenderer->bWindowMode ) goto LABEL_16; - if (pAsyncMouse) - goto LABEL_24; + //if (pAsyncMouse) + // goto LABEL_24; if ( v2 < 0 ) v2 = 0; if ( result < 0 ) @@ -203,8 +185,8 @@ { result = 479; LABEL_16: - if (pAsyncMouse) - goto LABEL_24; + //if (pAsyncMouse) + // goto LABEL_24; if ( pRenderer->bWindowMode && (v2 < 0 || result < 0 || v2 > 639 || result > 479) ) goto LABEL_23; } @@ -262,26 +244,9 @@ //----- (00469C39) -------------------------------------------------------- POINT *Mouse::GetCursorPos(POINT *a2) { - void *v2; // edx@1 - POINT *result; // eax@1 - unsigned int v4; // ecx@2 - unsigned int v5; // edx@3 - - v2 = pAsyncMouse; - result = a2; - if (pAsyncMouse) - { - a2->x = *((int *)pAsyncMouse + 6); - v4 = *((int *)v2 + 7); - } - else - { - v5 = this->uMouseClickX; - v4 = this->uMouseClickY; - a2->x = v5; - } - a2->y = v4; - return result; + a2->x = this->uMouseClickX; + a2->y = this->uMouseClickY; + return a2; } //----- (00469C65) -------------------------------------------------------- @@ -458,16 +423,10 @@ { pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0); - if (pAsyncMouse) - { - v4 = *((int *)pAsyncMouse + 6); - v5 = *((int *)pAsyncMouse + 7); - } - else - { + v4 = pMouse->uMouseClickX; v5 = pMouse->uMouseClickY; - } + v6 = v5; a2 = v4; v15 = v5; @@ -572,1492 +531,3 @@ uMouseClickY = y; } - -//----- (00409E3D) -------------------------------------------------------- -void AsyncMouse::_409E3D(char a2) -{ - if ( *((unsigned char *)this + 128) & 1 ) - *((unsigned char *)this + 103) = 1; - else - *((unsigned char *)this + 103) = 0; - if ( a2 ) - *((unsigned int *)this + 32) |= 1u; - else - *((unsigned int *)this + 32) &= 0xFFFFFFFEu; -} - -//----- (00465C2C) -------------------------------------------------------- -void AsyncMouse::Release() -{ - if (pAsyncMouse) - { - pAsyncMouse->Suspend(); - if (pAsyncMouse) - (**(void (__stdcall ***)(int))pAsyncMouse)(1); - } - pAsyncMouse = 0; -} - - - - -//----- (0046ACA9) -------------------------------------------------------- -AsyncMouse::AsyncMouse(IDirectDrawSurface *a2) -{ - IDirectDrawSurface *v2; // eax@1 - void *v3; // esi@1 - char *v4; // edi@1 - double v5; // ST14_8@3 - double v6; // ST14_8@3 - - v2 = a2; - v3 = this; - *((int *)this + 16) = -1; - *((int *)this + 3) = (int)v2; - LOBYTE(v2) = BYTE3(a2); - v4 = (char *)this + 104; - *((int *)this + 1) = 0; - *((char *)this + 20) = 0; - *((int *)this + 17) = 0; - *((int *)this + 18) = 0; - *((char *)this + 88) = 1; - *((char *)this + 91) = 0; - *((char *)this + 93) = 0; - *((char *)this + 94) = 0; - *((char *)this + 95) = 0; - *((char *)this + 96) = 0; - *((char *)this + 97) = 0; - *((char *)this + 98) = 0; - *((char *)this + 99) = 0; - *((char *)this + 100) = 0; - *((char *)this + 101) = 0; - *((char *)this + 102) = 0; - *((char *)this + 104) = (char)v2; - *((int *)this + 27) = (int)AsyncMouse::unk_46BD09(0, 0); - *((int *)v4 + 2) = 0; - *((char *)v3 + 116) = BYTE3(a2); - *((int *)v3 + 30) = (int)AsyncMouse::unk_46BD09(0, 0); - *((int *)v3 + 31) = 0; - *((int *)v3 + 32) = 0; - *((int *)v3 + 33) = 0; - *(int *)v3 = 5080880; - if ( !Initialize(this) ) - { - MessageBoxW(nullptr, L"Could not initialize CMouseAsync object", nullptr, 0); - } - *((int *)v3 + 12) = 0; - *((int *)v3 + 13) = 0; - *((int *)v3 + 14) = 0; - *((int *)v3 + 15) = 0; - v5 = (float)0.0 + 6.7553994e15; - *((int *)v3 + 10) = LODWORD(v5); - v6 = (float)0.0 + 6.7553994e15; - a2 = (IDirectDrawSurface *)LODWORD(v6); - *((int *)v3 + 32) |= 1u; - *((int *)v3 + 11) = LODWORD(v6); - *((char *)v3 + 103) = 1; -} -// 4DBD94: using guessed type int dword_4DBD94; - - - -//----- (0046ADE2) -------------------------------------------------------- -AsyncMouse::~AsyncMouse() -{ - void *v1; // esi@1 - char *v2; // edi@1 - int v3; // ecx@1 - - v1 = this; - //*(int *)this = AsyncMouse_pvdtor; - v2 = (char *)this + 132; - v3 = *((int *)this + 33); - if ( v3 ) - (**(void (__stdcall ***)(int))v3)(1); - *(int *)v2 = 0; - TerminateThread(*((HANDLE *)v1 + 4), 0xFAu); - SetWindowPos(hWnd, (HWND)0xFFFFFFFE, uWindowX, uWindowY, 640, 480, 0); - //AsyncMouse::dtor_sub_46BC73((int)((char *)v1 + 116)); - //AsyncMouse::dtor_sub_46BC73((int)((char *)v1 + 104)); -} -// 4D8730: using guessed type int (__stdcall *AsyncMouse_pvdtor[2])(char); - - - - - - - - - - - - - -//----- (0046AE6E) -------------------------------------------------------- -char AsyncMouse::Initialize(LPVOID lpParameter) -{ - void *v1; // esi@1 - char result; // al@2 - - v1 = lpParameter; - if ( LoadCursorImage() && _46B072() ) - result = CreateDisrectInputMouse() != 0; - else - result = 0; - return result; -} - -//----- (0046AE97) -------------------------------------------------------- -char AsyncMouse::LoadCursor(const char *pContainer) -{ - __debugbreak(); - return 0; - /* - void *v2; // esi@1 - int v3; // eax@1 - HRESULT v4; // eax@1 - char result; // al@3 - HRESULT a2; // [sp+8h] [bp-B0h]@1 - int v7; // [sp+58h] [bp-60h]@1 - char v9; // [sp+B4h] [bp-4h]@1 - - v2 = this; - EnterCriticalSection(&pGame->pThreadWardInstance->cs2); - v3 = *((int *)v2 + 1); - a2 = 100; - v7 = 0; - v4 = (*(int (__stdcall **)(int, int, int, int, signed int, HRESULT *))(*(int *)v3 + 20))( - v3, - 0, - 0, - 0, - 1024, - &a2); - ErrHR(v4, "DirectInput", __FUNCTION__, __FILE__, __LINE__); - - Texture thisa; // [sp+6Ch] [bp-4Ch]@1 - //Texture::Texture(&thisa); - - if ( pIcons_LOD->LoadTextureFromLOD(&thisa, pContainer, TEXTURE_16BIT_PALETTE) != -1 - && DrawCursor(&thisa, *((IDirectDrawSurface4 **)v2 + 1), 0) ) - { - thisa.Release(); - LeaveCriticalSection(&pGame->pThreadWardInstance->cs2); - result = 1; - } - else - { - result = 0; - } - return result;*/ -} - -//----- (0046AF50) -------------------------------------------------------- -char AsyncMouse::LoadCursorImage() -{ - void *v1; // ebx@1 - int v2; // eax@2 - int v3; // esi@4 - char result; // al@5 - //const char *v5; // eax@6 - //std::string v6; // [sp-18h] [bp-12Ch]@9 - const char *v7; // [sp-8h] [bp-11Ch]@9 - int v8; // [sp-4h] [bp-118h]@9 - DDSURFACEDESC2 Dst; // [sp+Ch] [bp-108h]@1 - int v10; // [sp+88h] [bp-8Ch]@2 - int v11; // [sp+8Ch] [bp-88h]@2 - int v12; // [sp+90h] [bp-84h]@2 - int v13; // [sp+94h] [bp-80h]@2 - char v14; // [sp+D0h] [bp-44h]@2 - int v15; // [sp+F0h] [bp-24h]@2 - int v16; // [sp+104h] [bp-10h]@4 - int v17; // [sp+108h] [bp-Ch]@4 - std::string *v18; // [sp+10Ch] [bp-8h]@9 - int a3; // [sp+113h] [bp-1h]@9 - - v1 = this; - memset(&Dst, 0, 0x7Cu); - Dst.dwSize = 124; - if ( pRenderer->pDirectDraw4->GetDisplayMode(&Dst) - || (memset(&v10, 0, 0x7Cu), - v10 = 124, - v11 = 4103, - v15 = 2112, - v12 = 32, - v13 = 32, - v2 = *((int *)v1 + 3), - memcpy(&v14, &Dst.ddpfPixelFormat, 0x20u), - (*(int (__stdcall **)(int, int *, char *, int))(**(int **)v2 + 24))( - *(int *)v2, - &v10, - (char *)v1 + 4, - 0)) - || (*(int (__stdcall **)(int, int *, char *, int))(***((int ***)v1 + 3) + 24))( - **((int **)v1 + 3), - &v10, - (char *)v1 + 8, - 0) - || (v3 = *((int *)v1 + 1), - v16 = 0, - v17 = 0, - (*(int (__stdcall **)(int, signed int, int *))(*(int *)v3 + 116))(v3, 8, &v16)) ) - { - result = 0; - return false; - } - else - { - if ( !LoadCursor("micon1") ) - { - MessageBoxW(nullptr, L"Could not load async mouse cursor image", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp:182", 0); - } - result = 1; - return true; - } - return result; -} -// 4D86F0: using guessed type int dword_4D86F0; - -//----- (0046B072) -------------------------------------------------------- -char AsyncMouse::_46B072() -{ - DWORD v1; // esi@1 - HANDLE v2; // eax@1 - char result; // al@2 - DWORD ThreadId; // [sp+0h] [bp-4h]@1 - - ThreadId = (DWORD)this; - v1 = (DWORD)this; - v2 = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)AsyncMouseThread, this, 4u, &ThreadId); - *(int *)(v1 + 16) = (int)v2; - if ( v2 ) - result = SetThreadPriority(v2, 15) != 0; - else - result = 0; - return result; -} - -//----- (0046B0A9) -------------------------------------------------------- -char AsyncMouse::CreateDisrectInputMouse() -{ - __debugbreak(); - /* - void *v1; // esi@1 - DirectInputMouse *v2; // ecx@1 - DirectInputMouse *v3; // eax@2 - - v1 = this; - v2 = (DirectInputMouse *)operator new(0x2Cu); - if ( v2 ) - v3 = DirectInputMouse::DirectInputMouse(v2); - else - v3 = 0; - *((int *)v1 + 33) = v3; - return v3 != 0;*/ - return 0; -} - -//----- (0046B0ED) -------------------------------------------------------- -int AsyncMouse::_46B0ED() -{ - __debugbreak(); - /* - int v1; // esi@1 - int v2; // ecx@1 - int result; // eax@2 - - v1 = this + 132; - v2 = *(int *)(this + 132); - if ( v2 ) - result = (**(int (__stdcall ***)(int))v2)(1); - *(int *)v1 = 0; - return result;*/ - return 0; -} -// 46B0ED: using guessed type int __thiscall AsyncMouse__46B0ED(int); - -//----- (0046B105) -------------------------------------------------------- -void AsyncMouse::Resume() -{ - __debugbreak(); - /* - void *v1; // esi@1 - - v1 = this; - EnterCriticalSection(&pGame->pThreadWardInstance->cs3); - AsyncMouse::CreateDisrectInputMouse(v1); - AsyncMouse::Clip(); - ResumeThread(*((HANDLE *)v1 + 4)); - *((char *)v1 + 88) = 0; - LeaveCriticalSection(&pGame->pThreadWardInstance->cs3);*/ -} - -//----- (0046B14F) -------------------------------------------------------- -void AsyncMouse::Suspend() -{ - void *v1; // esi@1 - //Vis *v2; // eax@3 - std::string v3; // [sp-18h] [bp-24h]@2 - const char *v4; // [sp-8h] [bp-14h]@2 - int v5; // [sp-4h] [bp-10h]@2 - std::string *v6; // [sp+4h] [bp-8h]@2 - int a3; // [sp+Bh] [bp-1h]@2 - - v1 = this; - if ( *((int *)this + 33) ) - { - //v2 = pGame->pVisInstance; - if (pGame->pVisInstance) - pGame->pVisInstance->default_list.uNumPointers = 0; - - EnterCriticalSection(&pGame->pThreadWardInstance->cs3); - SuspendThread(*((HANDLE *)v1 + 4)); - _46B0ED(); - LeaveCriticalSection(&pGame->pThreadWardInstance->cs3); - } - else - { - MessageBoxW(nullptr, L"DI_Mouse pointer invalid; bailing out from suspend()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp:233", 0); - } -} -// 46B0ED: using guessed type int __thiscall AsyncMouse__46B0ED(int); - -//----- (0046B1DD) -------------------------------------------------------- -char AsyncMouse::_46B1DD() -{ - *((char *)this + 20) = 1; - Sleep(118); - return 1; -} - -//----- (0046B1EC) -------------------------------------------------------- -bool AsyncMouse::DrawCursor(Texture *a1, IDirectDrawSurface4 *a2, int a3) -{ - __debugbreak(); - /* - bool result; // eax@1 - unsigned __int16 *v5; // ebx@2 - unsigned __int8 *v6; // edx@2 - int v7; // esi@2 - int v8; // ecx@2 - LPVOID v9; // edi@2 - int v10; // ecx@5 - DDSURFACEDESC2 Dst; // [sp+0h] [bp-84h]@1 - __int32 v12; // [sp+7Ch] [bp-8h]@3 - int v13; // [sp+80h] [bp-4h]@3 - - Dst.dwSize = 124; - result = pRenderer->LockSurface_DDraw4(a2, &Dst, DDLOCK_WAIT); - if ( result ) - { - v5 = a1->pPalette16; - v6 = a1->pLevelOfDetail0_prolly_alpha_mask; - v7 = a1->uTextureWidth; - v8 = a1->uTextureHeight; - v9 = Dst.lpSurface; - if ( v8 > 0 ) - { - v12 = 2 * (Dst.lPitch / 2 - v7); - v13 = v8; - do - { - if ( v7 > 0 ) - { - v10 = v7; - do - { - if ( v5[*v6] ) - *(short *)v9 = v5[*v6]; - v9 = (char *)v9 + 2; - ++v6; - --v10; - } - while ( v10 ); - } - v9 = (char *)v9 + v12; - --v13; - } - while ( v13 ); - } - result = a2->Unlock( - v6, - a2, - a3); - } - LOBYTE(result) = 1; - return result;*/ - return 0; -} - -//----- (0046B289) -------------------------------------------------------- -bool AsyncMouse::_46B289(int a2, char a3) -{ - char v3; // dl@1 - bool result; // eax@33 - char v5; // [sp+2h] [bp-2h]@1 - char v6; // [sp+3h] [bp-1h]@1 - - v3 = *((char *)this + 93); - v6 = *((char *)this + 94); - v5 = *((char *)this + 95); - if ( a3 & 1 ) - { - *((char *)this + 93) = 1; - } - else - { - if ( v3 ) - *((char *)this + 99) = 1; - else - *((char *)this + 99) = 0; - *((char *)this + 93) = 0; - } - if ( a3 & 2 ) - { - *((char *)this + 94) = 1; - } - else - { - if ( v6 ) - *((char *)this + 100) = 1; - else - *((char *)this + 100) = 0; - *((char *)this + 94) = 0; - } - if ( a3 & 4 ) - { - *((char *)this + 95) = 1; - } - else - { - if ( v5 ) - *((char *)this + 101) = 1; - else - *((char *)this + 101) = 0; - *((char *)this + 95) = 0; - } - *((char *)this + 96) = v3 != *((char *)this + 93); - *((char *)this + 97) = v6 != *((char *)this + 94); - *((char *)this + 98) = v5 != *((char *)this + 95); - if ( *((char *)this + 99) && *((char *)this + 96) || *((char *)this + 100) && *((char *)this + 97) ) - *((char *)this + 102) = 1; - LOBYTE(result) = 1; - return result; -} - -//----- (0046B342) -------------------------------------------------------- -void AsyncMouse::SetHotspot(float hotspotx, float hotspoty) -{ - double v3; // ST00_8@1 - double v4; // ST00_8@1 - - v3 = hotspotx + 6.7553994e15; - *(int *)(this + 40) = LODWORD(v3); - v4 = hotspoty + 6.7553994e15; - *(int *)(this + 44) = LODWORD(v4); -} - -//----- (0046B37C) -------------------------------------------------------- -int AsyncMouse::UpdateData(int a2) -{ - __debugbreak(); - /* - void *v2; // edi@1 - int result; // eax@2 - int v4; // eax@3 - int v5; // esi@3 - std::string v6; // [sp-18h] [bp-28h]@2 - const char *v7; // [sp-8h] [bp-18h]@2 - int v8; // [sp-4h] [bp-14h]@2 - std::string *v9; // [sp+8h] [bp-8h]@2 - int a3; // [sp+Fh] [bp-1h]@2 - - v2 = this; - if ( *((int *)this + 33) ) - { - EnterCriticalSection(&pGame->pThreadWardInstance->cs3); - DirectInputMouse::_43BB89(*((DirectInputMouse **)v2 + 33)); - v4 = *((int *)v2 + 33); - v5 = v4 + 32; - _46B289(v4 + 32, *(int *)(v4 + 40)); - LeaveCriticalSection(&pGame->pThreadWardInstance->cs3); - result = a2; - *(int *)a2 = *(int *)v5; - *(int *)(a2 + 4) = *(int *)(v5 + 4); - } - else - { - MessageBoxW(nullptr, L"DI_Mouse pointer invalid bailing out from update_mouse_data()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp:446", 0); - result = a2; - *(int *)a2 = 0; - *(int *)(a2 + 4) = 0; - } - return result;*/ - return 0; -} - -//----- (0046B420) -------------------------------------------------------- -char AsyncMouse::Thread() -{ - void *v1; // esi@1 - char result; // al@2 - int v3; // eax@3 - int v4; // ecx@3 - int v5; // eax@3 - int v6; // ecx@3 - int v7; // [sp+4h] [bp-8h]@3 - int v8; // [sp+8h] [bp-4h]@3 - - v1 = this; - if ( *((char *)this + 20) ) - { - result = 0; - } - else - { - UpdateData((int)&v7); - _46BA8D(v7, v8); - _46B958(v7 - *((int *)v1 + 10), v8 - *((int *)v1 + 11)); - _46B492((int)&v7); - _46B5D5((int)&v7); - v3 = v7; - v4 = v8; - *((int *)v1 + 6) = v7; - v5 = v3 - *((int *)v1 + 10); - *((int *)v1 + 7) = v4; - v6 = v4 - *((int *)v1 + 11); - *((int *)v1 + 8) = v5; - result = 1; - *((int *)v1 + 9) = v6; - } - return result; -} - -//----- (0046B492) -------------------------------------------------------- -void AsyncMouse::_46B492(int a2) -{ - __debugbreak(); - /* - void *v2; // edi@1 - int v3; // esi@3 - int v4; // eax@5 - int v5; // ecx@5 - int v6; // eax@8 - int v7; // ecx@8 - int v8; // eax@11 - int v9; // esi@11 - int v10; // [sp+Ch] [bp-1Ch]@5 - int v11; // [sp+10h] [bp-18h]@5 - int v12; // [sp+14h] [bp-14h]@5 - int v13; // [sp+18h] [bp-10h]@5 - int v14; // [sp+24h] [bp-4h]@5 - - v2 = this; - EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); - if ( *((int *)v2 + 28) > 0x80u ) - _46BCAB((char *)v2 + 104); - v3 = a2; - if ( *((char *)v2 + 93) && *((char *)v2 + 96) ) - { - v4 = *(int *)a2; - v5 = *(int *)(a2 + 4); - v13 = 1; - v10 = 5080884; - v11 = v4; - v12 = v5; - v14 = 0; - AsyncMouse::unk_46BCD2((char *)v2 + 104, (int)&a2, *((int *)v2 + 27), (int)&v10); - v14 = -1; - } - if ( *((char *)v2 + 94) && *((char *)v2 + 97) ) - { - v6 = *(int *)v3; - v7 = *(int *)(v3 + 4); - v13 = 2; - v10 = 5080884; - v11 = v6; - v12 = v7; - v14 = 1; - AsyncMouse::unk_46BCD2((char *)v2 + 104, (int)&a2, *((int *)v2 + 27), (int)&v10); - v14 = -1; - } - if ( *((char *)v2 + 95) && *((char *)v2 + 98) ) - { - v8 = *(int *)v3; - v9 = *(int *)(v3 + 4); - v13 = 4; - v10 = 5080884; - v11 = v8; - v12 = v9; - v14 = 2; - AsyncMouse::unk_46BCD2((char *)v2 + 104, (int)&a2, *((int *)v2 + 27), (int)&v10); - } - LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);*/ -} - -//----- (0046B5D5) -------------------------------------------------------- -void AsyncMouse::_46B5D5(int a2) -{ - __debugbreak(); - /* - void *v2; // esi@1 - DWORD v3; // eax@3 - char v4; // zf@3 - int v5; // edi@3 - int v6; // eax@6 - int v7; // ecx@6 - int v8; // eax@11 - int v9; // ecx@11 - int v10; // eax@16 - int v11; // edi@16 - int (__stdcall **v12)(char); // [sp+Ch] [bp-20h]@6 - int v13; // [sp+10h] [bp-1Ch]@6 - int v14; // [sp+14h] [bp-18h]@6 - int v15; // [sp+18h] [bp-14h]@6 - DWORD v16; // [sp+1Ch] [bp-10h]@3 - int v17; // [sp+28h] [bp-4h]@6 - - v2 = this; - EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); - if ( *((int *)v2 + 31) > 0x80u ) - _46BCAB((char *)v2 + 116); - v3 = timeGetTime(); - v4 = *((char *)v2 + 93) == 0; - v5 = a2; - v16 = v3; - if ( !v4 && *((char *)v2 + 96) ) - { - if ( v3 - *((int *)v2 + 19) < 0xFA ) - { - v6 = *(int *)a2; - v7 = *(int *)(a2 + 4); - v15 = 1; - v12 = &AsyncMouse::unk::vdtor_ptr; - v13 = v6; - v14 = v7; - v17 = 0; - AsyncMouse::unk_46BCD2((char *)v2 + 116, (int)&a2, *((int *)v2 + 30), (int)&v12); - v17 = -1; - v3 = v16; - } - *((int *)v2 + 19) = v3; - } - if ( *((char *)v2 + 94) && *((char *)v2 + 97) ) - { - if ( v3 - *((int *)v2 + 20) < 0xFA ) - { - v8 = *(int *)v5; - v9 = *(int *)(v5 + 4); - v15 = 2; - //v12 = &AsyncMouse::unk::vdtor_ptr; - v13 = v8; - v14 = v9; - v17 = 1; - AsyncMouse::unk_46BCD2((char *)v2 + 116, (int)&a2, *((int *)v2 + 30), (int)&v12); - v17 = -1; - v3 = v16; - } - *((int *)v2 + 20) = v3; - } - if ( *((char *)v2 + 95) && *((char *)v2 + 98) ) - { - if ( v3 - *((int *)v2 + 21) < 0xFA ) - { - v10 = *(int *)v5; - v11 = *(int *)(v5 + 4); - v15 = 4; - //v12 = &AsyncMouse::unk::vdtor_ptr; - v13 = v10; - v14 = v11; - v17 = 2; - AsyncMouse::unk_46BCD2((char *)v2 + 116, (int)&a2, *((int *)v2 + 30), (int)&v12); - v3 = v16; - } - *((int *)v2 + 21) = v3; - } - LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);*/ -} - -//----- (0046B736) -------------------------------------------------------- -void AsyncMouse::_46B736_consume_click_lists(char a2) -{ - __debugbreak(); - /* - void *v2; // esi@1 - - v2 = this; - _46B76F(); - _46B879(); - if ( a2 ) - { - _46BCAB((char *)v2 + 104); - _46BCAB((char *)v2 + 116); - } - if ( *((char *)v2 + 102) ) - { - back_to_game(); - *((char *)v2 + 102) = 0; - }*/ -} - -//----- (0046B76F) -------------------------------------------------------- -void AsyncMouse::_46B76F() -{ - __debugbreak(); - /* - char *v0; // ebx@1 - int v1; // eax@1 - int v2; // edi@1 - int v3; // eax@2 - unsigned int *v4; // esi@2 - unsigned int v5; // ST08_4@7 - unsigned int v6; // ST04_4@7 - float v7; // ST00_4@7 - unsigned int v8; // ST08_4@9 - unsigned int v9; // ST04_4@9 - float v10; // ST00_4@9 - - EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); - v0 = (char *)pAsyncMouse + 108; - v1 = *((int *)pAsyncMouse + 27); - v2 = *(int *)v1; - if ( *(int *)v1 != v1 ) - { - do - { - v3 = *(int *)(v2 + 20); - v4 = (unsigned int *)(v2 + 12); - if ( v3 & 1 ) - { - pGame->PickMouse(512.0, *v4, *(int *)(v2 + 16), 0, &a3, &a4); - if ( GetCurrentMenuID() == 6 ) - UI_OnKeyDown(VK_SELECT); - UI_OnMouseLeftClick((int *)(v2 + 12)); - } - else - { - if ( v3 & 2 ) - { - v5 = *(int *)(v2 + 16); - v6 = *v4; - v7 = GetPickDepth(); - pGame->PickMouse(v7, v6, v5, 0, &stru_F93E30, &a5); - sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62((Vec2_int_ *)(v2 + 12)); - } - else - { - if ( v3 & 4 ) - { - v8 = *(int *)(v2 + 16); - v9 = *v4; - v10 = GetPickDepth(); - pGame->PickMouse(v10, v9, v8, 1, &a3, &a5); - } - } - } - v2 = *(int *)v2; - } - while ( v2 != *(int *)v0 ); - } - LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);*/ -} - -//----- (0046B879) -------------------------------------------------------- -void AsyncMouse::_46B879() -{ - __debugbreak(); - /* - char *v0; // ebx@1 - int v1; // eax@1 - int v2; // edi@1 - int v3; // eax@2 - unsigned int *v4; // esi@2 - unsigned int v5; // ST08_4@5 - unsigned int v6; // ST04_4@5 - float v7; // ST00_4@5 - - EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); - v0 = (char *)pAsyncMouse + 120; - v1 = *((int *)pAsyncMouse + 30); - v2 = *(int *)v1; - if ( *(int *)v1 != v1 ) - { - do - { - v3 = *(int *)(v2 + 20); - v4 = (unsigned int *)(v2 + 12); - if ( v3 & 1 ) - { - pGame->PickMouse(512.0, *v4, *(int *)(v2 + 16), 0, &a3, &a4); - sub_4178C4(); - } - else - { - if ( v3 & 2 ) - { - v5 = *(int *)(v2 + 16); - v6 = *v4; - v7 = GetPickDepth(); - pGame->PickMouse(v7, v6, v5, 0, &stru_F93E30, &a4); - sub_4178E1(); - } - else - { - if ( v3 & 4 ) - nullsub_1(); - } - } - v2 = *(int *)v2; - } - while ( v2 != *(int *)v0 ); - } - LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);*/ -} - -//----- (0046B944) -------------------------------------------------------- -int AsyncMouse::_46B944() -{ - __debugbreak(); - /* - void *v1; // esi@1 - - v1 = this; - _46BCAB((char *)this + 104); - return _46BCAB((char *)v1 + 116);*/ - return 0; -} -// 46BCAB: using guessed type int __thiscall AsyncMouse__46BCAB(int); - -//----- (0046B958) -------------------------------------------------------- -char AsyncMouse::_46B958(int a2, int a3) -{ - __debugbreak(); - /* - void *v3; // esi@1 - char result; // al@3 - int v5; // edx@6 - int v6; // eax@6 - int v7; // eax@12 - int v8; // edi@13 - int v9; // eax@19 - struct IDirectDrawSurface4 *v10; // ST08_4@21 - DDBLTFX v11; // [sp+4h] [bp-74h]@21 - RECT v12; // [sp+68h] [bp-10h]@19 - - v3 = this; - if ( pRenderer->pFrontBuffer4 && !pRenderer->pFrontBuffer4->IsLost() ) - { - EnterCriticalSection(&pGame->pThreadWardInstance->cs2); - if ( *((char *)v3 + 88) ) - pRenderer->pFrontBuffer4->BltFast( - *((int *)v3 + 8), - *((int *)v3 + 9), - (LPDIRECTDRAWSURFACE4)*((int *)v3 + 2), - (LPRECT)((char *)v3 + 48), - 16u); - v5 = 640 - a2; - v6 = 640 - a2; - if ( 640 - a2 >= 31 ) - v6 = 31; - if ( v6 >= 0 ) - { - if ( v5 >= 31 ) - v5 = 31; - } - else - { - v5 = 0; - } - v7 = 480 - a3; - if ( 480 - a3 >= 31 ) - v8 = 31; - else - v8 = 480 - a3; - if ( v8 >= 0 ) - { - if ( v7 >= 31 ) - v7 = 31; - } - else - { - v7 = 0; - } - *((int *)v3 + 13) = 0; - *((int *)v3 + 14) = v5; - v12.right = a2 + v5; - *((int *)v3 + 12) = 0; - *((int *)v3 + 15) = v7; - v12.left = a2; - v12.bottom = a3 + v7; - v9 = *((int *)v3 + 2); - v12.top = a3; - (*(void (__stdcall **)(int, int, int, IDirectDrawSurface4 *, RECT *, signed int))(*(int *)v9 + 28))( - v9, - 0, - 0, - pRenderer->pFrontBuffer4, - &v12, - 16); - if ( !*((char *)v3 + 90) || *((char *)v3 + 128) & 1 ) - { - v10 = (struct IDirectDrawSurface4 *)*((int *)v3 + 1); - v11.dwSize = 100; - v11.dwDDFX = 8; - pRenderer->pFrontBuffer4->Blt( - &v12, - v10, - (LPRECT)((char *)v3 + 48), - 16812032u, - &v11); - } - *((char *)v3 + 88) = 1; - LeaveCriticalSection(&pGame->pThreadWardInstance->cs2); - result = 1; - } - else - { - result = 0; - } - return result;*/ - return 0; -} - -//----- (0046BA8D) -------------------------------------------------------- -char AsyncMouse::_46BA8D(int a2, int a3) -{ - __debugbreak(); - /* - void *v3; // esi@1 - DWORD v4; // eax@1 - - v3 = this; - v4 = timeGetTime(); - if ( v4 - *((int *)v3 + 16) <= 0x32 ) - { - *((char *)v3 + 91) = *((char *)v3 + 90) == 1; - *((char *)v3 + 90) = 0; - } - else - { - if ( *((char *)v3 + 90) ) - *((char *)v3 + 91) = 0; - else - *((char *)v3 + 91) = 1; - *((char *)v3 + 90) = 1; - } - if ( a2 != *((int *)v3 + 17) || a3 != *((int *)v3 + 18) ) - { - *((int *)v3 + 16) = v4; - *((int *)v3 + 17) = a2; - *((int *)v3 + 18) = a3; - } - return *((char *)v3 + 90);*/ - return 0; -} - -//----- (0046BAEC) -------------------------------------------------------- -void AsyncMouse::_46BAEC() -{ - void *v1; // esi@1 - - v1 = this; - EnterCriticalSection(&pGame->pThreadWardInstance->cs2); - *((char *)v1 + 88) = 0; -} - -//----- (0046BB0A) -------------------------------------------------------- -void AsyncMouse::_46BB0A() -{ - __debugbreak(); - /* - void *v1; // esi@1 - int v2; // eax@1 - int v3; // edx@1 - int v4; // ecx@1 - int v5; // edx@1 - int v6; // eax@1 - char v7; // zf@1 - struct IDirectDrawSurface4 *v8; // ST08_4@8 - int v9; // [sp+8h] [bp-74h]@8 - int v10; // [sp+Ch] [bp-70h]@8 - int v11; // [sp+6Ch] [bp-10h]@1 - int v12; // [sp+70h] [bp-Ch]@1 - int v13; // [sp+74h] [bp-8h]@1 - int v14; // [sp+78h] [bp-4h]@1 - - v1 = this; - v2 = *((int *)this + 17) - *((int *)this + 10); - v3 = *((int *)this + 14); - v4 = *((int *)this + 18) - *((int *)this + 11); - v11 = v2; - v5 = v2 + v3; - v6 = *((int *)v1 + 15); - v12 = v4; - v7 = *((char *)v1 + 90) == 0; - v13 = v5; - v14 = v4 + v6; - if ( v7 || *((char *)v1 + 128) & 1 ) - { - if ( *((char *)v1 + 88) ) - pRenderer->pFrontBuffer4->BltFast( - *((int *)v1 + 8), - *((int *)v1 + 9), - (LPDIRECTDRAWSURFACE4)*((int *)v1 + 2), - (LPRECT)((char *)v1 + 48), - 16u); - (*(void (__stdcall **)(int, int, int, IDirectDrawSurface4 *, int *, signed int))(**((int **)v1 + 2) + 28))( - *((int *)v1 + 2), - 0, - 0, - pRenderer->pFrontBuffer4, - &v11, - 16); - } - if ( *((char *)v1 + 90) && !(*((char *)v1 + 128) & 1) ) - { - v8 = (struct IDirectDrawSurface4 *)*((int *)v1 + 1); - v9 = 100; - v10 = 8; - pRenderer->pFrontBuffer4->Blt( - (LPRECT)&v11, - v8, - (LPRECT)((char *)v1 + 48), - 16812032u, - (LPDDBLTFX)&v9); - } - LeaveCriticalSection(&pGame->pThreadWardInstance->cs2);*/ -} - -//----- (0046BBD0) -------------------------------------------------------- -void *AsyncMouse::Clip() -{ - __debugbreak(); - /* - void *result; // eax@1 - std::string v1; // [sp-18h] [bp-30h]@2 - const char *v2; // [sp-8h] [bp-20h]@2 - int v3; // [sp-4h] [bp-1Ch]@2 - RECT Rect; // [sp+0h] [bp-18h]@1 - std::string *v5; // [sp+10h] [bp-8h]@2 - int a3; // [sp+17h] [bp-1h]@2 - - SetWindowPos(hWnd, HWND_MESSAGE|0x2, 320, 240, 640, 480, 0); - Rect.left = 325; - Rect.top = 245; - Rect.right = 326; - Rect.bottom = 246; - result = (void *)ClipCursor(&Rect); - if ( !result ) - { - MessageBoxW(nullptr, L"Could not clip cursor to screen!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp:827", 0); - } - return result;*/ - return 0; -} - -//----- (0046BC4E) -------------------------------------------------------- -void __stdcall AsyncMouse::AsyncMouseThread(int a1) -{ - __debugbreak(); - /* - while ( 1 ) - { - while ( !pAsyncMouse ) - Sleep(1); - if ( !AsyncMouse::Thread(pAsyncMouse) ) - ExitThread(0); - Sleep(18); - }*/ -} - -//----- (0046BC73) -------------------------------------------------------- -void AsyncMouse::dtor_sub_46BC73() -{ - __debugbreak(); - /* - int v1; // edi@1 - void **v2; // ebx@1 - void *v3; // esi@1 - void *v4; // eax@2 - int v5; // [sp+0h] [bp-4h]@1 - - v5 = this; - v1 = this; - v2 = *(void ***)(this + 4); - v3 = *v2; - while ( v3 != v2 ) - { - v4 = v3; - v3 = *(void **)v3; - AsyncMouse::unk_46BD2D((void *)v1, (int)&v5, v4); - } - free(*(void **)(v1 + 4)); - *(int *)(v1 + 4) = 0; - *(int *)(v1 + 8) = 0;*/ -} - -//----- (0046BCAB) -------------------------------------------------------- -int AsyncMouse::_46BCAB() -{ - __debugbreak(); - /* - void *v1; // ebx@1 - void **v2; // edi@1 - void *v3; // esi@1 - void *v4; // eax@2 - int result; // eax@2 - int v6; // [sp+0h] [bp-4h]@1 - - v6 = this; - v1 = (void *)this; - v2 = *(void ***)(this + 4); - v3 = *v2; - while ( v3 != v2 ) - { - v4 = v3; - v3 = *(void **)v3; - result = AsyncMouse::unk_46BD2D(v1, (int)&v6, v4); - } - return result;*/ - return 0; -} -// 46BCAB: using guessed type int __thiscall AsyncMouse__46BCAB(int); - -//----- (0046BCD2) -------------------------------------------------------- -int AsyncMouse::unk_46BCD2(int a2, int a3, int a4) -{ - __debugbreak(); - /* - void *v4; // edi@1 - void *v5; // eax@1 - void *v6; // esi@1 - int result; // eax@1 - - v4 = this; - v5 = AsyncMouse::unk_46BD09((void *)a3, *(void **)(a3 + 4)); - v6 = v5; - *(int *)(a3 + 4) = v5; - **((int **)v5 + 1) = v5; - AsyncMouse::unk_46BD66((char *)v5 + 8, a4); - result = a2; - ++*((int *)v4 + 2); - *(int *)a2 = v6; - return result;*/ - return 0; -} -// 46BD66: using guessed type int __fastcall AsyncMouse__unk__46BD66(int, int); - -//----- (0046BD09) -------------------------------------------------------- -void *AsyncMouse::unk_46BD09(void *a1, void *a2) -{ - __debugbreak(); - /* - void *result; // eax@1 - void *v3; // ecx@1 - void *v4; // ecx@3 - - result = operator new(0x18u); - v3 = a1; - if ( !a1 ) - v3 = result; - *(int *)result = v3; - v4 = a2; - if ( !a2 ) - v4 = result; - *((int *)result + 1) = v4; - return result;*/ - return 0; -} - -//----- (0046BD2D) -------------------------------------------------------- -int AsyncMouse::unk_46BD2D(int a2, void *a3) -{ - __debugbreak(); - /* - void *v3; // edi@1 - int v4; // ebx@1 - int result; // eax@1 - - v3 = this; - v4 = *(int *)a3; - **((int **)a3 + 1) = *(int *)a3; - *(int *)(*(int *)a3 + 4) = *((int *)a3 + 1); - (**((void (__stdcall ***)(int))a3 + 2))(0); - free(a3); - result = a2; - --*((int *)v3 + 2); - *(int *)a2 = v4; - return result;*/ - return 0; -} - -//----- (0046BD66) -------------------------------------------------------- -int AsyncMouse::unk_46BD66(int a1, int a2) -{ - int result; // eax@2 - - if ( a1 ) - { - *(int *)(a1 + 4) = *(int *)(a2 + 4); - *(int *)(a1 + 8) = *(int *)(a2 + 8); - result = *(int *)(a2 + 12); - *(int *)(a1 + 12) = result; - //*(int *)a1 = &AsyncMouse::unk::vdtor_ptr; - } - return result; -} -// 46BD66: using guessed type int __fastcall AsyncMouse__unk__46BD66(int, int); -// 4D8734: using guessed type int (__stdcall *AsyncMouse__unk__vdtor_ptr)(char); - - - - - - - - - - - - - - - - - - - -/* -//----- (0043B9FF) -------------------------------------------------------- -DirectInputMouse *__thiscall DirectInputMouse::DirectInputMouse(DirectInputMouse *this) -{ - DirectInputMouse *v1; // esi@1 - HRESULT v2; // eax@5 - signed int v4; // [sp-18h] [bp-24h]@3 - char *v5; // [sp-14h] [bp-20h]@3 - int v6; // [sp-10h] [bp-1Ch]@3 - const char *v7; // [sp-Ch] [bp-18h]@3 - int v8; // [sp-8h] [bp-14h]@3 - unsigned int v9; // [sp-4h] [bp-10h]@3 - CheckHRESULT_stru0 v10; // [sp+8h] [bp-4h]@5 - - v1 = this; - this->field_8 = 0; - LOBYTE(this->field_1C) = 0; - this->field_28 = 0; - this->vdestructor_ptr = (int)&DirectInputMouse_pvdtor; - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) - { - v9 = 1; - v8 = 30; - v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp"; - v6 = 0; - v5 = (char *)&this->pDirectInput; - v4 = 1280; - } - else - { - v9 = 1; - v8 = 28; - v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp"; - v6 = 0; - v5 = (char *)&this->pDirectInput; - v4 = 768; - } - v2 = DirectInputCreateA(hInstance, v4, v5, v6); - CheckHRESULT(&v10, v2, v7, v8, v9); - DirectInputMouse::CreateDevice(v1); - DirectInputMouse::43BB18(v1); - v1->field_20 = 0; - v1->field_24 = 0; - return v1; -} -// 4C8880: using guessed type int __stdcall DirectInputCreateA(int, int, int, int); -// 4D8608: using guessed type int (__stdcall *DirectInputMouse_pvdtor)(char); - -//----- (0043BA80) -------------------------------------------------------- -void *__thiscall DirectInputMouse::vdtor(void *this, bool a2) -{ - void *v2; // esi@1 - - v2 = this; - DirectInputMouse::dtor(this); - if ( a2 & 1 ) - free(v2); - return v2; -} - -//----- (0043BA9C) -------------------------------------------------------- -int __thiscall DirectInputMouse::dtor(void *this) -{ - void *v1; // esi@1 - int v2; // eax@1 - int result; // eax@3 - - v1 = this; - v2 = *((int *)this + 2); - *(int *)this = &DirectInputMouse_pvdtor; - if ( v2 ) - { - (*(void (__stdcall **)(int))(*(int *)v2 + 32))(v2); - (*(void (__stdcall **)(int))(**((int **)v1 + 2) + 8))(*((int *)v1 + 2)); - *((int *)v1 + 2) = 0; - } - result = (*(int (__stdcall **)(int))(**((int **)v1 + 1) + 8))(*((int *)v1 + 1)); - *((int *)v1 + 1) = 0; - return result; -} -// 4D8608: using guessed type int (__stdcall *DirectInputMouse_pvdtor)(char); - -//----- (0043BACE) -------------------------------------------------------- -void __thiscall DirectInputMouse::CreateDevice(DirectInputMouse *this) -{ - DirectInputMouse *v1; // esi@1 - HRESULT v2; // eax@1 - CheckHRESULT_stru0 v3; // [sp+4h] [bp-4h]@1 - - v1 = this; - v2 = ((int (__stdcall *)(int, int, int, int, int))this->pDirectInput->lpVtbl->field_10)( - this->pDirectInput, - 2, - DirectInputMouse_enumerator, - this, - 1); - CheckHRESULT(&v3, v2, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp", 57, 1u); - if ( !LOBYTE(v1->field_1C) ) - { - v3.vdestructor_ptr = (void (__thiscall ***)(CheckHRESULT_stru0 *, bool))"Error: No mouse found"; - _CxxThrowException((int)&v3, (int)&dword_4DBD94); - } -} -// 43BC61: using guessed type int __stdcall DirectInputMouse_enumerator(int, int); -// 4DBD94: using guessed type int dword_4DBD94; - -//----- (0043BB18) -------------------------------------------------------- -int __thiscall DirectInputMouse::43BB18(DirectInputMouse *this) -{ - char *v1; // esi@1 - HRESULT v2; // eax@1 - HRESULT v3; // eax@1 - HRESULT v4; // eax@1 - unsigned int v6; // [sp+0h] [bp-Ch]@0 - CheckHRESULT_stru0 v7; // [sp+8h] [bp-4h]@1 - - v1 = (char *)&this->field_8; - v2 = ((int (__stdcall *)(int, int, int, int, int))this->pDirectInput->lpVtbl->field_C)( - this->pDirectInput, - &this->field_C, - &this->field_8, - 0, - "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp"); - CheckHRESULT(&v7, v2, (const char *)0x40, 1, v6); - v3 = (*(int (__stdcall **)(int, int))(**(int **)v1 + 44))(*(int *)v1, dword_4C9920); - CheckHRESULT(&v7, v3, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp", 65, 1u); - v4 = (*(int (__stdcall **)(int, int, int))(**(int **)v1 + 52))(*(int *)v1, hWnd, 6); - CheckHRESULT(&v7, v4, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp", 66, 1u); - return (*(int (__cdecl **)(int))(**(int **)v1 + 28))(*(int *)v1); -} -// 4C9920: using guessed type int dword_4C9920[16]; - -//----- (0043BB89) -------------------------------------------------------- -bool __thiscall DirectInputMouse::43BB89(DirectInputMouse *this) -{ - DirectInputMouse *v1; // esi@1 - bool result; // eax@1 - HRESULT v3; // eax@5 - __int32 v4; // ecx@6 - __int32 v5; // eax@6 - __int32 v6; // edx@6 - int v7; // ecx@12 - bool v8; // ecx@12 - signed int v9; // edx@12 - HRESULT a2; // [sp+4h] [bp-14h]@3 - int v11; // [sp+8h] [bp-10h]@12 - char v12; // [sp+10h] [bp-8h]@18 - char v13; // [sp+11h] [bp-7h]@20 - char v14; // [sp+12h] [bp-6h]@22 - char v15; // [sp+13h] [bp-5h]@24 - char v18; // [sp+14h] [bp-4h]@5 - - v1 = this; - result = this->field_8; - if ( result ) - { - if ( (*(int (__stdcall **)(bool, signed int, HRESULT *))(*(int *)result + 36))(result, 16, &a2) == -2147024866 - && !(*(int (__stdcall **)(int))(*(int *)v1->field_8 + 28))(v1->field_8) ) - { - v3 = (*(int (__stdcall **)(int, signed int, HRESULT *))(*(int *)v1->field_8 + 36))(v1->field_8, 16, &a2); - CheckHRESULT((CheckHRESULT_stru0 *)&v18, v3, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp", 80, 1u); - } - v4 = v1->field_20 + a2; - v5 = 640; - v6 = v1->field_20 + a2; - if ( v4 >= 640 ) - v6 = 640; - if ( v6 >= 0 ) - { - if ( v4 < 640 ) - v5 = v1->field_20 + a2; - } - else - { - v5 = 0; - } - v7 = v11; - v1->field_20 = v5; - v8 = v1->field_24 + v7; - result = 480; - v9 = v8; - if ( v8 >= 480 ) - v9 = 480; - if ( v9 >= 0 ) - { - if ( v8 < 480 ) - result = v8; - } - else - { - result = 0; - } - v1->field_28 = 0; - v1->field_24 = result; - if ( v12 & 0x80 ) - v1->field_28 = 1; - if ( v13 & 0x80 ) - v1->field_28 |= 2u; - if ( v14 & 0x80 ) - v1->field_28 |= 4u; - if ( v15 & 0x80 ) - v1->field_28 |= 8u; - LOBYTE(result) = 1; - } - else - { - LOBYTE(result) = 0; - } - return result; -} - -//----- (0043BC61) -------------------------------------------------------- -signed int __stdcall DirectInputMouse_enumerator(int a1, int a2) -{ - signed int result; // eax@2 - - if ( *(char *)(a1 + 36) & 2 ) - { - *(int *)(a2 + 12) = *(int *)(a1 + 4); - *(int *)(a2 + 16) = *(int *)(a1 + 8); - *(int *)(a2 + 20) = *(int *)(a1 + 12); - *(int *)(a2 + 24) = *(int *)(a1 + 16); - *(char *)(a2 + 28) = 1; - result = 0; - } - else - { - result = 1; - } - return result; -} -// 43BC61: using guessed type int __stdcall DirectInputMouse_enumerator(int, int); -*/ \ No newline at end of file
--- a/Mouse.h Wed May 22 22:26:31 2013 +0400 +++ b/Mouse.h Thu May 23 03:32:36 2013 +0200 @@ -135,53 +135,7 @@ #pragma pack(pop) -#pragma pack(push, 1) -struct AsyncMouse -{ - AsyncMouse(struct IDirectDrawSurface *); - ~AsyncMouse(); - - char Initialize(LPVOID lpParameter); - char LoadCursor(const char *pContainer); - char LoadCursorImage(); - char _46B072(); - char CreateDisrectInputMouse(); - int _46B0ED(); - void Resume(); - void Suspend(); - char _46B1DD(); - bool DrawCursor(struct Texture *a1, struct IDirectDrawSurface4 *a2, int a3); - bool _46B289(int a2, char a3); - void SetHotspot(float hotspotx, float hotspoty); - int UpdateData(int a2); - char Thread(); - void _46B492(int a2); - void _46B5D5(int a2); - void _46B736_consume_click_lists(char a2); - void _46B76F(); - void _46B879(); - int _46B944(); - char _46B958(int a2, int a3); - char _46BA8D(int a2, int a3); - void _46BAEC(); - void _46BB0A(); - void *Clip(); - void dtor_sub_46BC73(); - int _46BCAB(); - int unk_46BCD2(int a2, int a3, int a4); - void *unk_46BD09(void *a1, void *a2); - int unk_46BD2D(int a2, void *a3); - int unk_46BD66(int a1, int a2); - - static void __stdcall AsyncMouseThread(int a1); - - void _409E3D(char a2); - void Release(); -}; -#pragma pack(pop) - -extern Mouse *pMouse; -extern AsyncMouse *pAsyncMouse; \ No newline at end of file +extern Mouse *pMouse; \ No newline at end of file
--- a/OSAPI.cpp Wed May 22 22:26:31 2013 +0400 +++ b/OSAPI.cpp Thu May 23 03:32:36 2013 +0200 @@ -6,6 +6,7 @@ OSVersion *pVersion = nullptr; + //----- (00462C94) -------------------------------------------------------- int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE, wchar_t *lpCmdLine, int nShowCmd) {
--- a/Render.cpp Wed May 22 22:26:31 2013 +0400 +++ b/Render.cpp Thu May 23 03:32:36 2013 +0200 @@ -5549,11 +5549,7 @@ { if ( v1->field_40110 ) { - if (pAsyncMouse) - pAsyncMouse->_46BAEC(); pRenderD3D->Present(false); - if (pAsyncMouse) - pAsyncMouse->_46BB0A(); } } else @@ -6518,8 +6514,6 @@ result = pSurface->Lock(0, pDesc, uLockFlags, 0); if ( result == DDERR_SURFACELOST ) { - if (pAsyncMouse) - pAsyncMouse->Suspend(); v6 = v4->Restore(); if ( v6 ) { @@ -6548,8 +6542,6 @@ if ( pRenderer->pRenderD3D ) pRenderD3D->HandleLostResources(); result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); - if (pAsyncMouse) - pAsyncMouse->Resume(); } else { @@ -10923,10 +10915,6 @@ BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; else pMiscTimer->Resume(); - pAsyncMouse->Release(); - CreateAsyncMouse(); - if (pAsyncMouse) - pAsyncMouse->Clip(); } } // 6BE364: using guessed type int dword_6BE364_game_settings_1;
--- a/UIBooks.cpp Wed May 22 22:26:31 2013 +0400 +++ b/UIBooks.cpp Thu May 23 03:32:36 2013 +0200 @@ -27,6 +27,151 @@ +//----- (00411150) -------------------------------------------------------- +void BookUI_DrawTownPortalMap() +{ + //signed int v0; // edi@1 + //__int16 v1; // dx@8 + //POINT *v2; // edi@17 + int v3; // edi@17 + //__int16 v4; // dx@24 + GUIWindow v6; // [sp+Ch] [bp-64h]@1 + //POINT v7; // [sp+60h] [bp-10h]@17 + POINT a2; // [sp+68h] [bp-8h]@17 + + pRenderer->ClearZBuffer(0, 479); + pRenderer->DrawTextureTransparent(8, 8, pTexture_CurrentBook); + pRenderer->DrawTextureTransparent(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); + + v6.uFrameX = game_viewport_x; + v6.uFrameY = game_viewport_y; + v6.uFrameWidth = game_viewport_width; + v6.uFrameHeight = game_viewport_height; + v6.uFrameZ = game_viewport_z; + v6.uFrameW = game_viewport_w; + + const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE, + PARTY_QUEST_FOUNTAIN_PIERPONT, + PARTY_QUEST_FOUNTAIN_NIGHON, + PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE, + PARTY_QUEST_FOUNTAIN_CELESTIA, + PARTY_QUEST_FOUNTAIN_THE_PIT}; + for (uint i = 0; i < 6; ++i) + { + + if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i])) + pRenderer->DrawMaskToZBuffer(pTownPortalBook_xs[i], + pTownPortalBook_ys[i], + pTexture_TownPortalIcons[i], i + 1); + } + +/* v0 = 0; + do + { + if ( !v0 ) + { + v1 = 206; +LABEL_14: + if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v1) ) + goto LABEL_16; + goto LABEL_15; + } + if ( v0 == 1 ) + { + v1 = 208; + goto LABEL_14; + } + if ( v0 == 2 ) + { + v1 = 207; + goto LABEL_14; + } + if ( v0 == 3 ) + { + v1 = 211; + goto LABEL_14; + } + if ( v0 == 4 ) + { + v1 = 209; + goto LABEL_14; + } + if ( v0 == 5 ) + { + v1 = 210; + goto LABEL_14; + } +LABEL_15: + pRenderer->DrawMaskToZBuffer( + pTownPortalBook_xs[v0], + pTownPortalBook_ys[v0], + *(&pTexture_TownPortalHarmn + v0), + v0 + 1); +LABEL_16: + ++v0; + } + while ( v0 < 6 );*/ + + pMouse->GetCursorPos(&a2); + //v2 = pMouse->GetCursorPos(&a2); + v3 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF; + + if (v3) + { + if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1])) + pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]); + } + v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); + + +/* if ( !v3 ) // Town Portal + { + v6.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3); // "Town Portal" + return; + } + if ( v3 == 1 ) + { + v4 = 206; +LABEL_30: + if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) ) + goto LABEL_31; + v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); // "Town Portal" + return; + } + if ( v3 == 2 ) + { + v4 = 208; + goto LABEL_30; + } + if ( v3 == 3 ) + { + v4 = 207; + goto LABEL_30; + } + if ( v3 == 4 ) + { + v4 = 211; + goto LABEL_30; + } + if ( v3 == 5 ) + { + v4 = 209; + goto LABEL_30; + } + if ( v3 == 6 ) + { + v4 = 210; + goto LABEL_30; + } +LABEL_31: + pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3)); + v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);*/ +} +// 4E1D3A: using guessed type __int16 word_4E1D3A[]; + + + + //----- (00413CC6) -------------------------------------------------------- void BookUI_Draw(WindowType book) { @@ -40,7 +185,7 @@ case WINDOW_JournalBook: BookUI_Journal_Draw(); break; case WINDOW_LloydsBeacon: DrawLloydBeaconsScreen(); break; - case WINDOW_TownPortal: DrawTownPortalScreen(); break; + case WINDOW_TownPortal: BookUI_DrawTownPortalMap(); break; } }
--- a/UIHouses.cpp Wed May 22 22:26:31 2013 +0400 +++ b/UIHouses.cpp Thu May 23 03:32:36 2013 +0200 @@ -476,7 +476,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; viewparams->bRedrawGameUI = 1; uDialogueType = 0; - pKeyActionMap->_459ED1(3); + pKeyActionMap->SetWindowInputStatus(3); pKeyActionMap->ResetKeys(); if (uHouseID == HOUSE_600 || uHouseID == HOUSE_601) { @@ -2121,9 +2121,9 @@ case HOUSE_DIALOGUE_TOWNHALL_100: { v0 = window_SpeakInHouse; - if ( window_SpeakInHouse->field_40 == 1 ) + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) { - sprintf(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay" "How Much?" + sprintfex(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay" "How Much?" _this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf, 3u); _this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3); v3 = pFontArrus; @@ -2131,7 +2131,7 @@ _this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3); return; } - if ( window_SpeakInHouse->field_40 == 2 ) + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) { v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); v2 = v1; @@ -2155,9 +2155,9 @@ pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); v0 = window_SpeakInHouse; } - if ( window_SpeakInHouse->field_40 == 3 ) + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED) { - v0->field_40 = 0; + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); } break; @@ -2176,7 +2176,7 @@ void __cdecl BankDialog() { GUIWindow *v0; // eax@4 - int v1; // ecx@5 + //int v1; // ecx@5 int v2; // eax@6 unsigned int v3; // esi@6 GUIFont *v4; // ST10_4@12 @@ -2216,24 +2216,15 @@ case HOUSE_DIALOGUE_BANK_7: { v0 = window_SpeakInHouse; - if ( window_SpeakInHouse->field_40 != 1 ) + if ( window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS) { - v1 = window_SpeakInHouse->field_40 - 2; - if ( window_SpeakInHouse->field_40 == 2 ) + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) { v6 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); v7 = v6; if ( !v6 ) { -//LABEL_17: pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ return; } if ( v6 > pParty->uNumGold ) @@ -2249,13 +2240,13 @@ pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); } v0 = window_SpeakInHouse; - v0->field_40 = 0; + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); return; } - if ( v1 != 1 ) + if (window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED) return; - v0->field_40 = 0; + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); return; } @@ -2273,12 +2264,11 @@ case HOUSE_DIALOGUE_BANK_8: { v0 = window_SpeakInHouse; - if ( window_SpeakInHouse->field_40 != 1 ) + if ( window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS) { - v1 = window_SpeakInHouse->field_40 - 2; - if ( window_SpeakInHouse->field_40 == 2 ) + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) { - window_SpeakInHouse->field_40 = 0; + window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE; v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); v3 = v2; if ( v2 ) @@ -2294,18 +2284,19 @@ pParty->uNumGoldInBank -= v3; } } + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); return; } - if ( v1 != 1 ) + if ( window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED) return; - v0->field_40 = 0; + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); return; } v11 = pGlobalTXT_LocalizationStrings[112]; v10 = pGlobalTXT_LocalizationStrings[244]; - sprintf(pTmpBuf, "%s\n%s", v10, v11); + sprintfex(pTmpBuf, "%s\n%s", v10, v11); _this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf, 3u); _this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u); v4 = pFontArrus;
--- a/UIMainMenu.cpp Wed May 22 22:26:31 2013 +0400 +++ b/UIMainMenu.cpp Thu May 23 03:32:36 2013 +0200 @@ -359,8 +359,6 @@ } else { - if (pAsyncMouse) - pAsyncMouse->_46B736_consume_click_lists(1); pRenderer->BeginScene(); pRenderer->DrawTextureRGB(0, 0, &pTexture); pRenderer->SetTextureClipRect(pX, pY, pX + v20, pY + a4);
--- a/UIOptions.cpp Wed May 22 22:26:31 2013 +0400 +++ b/UIOptions.cpp Thu May 23 03:32:36 2013 +0200 @@ -89,7 +89,7 @@ signed int v4; // ecx@7 signed int v5; // eax@8 - if ( pGUIWindow_CurrentMenu->field_40 == 2 ) + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) { pPrevVirtualCidesMapping[uGameMenuUI_CurentlySelectedKeyIdx] = pKeyActionMap->pPressedKeysBuffer[0]; memset(GameMenuUI_InvaligKeyBindingsFlags, 0, sizeof(GameMenuUI_InvaligKeyBindingsFlags)); @@ -111,7 +111,7 @@ } while ( v4 < 28 ); uGameMenuUI_CurentlySelectedKeyIdx = -1; - pGUIWindow_CurrentMenu->field_40 = 0; + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; } pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Optkb[0])); if ( KeyboardPageNum == 1 )
--- a/UIPartyCreation.cpp Wed May 22 22:26:31 2013 +0400 +++ b/UIPartyCreation.cpp Thu May 23 03:32:36 2013 +0200 @@ -257,16 +257,16 @@ pGUIWindow_CurrentMenu->DrawText(pFontCreate, pIntervalX + 73, 100, 0, pClassNames[player->classType], 0, 0, 0); pRenderer->DrawTextureTransparent(pIntervalX + 77, 50, pTexture_IC_KNIGHT[player->classType / 4]); - if ( pGUIWindow_CurrentMenu->field_40 && pGUIWindow_CurrentMenu->ptr_1C == (void *)i ) + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 != WINDOW_INPUT_NONE && pGUIWindow_CurrentMenu->ptr_1C == (void *)i ) { - switch ( pGUIWindow_CurrentMenu->field_40 ) + switch ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 ) { - case 1://press name panel + case WINDOW_INPUT_IN_PROGRESS://press name panel v17 = pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, 159 * (int)pGUIWindow_CurrentMenu->ptr_1C + 18, 124, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 120, 1); pGUIWindow_CurrentMenu->DrawFlashingInputCursor(159 * (unsigned int)pGUIWindow_CurrentMenu->ptr_1C + v17 + 20, 124, pFontCreate); break; - case 2: // press enter - pGUIWindow_CurrentMenu->field_40 = 0; + case WINDOW_INPUT_CONFIRMED: // press enter + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; v120 = strlen((const char *)pKeyActionMap->pPressedKeysBuffer); v126 = 0; v133 = 0; @@ -286,8 +286,8 @@ pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pIntervalX, 124, 0, player->pName, 130, 0); *(short *)&player->field_1988[27] = 1; break; - case 3: // press escape - pGUIWindow_CurrentMenu->field_40 = 0; + case WINDOW_INPUT_CANCELLED: // press escape + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pIntervalX, 124, 0, player->pName, 130, 0); SetCurrentMenuID(MENU_NAMEPANELESC); break; @@ -708,16 +708,13 @@ v26 = 0; pTexture_PCX.Release(); pTexture_PCX.Load("makeme.pcx", 0); - if (pAsyncMouse) - pAsyncMouse->Resume(); + v2 = 6; - pGUIWindow_CurrentMenu->field_40 = 0; + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; //LABEL_27: SetCurrentMenuID((MENU_STATE)v2); while ( GetCurrentMenuID() == MENU_CREATEPARTY ) { - if (pAsyncMouse) - pAsyncMouse->_46B736_consume_click_lists(1); uMouseX = pMouse->GetCursorPos(&v25)->x; uMouseY = pMouse->GetCursorPos(&v25)->y; pControlsHead = pGUIWindow_CurrentMenu->pControlsHead; @@ -911,7 +908,5 @@ } pAudioPlayer->StopChannels(-1, -1); - if (pAsyncMouse) - pAsyncMouse->Suspend(); return v26; } \ No newline at end of file
--- a/UISaveLoad.cpp Wed May 22 22:26:31 2013 +0400 +++ b/UISaveLoad.cpp Thu May 23 03:32:36 2013 +0200 @@ -180,23 +180,16 @@ pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pTmpBuf, 3u); v1 = 255; } - if ( pGUIWindow_CurrentMenu->field_40 == 2 ) + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) { - pGUIWindow_CurrentMenu->field_40 = 0; + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; strcpy((char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot, (const char *)pKeyActionMap->pPressedKeysBuffer); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_SaveGame; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0); } else { - if ( pGUIWindow_CurrentMenu->field_40 == 3 ) - pGUIWindow_CurrentMenu->field_40 = 0; + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED) + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; } if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) { @@ -225,7 +218,7 @@ break; short clr; HIDWORD(pAMPM2) = clr = (pFilesID == uLoadGameUI_SelectedSlot ? TargetColor(v1, v1, 0x64) : 0); - if ( pGUIWindow_CurrentMenu->field_40 != 1 || pFilesID != uLoadGameUI_SelectedSlot ) + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS || pFilesID != uLoadGameUI_SelectedSlot ) { pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1B, a4, clr, pSlotName, 185, 0); }
--- a/UiGame.cpp Wed May 22 22:26:31 2013 +0400 +++ b/UiGame.cpp Thu May 23 03:32:36 2013 +0200 @@ -70,6 +70,257 @@ +//----- (00421D00) -------------------------------------------------------- +void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID) +{ + //unsigned int v1; // esi@1 + //int v2; // eax@2 + //Player *v3; // ecx@2 + //Player *v4; // ecx@5 + unsigned int v5; // [sp-4h] [bp-10h]@21 + + //v1 = uPlayerID; + auto player = &pParty->pPlayers[uPlayerID - 1]; + if (pParty->pPickedItem.uItemID) + { + //v3 = player; + if (auto slot = player->AddItem(-1, pParty->pPickedItem.uItemID)) + { + memcpy(&player->pInventoryItems[slot-1], &pParty->pPickedItem, 0x24u); + viewparams->bRedrawGameUI = true; + pMouse->RemoveHoldingItem(); + return; + } + + if (!player->CanAct()) + { + player = pPlayers[uActiveCharacter]; + } + if(player->CanAct() || !pPlayers[uActiveCharacter]->CanAct()) + player->PlaySound(SPEECH_NoRoom, 0); + } + +//LABEL_9: + if (pCurrentScreen == SCREEN_GAME) + { + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter != uPlayerID ) + //goto LABEL_27; + { + if ( pPlayers[uPlayerID]->uTimeToRecovery ) + return; + + uActiveCharacter = uPlayerID; + return; + } + v5 = 7; +//LABEL_22: + pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5); + return; + } + if ( pCurrentScreen == SCREEN_SPELL_BOOK ) + return; + if ( pCurrentScreen == SCREEN_CHEST ) + { +//LABEL_23: + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter == uPlayerID ) + { + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + pCurrentScreen = SCREEN_CHEST_INVENTORY; + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + } +//LABEL_27: + if ( pPlayers[uPlayerID]->uTimeToRecovery ) + return; + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + } + if ( pCurrentScreen != SCREEN_HOUSE ) + { + if ( pCurrentScreen == SCREEN_E ) + { +//LABEL_28: + uActiveCharacter = uPlayerID; + return; + } + if ( pCurrentScreen != SCREEN_CHEST_INVENTORY ) + { + viewparams->bRedrawGameUI = true; + uActiveCharacter = uPlayerID; + if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 102 ) + FillAwardsData(); + return; + } + //goto LABEL_23; + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter == uPlayerID ) + { + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + pCurrentScreen = SCREEN_CHEST_INVENTORY; + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + } +//LABEL_27: + if ( pPlayers[uPlayerID]->uTimeToRecovery ) + return; + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + } + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + return; + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter != uPlayerID ) + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + if (dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_6) + { + __debugbreak(); // fix indexing + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + v5 = 14; + //goto LABEL_22; + pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5); + return; + } +} +// 4E28F8: using guessed type int pCurrentScreen; +// F8B19C: using guessed type int dword_F8B19C; + +//----- (00416B01) -------------------------------------------------------- +void GameUI_DrawNPCPopup(void *_this)//PopupWindowForBenefitAndJoinText +{ + int v1; // edi@2 + int v2; // ecx@2 + NPCData *v3; // eax@2 + NPCData *v4; // esi@7 + NPCData *v5; // eax@16 + NPCData *v6; // esi@16 + const CHAR *v7; // eax@18 + unsigned int v8; // eax@25 + unsigned int v9; // eax@25 + const char *v10; // ST14_4@26 + char *v11; // esi@26 + const char *v12; // ST18_4@27 + unsigned __int16 v13; // ax@28 + char *v14; // eax@28 + GUIWindow a1; // [sp+Ch] [bp-60h]@23 + int a2; // [sp+60h] [bp-Ch]@16 + void *v17; // [sp+64h] [bp-8h]@1 + LPCSTR lpsz; // [sp+68h] [bp-4h]@6 + + v17 = _this; + if ( bNoNPCHiring != 1 ) + { + v1 = 0; + v2 = 0; + v3 = pParty->pHirelings; + /*do + { + if ( v3->pName ) + pTmpBuf[v1++] = v2; + ++v3; + ++v2; + } + while ( (signed int)v3 < (signed int)&pParty->pPickedItem );*/ + for (int i = 0; i < 2; ++i) + { + if (pParty->pHirelings[i].pName) + pTmpBuf[v1++] = i; + } + lpsz = 0; + if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) + { + /*v4 = pNPCStats->pNewNPCData; + do + { + if ( v4->uFlags & 0x80 + && (!pParty->pHirelings[0].pName || strcmp(v4->pName, pParty->pHirelings[0].pName)) + && (!pParty->pHirelings[1].pName || strcmp(v4->pName, pParty->pHirelings[1].pName)) ) + pTmpBuf[v1++] = (char)lpsz + 2; + ++lpsz; + ++v4; + } + while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );*/ + for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i) + { + if (pNPCStats->pNewNPCData[i].Hired()) + { + if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName)) + { + if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName)) + pTmpBuf[v1++] = i + 2; + } + } + } + } + if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 ) + { + sDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17; + v5 = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int)&a2); + v6 = v5; + if ( v5 ) + { + if ( a2 == 57 ) + v7 = pNPCTopics[512].pText; // Baby dragon + else + v7 = (const CHAR *)pNPCStats->pProfessions[v5->uProfession].pBenefits; + lpsz = v7; + if ( !v7 ) + { + lpsz = (LPCSTR)pNPCStats->pProfessions[v5->uProfession].pJoinText; + if ( !lpsz ) + lpsz = ""; + } + a1.Hint = 0; + a1.uFrameX = 38; + a1.uFrameY = 60; + a1.uFrameWidth = 276; + a1.uFrameZ = 313; + a1.uFrameHeight = pFontArrus->CalcTextHeight(lpsz, &a1, 0, 0) + + 2 * LOBYTE(pFontArrus->uFontHeight) + + 24; + if ( (signed int)a1.uFrameHeight < 130 ) + a1.uFrameHeight = 130; + a1.uFrameWidth = 400; + a1.uFrameZ = a1.uFrameX + 399; + a1.DrawMessageBox(0); + sprintfex(pTmpBuf2, "NPC%03d", v6->uPortraitID); + v8 = pIcons_LOD->LoadTexture(pTmpBuf2, TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed( + a1.uFrameX + 22, + a1.uFrameY + 36, + (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0)); + v9 = v6->uProfession; + if ( v9 ) + { + v10 = v6->pName; + v11 = pTmpBuf; + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]); + } + else + { + v12 = v6->pName; + v11 = pTmpBuf; + strcpy(pTmpBuf, v12); + } + v13 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u); + a1.uFrameWidth -= 24; + a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; + v14 = BuilDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); + a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0); + } + } + } +} + + //----- (00445D4A) -------------------------------------------------------- void GameUI_InitializeDialogue(Actor *actor, int bPlayerSaysHello) @@ -559,19 +810,19 @@ v2 = FitTextInAWindow(byte_5B0938, pFont, &v5, 0xCu, 0); pGUIWindow2->DrawText(pFont, 12, 354 - v1, 0, v2, 0, 0, 0); pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar); - if ( pGUIWindow2->field_40 != 1 ) + if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS) { - if ( pGUIWindow2->field_40 == 2 ) + if ( pGUIWindow2->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) { - pGUIWindow2->field_40 = 0; + pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE; strcpy(GameUI_Footer_TimedString, (const char *)pKeyActionMap->pPressedKeysBuffer); LABEL_16: sub_4452BB(); return; } - if ( pGUIWindow2->field_40 != 3 ) + if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED) return; - pGUIWindow2->field_40 = 0; + pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE; LABEL_15: memset(GameUI_Footer_TimedString, 0, 0xC8u); goto LABEL_16; @@ -586,7 +837,7 @@ } if ( pKeyActionMap->pPressedKeysBuffer[0] ) { - pKeyActionMap->_459ED1(0); + pKeyActionMap->SetWindowInputStatus(0); goto LABEL_15; } }
--- a/Vis.cpp Wed May 22 22:26:31 2013 +0400 +++ b/Vis.cpp Thu May 23 03:32:36 2013 +0200 @@ -6,7 +6,9 @@ #include "Game.h" #include "Actor.h" #include "IndoorCamera.h" +#include "OutdoorCamera.h" #include "Viewport.h" +#include "Math.h" #include "Log.h" #include "mm7_data.h" @@ -820,8 +822,8 @@ //unsigned int v10; // ecx@1 //unsigned int v11; // edx@3 //signed int v12; // ecx@4 - __int16 v13; // si@4 - __int16 *v14; // ecx@4 + //__int16 v13; // si@4 + //__int16 *v14; // ecx@4 unsigned int v15; // edx@8 //signed int v16; // ecx@9 __int16 v17; // si@9 @@ -831,7 +833,7 @@ __int16 v21; // si@13 __int16 *v22; // ecx@13 //signed int a1a; // [sp+14h] [bp+8h]@1 - __int16 *a5a; // [sp+24h] [bp+18h]@3 + //__int16 *a5a; // [sp+24h] [bp+18h]@3 __int16 *a5b; // [sp+24h] [bp+18h]@8 __int16 *a5c; // [sp+24h] [bp+18h]@12 @@ -839,73 +841,93 @@ //v9 = pFace; //v10 = pFace->uAttributes; //a1a = 0; - if ( BYTE1(pFace->uAttributes) & 1 ) + if (pFace->uAttributes & FACE_XY_PLANE) { pFace->pFacePlane.vNormal.x = a5->x; pFace->pFacePlane.vNormal.y = a5->y; - if ( pFace->uNumVertices ) + + for (int i = 0; i < pFace->uNumVertices; ++i) + { + displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; + displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; + + displaced_face_intersect_plane_coords_b[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; + displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; + } + } + else if (pFace->uAttributes & FACE_XZ_PLANE) + { + pFace->pFacePlane.vNormal.x = a5->x; + pFace->pFacePlane.vNormal.z = a5->z; + + for (int i = 0; i < pFace->uNumVertices; ++i) { - //v11 = 188 * ModelID + 72; - a5a = displaced_face_intersect_plane_coords_b + 1; - for ( uint i = 0; i < pFace->uNumVertices; ++i ) - { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; - displaced_face_intersect_plane_coords_b[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; - *(__int16 *)((char *)a5a + (int)(char *)displaced_face_intersect_plane_coords_a - (char *)displaced_face_intersect_plane_coords_b) = - pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; - v13 = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; - v14 = a5a; - a5a += 2; - *v14 = v13; - } + displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; + displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; + + displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; + displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; + } + } + else if (pFace->uAttributes & FACE_YZ_PLANE) + { + pFace->pFacePlane.vNormal.y = a5->y; + pFace->pFacePlane.vNormal.z = a5->z; + + for (int i = 0; i < pFace->uNumVertices; ++i) + { + displaced_face_intersect_plane_coords_a[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; + displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; + + displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; + displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; } } + else assert(false); + + return true; +} + + + + + +//----- (0046A0A1) -------------------------------------------------------- +int UnprojectX(int x) +{ + int v3; // [sp-4h] [bp-8h]@5 + + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + if ( pRenderer->pRenderD3D ) + v3 = pGame->pIndoorCameraD3D->fov; + else + v3 = pIndoorCamera->flt_1C_fov; + } else { - if ( BYTE1(pFace->uAttributes) & 2 ) - { - pFace->pFacePlane.vNormal.x = a5->x; - pFace->pFacePlane.vNormal.z = a5->z; - if ( pFace->uNumVertices ) - { - v15 = 188 * uModelID + 72; - a5b = displaced_face_intersect_plane_coords_b + 1; - for ( uint i = 0; i < pFace->uNumVertices; ++i ) - { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; - *(a5b - 1) = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; - *(__int16 *)((char *)a5b + (int)displaced_face_intersect_plane_coords_a - (int)displaced_face_intersect_plane_coords_b) = pFace->pXInterceptDisplacements[i + 1] - + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; - v17 = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; - v18 = a5b; - a5b += 2; - *v18 = v17; - } - } - } + v3 = pOutdoorCamera->int_fov_rad; + } + return stru_5C6E00->Atan2(x - pViewport->uScreenCenterX, v3) - stru_5C6E00->uIntegerHalfPi; +} + +//----- (0046A0F6) -------------------------------------------------------- +int UnprojectY(int y) +{ + int v3; // [sp-4h] [bp-8h]@5 + + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + if ( pRenderer->pRenderD3D ) + v3 = pGame->pIndoorCameraD3D->fov; else - { - pFace->pFacePlane.vNormal.y = a5->y; - pFace->pFacePlane.vNormal.z = a5->z; - if ( pFace->uNumVertices ) - { - v19 = 188 * uModelID + 72; - a5c = displaced_face_intersect_plane_coords_b + 1; - for ( uint i = 0; i < pFace->uNumVertices; ++i ) - { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; - *(a5c - 1) = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; - *(__int16 *)((char *)a5c + (int)(char *)displaced_face_intersect_plane_coords_a - (char *)displaced_face_intersect_plane_coords_b) = pFace->pYInterceptDisplacements[i + 1] - + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; - v21 = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; - v22 = a5c; - a5c += 2; - *v22 = v21; - } - } - } + v3 = pIndoorCamera->flt_1C_fov; } - return true; + else + { + v3 = pOutdoorCamera->int_fov_rad; + } + return stru_5C6E00->Atan2(y - pViewport->uScreenCenterY, v3) - stru_5C6E00->uIntegerHalfPi; } //----- (004C248E) --------------------------------------------------------
--- a/mm7_1.cpp Wed May 22 22:26:31 2013 +0400 +++ b/mm7_1.cpp Thu May 23 03:32:36 2013 +0200 @@ -384,7 +384,7 @@ v10 = pGlobalTXT_LocalizationStrings[57]; // Days if ( v19 <= 1 ) v10 = pGlobalTXT_LocalizationStrings[56]; // Day - sprintf(pTmpBuf2, "%d %s ", v19, v10); + sprintfex(pTmpBuf2, "%d %s ", v19, v10); strcat(pTmpBuf, pTmpBuf2); } if ( v9 ) @@ -393,7 +393,7 @@ v11 = pGlobalTXT_LocalizationStrings[109];// Hour else v11 = pGlobalTXT_LocalizationStrings[110];// Hours - sprintf(pTmpBuf2, "%d %s ", v9, v11); + sprintfex(pTmpBuf2, "%d %s ", v9, v11); strcat(pTmpBuf, pTmpBuf2); } if ( v17 && !v19 ) @@ -402,7 +402,7 @@ v12 = pGlobalTXT_LocalizationStrings[437];// Minute else v12 = pGlobalTXT_LocalizationStrings[436];// Minutes - sprintf(pTmpBuf2, "%d %s ", v17, v12); + sprintfex(pTmpBuf2, "%d %s ", v17, v12); strcat(pTmpBuf, pTmpBuf2); } if ( v18 && !v9 ) @@ -411,7 +411,7 @@ v13 = pGlobalTXT_LocalizationStrings[439];// Second else v13 = pGlobalTXT_LocalizationStrings[438];// Seconds - sprintf(pTmpBuf2, "%d %s ", v18, v13); + sprintfex(pTmpBuf2, "%d %s ", v18, v13); strcat(pTmpBuf, pTmpBuf2); } a1->DrawText(a2, 32, uY, 0, pTmpBuf, 0, 0, 0); @@ -434,10 +434,10 @@ { if ( _506F18_num_hours_to_sleep < 6 ) { - pParty->pPlayers[3].pConditions[2] = 0i64; - pParty->pPlayers[2].pConditions[2] = 0i64; - pParty->pPlayers[1].pConditions[2] = 0i64; - pParty->pPlayers[0].pConditions[2] = 0i64; + pParty->pPlayers[3].SetAsleep(false); + pParty->pPlayers[2].SetAsleep(false); + pParty->pPlayers[1].SetAsleep(false); + pParty->pPlayers[0].SetAsleep(false); if ( _506F18_num_hours_to_sleep ) { Rest(_506F18_num_hours_to_sleep); @@ -484,6 +484,7 @@ POINT v3; // [sp+0h] [bp-10h]@2 POINT a2; // [sp+8h] [bp-8h]@1 + __debugbreak(); // invalid indexing if ( pMouse->GetCursorPos(&a2)->y < 350 ) { v0 = pMouse->GetCursorPos(&a2); @@ -755,127 +756,6 @@ return 1; } -//----- (00421D00) -------------------------------------------------------- -void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID) -{ - //unsigned int v1; // esi@1 - //int v2; // eax@2 - //Player *v3; // ecx@2 - //Player *v4; // ecx@5 - unsigned int v5; // [sp-4h] [bp-10h]@21 - - //v1 = uPlayerID; - auto player = &pParty->pPlayers[uPlayerID - 1]; - if (pParty->pPickedItem.uItemID) - { - //v3 = player; - if (auto slot = player->AddItem(-1, pParty->pPickedItem.uItemID)) - { - memcpy(&player->pInventoryItems[slot-1], &pParty->pPickedItem, 0x24u); - viewparams->bRedrawGameUI = true; - pMouse->RemoveHoldingItem(); - return; - } - - if (!player->CanAct()) - { - player = pPlayers[uActiveCharacter]; - } - if(player->CanAct() || !pPlayers[uActiveCharacter]->CanAct()) - player->PlaySound(SPEECH_NoRoom, 0); - } - -//LABEL_9: - if (pCurrentScreen == SCREEN_GAME) - { - viewparams->bRedrawGameUI = true; - if ( uActiveCharacter != uPlayerID ) - //goto LABEL_27; - { - if ( pPlayers[uPlayerID]->uTimeToRecovery ) - return; - - uActiveCharacter = uPlayerID; - return; - } - v5 = 7; -//LABEL_22: - pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5); - return; - } - if ( pCurrentScreen == SCREEN_SPELL_BOOK ) - return; - if ( pCurrentScreen == SCREEN_CHEST ) - { -//LABEL_23: - viewparams->bRedrawGameUI = true; - if ( uActiveCharacter == uPlayerID ) - { - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - pCurrentScreen = SCREEN_CHEST_INVENTORY; - //goto LABEL_28; - uActiveCharacter = uPlayerID; - return; - } -//LABEL_27: - if ( pPlayers[uPlayerID]->uTimeToRecovery ) - return; - //goto LABEL_28; - uActiveCharacter = uPlayerID; - return; - } - if ( pCurrentScreen != SCREEN_HOUSE ) - { - if ( pCurrentScreen == SCREEN_E ) - { -//LABEL_28: - uActiveCharacter = uPlayerID; - return; - } - if ( pCurrentScreen != SCREEN_CHEST_INVENTORY ) - { - viewparams->bRedrawGameUI = true; - uActiveCharacter = uPlayerID; - if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 102 ) - FillAwardsData(); - return; - } - //goto LABEL_23; - viewparams->bRedrawGameUI = true; - if ( uActiveCharacter == uPlayerID ) - { - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - pCurrentScreen = SCREEN_CHEST_INVENTORY; - //goto LABEL_28; - uActiveCharacter = uPlayerID; - return; - } -//LABEL_27: - if ( pPlayers[uPlayerID]->uTimeToRecovery ) - return; - //goto LABEL_28; - uActiveCharacter = uPlayerID; - return; - } - if ( window_SpeakInHouse->field_40 == 1 ) - return; - viewparams->bRedrawGameUI = true; - if ( uActiveCharacter != uPlayerID ) - //goto LABEL_28; - uActiveCharacter = uPlayerID; - return; - if (dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_6) - { - __debugbreak(); // fix indexing - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - v5 = 14; - //goto LABEL_22; - pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5); - return; - } -} -// 4E28F8: using guessed type int pCurrentScreen; -// F8B19C: using guessed type int dword_F8B19C; //----- (00421EA6) -------------------------------------------------------- void __cdecl OnInventoryLeftClick() @@ -994,7 +874,7 @@ unsigned __int16 v5; // dx@14 signed int v6; // eax@14 char *v7; // esi@15 - int *v8; // eax@19 + //int *v8; // eax@19 int v9; // eax@19 unsigned int v10; // eax@19 int v11; // ecx@21 @@ -1011,7 +891,7 @@ ItemGen *v22; // esi@62 unsigned int v23; // eax@62 SpriteObject a1; // [sp+Ch] [bp-80h]@1 - POINT v25; // [sp+7Ch] [bp-10h]@3 + //POINT v25; // [sp+7Ch] [bp-10h]@3 POINT a2; // [sp+84h] [bp-8h]@3 if ( pRenderer->pRenderD3D ) @@ -1021,8 +901,9 @@ else { v1 = pMouse->GetCursorPos(&a2); - v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v25)->y]]; + v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]]; } + if ( PID_TYPE(v0) == OBJECT_Item) { a2.y = (signed int)(unsigned __int16)v0 >> 3; @@ -1144,12 +1025,11 @@ pParty->sEyelevel + pParty->vPosition.z); a1.uSpriteFrameID = 0; memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); - v8 = (int *)pMouse->GetCursorPos(&v25); - v9 = UnprojectX(*v8); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); a1.Create(pParty->sRotationY + v9, 184, 200, 0); - v10 = pIcons_LOD->LoadTexture( - pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, - TEXTURE_16BIT_PALETTE); + v10 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); if (v10 != -1) pIcons_LOD->pTextures[v10].Release(); pMouse->RemoveHoldingItem(); @@ -1526,6 +1406,10 @@ uGameUIFontShadow = TargetColor(v5, v4, v6); } + + + + //----- (00423AEE) -------------------------------------------------------- void __cdecl reset_some_strus_flt_2Cs() {
--- a/mm7_2.cpp Wed May 22 22:26:31 2013 +0400 +++ b/mm7_2.cpp Thu May 23 03:32:36 2013 +0200 @@ -802,7 +802,7 @@ if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pKeyActionMap->_459ED1(3); + pKeyActionMap->SetWindowInputStatus(3); pKeyActionMap->ResetKeys(); activeLevelDecoration = NULL; current_npc_text = 0; @@ -6634,10 +6634,7 @@ GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 pCurrentScreen = SCREEN_GAME; - if (pAsyncMouse) - pAsyncMouse->Resume(); - if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard ) - pAsyncKeyboard->Resume(); + pGUIWindow2 = 0; pAudioPlayer->StopChannels(-1, -1); pMouse->RemoveHoldingItem(); @@ -6694,12 +6691,10 @@ { pRenderer->BeginScene(); pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); - if (pAsyncMouse) - pAsyncMouse->_46B736_consume_click_lists(1); + GUI_MainMenuMessageProc(); GUI_UpdateWindows(); - if (pAsyncMouse) - pAsyncMouse->_46B736_consume_click_lists(1); + if (GetCurrentMenuID() != MENU_MAIN) { if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) @@ -7016,8 +7011,6 @@ case WM_LBUTTONDOWN: if ( pArcomageGame->bGameInProgress ) { - if (pAsyncMouse) - return DefWindowProcA(hWnd, Msg, wParam, lParam); pArcomageGame->stru1.field_0 = 7; ArcomageGame::OnMouseClick(0, 1); return DefWindowProcA(hWnd, Msg, wParam, lParam); @@ -7031,27 +7024,19 @@ { if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 ) pVideoPlayer->bStopBeforeSchedule = 1; - if (!pAsyncMouse) - pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); + + pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); if (pGame) { - if (pAsyncMouse) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); v33 = pGame->pIndoorCameraD3D->GetPickDepth(); pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter); } - if (!pAsyncMouse) - { + sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - if (pAsyncMouse) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); + + } + pArcomageGame->stru1.field_0 = 8; ArcomageGame::OnMouseClick(1, 1); return DefWindowProcA(hWnd, Msg, wParam, lParam); @@ -7060,14 +7045,9 @@ if ( !pArcomageGame->bGameInProgress ) //goto LABEL_218; { - if ( pAsyncMouse != v32 ) - return DefWindowProcA(hWnd, Msg, wParam, lParam); back_to_game(); return DefWindowProcA(hWnd, Msg, wParam, lParam); } - if (pAsyncMouse) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); pArcomageGame->stru1.field_0 = 3; ArcomageGame::OnMouseClick(0, 0); return DefWindowProcA(hWnd, Msg, wParam, lParam); @@ -7076,15 +7056,10 @@ if ( !pArcomageGame->bGameInProgress ) { //LABEL_218: - if ( pAsyncMouse != v32 ) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); + back_to_game(); return DefWindowProcA(hWnd, Msg, wParam, lParam); } - if (pAsyncMouse) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); pArcomageGame->stru1.field_0 = 4; v29 = 0; //goto LABEL_262; @@ -7095,9 +7070,6 @@ case WM_LBUTTONDBLCLK: if ( pArcomageGame->bGameInProgress ) { - if (pAsyncMouse) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); pArcomageGame->stru1.field_0 = 7; return DefWindowProcA(hWnd, Msg, wParam, lParam); } @@ -7106,7 +7078,6 @@ if ( pVideoPlayer->pVideoFrame.pPixels ) pVideoPlayer->bStopBeforeSchedule = 1; - if ( !pAsyncMouse ) pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); if (GetCurrentMenuID() != MENU_CREATEPARTY) @@ -7117,13 +7088,12 @@ pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); } - if (!pAsyncMouse) - { + if (pGame) pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, false, &vis_sprite_filter_3, &vis_door_filter); UI_OnMouseLeftClick(0); - } + return DefWindowProcA(hWnd, Msg, wParam, lParam); case WM_RBUTTONDBLCLK: @@ -7133,40 +7103,29 @@ //LABEL_240: if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 ) pVideoPlayer->bStopBeforeSchedule = 1; - if (!pAsyncMouse) + pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); if (pGame) { - if (pAsyncMouse) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); v33 = pGame->pIndoorCameraD3D->GetPickDepth(); pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter); } - if (!pAsyncMouse) - { + sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - if (pAsyncMouse) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); + + } pArcomageGame->stru1.field_0 = 8; return DefWindowProcA(hWnd, Msg, wParam, lParam); case WM_MBUTTONDOWN: if ( pRenderer->pRenderD3D ) { - if ( pGame && !pAsyncMouse ) + if ( pGame ) { v34 = pGame->pIndoorCameraD3D->GetPickDepth(); pGame->PickMouse(v34, (unsigned __int16)lParam, lParam >> 16, 1, &vis_sprite_filter_3, &vis_face_filter); return DefWindowProcA(hWnd, Msg, wParam, lParam); } - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); } if ( !pGame ) //goto _def_wnd_proc; @@ -7176,9 +7135,6 @@ case WM_MOUSEMOVE: if ( pArcomageGame->bGameInProgress ) { - if (pAsyncMouse) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); pXY[0] = (unsigned __int16)lParam; pXY[1] = lParam >> 16; ArcomageGame::OnMouseMove((POINT *)pXY); @@ -7188,9 +7144,6 @@ } else { - if (pAsyncMouse) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); } return DefWindowProcA(hWnd, Msg, wParam, lParam); @@ -7930,8 +7883,7 @@ Abortf(pGlobalTXT_LocalizationStrings[62]); } BYTE1(dword_6BE364_game_settings_1) &= 0xFEu; - if (pAsyncMouse) - pAsyncMouse->Resume(); + if ( pArcomageGame->bGameInProgress ) { pArcomageGame->field_F9 = 1; @@ -7946,9 +7898,8 @@ BYTE1(dword_6BE364_game_settings_1) &= 0xFBu; else pMiscTimer->Resume(); - if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard ) - pAsyncKeyboard->Resume(); - viewparams->bRedrawGameUI = 1; + + viewparams->bRedrawGameUI = true; if ( pVideoPlayer->pSmackerMovie ) { pRenderer->RestoreFrontBuffer(); @@ -7968,8 +7919,7 @@ dword_4E98BC_bApplicationActive = 0; if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie ) pVideoPlayer->bStopBeforeSchedule = 1; - if (pAsyncMouse) - pAsyncMouse->Suspend(); + if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 ) SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); ClipCursor(0); @@ -7982,8 +7932,7 @@ BYTE1(dword_6BE364_game_settings_1) |= 4u; else pMiscTimer->Pause(); - if ( pGame && LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard ) - pAsyncKeyboard->Suspend(); + pAudioPlayer->StopChannels(-1, -1); if ( pAudioPlayer->hAILRedbook ) AIL_redbook_pause(pAudioPlayer->hAILRedbook); @@ -8011,15 +7960,9 @@ SetPriorityClass(v6, 0x20u); if ( pGame ) { - v7 = pGame->pKeyboardInstance; - if ( v7 ) - { - if ( LOBYTE(v7->bUsingAsynKeyboard) && pAsyncKeyboard ) - pAsyncKeyboard->_45B3A4(); - } - } - if (pAsyncMouse) - pAsyncMouse->_46B1DD(); + + } + PostQuitMessage(0); return 0; } @@ -8031,11 +7974,7 @@ if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 ) SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); ClipCursor(0); - if (pAsyncMouse) - { - pAsyncMouse->Suspend(); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } + } //_def_wnd_proc: return DefWindowProcA(hWnd, Msg, wParam, lParam); @@ -8070,14 +8009,9 @@ //goto _def_wnd_proc; return DefWindowProcA(hWnd, Msg, wParam, lParam); } - if ( ::hWnd != (HWND)wParam || (dword_4E98BC_bApplicationActive = 1, pRenderer->bWindowMode) || !pAsyncMouse ) + if ( ::hWnd != (HWND)wParam || (dword_4E98BC_bApplicationActive = 1, pRenderer->bWindowMode) || true ) return DefWindowProcA(hWnd, Msg, wParam, lParam); - pAsyncMouse->Resume(); - if ( !pAsyncMouse ) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - pAsyncMouse->Clip(); - return DefWindowProcA(hWnd, Msg, wParam, lParam); + } //----- (00464479) -------------------------------------------------------- @@ -9073,8 +9007,6 @@ SetMenu(hWnd, 0); SetWindowLongA(hWnd, GWL_EXSTYLE, 0); SetWindowLongA(hWnd, GWL_STYLE, WS_VISIBLE); - if (pAsyncMouse) - pAsyncMouse->Clip(); pRenderer->InitializeFullscreen(hWnd); } else @@ -9155,8 +9087,6 @@ char pContainer[32]; // [sp+10h] [bp-Ch]@9 pMouse->Initialize(hWnd); - CreateAsyncMouse(); - CreateAsyncKeyboard(); pItemsTable = new ItemsTable; pItemsTable->Initialize(); @@ -9523,10 +9453,7 @@ if (GetCurrentMenuID() != MENU_10) goto LABEL_49; pMouse->Activate(0); - if (pAsyncMouse) - pAsyncMouse->Suspend(); - if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard ) - pAsyncKeyboard->Suspend(); + pParty->Reset(); pParty->CreateDefaultParty(1); crt_init_globals_46271C(); @@ -9534,19 +9461,12 @@ if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) { pMouse->Activate(1); - if (pAsyncMouse) - pAsyncMouse->Resume(); - if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard ) - pAsyncKeyboard->Resume(); + break; } _chdir("..\\"); strcpy(pCurrentMapName, ofn.lpstrFileTitle); pMouse->Activate(1); - if (pAsyncMouse) - pAsyncMouse->Resume(); - if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard ) - pAsyncKeyboard->Resume(); } //LABEL_48: pGame->Loop(); @@ -9591,35 +9511,6 @@ } // 507BF0: using guessed type int dword_507BF0_is_there_popup_onscreen; -//----- (00465F5A) -------------------------------------------------------- -void __cdecl CreateAsyncMouse() -{ - LOG_DECOMPILATION_WARNING(); - /* - if (!pAsyncMouse && - pRenderer->bUserDirect3D && - pRenderer->uAcquiredDirect3DDevice == 1) - { - pAsyncMouse = new AsyncMouse(&pRenderer->pDirectDraw4); - if (pAsyncMouse) - pAsyncMouse->Resume(); - }*/ -} - -//----- (00465FF0) -------------------------------------------------------- -void __cdecl CreateAsyncKeyboard() -{ - LOG_DECOMPILATION_WARNING(); - /* - if (!pAsyncKeyboard && - pGame->pKeyboardInstance->bUsingAsynKeyboard) - { - pAsyncKeyboard = new AsyncKeyboard; - if (pAsyncKeyboard) - pAsyncKeyboard->Resume(); - }*/ -} - //----- (00466082) -------------------------------------------------------- void MM6_Initialize(const wchar_t *pIniFilename) { @@ -9862,11 +9753,6 @@ }; void SetCurrentMenuID(MENU_STATE uMenu) { - if ((int)uCurrentMenuID != -1) - { - if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard) - pAsyncKeyboard->Resume(); - } uCurrentMenuID = uMenu; Log::Warning(L"CurrentMenu = %s", MENU_STATE_to_string(uMenu)); @@ -9878,33 +9764,60 @@ return uCurrentMenuID; } -//----- (00467D5D) -------------------------------------------------------- -int __thiscall sub_467D5D(int _this) -{ - return *(int *)(_this + 7204); -} //----- (00467E7F) -------------------------------------------------------- -void __thiscall sub_467E7F_EquipBody(unsigned int uEquipType) -{ - unsigned int v1; // esi@1 +void sub_467E7F_EquipBody(ITEM_EQUIP_TYPE uEquipType) +{ + //unsigned int v1; // esi@1 int v2; // ebx@1 Player *v3; // eax@1 int v4; // edx@1 int v5; // esi@2 - int v6; // eax@2 + //int v6; // eax@2 unsigned int v7; // eax@3 ItemGen _this; // [sp+Ch] [bp-30h]@1 - Player *v9; // [sp+30h] [bp-Ch]@1 + //Player *v9; // [sp+30h] [bp-Ch]@1 int v10; // [sp+34h] [bp-8h]@1 int *v11; // [sp+38h] [bp-4h]@1 - v1 = uEquipType; + static unsigned char byte_4E8398[200] = // 4E8398 + { + 1, // EQUIP_OFF_HAND + 1, // EQUIP_MAIN_HAND + 2, // EQUIP_BOW + 3, // EQUIP_ARMOUR + 0, // EQUIP_SHIELD + 4, // EQUIP_HELMET + 5, // EQUIP_BELT + 6, // EQUIP_CLOAK + 7, // EQUIP_GAUNTLETS + 8, // EQUIP_BOOTS + 10, // EQUIP_RING + 9, // EQUIP_AMULET + 1, // EQUIP_WAND + 0, // EQUIP_REAGENT + 0, // EQUIP_POTION + 0, // EQUIP_SPELL_SCROLL + 0, // EQUIP_BOOK + 0, // EQUIP_MESSAGE_SCROLL + 0, // EQUIP_GOLD + 0, // EQUIP_GEM + 0, // EQUIP_NONE + // ??? + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, + 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0 +}; + _this.Reset(); - v2 = (unsigned __int8)byte_4E8394[v1 + 4]; + v2 = byte_4E8398[uEquipType]; v3 = pPlayers[uActiveCharacter]; - v9 = v3; - v11 = (int *)((char *)&v3->pEquipment + 4 * v2); + v11 = (int *)&v3->pEquipment.pIndices[v2]; v4 = *v11; v10 = *v11; if ( v10 ) @@ -9914,18 +9827,17 @@ *(char *)(v5 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v5 + 532)); - v6 = v10; _this.uBodyAnchor = v2 + 1; memcpy((void *)(v5 + 532), &_this, 0x24u); - *v11 = v6; + *v11 = v10; } else { v7 = v3->FindFreeInventorySlot(); - if ( (v7 & 0x80000000u) == 0 ) + if (v7 >= 0) { pParty->pPickedItem.uBodyAnchor = v2 + 1; - memcpy(&v9->pInventoryItems[v7], &pParty->pPickedItem, sizeof(v9->pInventoryItems[v7])); + memcpy(&v3->pInventoryItems[v7], &pParty->pPickedItem, sizeof(v3->pInventoryItems[v7])); *v11 = v7 + 1; pMouse->RemoveHoldingItem(); } @@ -10105,7 +10017,7 @@ } if ( pParty->pPickedItem.uItemID == 604 ) { - sub_467E7F_EquipBody(3); + sub_467E7F_EquipBody((ITEM_EQUIP_TYPE)3); WetsuitOn(uActiveCharacter); return; } @@ -10130,7 +10042,7 @@ pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - sub_467E7F_EquipBody(v6); + sub_467E7F_EquipBody((ITEM_EQUIP_TYPE)v6); if ( pParty->pPickedItem.uItemID == 604 ) WetsuitOff(uActiveCharacter); return; @@ -10247,16 +10159,10 @@ if ( pSkillType == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0) || pSkillType == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 ) { - if (pAsyncMouse) - { - v18 = *((int *)pAsyncMouse + 6); - v19 = *((int *)pAsyncMouse + 7); - } - else - { + v18 = pMouse->uMouseClickX; v19 = pMouse->uMouseClickY; - } + v49 = v19; if ( (signed int)v18 >= 560 ) { @@ -10413,18 +10319,10 @@ } return; } - if (pAsyncMouse) - { - v32 = *((int *)pAsyncMouse + 6); - v33 = *((int *)pAsyncMouse + 7); - v49 = *((int *)pAsyncMouse + 7); - v48 = v32; - } - else - { + v32 = pMouse->uMouseClickX; v33 = pMouse->uMouseClickY; - } + v34 = pRenderer->pActiveZBuffer[v32 + pSRZBufferLineOffsets[v33]] & 0xFFFF; if ( v34 ) { @@ -10482,47 +10380,6 @@ } } -//----- (0046A0A1) -------------------------------------------------------- -int __thiscall UnprojectX(int x) -{ - double v1; // st7@3 - int v3; // [sp-4h] [bp-8h]@5 - - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - if ( pRenderer->pRenderD3D ) - v1 = pGame->pIndoorCameraD3D->fov; - else - v1 = pIndoorCamera->flt_1C_fov; - v3 = (signed __int64)v1; - } - else - { - v3 = pOutdoorCamera->int_fov_rad; - } - return stru_5C6E00->Atan2(x - pViewport->uScreenCenterX, v3) - stru_5C6E00->uIntegerHalfPi; -} - -//----- (0046A0F6) -------------------------------------------------------- -int __thiscall UnprojectY(int _this) -{ - double v1; // st7@3 - int v3; // [sp-4h] [bp-8h]@5 - - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - if ( pRenderer->pRenderD3D ) - v1 = pGame->pIndoorCameraD3D->fov; - else - v1 = pIndoorCamera->flt_1C_fov; - v3 = (signed __int64)v1; - } - else - { - v3 = pOutdoorCamera->int_fov_rad; - } - return stru_5C6E00->Atan2(_this - pViewport->uScreenCenterY, v3) - stru_5C6E00->uIntegerHalfPi; -} //----- (0046A14B) -------------------------------------------------------- void OnPressSpace() @@ -10556,7 +10413,14 @@ auto pid = pGame->pVisInstance->get_picked_object_zbuf_val(); if ( pid != -1 ) DoInteractionWithTopmostZObject(pid & 0xFFFF, PID_ID(pid)); - } + return; + } + + + // software render stuff following + + static int dword_720660[100]; // 720660 + static int dword_7207F0[100]; // 7207F0 v22 = 0; v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);//wrong pointer @@ -10602,8 +10466,8 @@ ++v22; ++v4; v8 = *v21; - dword_7207EC[v4] = v7; - dword_72065C[v4] = v8; + dword_7207F0[v4 - 1] = v7; + dword_720660[v4 - 1] = v8; } } else if ( (unsigned int)*v21 <= 0x2000000 ) @@ -10613,8 +10477,8 @@ ++v22; ++v4; v8 = *v21; - dword_7207EC[v4] = v7; - dword_72065C[v4] = v8; + dword_7207F0[v4 - 1] = v7; + dword_720660[v4 - 1] = v8; } } v1 = v21 + 2; @@ -10744,13 +10608,6 @@ if ( v13->sNPC_ID ) { pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_StartNPCDialogue; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ } else { @@ -10947,15 +10804,15 @@ v6 = PID_ID(v5); v7 = v6; v8 = pActors[v6].uAIState; - if ( v8 != 5 ) - { - if ( v8 != 4 ) - { - if ( v8 != 11 ) + if ( v8 != Dead ) + { + if ( v8 != Dying ) + { + if ( v8 != Removed ) { - if ( v8 != 19 ) + if ( v8 != Disabled ) { - if ( v8 != 17 ) + if ( v8 != Summoned ) { v9 = (double)a3; if ( pGame->pVisInstance->DoesRayIntersectBillboard(v9, a1a) )
--- a/mm7_5.cpp Wed May 22 22:26:31 2013 +0400 +++ b/mm7_5.cpp Thu May 23 03:32:36 2013 +0200 @@ -457,8 +457,8 @@ GUIWindow::Create(241, 302, 106, 42, WINDOW_SaveLoadBtn, (int)pBtnLoadSlot, 0); continue; case UIMSG_SelectLoadSlot: - if ( pGUIWindow_CurrentMenu->field_40 == 1 ) - pKeyActionMap->_459ED1(0); + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); if ( pCurrentScreen != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != pSaveListPosition + uMessageParam ) { v10 = pSaveListPosition + uMessageParam; @@ -466,23 +466,6 @@ { pMessageQueue_50CBD0->AddMessage(UIMSG_SaveLoadBtn, 0, 0); pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_SaveLoadBtn; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - //v11 = pMessageQueue_50CBD0->uNumMessages + 1; - //v13 = pMessageQueue_50CBD0->uNumMessages + 1 > 40; - //v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0; - ++pMessageQueue_50CBD0->uNumMessages; - if ( v12 ^ v13 ) - { - pMessageQueue_50CBD0->pMessages[v11].eType = UIMSG_LoadGame; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - } - }*/ } uLoadGameUI_SelectedSlot = v10; dword_6BE138 = v10; @@ -504,9 +487,9 @@ stru_506E40.Release(); continue; case UIMSG_SaveGame: - if ( pGUIWindow_CurrentMenu->field_40 == 1 ) - { - pKeyActionMap->_459ED1(0); + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + { + pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); strcpy((char *)&pSavegameHeader[uLoadGameUI_SelectedSlot], (const char *)pKeyActionMap->pPressedKeysBuffer); } DoSavegame(uLoadGameUI_SelectedSlot); @@ -3464,8 +3447,8 @@ break; case UIMSG_SelectLoadSlot: //main menu save/load wnd clicking on savegame lines - if (pGUIWindow_CurrentMenu->field_40 == 1) - pKeyActionMap->_459ED1(0); + if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); if ( pCurrentScreen != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != pParam + pSaveListPosition ) { //load clicked line @@ -9767,149 +9750,6 @@ } -//----- (00411150) -------------------------------------------------------- -void DrawTownPortalScreen() -{ - //signed int v0; // edi@1 - //__int16 v1; // dx@8 - //POINT *v2; // edi@17 - int v3; // edi@17 - //__int16 v4; // dx@24 - GUIWindow v6; // [sp+Ch] [bp-64h]@1 - //POINT v7; // [sp+60h] [bp-10h]@17 - POINT a2; // [sp+68h] [bp-8h]@17 - - pRenderer->ClearZBuffer(0, 479); - pRenderer->DrawTextureTransparent(8, 8, pTexture_CurrentBook); - pRenderer->DrawTextureTransparent(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); - - v6.uFrameX = game_viewport_x; - v6.uFrameY = game_viewport_y; - v6.uFrameWidth = game_viewport_width; - v6.uFrameHeight = game_viewport_height; - v6.uFrameZ = game_viewport_z; - v6.uFrameW = game_viewport_w; - - const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE, - PARTY_QUEST_FOUNTAIN_PIERPONT, - PARTY_QUEST_FOUNTAIN_NIGHON, - PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE, - PARTY_QUEST_FOUNTAIN_CELESTIA, - PARTY_QUEST_FOUNTAIN_THE_PIT}; - for (uint i = 0; i < 6; ++i) - { - - if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i])) - pRenderer->DrawMaskToZBuffer(pTownPortalBook_xs[i], - pTownPortalBook_ys[i], - pTexture_TownPortalIcons[i], i + 1); - } - -/* v0 = 0; - do - { - if ( !v0 ) - { - v1 = 206; -LABEL_14: - if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v1) ) - goto LABEL_16; - goto LABEL_15; - } - if ( v0 == 1 ) - { - v1 = 208; - goto LABEL_14; - } - if ( v0 == 2 ) - { - v1 = 207; - goto LABEL_14; - } - if ( v0 == 3 ) - { - v1 = 211; - goto LABEL_14; - } - if ( v0 == 4 ) - { - v1 = 209; - goto LABEL_14; - } - if ( v0 == 5 ) - { - v1 = 210; - goto LABEL_14; - } -LABEL_15: - pRenderer->DrawMaskToZBuffer( - pTownPortalBook_xs[v0], - pTownPortalBook_ys[v0], - *(&pTexture_TownPortalHarmn + v0), - v0 + 1); -LABEL_16: - ++v0; - } - while ( v0 < 6 );*/ - - pMouse->GetCursorPos(&a2); - //v2 = pMouse->GetCursorPos(&a2); - v3 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF; - - if (v3) - { - if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1])) - pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]); - } - v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); - - -/* if ( !v3 ) // Town Portal - { - v6.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3); // "Town Portal" - return; - } - if ( v3 == 1 ) - { - v4 = 206; -LABEL_30: - if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) ) - goto LABEL_31; - v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); // "Town Portal" - return; - } - if ( v3 == 2 ) - { - v4 = 208; - goto LABEL_30; - } - if ( v3 == 3 ) - { - v4 = 207; - goto LABEL_30; - } - if ( v3 == 4 ) - { - v4 = 211; - goto LABEL_30; - } - if ( v3 == 5 ) - { - v4 = 209; - goto LABEL_30; - } - if ( v3 == 6 ) - { - v4 = 210; - goto LABEL_30; - } -LABEL_31: - pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3)); - v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);*/ -} -// 4E1D3A: using guessed type __int16 word_4E1D3A[]; - - //----- (00413FF1) -------------------------------------------------------- void SetMonthNames() { @@ -9980,17 +9820,6 @@ - -//----- (004141CA) -------------------------------------------------------- -void ModalWindow(const char *pStr, int a4) -{ - pEventTimer->Pause(); - dword_506F0C[0] = pCurrentScreen; - ptr_507BDC = GUIWindow::Create(0, 0, 640, 480, WINDOW_FinalWindow, a4, (int)pStr); - pCurrentScreen = SCREEN_PRESS_ESCAPE_MESSAGE; -} -// 4E28F8: using guessed type int pCurrentScreen; - //----- (0041420D) -------------------------------------------------------- void __cdecl sub_41420D_press_esc() { @@ -10014,13 +9843,7 @@ v0 = ptr_507BDC; pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BDC->ptr_1C, 0, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)(int)ptr_507BDC->ptr_1C; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ + v0->Release(); ptr_507BDC = 0; pCurrentScreen = dword_506F0C[0]; @@ -10223,7 +10046,7 @@ case WINDOW_50: { v27 = TargetColor(255, 255, 255); - if ( ptr_507BD0->field_40 == 1 ) + if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) { ptr_507BD0->DrawMessageBox(0); ptr_507BD0->DrawText(pFontCreate, 30, 40, v27, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0); @@ -10231,19 +10054,19 @@ ptr_507BD0->DrawFlashingInputCursor(v31 + 30, 40, pFontCreate); continue; } - if ( ptr_507BD0->field_40 == 2 ) + if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) { - pWindow->field_40 = 0; + pWindow->receives_keyboard_input_2 = WINDOW_INPUT_NONE; pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0); pEventTimer->Resume(); ptr_507BD0->Release(); - pCurrentScreen = 0; - viewparams->bRedrawGameUI = 1; + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = true; continue; } - if ( ptr_507BD0->field_40 == 3 ) + if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED) { - pWindow->field_40 = 0; + pWindow->receives_keyboard_input_2 = WINDOW_INPUT_NONE; pEventTimer->Resume(); ptr_507BD0->Release(); continue; @@ -10260,7 +10083,7 @@ pWindow->Release(); pEventTimer->Resume(); pCurrentScreen = 0; - viewparams->bRedrawGameUI = 1; + viewparams->bRedrawGameUI = true; v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); if ( v26 > 0 ) { @@ -10910,134 +10733,6 @@ } -//----- (00416B01) -------------------------------------------------------- -void GameUI_DrawNPCPopup(void *_this)//PopupWindowForBenefitAndJoinText -{ - int v1; // edi@2 - int v2; // ecx@2 - NPCData *v3; // eax@2 - NPCData *v4; // esi@7 - NPCData *v5; // eax@16 - NPCData *v6; // esi@16 - const CHAR *v7; // eax@18 - unsigned int v8; // eax@25 - unsigned int v9; // eax@25 - const char *v10; // ST14_4@26 - char *v11; // esi@26 - const char *v12; // ST18_4@27 - unsigned __int16 v13; // ax@28 - char *v14; // eax@28 - GUIWindow a1; // [sp+Ch] [bp-60h]@23 - int a2; // [sp+60h] [bp-Ch]@16 - void *v17; // [sp+64h] [bp-8h]@1 - LPCSTR lpsz; // [sp+68h] [bp-4h]@6 - - v17 = _this; - if ( bNoNPCHiring != 1 ) - { - v1 = 0; - v2 = 0; - v3 = pParty->pHirelings; - /*do - { - if ( v3->pName ) - pTmpBuf[v1++] = v2; - ++v3; - ++v2; - } - while ( (signed int)v3 < (signed int)&pParty->pPickedItem );*/ - for (int i = 0; i < 2; ++i) - { - if (pParty->pHirelings[i].pName) - pTmpBuf[v1++] = i; - } - lpsz = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - /*v4 = pNPCStats->pNewNPCData; - do - { - if ( v4->uFlags & 0x80 - && (!pParty->pHirelings[0].pName || strcmp(v4->pName, pParty->pHirelings[0].pName)) - && (!pParty->pHirelings[1].pName || strcmp(v4->pName, pParty->pHirelings[1].pName)) ) - pTmpBuf[v1++] = (char)lpsz + 2; - ++lpsz; - ++v4; - } - while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );*/ - for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i) - { - if (pNPCStats->pNewNPCData[i].Hired()) - { - if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName)) - { - if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName)) - pTmpBuf[v1++] = i + 2; - } - } - } - } - if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 ) - { - sDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17; - v5 = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int)&a2); - v6 = v5; - if ( v5 ) - { - if ( a2 == 57 ) - v7 = pNPCTopics[512].pText; // Baby dragon - else - v7 = (const CHAR *)pNPCStats->pProfessions[v5->uProfession].pBenefits; - lpsz = v7; - if ( !v7 ) - { - lpsz = (LPCSTR)pNPCStats->pProfessions[v5->uProfession].pJoinText; - if ( !lpsz ) - lpsz = ""; - } - a1.Hint = 0; - a1.uFrameX = 38; - a1.uFrameY = 60; - a1.uFrameWidth = 276; - a1.uFrameZ = 313; - a1.uFrameHeight = pFontArrus->CalcTextHeight(lpsz, &a1, 0, 0) - + 2 * LOBYTE(pFontArrus->uFontHeight) - + 24; - if ( (signed int)a1.uFrameHeight < 130 ) - a1.uFrameHeight = 130; - a1.uFrameWidth = 400; - a1.uFrameZ = a1.uFrameX + 399; - a1.DrawMessageBox(0); - sprintf(pTmpBuf2, "NPC%03d", v6->uPortraitID); - v8 = pIcons_LOD->LoadTexture(pTmpBuf2, TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed( - a1.uFrameX + 22, - a1.uFrameY + 36, - (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0)); - v9 = v6->uProfession; - if ( v9 ) - { - v10 = v6->pName; - v11 = pTmpBuf; - sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]); - } - else - { - v12 = v6->pName; - v11 = pTmpBuf; - strcpy(pTmpBuf, v12); - } - v13 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u); - a1.uFrameWidth -= 24; - a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; - v14 = BuilDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); - a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0); - } - } - } -} - @@ -11197,26 +10892,6 @@ } } -//----- (004178C4) -------------------------------------------------------- -void __cdecl sub_4178C4() -{ - if ( pArcomageGame->bGameInProgress == 1 ) - { - if (pAsyncMouse) - pArcomageGame->stru1.field_0 = 7; - } -} - -//----- (004178E1) -------------------------------------------------------- -void __cdecl sub_4178E1() -{ - if ( pArcomageGame->bGameInProgress == 1 ) - { - if (pAsyncMouse) - pArcomageGame->stru1.field_0 = 8; - } -} - //----- (004178FE) -------------------------------------------------------- unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2) {
--- a/mm7_6.cpp Wed May 22 22:26:31 2013 +0400 +++ b/mm7_6.cpp Thu May 23 03:32:36 2013 +0200 @@ -7819,12 +7819,4 @@ } } } - if (pGame->pKeyboardInstance->bUsingAsynKeyboard) - { - AsyncKeyboard::LeaveCriticalSection(); - //v16 = pAsyncKeyboard; - AsyncKeyboard::EnterCriticalSection(); - memset((char *)pAsyncKeyboard + 521, 0, 0x100u); - AsyncKeyboard::LeaveCriticalSection(); - } }
--- a/mm7_data.cpp Wed May 22 22:26:31 2013 +0400 +++ b/mm7_data.cpp Thu May 23 03:32:36 2013 +0200 @@ -692,18 +692,6 @@ int bWinNT4_0; // weak __int16 word_4E8152[11] = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30}; -char byte_4E8394[204] = -{ - 0, 0, 0, 0, 1, 1, 2, 3, 0, 4, 5, 6, 7, 8, 10, 9, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, - 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 1, - 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0 -}; stru355 stru_4E82A4 = {0x20, 0x41, 0, 0x20, 0xFF0000, 0xFF00, 0xFF, 0xFF000000}; stru355 stru_4EFCBC = {0x20, 0x41, 0, 0x10, 0x7C00, 0x3E0, 0x1F, 0x8000}; char byte_4E94D0 = 5; // weak @@ -1511,10 +1499,6 @@ int aborting_app; // weak int dword_720020_zvalues[100]; int dword_7201B0_zvalues[299]; -int dword_72065C[777]; // weak -int dword_720660[777]; // idb -int dword_7207EC[777]; // weak -int dword_7207F0[777]; // idb int uTextureID_720980; // weak int _720984_unused; // weak char _72098C_unused; // weak
--- a/mm7_data.h Wed May 22 22:26:31 2013 +0400 +++ b/mm7_data.h Thu May 23 03:32:36 2013 +0200 @@ -482,7 +482,6 @@ extern int bWinNT4_0; // weak extern __int16 word_4E8152[11]; extern char byte_4E8168[7][14]; -extern char byte_4E8394[]; // weak #include "Texture.h" extern stru355 stru_4E82A4;// = {0x20, 0x41, 0, 0x20, 0xFF0000, 0xFF00, 0xFF, 0xFF000000}; extern stru355 stru_4EFCBC;// = {0x20, 0x41, 0, 0x10, 0x7C00, 0x3E0, 0x1F, 0x8000}; @@ -995,9 +994,6 @@ extern int aborting_app; // weak extern int dword_720020_zvalues[100]; extern int dword_7201B0_zvalues[299]; -extern int dword_72065C[]; // weak -extern int dword_720660[]; // idb -extern int dword_7207EC[]; // weak extern int dword_7207F0[]; // idb extern int uTextureID_720980; // weak extern int _720984_unused; // weak @@ -1262,8 +1258,6 @@ void __thiscall sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(struct Vec2_int_ *_this); void UI_OnMouseLeftClick(int *pXY); // idb void __thiscall sub_417871(int *pXY); -void sub_4178C4(); -void sub_4178E1(); unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2); signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx); // idb void __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2); // idb @@ -1480,14 +1474,12 @@ enum MENU_STATE GetCurrentMenuID(); void *__thiscall output_debug_string(void *_this, std::string a2, const char *a3, int a4); std::string *__fastcall _4678E2_make_error_string(std::string *a1, int line, std::string file); -int __thiscall sub_467D5D(int _this); -void __thiscall sub_467E7F_EquipBody(unsigned int uEquipType); // idb +#include "Items.h" +void sub_467E7F_EquipBody(ITEM_EQUIP_TYPE uEquipType); // idb void CreateMsgScrollWindow(signed int mscroll_id); void __cdecl free_book_subwindow(); void CreateScrollWindow(); void __cdecl OnPaperdollLeftClick(); -int __thiscall UnprojectX(int x); -int __thiscall UnprojectY(int _this); void OnPressSpace(); char __fastcall DoInteractionWithTopmostZObject(int a1, int a2); int __fastcall sub_46A6AC(int a1, int a2, int a3);