Mercurial > mm7
diff mm7_2.cpp @ 1306:13b7be8b06a0
Слияние
author | Ritor1 |
---|---|
date | Sun, 23 Jun 2013 14:27:57 +0600 |
parents | dcc52e17b517 8c2f689b5f0b |
children | ad903bb5b702 |
line wrap: on
line diff
--- a/mm7_2.cpp Sun Jun 23 14:27:32 2013 +0600 +++ b/mm7_2.cpp Sun Jun 23 14:27:57 2013 +0600 @@ -63,11 +63,10 @@ #include "stru298.h" #include "Events2D.h" #include "Log.h" -#include "UIHouses.h" +#include "UI\UIHouses.h" #include "texts.h" #include "MM7.h" #include "Lights.h" -#include "Arcomage.h" //----- (004BB756) -------------------------------------------------------- signed int __fastcall sub_4BB756(signed int a1) @@ -460,7 +459,6 @@ } // F8B1B4: using guessed type int dword_F8B1B4; - // 4EE088: using guessed type __int16 word_4EE088_sound_ids[]; //----- (004BC109) -------------------------------------------------------- @@ -674,17 +672,6 @@ pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0); } -//----- (004BCA33) -------------------------------------------------------- -void UI_CreateEndConversationButton() -{ - pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, - pGlobalTXT_LocalizationStrings[74], //"End Conversation" - pIcons_LOD->GetTexture(uExitCancelTextureId), 0); - pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); -} - //----- (004BD8B5) -------------------------------------------------------- signed int __cdecl sub_4BD8B5() { @@ -783,24 +770,6 @@ return 0; } -//----- (004BE386) -------------------------------------------------------- -void __fastcall log_error(const char *pMessage) -{ - const char *v1; // edi@1 - FILE *f; // eax@1 - FILE *v3; // esi@1 - - v1 = pMessage; - f = fopen("errorlog.txt", "a"); - v3 = f; - if ( f ) - { - fprintf(f, "%s\n", v1); - fclose(v3); - fflush(v3); - } -} - //----- (004BF91E) -------------------------------------------------------- unsigned int __thiscall GameOverMenu(void *ecx0) { @@ -2804,6 +2773,62 @@ } } +//----- (00450B0A) -------------------------------------------------------- +bool __fastcall SpawnActor(unsigned int uMonsterID) +{ + unsigned int v1; // ebx@1 + bool result; // eax@2 + MonsterDesc *v3; // esi@5 + MonsterInfo *v4; // edi@5 + Vec3_int_ v5; // ST08_12@5 + unsigned int v6; // ecx@5 + Actor *v7; // eax@7 + Actor actor; // [sp+4h] [bp-350h]@5 + Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5 + + v1 = uMonsterID; + if ( uNumActors == 499 ) + { + result = 0; + } + else + { + if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters ) + v1 = 0; + v3 = &pMonsterList->pMonsters[v1]; + v4 = &pMonsterStats->pInfos[v1 + 1]; + memset(&actor, 0, 0x344u); + strcpy(actor.pActorName, v4->pName); + actor.sCurrentHP = LOWORD(v4->uHP); + memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], 0x58u); + actor.word_000086_some_monster_id = v1 + 1; + actor.uActorRadius = v3->uMonsterRadius; + actor.uActorHeight = v3->uMonsterHeight; + actor.uMovementSpeed = v3->uMovementSpeed; + v5 = pParty->vPosition; + Vec3_int_::Rotate(200, pParty->sRotationY, 0, v5, &pOut.x, &pOut.z, &pOut.y); + actor.vInitialPosition.x = pOut.x; + actor.vPosition.x = pOut.x; + actor.uTetherDistance = 256; + actor.vInitialPosition.y = LOWORD(pOut.z); + actor.vPosition.y = LOWORD(pOut.z); + actor.vInitialPosition.z = LOWORD(pOut.y); + actor.vPosition.z = LOWORD(pOut.y); + pSprites_LOD->DeleteSomeSprites(); + pPaletteManager->ResetNonTestLocked(); + v6 = uNumActors - 1; + if ( dword_5C6DF8 == 1 ) + { + dword_5C6DF8 = 0; + v6 = uNumActors++; + } + v7 = &pActors[v6]; + memcpy(v7, &actor, 0x344u); + v7->PrepareSprites(1); + result = 1; + } + return result; +} // 5C6DF8: using guessed type int dword_5C6DF8; //----- (00450DA3) -------------------------------------------------------- @@ -3735,213 +3760,120 @@ } } -//----- (004583B0) -------------------------------------------------------- -LevelDecoration::LevelDecoration() -{ - this->field_1A = 0; - this->field_18 = 0; - this->vPosition.z = 0; - this->vPosition.y = 0; - this->vPosition.x = 0; - this->uDecorationDescID = 0; - this->field_2 = 0; - this->field_16_event_id = 0; - this->uCog = 0; -} - -//----- (0045E03A) -------------------------------------------------------- -unsigned short * MakeScreenshot( signed int width, signed int height ) +//----- (0045828B) -------------------------------------------------------- +unsigned int __fastcall GetSpellColor(signed int a1) { - //signed int v2; // edi@1 - unsigned __int16 *v3; // ebx@1 - int v4; // edx@7 - unsigned __int8 v5; // cf@9 - unsigned int v6; // ecx@9 - unsigned __int16 *v7; // edi@9 - int j; // ecx@9 - //unsigned __int16 *v9; // edi@15 - //int v10; // ecx@15 - //LONG v11; // esi@15 - //signed __int64 v12; // qax@18 - //unsigned int v13; // ST10_4@21 - HRESULT v14; // eax@21 - int v15; // edi@29 - signed __int64 v16; // qax@30 - signed int v17; // edx@34 - unsigned __int16 *v18; // edi@36 - int k; // ecx@36 - DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 - unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 - float v23; // [sp+84h] [bp-20h]@1 - unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 - float v25; // [sp+8Ch] [bp-18h]@1 - unsigned int v26; // [sp+90h] [bp-14h]@17 - //int v27; // [sp+94h] [bp-10h]@1 - int v28; // [sp+98h] [bp-Ch]@16 - int v29; // [sp+9Ch] [bp-8h]@15 - //int v30; // [sp+A0h] [bp-4h]@1 - - //v30 = width; - //v2 = height; - //v27 = height; - v23 = game_viewport_width / (double)width; - v25 = game_viewport_height / (double)height; - - pPixels = (unsigned __int16 *)malloc(2 * height * width); - memset(pPixels, 0 , 2 * height * width); - - v3 = pPixels; - if ( pRenderer->pRenderD3D ) - { - pRenderer->BeginSceneD3D(); - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - pIndoor->Draw(); - else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pOutdoor->Draw(); - - pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); - memset(&Dst, 0, 0x7Cu); - Dst.dwSize = sizeof(Dst); - - if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) - { - auto src = (unsigned __int16 *)Dst.lpSurface; - auto src_width = (Dst.lPitch / sizeof(short)); - auto src_height = Dst.dwHeight; - auto dst = pPixels; - for (uint y = 0; y < height; ++y) + unsigned __int16 v1; // dx@3 + unsigned __int16 v2; // cx@6 + unsigned __int16 v4; // [sp-4h] [bp-4h]@3 + + if ( a1 < 1 ) + { + if ( a1 < 12 ) + { + if ( a1 < 23 ) { - //uint src_y = (game_viewport_y + y * v25) * (Dst.lPitch / sizeof(short)); - uint src_y = game_viewport_y + y * v25; - assert(game_viewport_y + y * v25 < src_height); - assert(y < height); - - for (uint x = 0; x < width; ++x) + if ( a1 < 34 ) { - //uint src_x = game_viewport_x + x * v23; - uint src_x = game_viewport_x + x * v23; - assert(src_x < src_width); - assert(x < width); - - dst[y * width + x] = (((63*y)/117) << 5) | 31*x/155;//31*y/117;//src[src_y * src_width + src_x]; + if ( a1 < 45 ) + { + if ( a1 < 56 ) + { + if ( a1 < 67 ) + { + if ( a1 < 78 ) + { + if ( a1 < 89 ) + goto LABEL_31; + goto LABEL_28; + } +LABEL_25: + if ( a1 < 89 ) + { + v4 = 155; + v2 = 255; + goto LABEL_30; + } +LABEL_28: + if ( a1 < 100 ) + { + v4 = 240; + v2 = 192; + goto LABEL_30; + } +LABEL_31: + v4 = 0; + v1 = 0; + goto LABEL_32; + } +LABEL_21: + if ( a1 < 78 ) + { + v4 = 0; + v1 = 128; + goto LABEL_23; + } + goto LABEL_25; + } +LABEL_18: + if ( a1 < 67 ) + { + v4 = 255; + v1 = 15; + v2 = 235; + return TargetColor(v2, v1, v4); + } + goto LABEL_21; + } +LABEL_15: + if ( a1 < 56 ) + { + v2 = 225; + goto LABEL_13; + } + goto LABEL_18; } +LABEL_11: + if ( a1 < 45 ) + { + v2 = 128; +LABEL_13: + v4 = v2; +LABEL_30: + v1 = v2; + return TargetColor(v2, v1, v4); + } + goto LABEL_15; } - ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); - } - else - { - __debugbreak(); // unrefactored - v4 = height; - if ( height > 0 ) +LABEL_8: + if ( a1 < 34 ) { - do - { - if ( width > 0 ) - { - v5 = width & 1; - v6 = (unsigned int)width >> 1; - memset(v3, 0, 4 * ((unsigned int)width >> 1)); - v7 = &v3[2 * v6]; - for ( j = v5; j; --j ) - { - *v7 = 0; - ++v7; - } - v3 += width; - } - --v4; - } - while ( v4 ); + v4 = 255; + v1 = 128; +LABEL_32: + v2 = 0; + return TargetColor(v2, v1, v4); } + goto LABEL_11; } } else { - pRenderer->BeginScene(); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - pIndoor->Draw(); - } - else - { - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - pOutdoor->Draw(); - } - _this = pRenderer->pTargetSurface; - v26 = pRenderer->uTargetSurfacePitch; - if ( pRenderer->pTargetSurface ) - { - v29 = 0; - if ( height > 0 ) - { - do - { - v28 = 0; - if ( width > 0 ) - { - v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); - do - { - v16 = (signed __int64)((double)v28++ * v23 + 8.0); - *v3 = _this[v15 + (int)v16]; - ++v3; - } - while ( v28 < width ); - } - ++v29; - } - while ( v29 < height ); - } - } - else - { - if ( height > 0 ) - { - v17 = height; - do - { - if ( width > 0 ) - { - memset(v3, 0, 4 * ((unsigned int)width >> 1)); - v18 = &v3[2 * ((unsigned int)width >> 1)]; - for ( k = width & 1; k; --k ) - { - *v18 = 0; - ++v18; - } - v3 += width; - } - --v17; - } - while ( v17 ); - } - } - pRenderer->EndScene(); - } - return pPixels; -} - -//----- (0046080D) -------------------------------------------------------- -void __cdecl sub_46080D() -{ - pAllocator->FreeChunk(ptr_6A0D08); - ptr_6A0D08 = 0; - _6A0D0C_txt_lod_loading = 0; -} - -//----- (0046082C) -------------------------------------------------------- -bool Initialize_GamesLOD_NewLOD() -{ - pGames_LOD = new LODWriteableFile; - pGames_LOD->AllocSubIndicesAndIO(300, 0); - if (pGames_LOD->LoadFile("data\\games.lod", 1)) - { - pNew_LOD = new LODWriteableFile; - pNew_LOD->AllocSubIndicesAndIO(300, 100000); - return true; - } - return false; + if ( a1 < 12 ) + { + v4 = 0; + v1 = 85; +LABEL_23: + v2 = 255; + return TargetColor(v2, v1, v4); + } + } + if ( a1 >= 23 ) + goto LABEL_8; + v4 = 255; + v1 = 212; + v2 = 150; + return TargetColor(v2, v1, v4); } //----- (004610AA) -------------------------------------------------------- @@ -4367,6 +4299,35 @@ pIcons_LOD->_4114F2(); } +void set_stru1_field_8_InArcomage(int inValue) +{ + switch(inValue) + { + case 91:LOBYTE(pArcomageGame->stru1.field_8) = 123;break; + case 92:LOBYTE(pArcomageGame->stru1.field_8) = 124;break; + case 93:LOBYTE(pArcomageGame->stru1.field_8) = 125;break; + case 96:LOBYTE(pArcomageGame->stru1.field_8) = 126;break; + case 61:LOBYTE(pArcomageGame->stru1.field_8) = 43;break; + case 55:LOBYTE(pArcomageGame->stru1.field_8) = 38;break; + case 56:LOBYTE(pArcomageGame->stru1.field_8) = 42;break; + case 57:LOBYTE(pArcomageGame->stru1.field_8) = 40;break; + case 59:LOBYTE(pArcomageGame->stru1.field_8) = 58;break; + case 54:LOBYTE(pArcomageGame->stru1.field_8) = 94;break; + case 50:LOBYTE(pArcomageGame->stru1.field_8) = 64;break; + case 51:LOBYTE(pArcomageGame->stru1.field_8) = 35;break; + case 52:LOBYTE(pArcomageGame->stru1.field_8) = 36;break; + case 53:LOBYTE(pArcomageGame->stru1.field_8) = 37;break; + case 49:LOBYTE(pArcomageGame->stru1.field_8) = 33;break; + case 39:LOBYTE(pArcomageGame->stru1.field_8) = 34;break; + case 44:LOBYTE(pArcomageGame->stru1.field_8) = 60;break; + case 46:LOBYTE(pArcomageGame->stru1.field_8) = 62;break; + case 47:LOBYTE(pArcomageGame->stru1.field_8) = 63;break; + case 48:LOBYTE(pArcomageGame->stru1.field_8) = 41;break; + default:LOBYTE(pArcomageGame->stru1.field_8) = inValue;break; + } +} + + //----- (004637EB) -------------------------------------------------------- int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam) { @@ -6717,782 +6678,6 @@ // 720980: using guessed type int uTextureID_720980; -//----- (00467F9F) -------------------------------------------------------- -void __cdecl free_book_subwindow() -{ - if ( pGUIWindow_ScrollWindow ) - { - pGUIWindow_ScrollWindow->Release(); - pGUIWindow_ScrollWindow = 0; - } -} - -//----- (00468F8A) -------------------------------------------------------- -void __cdecl OnPaperdollLeftClick() -{ - int v1; // ecx@1 - unsigned int v2; // edi@1 - unsigned int v3; // edx@4 - unsigned int pSkillType; // esi@5 - unsigned __int16 v5; // ax@7 - unsigned int v6; // edi@19 - int v7; // esi@27 - unsigned int v8; // eax@29 - int v9; // edx@32 - int v10; // esi@34 - int v11; // eax@34 - int v12; // esi@38 - int v13; // eax@38 - char v14; // zf@38 - int v15; // esi@42 - int v16; // eax@42 - int v17; // eax@44 - unsigned int v18; // ecx@55 - unsigned int v19; // eax@55 - int v20; // esi@60 - int v21; // eax@60 - unsigned int v22; // eax@61 - unsigned int v23; // eax@62 - int v24; // esi@65 - int v25; // eax@65 - unsigned int v26; // eax@69 - int v27; // esi@81 - int v28; // eax@81 - int v29; // esi@84 - int v30; // eax@84 - int v31; // eax@85 - unsigned int v32; // ecx@88 - unsigned int v33; // eax@88 - int v34; // esi@90 - unsigned int v35; // eax@91 - int v36; // esi@93 - int v37; // edi@93 - ItemGen *v38; // edi@93 - __int16 v39; // dx@99 - ItemGen _this; // [sp+Ch] [bp-40h]@1 - unsigned int v48; // [sp+30h] [bp-1Ch]@88 - unsigned int v49; // [sp+34h] [bp-18h]@57 - unsigned int v50; // [sp+38h] [bp-14h]@50 - int v51; // [sp+3Ch] [bp-10h]@1 - unsigned int v52; // [sp+40h] [bp-Ch]@5 - //int v53; // [sp+44h] [bp-8h]@1 - //unsigned int v54; // [sp+48h] [bp-4h]@1 - - v51 = 0; - _this.Reset(); - //v0 = pPlayers[uActiveCharacter]; - v1 = pPlayers[uActiveCharacter]->pEquipment.uMainHand; - v2 = pPlayers[uActiveCharacter]->pEquipment.uShield; - //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; - //v53 = v1; - if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1 - 1]].uEquipType == 1 ) - v51 = v1; - v3 = pParty->pPickedItem.uItemID; - if ( pParty->pPickedItem.uItemID ) - { - v52 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType; - pSkillType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType; - if ( pSkillType == 4 ) - { - if ( v2 ) - { - LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); - if ( (signed int)SkillToMastery(v5) < 3 ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - v3 = pParty->pPickedItem.uItemID; - } - } - else - { - if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2) - && v1 - && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uSkillType == 4 ) - { - LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); - if ( (signed int)SkillToMastery(v5) < 3 ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - } - } - if ( !pPlayers[uActiveCharacter]->CanEquip_RaceAndAlignmentCheck(v3) ) - { - - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - if ( pParty->pPickedItem.uItemID == 604 ) - { - pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)3); - WetsuitOn(uActiveCharacter); - return; - } - v6 = v52; - switch ( v52 ) - { - case 2u: - case 3u: - case 5u: - case 6u: - case 7u: - case 8u: - case 9u: - case 0xBu: - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) && (v6 != 3 || bUnderwater) ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)v6); - if ( pParty->pPickedItem.uItemID == 604 ) - WetsuitOff(uActiveCharacter); - return; - case 0xAu: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - v52 = 10; - v7 = (int)&pPlayers[uActiveCharacter]->pEquipment.uRings; - while ( 1 ) - { - if ( !*(int *)v7 ) - { - v8 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v8 & 0x80000000u) == 0 ) - { - v9 = v52; - pParty->pPickedItem.uBodyAnchor = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v8], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v8])); - *(&pPlayers[uActiveCharacter]->pEquipment.uShield + v9) = v8 + 1; - pMouse->RemoveHoldingItem(); - break; - } - } - ++v52; - v7 += 4; - if ( (signed int)v52 > 15 ) - break; - } - if ( v52 == 16 ) - { - v52 = pPlayers[uActiveCharacter]->pEquipment.uRings[6] - 1; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v10 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v52); - *(char *)(v10 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v10 + 532)); - _this.uBodyAnchor = 16; - v11 = v52 + 1; - memcpy((void *)(v10 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uRings[6] = v11; - } - return; - case 4u: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - if ( v2 ) - { - --v2; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); - *(char *)(v12 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v12 + 532)); - _this.uBodyAnchor = 1; - v13 = v2 + 1; - v14 = v51 == 0; - memcpy((void *)(v12 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uShield = v13; - if ( v14 ) - return; - } - else - { - v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v52 & 0x80000000u) != 0 ) - return; - if ( !v51 ) - { - pParty->pPickedItem.uBodyAnchor = 1; - v17 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); - pPlayers[uActiveCharacter]->pEquipment.uShield = v17; - pMouse->RemoveHoldingItem(); - return; - } - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v1 - 1)); - *(char *)(v15 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v15 + 532)); - _this.uBodyAnchor = 1; - v16 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); - pPlayers[uActiveCharacter]->pEquipment.uShield = v16; - } - pPlayers[uActiveCharacter]->pEquipment.uMainHand = 0; - return; - case 0u: - case 0xCu: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) - && pParty->pPickedItem.uItemID != 64 - && pParty->pPickedItem.uItemID != 65 ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - v50 = 0; - if ( pSkillType == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0) - || pSkillType == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 ) - { - - v18 = pMouse->uMouseClickX; - v19 = pMouse->uMouseClickY; - - v49 = v19; - if ( (signed int)v18 >= 560 ) - { - if ( !v51 ) - { - if ( v2 ) - { - --v2; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); - *(char *)(v20 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v20 + 532)); - _this.uBodyAnchor = 1; - v21 = v2 + 1; - v14 = v52 == 12; - memcpy((void *)(v20 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uShield = v21; - if ( !v14 ) - return; - v22 = _this.uItemID; - v50 = v22; - if ( v50 ) - { - __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); - } - break; - } - v23 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v23 & 0x80000000u) != 0 ) - return; - pParty->pPickedItem.uBodyAnchor = 1; - v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItems[v23]; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v23], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v23])); - pPlayers[uActiveCharacter]->pEquipment.uShield = v23 + 1; - pMouse->RemoveHoldingItem(); - if ( v52 != 12 ) - return; - v22 = *(int *)v50; - v50 = v22; - if ( v50 ) - { - __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); - } - break; - } - } - } - if ( !v1 ) - { - v26 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v26 & 0x80000000u) != 0 ) - return; - pParty->pPickedItem.uBodyAnchor = 2; - v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItems[v26]; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v26], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v26])); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v26 + 1; - pMouse->RemoveHoldingItem(); - if ( v52 != 12 ) - return; - v22 = *(int *)v50; - v50 = v22; - if ( v50 ) - { - __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); - } - break; - } - --v1; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); - *(char *)(v24 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v24 + 532)); - _this.uBodyAnchor = 2; - v25 = v1 + 1; - v14 = v52 == 12; - memcpy((void *)(v24 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v25; - if ( v14 ) - v50 = _this.uItemID; - if ( v51 ) - pPlayers[uActiveCharacter]->pEquipment.uShield = 0; - if ( v50 ) - { - __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); - } - break; - case 1u: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - if ( v1 ) - { - if ( v2 ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - --v1; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); - *(char *)(v27 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v27 + 532)); - _this.uBodyAnchor = 2; - v28 = v1 + 1; - memcpy((void *)(v27 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v28; - } - else - { - v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v52 & 0x80000000u) == 0 ) - { - if ( v2 ) - { - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v2 - 1)); - *(char *)(v29 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v29 + 532)); - _this.uBodyAnchor = 2; - v30 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); - pPlayers[uActiveCharacter]->pEquipment.uShield = 0; - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v30; - } - else - { - pParty->pPickedItem.uBodyAnchor = 2; - v31 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v31; - pMouse->RemoveHoldingItem(); - } - } - } - return; - default: - pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(uActiveCharacter, 0); - return; - } - return; - } - - v32 = pMouse->uMouseClickX; - v33 = pMouse->uMouseClickY; - - v34 = pRenderer->pActiveZBuffer[v32 + pSRZBufferLineOffsets[v33]] & 0xFFFF; - if ( v34 ) - { - v36 = v34 - 1; - v37 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v36); - v50 = v37; - v38 = (ItemGen *)(v37 + 532); - v14 = v38->uItemID == 604; - v52 = pItemsTable->pItems[v38->uItemID].uEquipType; - if ( v14 ) - { - if ( bUnderwater ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - WetsuitOff(uActiveCharacter); - } - if ( unk_50C9A0 ) - { - *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; - *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; - v39 = v52; - *((int *)pGUIWindow_Settings->ptr_1C + 3) = v36; - *((short *)pGUIWindow_Settings->ptr_1C + 3) = v39; - ptr_50C9A4 = v38; - unk_50C9A0 = 0; - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pMouse->SetCursorBitmap("MICON1"); - dword_50C9D4 = 0; - dword_50C9D0 = 113; - dword_50C9D8 = 256; - } - else - { - if ( !ptr_50C9A4 ) - { - pParty->SetHoldingItem(v38); - *(&pPlayers[uActiveCharacter]->uBirthYear + *(char *)(v50 + 556)) = 0; - v38->Reset(); - } - } - } - else - { - v35 = pPlayers[uActiveCharacter]->pEquipment.uBow; - if ( v35 ) - { - auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35 - 1]; - pParty->SetHoldingItem(_a); - _a->Reset(); - pPlayers[uActiveCharacter]->pEquipment.uBow = 0; - } - } -} - - -//----- (0046A14B) -------------------------------------------------------- -void OnPressSpace() -{ - //SHORT v0; // ax@2 - int *v1; // eax@2 - char *v2; // ebx@5 - unsigned int v3; // esi@5 - signed int v4; // edi@7 - unsigned int v5; // edx@7 - int v6; // ecx@8 - int v7; // eax@8 - int v8; // ecx@17 - int *v9; // esi@22 - signed int v10; // ebx@22 - int i; // edi@23 - int v12; // edx@24 - int v13; // ecx@24 - int j; // esi@28 - int v16; // [sp+4h] [bp-1Ch]@0 - char *v17; // [sp+8h] [bp-18h]@5 - unsigned int v18; // [sp+Ch] [bp-14h]@5 - int v19; // [sp+10h] [bp-10h]@8 - int *v20; // [sp+14h] [bp-Ch]@5 - int *v21; // [sp+18h] [bp-8h]@7 - int v22; // [sp+1Ch] [bp-4h]@4 - - if ( pRenderer->pRenderD3D ) - { - pGame->PickKeyboard(GetAsyncKeyState(VK_CONTROL) & 0x8001, &vis_sprite_filter_3, &vis_door_filter); - 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 - if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) - { - v2 = (char *)v1 - 50; - v1 = (int *)((char *)v1 + 50); - v3 = 640 * viewparams->uScreen_topL_Y; - v17 = v2; - v20 = v1; - v18 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1; - do - { - if ( (signed int)v2 < (signed int)v20 ) - { - v1 = &pRenderer->pActiveZBuffer[(int)&v2[v3]]; - v21 = &pRenderer->pActiveZBuffer[(int)&v2[v3]]; - v4 = v22; - v5 = (((char *)v20 - v2 - 1) >> 1) + 1; - do - { - v6 = 0; - v7 = *v1 & 0xFFFF; - v19 = 0; - if ( v4 > 0 ) - { - do - { - if ( dword_7207F0[v6] == v7 ) - break; - ++v6; - v19 = v6; - } - while ( v6 < v22 ); - } - if ( PID_TYPE(v7) == OBJECT_Decoration) - { - v16 = (unsigned int)PID_ID(v7); - if ( (signed int)(((unsigned int)*v21 >> 16) - - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)PID_ID(v7)].uDecorationDescID].uRadius) <= 512 ) - if ( v19 == v22 && v4 < 100 ) - { - ++v22; - ++v4; - v8 = *v21; - dword_7207F0[v4 - 1] = v7; - dword_720660[v4 - 1] = v8; - } - } - else if ( (unsigned int)*v21 <= 0x2000000 ) - { - if ( v19 == v22 && v4 < 100 ) - { - ++v22; - ++v4; - v8 = *v21; - dword_7207F0[v4 - 1] = v7; - dword_720660[v4 - 1] = v8; - } - } - v1 = v21 + 2; - --v5; - v21 += 2; - } - while ( v5 ); - v2 = v17; - } - v3 += 1280; - --v18; - } - while ( v18 ); - } - if ( v22 > 0 ) - { - v9 = dword_720660; - v10 = 1; - do - { - for ( i = v10; i < v22; ++i ) - { - v12 = *v9; - v13 = dword_720660[i]; - if ( v13 < *v9 ) - { - *v9 = v13; - dword_720660[i] = v12; - } - } - ++v10; - ++v9; - LOBYTE(v1) = v10 - 1; - } - while ( v10 - 1 < v22 ); - } - for ( j = 0; j < v22; ++j ) - { - LOBYTE(v1) = DoInteractionWithTopmostZObject(dword_720660[j] & 0xFFFF, v16); - if ( !(char)v1 ) - break; - } -} - -//----- (0046A334) -------------------------------------------------------- -char __fastcall DoInteractionWithTopmostZObject(int a1, int a2) -{ - int v2; // edx@1 - BLVFace *v4; // eax@9 - unsigned int v5; // ecx@9 - unsigned __int16 v6; // ax@11 - //ODMFace *v7; // eax@16 - LevelDecoration *v8; // esi@19 - __int16 v9; // ax@19 - int v10; // eax@22 - int v11; // ecx@22 - int v12; // edi@23 - Actor *v13; // esi@23 - unsigned __int16 v14; // ax@23 - unsigned __int16 v15; // ax@33 - const char *v16; // eax@34 - int v17; // edi@36 - int v18; // eax@36 - ItemGen *v19; // esi@39 - unsigned int v20; // eax@39 - int v21; // ecx@40 - std::string v22; // [sp-18h] [bp-2Ch]@5 - const char *v23; // [sp-8h] [bp-1Ch]@5 - int v24; // [sp-4h] [bp-18h]@5 - char v25; // [sp+8h] [bp-Ch]@5 - int v26; // [sp+Ch] [bp-8h]@1 - int a3; // [sp+13h] [bp-1h]@5 - - v26 = a2; - v2 = a1; - switch ( PID_TYPE(a1) ) - { - case OBJECT_Item: // take the item - v17 = PID_ID(a1); - v26 = PID_ID(a1); - v18 = PID_ID(a1); - if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 - || v17 >= 1000 - || !pSpriteObjects[v18].uObjectDescID ) - return 1; - v19 = &pSpriteObjects[v18].stru_24; - v20 = pSpriteObjects[v18].stru_24.uItemID; - if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD) - { - party_finds_gold(v19->uSpecEnchantmentType, 0); - viewparams->bRedrawGameUI = 1; - v21 = v17; - } - else - { - if ( pParty->pPickedItem.uItemID ) - return 1; - v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName; - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v24); - ShowStatusBarString(pTmpBuf2.data(), 2u); - if ( v19->uItemID == 506 ) - _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); - if ( v19->uItemID == 455 ) - _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); - if ( !pParty->AddItem(v19) ) - pParty->SetHoldingItem(v19); - v21 = v26; - } - SpriteObject::OnInteraction(v21); - break; - - case OBJECT_Actor: - v12 = PID_ID(a1); - v13 = &pActors[PID_ID(a1)]; - v14 = v13->uAIState; - if ( v14 == 4 || v14 == 17 ) - return 1; - if ( v14 == 5 ) - { - stru_50C198.LootActor(&pActors[PID_ID(a1)]); - } - else - { - if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() ) - { - Actor::AI_FaceObject(v12, 4u, 0, 0); - if ( v13->sNPC_ID ) - { - pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0); - } - else - { - v15 = pNPCStats->pGroups_copy[v13->uGroup]; - if ( v15 ) - { - v16 = pNPCStats->pCatchPhrases[v15]; - if ( v16 ) - { - pParty->uFlags |= 2u; - strcpy(byte_5B0938.data(), v16); - sub_4451A8_press_any_key(0, 0, 0); - } - } - } - } - } - break; - - case OBJECT_Decoration: - v8 = &pLevelDecorations[PID_ID(a1)]; - v9 = v8->field_16_event_id; - if ( v9 ) - { - EventProcessor(v9, a1, 1); - LOBYTE(v8->field_2) |= 8u; - } - else - { - if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() ) - return 1; - v10 = v8->_idx_in_stru123; - v24 = 1; - v11 = stru_5E4C90._decor_events[v10 - 75] + 380; - activeLevelDecoration = v8; - EventProcessor(v11, 0, 1); - activeLevelDecoration = NULL; - } - break; - - default: - MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); - return 1; - - case OBJECT_BModel: - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - { - int bmodel_id = a1 >> 9, - face_id = PID_ID(a1) & 0x3F; - if (bmodel_id >= pOutdoor->uNumBModels) - return 1; - auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id]; - if (face->uAttributes & 0x100000 || face->sCogTriggeredID == 0 ) - return 1; - EventProcessor((signed __int16)face->sCogTriggeredID, v2, 1); - } - else - { - v4 = &pIndoor->pFaces[PID_ID(a1)]; - v5 = v4->uAttributes; - if ( !(v5 & 0x2000000) ) - { - ShowNothingHereStatus(); - return 1; - } - if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 ) - return 1; - if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) - EventProcessor((signed __int16)v6, v2, 1); - } - return 0; - break; - } - return 0; -} // 4E28F8: using guessed type int pCurrentScreen; //----- (0046A6AC) --------------------------------------------------------