# HG changeset patch # User Ritor1 # Date 1362367358 -21600 # Node ID 1bd8758f50b825d6e085e735f184e5fa95653f56 # Parent cf366ba68de51da057edf5b455acf50677f76351# Parent 0ca16f606be8a322a772fa2b2e0d50c72a875f91 Слияние diff -r cf366ba68de5 -r 1bd8758f50b8 Actor.cpp --- a/Actor.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/Actor.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -1,7 +1,7 @@ #include #include "Actor.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "Math.h" #include "Party.h" #include "Outdoor.h" @@ -94,14 +94,14 @@ } //----- (004485A7) -------------------------------------------------------- -void Actor::GiveItem(unsigned int uActorID, unsigned int uItemID, unsigned int bGive) +void Actor::GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive) { unsigned int v3; // eax@3 char *v4; // ecx@3 - unsigned int *v5; // eax@8 + int *v5; // eax@8 ItemGen *v6; // ecx@12 - if ( (uActorID & 0x80000000u) == 0 && (signed int)uActorID <= (signed int)(uNumActors - 1) ) + if ( (uActorID >= 0) && (signed int)uActorID <= (signed int)(uNumActors - 1) ) { v3 = uActorID; v4 = (char *)&pActors[uActorID].uCarriedItemID; @@ -469,7 +469,7 @@ float v112; // [sp+3Ch] [bp-94h]@49 int v113; // [sp+40h] [bp-90h]@41 int v114; // [sp+48h] [bp-88h]@41 - LayingItem a1; // [sp+4Ch] [bp-84h]@1 + SpriteObject a1; // [sp+4Ch] [bp-84h]@1 int v116; // [sp+BCh] [bp-14h]@49 AIDirection *v117; // [sp+C0h] [bp-10h]@1 int v118; // [sp+C4h] [bp-Ch]@29 @@ -561,7 +561,7 @@ v10 = v105; LABEL_29: spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - a1.uItemType = stru_4E3ACC[15].field_0; + a1.uType = stru_4E3ACC[15].field_0; v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1); v11 = 0; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -642,7 +642,7 @@ return; } LABEL_159: - a1.uItemType = stru_4E3ACC[spellnum].field_0; + a1.uType = stru_4E3ACC[spellnum].field_0; v119 = 0.0; if ( (signed int)pObjectList->uNumObjects <= 0 ) { @@ -652,7 +652,7 @@ else { v66 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)a1.uItemType != *(short *)v66 ) + while ( (short)a1.uType != *(short *)v66 ) { ++LODWORD(v119); v66 += 56; @@ -790,7 +790,7 @@ pitch = stru_5C6E00->Atan2(v31, (signed __int64)spellnumc); } a1.stru_24.Reset(); - a1.uItemType = stru_4E3ACC[9].field_0; + a1.uType = stru_4E3ACC[9].field_0; spellnumd = 0; if ( (signed int)pObjectList->uNumObjects <= 0 ) { @@ -800,7 +800,7 @@ else { v33 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)a1.uItemType != *(short *)v33 ) + while ( (short)a1.uType != *(short *)v33 ) { ++spellnumd; v33 += 56; @@ -1334,7 +1334,7 @@ v70 = v108; LABEL_179: spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - a1.uItemType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].field_0; + a1.uType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].field_0; v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1); v71 = 0; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -1482,7 +1482,7 @@ signed int v11; // ecx@19 int v12; // eax@19 int v13; // edx@28 - //LayingItem a1; // [sp+Ch] [bp-74h]@1 + //SpriteObject a1; // [sp+Ch] [bp-74h]@1 unsigned int v15; // [sp+7Ch] [bp-4h]@1 signed int v16; // [sp+88h] [bp+8h]@14 signed int v17; // [sp+88h] [bp+8h]@19 @@ -1491,47 +1491,47 @@ v4 = a2; v5 = &pActors[uActorID]; - LayingItem a1; // [sp+Ch] [bp-74h]@1 - //LayingItem::LayingItem(&a1); + SpriteObject a1; // [sp+Ch] [bp-74h]@1 + //SpriteObject::SpriteObject(&a1); result = a3 - 1; switch ( a3 ) { case 1: - a1.uItemType = 545; + a1.uType = 545; goto LABEL_14; case 2: - a1.uItemType = 550; + a1.uType = 550; goto LABEL_14; case 3: - a1.uItemType = 510; + a1.uType = 510; goto LABEL_14; case 4: - a1.uItemType = 500; + a1.uType = 500; goto LABEL_14; case 5: - a1.uItemType = 515; + a1.uType = 515; goto LABEL_14; case 6: - a1.uItemType = 505; + a1.uType = 505; goto LABEL_14; case 7: - a1.uItemType = 530; + a1.uType = 530; goto LABEL_14; case 8: - a1.uItemType = 525; + a1.uType = 525; goto LABEL_14; case 9: - a1.uItemType = 520; + a1.uType = 520; goto LABEL_14; case 10: - a1.uItemType = 535; + a1.uType = 535; goto LABEL_14; case 11: - a1.uItemType = 540; + a1.uType = 540; goto LABEL_14; case 13: - a1.uItemType = 555; + a1.uType = 555; LABEL_14: v16 = 0; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -1541,7 +1541,7 @@ default: return result; } - while ( (short)a1.uItemType != *(short *)v7 ) + while ( (short)a1.uType != *(short *)v7 ) { ++v16; v7 += 56; @@ -1636,14 +1636,14 @@ int v5; // ebx@6 int v6; // ecx@6 int v7; // eax@6 - LayingItem a1; // [sp+Ch] [bp-78h]@1 + SpriteObject a1; // [sp+Ch] [bp-78h]@1 unsigned int v10; // [sp+7Ch] [bp-8h]@1 int v11; // [sp+80h] [bp-4h]@6 v10 = uActorID; v1 = &pActors[uActorID]; v2 = 0; - a1.uItemType = 600; + a1.uType = 600; if ( (signed int)pObjectList->uNumObjects <= 0 ) { LABEL_5: @@ -1692,7 +1692,7 @@ // // // // // // object1 & object2 format : objectType | (objectID << 3) -// // objectType == 2 - LayingItem +// // objectType == 2 - SpriteObject // // objectType == 3 - Actor // // objectType == 4 - Party // // objectType == 5 - Decoration @@ -1755,9 +1755,9 @@ if ( !v5 ) { v19 = v4; - outx = pLayingItems[v19].vPosition.x; - v13 = pLayingItems[v19].vPosition.y; - v14 = pLayingItems[v19].vPosition.z; + outx = pSpriteObjects[v19].vPosition.x; + v13 = pSpriteObjects[v19].vPosition.y; + v14 = pSpriteObjects[v19].vPosition.z; goto LABEL_26; } v7 = v5 - 1; @@ -1865,9 +1865,9 @@ if ( v21 == 2 ) { v30 = v22; - LODWORD(v45) = pLayingItems[v30].vPosition.x; - v27 = pLayingItems[v30].vPosition.y; - v28 = pLayingItems[v30].vPosition.z; + LODWORD(v45) = pSpriteObjects[v30].vPosition.x; + v27 = pSpriteObjects[v30].vPosition.y; + v28 = pSpriteObjects[v30].vPosition.z; goto LABEL_43; } if ( v21 == 3 ) diff -r cf366ba68de5 -r 1bd8758f50b8 Actor.h --- a/Actor.h Mon Mar 04 09:22:29 2013 +0600 +++ b/Actor.h Mon Mar 04 09:22:38 2013 +0600 @@ -229,7 +229,7 @@ static void AggroSurroundingPeasants(unsigned int uActorID, int a2); static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2); static bool StealFrom(unsigned int uActorID); - static void GiveItem(unsigned int uActorID, unsigned int uItemID, unsigned int bGive); + static void GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive); static void ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle); static void ApplyFineForKillingPeasant(unsigned int uActorID); static void DrawHealthBar(Actor *a1, struct GUIWindow *a2); diff -r cf366ba68de5 -r 1bd8758f50b8 AudioPlayer.cpp --- a/AudioPlayer.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/AudioPlayer.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -5,7 +5,7 @@ #include "Allocator.h" #include "FrameTableInc.h" #include "Indoor.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "Party.h" #include "Actor.h" #include "Game.h" @@ -635,7 +635,7 @@ signed int v14; // eax@20 int v15; // eax@24 signed int v16; // eax@25 - LayingItem *pLayingItem; // eax@28 + SpriteObject *pLayingItem; // eax@28 signed int v18; // eax@29 Actor *pActor1; // eax@32 signed int v20; // ecx@32 @@ -662,7 +662,7 @@ char *v41; // edi@82 int v42; // esi@82 double v43; // st7@91 - LayingItem *pLayingItem2; // eax@92 + SpriteObject *pLayingItem2; // eax@92 Actor *pActor; // eax@93 signed int v46; // ecx@93 double v47; // st7@93 @@ -675,7 +675,7 @@ float v54; // ST04_4@106 //AudioPlayer *pAudioPlayer3; // edx@106 SoundDesc *pSoundDesc; // edx@107 - LayingItem *pLayingItem3; // eax@114 + SpriteObject *pLayingItem3; // eax@114 //int v58; // edx@115 //int v59; // ecx@115 //Actor *pActor2; // eax@118 @@ -695,7 +695,7 @@ //unsigned int pVolume; // eax@157 //int pPartyX; // ebx@159 //int v76; // ebx@160 - //LayingItem *pLayingItem4; // edi@164 + //SpriteObject *pLayingItem4; // edi@164 //unsigned int pPosY; // edx@166 //unsigned int pPosX; // ecx@166 //int v80; // eax@167 @@ -829,8 +829,8 @@ start_channel = 5; end_channel = 7; - assert(object_id < uNumLayingItems); - auto object = &pLayingItems[object_id]; + assert(object_id < uNumSpriteObjects); + auto object = &pSpriteObjects[object_id]; sample_volume = GetSoundStrengthByDistanceFromParty(object->vPosition.x, object->vPosition.y, object->vPosition.z); if (!sample_volume) @@ -1008,8 +1008,8 @@ } else if (object_type == OBJECT_Item) { - assert(object_id < uNumLayingItems); - auto object = &pLayingItems[object_id]; + assert(object_id < uNumSpriteObjects); + auto object = &pSpriteObjects[object_id]; if (!GetSoundStrengthByDistanceFromParty(object->vPosition.x, object->vPosition.y, object->vPosition.z) ) return; AIL_set_sample_pan(channel->hSample, sub_4AB66C(object->vPosition.x, object->vPosition.y)); @@ -1087,7 +1087,7 @@ v96 = 7; v12 = 5; } - pLayingItem = &pLayingItems[a3 >> 3]; + pLayingItem = &pSpriteObjects[a3 >> 3]; } else { @@ -1160,7 +1160,7 @@ v12 = 4; v96 = 4; } - pLayingItem = (LayingItem *)&pLevelDecorations[a3 >> 3]; + pLayingItem = (SpriteObject *)&pLevelDecorations[a3 >> 3]; } pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem->vPosition.x; pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem->vPosition.y; @@ -1334,7 +1334,7 @@ } if ( (a3 & 7) == 2 ) { - pLayingItem2 = &pLayingItems[a3 >> 3]; + pLayingItem2 = &pSpriteObjects[a3 >> 3]; } else { @@ -1357,7 +1357,7 @@ v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_101; } - pLayingItem2 = (LayingItem *)&pLevelDecorations[a3 >> 3]; + pLayingItem2 = (SpriteObject *)&pLevelDecorations[a3 >> 3]; } pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem2->vPosition.x; pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem2->vPosition.y; @@ -1393,7 +1393,7 @@ int v9; // ebx@10 int v10; // ebx@11 double v11; // st7@13 - LayingItem *v12; // eax@14 + SpriteObject *v12; // eax@14 Actor *v13; // eax@15 signed int v14; // edx@15 BLVDoor *v15; // eax@19 @@ -1413,12 +1413,12 @@ //unsigned __int8 v29; // of@43 //MixerChannel *v30; // esi@44 //int v31; // eax@45 - //LayingItem *v32; // eax@49 + //SpriteObject *v32; // eax@49 //Actor *v33; // edi@50 //int v34; // eax@50 //unsigned int v35; // edx@51 //unsigned int v36; // ecx@51 - //LayingItem *v37; // edi@53 + //SpriteObject *v37; // edi@53 int v38; // eax@53 //BLVDoor *v39; // edi@56 //int v40; // eax@57 @@ -1527,11 +1527,11 @@ v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_21; } - v12 = (LayingItem *)&pLevelDecorations[v6->field_4 >> 3]; + v12 = (SpriteObject *)&pLevelDecorations[v6->field_4 >> 3]; } else { - v12 = &pLayingItems[v6->field_4 >> 3]; + v12 = &pSpriteObjects[v6->field_4 >> 3]; } a1.vWorldPosition.x = (double)v12->vPosition.x; a1.vWorldPosition.y = (double)v12->vPosition.y; @@ -1662,8 +1662,8 @@ case OBJECT_Item: { - assert(source_id < uNumLayingItems); - auto object = &pLayingItems[source_id]; + assert(source_id < uNumSpriteObjects); + auto object = &pSpriteObjects[source_id]; source_x = object->vPosition.x; source_y = object->vPosition.y; @@ -1674,7 +1674,7 @@ case OBJECT_Decoration: { assert(source_id < uNumLevelDecorations); - auto object = (LayingItem *)&pLevelDecorations[source_id]; + auto object = (SpriteObject *)&pLevelDecorations[source_id]; source_x = object->vPosition.x; source_y = object->vPosition.y; diff -r cf366ba68de5 -r 1bd8758f50b8 Chest.cpp --- a/Chest.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/Chest.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -29,12 +29,15 @@ Chest pChests[20]; - +const int pChestPixelOffsetX[8] = {42, 18, 18, 42, 42, 42, 18, 42}; +const int pChestPixelOffsetY[8] = {34, 30, 30, 34, 34, 34, 30, 34}; +const int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; +const int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; //----- (0042041E) -------------------------------------------------------- -bool Chest::Open(unsigned int uChestID) -{ +bool Chest::Open( signed int uChestID ) + { //char *v1; // edi@5 unsigned int v2; // eax@8 GUIWindow *v3; // eax@15 @@ -61,7 +64,7 @@ signed int v25; // ecx@28 char *v26; // edx@29 unsigned __int16 v27; // ax@32 - //LayingItem a1; // [sp+14h] [bp-B0h]@28 + //SpriteObject a1; // [sp+14h] [bp-B0h]@28 int v29; // [sp+84h] [bp-40h]@16 int v30; // [sp+88h] [bp-3Ch]@16 int v31; // [sp+8Ch] [bp-38h]@16 @@ -79,7 +82,9 @@ //a4 = uChestID; assert(uChestID < 20); - auto chest = pChests + uChestID; + if ((uChestID <0)&&(uChestID >=20) ) + return false; + auto chest = &pChests[uChestID]; ++pIcons_LOD->uTexturePacksCount; if (!pIcons_LOD->uNumPrevLoadedFiles) @@ -89,7 +94,7 @@ //v1 = (char *)&pChests[uChestID].uFlags; //v34 = v1; if (!chest->Initialized()) - Chest::_420284(uChestID); + Chest::PlaceItems(uChestID); if ( !uActiveCharacter ) return 0; @@ -169,8 +174,8 @@ v23 = (unsigned int *)(&v29 + v35); sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); - LayingItem a1; // [sp+14h] [bp-B0h]@28 - //LayingItem::LayingItem(&a1); + SpriteObject a1; // [sp+14h] [bp-B0h]@28 + //SpriteObject::SpriteObject(&a1); a1.stru_24.Reset(); v24 = *(short *)v23; @@ -179,7 +184,7 @@ a1.field_4C = 0; a1.field_48 = 0; a1.field_54 = 0; - a1.uItemType = v24; + a1.uType = v24; if ( (signed int)pObjectList->uNumObjects <= 0 ) { LABEL_32: @@ -233,22 +238,11 @@ pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); } dword_507CD8 = 0; - v3 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, a4, 0); - pGUIWindow_CurrentMenu = v3; - pChestWindow = v3; - pBtn_ExitCancel = v3->CreateButton( - 0x1D7u, - 0x1BDu, - 0xA9u, - 0x23u, - 1, - 0, - 0x71u, - 0, - 0, - pGlobalTXT_LocalizationStrings[79],// Exit - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), - 0); + + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, uChestID, 0); + pChestWindow = pGUIWindow_CurrentMenu; + pBtn_ExitCancel = pChestWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79],// Exit + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0); pCurrentScreen = SCREEN_CHEST; pEventTimer->Pause(); @@ -257,188 +251,165 @@ //----- (0042092D) -------------------------------------------------------- void Chest::DrawChestUI(unsigned int uChestID) -{ - Render *v1; // edi@1 - unsigned int v2; // ebx@1 - unsigned int v3; // ebx@1 - int v4; // eax@1 - unsigned int v5; // eax@1 - int v6; // ecx@3 - unsigned int v7; // eax@4 - Texture *v8; // esi@4 - signed int v9; // ecx@4 - signed int v10; // edx@4 - signed int v11; // eax@4 - int v12; // eax@6 - int v13; // eax@6 - unsigned int v14; // ST34_4@8 - int v15; // edi@8 - int *v16; // [sp+Ch] [bp-28h]@1 - int v17; // [sp+10h] [bp-24h]@4 - int v18; // [sp+14h] [bp-20h]@1 - signed int v19; // [sp+18h] [bp-1Ch]@1 - int v20; // [sp+1Ch] [bp-18h]@1 - signed int v21; // [sp+20h] [bp-14h]@1 - char *v22; // [sp+2Ch] [bp-8h]@2 - signed int v23; // [sp+30h] [bp-4h]@1 + { + + int chestBitmapId; // eax@1 + unsigned int v5; // eax@1 + int chest_item_index; // ecx@3 + unsigned int item_texture_id; // eax@4 + Texture *item_texture; // esi@4 + signed int itemPixelWidth; // ecx@4 + signed int itemPixelHeght; // edx@4 + signed int v11; // eax@4 + int v12; // eax@6 + int v13; // eax@6 + unsigned int itemPixelPosX; // ST34_4@8 + int itemPixelPosY; // edi@8 + int *v16; // [sp+Ch] [bp-28h]@1 + int v17; // [sp+10h] [bp-24h]@4 + int chest_offs_y; // [sp+14h] [bp-20h]@1 + signed int chestHeghtCells; // [sp+18h] [bp-1Ch]@1 + int chest_offs_x; // [sp+1Ch] [bp-18h]@1 + signed int chestWidthCells; // [sp+20h] [bp-14h]@1 + signed int item_counter; // [sp+30h] [bp-4h]@1 - v1 = pRenderer; - v2 = uChestID; - v16 = pRenderer->pActiveZBuffer; - pRenderer->ClearZBuffer(0, 479); - v3 = v2; - v4 = pChests[v3].uChestBitmapID; - v20 = pChestSmthn1ByType[v4]; - v18 = pChestSmthn2ByType[v4]; - v21 = pChestWidthsByType[v4]; - v19 = pChestHeightsByType[v4]; - sprintf(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID); - v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0)); - v23 = 0; - if ( v21 * v19 > 0 ) - { - v22 = (char *)pChests[v3].pInventoryIndices; - do - { - v6 = *(short *)v22; - if ( v6 > 0 ) - { - v17 = v18 + 32 * v23 / v19; - v7 = pIcons_LOD->LoadTexture( - pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName, - TEXTURE_16BIT_PALETTE); - v8 = (Texture *)(v7 != -1 ? &pIcons_LOD->pTextures[v7] : 0); - v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureHeight : 26); - v11 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - if ( v9 < 14 ) - v11 = 14; - v12 = v11 - 14; - LOBYTE(v12) = v12 & 0xE0; - v13 = v12 + 32; - if ( (signed int)v8->uTextureHeight < 14 ) - v10 = 14; - v14 = v20 + 32 * v23 % v21 + ((v13 - v9) >> 1); - v15 = v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1); - pRenderer->DrawTextureTransparent( - v14, - v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1), - v8); - sub_40F92A(&v16[v14 + pSRZBufferLineOffsets[v15]], v8, v23 + 1); - v1 = pRenderer; - } - ++v23; - v22 += 2; + v16 = pRenderer->pActiveZBuffer; + pRenderer->ClearZBuffer(0, 479); + chestBitmapId = pChests[uChestID].uChestBitmapID; + chest_offs_x = pChestPixelOffsetX[chestBitmapId]; + chest_offs_y = pChestPixelOffsetY[chestBitmapId]; + chestWidthCells = pChestWidthsByType[chestBitmapId]; + chestHeghtCells = pChestHeightsByType[chestBitmapId]; + sprintf(pTmpBuf, "chest%02d", pChestList->pChests[chestBitmapId].uTextureID); + v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0)); + + for (item_counter = 0; item_counter< chestWidthCells * chestHeghtCells; ++item_counter) + { + chest_item_index = pChests[uChestID].pInventoryIndices[item_counter]; + if ( chest_item_index > 0 ) + { + item_texture_id = pIcons_LOD->LoadTexture( + //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName, + pItemsTable->pItems[pChests[uChestID].igChestItems[chest_item_index-1].uItemID].pIconName, TEXTURE_16BIT_PALETTE); + item_texture = (Texture *)(item_texture_id != -1 ? &pIcons_LOD->pTextures[item_texture_id] : 0); + itemPixelWidth = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24); + itemPixelHeght = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureHeight : 26); + if ( itemPixelWidth < 14 ) + itemPixelWidth = 14; + v12 = itemPixelWidth - 14; + v12 = v12 & 0xFFFFFFE0; + v13 = v12 + 32; + if ( itemPixelHeght < 14 ) + itemPixelHeght = 14; + itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((v13 - itemPixelWidth) >> 1); + itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) + + ((((itemPixelHeght - 14) & 0xFFFFFFE0) - item_texture->uTextureHeight + 32) >> 1); + pRenderer->DrawTextureTransparent( itemPixelPosX, itemPixelPosY, item_texture); + sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1); + } + } + pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); } - while ( v23 < v21 * v19 ); - } - pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); -} //----- (0041FE71) -------------------------------------------------------- -int Chest::CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID) -{ - int v3; // eax@1 - unsigned int v4; // eax@1 - Texture *v5; // ecx@1 - signed int v6; // eax@1 - signed int v7; // edi@3 - signed int v8; // eax@3 - int v9; // edi@3 - int v10; // ebx@5 - int v11; // esi@9 - int v12; // edx@10 - int v13; // ecx@11 - char *v14; // eax@12 - int v16; // [sp+Ch] [bp-Ch]@1 - signed int v17; // [sp+10h] [bp-8h]@1 - signed int v18; // [sp+14h] [bp-4h]@1 +bool Chest::CanPlaceItemAt( signed int test_cell_position, int item_id, unsigned int uChestID ) + { + int v3; // eax@1 + unsigned int item_texture_id; // eax@1 + Texture *item_texture; // ecx@1 + signed int v6; // eax@1 + signed int v7; // edi@3 + signed int v8; // eax@3 + int texture_cell_width; // edi@3 + int texture_cell_height; // ebx@5 + int _row; // esi@9 + int _cell_rows; // edx@10 + int _column; // ecx@11 + char *v14; // eax@12 + int chest_cell_heght; // [sp+Ch] [bp-Ch]@1 + signed int v17; // [sp+10h] [bp-8h]@1 + signed int chest_cell_width; // [sp+14h] [bp-4h]@1 - v17 = a1; - v3 = pChests[uChestID].uChestBitmapID; - v16 = pChestHeightsByType[v3]; - v18 = pChestWidthsByType[v3]; - v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[a2].pIconName, TEXTURE_16BIT_PALETTE); - v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0); - v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24); - if ( v6 < 14 ) - v6 = 14; - v7 = v6 - 14; - v8 = v5->uTextureHeight; - v9 = (v7 >> 5) + 1; - if ( v8 < 14 ) - v8 = 14; - v10 = ((v8 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - v5->Release(); - pIcons_LOD->_40F9C5(); - } - if ( v9 + v17 % v18 <= v18 && v10 + v17 / v18 <= v16 ) - { - v11 = 0; - if ( v10 <= 0 ) - return 1; - v12 = 0; - while ( 1 ) - { - v13 = 0; - if ( v9 > 0 ) - break; -LABEL_15: - v12 += v18; - ++v11; - if ( v11 >= v10 ) - return 1; + chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID]; + chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID]; + item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE); + item_texture = (Texture *)(item_texture_id != -1 ? (int)&pIcons_LOD->pTextures[item_texture_id] : 0); + v6 = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24); + if ( v6 < 14 ) + v6 = 14; + texture_cell_width = (v6 - 14 >> 5) + 1; + v8 = item_texture->uTextureHeight; + if ( v8 < 14 ) + v8 = 14; + texture_cell_height = ((v8 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + item_texture->Release(); + pIcons_LOD->_40F9C5(); + } + if ( (texture_cell_width + test_cell_position % chest_cell_width <= chest_cell_width) && + (texture_cell_height + test_cell_position / chest_cell_width <= chest_cell_heght) ) + { //we not put over borders + _row = 0; + if ( texture_cell_height <= 0 ) + return true; + _cell_rows = 0; + while ( 1 ) + { + _column = 0; + if ( texture_cell_width > 0 ) + { + while ( pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]==0) + { + ++_column; + if ( _column >= texture_cell_width ) + break; + } + if (pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]!=0) + return false; + } + _cell_rows += chest_cell_width; + ++_row; + if ( _row >= texture_cell_height ) + return true; + } + + } + return false; } - v14 = (char *)&pChests[0].pInventoryIndices[v17 + v12 + 2662 * uChestID]; - while ( !*(short *)v14 ) - { - ++v13; - v14 += 2; - if ( v13 >= v9 ) - goto LABEL_15; - } - } - return 0; -} // 506128: using guessed type int areWeLoadingTexture; //----- (0041FF64) -------------------------------------------------------- -int Chest::_41FF64(unsigned int uChestID) +int Chest::CountChestItems(unsigned int uChestID) { - unsigned int v1; // ecx@1 - signed int result; // eax@1 - int v3; // edx@1 - ItemGen *pItem; // ecx@2 - - v1 = uChestID; - result = 0; - v3 = pChestWidthsByType[pChests[v1].uChestBitmapID] * pChestHeightsByType[pChests[v1].uChestBitmapID]; - if ( v3 <= 0 ) + signed int item_count; // eax@1 + int max_items; // edx@1 + item_count = 0; + max_items = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; + if ( max_items <= 0 ) { -LABEL_5: - result = -1; + item_count = -1; } else { - pItem = pChests[v1].mm7__vector_pItems; - while ( pItem->uItemID ) + while ( pChests[uChestID].igChestItems[item_count].uItemID ) { - ++result; - ++pItem; - if ( result >= v3 ) - goto LABEL_5; + ++item_count; + if ( item_count >= max_items ) + { + item_count = -1; + break; + } } } - return result; + return item_count; } //----- (0041FFA2) -------------------------------------------------------- -int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID) +int Chest::PutItemInChest(int position, ItemGen *put_item, unsigned int uChestID) { int v3; // eax@1 ItemGen *v4; // edi@1 @@ -455,7 +426,7 @@ int v15; // edi@21 int i; // ecx@21 ItemGen *Src; // [sp+Ch] [bp-18h]@1 - signed int v18; // [sp+10h] [bp-14h]@2 + signed int item_in_chest_count; // [sp+10h] [bp-14h]@2 int v19; // [sp+14h] [bp-10h]@1 int v20; // [sp+18h] [bp-Ch]@19 signed int v21; // [sp+1Ch] [bp-8h]@1 @@ -464,19 +435,19 @@ v21 = 0; v3 = pChests[uChestID].uChestBitmapID; - v4 = a2; + v4 = put_item; v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3]; - Src = a2; + Src = put_item; v19 = pChestWidthsByType[v3]; - if ( a1 == -1 ) + if ( position == -1 ) { - v18 = _41FF64(uChestID); - if ( v18 == -1 ) + item_in_chest_count = CountChestItems(uChestID); + if ( item_in_chest_count == -1 ) return 0; v22 = 0; if ( v5 > 0 ) { - while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, (unsigned int)pChestWindow->ptr_1C) ) + while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, pChestWindow->par1C) ) { ++v22; if ( v22 >= v5 ) @@ -515,7 +486,7 @@ { if ( (signed int)v12 > 0 ) { - v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID]; + v14 = &pChests[uChestID].pInventoryIndices[v21 + v23]; LOWORD(v8) = -1 - v21; v8 <<= 16; LOWORD(v8) = -1 - v21; @@ -532,8 +503,8 @@ } while ( v20 ); } - pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1; - memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u); + pChests[uChestID].pInventoryIndices[v21] = item_in_chest_count + 1; + memcpy(&pChests[uChestID].igChestItems[item_in_chest_count], put_item, sizeof(ItemGen)); result = v21 + 1; } else @@ -545,159 +516,110 @@ // 506128: using guessed type int areWeLoadingTexture; //----- (0042013E) -------------------------------------------------------- -unsigned int Chest::PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID) -{ - int v3; // esi@1 - unsigned int v4; // ebx@1 - int uItemID; // edi@1 - int v6; // edx@4 - unsigned int v7; // eax@5 - Texture *v8; // ecx@5 - signed int v9; // eax@5 - signed int v10; // edi@7 - unsigned int v11; // ebx@7 - int v12; // edi@9 - int v13; // edx@12 - void *v14; // edi@14 - int v15; // edi@14 - int i; // ecx@14 - unsigned int result; // eax@18 - __int16 v18; // [sp+Ch] [bp-10h]@1 - int v19; // [sp+10h] [bp-Ch]@11 - int v20; // [sp+14h] [bp-8h]@12 - unsigned int v21; // [sp+18h] [bp-4h]@1 +void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int item_at_cell, unsigned int uChestID ) + { + + int uItemID; // edi@1 + int v6; // edx@4 + unsigned int v7; // eax@5 + Texture *v8; // ecx@5 + signed int v9; // eax@5 + signed int v10; // edi@7 + unsigned int texture_cell_width; // ebx@7 + int textute_cell_height; // edi@9 + int chest_cell_row_pos; // edx@12 + int chest_cell_width; // [sp+10h] [bp-Ch]@11 - v3 = 5324 * uChestID; - v21 = a1; - v4 = 5324 * uChestID + 36 * uItemIdx; - v18 = uItemIdx; - uItemID = *(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v4); - pItemsTable->SetSpecialBonus((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v4)); - if ( uItemID >= 135 && uItemID <= 159 && !*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) ) - { - v6 = rand() % 21 + 10; - *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6; - *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6; - } - v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); - v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0); - v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - if ( v9 < 14 ) - v9 = 14; - v10 = v8->uTextureHeight; - v11 = ((v9 - 14) >> 5) + 1; - if ( v10 < 14 ) - v10 = 14; - v12 = ((v10 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - v8->Release(); - pIcons_LOD->_40F9C5(); - } - v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)]; - if ( v12 > 0 ) - { - v13 = 0; - v20 = v12; - do - { - if ( (signed int)v11 > 0 ) - { - v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID]; - LOWORD(v3) = -1 - v21; - v3 <<= 16; - LOWORD(v3) = -1 - v21; - memset32(v14, v3, v11 >> 1); - v15 = (int)((char *)v14 + 4 * (v11 >> 1)); - for ( i = v11 & 1; i; --i ) + uItemID = pChests[ uChestID].igChestItems[item_at_cell].uItemID; + pItemsTable->SetSpecialBonus(&pChests[ uChestID].igChestItems[item_at_cell]); + if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[item_at_cell].uNumCharges) { - *(short *)v15 = v3; - v15 += 2; + v6 = rand() % 21 + 10; + pChests[ uChestID].igChestItems[item_at_cell].uNumCharges = v6; + pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6; } - } - v13 += v19; - --v20; + v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); + v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0); + v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); + if ( v9 < 14 ) + v9 = 14; + v10 = v8->uTextureHeight; + texture_cell_width = ((v9 - 14) >> 5) + 1; + if ( v10 < 14 ) + v10 = 14; + textute_cell_height = ((v10 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + v8->Release(); + pIcons_LOD->_40F9C5(); + } + chest_cell_width = pChestWidthsByType[pChests[ uChestID].uChestBitmapID]; + chest_cell_row_pos = 0; + for(int i=0; iClearZBuffer(0, 479); - v3 = v2; - uChestArea = pChestWidthsByType[pChests[v3].uChestBitmapID] * pChestHeightsByType[pChests[v3].uChestBitmapID]; - memset(Dst, 0, 0x90u); - if ( uChestArea > 0 ) - { - do +void Chest::PlaceItems( unsigned int uChestID ) { - do - v5 = (unsigned __int8)rand(); - while ( v5 >= uChestArea ); - while ( Dst[v5] ) - { - ++v5; - if ( v5 == uChestArea ) - v5 = 0; - } - Dst[v5] = v1++; + int uChestArea; // edi@1 + int random_chest_pos; // eax@2 + int test_position; // ebx@11 + char chest_cells_map[144]; // [sp+Ch] [bp-A0h]@1 + int chest_item_id; // [sp+9Ch] [bp-10h]@10 + unsigned int items_counter; // [sp+A4h] [bp-8h]@8 + + pRenderer->ClearZBuffer(0, 479); + uChestArea = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; + memset(chest_cells_map, 0, 144); + //fill cell map at random positions + for (items_counter = 0; items_counter= uChestArea ); + //if this pos occupied move to next + while ( chest_cells_map[random_chest_pos] ) + { + ++random_chest_pos; + if ( random_chest_pos == uChestArea ) + random_chest_pos = 0; + } + chest_cells_map[random_chest_pos] = items_counter; + } + items_counter = 0; + + for (items_counter = 0; items_counter= uChestArea ) + break; + } + if(test_position 0 ) - { - v12 = pChests[v3].mm7__vector_pItems;//&pChests[v3].mm7__vector_pItems[0].uAttributes; - do - { - v9 = v12->uItemID; - if ( v9 ) - { - v6 = 0; - while ( !Chest::CanPlaceItemAt((unsigned __int8)Dst[v6], v9, v10) ) - { - ++v6; - if ( v6 >= uChestArea ) - break; - } - if(v6SetIdentified(); - } - } - ++v11; - ++v12; - } - while ( (signed int)v11 < uChestArea ); - } - result = (char *)&pChests[v3].uFlags; - pChests[v3].uFlags = pChests[v3].uFlags & 0xFFFB | 2; - return result; -} // 420284: using guessed type char Dst[144]; //----- (00458B03) -------------------------------------------------------- @@ -801,3 +723,83 @@ fclose(File); return 1; } + +//----- (00420B13) -------------------------------------------------------- +void __fastcall sub_420B13(int a1, int a2) + { + void *v2; // eax@1 + ItemGen *v3; // ebx@1 + unsigned int v4; // eax@1 + Texture *v5; // ecx@1 + signed int v6; // eax@1 + signed int v7; // edi@3 + signed int v8; // eax@3 + int v9; // edi@3 + int v10; // eax@5 + int v11; // esi@8 + unsigned int v12; // ecx@10 + void *v13; // edi@10 + unsigned __int8 v14; // cf@10 + int v15; // edi@10 + int i; // ecx@10 + int v17; // [sp+Ch] [bp-14h]@1 + int v18; // [sp+10h] [bp-10h]@3 + int v19; // [sp+14h] [bp-Ch]@1 + void *v20; // [sp+18h] [bp-8h]@1 + int v21; // [sp+1Ch] [bp-4h]@5 + int v22; // [sp+1Ch] [bp-4h]@8 + + v19 = a2; + v2 = pChestWindow->ptr_1C; + v20 = v2; + v2 = (void *)(5324 * (int)v2); + v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4)); + v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)]; + v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0); + v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24); + if ( v6 < 14 ) + v6 = 14; + v7 = v6 - 14; + v8 = v5->uTextureHeight; + v9 = (v7 >> 5) + 1; + v18 = v9; + if ( v8 < 14 ) + v8 = 14; + v10 = ((v8 - 14) >> 5) + 1; + v21 = v10; + if ( !areWeLoadingTexture ) + { + v5->Release(); + pIcons_LOD->_40F9C5(); + v10 = v21; + } + if ( v10 > 0 ) + { + v11 = 0; + v22 = v10; + do + { + if ( v9 > 0 ) + { + v12 = v9; + v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20]; + v14 = v12 & 1; + v12 >>= 1; + memset(v13, 0, 4 * v12); + v15 = (int)((char *)v13 + 4 * v12); + for ( i = v14; i; --i ) + { + *(short *)v15 = 0; + v15 += 2; + } + v9 = v18; + } + v11 += v17; + --v22; + } + while ( v22 ); + } + v3->Reset(); + } +// 506128: using guessed type int areWeLoadingTexture; diff -r cf366ba68de5 -r 1bd8758f50b8 Chest.h --- a/Chest.h Mon Mar 04 09:22:29 2013 +0600 +++ b/Chest.h Mon Mar 04 09:22:38 2013 +0600 @@ -47,29 +47,29 @@ /* 65 */ #pragma pack(push, 1) -struct Chest +struct Chest //0x14cc { inline bool Initialized() const {return uFlags & CHEST_ITEMS_PLACED;} inline void SetInitialized(bool b) {if (b) uFlags |= CHEST_ITEMS_PLACED; else uFlags &= ~CHEST_ITEMS_PLACED;} inline bool Trapped() const {return uFlags & CHEST_TRAPPED;} - static int CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID); - static int _41FF64(unsigned int uChestID); - static int _41FFA2(int a1, ItemGen *a2, unsigned int uChestID); - static unsigned int PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID); - static char *_420284(unsigned int uChestID); - static bool Open(unsigned int uChestID); + static bool CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID); + static int CountChestItems(unsigned int uChestID); + static int PutItemInChest(int a1, ItemGen *a2, unsigned int uChestID); + static void PlaceItemAt(unsigned int put_cell_pos, unsigned int uItemIdx, unsigned int uChestID); + static void PlaceItems(unsigned int uChestID); + static bool Open(signed int uChestID); static void DrawChestUI(unsigned int uChestID); static void ToggleFlag(unsigned int uChestID, unsigned __int16 uFlag, unsigned int bToggle); - unsigned __int16 uChestBitmapID; - unsigned __int16 uFlags; - struct ItemGen mm7__vector_pItems[140]; - __int16 pInventoryIndices[140]; + unsigned __int16 uChestBitmapID; //0 + unsigned __int16 uFlags; //2 + struct ItemGen igChestItems[140]; //4 + signed __int16 pInventoryIndices[140]; //0x13b4 }; #pragma pack(pop) - +void __fastcall sub_420B13(int a1, int a2); extern size_t uNumChests; // idb diff -r cf366ba68de5 -r 1bd8758f50b8 DecalBuilder.h --- a/DecalBuilder.h Mon Mar 04 09:22:29 2013 +0600 +++ b/DecalBuilder.h Mon Mar 04 09:22:38 2013 +0600 @@ -40,7 +40,7 @@ { } - void (__thiscall ***vdestructor_ptr)(Decal *, bool); + //void (__thiscall ***vdestructor_ptr)(Decal *, bool); int uNumVertices; RenderVertexSoft pVertices[64]; __int16 field_C08; @@ -103,7 +103,7 @@ - void (__thiscall ***vdestructor_ptr)(DecalBuilder *, bool); + //void (__thiscall ***vdestructor_ptr)(DecalBuilder *, bool); Decal std__vector_pDecals[1024]; unsigned int std__vector_pDecals_size; int field_308008; @@ -150,7 +150,7 @@ { } - void (__thiscall ***vdestructor_ptr)(Bloodsplat *, bool); + //void (__thiscall ***vdestructor_ptr)(Bloodsplat *, bool); float x; float y; float z; @@ -194,7 +194,7 @@ bool AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b); - void (__thiscall ***vdestructor_ptr)(BloodsplatContainer *, bool); + //void (__thiscall ***vdestructor_ptr)(BloodsplatContainer *, bool); Bloodsplat std__vector_pBloodsplats[64]; unsigned int std__vector_pBloodsplats_size; int uNumBloodsplats; diff -r cf366ba68de5 -r 1bd8758f50b8 Events.cpp --- a/Events.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/Events.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -298,7 +298,7 @@ } player_choose = (uActiveCharacter == 0)?6:4; //4 - active or 6 - random player if active =0 curr_seq_num = start_event_seq_number; - if ( GlobalEventInfo ) + if ( activeLevelDecoration ) { uSomeEVT_NumEvents = uGlobalEVT_NumEvents; pSomeEVT = pGlobalEVT; @@ -338,9 +338,6 @@ { ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; break; } v124 = -1; @@ -524,28 +521,25 @@ //v7 = ""; break; case EVENT_ChangeEvent: - v25 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); + v25 = EVT_DWORD(_evt->v5); if ( v25 ) { - stru_5E4C90._decor_events[GlobalEventInfo + 28] = _evt->v5 - 124; + stru_5E4C90._decor_events[activeLevelDecoration->_idx_in_stru123] = _evt->v5 - 124; } else { - v26 = (LevelDecoration *)GlobalEventInfo; - stru_5E4C90._decor_events[GlobalEventInfo + 28] = 0; - LOBYTE(v26->field_2) |= 0x20u; + v26 = (LevelDecoration *)activeLevelDecoration; + stru_5E4C90._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0; + v26->field_2 |= 0x0020; } ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; + break; case EVENT_SetNPCGreeting: - v27 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - v28 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); + v27 = EVT_DWORD(_evt->v5); pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu; - pNPCStats->pNewNPCData[v27].greet = v28; + pNPCStats->pNewNPCData[v27].greet = EVT_DWORD(_evt->v9); ++curr_seq_num; v4 = v124; @@ -629,39 +623,26 @@ //v7 = ""; break; case EVENT_NPCSetItem: - sub_448518_npc_set_item(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), - _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13); + sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; + break; case EVENT_SetActorItem: - Actor::GiveItem(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), - _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13); + Actor::GiveItem(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_SetNPCGroupNews: pNPCStats->pGroups_copy[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)] = _evt->v9 + ((uint)_evt->v10 << 8); ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_SetActorGroup: __debugbreak(); *(&pActors[0].uGroup + 0x11000000 * _evt->v8 + 209 * (_evt->v5 + ((_evt->v6 + ((uint)_evt->v7 << 8)) << 8))) = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_ChangeGroup: v38 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); @@ -712,23 +693,22 @@ case EVENT_MoveNPC: { - pNPCStats->pNewNPCData[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)].Location2D = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); + pNPCStats->pNewNPCData[EVT_DWORD(_evt->v5)].Location2D =EVT_DWORD(_evt->v9); if ( window_SpeakInHouse ) { - v46 = window_SpeakInHouse->ptr_1C; - if ( v46 == (void *)165 ) + + if ( window_SpeakInHouse->par1C == 165 ) { sub_4BD8B5(); pVideoPlayer->Unload(); window_SpeakInHouse->Release(); pParty->uFlags &= 0xFFFFFFFDu; - GlobalEventInfo = 1; + activeLevelDecoration = (LevelDecoration*)1; if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) { pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); - v47 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0); - window_SpeakInHouse = v47; - v48 = v47->pControlsHead; + window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0); + v48 = window_SpeakInHouse->pControlsHead; if ( v48 ) { do @@ -738,33 +718,29 @@ v48 = v49; } while ( v49 ); - v47 = window_SpeakInHouse; } - v47->pControlsHead = 0; + window_SpeakInHouse->pControlsHead = 0; window_SpeakInHouse->pControlsTail = 0; window_SpeakInHouse->uNumControls = 0; } } else { - if ( v46 == (void *)553 ) + if ( window_SpeakInHouse->par1C == 553 ) pVideoPlayer->bLoopPlaying = 0; } } - ++curr_seq_num; + } + ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; + break; case EVENT_Jmp: curr_seq_num = _evt->v5 - 1; ++curr_seq_num; - //v4 = -1; - - //v6 = v123; - //v7 = ""; + v4 = -1; + break; case EVENT_ShowFace: if ( _evt->v5 <= 3u ) //someone @@ -780,9 +756,7 @@ pParty->pPlayers[rand() % 4].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; + break; case EVENT_CharacterAnimation: if ( _evt->v5 <= 3u ) //someone @@ -795,18 +769,13 @@ else //random pParty->pPlayers[rand() % 4].PlaySound((PlayerSpeech) _evt->v6, 0); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; + v4 = v124; + break; case EVENT_ForPartyMember: player_choose = _evt->v5; ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_SummonItem: sub_42F7EB_DropItemAt(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), @@ -824,53 +793,48 @@ case EVENT_Compare: pValue = EVT_DWORD(_evt->v7); if ( player_choose <= 3 ) - { + { if ( pPlayers[player_choose]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { + { v124 = -1; curr_seq_num = _evt->v11 - 1; - }; } + } else if ( player_choose == 4 ) //active + { + if ( uActiveCharacter ) { - if ( uActiveCharacter ) + if ( pPlayers[uActiveCharacter]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) { - if ( pPlayers[uActiveCharacter]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { v124 = -1; curr_seq_num = _evt->v11 - 1; - }; } } + } else if ( player_choose == 5 )//all - { + { v130=0; - for(int i=0; i<4; ++i) + for(int i = 0; i < 5; ++i) + { + if ( pPlayers[i]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) { - if ( pPlayers[i]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { v124 = -1; curr_seq_num = _evt->v11 - 1; break; - }; - + } ++v130; - } - } + } else if ( player_choose == 6 ) //random - { + { if ( pPlayers[rand() % 4]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { + { v124 = -1; curr_seq_num = _evt->v11 - 1; - } } - + } ++curr_seq_num; v4 = v124; - //v6 = v123; - //v7 = ""; break; case EVENT_IsActorAlive: if (IsActorAlive(EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10))) @@ -885,107 +849,66 @@ pValue = EVT_DWORD(_evt->v7); if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands ) { - v64 = 0; - if ( pParty->pPickedItem.uItemID == pValue ) + if ( pParty->pPickedItem.uItemID == pValue )//In hand { pMouse->RemoveHoldingItem(); ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; break; } - v65 = 0; - v66 = pPlayers[uActiveCharacter]; - v67 = (int)v66->pInventoryIndices; - do + v67 = (int)pPlayers[uActiveCharacter]->pInventoryIndices; + for ( v65 = 0; v65 < 126; ++v65 ) { - if ( (int)&v66->pInventoryItems[v67] == pValue ) + if ( (int)&pPlayers[uActiveCharacter]->pInventoryItems[v67] == pValue ) { - v66->RemoveItemAtInventoryIndex(v65); + pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65); ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; break; } - ++v65; v67 += 4; } while ( (signed int)v65 < 126 ); - v68 = 0; - v69 = (int)&v66->pEquipment; - do + v69 = (int)&pPlayers[uActiveCharacter]->pEquipment; + for ( v68 = 0; v68 < 16; ++v68 ) + { + if ( *(int *)v69 && (int)&pPlayers[uActiveCharacter]->pInventoryItems[v69] == pValue ) { - if ( *(int *)v69 && (int)&v66->pInventoryItems[v69] == pValue ) + *(&pPlayers[uActiveCharacter]->pEquipment.uOffHand + v68) = 0; + ++curr_seq_num; + v4 = v124; + break; + } + v69 += 4; + } + for (int i = 1; i < 5; i++) + { + v72 = (int)pPlayers[i]->pInventoryIndices; + for ( int v71 = 0; v71 < 126; ++v71 ) + { + if ( (int)&pPlayers[i]->pInventoryItems[v72] == pValue ) { - *(&v66->pEquipment.uOffHand + v68) = 0; - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; + pPlayers[i]->RemoveItemAtInventoryIndex(v71); break; } - ++v68; - v69 += 4; + v72 += 4; } - while ( v68 < 16 ); - pPlayer = pPlayers[1]; - while ( 1 ) - { - v70 = pPlayer; - if ( !v64 ) - { - v71 = 0; - v72 = (int)v70->pInventoryIndices; - do - { - if ( (int)&v70->pInventoryItems[v72] == pValue ) - { - v70->RemoveItemAtInventoryIndex(v71); - goto LABEL_169; - } - ++v71; - v72 += 4; - } - while ( (signed int)v71 < 126 ); - v73 = 0; - v74 = (int)&v70->pEquipment; - while ( !*(int *)v74 || (int)&v70->pInventoryItems[v74] != pValue ) - { - ++v73; - v74 += 4; - if ( v73 >= 16 ) - goto LABEL_170; - } - *(&v70->pEquipment.uOffHand + v73) = 0; -LABEL_169: - v64 = 1; - } -LABEL_170: - pPlayer += 4; - if ( pPlayer > pPlayers[4] ) - { - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } - } + v73 = 0; + v74 = (int)&pPlayers[i]->pEquipment; + while ( !*(int *)v74 || (int)&pPlayer->pInventoryItems[v74] != pValue ) + { + ++v73; + v74 += 4; + if ( v73 >= 16 ) + break; + } + *(&pPlayers[i]->pEquipment.uOffHand + v73) = 0; } - v75 = player_choose; + } if ( player_choose <= 3 ) { - pPlayer = &pParty->pPlayers[v75]; + pPlayer = &pParty->pPlayers[player_choose]; pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - ++curr_seq_num; - //v4 = v124; - break; } else if ( player_choose == 4 ) //active { @@ -993,173 +916,97 @@ { pPlayer = pPlayers[uActiveCharacter]; pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - ++curr_seq_num; - v4 = v124; - break; } } else if ( player_choose == 5 )//all { - v130=0; - for(int i=0; i<4; ++i) + v130 = 0; + for(int i = 0; i < 4; ++i) { if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { - ++curr_seq_num; break; - } } ++v130; - break; + } + else if ( player_choose == 6 ) //random + { + player_choose = rand() % 4; + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + ++curr_seq_num; + v4 = v124; + break; + case EVENT_Set: + pValue = EVT_DWORD(_evt->v7); + if ( player_choose <= 3 ) + { + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + else if ( player_choose == 4 ) //active + { + if ( uActiveCharacter ) + { + pPlayer = pPlayers[uActiveCharacter]; + pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + } + else if ( player_choose == 5 )//all + { + //recheck v130 + for(int i = 1; i < 5; ++i) + pPlayers[i]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } else if ( player_choose == 6 ) //random { - v75 = rand() % 4; - pPlayer = &pParty->pPlayers[v75]; - pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - ++curr_seq_num; - v4 = v124; - break; + player_choose = rand() % 4; + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } -/* if ( player_choose != 5 ) + ++curr_seq_num; + v4 = v124; + break; + case EVENT_Add: + pValue = EVT_DWORD(_evt->v7); + if ( player_choose <= 3 ) { - if ( player_choose < 0 ) - goto LABEL_183; - //if ( player_choose > 3 ) - //{ - if ( player_choose != 4 ) - { - if ( player_choose == 6 ) - goto LABEL_180; -LABEL_183: - ((Player *)v6)->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } - if ( uActiveCharacter ) - { - v6 = pPlayers[uActiveCharacter]; - goto LABEL_182; - } -LABEL_180: - v75 = rand() % 4; - - //} - v6 = &pParty->pPlayers[v75]; -LABEL_182: - //v123 = v6; - goto LABEL_183; + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } - v130=0; - for(int i=0; i<4; ++i) + else if ( player_choose == 4 ) //active { - if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) + if ( uActiveCharacter ) { - ++curr_seq_num; - break; + pPlayer = pPlayers[uActiveCharacter]; + pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } } - ++v130; - break;*/ - case EVENT_Set: - v77 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); - v78 = player_choose; - if ( player_choose != 5 ) - { - if ( player_choose < 0 ) - goto LABEL_197; - if ( player_choose > 3 ) - { - if ( player_choose != 4 ) - { - if ( player_choose == 6 ) - goto LABEL_194; -LABEL_197: - ((Player *)v6)->SetVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v77); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } - if ( uActiveCharacter ) - { - v6 = pPlayers[uActiveCharacter]; - goto LABEL_196; - } -LABEL_194: - v78 = rand() % 4; - - } - v6 = &pParty->pPlayers[v78]; -LABEL_196: - //v123 = v6; - goto LABEL_197; - } - v79 = pParty->pPlayers; - v130 = 4; - do - { - v79->SetVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v77); - ++v79; - } - while ( (signed int)v79 < (signed int)pParty->pHirelings ); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_Add: - pValue = EVT_DWORD(_evt->v7); - //v81 = player_choose; - if ( player_choose != 5 ) - { - if ( player_choose < 0 ) - goto LABEL_211; - if ( player_choose > 3 ) - { - if ( player_choose != 4 ) - { - if ( player_choose == 6 ) - goto LABEL_208; -LABEL_211: - ((Player *)v6)->AddVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), pValue); - goto LABEL_212; - } - if ( uActiveCharacter ) - { - v6 = pPlayers[uActiveCharacter]; - goto LABEL_210; - } -LABEL_208: - player_choose = rand() % 4; - - } - v6 = &pParty->pPlayers[player_choose]; -LABEL_210: - //v123 = v6; - goto LABEL_211; - } - v130 = 0; - for(int i=1; i<5; ++i) - pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); -LABEL_212: - v83 = EVT_WORD(_evt->v5); - if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 ) - viewparams->bRedrawGameUI = 1; - ++curr_seq_num; - v4 = v124; - break; + else if ( player_choose == 5 )//all + { + //v130 = 0; + for(int i = 1; i < 5; ++i) + pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + + } + else if ( player_choose == 6 ) //random + { + player_choose = rand() % 4; + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + v83 = EVT_WORD(_evt->v5); + if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 ) + viewparams->bRedrawGameUI = 1; + ++curr_seq_num; + v4 = v124; + break; case EVENT_InputString: if ( !start_event_seq_number ) { - strcpy(GameUI_StatusBar_TimedString, &pLevelStr[pLevelStrOffsets[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)]]); + strcpy(GameUI_StatusBar_TimedString, &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); v105 = curr_seq_num; v121 = 26; LABEL_295: @@ -1190,14 +1037,16 @@ //v124 = -1; v11 = (unsigned __int8)*(&_evt->v5 + rand() % ((_evt->v5 != 0) + (_evt->v6 != 0) + (_evt->v7 != 0) + (_evt->v8 != 0) + (_evt->v9 != 0) + (_evt->v10 != 0))); - goto LABEL_131; + curr_seq_num = v11 - 1; + ++curr_seq_num; + v4 = v124; case EVENT_ReceiveDamage: - v85 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); + v85 = EVT_DWORD(_evt->v7 ); v86 = _evt->v5; if ( (unsigned __int8)v86 <= 3u ) { v119 = _evt->v6; - v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); + v115 = EVT_DWORD(_evt->v7 ); v89 = (unsigned __int8)v86; goto LABEL_233; } @@ -1214,13 +1063,13 @@ } v119 = _evt->v6; v88 = pPlayers[uActiveCharacter]; - v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); + v115 = EVT_DWORD(_evt->v7 ); goto LABEL_234; } if ( v86 != 5 ) { v119 = _evt->v6; - v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10<< 8)) << 8)) << 8); + v115 = EVT_DWORD(_evt->v7 ); v89 = rand() % 4; LABEL_233: v88 = &pParty->pPlayers[v89]; @@ -1247,7 +1096,7 @@ //v7 = ""; break; case EVENT_ToggleIndoorLight: - pIndoor->ToggleLight(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), _evt->v9); + pIndoor->ToggleLight(EVT_DWORD(_evt->v5 ), _evt->v9); ++curr_seq_num; v4 = v124; @@ -1255,8 +1104,7 @@ //v7 = ""; break; case EVENT_SetFacesBit: - sub_44892E_set_faces_bit(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), - _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13); + sub_44892E_set_faces_bit(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); ++curr_seq_num; v4 = v124; @@ -1264,8 +1112,7 @@ //v7 = ""; break; case EVENT_ToggleChestFlag: - Chest::ToggleFlag(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), - _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13); + Chest::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); ++curr_seq_num; v4 = v124; @@ -1273,8 +1120,7 @@ //v7 = ""; break; case EVENT_ToggleActorFlag: - Actor::ToggleFlag(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), - _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13); + Actor::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); ++curr_seq_num; v4 = v124; @@ -1282,10 +1128,7 @@ //v7 = ""; break; case EVENT_ToggleActorGroupFlag: - ToggleActorGroupFlag( - _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), - _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), - _evt->v13); + ToggleActorGroupFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); ++curr_seq_num; v4 = v124; @@ -1302,30 +1145,18 @@ //v7 = ""; break; case EVENT_StatusText: - v90 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - if ( GlobalEventInfo ) + v90 = EVT_DWORD(_evt->v5 ); + if ( activeLevelDecoration ) { - if ( GlobalEventInfo == 1 ) + if ( activeLevelDecoration == (LevelDecoration*)1 ) { ptr_F8B1E8 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; } if ( canShowMessages == 1 ) { v91 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; //LABEL_248: ShowStatusBarString(v91, 2u); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; } } else @@ -1334,12 +1165,6 @@ { v91 = &pLevelStr[pLevelStrOffsets[v90]]; ShowStatusBarString(v91, 2u); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; } } ++curr_seq_num; @@ -1349,8 +1174,8 @@ //v7 = ""; break; case EVENT_ShowMessage: - v92 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - if ( GlobalEventInfo ) + v92 = EVT_DWORD(_evt->v5 ); + if ( activeLevelDecoration ) { v93 = (char *)pNPCTopics[v92-1].pText;//(&dword_721664)[8 * v92]; byte_5B0938[0] = 0; @@ -1367,20 +1192,15 @@ //v7 = ""; break; case EVENT_CastSpell: - sub_448DF8_cast_spell(_evt->v5, _evt->v6, _evt->v7, _evt->v8 + ((_evt->v9 + ((_evt->v10 + ((uint)_evt->v11 << 8)) << 8)) << 8), - _evt->v12 + ((_evt->v13 + ((_evt->v14 + ((uint)_evt->v15 << 8)) << 8)) << 8), - _evt->v16 + ((_evt->v17 + ((_evt->v18 + ((uint)_evt->v19 << 8)) << 8)) << 8), - _evt->v20 + ((_evt->v21 + ((_evt->v22 + ((uint)_evt->v23 << 8)) << 8)) << 8), - _evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8), - _evt->v28 + ((_evt->v29 + ((_evt->v30 + ((uint)_evt->v31 << 8)) << 8)) << 8)); + sub_448DF8_cast_spell(_evt->v5, _evt->v6, _evt->v7, EVT_DWORD(_evt->v8 ), + EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ), + EVT_DWORD(_evt->v24 ), EVT_DWORD(_evt->v28 )); ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; + break; case EVENT_SetTexture: - sub_44861E_set_texture(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), (char *)&_evt->v9); + sub_44861E_set_texture(EVT_DWORD(_evt->v5 ), (char *)&_evt->v9); ++curr_seq_num; v4 = v124; @@ -1388,7 +1208,7 @@ //v7 = ""; break; case EVENT_SetSprite: - SetDecorationSprite(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), _evt->v9, (char *)&_evt->v10); + SetDecorationSprite(EVT_DWORD(_evt->v5 ), _evt->v9, (char *)&_evt->v10); ++curr_seq_num; v4 = v124; @@ -1396,12 +1216,9 @@ //v7 = ""; break; case EVENT_SummonMonsters: - sub_448CF4_spawn_monsters(_evt->v5, _evt->v6, _evt->v7, - _evt->v8 + ((_evt->v9 + ((_evt->v10 + ((uint)_evt->v11 << 8)) << 8)) << 8), - _evt->v12 + ((_evt->v13 + ((_evt->v14 + ((uint)_evt->v15 << 8)) << 8)) << 8), - _evt->v16 + ((_evt->v17 + ((_evt->v18 + ((uint)_evt->v19 << 8)) << 8)) << 8), - _evt->v20 + ((_evt->v21 + ((_evt->v22 + ((uint)_evt->v23 << 8)) << 8)) << 8), - _evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8)); + sub_448CF4_spawn_monsters(_evt->v5, _evt->v6, _evt->v7,EVT_DWORD(_evt->v8 ), + EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ), + EVT_DWORD(_evt->v24 )); ++curr_seq_num; v4 = v124; @@ -1503,7 +1320,7 @@ } else { - pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((GlobalEventInfo == 0) + 1); + pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((activeLevelDecoration == NULL) + 1); sub_44987B(v99, 0); v133 = 1; if ( pCurrentScreen == SCREEN_HOUSE ) @@ -1570,13 +1387,13 @@ pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0); v104 = 187; if ( uCurrentHouse_Animation != 167 ) - v104 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); + v104 = EVT_DWORD(_evt->v5); window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0); window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, 0x6Eu, 1, 49, "", 0); window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, 0x6Eu, 2, 50, "", 0); window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, 0x6Eu, 3, 51, "", 0); window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, 0x6Eu, 4, 52, "", 0); - window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0); + window_SpeakInHouse->CreateButton( 0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0); } ++curr_seq_num; v4 = v124; diff -r cf366ba68de5 -r 1bd8758f50b8 GUIWindow.cpp --- a/GUIWindow.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/GUIWindow.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -15,7 +15,6 @@ #include "Viewport.h" #include "Render.h" #include "PlayerFrameTable.h" -#include "stru179.h" #include "SaveLoad.h" #include "FactionTable.h" #include "StorylineTextTable.h" @@ -474,10 +473,10 @@ InitializeBookFonts(); v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); pCurrentScreen = SCREEN_BOOKS; - dword_506524 = 0; + awards_count2 = 0; dword_506528 = 0; dword_50651C = 0; - dword_506520 = 0; + awards_count = 0; if ( v1->ptr_1C == (void *)177 ) { byte_506360 = 0; @@ -558,15 +557,15 @@ pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, pTex_tab_an_7b__zoot_on->uTextureHeight, pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, 0x47u, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down" pTex_tab_an_7b__zoot_on, 0); - dword_506520 = 0; - memset(&pStru179, 0, 0xFA0u); + awards_count = 0; + memset(&achievedAwardsIndex, 0, 4000); for ( i = dword_506528; i < 512; ++i ) { v14 = (char *)pQuestTable[i-1];//(&dword_722F10)[4 * i]; - if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, i) && v14 ) + if ( _449B57_test_bit(pParty->_quest_bits, i) && v14 ) { - v15 = dword_506520++; - pStru179.field_0[v15] = i; + v15 = awards_count++; + achievedAwardsIndex[v15] = i; } } } @@ -610,7 +609,7 @@ pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0);// "Instructors" v10 = dword_506528; pBtn_Autonotes_Instructors = v9; - dword_506520 = 0; + awards_count = 0; while ( v10 < 196 ) { if ( dword_506568 == pAutonoteTxt[v10-1].eType)//dword_72371C[2 * v10] ) @@ -619,10 +618,10 @@ v25 = (char *)pAutonoteTxt[v10-1].pText; if ( (short)v10 ) { - if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v10) && v25 ) + if ( _449B57_test_bit(pParty->_autonote_bits, v10) && v25 ) { - v11 = dword_506520++; - pStru179.field_0[v11] = (signed __int16)v10; + v11 = awards_count++; + achievedAwardsIndex[v11] = (signed __int16)v10; } } } @@ -704,7 +703,7 @@ pGlobalTXT_LocalizationStrings[193], pTex_tab_an_7b__zoot_on, 0); - dword_506520 = 0; + awards_count = 0; v26.uFrameX = 48; v26.uFrameY = 70; v26.uFrameWidth = 360; @@ -713,7 +712,7 @@ v26.uFrameZ = 407; v26.uFrameHeight = v2 * 264 / v2; v26.uFrameW = v26.uFrameHeight + 69; - memset(&pStru179, 0, 0xFA0u); + memset(&achievedAwardsIndex, 0, 4000); memset(byte_5C6D50, 0, 0x64u); if ( dword_506528 < 29 ) { @@ -731,10 +730,10 @@ v8 = v7 + 1; if ( (signed int)v7 + 1 > 0 ) { - memset32((char *)&pStru179 + 4 * dword_506520 , i, v8); + memset32((char *)&achievedAwardsIndex + 4 * awards_count , i, v8); do { - LODWORD(v7) = dword_506520++; + LODWORD(v7) = awards_count++; byte_5C6D50[(int)v7] = BYTE4(v7); ++HIDWORD(v7); } @@ -748,9 +747,9 @@ } } } - v12 = dword_506520; - dword_506520 = 0; - dword_506524 = v12; + v12 = awards_count; + awards_count = 0; + awards_count2 = v12; } } } @@ -1212,7 +1211,7 @@ } else { - pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uTextureID_506438]); + pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); } } @@ -1795,7 +1794,7 @@ pMainScreenNum = pCurrentScreen; pCurrentScreen = SCREEN_NPC_DIALOGUE; pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], //"Exit" - (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); if ( pWindow->par1C != 1 ) { num_menu_buttons = 0; @@ -1917,7 +1916,7 @@ { pCurrentScreen = SCREEN_HOUSE; pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[80],// - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); v25 = uNumDialogueNPCPortraits; v26 = 0; if ( uNumDialogueNPCPortraits > 0 ) diff -r cf366ba68de5 -r 1bd8758f50b8 Game.h --- a/Game.h Mon Mar 04 09:22:29 2013 +0600 +++ b/Game.h Mon Mar 04 09:22:38 2013 +0600 @@ -82,7 +82,7 @@ static void Destroy(); protected: Game(); -protected: ~Game(); +protected: virtual ~Game(); public: void _44E904(); @@ -113,7 +113,7 @@ struct IndoorCameraD3D *GetIndoorCamera() {return this->pIndoorCameraD3D;} - void (__thiscall ***vdestructor_ptr)(Game *, bool); + //void (__thiscall ***vdestructor_ptr)(Game *, bool); Game__StationaryLight pStationaryLights[25]; char field_2C0[1092]; unsigned int uNumStationaryLights; diff -r cf366ba68de5 -r 1bd8758f50b8 Indoor.cpp --- a/Indoor.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/Indoor.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -2,7 +2,7 @@ #include "Outdoor.h" #include "Render.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "Events.h" #include "Game.h" #include "Viewport.h" @@ -41,7 +41,7 @@ LevelDecoration pLevelDecorations[3000]; size_t uNumLevelDecorations; -int GlobalEventInfo; +LevelDecoration* activeLevelDecoration; LEVEL_TYPE uCurrentlyLoadedLevelType = LEVEL_null; @@ -1892,7 +1892,7 @@ int v72; // eax@38 unsigned __int16 v73; // ax@42 char *v74; // ecx@42 - LayingItem *v75; // ecx@44 + SpriteObject *v75; // ecx@44 size_t v76; // eax@45 int j; // edx@46 unsigned __int16 v78; // ax@50 @@ -2362,13 +2362,13 @@ while ( Argsi < (signed int)uNumLevelDecorations ); } fseek(v7, v219, 0); - fread(&uNumLayingItems, 4u, 1u, v7); + fread(&uNumSpriteObjects, 4u, 1u, v7); fseek(v7, v220, 0); - fread(pLayingItems, 0x70u, uNumLayingItems, v7); - if ( (signed int)uNumLayingItems > 0 ) + fread(pSpriteObjects, 0x70u, uNumSpriteObjects, v7); + if ( (signed int)uNumSpriteObjects > 0 ) { - v75 = pLayingItems; - pDest = (char *)uNumLayingItems; + v75 = pSpriteObjects; + pDest = (char *)uNumSpriteObjects; do { Argsj = 0; @@ -2517,7 +2517,7 @@ assert(sizeof(SpawnPointMM7) == 24); assert(sizeof(DDM_DLV_Header) == 40); assert(sizeof(Actor) == 836); - assert(sizeof(LayingItem) == 112); + assert(sizeof(SpriteObject) == 112); assert(sizeof(Chest) == 5324); assert(sizeof(stru123) == 0xC8); assert(sizeof(BLVMapOutline) == 12); @@ -2972,23 +2972,23 @@ pGameLoadingUI_ProgressBar->Progress(); pGameLoadingUI_ProgressBar->Progress(); - memcpy(&uNumLayingItems, pData, 4); - memcpy(pLayingItems, pData + 4, uNumLayingItems * sizeof(LayingItem)); - pData += 4 + uNumLayingItems * sizeof(LayingItem); + memcpy(&uNumSpriteObjects, pData, 4); + memcpy(pSpriteObjects, pData + 4, uNumSpriteObjects * sizeof(SpriteObject)); + pData += 4 + uNumSpriteObjects * sizeof(SpriteObject); pGameLoadingUI_ProgressBar->Progress(); - for (uint i = 0; i < uNumLayingItems; ++i) + for (uint i = 0; i < uNumSpriteObjects; ++i) { - auto pItem = pLayingItems + i; + auto pItem = pSpriteObjects + i; if (pItem->stru_24.uItemID && !(pItem->uAttributes & 0x0100)) { - pItem->uItemType = pItemsTable->pItems[pItem->stru_24.uItemID - 1].uSpriteID; + pItem->uType = pItemsTable->pItems[pItem->stru_24.uItemID - 1].uSpriteID; uint uObjectID = 0; for (uint j = 0; j < pObjectList->uNumObjects; ++j) - if (pItem->uItemType == pObjectList->pObjects[j].uObjectID) + if (pItem->uType == pObjectList->pObjects[j].uObjectID) { pItem->uObjectDescID = j; break; @@ -4138,7 +4138,7 @@ _46E44E_collide_against_faces_and_portals(1u); _46E0B2_collide_against_decorations(); _46EF01_collision_chech_player(0); - _46ED8A_collide_against_layingItems(_this); + _46ED8A_collide_against_sprite_objects(_this); v25 = 0; v56 = 0; if ( ai_arrays_size > v22 ) @@ -4487,7 +4487,7 @@ if ( !(dword_6BE364_game_settings_1 & 0x2000) ) { InitializeActors(); - InitializeLayingItems(); + InitializeSpriteObjects(); } BYTE1(dword_6BE364_game_settings_1) &= 0xDFu; if ( !v39 ) @@ -4658,9 +4658,9 @@ pGameLoadingUI_ProgressBar->Progress(); - for (uint i = 0; i < uNumLayingItems; ++i) + for (uint i = 0; i < uNumSpriteObjects; ++i) { - auto p = pLayingItems + i; + auto p = pSpriteObjects + i; if (p->uObjectDescID) { auto uItemID = p->stru_24.uItemID; diff -r cf366ba68de5 -r 1bd8758f50b8 Indoor.h --- a/Indoor.h Mon Mar 04 09:22:29 2013 +0600 +++ b/Indoor.h Mon Mar 04 09:22:38 2013 +0600 @@ -42,7 +42,7 @@ #pragma pack(pop) extern LevelDecoration pLevelDecorations[3000]; extern size_t uNumLevelDecorations; -extern int GlobalEventInfo; +extern LevelDecoration* activeLevelDecoration; diff -r cf366ba68de5 -r 1bd8758f50b8 IndoorCameraD3D.h --- a/IndoorCameraD3D.h Mon Mar 04 09:22:29 2013 +0600 +++ b/IndoorCameraD3D.h Mon Mar 04 09:22:38 2013 +0600 @@ -14,7 +14,7 @@ //----- (004C039C) -------------------------------------------------------- //void ~IndoorCameraD3D_Vec3() {} - void (__thiscall ***vdestructor_ptr)(IndoorCameraD3D_Vec3 *, bool); + //void (__thiscall ***vdestructor_ptr)(IndoorCameraD3D_Vec3 *, bool); union { @@ -43,6 +43,7 @@ {} float dot; + int _wtf; // sizeof vec4 is 18 and first member is vdtor, but vdtor is already included in vec3 so very weird }; #pragma pack(pop) @@ -157,7 +158,7 @@ void ViewTransfrom_OffsetUV(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *pOutVertices, struct stru320 *a5); char ApplyViewTransform_TrueIfStillVisible(int x, int y, int z, signed int *pOutX, int *pOutZ, int *pOutY, char bDoNotShow); - void (__thiscall ***vdestructor_ptr)(IndoorCameraD3D *, bool); + //void (__thiscall ***vdestructor_ptr)(IndoorCameraD3D *, bool); IndoorCameraD3D_Vec3 field_4[3]; //IndoorCameraD3D_Vec3 field_14; //IndoorCameraD3D_Vec3 field_24; diff -r cf366ba68de5 -r 1bd8758f50b8 Items.cpp --- a/Items.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/Items.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -25,9 +25,9 @@ }; -char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12}; +const char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12}; -ITEM_VARIATION shopWeap_variation_ord[15] ={ +const ITEM_VARIATION shopWeap_variation_ord[15] ={ { 0, { 0, 0, 0, 0 }}, { 1, { 23, 27, 20, 20 }}, { 1, { 23, 24, 28, 20 }}, @@ -44,7 +44,7 @@ { 2, { 30, 26, 26, 26 }}, { 2, { 28, 25, 28, 29 }}}; -ITEM_VARIATION shopArmr_variation_ord[28] ={ +const ITEM_VARIATION shopArmr_variation_ord[28] ={ { 1, { 35, 35, 38, 38 }}, { 1, { 31, 31, 31, 34 }}, { 1, { 35, 35, 38, 38 }}, @@ -76,10 +76,10 @@ -unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2}; -unsigned __int16 shopAlch_treasure_lvl[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2}; +const unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2}; +const unsigned __int16 shopAlch_treasure_lvl[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2}; -ITEM_VARIATION shopWeap_variation_spc[15]={ +const ITEM_VARIATION shopWeap_variation_spc[15]={ { 0, { 0, 0, 0, 0 }}, { 2, { 25, 30, 20, 20}}, { 2, { 23, 24, 28, 20}}, @@ -96,7 +96,7 @@ { 4, { 30, 26, 26, 26}}, { 4, { 28, 25, 28, 29}}}; -ITEM_VARIATION shopArmr_variation_spc[28]={ +const ITEM_VARIATION shopArmr_variation_spc[28]={ { 2, { 35, 35, 38, 38 }}, { 2, { 31, 31, 31, 34 }}, { 2, { 35, 35, 38, 38 }}, @@ -127,8 +127,18 @@ { 5, { 33, 33, 33, 33 }} }; -unsigned __int16 shopMagicSpc_treasure_lvl[14] = {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3}; -unsigned __int16 shopAlchSpc_treasure_lvl[13] = {0, 2, 2, 3, 3, 4, 4, 5, 5, 3, 2, 2, 2}; +const unsigned __int16 shopMagicSpc_treasure_lvl[14] = {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3}; +const unsigned __int16 shopAlchSpc_treasure_lvl[13] = {0, 2, 2, 3, 3, 4, 4, 5, 5, 3, 2, 2, 2}; + + +char byte_4E8168[7][14]={ //byte_4E8178 + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + { 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, + { 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}, + { 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4}, + { 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5}, + { 2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6}, + { 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}}; int sub_4BE571(int a1, int *a2, int a3, int a4); @@ -2043,8 +2053,8 @@ //----- (00450218) -------------------------------------------------------- -void __cdecl sub_450218_prolly_generate_chests_loot() - { +void sub_450218_prolly_generate_chests_loot() + { unsigned int v0; // eax@1 Chest *v1; // ebx@1 MapInfo *v2; // esi@1 @@ -2076,14 +2086,13 @@ v2 = &pMapStats->pInfos[v0]; v21 = pChests; v20 = &pMapStats->pInfos[v0]; - do + for(int i=0; i<20;++i) { - v3 = v1->mm7__vector_pItems; - v23 = 140; - do + for(int j=0; j<140;++j) { - if ( (v3->uItemID & 0x80000000u) == 0 ) - goto LABEL_56; + v3 = &pChests[i].igChestItems[j]; + if ( v3->uItemID < 0 ) + { v4 = rand() % 5 + 1; v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3]; @@ -2091,6 +2100,13 @@ v8 = v6 - v5 + 1; v9 = v5 + v7 % v8; v19 = v5 + v7 % v8; + /* switch (v9) + { + default: + + }*/ + + if ( v9 < 7 ) { if ( v18 < 20 ) @@ -2146,7 +2162,7 @@ v13 = v12; if ( v12 >= 140 ) goto LABEL_52; - v14 = &v21->mm7__vector_pItems[v12]; + v14 = &v21->igChestItems[v12]; while ( v14->uItemID ) { ++v13; @@ -2226,17 +2242,14 @@ goto LABEL_25; } v3->GenerateArtifact(); + LABEL_55: v2 = v20; -LABEL_56: - ++v3; - --v23; - } - while ( v23 ); - v1 = v21 + 1; - ++v21; +LABEL_56: ; + } + } } - while ( (signed int)v21 < (signed int)&uNumChests ); + } diff -r cf366ba68de5 -r 1bd8758f50b8 Items.h --- a/Items.h Mon Mar 04 09:22:29 2013 +0600 +++ b/Items.h Mon Mar 04 09:22:38 2013 +0600 @@ -64,8 +64,25 @@ ITEM_SPELLBOOK_LIGHT_SUN_BURST = 0x1E6, ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION = 0x1E7, ITEM_ARTIFACT_PUCK = 0x1F4, + ITEM_ARTICACT_GOVERNONS_ARMOR = 504,//1F8 + ITEM_ARTIFACT_YORUBA = 505,//1F9 ITEM_ARTIFACT_SPLITTER = 506,//1FA + ITEM_ARTIFACT_LEAGUE_BOOTS = 512,//200 + ITEM_RELIC_HARECS_LEATHER = 516,//204 + ITEM_RELIC_TALEDONS_HELM = 521,//209 + ITEM_RELIC_SCHOLARS_CAP = 522,//20A + ITEM_RELIC_PHYNAXIAN_CROWN = 523,//20B + ITEM_RILIC_TITANS_BELT = 524,//20C + ITEM_RELIC_TWILIGHT = 525,//20D ITEM_RELIC_MEKORIGS_HAMMER = 0x210, + ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP = 530,//212 + ITEM_ARTIFACT_MINDS_EYE = 532,//214 + ITEM_ELVEN_CHAINMAIL = 533,//215 + ITEM_ARTIFAT_HEROS_BELT = 535,//217 + ITEM_RARE_SHADOWS_MASK = 544,//220 + ITEM_RARE_SUN_CLOAK = 547,//223 + ITEM_RARE_MOON_CLOAK = 548,//224 + ITEM_RARE_VAMPIRES_CAPE = 550,//226 ITEM_LICH_JAR = 601 }; @@ -99,7 +116,7 @@ /* 64 */ #pragma pack(push, 1) -struct ItemGen +struct ItemGen //0x24 { //----- (0042EB25) -------------------------------------------------------- inline ItemGen() @@ -122,7 +139,7 @@ - unsigned int uItemID; + int uItemID; int uEncantmentType; int _bonus_strength; int uSpecEnchantmentType; // 25: +5 levels @@ -273,7 +290,7 @@ void GenerateStandartShopItems(); void GenerateSpecialShopItems(); - +extern const char uItemsAmountPerShopType[]; // weak extern ItemGen *ptr_50C9A4; extern struct ItemsTable *pItemsTable; diff -r cf366ba68de5 -r 1bd8758f50b8 LayingItem.cpp --- a/LayingItem.cpp Mon Mar 04 09:22:29 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -#include "LayingItem.h" -#include "Party.h" -#include "TurnEngine.h" -#include "MapInfo.h" - -#include "mm7_data.h" - - - - -size_t uNumLayingItems; -LayingItem pLayingItems[1000]; - - -//----- (00438E35) -------------------------------------------------------- -void LayingItem::_438E35() -{ - LayingItem *v1; // edi@1 - MapInfo *pMapInfo; // esi@1 - int v3; // ebx@1 - int v4; // eax@1 - int v5; // ebx@1 - unsigned int v6; // ecx@1 - int v7; // edx@2 - unsigned int v8; // edx@4 - unsigned int v9; // edx@6 - unsigned int v10; // eax@7 - signed int v11; // ebx@8 - Player **v12; // esi@18 - signed int v13; // edi@20 - int v15; // [sp+Ch] [bp-Ch]@1 - int v16; // [sp+10h] [bp-8h]@1 - signed int v17; // [sp+14h] [bp-4h]@8 - int v18; // [sp+14h] [bp-4h]@14 - - v1 = this; - pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]; - v3 = abs(pParty->vPosition.x - v1->vPosition.x); - v15 = abs(pParty->vPosition.y - v1->vPosition.y); - v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z); - v4 = v3; - v5 = v15; - v6 = v16; - if ( v4 < v15 ) - { - v7 = v4; - v4 = v15; - v5 = v7; - } - if ( v4 < v16 ) - { - v8 = v4; - v4 = v16; - v6 = v8; - } - if ( v5 < (signed int)v6 ) - { - v9 = v6; - v6 = v5; - v5 = v9; - } - v10 = ((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4; - if ( (signed int)v10 <= 768 ) - { - v17 = 0; - v11 = 5; - if ( pMapInfo->Trap_D20 ) - { - do - { - ++v17; - v11 += rand() % 20 + 1; - } - while ( v17 < pMapInfo->Trap_D20 ); - } - switch ( v1->uItemType ) - { - case 0x32Bu: - v18 = 0; - break; - case 0x32Cu: - v18 = 1; - break; - case 0x32Du: - v18 = 2; - break; - default: - //LOWORD(v10) = v1->uItemType - 814; - if ( v1->uItemType != 814 ) - return; - v18 = 8; - break; - } - v12 = &pPlayers[1]; - do - { - if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) ) - (*v12)->PlaySound(SPEECH_6, 0); - else - (*v12)->ReceiveDamage(v11, v18); - ++v12; - } - while ( (signed int)v12 <= (signed int)&pPlayers[4] ); - } -} - - - -//----- (0042F933) -------------------------------------------------------- -void LayingItem::OnItemPickup(unsigned int uLayingItemID) -{ - unsigned int v1; // ecx@1 - unsigned __int16 *pAttributes; // ecx@2 - unsigned __int16 v3; // ax@2 - - //__debugbreak(); // find out what's going on - - v1 = uLayingItemID; - pLayingItems[v1].uObjectDescID = 0; - if ( pParty->bTurnBasedModeOn == 1 ) - { - pAttributes = &pLayingItems[v1].uAttributes; - v3 = *pAttributes; - if ( *pAttributes & 4 ) - { - v3 = v3 & 0xFB; - --pTurnEngine->field_1C; - *pAttributes = v3; - } - } -} diff -r cf366ba68de5 -r 1bd8758f50b8 LayingItem.h --- a/LayingItem.h Mon Mar 04 09:22:29 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -#pragma once -#include "VectorTypes.h" -#include "Items.h" - -enum -{ - OBJECT_ATTACHED_TO_ACTOR = 0x80, -}; - - -/* 72 */ -#pragma pack(push, 1) -struct LayingItem -{ - inline bool AttachedToActor() const {return uAttributes & OBJECT_ATTACHED_TO_ACTOR;} - - LayingItem(); - int Create(int yaw, int pitch, int a4, int a5); - void _46BEF1_apply_spells(); - void _438E35(); - - static void UpdateObject_fn0_BLV(unsigned int uLayingItemID); - static void UpdateObject_fn0_ODM(unsigned int uLayingItemID); - static void OnItemPickup(unsigned int uLayingItemID); - - - unsigned __int16 uItemType; - unsigned __int16 uObjectDescID; - struct Vec3_int_ vPosition; - struct Vec3_short_ vVelocity; - unsigned __int16 uFacing; - unsigned __int16 uSoundID; - unsigned __int16 uAttributes; - __int16 uSectorID; - unsigned __int16 uSpriteFrameID; - __int16 field_20; - __int16 field_22_glow_radius_multiplier; - struct ItemGen stru_24; - int field_48; - int field_4C; - int field_50; - int field_54; - int field_58_pid; - int field_5C; - char field_60_distance_related_prolly_lod; - char field_61; - char field_62[14]; -}; -#pragma pack(pop) - - - -extern size_t uNumLayingItems; -extern LayingItem pLayingItems[1000]; \ No newline at end of file diff -r cf366ba68de5 -r 1bd8758f50b8 LightmapBuilder.h --- a/LightmapBuilder.h Mon Mar 04 09:22:29 2013 +0600 +++ b/LightmapBuilder.h Mon Mar 04 09:22:38 2013 +0600 @@ -9,8 +9,9 @@ struct Lightmap { Lightmap(); + virtual ~Lightmap() {} - void (__thiscall ***vdestructor_ptr)(Lightmap *, bool); + //void (__thiscall ***vdestructor_ptr)(Lightmap *, bool); unsigned int uNumVertices; RenderVertexSoft pVertices[64]; __int16 field_C08; @@ -29,7 +30,7 @@ struct LightmapBuilder { LightmapBuilder(); - inline ~LightmapBuilder() //----- (0045BBAA) + virtual ~LightmapBuilder() //----- (0045BBAA) {} void DoDrawLightmaps(); @@ -57,7 +58,7 @@ bool ApplyLights(struct stru320 *a2, struct stru154 *a3, unsigned int uNumVertices, struct RenderVertexSoft *a5, struct IndoorCameraD3D_Vec4 *, char uClipFlag); - void (__thiscall ***vdestructor_ptr)(LightmapBuilder *, bool); + //void (__thiscall ***vdestructor_ptr)(LightmapBuilder *, bool); //std::vector std__vector_000004; //std::vector std__vector_183808; Lightmap std__vector_000004[512]; diff -r cf366ba68de5 -r 1bd8758f50b8 Lights.h --- a/Lights.h Mon Mar 04 09:22:29 2013 +0600 +++ b/Lights.h Mon Mar 04 09:22:38 2013 +0600 @@ -98,7 +98,7 @@ - void (__thiscall ***vdestructor_ptr)(LightsStack_StationaryLight_ *, bool); + //void (__thiscall ***vdestructor_ptr)(LightsStack_StationaryLight_ *, bool); StationaryLight pLights[400]; unsigned int uNumLightsActive; }; @@ -127,7 +127,7 @@ - void (__thiscall ***vdestructor_ptr)(LightsStack_MobileLight_ *, bool); + //void (__thiscall ***vdestructor_ptr)(LightsStack_MobileLight_ *, bool); MobileLight pLights[400]; unsigned int uNumLightsActive; }; diff -r cf366ba68de5 -r 1bd8758f50b8 MM7.h --- a/MM7.h Mon Mar 04 09:22:29 2013 +0600 +++ b/MM7.h Mon Mar 04 09:22:38 2013 +0600 @@ -212,38 +212,22 @@ #pragma pack(pop) extern int paperdoll_Weapon[4][16][2]; -/* 371 */ -#pragma pack(push, 1) -struct stru331 -{ - int field_0; - int field_4; - int field_8; - int field_C; - int field_10; - int field_14; - int field_18; - int field_1C; - int field_20; - int field_24; - int field_28; - int field_2C; - int field_30; - int field_34; - int field_38; - int field_3C; -}; -#pragma pack(pop) +/* 371 */ // stru331 - deleted + /* 372 */ #pragma pack(push, 1) struct stru332 { unsigned int texids[11]; - stru331 field_2C; + int texid1; + int texid2; + int texid3; + int texid4; + int texid5; }; #pragma pack(pop) -extern stru332 stru_511698; +extern stru332 stru_511698[]; /* 373 */ @@ -251,11 +235,11 @@ struct stru333 { unsigned int texids[5]; - unsigned int *texid1; - int field_18; + int texid1; + int texid2; }; #pragma pack(pop) -extern stru333 stru_511718; +extern stru333 stru_511718[]; /* 374 */ diff -r cf366ba68de5 -r 1bd8758f50b8 MM7.vcxproj.filters --- a/MM7.vcxproj.filters Mon Mar 04 09:22:29 2013 +0600 +++ b/MM7.vcxproj.filters Mon Mar 04 09:22:38 2013 +0600 @@ -127,7 +127,6 @@ - @@ -202,6 +201,7 @@ + @@ -258,7 +258,6 @@ - @@ -321,6 +320,7 @@ + diff -r cf366ba68de5 -r 1bd8758f50b8 Outdoor.cpp --- a/Outdoor.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/Outdoor.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -2,7 +2,7 @@ #include "Outdoor.h" #include "Party.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "LOD.h" #include "Render.h" #include "MapInfo.h" @@ -135,7 +135,7 @@ if (!pOutdoorCamera->bDoNotRenderDecorations) pRenderer->PrepareDecorationsRenderList_ODM(); - pRenderer->DrawLayingItems_Shooting_Magic_ODM(); + pRenderer->DrawSpriteObjects_ODM(); pRenderer->TransformBillboardsAndSetPalettesODM(); sub_485F53((Vec2_int_ *)unnamed_6BE060); } @@ -1209,7 +1209,7 @@ __int16 v20; // ax@16 int v21; // ecx@16 ODMFace *v22; // ebx@26 - LayingItem *pItems; // ecx@27 + SpriteObject *pItems; // ecx@27 unsigned int v24; // eax@28 //unsigned __int8 v25; // zf@28 //unsigned __int8 v26; // sf@28 @@ -1391,7 +1391,7 @@ fseek((FILE *)v7, v114, 0); fread(&uNumBModels, 4u, 1u, (FILE *)v7); fseek((FILE *)v7, v115, 0); - fread(&uNumLayingItems, 4u, 1u, (FILE *)v7); + fread(&uNumSpriteObjects, 4u, 1u, (FILE *)v7); fseek((FILE *)v7, v116, 0); fread(&uNumLevelDecorations, 4u, 1u, (FILE *)v7); fseek((FILE *)v7, v117, 0); @@ -1518,11 +1518,11 @@ LABEL_26: v22 = File; fseek((FILE *)File, v124, 0); - fread(pLayingItems, 0x70u, uNumLayingItems, (FILE *)v22); - if ( (signed int)uNumLayingItems > 0 ) + fread(pSpriteObjects, 0x70u, uNumSpriteObjects, (FILE *)v22); + if ( (signed int)uNumSpriteObjects > 0 ) { - pItems = pLayingItems; - pNumItems = uNumLayingItems; + pItems = pSpriteObjects; + pNumItems = uNumSpriteObjects; do { v24 = pItems->stru_24.uItemID; @@ -2222,15 +2222,15 @@ //v92 = (char *)v91 + (int)pFilename; pGameLoadingUI_ProgressBar->Progress(); - memcpy(&uNumLayingItems, pSrc, 4); - assert(uNumLayingItems <= 1000 && "Too many objects"); - assert(sizeof(LayingItem) == 112); + memcpy(&uNumSpriteObjects, pSrc, 4); + assert(uNumSpriteObjects <= 1000 && "Too many objects"); + assert(sizeof(SpriteObject) == 112); pGameLoadingUI_ProgressBar->Progress(); - //pFilename = (char *)(112 * uNumLayingItems); - memcpy(pLayingItems, pSrc + 4, uNumLayingItems * sizeof(LayingItem)); - pSrc += 4 + uNumLayingItems * sizeof(LayingItem); + //pFilename = (char *)(112 * uNumSpriteObjects); + memcpy(pSpriteObjects, pSrc + 4, uNumSpriteObjects * sizeof(SpriteObject)); + pSrc += 4 + uNumSpriteObjects * sizeof(SpriteObject); //v94 = (char *)v93 + (int)pFilename; pGameLoadingUI_ProgressBar->Progress(); @@ -2730,9 +2730,9 @@ v5 = this; v1 = 0; - if ( (signed int)uNumLayingItems > 0 ) + if ( (signed int)uNumSpriteObjects > 0 ) { - v2 = (char *)&pLayingItems[0].uObjectDescID; + v2 = (char *)&pSpriteObjects[0].uObjectDescID; do { if ( *(short *)v2 ) @@ -2750,7 +2750,7 @@ ++v1; v2 += 112; } - while ( v1 < (signed int)uNumLayingItems ); + while ( v1 < (signed int)uNumSpriteObjects ); } pGameLoadingUI_ProgressBar->Progress(); return 1; diff -r cf366ba68de5 -r 1bd8758f50b8 Party.h --- a/Party.h Mon Mar 04 09:22:29 2013 +0600 +++ b/Party.h Mon Mar 04 09:22:38 2013 +0600 @@ -120,6 +120,8 @@ int field_4F0[38]; char field_588[2]; __int64 _s_times[21]; //5d8 440h+8*51 + __int64 field_632[8]; + char field_672[6]; // char pIsArtifactFound[8]; }; #pragma pack(pop) @@ -277,10 +279,7 @@ ItemGen StandartItemsInShops[53][12]; ItemGen SpecialItemsInShops[53][12]; //D0EC ItemGen SpellBooksInGuilds[32][12]; - //int field_12A5C[2117]; - // char field_14B70[5000]; - //char field_15EF8[250]; - //char field_15FF2[130]; + char field_1605C[24]; char pHireling1Name[100]; char pHireling2Name[100]; int armageddon_timer; diff -r cf366ba68de5 -r 1bd8758f50b8 Player.cpp --- a/Player.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/Player.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -8868,9 +8868,8 @@ return; case VAR_Award: v13 = pPlayers[uPlayerIdx + 1]; - v33 = 0x80u >> ((signed __int16)val - 1) % 8; - if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & v13->_guilds_member_bits[((signed __int16)val - 1) >> 3]) - //&& dword_723E80_award_related[2 * val] ) + if (_449B57_test_bit((unsigned __int8 *)pPlayers[uPlayerIdx + 1]->_guilds_member_bits, val) + && pAwards[val].pText ) { v14 = pPlayers[uPlayerIdx + 1]; diff -r cf366ba68de5 -r 1bd8758f50b8 Render.cpp --- a/Render.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/Render.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -14,7 +14,7 @@ #include "LightmapBuilder.h" #include "stru220.h" #include "ObjectList.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "DecorationList.h" #include "Allocator.h" #include "OSInfo.h" @@ -3050,7 +3050,7 @@ //----- (0047AF11) -------------------------------------------------------- -void Render::DrawLayingItems_Shooting_Magic_ODM() +void Render::DrawSpriteObjects_ODM() { //char *v0; // edi@2 //ObjectDesc *v1; // ebx@4 @@ -3101,11 +3101,11 @@ signed __int16 v46; // [sp+3Ch] [bp-4h]@12 //v41 = 0; - for (int i = 0; i < uNumLayingItems; ++i) - { - auto object = pLayingItems + i; - //auto v0 = (char *)&pLayingItems[i].uSectorID; - //v0 = (char *)&pLayingItems[0].uSectorID; + for (int i = 0; i < uNumSpriteObjects; ++i) + { + auto object = pSpriteObjects + i; + //auto v0 = (char *)&pSpriteObjects[i].uSectorID; + //v0 = (char *)&pSpriteObjects[0].uSectorID; //do //{ if (!object->uObjectDescID) // item probably pciked up @@ -3120,7 +3120,7 @@ //if ( !(v1->uFlags & 1) ) //{ //v2 = *((short *)v0 - 14) - v2 = object->uItemType; + v2 = object->uType; if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) { //a5 = *(short *)v0; @@ -3249,7 +3249,7 @@ //++v41; //v0 += 112; //} - //while ( v41 < (signed int)uNumLayingItems ); + //while ( v41 < (signed int)uNumSpriteObjects ); } } // 4E94D3: using guessed type char byte_4E94D3; diff -r cf366ba68de5 -r 1bd8758f50b8 Render.h --- a/Render.h Mon Mar 04 09:22:29 2013 +0600 +++ b/Render.h Mon Mar 04 09:22:38 2013 +0600 @@ -362,7 +362,7 @@ void DrawSkyD3D(); int DrawSkySW(struct Span *a1, stru148 *a2, int a3); void PrepareDecorationsRenderList_ODM(); - void DrawLayingItems_Shooting_Magic_ODM(); + void DrawSpriteObjects_ODM(); void TransformBillboardsAndSetPalettesODM(); float DrawBezierTerrain(); void RenderTerrainD3D(); diff -r cf366ba68de5 -r 1bd8758f50b8 SaveLoad.cpp --- a/SaveLoad.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/SaveLoad.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -14,7 +14,7 @@ #include "GUIWindow.h" #include "GUIFont.h" #include "Overlays.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "Viewport.h" #include "stru123.h" #include "texts.h" @@ -467,10 +467,10 @@ v12 = (char *)v11 + 4; memcpy(v12, pActors, 836 * uNumActors); v13 = (char *)v12 + 836 * uNumActors; - memcpy(v13, &uNumLayingItems, 4); + memcpy(v13, &uNumSpriteObjects, 4); v13 = (char *)v13 + 4; - memcpy(v13, pLayingItems, 112 * uNumLayingItems); - v14 = (char *)v13 + 112 * uNumLayingItems; + memcpy(v13, pSpriteObjects, 112 * uNumSpriteObjects); + v14 = (char *)v13 + 112 * uNumSpriteObjects; memcpy(v14, &uNumChests, 4); v14 = (char *)v14 + 4; memcpy(v14, pChests, 5324 * uNumChests); @@ -546,10 +546,10 @@ v28 = (char *)v22 + 4; memcpy(v28, pActors, 836 * uNumActors); v29 = (char *)v28 + 836 * uNumActors; - memcpy(v29, &uNumLayingItems, 4); + memcpy(v29, &uNumSpriteObjects, 4); v29 = (char *)v29 + 4; - memcpy(v29, pLayingItems, 112 * uNumLayingItems); - v30 = (char *)v29 + 112 * uNumLayingItems; + memcpy(v29, pSpriteObjects, 112 * uNumSpriteObjects); + v30 = (char *)v29 + 112 * uNumSpriteObjects; memcpy(v30, &uNumChests, 4); v30 = (char *)v30 + 4; memcpy(v30, pChests, 5324 * uNumChests); diff -r cf366ba68de5 -r 1bd8758f50b8 SpriteObject.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SpriteObject.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -0,0 +1,1085 @@ +#include + +#include "SpriteObject.h" +#include "Party.h" +#include "TurnEngine.h" +#include "MapInfo.h" +#include "Math.h" +#include "ObjectList.h" +#include "Indoor.h" +#include "Outdoor.h" +#include "ParticleEngine.h" +#include "Time.h" +#include "Game.h" +#include "LOD.h" +#include "Actor.h" +#include "Events.h" + +#include "mm7_data.h" + + + + +size_t uNumSpriteObjects; +SpriteObject pSpriteObjects[1000]; + + + + +//----- (0042F5ED) -------------------------------------------------------- +int SpriteObject::Create(int yaw, int pitch, int a4, int a5) +{ + //SpriteObject *v5; // eax@1 + signed int v6; // ebx@2 + //char *v7; // ecx@2 + //signed int result; // eax@6 + SpriteObject *v9; // ebx@7 + int v10; // edx@11 + int v11; // edi@18 + __int16 v12; // ax@18 + int v13; // ST2C_4@20 + int v14; // eax@20 + int v15; // [sp-28h] [bp-38h]@14 + int v16; // [sp-24h] [bp-34h]@11 + Vec3_int_ v17; // [sp-20h] [bp-30h]@11 + int *v18; // [sp-14h] [bp-24h]@11 + int *v19; // [sp-10h] [bp-20h]@11 + int *v20; // [sp-Ch] [bp-1Ch]@11 + //signed int v21; // [sp+8h] [bp-8h]@2 + int angle; // [sp+Ch] [bp-4h]@1 + int a4a; // [sp+1Ch] [bp+Ch]@20 + int a4b; // [sp+1Ch] [bp+Ch]@20 + int a5a; // [sp+20h] [bp+10h]@20 + + //auto a1 = this; + angle = yaw; + //v5 = a1; + if (!uObjectDescID) + return -1; + + v6 = 1000; + //v7 = (char *)&pSpriteObjects[0].uObjectDescID; + /*v21 = 0; + do + { + if ( !*(short *)v7 ) + break; + v7 += 112; + ++v6; + v21 = v6; + } + while ( (signed int)v7 < (signed int)((char *)&pObjectList->uNumObjects + 2) );*/ + for (uint i = 0; i < 1000; ++i) + if (!pSpriteObjects[i].uObjectDescID) + { + v6 = i; + break; + } + + if ( v6 >= 1000 ) + return -1; + field_64.x = vPosition.x; + field_64.y = vPosition.y; + v9 = &pSpriteObjects[v6]; + field_64.z = vPosition.z; + + assert(sizeof(SpriteObject) == 0x70); + memcpy(v9, this, sizeof(*this)); + if ( a5 == 1 ) + { + v20 = &v9->vPosition.z; + v19 = &v9->vPosition.y; + v18 = (int *)&v9->vPosition; + v17.x = vPosition.x; + v17.y = vPosition.y; + v17.z = vPosition.z; + v16 = 0; + v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; + goto LABEL_16; + } + if ( a5 == 2 ) + { + v20 = &v9->vPosition.z; + v19 = &v9->vPosition.y; + v18 = (int *)&v9->vPosition; + v17.x = vPosition.x; + v17.y = vPosition.y; + v17.z = vPosition.z; + v16 = 0; + v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; + goto LABEL_14; + } + if ( a5 == 3 ) + { + v20 = &v9->vPosition.z; + v19 = &v9->vPosition.y; + v18 = (int *)&v9->vPosition; + v17.x = vPosition.x; + v17.y = vPosition.y; + v17.z = vPosition.z; + v16 = 0; + v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; +LABEL_14: + v15 = 8; +LABEL_17: + Vec3_int_::Rotate(v15, v10, v16, v17, v18, v19, v20); + goto LABEL_18; + } + if ( a5 == 4 ) + { + v20 = &v9->vPosition.z; + v19 = &v9->vPosition.y; + v18 = (int *)&v9->vPosition; + v17.x = vPosition.x; + v17.y = vPosition.y; + v17.z = vPosition.z; + v16 = 0; + v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; +LABEL_16: + v15 = 24; + goto LABEL_17; + } +LABEL_18: + v11 = a4; + v12 = 0; + if ( a4 ) + { + a4a = stru_5C6E00->Cos(angle); + v13 = (unsigned __int64)(a4a * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a4b = stru_5C6E00->Sin(angle); + a5a = (unsigned __int64)(a4b * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + v14 = stru_5C6E00->Sin(pitch); + v9->vVelocity.x = (unsigned int)(v13 * v11) >> 16; + v9->vVelocity.y = (unsigned int)(a5a * v11) >> 16; + v12 = (unsigned int)(v14 * v11) >> 16; + } + else + { + v9->vVelocity.y = 0; + v9->vVelocity.x = 0; + } + v9->vVelocity.z = v12; + + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; +} + + + +//----- (00471C03) -------------------------------------------------------- +void SpriteObject::UpdateObject_fn0_ODM(unsigned int uLayingItemID) +{ + SpriteObject *v1; // esi@1 + ObjectDesc *v2; // ebx@1 + signed int v3; // edx@1 + int v4; // ecx@1 + int v5; // ST04_4@1 + int v6; // eax@1 + int v7; // ecx@1 + int v8; // edi@1 + int v9; // eax@4 + __int16 v10; // ax@7 + int v11; // edx@11 + int v12; // ecx@11 + signed int v13; // edx@14 + signed int v14; // edx@16 + int v15; // eax@24 + int v16; // eax@25 + int v17; // ST10_4@25 + signed int v18; // eax@25 + signed int v19; // eax@28 + Actor *v20; // edi@31 + int v21; // eax@41 + int v22; // ecx@43 + __int16 v23; // bx@45 + char v24; // al@46 + signed int i; // edi@50 + int v26; // edi@52 + int v27; // eax@52 + __int16 v28; // cx@55 + int v29; // eax@55 + signed int v30; // edi@59 + BSPModel *v31; // ecx@61 + ODMFace *v32; // edi@61 + int v33; // eax@62 + int v34; // ecx@62 + int v35; // eax@63 + Actor *v36; // ecx@67 + __int16 v37; // ax@67 + int v38; // eax@72 + int v39; // eax@72 + unsigned __int64 v40; // qax@72 + int v41; // eax@72 + unsigned __int8 v42; // sf@74 + unsigned __int8 v43; // of@74 + int v44; // eax@77 + __int16 v45; // bx@81 + int v46; // eax@85 + const char *v47; // [sp-8h] [bp-B0h]@83 + enum TEXTURE_TYPE v48; // [sp-4h] [bp-ACh]@46 + int v49; // [sp+Ch] [bp-9Ch]@52 + int v50; // [sp+10h] [bp-98h]@52 + Vec3_int_ v51; // [sp+14h] [bp-94h]@11 + Particle_ Dst; // [sp+20h] [bp-88h]@45 + unsigned int uLayingItemID_; // [sp+88h] [bp-20h]@1 + int v54; // [sp+8Ch] [bp-1Ch]@1 + int v55; // [sp+90h] [bp-18h]@1 + int v56; // [sp+94h] [bp-14h]@11 + int v57; // [sp+98h] [bp-10h]@1 + int v58; // [sp+9Ch] [bp-Ch]@1 + int v59; // [sp+A0h] [bp-8h]@1 + Actor *v60; // [sp+A4h] [bp-4h]@11 + + uLayingItemID_ = uLayingItemID; + v1 = &pSpriteObjects[uLayingItemID]; + v58 = 0; + v2 = &pObjectList->pObjects[v1->uObjectDescID]; + v57 = IsTerrainSlopeTooHigh(v1->vPosition.x, v1->vPosition.y); + v3 = v1->vPosition.y; + v4 = v1->vPosition.x; + v5 = v2->uHeight; + v55 = 0; + v6 = sub_46D49E_prolly_get_world_y_under_party(v4, v3, v1->vPosition.z, v5, &v59, &v55, 0); + v7 = v6; + v54 = v6; + v8 = v6 + 1; + if ( v1->vPosition.z <= v6 + 1 ) + { + if ( v59 ) + { + v9 = v6 + 60; + if ( v55 ) + v9 = v7 + 30; + sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v9); + SpriteObject::OnInteraction(uLayingItemID_); + v7 = v54; + } + } + else + { + v58 = 1; + } + v10 = v2->uFlags; + if ( !(v10 & 0x20) ) + { + if ( v58 ) + { + v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); + goto LABEL_13; + } + if ( v57 ) + { + v11 = v1->vPosition.y; + v12 = v1->vPosition.x; + v1->vPosition.z = v8; + ODM_GetTerrainNormalAt(v12, v11, &v51); + v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); + v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16; + v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16); + v1->vVelocity.x += (unsigned int)(v56 * v51.x) >> 16; + v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16); + v1->vVelocity.y += (unsigned int)(v56 * v51.y) >> 16; + v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16); + v1->vVelocity.z += (unsigned int)(v56 * v51.z) >> 16; +LABEL_12: + v7 = v54; + goto LABEL_13; + } + if ( v10 & 0x40 ) + { + if ( v1->vPosition.z < v7 ) + v1->vPosition.z = v8; + if ( !_46BFFA_check_object_intercept(uLayingItemID_, 0) ) + return; + } + v1->vPosition.z = v8; + if ( !(v2->uFlags & 0x80) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) ) + v1->vVelocity.z = 0; + v60 = (Actor *)v1->vVelocity.x; + v55 = 58500; + v60 = (Actor *)((unsigned __int64)(58500i64 * (signed int)v60) >> 16); + v1->vVelocity.x = (signed __int16)v60; + v60 = (Actor *)v1->vVelocity.y; + v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16); + v55 = 58500; + v1->vVelocity.y = (signed __int16)v60; + v60 = (Actor *)v1->vVelocity.z; + v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16); + v22 = v1->vVelocity.x; + v1->vVelocity.z = (signed __int16)v60; + if ( v1->vVelocity.y * v1->vVelocity.y + v22 * v22 >= 400 ) + goto LABEL_12; + v1->vVelocity.y = 0; + v1->vVelocity.x = 0; + if ( !(HIBYTE(v2->uFlags) & 1) ) + return; + memset(&Dst, 0, 0x68u); + v23 = v2->uFlags; + Dst.x = (double)v1->vPosition.x; + Dst.y = (double)v1->vPosition.y; + Dst.z = (double)v1->vPosition.z; + Dst.flt_10 = 0.0; + Dst.flt_14 = 0.0; + Dst.flt_18 = 0.0; + if ( HIBYTE(v23) & 2 ) + { + Dst.bFree = 1036; + Dst.uDiffuse = 16727070; + v24 = rand(); + v48 = (TEXTURE_TYPE)0; +LABEL_83: + v47 = "effpar01"; + } + else + { + if ( HIBYTE(v23) & 4 ) + { + Dst.bFree = 512; + Dst.uDiffuse = rand(); + Dst.timeToLive = 64; + Dst.uTextureID = 0; +LABEL_89: + Dst.flt_28 = 1.0; + pGame->pParticleEngine->AddParticle(&Dst); + return; + } + Dst.bFree = 1032; + Dst.uDiffuse = rand(); + v24 = rand(); + v48 = (TEXTURE_TYPE)0; +LABEL_87: + v47 = "effpar03"; + } + Dst.timeToLive = (unsigned __int8)(v24 & 0x80) + 128; + Dst.uTextureID = pBitmaps_LOD->LoadTexture(v47, v48); + goto LABEL_89; + } +LABEL_13: + if ( v1->vPosition.z > v7 + && (v13 = v1->vPosition.x, v13 >= -32768) + && v13 <= 32768 + && (v14 = v1->vPosition.y, v14 >= -32768) + && v14 <= 32768 + && v1->vPosition.z <= 13000 + || !(v2->uFlags & 0x40) ) + goto LABEL_92; + if ( v1->vPosition.z < v7 ) + v1->vPosition.z = v8; + if ( _46BFFA_check_object_intercept(uLayingItemID_, 0) ) + { +LABEL_92: + stru_721530.field_0 = 0; + v55 = 0; + stru_721530.prolly_normal_d = v2->uRadius; + stru_721530.field_C = v2->uHeight; + stru_721530.field_8 = 0; + stru_721530.field_70 = 0; + while ( 1 ) + { + stru_721530.field_34.x = v1->vPosition.x; + stru_721530.normal.x = stru_721530.field_34.x; + v15 = v1->vPosition.y; + stru_721530.uSectorID = 0; + stru_721530.field_34.y = v15; + stru_721530.normal.y = v15; + stru_721530.field_34.z = v1->vPosition.z + stru_721530.prolly_normal_d + 1; + stru_721530.normal.z = stru_721530.field_34.z; + stru_721530.field_1C = v1->vVelocity.x; + stru_721530.field_20 = v1->vVelocity.y; + stru_721530.field_24 = v1->vVelocity.z; + if ( stru_721530._47050A(0) ) + return; + _46E889_collide_against_bmodels(0); + v16 = WorldPosToGridCellZ(v1->vPosition.y); + v17 = v1->vPosition.x; + v58 = v16; + v18 = WorldPosToGridCellX(v17); + _46E26D_collide_against_sprites(v18, v58); + if ( (v1->field_58_pid & 7) != OBJECT_Player) + _46EF01_collision_chech_player(0); + if ( (v1->field_58_pid & 7) == OBJECT_Actor) + { + v19 = v1->field_58_pid >> 3; + if ( v19 >= 0 ) + { + if ( v19 < (signed int)(uNumActors - 1) ) + { + v56 = 0; + if ( (signed int)uNumActors > 0 ) + { + v60 = pActors; + v20 = &pActors[v19]; + do + { + if ( v20->GetActorsRelation(v60) ) + _46DF1A_collide_against_actor(v56, 0); + ++v56; + ++v60; + } + while ( v56 < (signed int)uNumActors ); + } + } + } + } + else + { + for ( i = 0; i < (signed int)uNumActors; ++i ) + _46DF1A_collide_against_actor(i, 0); + } + v26 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; + v27 = sub_46D49E_prolly_get_world_y_under_party( + stru_721530.normal2.x, + stru_721530.normal2.y, + stru_721530.normal2.z - stru_721530.prolly_normal_d - 1, + v2->uHeight, + &v49, + &v50, + 0); + if ( v59 && v26 < v27 + 60 ) + { + if ( v50 ) + v44 = v27 + 30; + else + v44 = v54 + 60; + sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v44); + SpriteObject::OnInteraction(uLayingItemID_); + return; + } + if ( stru_721530.field_7C >= stru_721530.field_6C ) + { + v1->vPosition.x = stru_721530.normal2.x; + v1->vPosition.y = stru_721530.normal2.y; + v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; + v1->uSectorID = LOWORD(stru_721530.uSectorID); + if ( !(HIBYTE(v2->uFlags) & 1) ) + return; + memset(&Dst, 0, 0x68u); + v45 = v2->uFlags; + Dst.x = (double)v1->vPosition.x; + Dst.y = (double)v1->vPosition.y; + Dst.z = (double)v1->vPosition.z; + Dst.flt_10 = 0.0; + Dst.flt_14 = 0.0; + Dst.flt_18 = 0.0; + if ( HIBYTE(v45) & 2 ) + { + Dst.bFree = 1036; + Dst.uDiffuse = 16727070; + v24 = rand(); + v48 = (TEXTURE_TYPE)0; + goto LABEL_83; + } + if ( HIBYTE(v45) & 4 ) + { + Dst.bFree = 512; + v46 = rand(); + Dst.uTextureID = 0; + Dst.uDiffuse = v46; + Dst.timeToLive = 64; + goto LABEL_89; + } + Dst.bFree = 1032; + Dst.uDiffuse = rand(); + v24 = rand(); + v48 = (TEXTURE_TYPE)0; + goto LABEL_87; + } + v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16); + v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; + v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16); + v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; + v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16); + v28 = LOWORD(stru_721530.uSectorID); + v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; + v29 = v1->vPosition.z; + v1->uSectorID = v28; + stru_721530.field_70 += stru_721530.field_7C; + if ( v2->uFlags & 0x40 ) + { + if ( v29 < v54 ) + v1->vPosition.z = v54 + 1; + if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) + return; + } + v30 = (signed int)stru_721530.uFaceID >> 3; + if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + break; + if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) + { + v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; + v32 = &v31->pFaces[v30 & 0x3F]; + if ( v32->uPolygonType != 3 ) + { + v56 = abs(v32->pFacePlane.vNormal.z * v1->vVelocity.z + v32->pFacePlane.vNormal.y * v1->vVelocity.y + + v32->pFacePlane.vNormal.x * v1->vVelocity.x) >> 16; + if ( stru_721530.field_64 >> 3 > v56 ) + v56 = stru_721530.field_64 >> 3; + v57 = v32->pFacePlane.vNormal.x; + v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16; + v58 = v32->pFacePlane.vNormal.y; + v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16; + v60 = (Actor *)v32->pFacePlane.vNormal.z; + v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)(signed int)v60) >> 16); + v1->vVelocity.x += 2 * v57; + v1->vVelocity.y += 2 * v58; + if ( v32->pFacePlane.vNormal.z <= 32000 ) + { + v37 = 2 * (short)v60; + } + else + { + v36 = v60; + v57 = 32000; + v1->vVelocity.z += (signed __int16)v60; + v58 = (unsigned __int64)(v57 * (signed __int64)(signed int)v36) >> 16; + v37 = (unsigned int)(v57 * (int)v36) >> 16; + } + v1->vVelocity.z += v37; +LABEL_70: + if ( BYTE3(v32->uAttributes) & 0x10 ) + EventProcessor(v32->sCogTriggeredID, 0, 1); + goto LABEL_74; + } + v33 = v31->pVertices.pVertices[v32->pVertexIDs[0]].z; + v34 = v1->vVelocity.x; + v1->vPosition.z = v33 + 1; + if ( v1->vVelocity.y * v1->vVelocity.y + v34 * v34 >= 400 ) + goto LABEL_70; + LOWORD(v35) = 0; + v1->vVelocity.z = 0; + v1->vVelocity.x = 0; + goto LABEL_73; + } +LABEL_74: + v58 = v1->vVelocity.x; + v57 = 58500; + v58 = (unsigned __int64)(58500i64 * v58) >> 16; + v1->vVelocity.x = v58; + v58 = v1->vVelocity.y; + v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16; + v57 = 58500; + v1->vVelocity.y = v58; + v58 = v1->vVelocity.z; + v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16; + ++v55; + v43 = __OFSUB__(v55, 100); + v42 = v55 - 100 < 0; + v1->vVelocity.z = v58; + if ( !(v42 ^ v43) ) + return; + } + v57 = integer_sqrt(v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x); + v38 = stru_5C6E00->Atan2( + v1->vPosition.x - pLevelDecorations[v30].vPosition.x, + v1->vPosition.y - pLevelDecorations[v30].vPosition.y); + v56 = v38; + v39 = stru_5C6E00->Cos(v38); + v60 = (Actor *)v39; + v40 = v39 * (signed __int64)v57; + v58 = v40 >> 16; + v1->vVelocity.x = WORD1(v40); + v41 = stru_5C6E00->Sin(v56 - stru_5C6E00->uIntegerHalfPi); + v60 = (Actor *)v41; + v35 = (unsigned __int64)(v41 * (signed __int64)v57) >> 16; + v58 = v35; +LABEL_73: + v1->vVelocity.y = v35; + goto LABEL_74; + } +} + + + +//----- (0047136C) -------------------------------------------------------- +void SpriteObject::UpdateObject_fn0_BLV(unsigned int uLayingItemID) +{ + SpriteObject *v1; // esi@1 + ObjectDesc *v2; // edi@1 + int v3; // ST08_4@1 + __int16 v4; // ax@5 + __int16 v5; // ax@7 + BLVFace *v6; // ecx@11 + BLVFace *v7; // eax@11 + signed int v8; // ebx@12 + int v9; // ecx@16 + __int16 v10; // di@18 + char v11; // al@19 + int v12; // eax@25 + int v13; // eax@31 + int v14; // ebx@34 + signed int v15; // ebx@46 + BLVFace *v16; // edi@48 + int v17; // eax@50 + int v18; // eax@52 + int v19; // ecx@52 + Vec3_short_ *v20; // ecx@53 + int v21; // ecx@57 + __int16 v22; // ax@57 + int v23; // edi@62 + int v24; // edi@62 + int v25; // eax@62 + unsigned __int64 v26; // qax@62 + unsigned __int8 v27; // sf@64 + unsigned __int8 v28; // of@64 + __int16 v29; // di@67 + char v30; // al@68 + const char *v31; // [sp-8h] [bp-98h]@19 + const char *v32; // [sp-8h] [bp-98h]@68 + enum TEXTURE_TYPE v33; // [sp-4h] [bp-94h]@19 + enum TEXTURE_TYPE v34; // [sp-4h] [bp-94h]@68 + Particle_ Dst; // [sp+Ch] [bp-84h]@18 + unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1 + ObjectDesc *v37; // [sp+78h] [bp-18h]@1 + unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4 + int v39; // [sp+80h] [bp-10h]@33 + Actor *v39b; + int v40; // [sp+84h] [bp-Ch]@28 + int v41; // [sp+88h] [bp-8h]@34 + int v42; // [sp+8Ch] [bp-4h]@4 + + uLayingItemID_ = uLayingItemID; + v1 = &pSpriteObjects[uLayingItemID]; + v2 = &pObjectList->pObjects[v1->uObjectDescID]; + v3 = v1->vPosition.x; + v37 = &pObjectList->pObjects[v1->uObjectDescID]; + if ( abs(v3) > 32767 + || abs(v1->vPosition.y) > 32767 + || abs(v1->vPosition.z) > 20000 + || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v1->uSectorID, &uFaceID), + v42 <= -30000) + && ((v4 = pIndoor->GetSector(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z), + (v1->uSectorID = v4) == 0) + || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v4, &uFaceID), v42 == -30000)) ) + { + SpriteObject::OnInteraction(uLayingItemID_); + return; + } + v5 = v2->uFlags; + if ( v5 & 0x20 ) + { +LABEL_24: + v8 = 0; +LABEL_25: + stru_721530.field_0 = v8; + uFaceID = v8; + stru_721530.prolly_normal_d = v2->uRadius; + v12 = v2->uHeight; + stru_721530.field_84 = -1; + stru_721530.field_C = v12; + stru_721530.field_8 = v8; + stru_721530.field_70 = v8; + while ( 1 ) + { + stru_721530.field_34.x = v1->vPosition.x; + stru_721530.normal.x = stru_721530.field_34.x; + stru_721530.field_34.y = v1->vPosition.y; + stru_721530.normal.y = stru_721530.field_34.y; + stru_721530.field_34.z = stru_721530.prolly_normal_d + v1->vPosition.z + 1; + stru_721530.normal.z = stru_721530.field_34.z; + stru_721530.field_1C = v1->vVelocity.x; + stru_721530.field_20 = v1->vVelocity.y; + stru_721530.field_24 = v1->vVelocity.z; + stru_721530.uSectorID = v1->uSectorID; + if ( stru_721530._47050A(v8) ) + return; + v40 = v8; + do + { + _46E44E_collide_against_faces_and_portals(0); + _46E0B2_collide_against_decorations(); + if ( (v1->field_58_pid & 7) != OBJECT_Player) + _46EF01_collision_chech_player(1); + v13 = v1->field_58_pid; + v42 = v8; + if ( (v13 & 7) == OBJECT_Actor) + { + if ( (signed int)uNumActors > v8 ) + { + v39b = pActors;//[0].word_000086_some_monster_id; + do + { + //v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1; + //v14 = (signed __int64)((double)v41 * 0.3333333333333333); + //v41 = *(short *)(v39 - 38) - 1; + //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) ) + if( pActors[v1->field_58_pid >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID ) + //not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius + _46DF1A_collide_against_actor(v42, *((short *)&pMonsterList->pMonsters[v39b->word_000086_some_monster_id] - 73)); + ++v42; + ++v39b;// += 836; + } + while ( v42 < (signed int)uNumActors ); + v8 = 0; + } + } + else + { + if ( (signed int)uNumActors > v8 ) + { + v39b = pActors;//[0].word_000086_some_monster_id; + do + { + _46DF1A_collide_against_actor(v42++, *((short *)&pMonsterList->pMonsters[*(short *)v39b] - 73)); + ++v39b; + } + while ( v42 < (signed int)uNumActors ); + } + } + if ( _46F04E_collide_against_portals() ) + break; + ++v40; + } + while ( v40 < 100 ); + if ( stru_721530.field_7C >= stru_721530.field_6C ) + { + v1->vPosition.x = stru_721530.normal2.x; + v1->vPosition.y = stru_721530.normal2.y; + v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; + v1->uSectorID = LOWORD(stru_721530.uSectorID); + if ( !(HIBYTE(v2->uFlags) & 1) ) + return; + memset(&Dst, v8, 0x68u); + v29 = v2->uFlags; + Dst.x = (double)v1->vPosition.x; + Dst.y = (double)v1->vPosition.y; + Dst.z = (double)v1->vPosition.z; + Dst.flt_10 = 0.0; + Dst.flt_14 = 0.0; + Dst.flt_18 = 0.0; + if ( v29 & 0x200 ) + { + Dst.bFree = 1036; + Dst.uDiffuse = 0xFF3C1Eu; + v30 = rand(); + v34 = (TEXTURE_TYPE)v8; + v32 = "effpar01"; + } + else + { + if ( v29 & 0x400 ) + goto LABEL_70; + Dst.bFree = 1032; + Dst.uDiffuse = rand(); + v30 = rand(); + v34 = (TEXTURE_TYPE)v8; + v32 = "effpar03"; + } + Dst.timeToLive = (unsigned __int8)(v30 & 0x80) + 128; + Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34); + goto LABEL_71; + } + v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; + v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; + v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; + v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; + v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; + v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; + v1->uSectorID = LOWORD(stru_721530.uSectorID); + stru_721530.field_70 += stru_721530.field_7C; + if ( v2->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) + return; + v15 = (signed int)stru_721530.uFaceID >> 3; + if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + { + v40 = integer_sqrt(v1->vVelocity.x * v1->vVelocity.x + v1->vVelocity.y * v1->vVelocity.y); + v23 = stru_5C6E00->Atan2( + v1->vPosition.x - pLevelDecorations[v15].vPosition.x, + v1->vPosition.y - pLevelDecorations[v15].vPosition.y); + v42 = stru_5C6E00->Cos(v23); + v41 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16; + v24 = v23; + v1->vVelocity.x = (unsigned int)(v42 * v40) >> 16; + v25 = stru_5C6E00->Sin(v23); + v42 = v25; + v26 = v25 * (signed __int64)v40; + v41 = v26 >> 16; + v1->vVelocity.y = WORD1(v26); + } + else + { + if ( (stru_721530.uFaceID & 7) != OBJECT_BModel) + goto LABEL_64; + stru_721530.field_84 = (signed int)stru_721530.uFaceID >> 3; + v16 = &pIndoor->pFaces[v15]; + if ( v16->uPolygonType != 3 ) + { + v42 = abs(v16->pFacePlane_old.vNormal.x * v1->vVelocity.x + v16->pFacePlane_old.vNormal.z * v1->vVelocity.z + + v16->pFacePlane_old.vNormal.y * v1->vVelocity.y) >> 16; + if ( stru_721530.field_64 >> 3 > v42 ) + v42 = stru_721530.field_64 >> 3; + v40 = v16->pFacePlane_old.vNormal.x; + v40 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16; + v41 = v16->pFacePlane_old.vNormal.y; + v41 = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; + v39 = v16->pFacePlane_old.vNormal.z; + v39 = (unsigned __int64)(v42 * (signed __int64)v39) >> 16; + v1->vVelocity.x += 2 * v40; + v1->vVelocity.y += 2 * v41; + if ( v16->pFacePlane_old.vNormal.z <= 32000 ) + { + v22 = 2 * v39; + } + else + { + v21 = v39; + v40 = 32000; + v1->vVelocity.z += v39; + v41 = (unsigned __int64)(v40 * (signed __int64)v21) >> 16; + v22 = (unsigned int)(v40 * v21) >> 16; + } + v1->vVelocity.z += v22; + goto LABEL_60; + } + if ( v37->uFlags & 0x80 ) + { + v17 = -v1->vVelocity.z >> 1; + v1->vVelocity.z = v17; + if ( (signed __int16)v17 < 10 ) + v1->vVelocity.z = 0; +LABEL_60: + if ( BYTE3(v16->uAttributes) & 0x10 ) + EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1); + goto LABEL_63; + } + v18 = v1->vVelocity.y; + v19 = v1->vVelocity.x; + v1->vVelocity.z = 0; + if ( v19 * v19 + v18 * v18 >= 400 ) + goto LABEL_60; + v20 = pIndoor->pVertices; + v1->vVelocity.z = 0; + v1->vVelocity.y = 0; + v1->vVelocity.x = 0; + v1->vPosition.z = v20[*v16->pVertexIDs].z + 1; + } +LABEL_63: + v2 = v37; +LABEL_64: + v41 = v1->vVelocity.x; + v40 = 58500; + v41 = (unsigned __int64)(58500i64 * v41) >> 16; + v1->vVelocity.x = v41; + v41 = v1->vVelocity.y; + v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16; + v40 = 58500; + v1->vVelocity.y = v41; + v41 = v1->vVelocity.z; + v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16; + ++uFaceID; + v28 = __OFSUB__(uFaceID, 100); + v27 = uFaceID - 100 < 0; + v1->vVelocity.z = v41; + if ( !(v27 ^ v28) ) + return; + v8 = 0; + } + } + if ( v42 <= v1->vPosition.z - 3 ) + { + v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); + goto LABEL_24; + } + if ( !(v5 & 0x40) || _46BFFA_check_object_intercept(uLayingItemID_, 0) ) + { + v6 = pIndoor->pFaces; + v1->vPosition.z = v42 + 1; + v7 = &v6[uFaceID]; + if ( v7->uPolygonType == 3 ) + { + v8 = 0; + v1->vVelocity.z = 0; + } + else + { + if ( v7->pFacePlane_old.vNormal.z < 45000 ) + v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); + v8 = 0; + } + v42 = v1->vVelocity.x; + uFaceID = 58500; + v42 = (unsigned __int64)(58500i64 * v42) >> 16; + v1->vVelocity.x = v42; + v42 = v1->vVelocity.y; + v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16; + uFaceID = 58500; + v1->vVelocity.y = v42; + v42 = v1->vVelocity.z; + v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16; + v9 = v1->vVelocity.x; + v1->vVelocity.z = v42; + if ( v9 * v9 + v1->vVelocity.y * v1->vVelocity.y < 400 ) + { + v1->vVelocity.z = v8; + v1->vVelocity.y = v8; + v1->vVelocity.x = v8; + if ( !(HIBYTE(v2->uFlags) & 1) ) + return; + memset(&Dst, v8, 0x68u); + v10 = v2->uFlags; + Dst.x = (double)v1->vPosition.x; + Dst.y = (double)v1->vPosition.y; + Dst.z = (double)v1->vPosition.z; + Dst.flt_10 = 0.0; + Dst.flt_14 = 0.0; + Dst.flt_18 = 0.0; + if ( v10 & 0x200 ) + { + Dst.bFree = 1036; + Dst.uDiffuse = 0xFF3C1Eu; + Dst.flt_28 = 1.0; + v11 = rand(); + v33 = (TEXTURE_TYPE)v8; + v31 = "effpar01"; + } + else + { + if ( v10 & 0x400 ) + { +LABEL_70: + Dst.bFree = 512; + Dst.uDiffuse = rand(); + Dst.timeToLive = 64; + Dst.uTextureID = v8; +LABEL_71: + Dst.flt_28 = 1.0; + goto LABEL_72; + } + Dst.bFree = 1032; + Dst.uDiffuse = rand(); + Dst.flt_28 = 1.0; + v11 = rand(); + v33 = (TEXTURE_TYPE)v8; + v31 = "effpar03"; + } + Dst.timeToLive = (unsigned __int8)(v11 & 0x80) + 128; + Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33); +LABEL_72: + pGame->pParticleEngine->AddParticle(&Dst); + return; + } + goto LABEL_25; + } +} +// 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); + + + + +//----- (00438E35) -------------------------------------------------------- +void SpriteObject::_438E35() +{ + SpriteObject *v1; // edi@1 + MapInfo *pMapInfo; // esi@1 + int v3; // ebx@1 + int v4; // eax@1 + int v5; // ebx@1 + unsigned int v6; // ecx@1 + int v7; // edx@2 + unsigned int v8; // edx@4 + unsigned int v9; // edx@6 + unsigned int v10; // eax@7 + signed int v11; // ebx@8 + Player **v12; // esi@18 + signed int v13; // edi@20 + int v15; // [sp+Ch] [bp-Ch]@1 + int v16; // [sp+10h] [bp-8h]@1 + signed int v17; // [sp+14h] [bp-4h]@8 + int v18; // [sp+14h] [bp-4h]@14 + + v1 = this; + pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]; + v3 = abs(pParty->vPosition.x - v1->vPosition.x); + v15 = abs(pParty->vPosition.y - v1->vPosition.y); + v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z); + v4 = v3; + v5 = v15; + v6 = v16; + if ( v4 < v15 ) + { + v7 = v4; + v4 = v15; + v5 = v7; + } + if ( v4 < v16 ) + { + v8 = v4; + v4 = v16; + v6 = v8; + } + if ( v5 < (signed int)v6 ) + { + v9 = v6; + v6 = v5; + v5 = v9; + } + v10 = ((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4; + if ( (signed int)v10 <= 768 ) + { + v17 = 0; + v11 = 5; + if ( pMapInfo->Trap_D20 ) + { + do + { + ++v17; + v11 += rand() % 20 + 1; + } + while ( v17 < pMapInfo->Trap_D20 ); + } + switch ( v1->uType ) + { + case 0x32Bu: + v18 = 0; + break; + case 0x32Cu: + v18 = 1; + break; + case 0x32Du: + v18 = 2; + break; + default: + //LOWORD(v10) = v1->uItemType - 814; + if ( v1->uType != 814 ) + return; + v18 = 8; + break; + } + v12 = &pPlayers[1]; + do + { + if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) ) + (*v12)->PlaySound(SPEECH_6, 0); + else + (*v12)->ReceiveDamage(v11, v18); + ++v12; + } + while ( (signed int)v12 <= (signed int)&pPlayers[4] ); + } +} + + + +//----- (0042F933) -------------------------------------------------------- +void SpriteObject::OnInteraction(unsigned int uLayingItemID) +{ + unsigned int v1; // ecx@1 + unsigned __int16 *pAttributes; // ecx@2 + unsigned __int16 v3; // ax@2 + + //__debugbreak(); // find out what's going on + + v1 = uLayingItemID; + pSpriteObjects[v1].uObjectDescID = 0; + if ( pParty->bTurnBasedModeOn == 1 ) + { + pAttributes = &pSpriteObjects[v1].uAttributes; + v3 = *pAttributes; + if ( *pAttributes & 4 ) + { + v3 = v3 & 0xFB; + --pTurnEngine->field_1C; + *pAttributes = v3; + } + } +} diff -r cf366ba68de5 -r 1bd8758f50b8 SpriteObject.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SpriteObject.h Mon Mar 04 09:22:38 2013 +0600 @@ -0,0 +1,55 @@ +#pragma once +#include "VectorTypes.h" +#include "Items.h" + +enum +{ + OBJECT_ATTACHED_TO_ACTOR = 0x80, +}; + + +/* 72 */ +#pragma pack(push, 1) +struct SpriteObject +{ + inline bool AttachedToActor() const {return uAttributes & OBJECT_ATTACHED_TO_ACTOR;} + + SpriteObject(); + int Create(int yaw, int pitch, int a4, int a5); + void _46BEF1_apply_spells(); + void _438E35(); + + static void UpdateObject_fn0_BLV(unsigned int uLayingItemID); + static void UpdateObject_fn0_ODM(unsigned int uLayingItemID); + static void OnInteraction(unsigned int uLayingItemID); + + + unsigned __int16 uType; + unsigned __int16 uObjectDescID; + struct Vec3_int_ vPosition; + struct Vec3_short_ vVelocity; + unsigned __int16 uFacing; + unsigned __int16 uSoundID; + unsigned __int16 uAttributes; + __int16 uSectorID; + unsigned __int16 uSpriteFrameID; + __int16 field_20; + __int16 field_22_glow_radius_multiplier; + struct ItemGen stru_24; + int field_48; + int field_4C; + int field_50; + int field_54; + int field_58_pid; + int field_5C; + char field_60_distance_related_prolly_lod; + char field_61; + char field_62[2]; + Vec3_int_ field_64; +}; +#pragma pack(pop) + + + +extern size_t uNumSpriteObjects; +extern SpriteObject pSpriteObjects[1000]; \ No newline at end of file diff -r cf366ba68de5 -r 1bd8758f50b8 Vis.h --- a/Vis.h Mon Mar 04 09:22:29 2013 +0600 +++ b/Vis.h Mon Mar 04 09:22:38 2013 +0600 @@ -87,7 +87,7 @@ //----- (004C05A2) -------------------------------------------------------- //virtual ~Vis() {} //----- (004C05BE) -------------------------------------------------------- - ~Vis() {} + virtual ~Vis() {} bool PickKeyboard(Vis_SelectionList *list, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter); void PickBillboards_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter); void PickIndoorFaces_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter); @@ -121,7 +121,7 @@ bool SortByScreenSpaceX(struct RenderVertexSoft *pArray, int sLeft, int sRight); bool SortByScreenSpaceY(struct RenderVertexSoft *pArray, int sLeft, int sRight); - void (__thiscall ***vdestructor_ptr)(Vis *, bool); + //void (__thiscall ***vdestructor_ptr)(Vis *, bool); Vis_SelectionList default_list; RenderVertexSoft stru_200C; RenderVertexSoft stru_203C; diff -r cf366ba68de5 -r 1bd8758f50b8 mm7_1.cpp --- a/mm7_1.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/mm7_1.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -29,7 +29,7 @@ #include "Viewport.h" #include "FrameTableInc.h" #include "Math.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "ObjectList.h" #include "Chest.h" #include "PaletteManager.h" @@ -38,7 +38,6 @@ #include "stru123.h" #include "Time.h" #include "IconFrameTable.h" -#include "stru179.h" #include "Awards.h" #include "Autonotes.h" #include "stru160.h" @@ -612,11 +611,11 @@ } //----- (0041A000) -------------------------------------------------------- -unsigned int __fastcall CharacterUI_AwardsTab_Draw(unsigned int uPlayerID) -{ +void CharacterUI_AwardsTab_Draw( unsigned int uPlayerID ) + { //unsigned int v1; // esi@1 unsigned int v2; // ebx@1 - unsigned int v3; // eax@1 + unsigned int award_texture_id; // eax@1 unsigned int result; // eax@1 int v5; // eax@15 char *v6; // ebx@15 @@ -637,15 +636,15 @@ int v21; // [sp+C8h] [bp-8h]@14 int v22; // [sp+CCh] [bp-4h]@40 - auto player = pParty->pPlayers + uPlayerID - 1; + auto player = &pParty->pPlayers[uPlayerID - 1]; //v1 = uPlayerID; v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); - v3 = pIcons_LOD->LoadTexture("fr_award", TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0)); - sprintfex(pTmpBuf, "%s\xC" "%05d", pGlobalTXT_LocalizationStrings[23], v2); - sprintfex(Source, pGlobalTXT_LocalizationStrings[429], player->pName, pClassNames[player->classType]); + award_texture_id = pIcons_LOD->LoadTexture("fr_award", TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(award_texture_id != -1 ? &pIcons_LOD->pTextures[award_texture_id] : 0)); + sprintfex(pTmpBuf, "%s \f%05d", pGlobalTXT_LocalizationStrings[LOCSTR_AVARDS_FOR], v2); + sprintfex(Source, pGlobalTXT_LocalizationStrings[LOCSTR_S_THE_S], player->pName, pClassNames[player->classType]); strcat(pTmpBuf, Source); - strcat(pTmpBuf, "\xC" "00000"); + strcat(pTmpBuf, "\f00000"); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0); result = dword_506528; a1.uFrameX = 12; @@ -654,7 +653,7 @@ a1.uFrameHeight = 290; a1.uFrameZ = 435; a1.uFrameW = 337; - if ( dword_506544 && dword_506520 + dword_506528 < dword_506524 ) + if ( dword_506544 && awards_count + dword_506528 < awards_count2 ) result = dword_506528++ + 1; if ( dword_506548 && result ) { @@ -663,16 +662,16 @@ } if ( dword_50651C < 0 ) { - result += dword_506520; + result += awards_count; dword_506528 = result; - if ( (signed int)(dword_506520 + result) <= dword_506524 ) + if ( (signed int)(awards_count + result) <= awards_count2 ) goto LABEL_14; - result = dword_506524 - dword_506520; + result = awards_count2 - awards_count; goto LABEL_13; } if ( dword_50651C > 0 ) { - result -= dword_506520; + result -= awards_count; dword_506528 = result; if ( (result & 0x80000000u) != 0 ) { @@ -685,16 +684,16 @@ LABEL_14: dword_506544 = 0; dword_506548 = 0; - dword_506520 = 0; + awards_count = 0; dword_50651C = 0; v21 = result; - if ( (signed int)result < dword_506524 ) + if ( (signed int)result < awards_count2 ) { while ( 1 ) { - v5 = pStru179.field_0[v21]; - v20 = 8 * pStru179.field_0[v21]; - v6 = (char *)pAwards[(v20-1)/8].pText;//(char *)dword_723E80_award_related[v20 / 4]; + v5 = achievedAwardsIndex[v21]; + v20 = achievedAwardsIndex[v21]; + v6 = (char *)pAwards[v20].pText;//(char *)dword_723E80_award_related[v20 / 4]; if ( v5 != 1 ) break; v17 = pParty->uFine; @@ -702,8 +701,8 @@ sprintf(pTmpBuf, v6, v17); v6 = pTmpBuf; LABEL_43: - v14 = pAwards[v20/8-1].uSort;//dword_723E84[v20 / 4]; - ++dword_506520; + v14 = pAwards[v20].uSort;//dword_723E84[v20 / 4]; + ++awards_count; v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat( pAwardsTextColors[3 * v14 % 6], pAwardsTextColors[3 * v14 % 6 + 1], @@ -716,10 +715,10 @@ ++v21; a1.uFrameY = result; result = v21; - if ( v21 < dword_506524 ) + if ( v21 < awards_count2 ) continue; } - return result; + return; } if ( (v5 < 85 || v5 > 91) && (v5 < 103 || v5 > 104) ) goto LABEL_43; @@ -786,7 +785,7 @@ v17 = v22; goto LABEL_42; } - return result; + return; } // 50651C: using guessed type int dword_50651C; // 506520: using guessed type int dword_506520; @@ -3818,7 +3817,7 @@ if ( v1 ) { auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C - + 18 * *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime + + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); v2 = _w->GetDisplayName(); sub_41C0B8_set_status_string(v2); @@ -3826,85 +3825,6 @@ } } -//----- (00420B13) -------------------------------------------------------- -void __fastcall sub_420B13(int a1, int a2) -{ - void *v2; // eax@1 - ItemGen *v3; // ebx@1 - unsigned int v4; // eax@1 - Texture *v5; // ecx@1 - signed int v6; // eax@1 - signed int v7; // edi@3 - signed int v8; // eax@3 - int v9; // edi@3 - int v10; // eax@5 - int v11; // esi@8 - unsigned int v12; // ecx@10 - void *v13; // edi@10 - unsigned __int8 v14; // cf@10 - int v15; // edi@10 - int i; // ecx@10 - int v17; // [sp+Ch] [bp-14h]@1 - int v18; // [sp+10h] [bp-10h]@3 - int v19; // [sp+14h] [bp-Ch]@1 - void *v20; // [sp+18h] [bp-8h]@1 - int v21; // [sp+1Ch] [bp-4h]@5 - int v22; // [sp+1Ch] [bp-4h]@8 - - v19 = a2; - v2 = pChestWindow->ptr_1C; - v20 = v2; - v2 = (void *)(5324 * (int)v2); - v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4)); - v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)]; - v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE); - v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0); - v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24); - if ( v6 < 14 ) - v6 = 14; - v7 = v6 - 14; - v8 = v5->uTextureHeight; - v9 = (v7 >> 5) + 1; - v18 = v9; - if ( v8 < 14 ) - v8 = 14; - v10 = ((v8 - 14) >> 5) + 1; - v21 = v10; - if ( !areWeLoadingTexture ) - { - v5->Release(); - pIcons_LOD->_40F9C5(); - v10 = v21; - } - if ( v10 > 0 ) - { - v11 = 0; - v22 = v10; - do - { - if ( v9 > 0 ) - { - v12 = v9; - v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20]; - v14 = v12 & 1; - v12 >>= 1; - memset(v13, 0, 4 * v12); - v15 = (int)((char *)v13 + 4 * v12); - for ( i = v14; i; --i ) - { - *(short *)v15 = 0; - v15 += 2; - } - v9 = v18; - } - v11 += v17; - --v22; - } - while ( v22 ); - } - v3->Reset(); -} -// 506128: using guessed type int areWeLoadingTexture; //----- (00420C05) -------------------------------------------------------- void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) @@ -4018,23 +3938,23 @@ //----- (00420E01) -------------------------------------------------------- void __cdecl sub_420E01() { - void *v0; // edi@1 + int chest_id; // edi@1 POINT *v1; // esi@2 int v2; // eax@2 int v3; // ebx@4 int v4; // esi@6 int v5; // ecx@6 - //LayingItem v6; // [sp+Ch] [bp-80h]@1 - char v7; // [sp+7Ch] [bp-10h]@2 + //SpriteObject v6; // [sp+Ch] [bp-80h]@1 + POINT v7; // [sp+7Ch] [bp-10h]@2 POINT a2; // [sp+84h] [bp-8h]@2 - LayingItem v6; // [sp+Ch] [bp-80h]@1 - //LayingItem::LayingItem(&v6); - - v0 = pGUIWindow_CurrentMenu->ptr_1C; + SpriteObject v6; // [sp+Ch] [bp-80h]@1 + //SpriteObject::SpriteObject(&v6); + + chest_id = pGUIWindow_CurrentMenu->par1C; if ( pParty->pPickedItem.uItemID ) { - if ( Chest::_41FFA2(-1, &pParty->pPickedItem, (unsigned int)pGUIWindow_CurrentMenu->ptr_1C) ) + if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) ) pMouse->RemoveHoldingItem(); } else @@ -4047,16 +3967,15 @@ v3 = v2 - 1; else v3 = -1; - v4 = pChests[0].pInventoryIndices[v3 + 2662 * (int)v0] - 1; - v5 = 5324 * (int)v0 + 36 * v4; - if ( pItemsTable->pItems[*(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v5)].uEquipType == 18 ) + v4 = pChests[chest_id].pInventoryIndices[v3] - 1; + if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == 18 ) { - party_finds_gold(*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uSpecEnchantmentType + v5), 0); + party_finds_gold(pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uValue, 0); //recheck viewparams->bRedrawGameUI = 1; } else { - pParty->SetHoldingItem((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v5)); + pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]); } sub_420B13(v4, v3); } @@ -4155,7 +4074,7 @@ if ( (v18 & 7) == OBJECT_Item ) { v30 = v19; - if ( pObjectList->pObjects[pLayingItems[v30].uObjectDescID].uFlags & 0x10 ) + if ( pObjectList->pObjects[pSpriteObjects[v30].uObjectDescID].uFlags & 0x10 ) //goto LABEL_73; { pMouse->uPointingObjectID = 0; @@ -4174,7 +4093,7 @@ } if ( v18 >= (signed int)0x2000000u || pParty->pPickedItem.uItemID ) { - v22 = pLayingItems[v30].stru_24.GetDisplayName(); + v22 = pSpriteObjects[v30].stru_24.GetDisplayName(); //LABEL_93: v26 = v22; //goto LABEL_87; @@ -4190,7 +4109,7 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - v31 = pLayingItems[v30].stru_24.GetDisplayName(); + v31 = pSpriteObjects[v30].stru_24.GetDisplayName(); v28 = pTmpBuf; sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[470], v31);// "Get %s" } @@ -4791,7 +4710,7 @@ pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0); pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0); pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0); - sub_419100(); + FillAwardsData(); return pWindow; } @@ -4847,7 +4766,7 @@ signed int v6; // eax@11 char *v7; // edi@12 __int16 v8; // ax@16 - LayingItem a1; // [sp+4h] [bp-78h]@11 + SpriteObject a1; // [sp+4h] [bp-78h]@11 int v11; // [sp+74h] [bp-8h]@2 int v12; // [sp+78h] [bp-4h]@5 @@ -4884,7 +4803,7 @@ { v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; v6 = 0; - a1.uItemType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; if ( (signed int)pObjectList->uNumObjects <= 0 ) { LOWORD(v6) = 0; @@ -5014,7 +4933,7 @@ viewparams->bRedrawGameUI = true; uActiveCharacter = uPlayerID; if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 102 ) - sub_419100(); + FillAwardsData(); return; } //goto LABEL_23; @@ -5186,7 +5105,7 @@ signed int v21; // eax@58 ItemGen *v22; // esi@62 unsigned int v23; // eax@62 - LayingItem a1; // [sp+Ch] [bp-80h]@1 + SpriteObject a1; // [sp+Ch] [bp-80h]@1 POINT v25; // [sp+7Ch] [bp-10h]@3 POINT a2; // [sp+84h] [bp-8h]@3 @@ -5203,13 +5122,13 @@ { a2.y = (signed int)(unsigned __int16)v0 >> 3; v21 = (signed int)(unsigned __int16)v0 >> 3; - if ( !(pObjectList->pObjects[pLayingItems[v21].uObjectDescID].uFlags & 0x10) + if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 - && pLayingItems[v21].uObjectDescID + && pSpriteObjects[v21].uObjectDescID && (unsigned int)v0 < 0x2000000 ) { - v22 = &pLayingItems[v21].stru_24; - v23 = pLayingItems[v21].stru_24.uItemID; + v22 = &pSpriteObjects[v21].stru_24; + v23 = pSpriteObjects[v21].stru_24.uItemID; if ( pItemsTable->pItems[v23].uEquipType == 18 ) { party_finds_gold(v22->uSpecEnchantmentType, 0); @@ -5226,7 +5145,7 @@ if ( !pParty->AddItem(v22) ) pParty->SetHoldingItem(v22); } - LayingItem::OnItemPickup(a2.y); + SpriteObject::OnInteraction(a2.y); return; } goto LABEL_13; @@ -5244,9 +5163,9 @@ if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) { v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380; - GlobalEventInfo = (int)&pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; + activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; EventProcessor(v15, 0, 1); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; } return; } @@ -5269,7 +5188,7 @@ LABEL_14: v5 = pItemsTable->pItems[v4].uSpriteID; v6 = 0; - a1.uItemType = v5; + a1.uType = v5; if ( (signed int)pObjectList->uNumObjects <= 0 ) { LABEL_18: @@ -5469,7 +5388,7 @@ pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID); pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC"); pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-c", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-c", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-c", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-c", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2); @@ -5505,7 +5424,7 @@ uTextureID_Btn_Rest = pIcons_LOD->LoadTexture("ib-m2d-c", TEXTURE_16BIT_PALETTE); uTextureID_Btn_QuickReference = pIcons_LOD->LoadTexture("ib-m3d-c", TEXTURE_16BIT_PALETTE); uTextureID_Btn_GameSettings = pIcons_LOD->LoadTexture("ib-m4d-c", TEXTURE_16BIT_PALETTE); - uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-c", TEXTURE_16BIT_PALETTE); + uExitCancelTextureId = pIcons_LOD->LoadTexture("ib-bcu-c", TEXTURE_16BIT_PALETTE); dword_50796C = pIcons_LOD->LoadTexture("isg-01-c", TEXTURE_16BIT_PALETTE); dword_507968 = pIcons_LOD->LoadTexture("isg-02-c", TEXTURE_16BIT_PALETTE); dword_507964 = pIcons_LOD->LoadTexture("isg-03-c", TEXTURE_16BIT_PALETTE); @@ -5554,7 +5473,7 @@ pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID); pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchA"); pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-a", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-a", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2); @@ -5590,7 +5509,7 @@ uTextureID_Btn_GameSettings = pIcons_LOD->LoadTexture("ib-m4d-a", TEXTURE_16BIT_PALETTE); uTextureID_Btn_ZoomIn = pIcons_LOD->LoadTexture("ib-autout-a", TEXTURE_16BIT_PALETTE); uTextureID_Btn_ZoomOut = pIcons_LOD->LoadTexture("ib-autin-a", TEXTURE_16BIT_PALETTE); - uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-a", TEXTURE_16BIT_PALETTE); + uExitCancelTextureId = pIcons_LOD->LoadTexture("ib-bcu-a", TEXTURE_16BIT_PALETTE); dword_50796C = pIcons_LOD->LoadTexture("isg-01-a", TEXTURE_16BIT_PALETTE); dword_507968 = pIcons_LOD->LoadTexture("isg-02-a", TEXTURE_16BIT_PALETTE); dword_507964 = pIcons_LOD->LoadTexture("isg-03-a", TEXTURE_16BIT_PALETTE); @@ -5650,7 +5569,7 @@ pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID); pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchB"); pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-b", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-b", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-b", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-b", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2); diff -r cf366ba68de5 -r 1bd8758f50b8 mm7_2.cpp --- a/mm7_2.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/mm7_2.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -21,7 +21,7 @@ #include "Viewport.h" #include "FrameTableInc.h" #include "Math.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "ObjectList.h" #include "Chest.h" #include "PaletteManager.h" @@ -29,6 +29,7 @@ #include "SaveLoad.h" #include "stru123.h" #include "stru287.h" +#include "stru176.h" #include "Time.h" #include "IconFrameTable.h" #include "GUIProgressBar.h" @@ -53,6 +54,7 @@ #include "texts.h" #include "mm7_data.h" +#include "MM7.h" //----- (004B4F4F) -------------------------------------------------------- @@ -148,141 +150,144 @@ v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine); _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf, 3u); - if ( dword_F8B19C == 1 ) - { - v11 = 1; - pOutString = 0; - pShopOptions[0] = pGlobalTXT_LocalizationStrings[604]; - if ( pParty->uFine ) - { - pShopOptions[1] = pGlobalTXT_LocalizationStrings[603]; - v11 = 2; - } - for ( i = 0; i < v11; ++i ) - { - v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0); - pOutString = (GUIFont *)((char *)pOutString + v13); - } - v29 = (100 - (signed int)pOutString) / v11; - v14 = pDialogueWindow; - v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString; - v16 = v15 - HIDWORD(v15); - LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem; - HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton; - v17 = (v16 >> 1) - v29 / 2 + 158; - v18 = -pDialogueWindow->pNumPresenceButton < 0; - pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem; - if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) ) - { - v31 = 2; - v19 = pShopOptions; - do - { - v20 = v14->GetControl((unsigned int)pOutString); - v21 = v20; - v20->uY = v29 + v17; - v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0); - v23 = v21->uY; - v21->uHeight = v22; - v17 = v23 + v22 - 1; - v21->uW = v17; - v24 = v30; - if ( pDialogueWindow->pCurrentPosActiveItem != v31 ) - v24 = v28; - _this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u); - v14 = pDialogueWindow; - ++v31; - ++v19; - pOutString = (GUIFont *)((char *)pOutString + 1); - } - while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); - } - } - else - { - if ( dword_F8B19C != 99 ) - { - if ( dword_F8B19C != 100 ) - return; - v0 = window_SpeakInHouse; - if ( window_SpeakInHouse->field_40 == 1 ) - { - sprintf(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); - _this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf, 3u); - _this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3u); - v3 = pFontArrus; - v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); - _this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3); - return; - } - if ( window_SpeakInHouse->field_40 == 2 ) - { - v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); - v2 = v1; - if ( v1 <= 0 ) - { -LABEL_8: - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - return; - } - if ( v1 > pParty->uNumGold ) - { - HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2); - v2 = pParty->uNumGold; - } - if ( v2 > pParty->uFine ) - v2 = pParty->uFine; - Party::TakeGold(v2); - pParty->uFine -= v2; - if ( pParty->uFine < 0 ) - pParty->uFine = 0; - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); - v0 = window_SpeakInHouse; - } - else - { - if ( window_SpeakInHouse->field_40 != 3 ) - return; - } - v0->field_40 = 0; - goto LABEL_8; - } - v5 = &pMonsterStats->pInfos[word_F8B1A0]; - v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); - v7 = v5->pName; - v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); - sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6); - sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel); - ptr_F8B1E8 = pTmpBuf2; - memcpy(&a1, pDialogueWindow, sizeof(a1)); - w.uFrameWidth = 458; - w.uFrameZ = 457; - pOutString = pFontArrus; - v9 = pFontArrus->CalcTextHeight(pTmpBuf2, &w, 13, 0) + 7; - if ( 352 - v9 < 8 ) - { - pOutString = pFontCreate; - v9 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7; - } - - auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0); - pRenderer->_4A6A68( - 8u, - 352 - v9, - pTex, - (pTex ? pTex->uTextureHeight : 26) - v9); - pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428); - v10 = FitTextInAWindow(ptr_F8B1E8, pOutString, &w, 0xDu, 0); - a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0); - } + switch(dword_F8B19C) + { + case 1: + { + v11 = 1; + pOutString = 0; + pShopOptions[0] = pGlobalTXT_LocalizationStrings[604]; + if ( pParty->uFine ) + { + pShopOptions[1] = pGlobalTXT_LocalizationStrings[603]; + v11 = 2; + } + for ( i = 0; i < v11; ++i ) + { + v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0); + pOutString = (GUIFont *)((char *)pOutString + v13); + } + v29 = (100 - (signed int)pOutString) / v11; + v14 = pDialogueWindow; + v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString; + v16 = v15 - HIDWORD(v15); + LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem; + HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton; + v17 = (v16 >> 1) - v29 / 2 + 158; + v18 = -pDialogueWindow->pNumPresenceButton < 0; + pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem; + if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) ) + { + v31 = 2; + v19 = pShopOptions; + do + { + v20 = v14->GetControl((unsigned int)pOutString); + v21 = v20; + v20->uY = v29 + v17; + v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0); + v23 = v21->uY; + v21->uHeight = v22; + v17 = v23 + v22 - 1; + v21->uW = v17; + v24 = v30; + if ( pDialogueWindow->pCurrentPosActiveItem != v31 ) + v24 = v28; + _this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u); + v14 = pDialogueWindow; + ++v31; + ++v19; + pOutString = (GUIFont *)((char *)pOutString + 1); + } + while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + break; + } + case 99: + { + v5 = &pMonsterStats->pInfos[word_F8B1A0]; + v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); + v7 = v5->pName; + v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); + sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6); + sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel); + ptr_F8B1E8 = pTmpBuf2; + memcpy(&a1, pDialogueWindow, sizeof(a1)); + w.uFrameWidth = 458; + w.uFrameZ = 457; + pOutString = pFontArrus; + v9 = pFontArrus->CalcTextHeight(pTmpBuf2, &w, 13, 0) + 7; + if ( 352 - v9 < 8 ) + { + pOutString = pFontCreate; + v9 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7; + } + + auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0); + pRenderer->_4A6A68(8u, 352 - v9, pTex, (pTex ? pTex->uTextureHeight : 26) - v9); + pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428); + v10 = FitTextInAWindow(ptr_F8B1E8, pOutString, &w, 0xDu, 0); + a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0); + break; + } + case 100: + { + v0 = window_SpeakInHouse; + if ( window_SpeakInHouse->field_40 == 1 ) + { + sprintf(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); + _this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf, 3u); + _this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3u); + v3 = pFontArrus; + v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); + _this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3); + return; + } + if ( window_SpeakInHouse->field_40 == 2 ) + { + v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); + v2 = v1; + if ( v1 <= 0 ) + { + //LABEL_8: + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + return; + } + if ( v1 > pParty->uNumGold ) + { + HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2); + v2 = pParty->uNumGold; + } + if ( v2 > pParty->uFine ) + v2 = pParty->uFine; + Party::TakeGold(v2); + pParty->uFine -= v2; + if ( pParty->uFine < 0 ) + pParty->uFine = 0; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); + v0 = window_SpeakInHouse; + } + if ( window_SpeakInHouse->field_40 == 3 ) + { + v0->field_40 = 0; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + } + break; + } + default: + { + break; + } + } + return; } // F8B19C: using guessed type int dword_F8B19C; // F8B1A0: using guessed type __int16 word_F8B1A0; @@ -314,105 +319,127 @@ *(int *)v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank); _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf, 3u); - if ( dword_F8B19C != 1 ) - { - if ( dword_F8B19C == 7 ) - { - v0 = window_SpeakInHouse; - if ( window_SpeakInHouse->field_40 != 1 ) - { - v1 = window_SpeakInHouse->field_40 - 2; - if ( window_SpeakInHouse->field_40 == 2 ) - { - 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 = (UIMessageType)113; - 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 ) - { - HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2); - v7 = pParty->uNumGold; - } - if ( v7 ) - { - Party::TakeGold(v7); - pParty->uNumGoldInBank += v7; - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); - } - v0 = window_SpeakInHouse; -LABEL_16: - v0->field_40 = 0; - goto LABEL_17; - } -LABEL_15: - if ( v1 != 1 ) - return; - goto LABEL_16; - } - v11 = pGlobalTXT_LocalizationStrings[112]; - v10 = pGlobalTXT_LocalizationStrings[60]; - } - else - { - if ( dword_F8B19C != 8 ) - return; - v0 = window_SpeakInHouse; - if ( window_SpeakInHouse->field_40 != 1 ) - { - v1 = window_SpeakInHouse->field_40 - 2; - if ( window_SpeakInHouse->field_40 == 2 ) - { - window_SpeakInHouse->field_40 = 0; - v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); - v3 = v2; - if ( v2 ) - { - if ( v2 > pParty->uNumGoldInBank ) - { - HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2); - v3 = pParty->uNumGoldInBank; - } - if ( v3 ) - { - Party::SetGold(pParty->uNumGold + v3); - pParty->uNumGoldInBank -= v3; - } - } - goto LABEL_17; - } - goto LABEL_15; - } - v11 = pGlobalTXT_LocalizationStrings[112]; - v10 = pGlobalTXT_LocalizationStrings[244]; - } - sprintf(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; - v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); - _this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4); - return; - } - v8 = v14[0]; - if ( pDialogueWindow->pCurrentPosActiveItem != 2 ) - v8 = v13[0]; - _this.DrawTitleText(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u); - v9 = v14[0]; - if ( pDialogueWindow->pCurrentPosActiveItem != 3 ) - v9 = v13[0]; - _this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u); + switch(dword_F8B19C) + { + case 1: + { + v8 = v14[0]; + if ( pDialogueWindow->pCurrentPosActiveItem != 2 ) + v8 = v13[0]; + _this.DrawTitleText(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u); + v9 = v14[0]; + if ( pDialogueWindow->pCurrentPosActiveItem != 3 ) + v9 = v13[0]; + _this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u); + break; + } + case 7: + { + v0 = window_SpeakInHouse; + if ( window_SpeakInHouse->field_40 != 1 ) + { + v1 = window_SpeakInHouse->field_40 - 2; + if ( window_SpeakInHouse->field_40 == 2 ) + { + 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 = (UIMessageType)113; + 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 ) + { + HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2); + v7 = pParty->uNumGold; + } + if ( v7 ) + { + Party::TakeGold(v7); + pParty->uNumGoldInBank += v7; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); + } + v0 = window_SpeakInHouse; + v0->field_40 = 0; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + if ( v1 != 1 ) + return; + v0->field_40 = 0; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + v11 = pGlobalTXT_LocalizationStrings[112]; + v10 = pGlobalTXT_LocalizationStrings[60]; + sprintf(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; + v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); + _this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4); + break; + } + + case 8: + { + v0 = window_SpeakInHouse; + if ( window_SpeakInHouse->field_40 != 1 ) + { + v1 = window_SpeakInHouse->field_40 - 2; + if ( window_SpeakInHouse->field_40 == 2 ) + { + window_SpeakInHouse->field_40 = 0; + v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); + v3 = v2; + if ( v2 ) + { + if ( v2 > pParty->uNumGoldInBank ) + { + HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2); + v3 = pParty->uNumGoldInBank; + } + if ( v3 ) + { + Party::SetGold(pParty->uNumGold + v3); + pParty->uNumGoldInBank -= v3; + } + } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + if ( v1 != 1 ) + return; + v0->field_40 = 0; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + v11 = pGlobalTXT_LocalizationStrings[112]; + v10 = pGlobalTXT_LocalizationStrings[244]; + sprintf(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; + v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); + _this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4); + return; + break; + } + + default: + { + break; + } + } } // F8B19C: using guessed type int dword_F8B19C; @@ -543,41 +570,57 @@ v7 = 1; v83 = 1; } - if ( dword_F8B19C > 101 ) - { - if ( dword_F8B19C == 102 ) - { - v65 = pFontArrus; - pOutString = pFontArrus; - strcpy(pTmpBuf, pNPCTopics[354].pText); - v78.uFrameWidth = 460; - v78.uFrameZ = 452; - v62 = v65->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7; - if ( 352 - v62 < 8 ) - { - pOutString = pFontCreate; - v62 = pFontCreate->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7; - } - - auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0); - pRenderer->_4A6A68( - 8u, - 352 - v62, - pTex, - (pTex ? pTex->uTextureHeight : 26) - v62); - - pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428); - v73 = 0; - v70 = 0; - v68 = 0; - v63 = FitTextInAWindow(pTmpBuf, pOutString, &v78, 0xCu, 0); - v64 = pOutString; - } - else - { - if ( dword_F8B19C != 103 ) - { - if ( dword_F8B19C != 104 || pArcomageGame->bGameInProgress == 1 ) + switch(dword_F8B19C) + { + case 102: + { + v65 = pFontArrus; + pOutString = pFontArrus; + strcpy(pTmpBuf, pNPCTopics[354].pText); + v78.uFrameWidth = 460; + v78.uFrameZ = 452; + v62 = v65->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7; + if ( 352 - v62 < 8 ) + { + pOutString = pFontCreate; + v62 = pFontCreate->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7; + } + + auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0); + pRenderer->_4A6A68(8u, 352 - v62, pTex, (pTex ? pTex->uTextureHeight : 26) - v62); + + pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428); + v73 = 0; + v70 = 0; + v68 = 0; + v63 = FitTextInAWindow(pTmpBuf, pOutString, &v78, 0xCu, 0); + v64 = pOutString; + window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73); + break; + } + case 103: + { + strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText); + v78.uFrameWidth = 460; + v78.uFrameZ = 452; + v61 = pFontArrus->CalcTextHeight(pTmpBuf, &v78, 12, 0); + v62 = v61 + 7; + + auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr); + pRenderer->_4A6A68(8u, 352 - (v61 + 7), pTex, (pTex ? pTex->uTextureHeight : 26) - (v61 + 7)); + + pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428); + v73 = 0; + v70 = 0; + v68 = 0; + v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &v78, 0xCu, 0); + v64 = pFontArrus; + window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73); + break; + } + case 104: + { + if ( pArcomageGame->bGameInProgress == 1 ) return; v26 = pTmpBuf; if ( pArcomageGame->uGameResult ) @@ -592,42 +635,16 @@ v72 = pGlobalTXT_LocalizationStrings[639];// A tie! } strcpy(pTmpBuf, v72); -LABEL_97: +//LABEL_97: v71 = 3; v69 = v26; v67 = v84[0]; v66 = (174 - pFontArrus->CalcTextHeight(v26, &v79, 0, 0)) / 2 + 138; - goto LABEL_98; - } - strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText); - v78.uFrameWidth = 460; - v78.uFrameZ = 452; - v61 = pFontArrus->CalcTextHeight(pTmpBuf, &v78, 12, 0); - v62 = v61 + 7; - - auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr); - pRenderer->_4A6A68( - 8u, - 352 - (v61 + 7), - pTex, - (pTex ? pTex->uTextureHeight : 26) - (v61 + 7)); - - pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428); - v73 = 0; - v70 = 0; - v68 = 0; - v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &v78, 0xCu, 0); - v64 = pFontArrus; - } - window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73); - return; - } - if ( dword_F8B19C != 101 ) - { - if ( dword_F8B19C != 1 ) - { - if ( dword_F8B19C == 15 ) - { + v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71); + break; + } + case 15: + { if ( pParty->uNumGold >= (unsigned int)pOutString ) { Party::TakeGold((unsigned int)pOutString); @@ -650,96 +667,106 @@ ++pMessageQueue_50CBD0->uNumMessages; return; } - } - else - { - if ( dword_F8B19C != 16 ) - { - if ( dword_F8B19C != 96 || !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) - return; - v8 = pDialogueWindow; - *(float *)&v89 = 0.0; - - //v9 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); - v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); - - pOutString = (GUIFont *)(v9 * (100 - v85->GetMerchant()) / 100); - if ( (signed int)pOutString < v9 / 3 ) - pOutString = (GUIFont *)(v9 / 3); - v10 = v8->pStartingPosActiveItem; - v11 = v10 + v8->pNumPresenceButton; - v86 = 0; - if ( (signed int)v10 < v11 ) - { - do - { - v12 = v8->GetControl(v10)->uControlParam - 36; - if ( byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v12] && !v85->pActiveSkills[v12] ) - { - v13 = pFontArrus->CalcTextHeight(pSkillNames[v12], &v79, 0, 0); - v89 += v13; - ++v86; - } - ++v10; - } - while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton ); - if ( v86 ) - { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString); - v79.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u); - pOutString = (GUIFont *)((149 - v89) / v86); - if ( (149 - v89) / v86 > 32 ) - pOutString = (GUIFont *)32; - v14 = (149 - v86 * (signed int)pOutString - v89) / 2 - (signed int)pOutString / 2 + 162; - v89 = v8->pStartingPosActiveItem; - v83 = v14; - if ( v89 < v89 + v8->pNumPresenceButton ) - { - v86 = 2; - do - { - v15 = v8->GetControl(v89); - v16 = v15; - v17 = v15->uControlParam - 36; - if ( !byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v17] || v85->pActiveSkills[v17] ) - { - v16->uW = 0; - v16->uHeight = 0; - v16->uY = 0; - } - else - { - v18 = pSkillNames[v17]; - v16->uY = (unsigned int)((char *)pOutString + v83); - Str[1] = v18; - v19 = pFontArrus->CalcTextHeight(v18, &v79, 0, 0); - v20 = v16->uY; - v21 = v86; - v16->uHeight = v19; - v22 = v19 + v20 - 1; - v16->uW = v22; - v83 = v22; - v23 = v84[0]; - if ( pDialogueWindow->pCurrentPosActiveItem != v21 ) - v23 = v81; - v79.DrawTitleText(pFontArrus, 0, v20, v23, Str[1], 3u); - } - v24 = v8->pNumPresenceButton; - ++v89; - v25 = v8->pStartingPosActiveItem + v24; - ++v86; - } - while ( v89 < v25 ); - } - return; - } - } - v26 = pTmpBuf; - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->classType]); - strcat(pTmpBuf, "\n \n"); - strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]); - goto LABEL_97; - } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0); + break; + } + case 96: + { + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + v8 = pDialogueWindow; + *(float *)&v89 = 0.0; + + //v9 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); + v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + + pOutString = (GUIFont *)(v9 * (100 - v85->GetMerchant()) / 100); + if ( (signed int)pOutString < v9 / 3 ) + pOutString = (GUIFont *)(v9 / 3); + v10 = v8->pStartingPosActiveItem; + v11 = v10 + v8->pNumPresenceButton; + v86 = 0; + if ( (signed int)v10 < v11 ) + { + do + { + v12 = v8->GetControl(v10)->uControlParam - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v12] && !v85->pActiveSkills[v12] ) + { + v13 = pFontArrus->CalcTextHeight(pSkillNames[v12], &v79, 0, 0); + v89 += v13; + ++v86; + } + ++v10; + } + while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton ); + if ( v86 ) + { + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString); + v79.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u); + pOutString = (GUIFont *)((149 - v89) / v86); + if ( (149 - v89) / v86 > 32 ) + pOutString = (GUIFont *)32; + v14 = (149 - v86 * (signed int)pOutString - v89) / 2 - (signed int)pOutString / 2 + 162; + v89 = v8->pStartingPosActiveItem; + v83 = v14; + if ( v89 < v89 + v8->pNumPresenceButton ) + { + v86 = 2; + do + { + v15 = v8->GetControl(v89); + v16 = v15; + v17 = v15->uControlParam - 36; + if ( !byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v17] || v85->pActiveSkills[v17] ) + { + v16->uW = 0; + v16->uHeight = 0; + v16->uY = 0; + } + else + { + v18 = pSkillNames[v17]; + v16->uY = (unsigned int)((char *)pOutString + v83); + Str[1] = v18; + v19 = pFontArrus->CalcTextHeight(v18, &v79, 0, 0); + v20 = v16->uY; + v21 = v86; + v16->uHeight = v19; + v22 = v19 + v20 - 1; + v16->uW = v22; + v83 = v22; + v23 = v84[0]; + if ( pDialogueWindow->pCurrentPosActiveItem != v21 ) + v23 = v81; + v79.DrawTitleText(pFontArrus, 0, v20, v23, Str[1], 3u); + } + v24 = v8->pNumPresenceButton; + ++v89; + v25 = v8->pStartingPosActiveItem + v24; + ++v86; + } + while ( v89 < v25 ); + } + return; + } + } + v26 = pTmpBuf; + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->classType]); + strcat(pTmpBuf, "\n \n"); + strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]); + v71 = 3; + v69 = v26; + v67 = v84[0]; + v66 = (174 - pFontArrus->CalcTextHeight(v26, &v79, 0, 0)) / 2 + 138; + v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71); + return; + break; + } + case 16: + { *(_QWORD *)Str = pParty->uNumFoodRations; //if ( (double)pParty->uNumFoodRations >= p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C] ) if ( (double)pParty->uNumFoodRations >= p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier ) @@ -747,7 +774,8 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); if ( uActiveCharacter ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_67, 0); - goto LABEL_43; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0); + return; } if ( pParty->uNumGold >= v7 ) { @@ -756,172 +784,193 @@ pParty->uNumFoodRations = (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 3); v5 = 1; -LABEL_43: +//LABEL_43: pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0); return; //goto LABEL_51; } - } - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); - HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4); - goto LABEL_43; - } - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) - return; - v28 = *(int *)v84; - if ( pDialogueWindow->pCurrentPosActiveItem != 2 ) - v28 = v81; - sprintf(Dest, format_4E2DC8, v28); - sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString); - strcat(Dest, pTmpBuf2); - v90 = pFontArrus->CalcTextHeight(Dest, &v79, 0, 0); - strcat(Dest, "\n \n"); - v29 = *(int *)v84; - if ( pDialogueWindow->pCurrentPosActiveItem != 3 ) - v29 = v81; - sprintf(a1, format_4E2DC8, v29); - sprintf(pTmpBuf2, - pGlobalTXT_LocalizationStrings[86], - //(signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C], - (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier, - v83); - strcat(a1, pTmpBuf2); - v88 = pFontArrus->CalcTextHeight(a1, &v79, 0, 0); - strcat(a1, "\n \n"); - v30 = *(int *)v84; - if ( pDialogueWindow->pCurrentPosActiveItem != 4 ) - v30 = v81; - sprintf(v77, format_4E2DC8, v30); - strcat(v77, pGlobalTXT_LocalizationStrings[160]); - v82 = pFontArrus->CalcTextHeight(v77, &v79, 0, 0); - strcat(v77, "\n \n"); - v75[0] = 0; - v87 = 0; - v31 = (signed int)window_SpeakInHouse->ptr_1C; - if ( v31 >= 108 && v31 <= 120 ) - { - v32 = *(int *)v84; - if ( pDialogueWindow->pCurrentPosActiveItem != 5 ) - v32 = v81; - sprintf(v75, format_4E2DC8, v32); - strcat(v75, pGlobalTXT_LocalizationStrings[611]); - v87 = pFontArrus->CalcTextHeight(v75, &v79, 0, 0); - } - v33 = pDialogueWindow; - Str[1] = (char *)pDialogueWindow; - v34 = pDialogueWindow->pStartingPosActiveItem; - v35 = v34 + pDialogueWindow->pNumPresenceButton; - v36 = LOBYTE(pFontArrus->uFontHeight) - 3; - v37 = -pDialogueWindow->pNumPresenceButton < 0; - pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem; - if ( !(v37 ^ __OFSUB__(v34, v35)) ) - { -LABEL_75: - sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75); - v71 = 3; - v69 = pTmpBuf; - v67 = 0; - v66 = 146; -LABEL_98: - v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71); - return; - } - while ( 1 ) - { - v38 = v33->GetControl((unsigned int)pOutString); - if ( v38->uControlParam == 15 ) - { - v46 = v90; - v38->uHeight = v90; - v38->uY = 146; - v41 = v46 + 145; - goto LABEL_73; - } - if ( v38->uControlParam == 16 ) - { - v44 = v88; - v45 = v90 + v36 + 146; - v38->uHeight = v88; - v38->uY = v45; - v41 = v45 + v44 - 1; - goto LABEL_73; - } - if ( v38->uControlParam == 96 ) - break; - if ( v38->uControlParam == 101 ) - { - v39 = v90 + 3 * v36 + v87 + v88 + 146; - v33 = (GUIWindow *)Str[1]; - v40 = v87; - v38->uHeight = v87; - v38->uY = v39; - v41 = v39 + v40 - 1; -LABEL_73: - v38->uW = v41; - } - v47 = v33->pStartingPosActiveItem; - pOutString = (GUIFont *)((char *)pOutString + 1); - if ( (signed int)pOutString >= v33->pNumPresenceButton + v47 ) - goto LABEL_75; - } - v42 = v90 + v88 + 2 * v36 + 146; - v43 = v82; - v38->uY = v42; - v38->uHeight = v43; - v41 = v43 + v42 - 1; - goto LABEL_73; - } - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) - { - v48 = 2; - pShopOptions[0] = pGlobalTXT_LocalizationStrings[620]; - pOutString = 0; - pShopOptions[1] = pGlobalTXT_LocalizationStrings[622]; - if ( pParty->HasItem(0x28Bu) ) - { - pShopOptions[2] = pGlobalTXT_LocalizationStrings[621]; - v48 = 3; - } - for ( i = 0; i < v48; ++i ) - { - v50 = pFontArrus->CalcTextHeight(pShopOptions[i], &v79, 0, 0); - pOutString = (GUIFont *)((char *)pOutString + v50); - } - v86 = (174 - (signed int)pOutString) / v48; - v51 = pDialogueWindow; - v52 = 174 - v48 * (174 - (signed int)pOutString) / v48 - (signed int)pOutString; - v53 = v52 - HIDWORD(v52); - LODWORD(v52) = pDialogueWindow->pStartingPosActiveItem; - HIDWORD(v52) = v52 + pDialogueWindow->pNumPresenceButton; - v54 = (v53 >> 1) - v86 / 2 + 138; - v37 = -pDialogueWindow->pNumPresenceButton < 0; - v89 = pDialogueWindow->pStartingPosActiveItem; - if ( v37 ^ __OFSUB__((int)v52, HIDWORD(v52)) ) - { - v85 = (Player *)2; - pOutString = (GUIFont *)pShopOptions; - do - { - v55 = v51->GetControl(v89); - v56 = (const char **)pOutString; - v55->uY = v86 + v54; - v57 = pFontArrus->CalcTextHeight(*v56, &v79, 0, 0); - v58 = v55->uY; - v59 = v85; - v55->uHeight = v57; - v54 = v57 + v58 - 1; - v55->uW = v54; - v60 = v84[0]; - if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v59 ) - v60 = v81; - v79.DrawTitleText(pFontArrus, 0, v58, v60, *(const char **)&pOutString->cFirstChar, 3u); - v51 = pDialogueWindow; - v85 = (Player *)((char *)v85 + 1); - pOutString = (GUIFont *)((char *)pOutString + 4); - ++v89; - } - while ( v89 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); - } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0); + break; + } + case 1: + { + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + v28 = *(int *)v84; + if ( pDialogueWindow->pCurrentPosActiveItem != 2 ) + v28 = v81; + sprintf(Dest, format_4E2DC8, v28); + sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString); + strcat(Dest, pTmpBuf2); + v90 = pFontArrus->CalcTextHeight(Dest, &v79, 0, 0); + strcat(Dest, "\n \n"); + v29 = *(int *)v84; + if ( pDialogueWindow->pCurrentPosActiveItem != 3 ) + v29 = v81; + sprintf(a1, format_4E2DC8, v29); + sprintf(pTmpBuf2, + pGlobalTXT_LocalizationStrings[86], + //(signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C], + (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier, + v83); + strcat(a1, pTmpBuf2); + v88 = pFontArrus->CalcTextHeight(a1, &v79, 0, 0); + strcat(a1, "\n \n"); + v30 = *(int *)v84; + if ( pDialogueWindow->pCurrentPosActiveItem != 4 ) + v30 = v81; + sprintf(v77, format_4E2DC8, v30); + strcat(v77, pGlobalTXT_LocalizationStrings[160]); + v82 = pFontArrus->CalcTextHeight(v77, &v79, 0, 0); + strcat(v77, "\n \n"); + v75[0] = 0; + v87 = 0; + v31 = (signed int)window_SpeakInHouse->ptr_1C; + if ( v31 >= 108 && v31 <= 120 ) + { + v32 = *(int *)v84; + if ( pDialogueWindow->pCurrentPosActiveItem != 5 ) + v32 = v81; + sprintf(v75, format_4E2DC8, v32); + strcat(v75, pGlobalTXT_LocalizationStrings[611]); + v87 = pFontArrus->CalcTextHeight(v75, &v79, 0, 0); + } + v33 = pDialogueWindow; + Str[1] = (char *)pDialogueWindow; + v34 = pDialogueWindow->pStartingPosActiveItem; + v35 = v34 + pDialogueWindow->pNumPresenceButton; + v36 = LOBYTE(pFontArrus->uFontHeight) - 3; + v37 = -pDialogueWindow->pNumPresenceButton < 0; + pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem; + if ( !(v37 ^ __OFSUB__(v34, v35)) ) + { + //LABEL_75: + sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75); + v71 = 3; + v69 = pTmpBuf; + v67 = 0; + v66 = 146; + //LABEL_98: + v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71); + return; + } + while ( 1 ) + { + v38 = v33->GetControl((unsigned int)pOutString); + if ( v38->uControlParam == 15 ) + { + v46 = v90; + v38->uHeight = v90; + v38->uY = 146; + v41 = v46 + 145; + v38->uW = v41; + } + else if ( v38->uControlParam == 16 ) + { + v44 = v88; + v45 = v90 + v36 + 146; + v38->uHeight = v88; + v38->uY = v45; + v41 = v45 + v44 - 1; + v38->uW = v41; + } + else if ( v38->uControlParam == 96 ) + { + v42 = v90 + v88 + 2 * v36 + 146; + v43 = v82; + v38->uY = v42; + v38->uHeight = v43; + v41 = v43 + v42 - 1; + v38->uW = v41; + } + else if ( v38->uControlParam == 101 ) + { + v39 = v90 + 3 * v36 + v87 + v88 + 146; + v33 = (GUIWindow *)Str[1]; + v40 = v87; + v38->uHeight = v87; + v38->uY = v39; + v41 = v39 + v40 - 1; + //LABEL_73: + v38->uW = v41; + } + v47 = v33->pStartingPosActiveItem; + pOutString = (GUIFont *)((char *)pOutString + 1); + if ( (signed int)pOutString >= v33->pNumPresenceButton + v47 ) + { + sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75); + v71 = 3; + v69 = pTmpBuf; + v67 = 0; + v66 = 146; + v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71); + return; + } + } + break; + } + case 101: + { + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v48 = 2; + pShopOptions[0] = pGlobalTXT_LocalizationStrings[620]; + pOutString = 0; + pShopOptions[1] = pGlobalTXT_LocalizationStrings[622]; + if ( pParty->HasItem(0x28Bu) ) + { + pShopOptions[2] = pGlobalTXT_LocalizationStrings[621]; + v48 = 3; + } + for ( i = 0; i < v48; ++i ) + { + v50 = pFontArrus->CalcTextHeight(pShopOptions[i], &v79, 0, 0); + pOutString = (GUIFont *)((char *)pOutString + v50); + } + v86 = (174 - (signed int)pOutString) / v48; + v51 = pDialogueWindow; + v52 = 174 - v48 * (174 - (signed int)pOutString) / v48 - (signed int)pOutString; + v53 = v52 - HIDWORD(v52); + LODWORD(v52) = pDialogueWindow->pStartingPosActiveItem; + HIDWORD(v52) = v52 + pDialogueWindow->pNumPresenceButton; + v54 = (v53 >> 1) - v86 / 2 + 138; + v37 = -pDialogueWindow->pNumPresenceButton < 0; + v89 = pDialogueWindow->pStartingPosActiveItem; + if ( v37 ^ __OFSUB__((int)v52, HIDWORD(v52)) ) + { + v85 = (Player *)2; + pOutString = (GUIFont *)pShopOptions; + do + { + v55 = v51->GetControl(v89); + v56 = (const char **)pOutString; + v55->uY = v86 + v54; + v57 = pFontArrus->CalcTextHeight(*v56, &v79, 0, 0); + v58 = v55->uY; + v59 = v85; + v55->uHeight = v57; + v54 = v57 + v58 - 1; + v55->uW = v54; + v60 = v84[0]; + if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v59 ) + v60 = v81; + v79.DrawTitleText(pFontArrus, 0, v58, v60, *(const char **)&pOutString->cFirstChar, 3u); + v51 = pDialogueWindow; + v85 = (Player *)((char *)v85 + 1); + pOutString = (GUIFont *)((char *)pOutString + 4); + ++v89; + } + while ( v89 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + } + break; + } + default: + { + break; + } } } @@ -1667,66 +1716,65 @@ v104.uFrameZ = 334; v108 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); v106 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u); - if ( dword_F8B19C == 1 ) - { - result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); - if ( result ) - { - pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; - pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; - pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; - v72 = 0; - pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; - v73 = pShopOptions; - do - { - v74 = pFontArrus->CalcTextHeight(*v73, &v104, 0, 0); - ++v73; - v72 += v74; - } - while ( (signed int)v73 < (signed int)&unk_F8B1C8 ); - v75 = pDialogueWindow; - Str = (char *)((174 - v72) / 4); - result = (POINT *)pDialogueWindow->pStartingPosActiveItem; - v76 = (int)((char *)result + pDialogueWindow->pNumPresenceButton); - v77 = (174 - 4 * (174 - v72) / 4 - v72) / 2 - (174 - v72) / 4 / 2 + 138; - v28 = -pDialogueWindow->pNumPresenceButton < 0; - v112 = pDialogueWindow->pStartingPosActiveItem; - if ( v28 ^ __OFSUB__((int)result, v76) ) - { - _this = (Player *)2; - v111 = (const char **)pShopOptions; - do - { - v78 = v75->GetControl(v112); - v79 = v111; - v78->uY = (unsigned int)&Str[v77]; - v80 = pFontArrus->CalcTextHeight(*v79, &v104, 0, 0); - v81 = v78->uY; - v82 = _this; - v78->uHeight = v80; - v77 = v81 + v80 - 1; - v78->uW = v77; - v83 = v106; - if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v82 ) - v83 = v108; - v104.DrawTitleText(pFontArrus, 0, v81, v83, *v111, 3u); - v75 = pDialogueWindow; - _this = (Player *)((char *)_this + 1); - ++v111; - ++v112; - result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem); - } - while ( (signed int)v112 < (signed int)result ); - } - } - } - else - { - if ( dword_F8B19C != 2 ) - { - if ( dword_F8B19C == 3 ) - { + switch(dword_F8B19C) + { + case 1: + { + result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); + if ( result ) + { + pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; + pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; + pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; + v72 = 0; + pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; + v73 = pShopOptions; + do + { + v74 = pFontArrus->CalcTextHeight(*v73, &v104, 0, 0); + ++v73; + v72 += v74; + } + while ( (signed int)v73 < (signed int)&unk_F8B1C8 ); + v75 = pDialogueWindow; + Str = (char *)((174 - v72) / 4); + result = (POINT *)pDialogueWindow->pStartingPosActiveItem; + v76 = (int)((char *)result + pDialogueWindow->pNumPresenceButton); + v77 = (174 - 4 * (174 - v72) / 4 - v72) / 2 - (174 - v72) / 4 / 2 + 138; + v28 = -pDialogueWindow->pNumPresenceButton < 0; + v112 = pDialogueWindow->pStartingPosActiveItem; + if ( v28 ^ __OFSUB__((int)result, v76) ) + { + _this = (Player *)2; + v111 = (const char **)pShopOptions; + do + { + v78 = v75->GetControl(v112); + v79 = v111; + v78->uY = (unsigned int)&Str[v77]; + v80 = pFontArrus->CalcTextHeight(*v79, &v104, 0, 0); + v81 = v78->uY; + v82 = _this; + v78->uHeight = v80; + v77 = v81 + v80 - 1; + v78->uW = v77; + v83 = v106; + if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v82 ) + v83 = v108; + v104.DrawTitleText(pFontArrus, 0, v81, v83, *v111, 3u); + v75 = pDialogueWindow; + _this = (Player *)((char *)_this + 1); + ++v111; + ++v112; + result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem); + } + while ( (signed int)v112 < (signed int)result ); + } + } + return result; + } + case 3: + { draw_leather(); CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0); @@ -1748,11 +1796,19 @@ v45 = _this->_490EEE(v87, 4, v44, 3); v39 = v113; v38 = (char *)pMerchantsSellPhrases[v45]; - goto LABEL_45; - } - if ( dword_F8B19C == 4 ) - { - draw_leather(); + v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93); + v92 = 3; + v90 = v21; + v88 = v108; + v86 = v3; + v85 = v3; + v84 = &v104; + v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86); + return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92); + } + case 4: + { + draw_leather(); CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); @@ -1776,14 +1832,14 @@ v42 = _this->_490EEE(v37, 4, v41, 4); v39 = v113; v38 = (char *)pMerchantsIdentifyPhrases[v42]; - goto LABEL_45; - } - v89 = window_SpeakInHouse->ptr_1C; - v38 = "%24"; - v87 = v37; -LABEL_44: - v39 = uActiveCharacter - 1; -LABEL_45: + } + else + { + v89 = window_SpeakInHouse->ptr_1C; + v38 = "%24"; + v87 = v37; + v39 = uActiveCharacter - 1; + } v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93); v92 = 3; v90 = v21; @@ -1791,11 +1847,12 @@ v86 = v3; v85 = v3; v84 = &v104; - goto LABEL_46; - } - if ( dword_F8B19C == 94 ) - { - draw_leather(); + v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86); + return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92); + } + case 94: + { + draw_leather(); CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); pShopOptions[0] = pGlobalTXT_LocalizationStrings[200]; pShopOptions[1] = pGlobalTXT_LocalizationStrings[113]; @@ -1844,13 +1901,294 @@ while ( (signed int)v112 < (signed int)result ); } return result; - } - if ( dword_F8B19C != 95 ) - { - result = (POINT *)(dword_F8B19C - 96); - if ( dword_F8B19C != 96 - || (result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) == 0 ) - return result; + } + case 2: + { + pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture); + v3 = 0; + v114 = 0; + do + { + // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID); + { + v46 = ItemsInShopTexture[v114]; + v47 = 152 - v46->uTextureHeight; + if ( (signed int)v47 < 1 ) + v47 = 0; + v48 = 75 * v114 - v46->uTextureWidth / 2 + 40; + if ( v114 ) + { + if ( v114 == 5 ) + { + v49 = ItemsInShopTexture[5]->uTextureWidth; + if ( (signed int)v48 > 457 - v49 ) + v48 = 457 - v49; + } + } + else if ( (signed int)v48 < 18 ) + v48 = 18; + pRenderer->DrawTextureTransparent(v48, v47, v46); + sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1); + } + ++v114; + } + while ( v114 < 6 ); + v114 = 0; + do + { + // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] ) + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID); + { + v50 = ItemsInShopTexture[v114 + 6]; + v51 = 308 - v50->uTextureHeight; + if ( (signed int)v51 < 1 ) + v51 = 0; + v52 = 75 * v114 - v50->uTextureWidth / 2 + 40; + if ( v114 ) + { + if ( v114 == 5 ) + { + v53 = ItemsInShopTexture[11]->uTextureWidth; + if ( (signed int)v52 > 457 - v53 ) + v52 = 457 - v53; + } + } + else + { + if ( (signed int)v52 < 18 ) + v52 = 18; + } + pRenderer->DrawTextureTransparent(v52, v51, v50); + sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7); + } + ++v114; + } + while ( v114 < 6 ); + result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); + if ( result ) + { + v62 = 0; + v109 = 0; + do + { + // if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID); + ++v109; + ++v62; + } + while ( v62 < 12 ); + v63 = GetAsyncKeyState(17); + v64 = _this->CanSteal(); + Str = (char *)v64; + if ( v63 && v64 ) + { + v65 = pGlobalTXT_LocalizationStrings[185]; + } + else if ( dword_F8B19C == 2 ) + { + v65 = pGlobalTXT_LocalizationStrings[195]; + } + else + { + v65 = pGlobalTXT_LocalizationStrings[196]; + } + DrawTextAtStatusBar(v65, 0); + if ( !v109 ) + { + v104.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + return 0; + } + v66 = pMouse->GetCursorPos(&v98); + result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]); + if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF ) + { + v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1; + v109 = v67; + v68 = (int)window_SpeakInHouse->ptr_1C; + // v69 = 9 * (v67 + 12 * v68); + v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67]; + if ( dword_F8B19C != 2 ) + v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; + if ( !v63 || !Str ) + { + v93 = 0; + v91 = 2; + v89 = window_SpeakInHouse->ptr_1C; + v87 = v70; + v113 = uActiveCharacter - 1; + v71 = _this->_490EEE(v70, 4, v68, 2); + v39 = v113; + v38 = (char *)pMerchantsBuyPhrases[v71]; + } + else + { + v38 = pGlobalTXT_LocalizationStrings[181]; + v93 = 0; + v91 = 2; + v89 = window_SpeakInHouse->ptr_1C; + v87 = v70; + v39 = uActiveCharacter - 1; + } + v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93); + v92 = 3; + v90 = v21; + v88 = v108; + v86 = v3; + v85 = v3; + v84 = &v104; + v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86); + return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92); + } + } + return result; + } + case 95: + { + pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture); + v3 = 0; + v114 = 0; + do + { + //if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID) + { + v54 = ItemsInShopTexture[v114]; + v55 = 152 - v54->uTextureHeight; + if ( (signed int)v55 < 1 ) + v55 = 0; + v56 = 75 * v114 - v54->uTextureWidth / 2 + 40; + if ( v114 ) + { + if ( v114 == 5 ) + { + v57 = ItemsInShopTexture[5]->uTextureWidth; + if ( (signed int)v56 > 457 - v57 ) + v56 = 457 - v57; + } + } + else + { + if ( (signed int)v56 < 18 ) + v56 = 18; + } + pRenderer->DrawTextureTransparent(v56, v55, v54); + sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1); + } + ++v114; + } + while ( v114 < 6 ); + v114 = 0; + do + { + // if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] ) //weak + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid + { + v58 = ItemsInShopTexture[v114 + 6]; + v59 = 308 - v58->uTextureHeight; + if ( (signed int)v59 < 1 ) + v59 = 0; + v60 = 75 * v114 - v58->uTextureWidth / 2 + 40; + if ( v114 ) + { + if ( v114 == 5 ) + { + v61 = ItemsInShopTexture[11]->uTextureWidth; + if ( (signed int)v60 > 457 - v61 ) + v60 = 457 - v61; + } + } + else + { + if ( (signed int)v60 < 18 ) + v60 = 18; + } + pRenderer->DrawTextureTransparent(v60, v59, v58); + sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7); + } + ++v114; + } + while ( v114 < 6 ); + result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); + if ( result ) + { + v62 = 0; + v109 = 0; + do + { + //if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID) + ++v109; + ++v62; + } + while ( v62 < 12 ); + v63 = GetAsyncKeyState(17); + v64 = _this->CanSteal(); + Str = (char *)v64; + if ( v63 && v64 ) + { + v65 = pGlobalTXT_LocalizationStrings[185]; + } + else + { + v65 = pGlobalTXT_LocalizationStrings[195]; + if ( dword_F8B19C != 2 ) + v65 = pGlobalTXT_LocalizationStrings[196]; + } + DrawTextAtStatusBar(v65, 0); + if ( !v109 ) + { + v104.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + return 0; + } + v66 = pMouse->GetCursorPos(&v98); + result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]); + if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF ) + { + v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1; + v109 = v67; + v68 = (int)window_SpeakInHouse->ptr_1C; + // v69 = 9 * (v67 + 12 * v68); + v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67]; + if ( dword_F8B19C != 2 ) + v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; + if ( !v63 || !Str ) + { + v93 = 0; + v91 = 2; + v89 = window_SpeakInHouse->ptr_1C; + v87 = v70; + v113 = uActiveCharacter - 1; + v71 = _this->_490EEE(v70, 4, v68, 2); + v39 = v113; + v38 = (char *)pMerchantsBuyPhrases[v71]; + } + else + { + v38 = pGlobalTXT_LocalizationStrings[181]; + v93 = 0; + v91 = 2; + v89 = window_SpeakInHouse->ptr_1C; + v87 = v70; + v39 = uActiveCharacter - 1; + } + v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93); + v92 = 3; + v90 = v21; + v88 = v108; + v86 = v3; + v85 = v3; + v84 = &v104; + v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86); + return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92); + } + } + return result; + } + case 96: + { + if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + return 0; v2 = pDialogueWindow; v3 = 0; v4 = window_SpeakInHouse->ptr_1C; @@ -1939,221 +2277,14 @@ v86 = 0; v85 = 0; v84 = &v104; -LABEL_46: v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86); return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92); - } - } - pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture); - v3 = 0; - v114 = 0; - if ( dword_F8B19C == 2 ) - { - do - { - // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID); - { - v46 = ItemsInShopTexture[v114]; - v47 = 152 - v46->uTextureHeight; - if ( (signed int)v47 < 1 ) - v47 = 0; - v48 = 75 * v114 - v46->uTextureWidth / 2 + 40; - if ( v114 ) - { - if ( v114 == 5 ) - { - v49 = ItemsInShopTexture[5]->uTextureWidth; - if ( (signed int)v48 > 457 - v49 ) - v48 = 457 - v49; - } - } - else - { - if ( (signed int)v48 < 18 ) - v48 = 18; - } - pRenderer->DrawTextureTransparent(v48, v47, v46); - sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1); - } - ++v114; - } - while ( v114 < 6 ); - v114 = 0; - do - { - // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] ) - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID); - { - v50 = ItemsInShopTexture[v114 + 6]; - v51 = 308 - v50->uTextureHeight; - if ( (signed int)v51 < 1 ) - v51 = 0; - v52 = 75 * v114 - v50->uTextureWidth / 2 + 40; - if ( v114 ) - { - if ( v114 == 5 ) - { - v53 = ItemsInShopTexture[11]->uTextureWidth; - if ( (signed int)v52 > 457 - v53 ) - v52 = 457 - v53; - } - } - else - { - if ( (signed int)v52 < 18 ) - v52 = 18; - } - pRenderer->DrawTextureTransparent(v52, v51, v50); - sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7); - } - ++v114; - } - while ( v114 < 6 ); - } - else - { - do - { - //if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) - if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID) - { - v54 = ItemsInShopTexture[v114]; - v55 = 152 - v54->uTextureHeight; - if ( (signed int)v55 < 1 ) - v55 = 0; - v56 = 75 * v114 - v54->uTextureWidth / 2 + 40; - if ( v114 ) - { - if ( v114 == 5 ) - { - v57 = ItemsInShopTexture[5]->uTextureWidth; - if ( (signed int)v56 > 457 - v57 ) - v56 = 457 - v57; - } - } - else - { - if ( (signed int)v56 < 18 ) - v56 = 18; - } - pRenderer->DrawTextureTransparent(v56, v55, v54); - sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1); - } - ++v114; - } - while ( v114 < 6 ); - v114 = 0; - do - { - // if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] ) //weak - if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid - { - v58 = ItemsInShopTexture[v114 + 6]; - v59 = 308 - v58->uTextureHeight; - if ( (signed int)v59 < 1 ) - v59 = 0; - v60 = 75 * v114 - v58->uTextureWidth / 2 + 40; - if ( v114 ) - { - if ( v114 == 5 ) - { - v61 = ItemsInShopTexture[11]->uTextureWidth; - if ( (signed int)v60 > 457 - v61 ) - v60 = 457 - v61; - } - } - else - { - if ( (signed int)v60 < 18 ) - v60 = 18; - } - pRenderer->DrawTextureTransparent(v60, v59, v58); - sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7); - } - ++v114; - } - while ( v114 < 6 ); - } - result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); - if ( result ) - { - v62 = 0; - v109 = 0; - if ( dword_F8B19C == 2 ) - { - do - { - // if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID); - ++v109; - ++v62; - } - while ( v62 < 12 ); - } - else - { - do - { - //if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) - if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID) - ++v109; - ++v62; - } - while ( v62 < 12 ); - } - v63 = GetAsyncKeyState(17); - v64 = _this->CanSteal(); - Str = (char *)v64; - if ( v63 && v64 ) - { - v65 = pGlobalTXT_LocalizationStrings[185]; - } - else - { - v65 = pGlobalTXT_LocalizationStrings[195]; - if ( dword_F8B19C != 2 ) - v65 = pGlobalTXT_LocalizationStrings[196]; - } - DrawTextAtStatusBar(v65, 0); - if ( !v109 ) - { - v104.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); - return 0; - } - v66 = pMouse->GetCursorPos(&v98); - result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]); - if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF ) - { - v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1; - v109 = v67; - v68 = (int)window_SpeakInHouse->ptr_1C; - // v69 = 9 * (v67 + 12 * v68); - v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67]; - if ( dword_F8B19C != 2 ) - v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; - if ( !v63 || !Str ) - { - v93 = 0; - v91 = 2; - v89 = window_SpeakInHouse->ptr_1C; - v87 = v70; - v113 = uActiveCharacter - 1; - v71 = _this->_490EEE(v70, 4, v68, 2); - v39 = v113; - v38 = (char *)pMerchantsBuyPhrases[v71]; - goto LABEL_45; - } - v38 = pGlobalTXT_LocalizationStrings[181]; - v93 = 0; - v91 = 2; - v89 = window_SpeakInHouse->ptr_1C; - v87 = v70; - goto LABEL_44; - } - } - } - return result; + } + default: + { + return (POINT *)dword_F8B19C - 96; + } + } } @@ -2189,7 +2320,7 @@ GUIButton *v26; // esi@26 int v27; // eax@26 unsigned int v28; // ecx@26 - Player *v29; // edx@26 + int v29; // edx@26 unsigned __int16 v30; // ax@26 signed int v31; // esi@31 unsigned int v32; // eax@33 @@ -2358,12 +2489,12 @@ v25->uY = v146 + v23; v27 = pFontArrus->CalcTextHeight(*v16, &v144, 0, 0); v28 = v26->uY; - v29 = _this; + v29 = th; v26->uHeight = v27; v23 = v28 + v27 - 1; v26->uW = v23; v30 = v147; - if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v29 ) + if ( pDialogueWindow->pCurrentPosActiveItem != v29 ) v30 = v148; v144.DrawTitleText(pFontArrus, 0, v28, v30, *v16, 3u); v20 = pDialogueWindow; @@ -3157,7 +3288,7 @@ pDialogueWindow->Release(); pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel" - (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0); pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, "", 0); pDialogueWindow->_41D08F(1, 1, 0, 2); @@ -3299,7 +3430,7 @@ pDialogueWindow->pControlsTail = 0; pDialogueWindow->uNumControls = 0; pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x55u, 0, "", 0); pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x56u, 0, "", 0); pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x57u, 0, "", 0); @@ -3683,7 +3814,7 @@ pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169, 35, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[74], //"End Conversation" - (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : NULL), + (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : NULL), 0); return pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, 0x51u, 0, 0, "", 0); } @@ -3730,7 +3861,7 @@ int v37; // ecx@227 int v38; // esi@230 int v39; // edx@235 - void *v40; // edi@243 + int v40; // edi@243 unsigned __int64 v41; // qax@243 void *v42; // eax@244 signed int v43; // edi@244 @@ -4188,14 +4319,14 @@ GenerateStandartShopItems(); GenerateSpecialShopItems(); v8 = window_SpeakInHouse; - v40 = window_SpeakInHouse->ptr_1C; + v40 = window_SpeakInHouse->par1C; //v3 = dword_F8B198; v41 = pParty->uTimePlayed //+ (signed __int64)((double)(11059200 * (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C]) + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); - pParty->field_3C.field_50[2 * (int)v40] = v41; - pParty->field_3C.field_50[2 * (int)v40 + 1] = HIDWORD(v41); + pParty->field_3C.field_50[v40] = v41; + } v42 = v8->ptr_1C; v43 = 0; @@ -4304,7 +4435,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pKeyActionMap->_459ED1(3); pKeyActionMap->ResetKeys(); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; ptr_F8B1E8 = 0; if ( pDialogueNPCCount ) { @@ -7872,7 +8003,7 @@ //int v28; // eax@35 //int v29; // esi@35 //__int16 v30; // ax@35 - LayingItem a1a; // [sp+Ch] [bp-7Ch]@1 + SpriteObject a1a; // [sp+Ch] [bp-7Ch]@1 //int v32; // [sp+7Ch] [bp-Ch]@1 //int v33; // [sp+80h] [bp-8h]@1 int v34; // [sp+84h] [bp-4h]@1 @@ -7932,7 +8063,7 @@ LABEL_20: v15 = 0; v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uItemType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; if ( (signed int)pObjectList->uNumObjects <= 0 ) { LABEL_24: @@ -7977,7 +8108,7 @@ return result; v23 = 0; v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uItemType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; if ( (signed int)pObjectList->uNumObjects <= 0 ) { LABEL_33: @@ -8025,14 +8156,14 @@ unsigned __int16 v9; // cx@1 char *v10; // edx@2 unsigned __int16 v11; // ax@5 - LayingItem a1; // [sp+8h] [bp-70h]@1 + SpriteObject a1; // [sp+8h] [bp-70h]@1 v6 = ecx0; v7 = a2; pItemsTable->GenerateItem(v6, v7, &a1.stru_24); v8 = 0; v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; - a1.uItemType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; + a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; if ( (signed int)pObjectList->uNumObjects <= 0 ) { LABEL_5: @@ -9328,26 +9459,18 @@ const char **v4; // ebx@2 unsigned int result; // eax@6 - v2 = this; v3 = 1; - if ( (signed int)this->uNumMaps <= 1 ) - { -LABEL_6: - result = 0; - } - else - { - v4 = (const char **)&this->pInfos[1].pFilename; - while ( !*v4 || _strcmpi(*v4, Str2) ) + if ( (signed int)uNumMaps <= 1 ) + return 0; + + while ( !*this->pInfos[v3].pFilename || _strcmpi(this->pInfos[v3].pFilename, Str2) ) { ++v3; - v4 += 17; - if ( (signed int)v3 >= (signed int)v2->uNumMaps ) - goto LABEL_6; - } - result = v3; - } - return result; + if ( (signed int)v3 >= (signed int)uNumMaps ) + return 0; + } + return v3; + } //----- (004547E4) -------------------------------------------------------- @@ -12215,7 +12338,7 @@ _strrev(Str1); for (uint i = 0; i < 1000; ++i) - pLayingItems[i].uObjectDescID = 0; + pSpriteObjects[i].uObjectDescID = 0; v5 = pMapStats->GetMapInfo(pCurrentMapName); bUnderwater = 0; @@ -13128,6 +13251,112 @@ +void IntegrityTest() +{ + assert(sizeof(RenderVertexSoft) == 0x30); + assert(sizeof(RenderBillboard) == 0x34); + assert(sizeof(Texture) == 0x48); + assert(sizeof(RGBTexture) == 0x28); + assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4); // + virtual dtor ptr + assert(sizeof(AudioPlayer) == 0xC84); + assert(sizeof(SoundDesc) == 0x78); + assert(sizeof(stru339_spell_sound) == 0xAFD8); + assert(sizeof(VideoPlayer) == 0x108 + 4); + assert(sizeof(MovieHeader) == 0x2C); + assert(sizeof(DecorationDesc) == 0x54); + assert(sizeof(ObjectDesc) == 0x38); + assert(sizeof(OverlayDesc) == 0x8); + assert(sizeof(ChestDesc) == 0x24); + assert(sizeof(TileDesc) == 0x1A); + assert(sizeof(MonsterDesc) == 0x98); + assert(sizeof(Timer) == 0x28); + assert(sizeof(OtherOverlay) == 0x14); + assert(sizeof(ItemGen) == 0x24); + assert(sizeof(SpriteObject) == 0x70); + assert(sizeof(ItemDesc) == 0x30); + assert(sizeof(ItemsTable) == 0x117A0); + assert(sizeof(Chest) == 0x14CC); + assert(sizeof(MapInfo) == 0x44); + assert(sizeof(SpellInfo) == 0x24); + assert(sizeof(SpellData) == 0x14); + assert(sizeof(SpellBuff) == 0x10); + assert(sizeof(AIDirection) == 0x1C); + assert(sizeof(ActorJob) == 0xC); + assert(sizeof(Actor) == 0x344); + assert(sizeof(LevelDecoration) == 0x20); + assert(sizeof(KeyboardActionMapping) == 0x20C); + assert(sizeof(UIAnimation) == 0xD); + assert(sizeof(SpawnPointMM7) == 0x18); + assert(sizeof(ODMFace) == 0x134); + assert(sizeof(BSPNode) == 0x8); + assert(sizeof(BSPModel) == 0xBC); + assert(sizeof(OutdoorLocation) == 0x1C28C); + assert(sizeof(BLVFace) == 0x60); + assert(sizeof(BLVFaceExtra) == 0x24); + assert(sizeof(BLVSector) == 0x74); + assert(sizeof(BLVLightMM7) == 0x10); + assert(sizeof(BLVDoor) == 0x50); + assert(sizeof(IndoorLocation) == 0x690); + assert(sizeof(OutdoorCamera) == 0x74); + assert(sizeof(Mouse) == 0x114); + assert(sizeof(Particle_) == 0x68); + assert(sizeof(Particle) == 0x68); + assert(sizeof(ParticleEngine) == 0xE430); + assert(sizeof(Lightmap) == 0xC1C); + assert(sizeof(LightmapBuilder) == 0x3CBC38); + assert(sizeof(Vis_SelectionList) == 0x2008); + assert(sizeof(Vis) == 0x20D0); + assert(sizeof(PlayerBuffAnim) == 0x10); + assert(sizeof(ProjectileAnim) == 0x1C); + assert(sizeof(stru6) == 0x5F8); + assert(sizeof(IndoorCameraD3D_Vec3) == 0x10); + assert(sizeof(IndoorCameraD3D_Vec4) == 0x18); //should be 14 (10 vec3 + 4 vdtor) but 18 coz of his +4 from own vdtor, but it is odd since vdtor already present from vec3 + assert(sizeof(IndoorCameraD3D) == 0x1A1384); + assert(sizeof(StationaryLight) == 0xC); + assert(sizeof(LightsStack_StationaryLight_) == 0x12C8); + assert(sizeof(MobileLight) == 0x12); + assert(sizeof(LightsStack_MobileLight_) == 0x1C28); + assert(sizeof(Game) == 0xE78); + assert(sizeof(stru141) == 0xA8); + assert(sizeof(ActionQueue) == 0x7C); + assert(sizeof(NPCData) == 0x4C); + assert(sizeof(NPCStats) == 0x17FFC); + assert(sizeof(BspRenderer) == 0x53740); + assert(sizeof(PaletteManager) == 0x267AF0); + assert(sizeof(ViewingParams) == 0x26C); + assert(sizeof(IndoorCamera) == 0x50); + assert(sizeof(Bloodsplat) == 0x28); + assert(sizeof(BloodsplatContainer) == 0xA0C); + assert(sizeof(stru167) == 0x18); + assert(sizeof(EventIndex) == 0xC); + assert(sizeof(_2devent) == 0x34); + assert(sizeof(stru176) == 0x20); + assert(sizeof(SavegameHeader) == 0x64); + assert(sizeof(SavegameList) == 0x3138); + assert(sizeof(StorylineText) == 0x168); + assert(sizeof(FactionTable) == 0x1EF1); + assert(sizeof(Decal) == 0xC20); + assert(sizeof(DecalBuilder) == 0x30C038); + assert(sizeof(MonsterInfo) == 0x58); + assert(sizeof(MonsterStats) == 0x5BA0); + assert(sizeof(RenderD3D) == 0x148); + assert(sizeof(Render) == 0x129844); + assert(sizeof(Player) == 0x1B3C); + assert(sizeof(Party_stru0) == 0x678); + assert(sizeof(Party) == 0x16238); + assert(sizeof(GUIButton) == 0xBC); + assert(sizeof(GUIWindow) == 0x54); + assert(sizeof(GUIProgressBar) == 0x1B8); + assert(sizeof(GUIFont) == 0x1020); + assert(sizeof(stru262_TurnBased) == 0x40); + assert(sizeof(ArcomageGame) == 0xFA); + assert(sizeof(stru277) == 0x14); + assert(sizeof(ArcomageCard) == 0x6C); + assert(sizeof(stru320) == 0x3FC); + assert(sizeof(TravelInfo) == 0x20); + assert(sizeof(stru336) == 0x798); +} + bool new_sky = false; //----- (00462C94) -------------------------------------------------------- @@ -13145,9 +13374,11 @@ unsigned int startms; // [sp+8h] [bp-24h]@55 RECT Rect; // [sp+Ch] [bp-20h]@15 int a2[4]; // [sp+1Ch] [bp-10h]@15 - + + IntegrityTest(); char test[1024]; - //sprintfex(test, "^Pi[%s]: ^R[;;]", ""); + sprintfex(test, "^Pi[%s]: ^R[;;]", ""); + if (pCmdLine && *pCmdLine) { @@ -14939,12 +15170,12 @@ v17 = a1 >> 3; v26 = a1 >> 3; v18 = a1 >> 3; - if ( pObjectList->pObjects[pLayingItems[v18].uObjectDescID].uFlags & 0x10 + if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 || v17 >= 1000 - || !pLayingItems[v18].uObjectDescID ) + || !pSpriteObjects[v18].uObjectDescID ) return 1; - v19 = &pLayingItems[v18].stru_24; - v20 = pLayingItems[v18].stru_24.uItemID; + v19 = &pSpriteObjects[v18].stru_24; + v20 = pSpriteObjects[v18].stru_24.uItemID; if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD) { party_finds_gold(v19->uSpecEnchantmentType, 0); @@ -14966,7 +15197,7 @@ pParty->SetHoldingItem(v19); v21 = v26; } - LayingItem::OnItemPickup(v21); + SpriteObject::OnInteraction(v21); break; case OBJECT_Actor: @@ -15028,9 +15259,9 @@ v10 = v8->_idx_in_stru123; v24 = 1; v11 = stru_5E4C90._decor_events[v10 - 75] + 380; - GlobalEventInfo = (int)v8; + activeLevelDecoration = v8; EventProcessor(v11, 0, 1); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; } break; @@ -15442,9 +15673,9 @@ { if ( v20 >= 0x3E8 ) return 0; - if ( !(pLayingItems[v20].uAttributes & 0x10) ) - { - v23 = pLayingItems[v20].stru_24.GetDisplayName(); + if ( !(pSpriteObjects[v20].uAttributes & 0x10) ) + { + v23 = pSpriteObjects[v20].stru_24.GetDisplayName(); LABEL_36: v24 = v23; goto LABEL_51; @@ -15591,9 +15822,9 @@ //----- (0046BEF1) -------------------------------------------------------- -void LayingItem::_46BEF1_apply_spells() -{ - LayingItem *v1; // edi@1 +void SpriteObject::_46BEF1_apply_spells() +{ + SpriteObject *v1; // edi@1 Actor *v2; // esi@2 __int16 v3; // fps@4 unsigned __int8 v4; // c0@4 @@ -15635,7 +15866,7 @@ //----- (0046BFFA) -------------------------------------------------------- bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2) { - LayingItem *v2; // esi@1 + SpriteObject *v2; // esi@1 ObjectDesc *v3; // ebx@1 unsigned __int16 v5; // cx@9 unsigned __int16 v6; // cx@14 @@ -15788,7 +16019,7 @@ unsigned int v153; // [sp+28h] [bp-4h]@1 v153 = uLayingItemID; - v2 = &pLayingItems[uLayingItemID]; + v2 = &pSpriteObjects[uLayingItemID]; v3 = &pObjectList->pObjects[v2->uObjectDescID]; v145 = a2; v151 = a2 & 7; @@ -15813,8 +16044,8 @@ } if ( v151 == OBJECT_BModel && (v2->field_58_pid & 7) != OBJECT_Player) BYTE2(pActors[v2->field_58_pid >> 3].uAttributes) |= 4u; - v6 = v2->uItemType; - v7 = v2->uItemType; + v6 = v2->uType; + v7 = v2->uType; if ( v7 > 3060 ) { if ( v7 > 6090 ) @@ -15833,7 +16064,7 @@ v98 = v6 + 1; v99 = pObjectList->uNumObjects; v32 = 0; - v2->uItemType = v98; + v2->uType = v98; v146 = 0; if ( (signed int)v99 > 0 ) { @@ -15877,7 +16108,7 @@ if ( !v138 ) { v109 = pObjectList->uNumObjects; - ++v2->uItemType; + ++v2->uType; v110 = 0; if ( (signed int)v109 <= 0 ) { @@ -15887,7 +16118,7 @@ else { v111 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uItemType != *(short *)v111 ) + while ( v2->uType != *(short *)v111 ) { ++v110; v111 += 56; @@ -15898,7 +16129,7 @@ } v2->uObjectDescID = v112; if ( !v112 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v2->vVelocity.z = 0; v2->vVelocity.y = 0; v2->vVelocity.x = 0; @@ -15921,7 +16152,7 @@ goto LABEL_269; } LABEL_246: - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); return 0; } v106 = v145; @@ -15966,7 +16197,7 @@ if ( stru_50C198.GetMagicalResistance(&pActors[v139], v107) ) { v138 = 0; - if ( v2->uItemType == 8030 ) + if ( v2->uType == 8030 ) { pActors[v108].uAIState = Standing; pActors[v108].UpdateAnimation(); @@ -16002,13 +16233,13 @@ && MonsterStats::BelongsToSupertype(pActors[v145 >> 3].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) sub_43A97E(v153, v145); v93 = pObjectList->uNumObjects; - ++v2->uItemType; + ++v2->uType; v9 = 0; v52 = 0; if ( (signed int)v93 > 0 ) { v94 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uItemType != *(short *)v94 ) + while ( v2->uType != *(short *)v94 ) { ++v52; v94 += 56; @@ -16048,7 +16279,7 @@ v56 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uItemType = v54; + v2->uType = v54; if ( v20 | v44 ) { LABEL_102: @@ -16068,7 +16299,7 @@ } v2->uObjectDescID = v58; if ( !v58 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v14 = v153; v2->vVelocity.z = 0; v2->vVelocity.y = 0; @@ -16104,7 +16335,7 @@ v61 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uItemType = v59; + v2->uType = v59; if ( v20 | v44 ) { LABEL_111: @@ -16124,7 +16355,7 @@ } v2->uObjectDescID = v63; if ( !v63 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v64 = v2->uFacing - stru_5C6E00->uIntegerDoublePi; v44 = v2->field_50 == 4; v2->vVelocity.z = 0; @@ -16147,7 +16378,7 @@ LABEL_160: v14 = v153; LABEL_34: - LayingItem::OnItemPickup(v14); + SpriteObject::OnInteraction(v14); goto LABEL_35; } if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) ) @@ -16157,7 +16388,7 @@ v69 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uItemType = v67; + v2->uType = v67; if ( v20 | v44 ) { LABEL_128: @@ -16177,7 +16408,7 @@ } v2->uObjectDescID = v71; if ( !v71 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v134 = 0; v72 = v153; v132 = 0; @@ -16213,7 +16444,7 @@ v86 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uItemType = v84; + v2->uType = v84; if ( v20 | v44 ) { LABEL_155: @@ -16233,7 +16464,7 @@ } v2->uObjectDescID = v88; if ( !v88 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v89 = v2->uFacing - stru_5C6E00->uIntegerDoublePi; v2->vVelocity.z = 0; v2->vVelocity.y = 0; @@ -16260,7 +16491,7 @@ v81 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uItemType = 4091; + v2->uType = 4091; if ( v20 | v44 ) { LABEL_144: @@ -16280,7 +16511,7 @@ } v2->uObjectDescID = v83; if ( !v83 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v134 = 0; v72 = v153; v132 = v2->field_61; @@ -16302,7 +16533,7 @@ { sub_43A97E(v153, v145); v23 = pObjectList->uNumObjects; - ++v2->uItemType; + ++v2->uType; v18 = 0; v24 = 0; if ( (signed int)v23 <= 0 ) @@ -16313,7 +16544,7 @@ else { v25 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uItemType != *(short *)v25 ) + while ( v2->uType != *(short *)v25 ) { ++v24; v25 += 56; @@ -16325,7 +16556,7 @@ LABEL_42: v2->uObjectDescID = v22; if ( v22 == v18 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v2->vVelocity.z = v18; v2->vVelocity.y = v18; v2->vVelocity.x = v18; @@ -16346,7 +16577,7 @@ case 540: sub_43A97E(v153, v145); v8 = pObjectList->uNumObjects; - ++v2->uItemType; + ++v2->uType; v9 = 0; v10 = 0; if ( (signed int)v8 <= 0 ) @@ -16371,7 +16602,7 @@ v19 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uItemType = 600; + v2->uType = 600; if ( v20 | v44 ) goto LABEL_41; v21 = (char *)&pObjectList->pObjects->uObjectID; @@ -16387,7 +16618,7 @@ default: return 0; } - while ( v2->uItemType != *(short *)v11 ) + while ( v2->uType != *(short *)v11 ) { ++v10; v11 += 56; @@ -16402,8 +16633,8 @@ LABEL_24: v2->uObjectDescID = v12; if ( !v12 ) - LayingItem::OnItemPickup(v153); - v44 = v2->uItemType == 555; + SpriteObject::OnInteraction(v153); + v44 = v2->uType == 555; v2->vVelocity.z = 0; v2->vVelocity.y = 0; v2->vVelocity.x = 0; @@ -16433,13 +16664,13 @@ LABEL_93: sub_43A97E(v153, v145); v51 = pObjectList->uNumObjects; - ++v2->uItemType; + ++v2->uType; v9 = 0; v52 = 0; if ( (signed int)v51 > 0 ) { v53 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uItemType != *(short *)v53 ) + while ( v2->uType != *(short *)v53 ) { ++v52; v53 += 56; @@ -16453,7 +16684,7 @@ LABEL_182: v2->uObjectDescID = v95; if ( v95 == (short)v9 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v96 = v2->uSoundID; v2->vVelocity.z = v9; v2->vVelocity.y = v9; @@ -16478,7 +16709,7 @@ v34 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uItemType = 601; + v2->uType = 601; if ( v20 | v44 ) { LABEL_69: @@ -16498,7 +16729,7 @@ } v2->uObjectDescID = v36; if ( !v36 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v37 = v2->vPosition.z; v2->vVelocity.z = 0; v38 = 8 * v153; @@ -16538,7 +16769,7 @@ v30 = v6 + 1; v31 = pObjectList->uNumObjects; v32 = 0; - v2->uItemType = v30; + v2->uType = v30; v146 = 0; if ( (signed int)v31 > 0 ) { @@ -16555,7 +16786,7 @@ LABEL_196: v2->uObjectDescID = v46; if ( v46 == (short)v32 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v100 = v2->field_61; v101 = v2->vPosition.z; v2->uSpriteFrameID = v32; @@ -16600,12 +16831,12 @@ { sub_43A97E(v153, v145); v122 = pObjectList->uNumObjects; - ++v2->uItemType; + ++v2->uType; v52 = 0; if ( (signed int)v122 > 0 ) { v123 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uItemType != *(short *)v123 ) + while ( v2->uType != *(short *)v123 ) { ++v52; v123 += 56; @@ -16623,7 +16854,7 @@ v119 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uItemType = v117; + v2->uType = v117; if ( v20 | v44 ) { LABEL_255: @@ -16643,7 +16874,7 @@ } v2->uObjectDescID = v121; if ( !v121 ) - LayingItem::OnItemPickup(v153); + SpriteObject::OnInteraction(v153); v2->vVelocity.z = 0; v2->vVelocity.y = 0; v2->vVelocity.x = 0; diff -r cf366ba68de5 -r 1bd8758f50b8 mm7_3.cpp --- a/mm7_3.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/mm7_3.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -20,7 +20,7 @@ #include "Viewport.h" #include "FrameTableInc.h" #include "Math.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "ObjectList.h" #include "Chest.h" #include "PaletteManager.h" @@ -543,7 +543,7 @@ } //----- (0046ED8A) -------------------------------------------------------- -void __fastcall _46ED8A_collide_against_layingItems(unsigned int _this) +void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this) { int v1; // ebx@2 ObjectDesc *v2; // edx@4 @@ -563,10 +563,10 @@ v15 = 0; v12 = _this; - if ( (signed int)uNumLayingItems > 0 ) - { - v1 = (int)&pLayingItems[0].uObjectDescID; - v14 = (char *)&pLayingItems[0].uObjectDescID; + if ( (signed int)uNumSpriteObjects > 0 ) + { + v1 = (int)&pSpriteObjects[0].uObjectDescID; + v14 = (char *)&pSpriteObjects[0].uObjectDescID; do { if ( *(short *)v1 ) @@ -625,7 +625,7 @@ v1 = (int)(v14 + 112); v14 += 112; } - while ( (signed int)v15 < (signed int)uNumLayingItems ); + while ( (signed int)v15 < (signed int)uNumSpriteObjects ); } } @@ -1161,7 +1161,7 @@ v30 = WorldPosToGridCellX(v0->vPosition.x); _46E26D_collide_against_sprites(v30, v29); _46EF01_collision_chech_player(0); - _46ED8A_collide_against_layingItems(8 * v75 | 3); + _46ED8A_collide_against_sprite_objects(8 * v75 | OBJECT_Actor); v31 = 0; for ( i = 0; v31 < ai_arrays_size; ++v31 ) { @@ -1387,801 +1387,6 @@ -//----- (0047136C) -------------------------------------------------------- -void LayingItem::UpdateObject_fn0_BLV(unsigned int uLayingItemID) -{ - LayingItem *v1; // esi@1 - ObjectDesc *v2; // edi@1 - int v3; // ST08_4@1 - __int16 v4; // ax@5 - __int16 v5; // ax@7 - BLVFace *v6; // ecx@11 - BLVFace *v7; // eax@11 - signed int v8; // ebx@12 - int v9; // ecx@16 - __int16 v10; // di@18 - char v11; // al@19 - int v12; // eax@25 - int v13; // eax@31 - int v14; // ebx@34 - signed int v15; // ebx@46 - BLVFace *v16; // edi@48 - int v17; // eax@50 - int v18; // eax@52 - int v19; // ecx@52 - Vec3_short_ *v20; // ecx@53 - int v21; // ecx@57 - __int16 v22; // ax@57 - int v23; // edi@62 - int v24; // edi@62 - int v25; // eax@62 - unsigned __int64 v26; // qax@62 - unsigned __int8 v27; // sf@64 - unsigned __int8 v28; // of@64 - __int16 v29; // di@67 - char v30; // al@68 - const char *v31; // [sp-8h] [bp-98h]@19 - const char *v32; // [sp-8h] [bp-98h]@68 - enum TEXTURE_TYPE v33; // [sp-4h] [bp-94h]@19 - enum TEXTURE_TYPE v34; // [sp-4h] [bp-94h]@68 - Particle_ Dst; // [sp+Ch] [bp-84h]@18 - unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1 - ObjectDesc *v37; // [sp+78h] [bp-18h]@1 - unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4 - int v39; // [sp+80h] [bp-10h]@33 - Actor *v39b; - int v40; // [sp+84h] [bp-Ch]@28 - int v41; // [sp+88h] [bp-8h]@34 - int v42; // [sp+8Ch] [bp-4h]@4 - - uLayingItemID_ = uLayingItemID; - v1 = &pLayingItems[uLayingItemID]; - v2 = &pObjectList->pObjects[v1->uObjectDescID]; - v3 = v1->vPosition.x; - v37 = &pObjectList->pObjects[v1->uObjectDescID]; - if ( abs(v3) > 32767 - || abs(v1->vPosition.y) > 32767 - || abs(v1->vPosition.z) > 20000 - || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v1->uSectorID, &uFaceID), - v42 <= -30000) - && ((v4 = pIndoor->GetSector(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z), - (v1->uSectorID = v4) == 0) - || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v4, &uFaceID), v42 == -30000)) ) - { - LayingItem::OnItemPickup(uLayingItemID_); - return; - } - v5 = v2->uFlags; - if ( v5 & 0x20 ) - { -LABEL_24: - v8 = 0; -LABEL_25: - stru_721530.field_0 = v8; - uFaceID = v8; - stru_721530.prolly_normal_d = v2->uRadius; - v12 = v2->uHeight; - stru_721530.field_84 = -1; - stru_721530.field_C = v12; - stru_721530.field_8 = v8; - stru_721530.field_70 = v8; - while ( 1 ) - { - stru_721530.field_34.x = v1->vPosition.x; - stru_721530.normal.x = stru_721530.field_34.x; - stru_721530.field_34.y = v1->vPosition.y; - stru_721530.normal.y = stru_721530.field_34.y; - stru_721530.field_34.z = stru_721530.prolly_normal_d + v1->vPosition.z + 1; - stru_721530.normal.z = stru_721530.field_34.z; - stru_721530.field_1C = v1->vVelocity.x; - stru_721530.field_20 = v1->vVelocity.y; - stru_721530.field_24 = v1->vVelocity.z; - stru_721530.uSectorID = v1->uSectorID; - if ( stru_721530._47050A(v8) ) - return; - v40 = v8; - do - { - _46E44E_collide_against_faces_and_portals(0); - _46E0B2_collide_against_decorations(); - if ( (v1->field_58_pid & 7) != OBJECT_Player) - _46EF01_collision_chech_player(1); - v13 = v1->field_58_pid; - v42 = v8; - if ( (v13 & 7) == OBJECT_Actor) - { - if ( (signed int)uNumActors > v8 ) - { - v39b = pActors;//[0].word_000086_some_monster_id; - do - { - //v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1; - //v14 = (signed __int64)((double)v41 * 0.3333333333333333); - //v41 = *(short *)(v39 - 38) - 1; - //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) ) - if( pActors[v1->field_58_pid >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID ) - //not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius - _46DF1A_collide_against_actor(v42, *((short *)&pMonsterList->pMonsters[v39b->word_000086_some_monster_id] - 73)); - ++v42; - ++v39b;// += 836; - } - while ( v42 < (signed int)uNumActors ); - v8 = 0; - } - } - else - { - if ( (signed int)uNumActors > v8 ) - { - v39b = pActors;//[0].word_000086_some_monster_id; - do - { - _46DF1A_collide_against_actor(v42++, *((short *)&pMonsterList->pMonsters[*(short *)v39b] - 73)); - ++v39b; - } - while ( v42 < (signed int)uNumActors ); - } - } - if ( _46F04E_collide_against_portals() ) - break; - ++v40; - } - while ( v40 < 100 ); - if ( stru_721530.field_7C >= stru_721530.field_6C ) - { - v1->vPosition.x = stru_721530.normal2.x; - v1->vPosition.y = stru_721530.normal2.y; - v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; - v1->uSectorID = LOWORD(stru_721530.uSectorID); - if ( !(HIBYTE(v2->uFlags) & 1) ) - return; - memset(&Dst, v8, 0x68u); - v29 = v2->uFlags; - Dst.x = (double)v1->vPosition.x; - Dst.y = (double)v1->vPosition.y; - Dst.z = (double)v1->vPosition.z; - Dst.flt_10 = 0.0; - Dst.flt_14 = 0.0; - Dst.flt_18 = 0.0; - if ( v29 & 0x200 ) - { - Dst.bFree = 1036; - Dst.uDiffuse = 0xFF3C1Eu; - v30 = rand(); - v34 = (TEXTURE_TYPE)v8; - v32 = "effpar01"; - } - else - { - if ( v29 & 0x400 ) - goto LABEL_70; - Dst.bFree = 1032; - Dst.uDiffuse = rand(); - v30 = rand(); - v34 = (TEXTURE_TYPE)v8; - v32 = "effpar03"; - } - Dst.timeToLive = (unsigned __int8)(v30 & 0x80) + 128; - Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34); - goto LABEL_71; - } - v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; - v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; - v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; - v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; - v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; - v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; - v1->uSectorID = LOWORD(stru_721530.uSectorID); - stru_721530.field_70 += stru_721530.field_7C; - if ( v2->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) - return; - v15 = (signed int)stru_721530.uFaceID >> 3; - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) - { - v40 = integer_sqrt(v1->vVelocity.x * v1->vVelocity.x + v1->vVelocity.y * v1->vVelocity.y); - v23 = stru_5C6E00->Atan2( - v1->vPosition.x - pLevelDecorations[v15].vPosition.x, - v1->vPosition.y - pLevelDecorations[v15].vPosition.y); - v42 = stru_5C6E00->Cos(v23); - v41 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16; - v24 = v23; - v1->vVelocity.x = (unsigned int)(v42 * v40) >> 16; - v25 = stru_5C6E00->Sin(v23); - v42 = v25; - v26 = v25 * (signed __int64)v40; - v41 = v26 >> 16; - v1->vVelocity.y = WORD1(v26); - } - else - { - if ( (stru_721530.uFaceID & 7) != OBJECT_BModel) - goto LABEL_64; - stru_721530.field_84 = (signed int)stru_721530.uFaceID >> 3; - v16 = &pIndoor->pFaces[v15]; - if ( v16->uPolygonType != 3 ) - { - v42 = abs(v16->pFacePlane_old.vNormal.x * v1->vVelocity.x + v16->pFacePlane_old.vNormal.z * v1->vVelocity.z - + v16->pFacePlane_old.vNormal.y * v1->vVelocity.y) >> 16; - if ( stru_721530.field_64 >> 3 > v42 ) - v42 = stru_721530.field_64 >> 3; - v40 = v16->pFacePlane_old.vNormal.x; - v40 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16; - v41 = v16->pFacePlane_old.vNormal.y; - v41 = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; - v39 = v16->pFacePlane_old.vNormal.z; - v39 = (unsigned __int64)(v42 * (signed __int64)v39) >> 16; - v1->vVelocity.x += 2 * v40; - v1->vVelocity.y += 2 * v41; - if ( v16->pFacePlane_old.vNormal.z <= 32000 ) - { - v22 = 2 * v39; - } - else - { - v21 = v39; - v40 = 32000; - v1->vVelocity.z += v39; - v41 = (unsigned __int64)(v40 * (signed __int64)v21) >> 16; - v22 = (unsigned int)(v40 * v21) >> 16; - } - v1->vVelocity.z += v22; - goto LABEL_60; - } - if ( v37->uFlags & 0x80 ) - { - v17 = -v1->vVelocity.z >> 1; - v1->vVelocity.z = v17; - if ( (signed __int16)v17 < 10 ) - v1->vVelocity.z = 0; -LABEL_60: - if ( BYTE3(v16->uAttributes) & 0x10 ) - EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1); - goto LABEL_63; - } - v18 = v1->vVelocity.y; - v19 = v1->vVelocity.x; - v1->vVelocity.z = 0; - if ( v19 * v19 + v18 * v18 >= 400 ) - goto LABEL_60; - v20 = pIndoor->pVertices; - v1->vVelocity.z = 0; - v1->vVelocity.y = 0; - v1->vVelocity.x = 0; - v1->vPosition.z = v20[*v16->pVertexIDs].z + 1; - } -LABEL_63: - v2 = v37; -LABEL_64: - v41 = v1->vVelocity.x; - v40 = 58500; - v41 = (unsigned __int64)(58500i64 * v41) >> 16; - v1->vVelocity.x = v41; - v41 = v1->vVelocity.y; - v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16; - v40 = 58500; - v1->vVelocity.y = v41; - v41 = v1->vVelocity.z; - v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16; - ++uFaceID; - v28 = __OFSUB__(uFaceID, 100); - v27 = uFaceID - 100 < 0; - v1->vVelocity.z = v41; - if ( !(v27 ^ v28) ) - return; - v8 = 0; - } - } - if ( v42 <= v1->vPosition.z - 3 ) - { - v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); - goto LABEL_24; - } - if ( !(v5 & 0x40) || _46BFFA_check_object_intercept(uLayingItemID_, 0) ) - { - v6 = pIndoor->pFaces; - v1->vPosition.z = v42 + 1; - v7 = &v6[uFaceID]; - if ( v7->uPolygonType == 3 ) - { - v8 = 0; - v1->vVelocity.z = 0; - } - else - { - if ( v7->pFacePlane_old.vNormal.z < 45000 ) - v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); - v8 = 0; - } - v42 = v1->vVelocity.x; - uFaceID = 58500; - v42 = (unsigned __int64)(58500i64 * v42) >> 16; - v1->vVelocity.x = v42; - v42 = v1->vVelocity.y; - v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16; - uFaceID = 58500; - v1->vVelocity.y = v42; - v42 = v1->vVelocity.z; - v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16; - v9 = v1->vVelocity.x; - v1->vVelocity.z = v42; - if ( v9 * v9 + v1->vVelocity.y * v1->vVelocity.y < 400 ) - { - v1->vVelocity.z = v8; - v1->vVelocity.y = v8; - v1->vVelocity.x = v8; - if ( !(HIBYTE(v2->uFlags) & 1) ) - return; - memset(&Dst, v8, 0x68u); - v10 = v2->uFlags; - Dst.x = (double)v1->vPosition.x; - Dst.y = (double)v1->vPosition.y; - Dst.z = (double)v1->vPosition.z; - Dst.flt_10 = 0.0; - Dst.flt_14 = 0.0; - Dst.flt_18 = 0.0; - if ( v10 & 0x200 ) - { - Dst.bFree = 1036; - Dst.uDiffuse = 0xFF3C1Eu; - Dst.flt_28 = 1.0; - v11 = rand(); - v33 = (TEXTURE_TYPE)v8; - v31 = "effpar01"; - } - else - { - if ( v10 & 0x400 ) - { -LABEL_70: - Dst.bFree = 512; - Dst.uDiffuse = rand(); - Dst.timeToLive = 64; - Dst.uTextureID = v8; -LABEL_71: - Dst.flt_28 = 1.0; - goto LABEL_72; - } - Dst.bFree = 1032; - Dst.uDiffuse = rand(); - Dst.flt_28 = 1.0; - v11 = rand(); - v33 = (TEXTURE_TYPE)v8; - v31 = "effpar03"; - } - Dst.timeToLive = (unsigned __int8)(v11 & 0x80) + 128; - Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33); -LABEL_72: - pGame->pParticleEngine->AddParticle(&Dst); - return; - } - goto LABEL_25; - } -} -// 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); - -//----- (00471C03) -------------------------------------------------------- -void LayingItem::UpdateObject_fn0_ODM(unsigned int uLayingItemID) -{ - LayingItem *v1; // esi@1 - ObjectDesc *v2; // ebx@1 - signed int v3; // edx@1 - int v4; // ecx@1 - int v5; // ST04_4@1 - int v6; // eax@1 - int v7; // ecx@1 - int v8; // edi@1 - int v9; // eax@4 - __int16 v10; // ax@7 - int v11; // edx@11 - int v12; // ecx@11 - signed int v13; // edx@14 - signed int v14; // edx@16 - int v15; // eax@24 - int v16; // eax@25 - int v17; // ST10_4@25 - signed int v18; // eax@25 - signed int v19; // eax@28 - Actor *v20; // edi@31 - int v21; // eax@41 - int v22; // ecx@43 - __int16 v23; // bx@45 - char v24; // al@46 - signed int i; // edi@50 - int v26; // edi@52 - int v27; // eax@52 - __int16 v28; // cx@55 - int v29; // eax@55 - signed int v30; // edi@59 - BSPModel *v31; // ecx@61 - ODMFace *v32; // edi@61 - int v33; // eax@62 - int v34; // ecx@62 - int v35; // eax@63 - Actor *v36; // ecx@67 - __int16 v37; // ax@67 - int v38; // eax@72 - int v39; // eax@72 - unsigned __int64 v40; // qax@72 - int v41; // eax@72 - unsigned __int8 v42; // sf@74 - unsigned __int8 v43; // of@74 - int v44; // eax@77 - __int16 v45; // bx@81 - int v46; // eax@85 - const char *v47; // [sp-8h] [bp-B0h]@83 - enum TEXTURE_TYPE v48; // [sp-4h] [bp-ACh]@46 - int v49; // [sp+Ch] [bp-9Ch]@52 - int v50; // [sp+10h] [bp-98h]@52 - Vec3_int_ v51; // [sp+14h] [bp-94h]@11 - Particle_ Dst; // [sp+20h] [bp-88h]@45 - unsigned int uLayingItemID_; // [sp+88h] [bp-20h]@1 - int v54; // [sp+8Ch] [bp-1Ch]@1 - int v55; // [sp+90h] [bp-18h]@1 - int v56; // [sp+94h] [bp-14h]@11 - int v57; // [sp+98h] [bp-10h]@1 - int v58; // [sp+9Ch] [bp-Ch]@1 - int v59; // [sp+A0h] [bp-8h]@1 - Actor *v60; // [sp+A4h] [bp-4h]@11 - - uLayingItemID_ = uLayingItemID; - v1 = &pLayingItems[uLayingItemID]; - v58 = 0; - v2 = &pObjectList->pObjects[v1->uObjectDescID]; - v57 = IsTerrainSlopeTooHigh(v1->vPosition.x, v1->vPosition.y); - v3 = v1->vPosition.y; - v4 = v1->vPosition.x; - v5 = v2->uHeight; - v55 = 0; - v6 = sub_46D49E_prolly_get_world_y_under_party(v4, v3, v1->vPosition.z, v5, &v59, &v55, 0); - v7 = v6; - v54 = v6; - v8 = v6 + 1; - if ( v1->vPosition.z <= v6 + 1 ) - { - if ( v59 ) - { - v9 = v6 + 60; - if ( v55 ) - v9 = v7 + 30; - sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v9); - LayingItem::OnItemPickup(uLayingItemID_); - v7 = v54; - } - } - else - { - v58 = 1; - } - v10 = v2->uFlags; - if ( !(v10 & 0x20) ) - { - if ( v58 ) - { - v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); - goto LABEL_13; - } - if ( v57 ) - { - v11 = v1->vPosition.y; - v12 = v1->vPosition.x; - v1->vPosition.z = v8; - ODM_GetTerrainNormalAt(v12, v11, &v51); - v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); - v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16; - v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16); - v1->vVelocity.x += (unsigned int)(v56 * v51.x) >> 16; - v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16); - v1->vVelocity.y += (unsigned int)(v56 * v51.y) >> 16; - v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16); - v1->vVelocity.z += (unsigned int)(v56 * v51.z) >> 16; -LABEL_12: - v7 = v54; - goto LABEL_13; - } - if ( v10 & 0x40 ) - { - if ( v1->vPosition.z < v7 ) - v1->vPosition.z = v8; - if ( !_46BFFA_check_object_intercept(uLayingItemID_, 0) ) - return; - } - v1->vPosition.z = v8; - if ( !(v2->uFlags & 0x80) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) ) - v1->vVelocity.z = 0; - v60 = (Actor *)v1->vVelocity.x; - v55 = 58500; - v60 = (Actor *)((unsigned __int64)(58500i64 * (signed int)v60) >> 16); - v1->vVelocity.x = (signed __int16)v60; - v60 = (Actor *)v1->vVelocity.y; - v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16); - v55 = 58500; - v1->vVelocity.y = (signed __int16)v60; - v60 = (Actor *)v1->vVelocity.z; - v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16); - v22 = v1->vVelocity.x; - v1->vVelocity.z = (signed __int16)v60; - if ( v1->vVelocity.y * v1->vVelocity.y + v22 * v22 >= 400 ) - goto LABEL_12; - v1->vVelocity.y = 0; - v1->vVelocity.x = 0; - if ( !(HIBYTE(v2->uFlags) & 1) ) - return; - memset(&Dst, 0, 0x68u); - v23 = v2->uFlags; - Dst.x = (double)v1->vPosition.x; - Dst.y = (double)v1->vPosition.y; - Dst.z = (double)v1->vPosition.z; - Dst.flt_10 = 0.0; - Dst.flt_14 = 0.0; - Dst.flt_18 = 0.0; - if ( HIBYTE(v23) & 2 ) - { - Dst.bFree = 1036; - Dst.uDiffuse = 16727070; - v24 = rand(); - v48 = (TEXTURE_TYPE)0; -LABEL_83: - v47 = "effpar01"; - } - else - { - if ( HIBYTE(v23) & 4 ) - { - Dst.bFree = 512; - Dst.uDiffuse = rand(); - Dst.timeToLive = 64; - Dst.uTextureID = 0; -LABEL_89: - Dst.flt_28 = 1.0; - pGame->pParticleEngine->AddParticle(&Dst); - return; - } - Dst.bFree = 1032; - Dst.uDiffuse = rand(); - v24 = rand(); - v48 = (TEXTURE_TYPE)0; -LABEL_87: - v47 = "effpar03"; - } - Dst.timeToLive = (unsigned __int8)(v24 & 0x80) + 128; - Dst.uTextureID = pBitmaps_LOD->LoadTexture(v47, v48); - goto LABEL_89; - } -LABEL_13: - if ( v1->vPosition.z > v7 - && (v13 = v1->vPosition.x, v13 >= -32768) - && v13 <= 32768 - && (v14 = v1->vPosition.y, v14 >= -32768) - && v14 <= 32768 - && v1->vPosition.z <= 13000 - || !(v2->uFlags & 0x40) ) - goto LABEL_92; - if ( v1->vPosition.z < v7 ) - v1->vPosition.z = v8; - if ( _46BFFA_check_object_intercept(uLayingItemID_, 0) ) - { -LABEL_92: - stru_721530.field_0 = 0; - v55 = 0; - stru_721530.prolly_normal_d = v2->uRadius; - stru_721530.field_C = v2->uHeight; - stru_721530.field_8 = 0; - stru_721530.field_70 = 0; - while ( 1 ) - { - stru_721530.field_34.x = v1->vPosition.x; - stru_721530.normal.x = stru_721530.field_34.x; - v15 = v1->vPosition.y; - stru_721530.uSectorID = 0; - stru_721530.field_34.y = v15; - stru_721530.normal.y = v15; - stru_721530.field_34.z = v1->vPosition.z + stru_721530.prolly_normal_d + 1; - stru_721530.normal.z = stru_721530.field_34.z; - stru_721530.field_1C = v1->vVelocity.x; - stru_721530.field_20 = v1->vVelocity.y; - stru_721530.field_24 = v1->vVelocity.z; - if ( stru_721530._47050A(0) ) - return; - _46E889_collide_against_bmodels(0); - v16 = WorldPosToGridCellZ(v1->vPosition.y); - v17 = v1->vPosition.x; - v58 = v16; - v18 = WorldPosToGridCellX(v17); - _46E26D_collide_against_sprites(v18, v58); - if ( (v1->field_58_pid & 7) != OBJECT_Player) - _46EF01_collision_chech_player(0); - if ( (v1->field_58_pid & 7) == OBJECT_Actor) - { - v19 = v1->field_58_pid >> 3; - if ( v19 >= 0 ) - { - if ( v19 < (signed int)(uNumActors - 1) ) - { - v56 = 0; - if ( (signed int)uNumActors > 0 ) - { - v60 = pActors; - v20 = &pActors[v19]; - do - { - if ( v20->GetActorsRelation(v60) ) - _46DF1A_collide_against_actor(v56, 0); - ++v56; - ++v60; - } - while ( v56 < (signed int)uNumActors ); - } - } - } - } - else - { - for ( i = 0; i < (signed int)uNumActors; ++i ) - _46DF1A_collide_against_actor(i, 0); - } - v26 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; - v27 = sub_46D49E_prolly_get_world_y_under_party( - stru_721530.normal2.x, - stru_721530.normal2.y, - stru_721530.normal2.z - stru_721530.prolly_normal_d - 1, - v2->uHeight, - &v49, - &v50, - 0); - if ( v59 && v26 < v27 + 60 ) - { - if ( v50 ) - v44 = v27 + 30; - else - v44 = v54 + 60; - sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v44); - LayingItem::OnItemPickup(uLayingItemID_); - return; - } - if ( stru_721530.field_7C >= stru_721530.field_6C ) - { - v1->vPosition.x = stru_721530.normal2.x; - v1->vPosition.y = stru_721530.normal2.y; - v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; - v1->uSectorID = LOWORD(stru_721530.uSectorID); - if ( !(HIBYTE(v2->uFlags) & 1) ) - return; - memset(&Dst, 0, 0x68u); - v45 = v2->uFlags; - Dst.x = (double)v1->vPosition.x; - Dst.y = (double)v1->vPosition.y; - Dst.z = (double)v1->vPosition.z; - Dst.flt_10 = 0.0; - Dst.flt_14 = 0.0; - Dst.flt_18 = 0.0; - if ( HIBYTE(v45) & 2 ) - { - Dst.bFree = 1036; - Dst.uDiffuse = 16727070; - v24 = rand(); - v48 = (TEXTURE_TYPE)0; - goto LABEL_83; - } - if ( HIBYTE(v45) & 4 ) - { - Dst.bFree = 512; - v46 = rand(); - Dst.uTextureID = 0; - Dst.uDiffuse = v46; - Dst.timeToLive = 64; - goto LABEL_89; - } - Dst.bFree = 1032; - Dst.uDiffuse = rand(); - v24 = rand(); - v48 = (TEXTURE_TYPE)0; - goto LABEL_87; - } - v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16); - v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; - v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16); - v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; - v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16); - v28 = LOWORD(stru_721530.uSectorID); - v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; - v29 = v1->vPosition.z; - v1->uSectorID = v28; - stru_721530.field_70 += stru_721530.field_7C; - if ( v2->uFlags & 0x40 ) - { - if ( v29 < v54 ) - v1->vPosition.z = v54 + 1; - if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) - return; - } - v30 = (signed int)stru_721530.uFaceID >> 3; - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) - break; - if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) - { - v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; - v32 = &v31->pFaces[v30 & 0x3F]; - if ( v32->uPolygonType != 3 ) - { - v56 = abs(v32->pFacePlane.vNormal.z * v1->vVelocity.z + v32->pFacePlane.vNormal.y * v1->vVelocity.y - + v32->pFacePlane.vNormal.x * v1->vVelocity.x) >> 16; - if ( stru_721530.field_64 >> 3 > v56 ) - v56 = stru_721530.field_64 >> 3; - v57 = v32->pFacePlane.vNormal.x; - v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16; - v58 = v32->pFacePlane.vNormal.y; - v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16; - v60 = (Actor *)v32->pFacePlane.vNormal.z; - v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)(signed int)v60) >> 16); - v1->vVelocity.x += 2 * v57; - v1->vVelocity.y += 2 * v58; - if ( v32->pFacePlane.vNormal.z <= 32000 ) - { - v37 = 2 * (short)v60; - } - else - { - v36 = v60; - v57 = 32000; - v1->vVelocity.z += (signed __int16)v60; - v58 = (unsigned __int64)(v57 * (signed __int64)(signed int)v36) >> 16; - v37 = (unsigned int)(v57 * (int)v36) >> 16; - } - v1->vVelocity.z += v37; -LABEL_70: - if ( BYTE3(v32->uAttributes) & 0x10 ) - EventProcessor(v32->sCogTriggeredID, 0, 1); - goto LABEL_74; - } - v33 = v31->pVertices.pVertices[v32->pVertexIDs[0]].z; - v34 = v1->vVelocity.x; - v1->vPosition.z = v33 + 1; - if ( v1->vVelocity.y * v1->vVelocity.y + v34 * v34 >= 400 ) - goto LABEL_70; - LOWORD(v35) = 0; - v1->vVelocity.z = 0; - v1->vVelocity.x = 0; - goto LABEL_73; - } -LABEL_74: - v58 = v1->vVelocity.x; - v57 = 58500; - v58 = (unsigned __int64)(58500i64 * v58) >> 16; - v1->vVelocity.x = v58; - v58 = v1->vVelocity.y; - v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16; - v57 = 58500; - v1->vVelocity.y = v58; - v58 = v1->vVelocity.z; - v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16; - ++v55; - v43 = __OFSUB__(v55, 100); - v42 = v55 - 100 < 0; - v1->vVelocity.z = v58; - if ( !(v42 ^ v43) ) - return; - } - v57 = integer_sqrt(v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x); - v38 = stru_5C6E00->Atan2( - v1->vPosition.x - pLevelDecorations[v30].vPosition.x, - v1->vPosition.y - pLevelDecorations[v30].vPosition.y); - v56 = v38; - v39 = stru_5C6E00->Cos(v38); - v60 = (Actor *)v39; - v40 = v39 * (signed __int64)v57; - v58 = v40 >> 16; - v1->vVelocity.x = WORD1(v40); - v41 = stru_5C6E00->Sin(v56 - stru_5C6E00->uIntegerHalfPi); - v60 = (Actor *)v41; - v35 = (unsigned __int64)(v41 * (signed __int64)v57) >> 16; - v58 = v35; -LABEL_73: - v1->vVelocity.y = v35; - goto LABEL_74; - } -} - - //----- (0047253E) -------------------------------------------------------- void UpdateObjects() @@ -2210,9 +1415,9 @@ //v1 = 0; //v20 = 0; - for (uint i = 0; i < uNumLayingItems; ++i) - { - auto item = pLayingItems + i; + for (uint i = 0; i < uNumSpriteObjects; ++i) + { + auto item = pSpriteObjects + i; v2 = (char *)&item->uSpriteFrameID; //do //{ @@ -2253,7 +1458,7 @@ { v10 = i; LABEL_35: - LayingItem::OnItemPickup(v10); + SpriteObject::OnInteraction(v10); goto LABEL_36; } v11 = v4->uLifetime; @@ -2263,9 +1468,9 @@ { LABEL_22: if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - LayingItem::UpdateObject_fn0_BLV(i); + SpriteObject::UpdateObject_fn0_BLV(i); else - LayingItem::UpdateObject_fn0_ODM(i); + SpriteObject::UpdateObject_fn0_ODM(i); if ( pParty->bTurnBasedModeOn != 1 || !(*(v2 - 4) & 4) ) goto LABEL_36; v12 = abs(pParty->vPosition.x - *(int *)(v2 - 26)); @@ -2309,7 +1514,7 @@ //v2 += 112; //v1 = v20++ + 1; //} - //while ( v20 < (signed int)uNumLayingItems ); + //while ( v20 < (signed int)uNumSpriteObjects ); } } @@ -3668,7 +2873,7 @@ v37 = WorldPosToGridCellZ(pParty->vPosition.y); v38 = WorldPosToGridCellX(pParty->vPosition.x); _46E26D_collide_against_sprites(v38, v37); - _46ED8A_collide_against_layingItems(4u); + _46ED8A_collide_against_sprite_objects(4u); for ( i = 0; i < (signed int)uNumActors; ++i ) _46DF1A_collide_against_actor(i, 0); if ( stru_721530.field_7C >= stru_721530.field_6C ) @@ -7525,7 +6730,7 @@ if ( !(BYTE1(dword_6BE364_game_settings_1) & 0x20) ) { InitializeActors(); - InitializeLayingItems(); + InitializeSpriteObjects(); } BYTE1(dword_6BE364_game_settings_1) &= 0xDFu; //v5 = 0; @@ -12177,15 +11382,15 @@ signed int y; // [sp+54h] [bp-8h]@24 signed int x; // [sp+58h] [bp-4h]@24 - for (uint i = 0; i < uNumLayingItems; ++i) - { - auto p = pLayingItems + i; + for (uint i = 0; i < uNumSpriteObjects; ++i) + { + auto p = pSpriteObjects + i; if (p->uObjectDescID) { v1 = &pObjectList->pObjects[p->uObjectDescID]; if ( !(v1->uFlags & 1) ) { - if ( ((v2 = p->uItemType, v2 < 1000) || v2 >= 10000) + if ( ((v2 = p->uType, v2 < 1000) || v2 >= 10000) && (v2 < 500 || v2 >= 600) && (v2 < 811 || v2 >= 815) || pGame->pStru6Instance->_4A81CA(p)) @@ -12630,7 +11835,6 @@ while (++_it != 4); } - //----- (00441A4E) -------------------------------------------------------- __int16 __fastcall sub_441A4E(int a1) { @@ -13015,10 +12219,10 @@ if ( bWizardEyeActive = true) { uZe = 0; - //for (uint i = 0; i < uNumLayingItems; ++i) - if (uNumLayingItems > 0) - { - a2c = (char *)&pLayingItems[0].uObjectDescID; + //for (uint i = 0; i < uNumSpriteObjects; ++i) + if (uNumSpriteObjects > 0) + { + a2c = (char *)&pSpriteObjects[0].uObjectDescID; while ( 1 ) { if ( !*((short *)a2c - 1) @@ -13056,7 +12260,7 @@ LABEL_83: ++uZe; a2c += 112; - if ( uZe >= (signed int)uNumLayingItems ) + if ( uZe >= (signed int)uNumSpriteObjects ) { v36 = 255; v33 = 0; @@ -14861,7 +14065,7 @@ pEventTimer->Pause(); dword_5C3418 = v4; dword_5C341C = v3; - _591094_decoration = (LevelDecoration *)GlobalEventInfo; + _591094_decoration = activeLevelDecoration; pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)19, a4, 0); pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0); pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0); @@ -14875,11 +14079,11 @@ { pGUIWindow2->Release(); pGUIWindow2 = 0; - GlobalEventInfo = (int)_591094_decoration; + activeLevelDecoration = _591094_decoration; start_event_seq_number = dword_5C341C; EventProcessor(dword_5C3418, 0, 1); start_event_seq_number = 0; - GlobalEventInfo = 0; + activeLevelDecoration = NULL; pEventTimer->Resume(); } @@ -15254,7 +14458,7 @@ while ( (signed int)v41 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); } } - pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0)); + pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); } //----- (004459F9) -------------------------------------------------------- @@ -16345,7 +15549,7 @@ int v55; // [sp+28h] [bp-8Ch]@7 unsigned int yaw; // [sp+30h] [bp-84h]@7 int pitch; // [sp+34h] [bp-80h]@7 - //LayingItem a1; // [sp+38h] [bp-7Ch]@12 + //SpriteObject a1; // [sp+38h] [bp-7Ch]@12 int v59; // [sp+A8h] [bp-Ch]@1 int v60; // [sp+ACh] [bp-8h]@1 int spellnum_; // [sp+B0h] [bp-4h]@1 @@ -16402,10 +15606,10 @@ v15 = 1; a7b = v15; - LayingItem a1; // [sp+38h] [bp-7Ch]@12 - //LayingItem::LayingItem(&a1); - - a1.uItemType = stru_4E3ACC[spellnum_].field_0; + SpriteObject a1; // [sp+38h] [bp-7Ch]@12 + //SpriteObject::SpriteObject(&a1); + + a1.uType = stru_4E3ACC[spellnum_].field_0; if ( spellnum_ > 58 ) { if ( spellnum_ == 69 ) @@ -16468,7 +15672,7 @@ if ( (signed int)pObjectList->uNumObjects <= 0 ) goto LABEL_34; v17 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)a1.uItemType != *(short *)v17 ) + while ( (short)a1.uType != *(short *)v17 ) { ++v16; v17 += 56; @@ -16511,7 +15715,7 @@ else { v22 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)a1.uItemType != *(short *)v22 ) + while ( (short)a1.uType != *(short *)v22 ) { ++v21; v22 += 56; @@ -16551,7 +15755,7 @@ v19 = (char *)&pObjectList->pObjects->uObjectID; do { - if ( (short)a1.uItemType == *(short *)v19 ) + if ( (short)a1.uType == *(short *)v19 ) goto LABEL_20; ++v16; v19 += 56; @@ -16602,7 +15806,7 @@ if ( (signed int)pObjectList->uNumObjects <= 0 ) goto LABEL_59; v26 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)a1.uItemType != *(short *)v26 ) + while ( (short)a1.uType != *(short *)v26 ) { ++v25; v26 += 56; @@ -16758,7 +15962,7 @@ default: return; } - while ( (short)a1.uItemType != *(short *)v30 ) + while ( (short)a1.uType != *(short *)v30 ) { ++v29; v30 += 56; @@ -17081,8 +16285,8 @@ } //----- (00449B57) -------------------------------------------------------- -unsigned int __fastcall _449B57_test_bit(unsigned __int8 *a1, __int16 a2) -{ +bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 ) + { return a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8); } @@ -18561,27 +17765,24 @@ //----- (00404828) -------------------------------------------------------- -LayingItem::LayingItem() -{ - LayingItem *v1; // esi@1 - - v1 = this; - v1->field_22_glow_radius_multiplier = 1; - v1->uSoundID = 0; - v1->uFacing = 0; - v1->vVelocity.z = 0; - v1->vVelocity.y = 0; - v1->vVelocity.x = 0; - v1->uItemType = 0; - v1->uObjectDescID = 0; - v1->field_61 = 0; - v1->field_60_distance_related_prolly_lod = 0; - v1->field_20 = 0; - v1->uSpriteFrameID = 0; - v1->field_50 = 0; - v1->field_4C = 0; - v1->field_48 = 0; - v1->field_54 = 0; +SpriteObject::SpriteObject() +{ + field_22_glow_radius_multiplier = 1; + uSoundID = 0; + uFacing = 0; + vVelocity.z = 0; + vVelocity.y = 0; + vVelocity.x = 0; + uType = 0; + uObjectDescID = 0; + field_61 = 0; + field_60_distance_related_prolly_lod = 0; + field_20 = 0; + uSpriteFrameID = 0; + field_50 = 0; + field_4C = 0; + field_48 = 0; + field_54 = 0; } diff -r cf366ba68de5 -r 1bd8758f50b8 mm7_4.cpp --- a/mm7_4.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/mm7_4.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -23,7 +23,7 @@ #include "Viewport.h" #include "FrameTableInc.h" #include "Math.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "ObjectList.h" #include "Chest.h" #include "PaletteManager.h" @@ -194,9 +194,9 @@ if ( v1->field_2 & 4 ) { v38 = 0; - if ( (signed int)uNumLayingItems > 0 ) - { - v17 = (char *)&pLayingItems[0].vPosition.y; + if ( (signed int)uNumSpriteObjects > 0 ) + { + v17 = (char *)&pSpriteObjects[0].vPosition.y; do { v18 = abs(v33 - *((int *)v17 - 1)); @@ -228,7 +228,7 @@ ++v38; v17 += 112; } - while ( v38 < (signed int)uNumLayingItems ); + while ( v38 < (signed int)uNumSpriteObjects ); } } v0 = i + 1; @@ -1062,7 +1062,7 @@ unsigned int result; // eax@1 result = uLayingItemID; - if ( pObjectList->pObjects[pLayingItems[uLayingItemID].uObjectDescID].uFlags & 0x10 ) + if ( pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID].uFlags & 0x10 ) result = _46BFFA_check_object_intercept(uLayingItemID, a2); return result; } @@ -3401,7 +3401,7 @@ int v39; // edi@111 int v40; // ecx@113 char v41[400]; // [sp+4h] [bp-22Ch]@20 - LayingItem a1; // [sp+194h] [bp-9Ch]@15 + SpriteObject a1; // [sp+194h] [bp-9Ch]@15 Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15 int v44; // [sp+210h] [bp-20h]@22 int v45; // [sp+214h] [bp-1Ch]@25 @@ -3462,7 +3462,7 @@ } if (pParty->ImmolationActive()) { - //LayingItem::LayingItem(&a1); + //SpriteObject::SpriteObject(&a1); v9 = 0; a3.z = 0; a3.y = 0; @@ -3471,7 +3471,7 @@ a1.field_4C = pParty->pPartyBuffs[10].uPower; a1.field_50 = pParty->ImmolationSkillLevel(); v10 = 0; - a1.uItemType = 1070; + a1.uType = 1070; a1.field_48 = 8; if ( (signed int)pObjectList->uNumObjects <= 0 ) { @@ -9365,6 +9365,7 @@ v9->uHolderPlayer = v5; } } + // 4F08EC: using guessed type int dword_4F08EC[]; // 722B3C: using guessed type int dword_722B3C; // 722B44: using guessed type int dword_722B44; @@ -9457,9 +9458,9 @@ else { ptr_F8B1E8 = 0; - GlobalEventInfo = 1; + activeLevelDecoration = (LevelDecoration*)1; EventProcessor(pEventNumber, 0, 1); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; } } } @@ -10626,7 +10627,7 @@ pDialogueWindow->Release(); pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventCode, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7, 0x1BD, 0xA9, 0x23, 1, 0, 0x71, 0, 0, pGlobalTXT_LocalizationStrings[34], - (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0); pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0); pDialogueWindow->_41D08F(1, 1, 0, 2); @@ -10649,7 +10650,7 @@ v2 = ""; pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[34], - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0); if ( contract_approved ) @@ -10682,7 +10683,7 @@ 0, 0, pGlobalTXT_LocalizationStrings[34], - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0); if ( pNPCStats->pProfessions[v1->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v1->uProfession) ) @@ -10763,7 +10764,7 @@ pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton( 471u, 445u, 169u, 35u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0); if ( pDialogueNPCCount == 1 && dword_591080 ) { @@ -11939,264 +11940,227 @@ //----- (004BC49B) -------------------------------------------------------- void OnSelectDialogueOption(DIALOGUE_TYPE newDialogueType) -{ - //unsigned int v1; // esi@1 - NPCData *v2; // ebp@1 - //unsigned int v3; // eax@1 - int v4; // ecx@10 - signed int v5; // edi@14 - char *v6; // esi@15 - const char *v7; // ecx@22 - signed int v8; // edi@37 - //unsigned int v9; // eax@56 - unsigned int v10; // ecx@57 - void *v11; // [sp-Ch] [bp-1Ch]@46 - int v12; // [sp-8h] [bp-18h]@46 - char *v13; // [sp-8h] [bp-18h]@60 - size_t v14; // [sp-4h] [bp-14h]@46 - const char *v15; // [sp-4h] [bp-14h]@60 - - //v1 = _this; - v2 = GetNPCData(uDialogue_SpeakingActorNPC_ID); - //v3 = v1; - uDialogueType = newDialogueType; - if ( !v2->uFlags ) - { - v2->uFlags = 1; - //v3 = uDialogueType; - } - if ( (signed int)newDialogueType > 22 ) - { - if ( newDialogueType == DIALOGUE_23 ) - { - v4 = v2->evt_E; - goto LABEL_74; - } - if (newDialogueType == DIALOGUE_24) - { - v4 = v2->evt_F; - goto LABEL_74; - } - if (newDialogueType != DIALOGUE_76) - { - if (newDialogueType == DIALOGUE_PROFESSION_DETAILS) - { - dialogue_show_profession_details = ~dialogue_show_profession_details; - } - else - { - if ( (signed int)newDialogueType > 84 && (signed int)newDialogueType <= 88 ) - { - ArenaFight(); - return; - } - } - goto LABEL_87; - } - if (v2->Hired()) - { - v8 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v6 = (char *)pNPCStats->pNewNPCData; - while ( !(v6[8] & 0x80) || strcmp(v2->pName, *(const char **)v6) ) - { - ++v8; - v6 += 76; - if ( v8 >= (signed int)pNPCStats->uNumNewNPCs ) - goto LABEL_44; - } - goto LABEL_43; - } + { + //unsigned int v1; // esi@1 + NPCData *speakingNPC; // ebp@1 + //unsigned int v3; // eax@1 + int npc_event_id; // ecx@10 + signed int v5; // edi@14 + char *v6; // esi@15 + const char *v7; // ecx@22 + signed int v8; // edi@37 + //unsigned int v9; // eax@56 + unsigned int v10; // ecx@57 + void *v11; // [sp-Ch] [bp-1Ch]@46 + int v12; // [sp-8h] [bp-18h]@46 + char *v13; // [sp-8h] [bp-18h]@60 + size_t v14; // [sp-4h] [bp-14h]@46 + const char *v15; // [sp-4h] [bp-14h]@60 + + //v1 = _this; + speakingNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID); + //v3 = v1; + uDialogueType = newDialogueType; + if ( !speakingNPC->uFlags ) + { + speakingNPC->uFlags = 1; + //v3 = uDialogueType; + } + if ((newDialogueType>DIALOGUE_24)||(newDialogueType 84 && (signed int)newDialogueType <= 88 ) + { + ArenaFight(); + return; + } + } + goto LABEL_87; + } + if (speakingNPC->Hired()) + { + v8 = 0; + if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) + { + v6 = (char *)pNPCStats->pNewNPCData; + while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) ) + { + ++v8; + v6 += 76; + if ( v8 >= (signed int)pNPCStats->uNumNewNPCs ) + goto LABEL_44; + } + goto LABEL_43; + } LABEL_44: - if ( !pParty->pHirelings[0].pName || _strcmpi(pParty->pHirelings[0].pName, v2->pName) ) - { - if ( !pParty->pHirelings[1].pName || _strcmpi(pParty->pHirelings[1].pName, v2->pName) ) - { + if ( !pParty->pHirelings[0].pName || _strcmpi(pParty->pHirelings[0].pName, speakingNPC->pName) ) + { + if ( !pParty->pHirelings[1].pName || _strcmpi(pParty->pHirelings[1].pName, speakingNPC->pName) ) + { LABEL_51: - pParty->field_709 = 0; - sub_44A56A(); - dword_591084 = 0; - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - goto LABEL_89; - } - v14 = 76; - v12 = 0; - v11 = &pParty->pHirelings[1]; - } - else - { - v14 = 76; - v12 = 0; - v11 = pParty->pHirelings; - } - memset(v11, v12, v14); - goto LABEL_51; - } - if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName ) - { - v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full"" + pParty->field_709 = 0; + sub_44A56A(); + dword_591084 = 0; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + + goto LABEL_89; + } + v11 = &pParty->pHirelings[1]; + } + else + { + v11 = pParty->pHirelings; + } + memset(v11, 0, sizeof(NPCData)); + goto LABEL_51; + } + if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName ) + { + v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full"" LABEL_64: - ShowStatusBarString(v7, 2u); - goto LABEL_87; - } - //v9 = v2->uProfession; - if ( v2->uProfession != 51 ) - { - v10 = pNPCStats->pProfessions[v2->uProfession - 1].uHirePrice; - if ( pParty->uNumGold < v10 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold" - dialogue_show_profession_details = false; - uDialogueType = 13; + ShowStatusBarString(v7, 2u); + goto LABEL_87; + } + //v9 = v2->uProfession; + if ( speakingNPC->uProfession != 51 ) + { + v10 = pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice; + if ( pParty->uNumGold < v10 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold" + dialogue_show_profession_details = false; + uDialogueType = 13; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); + v7 = pGlobalTXT_LocalizationStrings[155]; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + goto LABEL_87; + } + Party::TakeGold(v10); + } + LOBYTE(speakingNPC->uFlags) |= 0x80u; + if ( pParty->pHirelings[0].pName ) + { + memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1])); + v15 = speakingNPC->pName; + v13 = pParty->pHireling2Name; + } + else + { + memcpy(pParty->pHirelings, speakingNPC, 0x4Cu); + v15 = speakingNPC->pName; + v13 = pParty->pHireling1Name; + } + strcpy(v13, v15); + pParty->field_709 = 0; + sub_44A56A(); + + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + + if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) + pDialogue_SpeakingActor->uAIState = Removed; if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); - v7 = pGlobalTXT_LocalizationStrings[155]; - goto LABEL_64; - } - Party::TakeGold(v10); - } - LOBYTE(v2->uFlags) |= 0x80u; - if ( pParty->pHirelings[0].pName ) - { - memcpy(&pParty->pHirelings[1], v2, sizeof(pParty->pHirelings[1])); - v15 = v2->pName; - v13 = pParty->pHireling2Name; - } + pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0); + goto LABEL_87; + if (newDialogueType == DIALOGUE_9) + { + if ( !sub_4BB756(speakingNPC->uProfession) ) + { + if ( speakingNPC->uProfession != 41 ) + speakingNPC->bHasUsedTheAbility = 1; + + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + } + else + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); //"Your packs are already full!" + } + + goto LABEL_87; + } + if (newDialogueType == DIALOGUE_13) + { + if (!speakingNPC->Hired()) + { + sub_4B3E1E(); + dialogue_show_profession_details = false; + goto LABEL_87; + } + else + { + v5 = 0; + if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) + { + v6 = (char *)pNPCStats->pNewNPCData; + while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) ) + { + ++v5; + v6 += 76; + if ( v5 >= (signed int)pNPCStats->uNumNewNPCs ) + goto LABEL_44; + } +LABEL_43: + v6[8] &= 0x7Fu; + goto LABEL_44; + } + goto LABEL_44; + } + } + } else - { - memcpy(pParty->pHirelings, v2, 0x4Cu); - v15 = v2->pName; - v13 = pParty->pHireling1Name; - } - strcpy(v13, v15); - pParty->field_709 = 0; - sub_44A56A(); - - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) - pDialogue_SpeakingActor->uAIState = Removed; - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0); - goto LABEL_87; - } - if (newDialogueType == DIALOGUE_22) - { - v4 = v2->evt_D; - goto LABEL_74; - } - if (newDialogueType == DIALOGUE_9) - { - if ( !sub_4BB756(v2->uProfession) ) - { - if ( v2->uProfession != 41 ) - v2->bHasUsedTheAbility = 1; - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - goto LABEL_87; - } - v7 = pGlobalTXT_LocalizationStrings[140]; - goto LABEL_64; - } - if (newDialogueType == DIALOGUE_13) - { - if (!v2->Hired()) - { - sub_4B3E1E(); - dialogue_show_profession_details = false; - goto LABEL_87; - } - v5 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v6 = (char *)pNPCStats->pNewNPCData; - while ( !(v6[8] & 0x80) || strcmp(v2->pName, *(const char **)v6) ) - { - ++v5; - v6 += 76; - if ( v5 >= (signed int)pNPCStats->uNumNewNPCs ) - goto LABEL_44; - } -LABEL_43: - v6[8] &= 0x7Fu; - goto LABEL_44; - } - goto LABEL_44; - } - if (newDialogueType == DIALOGUE_19) - { - v4 = v2->evt_A; - goto LABEL_74; - } - if (newDialogueType == DIALOGUE_20) - { - v4 = v2->evt_B; - goto LABEL_74; - } - if (newDialogueType == DIALOGUE_21) - { - v4 = v2->evt_C; -LABEL_74: - if ( v4 < 200 || v4 > 310 ) - { - if ( v4 < 400 || v4 > 410 ) - { - switch ( v4 ) - { - case 139: - sub_4B1ECE(); - break; - case 311: - sub_4BBA85_bounties(); - break; - case 399: - sub_4BBCDD(); - break; - default: - GlobalEventInfo = 1; - ptr_F8B1E8 = 0; - EventProcessor(v4, 0, 1); - GlobalEventInfo = 0; - break; - } - } - else - { - dword_F8B1D8 = newDialogueType; - DrawJoinGuildWindow(v4 - 400); - } - } - else - { - sub_4B3FE5(v4); - } - } + { + switch(newDialogueType) + { + case DIALOGUE_19: npc_event_id = speakingNPC->evt_A; break; + case DIALOGUE_20: npc_event_id = speakingNPC->evt_B; break; + case DIALOGUE_21: npc_event_id = speakingNPC->evt_C; break; + case DIALOGUE_22: npc_event_id = speakingNPC->evt_D; break; + case DIALOGUE_23: npc_event_id = speakingNPC->evt_E; break; + case DIALOGUE_24: npc_event_id = speakingNPC->evt_F; break; + } + if ( (npc_event_id >= 200) && (npc_event_id <= 310) ) + sub_4B3FE5(npc_event_id); //200-310 + else if (( npc_event_id >= 400) && (npc_event_id <= 410) ) + { //400-410 + dword_F8B1D8 = newDialogueType; + DrawJoinGuildWindow(npc_event_id - 400); + } + else + { + switch ( npc_event_id ) + { + case 139: + sub_4B1ECE(); + break; + case 311: + sub_4BBA85_bounties(); + break; + case 399: + sub_4BBCDD(); + break; + default: + activeLevelDecoration = (LevelDecoration*)1; + ptr_F8B1E8 = 0; + EventProcessor(npc_event_id, 0, 1); + activeLevelDecoration = NULL; + break; + } + } + } LABEL_87: - if ( !dword_7241C8 ) - pGame->Draw(); + if ( !dword_7241C8 ) + pGame->Draw(); LABEL_89: - dword_7241C8 = 0; -} + dword_7241C8 = 0; + } @@ -13559,10 +13523,10 @@ } while ( v4 < v2->uActorQueueSize ); } - if ( (signed int)uNumLayingItems > 0 ) - { - pAttributes = &pLayingItems[0].uAttributes; - v9 = uNumLayingItems; + if ( (signed int)uNumSpriteObjects > 0 ) + { + pAttributes = &pSpriteObjects[0].uAttributes; + v9 = uNumSpriteObjects; do { v10 = *pAttributes; diff -r cf366ba68de5 -r 1bd8758f50b8 mm7_5.cpp --- a/mm7_5.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/mm7_5.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -22,7 +22,7 @@ #include "Viewport.h" #include "FrameTableInc.h" #include "Math.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "ObjectList.h" #include "Chest.h" #include "PaletteManager.h" @@ -31,7 +31,6 @@ #include "stru123.h" #include "Time.h" #include "IconFrameTable.h" -#include "stru179.h" #include "Awards.h" #include "Autonotes.h" #include "stru160.h" @@ -1783,7 +1782,7 @@ } if ( v45 == 2 ) { - v47 = (pObjectList->pObjects[pLayingItems[v46].uObjectDescID].uFlags & 0x10) == 0; + v47 = (pObjectList->pObjects[pSpriteObjects[v46].uObjectDescID].uFlags & 0x10) == 0; //LABEL_400: if ( !v47 ) continue; @@ -3174,7 +3173,7 @@ pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 102; GUIWindow::Create(pCharacterScreen_AwardsBtn->uX, pCharacterScreen_AwardsBtn->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pCharacterScreen_AwardsBtn, 0); - sub_419100(); + FillAwardsData(); continue; case UIMSG_AutonotesBook: switch ( uMessageParam ) @@ -4679,7 +4678,7 @@ char *v1; // esi@2 int v2; // ecx@3 signed int v3; // eax@3 - LayingItem *v4; // eax@4 + SpriteObject *v4; // eax@4 signed int v5; // eax@4 signed int v6; // eax@6 unsigned int v7; // edi@6 @@ -4711,7 +4710,7 @@ int v33; // ST24_4@29 Vec3_int_ v34; // ST04_12@30 Vec3_int_ *v35; // eax@31 - LayingItem *v36; // [sp+0h] [bp-28h]@0 + SpriteObject *v36; // [sp+0h] [bp-28h]@0 signed int v37; // [sp+4h] [bp-24h]@5 int v38; // [sp+4h] [bp-24h]@15 signed int v39; // [sp+8h] [bp-20h]@3 @@ -4738,7 +4737,7 @@ v39 = (signed int)*((short *)v1 - 300) >> 3; if ( v2 == 2 ) { - v4 = &pLayingItems[v3]; + v4 = &pSpriteObjects[v3]; v36 = v4; v5 = v4->field_58_pid; v2 = v5 & 7; @@ -4904,12 +4903,12 @@ void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity) { //signed int v3; // eax@1 - LayingItem *v4; // ebx@1 + SpriteObject *v4; // ebx@1 //int v5; // edx@3 //bool uPlayerID; // eax@3 //Player *pPlayer; // edi@4 Actor *pMonster; // esi@7 - LayingItem *v9; // ebx@12 + SpriteObject *v9; // ebx@12 int v10; // eax@12 int v11; // ebx@12 unsigned int v12; // ecx@12 @@ -4978,7 +4977,7 @@ v62 = 0; if ( (a1 & 7) == OBJECT_Item) { - v4 = &pLayingItems[a1 >> 3]; + v4 = &pSpriteObjects[a1 >> 3]; //uDamageAmount = (int)v4; v61 = v4->field_60_distance_related_prolly_lod; a1 = v4->field_58_pid; @@ -5054,7 +5053,7 @@ v61 = v4->field_60_distance_related_prolly_lod; if ( !v19 ) { - v9 = (LayingItem *)uDamageAmount; + v9 = (SpriteObject *)uDamageAmount; v50 = pParty->vPosition.x - *(int *)(uDamageAmount + 4); //v55 = abs(v50); pMonsterName = (char *)(pParty->vPosition.y - v9->vPosition.y); @@ -5094,7 +5093,7 @@ { v61 = 1; } - v4 = (LayingItem *)uDamageAmount; + v4 = (SpriteObject *)uDamageAmount; } v15 = v4->field_48; @@ -5409,7 +5408,7 @@ int v34; // edi@61 int v35; // eax@70 double v36; // st7@70 - LayingItem *v37; // ebx@77 + SpriteObject *v37; // ebx@77 int v38; // edi@77 int v39; // esi@77 int v40; // eax@77 @@ -5650,7 +5649,7 @@ viewparams->bRedrawGameUI = 1; return; } - v37 = &pLayingItems[uActorID]; + v37 = &pSpriteObjects[uActorID]; v38 = v37->field_58_pid & 7; v39 = v37->field_58_pid >> 3; v40 = v37->field_58_pid & 7; @@ -5666,8 +5665,8 @@ a4 = stru_50C198.which_player_would_attack(v44); v45 = &pParty->pPlayers[a4]; v77 = Actor::_43B3E0_CalcDamage(v44, v74); - v46 = v37->uItemType; - if ( v37->uItemType == 545 ) + v46 = v37->uType; + if ( v37->uType == 545 ) { LOBYTE(v51) = v45->GetActualSkillLevel(PLAYER_SKILL_UNARMED); v52 = v51; @@ -5892,29 +5891,29 @@ v6 = uLayingItemID; v2 = uLayingItemID; v3 = a2 >> 3; - v4 = pLayingItems[uLayingItemID].field_58_pid & 7; + v4 = pSpriteObjects[uLayingItemID].field_58_pid & 7; v5 = (a2 & 7) - 3; if ( v5 ) { if ( v5 == 1 ) { - layingitem_vel_50FDFC.x = pLayingItems[v2].vVelocity.x; - layingitem_vel_50FDFC.y = pLayingItems[v2].vVelocity.y; - layingitem_vel_50FDFC.z = pLayingItems[v2].vVelocity.z; + layingitem_vel_50FDFC.x = pSpriteObjects[v2].vVelocity.x; + layingitem_vel_50FDFC.y = pSpriteObjects[v2].vVelocity.y; + layingitem_vel_50FDFC.z = pSpriteObjects[v2].vVelocity.z; Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); - DamagePlayerFromMonster(8 * v6 | 2, pLayingItems[v2].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu); - } - } - else - { - layingitem_vel_50FDFC.x = pLayingItems[v2].vVelocity.x; - layingitem_vel_50FDFC.y = pLayingItems[v2].vVelocity.y; - layingitem_vel_50FDFC.z = pLayingItems[v2].vVelocity.z; + DamagePlayerFromMonster(8 * v6 | 2, pSpriteObjects[v2].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu); + } + } + else + { + layingitem_vel_50FDFC.x = pSpriteObjects[v2].vVelocity.x; + layingitem_vel_50FDFC.y = pSpriteObjects[v2].vVelocity.y; + layingitem_vel_50FDFC.z = pSpriteObjects[v2].vVelocity.z; Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); switch ( v4 ) { case OBJECT_Actor: - sub_43B1B0(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC, pLayingItems[v2].field_61); + sub_43B1B0(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC, pSpriteObjects[v2].field_61); break; case OBJECT_Player: DamageMonsterFromParty(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC); @@ -6053,7 +6052,7 @@ void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) { Actor *pActor; // esi@1 - LayingItem *v4; // eax@3 + SpriteObject *v4; // eax@3 int v5; // ecx@3 int v6; // eax@4 int v7; // edi@4 @@ -6068,7 +6067,7 @@ { if ( (a2 & 7) == OBJECT_Item) { - v4 = &pLayingItems[(signed int)a2 >> 3]; + v4 = &pSpriteObjects[(signed int)a2 >> 3]; v5 = v4->field_48; if ( v5 ) { @@ -6108,7 +6107,7 @@ void sub_43B1B0(signed int a1, unsigned int a2, Vec3_int_ *pVelocity, signed int a4) { int v4; // ebx@1 - LayingItem *v5; // eax@2 + SpriteObject *v5; // eax@2 bool v6; // eax@3 Actor *v7; // esi@4 Actor *v8; // edi@4 @@ -6127,7 +6126,7 @@ v17 = a1; if ( (a1 & 7) == OBJECT_Item) { - v5 = &pLayingItems[a1 >> 3]; + v5 = &pSpriteObjects[a1 >> 3]; v4 = v5->field_60_distance_related_prolly_lod; v17 = v5->field_58_pid; } @@ -6223,7 +6222,7 @@ } //----- (0043BCA7) -------------------------------------------------------- -int __cdecl CharacterUI_LoadPaperdollTextures() +void CharacterUI_LoadPaperdollTextures() { int v0; // edi@7 enum CHARACTER_RACE pRace; // ebx@7 @@ -6238,14 +6237,14 @@ char v10; // al@16 signed int v11; // edi@21 Player *pPlayer3; // ebx@23 - Player *pPlayer4; // edi@29 - int v14; // ebp@29 - stru331 *v15; // edi@65 - signed int v16; // ebx@66 - unsigned int v17; // eax@67 - unsigned int *v18; // ecx@67 - unsigned int *v19; // ebx@68 - int v20; // edi@73 + //Player *pPlayer4; // edi@29 + //int v14; // ebp@29 + //stru331 *v15; // edi@65 + //signed int v16; // ebx@66 + //unsigned int v17; // eax@67 + //unsigned int *v18; // ecx@67 + //unsigned int *v19; // ebx@68 + //int v20; // edi@73 int v21; // ebp@73 unsigned int v22; // eax@76 int v23; // ecx@76 @@ -6254,19 +6253,19 @@ int v26; // ebx@79 unsigned int v27; // eax@80 int v28; // ecx@80 - int result; // eax@83 + //int result; // eax@83 int v30; // [sp+10h] [bp-28h]@5 - signed int v31; // [sp+10h] [bp-28h]@68 + //signed int v31; // [sp+10h] [bp-28h]@68 signed int v32; // [sp+10h] [bp-28h]@75 signed int v33; // [sp+10h] [bp-28h]@77 int v34; // [sp+10h] [bp-28h]@79 - char *v35; // [sp+14h] [bp-24h]@65 + //char *v35; // [sp+14h] [bp-24h]@65 int v36; // [sp+14h] [bp-24h]@75 int v37; // [sp+14h] [bp-24h]@77 signed int v38; // [sp+14h] [bp-24h]@79 - unsigned int *v39; // [sp+18h] [bp-20h]@66 + //unsigned int *v39; // [sp+18h] [bp-20h]@66 int *v40; // [sp+18h] [bp-20h]@73 - unsigned int *v41; // [sp+1Ch] [bp-1Ch]@73 + //unsigned int *v41; // [sp+1Ch] [bp-1Ch]@73 int v42; // [sp+20h] [bp-18h]@6 int v43; // [sp+20h] [bp-18h]@73 char pContainer[128]; // [sp+24h] [bp-14h]@12 @@ -6277,7 +6276,7 @@ uTextureID_507B04 = uTextureID_right_panel; v30 = 0; uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE); - uTextureID_5118C8 = uTextureID_506438; + uTextureID_5118C8 = uExitCancelTextureId; do { v42 = v30 + 1; @@ -6363,116 +6362,103 @@ ++v11; } while ( v11 < 54 ); - *(int *)byte_5111F6 = 0; - *(int *)&byte_5111F6[4] = 0; - *(int *)&byte_5111F6[8] = 0; - *(int *)&byte_5111F6[12] = 0; - *(int *)&byte_5111F6[16] = 0; - pPlayer4 = pParty->pPlayers; - v14 = 1; - do - { - if ( sub_43EE15_player_has_item(0x204u, pPlayer4, 1) ) - byte_5111F6[2] = 1; - if ( sub_43EE15_player_has_item(0x1F8u, pPlayer4, 1) ) - byte_5111F6[0] = 1; - if ( sub_43EE15_player_has_item(0x1F9u, pPlayer4, 1) ) - byte_5111F6[1] = 1; - if ( sub_43EE15_player_has_item(0x215u, pPlayer4, 1) ) - byte_5111F6[16] = 1; - if ( sub_43EE15_player_has_item(0x200u, pPlayer4, 1) ) - byte_5111F6[3] = 1; - if ( sub_43EE15_player_has_item(0x209u, pPlayer4, 1) ) - byte_5111F6[4] = 1; - if ( sub_43EE15_player_has_item(0x20Au, pPlayer4, 1) ) - byte_5111F6[5] = 1; - if ( sub_43EE15_player_has_item(0x20Bu, pPlayer4, 1) ) - byte_5111F6[6] = 1; - if ( sub_43EE15_player_has_item(0x214u, pPlayer4, 1) ) - byte_5111F6[7] = 1; - if ( sub_43EE15_player_has_item(0x220u, pPlayer4, 1) ) - byte_5111F6[8] = 1; - if ( sub_43EE15_player_has_item(0x20Cu, pPlayer4, 1) ) - byte_5111F6[9] = 1; - if ( sub_43EE15_player_has_item(0x217u, pPlayer4, 1) ) - byte_5111F6[10] = 1; - if ( sub_43EE15_player_has_item(0x20Du, pPlayer4, 1) ) - byte_5111F6[11] = 1; - if ( sub_43EE15_player_has_item(0x212u, pPlayer4, 1) ) - byte_5111F6[12] = 1; - if ( sub_43EE15_player_has_item(0x223u, pPlayer4, 1) ) - byte_5111F6[13] = 1; - if ( sub_43EE15_player_has_item(0x224u, pPlayer4, 1) ) - byte_5111F6[14] = 1; - if ( sub_43EE15_player_has_item(0x226u, pPlayer4, 1) ) - byte_5111F6[15] = 1; - ++pPlayer4; - } - while ( (signed int)pPlayer4 < (signed int)pParty->pHirelings ); - v15 = &stru_511698.field_2C; - v35 = (char *)&stru_511718.field_18; - do - { - v16 = 0; - v39 = (unsigned int *)(v35 - 24); - do - { - _43C91D_FormItemTextureFilename(pContainer, v16 + 100, v14, 0); - v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - ++v16; - v18 = v39; - ++v39; - *v18 = v17; - } - while ( v16 < 5 ); - _43C91D_FormItemTextureFilename(pContainer, 535, v14, 0); - v31 = 0; - v19 = (unsigned int *)((char *)v15 - 44); - *(int *)v35 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - do - { - _43C91D_FormItemTextureFilename(pContainer, v31++ + 89, v14, 0); - *v19 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - ++v19; - } - while ( v31 < 11 ); - _43C91D_FormItemTextureFilename(pContainer, 521, v14, 0); - v15->field_0 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 522, v14, 0); - v15->field_4 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 523, v14, 0); - v15->field_8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 532, v14, 0); - v15->field_C = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 544, v14, 0); - v15->field_10 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + + memset(byte_5111F6, 0, 16); + for (uint i = 0; i < 4; ++i) + { + auto player = pParty->pPlayers + i; + + if (sub_43EE15_player_has_item(ITEM_ARTICACT_GOVERNONS_ARMOR, player, 1)) byte_5111F6[0] = 1; + if (sub_43EE15_player_has_item(ITEM_ARTIFACT_YORUBA, player, 1)) byte_5111F6[1] = 1; + if (sub_43EE15_player_has_item(ITEM_RELIC_HARECS_LEATHER, player, 1)) byte_5111F6[2] = 1; + if (sub_43EE15_player_has_item(ITEM_ARTIFACT_LEAGUE_BOOTS, player, 1)) byte_5111F6[3] = 1; + if (sub_43EE15_player_has_item(ITEM_RELIC_TALEDONS_HELM, player, 1)) byte_5111F6[4] = 1; + if (sub_43EE15_player_has_item(ITEM_RELIC_SCHOLARS_CAP, player, 1)) byte_5111F6[5] = 1; + if (sub_43EE15_player_has_item(ITEM_RELIC_PHYNAXIAN_CROWN, player, 1)) byte_5111F6[6] = 1; + if (sub_43EE15_player_has_item(ITEM_ARTIFACT_MINDS_EYE, player, 1)) byte_5111F6[7] = 1; + if (sub_43EE15_player_has_item(ITEM_RARE_SHADOWS_MASK, player, 1)) byte_5111F6[8] = 1; + if (sub_43EE15_player_has_item(ITEM_RILIC_TITANS_BELT, player, 1)) byte_5111F6[9] = 1; + if (sub_43EE15_player_has_item(ITEM_ARTIFAT_HEROS_BELT, player, 1)) byte_5111F6[10] = 1; + if (sub_43EE15_player_has_item(ITEM_RELIC_TWILIGHT, player, 1)) byte_5111F6[11] = 1; + if (sub_43EE15_player_has_item(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, player, 1)) byte_5111F6[12] = 1; + if (sub_43EE15_player_has_item(ITEM_RARE_SUN_CLOAK, player, 1)) byte_5111F6[13] = 1; + if (sub_43EE15_player_has_item(ITEM_RARE_MOON_CLOAK, player, 1)) byte_5111F6[14] = 1; + if (sub_43EE15_player_has_item(ITEM_RARE_VAMPIRES_CAPE, player, 1)) byte_5111F6[15] = 1; + if (sub_43EE15_player_has_item(ITEM_ELVEN_CHAINMAIL, player, 1)) byte_5111F6[16] = 1; + } + + //v14 = 1; + //v15 = &stru_511698.field_2C; + //v35 = (char *)&stru_511718.field_18; + for (uint i = 0; i < 2; ++i) + { + //v16 = 0; + //v39 = (unsigned int *)(v35 - 24); + for (uint j = 0; j < 5; ++j) + { + _43C91D_FormItemTextureFilename(pContainer, j + 100, i + 1, 0); + //v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + //++v16; + //v18 = v39; + //++v39; + //*v18 = v17; + stru_511718[i].texids[j] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + } + //while ( v16 < 5 ); + + //*(int *)v35 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + _43C91D_FormItemTextureFilename(pContainer, 535, i + 1, 0); + stru_511718[i].texid2 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + + //v31 = 0; + //v19 = (unsigned int *)((char *)v15 - 44); + for (uint j = 0; j < 11; ++j) + { + _43C91D_FormItemTextureFilename(pContainer, j + 89, i + 1, 0); + //*v19 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + //++v19; + stru_511698[i].texids[j] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + } + //while ( v31 < 11 ); + + _43C91D_FormItemTextureFilename(pContainer, 521, i + 1, 0); + stru_511698[i].texid1 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + _43C91D_FormItemTextureFilename(pContainer, 522, i + 1, 0); + stru_511698[i].texid2 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + _43C91D_FormItemTextureFilename(pContainer, 523, i + 1, 0); + stru_511698[i].texid3 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + _43C91D_FormItemTextureFilename(pContainer, 532, i + 1, 0); + stru_511698[i].texid4 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + _43C91D_FormItemTextureFilename(pContainer, 544, i + 1, 0); + stru_511698[i].texid5 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); if ( _43ED6F_check_party_races(true) ) papredoll_dbrds[11] = pIcons_LOD->LoadTexture("item092v3", TEXTURE_16BIT_PALETTE); - v35 += 28; - ++v14; - ++v15; - } - while ( v14 - 1 < 2 ); + //v35 += 28; + //++v14; + //++v15; + } + //while ( v14 - 1 < 2 ); + v43 = 0; - v20 = 1; + //v20 = 1; v40 = &dword_511638[0][5]; v21 = (int)paperdoll_array_511290[0][13]; - v41 = (unsigned int *)&stru_511718.texid1; - do - { - if ( sub_43EDB9_get_some_race_sex_relation_2(v20 - 1) ) - { - _43C91D_FormItemTextureFilename(pContainer, 524, v20, 0); + //v41 = (unsigned int *)&stru_511718.texid1; + for (uint i = 0; i < 4; ++i) + { + if ( sub_43EDB9_get_some_race_sex_relation_2(i) ) + { + _43C91D_FormItemTextureFilename(pContainer, 524, i + 1, 0); v32 = 66; - *v41 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + stru_511718[i].texid1 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); v36 = v21 - 152; do { - _43C91D_FormItemTextureFilename(pContainer, v32, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, v32, i + 1, 0); *(int *)(v36 - 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, v32, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, v32, i + 1, 1); *(int *)v36 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, v32, v20, 2); + _43C91D_FormItemTextureFilename(pContainer, v32, i + 1, 2); v22 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); v23 = v36; v36 += 12; @@ -6480,35 +6466,35 @@ *(int *)(v23 + 4) = v22; } while ( v32 - 66 < 13 ); - _43C91D_FormItemTextureFilename(pContainer, 516, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 516, i + 1, 0); *(int *)v21 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 516, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, 516, i + 1, 1); *(int *)(v21 + 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 516, v20, 2); + _43C91D_FormItemTextureFilename(pContainer, 516, i + 1, 2); *(int *)(v21 + 8) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 505, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 505, i + 1, 0); *(int *)(v21 + 12) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 505, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, 505, i + 1, 1); *(int *)(v21 + 16) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 505, v20, 2); + _43C91D_FormItemTextureFilename(pContainer, 505, i + 1, 2); *(int *)(v21 + 20) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 504, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 504, i + 1, 0); *(int *)(v21 + 24) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 504, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, 504, i + 1, 1); *(int *)(v21 + 28) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 504, v20, 2); + _43C91D_FormItemTextureFilename(pContainer, 504, i + 1, 2); *(int *)(v21 + 32) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 533, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 533, i + 1, 0); *(int *)(v21 + 36) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 533, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, 533, i + 1, 1); *(int *)(v21 + 40) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 533, v20, 2); + _43C91D_FormItemTextureFilename(pContainer, 533, i + 1, 2); *(int *)(v21 + 44) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); v33 = 0; v37 = (int)(v40 - 5); do { - _43C91D_FormItemTextureFilename(pContainer, v33 + 115, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, v33 + 115, i + 1, 0); v24 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); ++v33; v25 = v37; @@ -6516,16 +6502,16 @@ *(int *)v25 = v24; } while ( v33 < 5 ); - _43C91D_FormItemTextureFilename(pContainer, 512, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 512, i + 1, 0); v26 = v43; v38 = 105; v34 = v43; *v40 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); do { - _43C91D_FormItemTextureFilename(pContainer, v38, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, v38, i + 1, 0); *(int *)((char *)paperdoll_array_511828 + v34) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, v38, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, v38, i + 1, 1); v27 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); v28 = v34; v34 += 4; @@ -6533,40 +6519,40 @@ *(int *)((char *)dword_511788 + v28) = v27; } while ( v38 - 105 < 5 ); - _43C91D_FormItemTextureFilename(pContainer, 525, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 525, i + 1, 0); *(int *)((char *)&paperdoll_array_511828[0][5] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 530, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 530, i + 1, 0); *(int *)((char *)&paperdoll_array_511828[0][6] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 547, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 547, i + 1, 0); *(int *)((char *)&paperdoll_array_511828[0][7] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 548, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 548, i + 1, 0); *(int *)((char *)&paperdoll_array_511828[0][8] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 550, v20, 0); + _43C91D_FormItemTextureFilename(pContainer, 550, i + 1, 0); *(int *)((char *)&paperdoll_array_511828[0][9] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 525, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, 525, i + 1, 1); *(int *)((char *)&dword_51179C + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 530, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, 530, i + 1, 1); *(int *)((char *)&dword_5117A0 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 547, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, 547, i + 1, 1); *(int *)((char *)&dword_5117A4 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 548, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, 548, i + 1, 1); *(int *)((char *)&dword_5117A8 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - _43C91D_FormItemTextureFilename(pContainer, 550, v20, 1); + _43C91D_FormItemTextureFilename(pContainer, 550, i + 1, 1); *(int *)((char *)&dword_5117AC + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); } else { v26 = v43; } - v41 += 7; + //v41 += 7; v40 += 6; v21 += 204; - ++v20; - result = v20 - 1; + //++v20; + //result = v20 - 1; v43 = v26 + 40; } - while ( v20 - 1 < 4 ); - return result; + //while ( v20 - 1 < 4 ); + //return result; } @@ -7292,9 +7278,9 @@ a2f = pPaperdoll_BodyX + paperdoll_Belt[0][v74][0]; a3f = pPaperdoll_BodyY + paperdoll_Belt[0][v74][1]; if ( IsDwarf != 1 || v73 == 5 ) - v75 = stru_511718.texids[v74]; + v75 = stru_511718[pBodyComplection].texids[v73]; else - v75 = stru_511718.texids[v73 + 7 * (pBodyComplection - 2)]; + v75 = stru_511718[pBodyComplection - 2].texids[v73]; v76 = *(int *)&pPlayer->field_1F5[36 * v71 + 15]; if ( !(*(int *)&pPlayer->field_1F5[36 * v71 + 15] & 0xF0) ) { @@ -7498,7 +7484,7 @@ a2j = pPaperdoll_BodyX + dword_4E58D0[v126]; a3i = pPaperdoll_BodyY + dword_4E58D4[v126]; if ( IsDwarf != 1 || *(int *)v124 != 92 ) - v127 = stru_511698.texids[v125 + 16 * pSex]; + v127 = stru_511698[0].texids[v125 + 16 * pSex]; else v127 = papredoll_dbrds[11]; v128 = *(int *)(v124 + 20); @@ -9061,7 +9047,7 @@ //LABEL_15: pSex = 1; return pSex;*/ - for (int i = 1; i <= 4; &pPlayers[i]) + for (uint i = 1; i <= 4; pPlayers[i]) { pRace = pPlayers[i]->GetRace(); pSex = pPlayers[i]->GetSexByVoice(); @@ -10857,10 +10843,10 @@ else { v10 = v2; - v63 = pLayingItems[v10].vPosition.x; - v64 = pLayingItems[v10].vPosition.y; - v11 = pLayingItems[v10].vPosition.z; - v7 = pLayingItems[v10].uSectorID; + v63 = pSpriteObjects[v10].vPosition.x; + v64 = pSpriteObjects[v10].vPosition.y; + v11 = pSpriteObjects[v10].vPosition.z; + v7 = pSpriteObjects[v10].uSectorID; v65 = v11; } v66 = v7; @@ -10906,10 +10892,10 @@ else { v22 = v12; - v18 = pLayingItems[v22].vPosition.x; - v17 = pLayingItems[v22].vPosition.z; - v60 = pLayingItems[v22].vPosition.y; - v19 = pLayingItems[v22].uSectorID; + v18 = pSpriteObjects[v22].vPosition.x; + v17 = pSpriteObjects[v22].vPosition.z; + v60 = pSpriteObjects[v22].vPosition.y; + v19 = pSpriteObjects[v22].uSectorID; } v62 = v19; v23 = v18 - v63; @@ -12129,15 +12115,15 @@ } //----- (00408896) -------------------------------------------------------- -void InitializeLayingItems() -{ - for (uint i = 0; i < uNumLayingItems; ++i) - { - auto item = pLayingItems + i; - - if (item->uItemType && - (item->uSoundID & 8 || pObjectList->pObjects[item->uItemType].uFlags & 0x10)) - LayingItem::OnItemPickup(i); +void InitializeSpriteObjects() +{ + for (uint i = 0; i < uNumSpriteObjects; ++i) + { + auto item = pSpriteObjects + i; + + if (item->uType && + (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10)) + SpriteObject::OnInteraction(i); } for (uint i = 0; i < 100; ++i) @@ -13138,7 +13124,7 @@ pRenderer->DrawTextureTransparent( 0x1D7u, 0x1BDu, - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); v6.uFrameX = 8; v6.uFrameY = 8; v6.uFrameWidth = 460; @@ -13615,7 +13601,7 @@ v0 = pViewport->uViewportX + 398; } pRenderer->DrawTextureTransparent(v0, v11, v13); - if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 ) + if ( dword_506544 || dword_506528 + awards_count >= awards_count2 ) { v14 = pTex_tab_an_7a__zoot_off; v12 = pViewport->uViewportY + 38; @@ -13630,7 +13616,7 @@ pRenderer->DrawTextureTransparent(v1, v12, v14); if ( !byte_5C6D50[dword_506528] ) { - v2 = pStru179.field_0[dword_506528]; + v2 = achievedAwardsIndex[dword_506528]; a1.uFrameWidth = 460; a1.uFrameX = 8; a1.uFrameY = 8; @@ -13649,12 +13635,12 @@ a1.uFrameZ = 407; a1.uFrameHeight = v4 * 264 / v4; a1.uFrameW = a1.uFrameHeight + 69; - if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 ) + if ( dword_506544 && dword_506528 + awards_count < awards_count2 ) { pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0); v5 = dword_50651C++; - dword_506528 += dword_506520; - byte_506130[v5] = dword_506520; + dword_506528 += awards_count; + byte_506130[v5] = awards_count; } if ( dword_506548 && dword_50651C ) { @@ -13662,15 +13648,15 @@ --dword_50651C; dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; } - if ( !dword_506520 || dword_506528 < 1 ) + if ( !awards_count || dword_506528 < 1 ) { dword_506528 = 0; dword_50651C = 0; } dword_506544 = 0; - v6 = pStru179.field_0[dword_506528]; + v6 = achievedAwardsIndex[dword_506528]; dword_506548 = 0; - dword_506520 = 0; + awards_count = 0; //v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6); v7 = (int)pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6); v8 = BuilDialogueString( @@ -13684,7 +13670,7 @@ { v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]); LOBYTE(v8) = a1.DrawText(pAutonoteFont, 1, 0, 0, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, 0); - ++dword_506520; + ++awards_count; } return (char)v8; } @@ -13721,7 +13707,7 @@ v0 = pViewport->uViewportX + 398; } pRenderer->DrawTextureTransparent(v0, v8, v10); - if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 ) + if ( dword_506544 || dword_506528 + awards_count >= awards_count2 ) { v11 = pTex_tab_an_7a__zoot_off; v9 = pViewport->uViewportY + 38; @@ -13747,12 +13733,12 @@ a1.uFrameHeight = 264; a1.uFrameZ = 407; a1.uFrameW = 333; - if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 ) + if ( dword_506544 && dword_506528 + awards_count < awards_count2 ) { pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0); v2 = dword_50651C++; - dword_506528 += dword_506520; - byte_506130[v2] = dword_506520; + dword_506528 += awards_count; + byte_506130[v2] = awards_count; } if ( dword_506548 && dword_50651C ) { @@ -13760,7 +13746,7 @@ --dword_50651C; dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; } - if ( !dword_506520 || (v3 = dword_506528, dword_506528 < 1) ) + if ( !awards_count || (v3 = dword_506528, dword_506528 < 1) ) { v3 = 0; dword_50651C = 0; @@ -13768,11 +13754,11 @@ } dword_506544 = 0; dword_506548 = 0; - dword_506520 = 0; - while ( v3 < dword_506524 ) - { - v4 = pStru179.field_0[v3]; - ++dword_506520; + awards_count = 0; + while ( v3 < awards_count2 ) + { + v4 = achievedAwardsIndex[v3]; + ++awards_count; v5 = pQuestTable[v4-1];//(&dword_722F10)[4 * v4]; a1.DrawText(pAutonoteFont, 1, 0, 0, pQuestTable[v4-1], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0); v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0); @@ -13839,7 +13825,7 @@ v0 = pViewport->uViewportX + 398; } pRenderer->DrawTextureTransparent(v0, v17, v24); - if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 ) + if ( dword_506544 || dword_506528 + awards_count >= awards_count2 ) { v25 = pTex_tab_an_7a__zoot_off; v18 = pViewport->uViewportY + 38; @@ -14013,10 +13999,10 @@ a1.uFrameW = 333; if ( v31 ) { - dword_506524 = 0; + awards_count2 = 0; dword_506528 = 0; dword_50651C = 0; - dword_506520 = 0; + awards_count = 0; v8 = 0; do { @@ -14029,25 +14015,25 @@ { if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 ) { - v9 = dword_506520++; - pStru179.field_0[v9] = (signed __int16)v8; + v9 = awards_count++; + achievedAwardsIndex[v9] = (signed __int16)v8; } } } ++v8; } while ( v8 < 196 ); - dword_506524 = dword_506520; + awards_count2 = awards_count; } else { if ( dword_506544 ) { - v10 = dword_506520 + dword_506528; - if ( dword_506520 + dword_506528 < dword_506524 ) + v10 = awards_count + dword_506528; + if ( awards_count + dword_506528 < awards_count2 ) { v11 = dword_50651C++; - byte_506130[v11] = dword_506520; + byte_506130[v11] = awards_count; dword_506528 = v10; pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0); } @@ -14058,7 +14044,7 @@ dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0); } - if ( !dword_506520 || dword_506528 < 1 ) + if ( !awards_count || dword_506528 < 1 ) { dword_506528 = 0; dword_50651C = 0; @@ -14068,16 +14054,16 @@ dword_50652C = 0; dword_506544 = 0; dword_506548 = 0; - dword_506520 = 0; + awards_count = 0; dword_506530 = 0; dword_506534 = 0; dword_506538 = 0; dword_50653C = 0; dword_506540 = 0; - while ( v12 < dword_506524 ) - { - v13 = pStru179.field_0[v12]; - ++dword_506520; + while ( v12 < awards_count2 ) + { + v13 = achievedAwardsIndex[v12]; + ++awards_count; //v14 = (&dword_723718_autonote_related)[8 * v13]; v14 = pAutonoteTxt[v13-1].pText; //a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0); @@ -14245,7 +14231,7 @@ enum WindowType pWindowType; // esi@1 pWindowType = (enum WindowType)uBook; - pRenderer->DrawTextureIndexed(471u, 445u, (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); + pRenderer->DrawTextureIndexed(471u, 445u, (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); switch ( pWindowType ) { case WINDOW_Lloyd: // 177 @@ -15511,7 +15497,7 @@ draw_leather(); CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); } } } @@ -15532,10 +15518,7 @@ { if ( (signed int)v10 < 53 ) { - - pParty->field_3C._shop_ban_times[(signed int)v10] = 0; - } continue; } @@ -16269,7 +16252,7 @@ { if ( pCurrentScreen == SCREEN_CHEST ) { - __debugbreak(); + // __debugbreak(); if ( !pPlayers[uActiveCharacter]->CanAct() ) { sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427],//%s %s @@ -16289,7 +16272,7 @@ v9 = pX + pSRZBufferLineOffsets[pY]; if ( !(pRenderer->pActiveZBuffer[v9] & 0xFFFF) ) goto LABEL_132; - v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime + v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); } else @@ -16439,9 +16422,9 @@ goto LABEL_132; } v7 = v6 >> 3; - if ( pObjectList->pObjects[pLayingItems[v7].uObjectDescID].uFlags & 0x10 ) + if ( pObjectList->pObjects[pSpriteObjects[v7].uObjectDescID].uFlags & 0x10 ) goto LABEL_132; - v8 = &pLayingItems[v7].stru_24; + v8 = &pSpriteObjects[v7].stru_24; } GameUI_DrawItemInfo(v8); goto LABEL_132; @@ -17670,88 +17653,45 @@ } //----- (00419100) -------------------------------------------------------- -int __cdecl sub_419100() -{ - Player *pPlayer; // esi@1 - int v1; // ebx@1 - unsigned __int8 *v2; // esi@1 - int v3; // eax@4 - int result; // eax@6 - int v5; // esi@6 - unsigned __int8 v6; // zf@6 - unsigned __int8 v7; // sf@6 - int v8; // edx@7 - int v9; // ecx@7 - unsigned __int8 v10; // of@7 - stru179 *v11; // edi@9 - int v12; // edx@11 - char *v13; // [sp+Ch] [bp-8h]@2 - signed int v14; // [sp+Ch] [bp-8h]@9 - int i; // [sp+10h] [bp-4h]@10 - - pPlayer = pPlayers[uActiveCharacter]; - memset(&pStru179, 0, 0xFA0u); - memset(pTmpBuf2, 0, 0x7D0u); - v1 = 0; - dword_506544 = 0; - dword_506548 = 0; - dword_506520 = 0; - dword_50651C = 0; - dword_506528 = 0; - v2 = (unsigned __int8 *)pPlayer->_guilds_member_bits; - do - { - v13 = (char *)pAwards[v1].pText;//dword_723E80_award_related[2 * v1]; - if ( (unsigned __int16)_449B57_test_bit(v2, v1) && v13 ) - { - v3 = dword_506520++; - pStru179.field_0[v3] = v1; - } - ++v1; - } - while ( v1 < 105 ); - result = dword_506520; - v5 = 0; - v6 = dword_506520 == 0; - v7 = dword_506520 < 0; - dword_506524 = dword_506520; - dword_506520 = 0; - if ( !(v7 | v6) ) - { - do - { - v8 = rand() % 16; - result = dword_506524; - v9 = dword_506524 + v5++; - v10 = v5 > dword_506524;//__OFSUB__(v5, dword_506524); - v7 = v5 - dword_506524 < 0; - pStru179.field_0[v9] = v8; - } - while ( v7 ^ v10 ); - if ( result > 0 ) - { - v14 = 1; - v11 = &pStru179; - do - { - for ( i = v14; i < result; ++i ) - { - v12 = pStru179.field_0[i]; - //if ( dword_723E84[2 * v12] < dword_723E84[2 * v11->field_0[0]] ) - if(pAwards[v12-1].uSort < pAwards[v11->field_0[0]].uSort) - { - pStru179.field_0[i] = v11->field_0[0]; - v11->field_0[0] = v12; - } - } - ++v14; - v11 = (stru179 *)((char *)v11 + 4); - } - while ( v14 - 1 < result ); - } - } - return result; -} +void FillAwardsData() + { + Player *pPlayer; // esi@1 + + pPlayer = pPlayers[uActiveCharacter]; + memset(&achievedAwardsIndex, 0, 4000); + memset(pTmpBuf2, 0, 0x7D0u); + dword_506544 = 0; + dword_506548 = 0; + awards_count = 0; + dword_50651C = 0; + dword_506528 = 0; + for(int i=0; i<105; ++i) + { + if ( _449B57_test_bit((unsigned char*)&pPlayer->_guilds_member_bits, i) && pAwards[i].pText ) + achievedAwardsIndex[awards_count++] = i; + } + awards_count2 = awards_count; + awards_count = 0; + //sort awards index + if ( awards_count2>0 ) + { + for(int i=0; ispellnum].field_0; - if (a1.uItemType) + a1.uType = stru_4E3ACC[v3->spellnum].field_0; + if (a1.uType) { if ( (a2 & 7) == OBJECT_Actor) { @@ -3460,8 +3459,9 @@ switch ( v3->spellnum ) { + case SPELL_101: + assert(false && "Unknown spell effect #101 (prolly flaming bow arrow"); case SPELL_BOW_ARROW: - case SPELL_101: v17 = pPlayer; _this = (ItemGen *)1; if ( (signed int)SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 ) @@ -3472,7 +3472,7 @@ a1.field_4C = v2; a1.field_48 = v18; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); if ( v17->WearsItem(510, 2) ) a1.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u); a1.vPosition.x = pParty->vPosition.x; @@ -3513,7 +3513,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v723; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = pParty->vPosition.x; a1.vPosition.y = pParty->vPosition.y; a1.uAttributes = 0; @@ -3565,7 +3565,7 @@ pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * v2 * 4.2666669), v731, amount, 0, 0); goto LABEL_1056; - case 7: + case SPELL_FIRE_FIRE_SPIKE: v29 = v12 - 2; if ( v29 ) { @@ -3586,14 +3586,19 @@ { amount = 5; } - v31 = v3->uPlayerID; + //v31 = v3->uPlayerID; + //v32 = 8 * v31; + //LOBYTE(v32) = v32 | OBJECT_Player; + + //if ( (signed int)uNumSpriteObjects > 0 ) HIDWORD(v733) = 0; - v32 = 8 * v31; - LOBYTE(v32) = v32 | OBJECT_Player; - if ( (signed int)uNumLayingItems > 0 ) - { - v33 = (char *)&pLayingItems[0].field_48; - v730 = uNumLayingItems; + for (uint i = 0; i < uNumSpriteObjects; ++i) + { + auto object = pSpriteObjects + i; + if (object->uType && object->field_48 == 7 && object->field_58_pid == 8 * (int)v3->uPlayerID | OBJECT_Player) + ++HIDWORD(v733); + /*v33 = (char *)&pSpriteObjects[0].field_48; + v730 = uNumSpriteObjects; do { if ( *((short *)v33 - 36) && *(int *)v33 == 7 && *((int *)v33 + 4) == v32 ) @@ -3601,17 +3606,18 @@ v33 += 112; --v730; } - while ( v730 ); + while ( v730 );*/ } if ( SHIDWORD(v733) > amount ) goto LABEL_200; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; + a1.stru_24.Reset(); a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; a1.uAttributes = 0; @@ -3648,7 +3654,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -3687,7 +3693,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -3724,7 +3730,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = *(short *)(HIDWORD(v733) + 142); a1.vPosition.y = *(short *)(HIDWORD(v733) + 144); v48 = *(short *)(HIDWORD(v733) + 138); @@ -3769,7 +3775,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; a1.uAttributes = 0; @@ -3801,7 +3807,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; a1.vPosition.y = pParty->vPosition.y; v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; @@ -3908,14 +3914,14 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - v60 = pObjectList->ObjectIDByItemID(a1.uItemType); + v60 = pObjectList->ObjectIDByItemID(a1.uType); v61 = a2 >> 3; goto LABEL_1086; case 92: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; a1.stru_24.Reset(); - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = pParty->vPosition.x; a1.vPosition.y = pParty->vPosition.y; a1.uAttributes = 0; @@ -4310,7 +4316,7 @@ a1.field_48 = *(int *)HIDWORD(v733); a1.field_4C = v723; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -4492,7 +4498,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.vPosition.x = uRequiredMana; a1.vPosition.y = LODWORD(v727); @@ -4539,7 +4545,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -4662,7 +4668,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; a1.uAttributes = 0; @@ -4856,7 +4862,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.vPosition.x = LODWORD(v718); a1.vPosition.y = v713; @@ -4945,7 +4951,7 @@ a1.field_48 = v3->spellnum; a1.field_50 = v731; a1.field_4C = v2; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; @@ -4983,7 +4989,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; a1.uAttributes = 0; @@ -5560,7 +5566,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; a1.uAttributes = 0; @@ -5588,12 +5594,12 @@ goto LABEL_200; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - a1.uItemType = 4090; + a1.uType = 4090; a1.stru_24.Reset(); a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = pParty->vPosition.x; a1.vPosition.y = pParty->vPosition.y; a1.uAttributes = 0; @@ -5780,12 +5786,12 @@ goto play_sound_and_continue; v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096); pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u); - ++a1.uItemType; + ++a1.uType; a1.stru_24.Reset(); a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -6120,7 +6126,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = *(short *)(v730 + 142); a1.vPosition.y = *(short *)(v730 + 144); v676 = *(short *)(v730 + 138); @@ -6166,7 +6172,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - v60 = pObjectList->ObjectIDByItemID(a1.uItemType); + v60 = pObjectList->ObjectIDByItemID(a1.uType); v61 = v426; goto LABEL_1086; case 66: @@ -6192,7 +6198,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - v60 = pObjectList->ObjectIDByItemID(a1.uItemType); + v60 = pObjectList->ObjectIDByItemID(a1.uType); v61 = v427; goto LABEL_1086; case 63: @@ -6206,12 +6212,12 @@ goto play_sound_and_continue; v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096); pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u); - ++a1.uItemType; + ++a1.uType; a1.stru_24.Reset(); a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -6300,7 +6306,7 @@ v445 = a2 >> 3; if ( (a2 & 7) == OBJECT_Item) { - v449 = (char *)&pLayingItems[v445].stru_24; + v449 = (char *)&pSpriteObjects[v445].stru_24; v450 = *(int *)v449; if ( pItemsTable->pItems[v450].uEquipType == 18 ) { @@ -6311,10 +6317,10 @@ { sprintf(pTmpBuf2, (char*)pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName); ShowStatusBarString(pTmpBuf2, 2u); - if ( !pParty->AddItem(&pLayingItems[v445].stru_24) ) - pParty->SetHoldingItem(&pLayingItems[v445].stru_24); + if ( !pParty->AddItem(&pSpriteObjects[v445].stru_24) ) + pParty->SetHoldingItem(&pSpriteObjects[v445].stru_24); } - LayingItem::OnItemPickup(v445); + SpriteObject::OnInteraction(v445); } else { @@ -6349,9 +6355,9 @@ } if ( v447->IsInteractive() ) { - GlobalEventInfo = (int)v447; + activeLevelDecoration = v447; EventProcessor(stru_5E4C90._decor_events[v447->_idx_in_stru123 - 75] + 380, 0, 1); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; } } } @@ -6626,7 +6632,7 @@ pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u); v505 = sub_46A6AC((int)dword_50BF30, 100, 4096); - ++a1.uItemType; + ++a1.uType; HIDWORD(v733) = v505; v690 = 0; v689 = 0; @@ -6635,7 +6641,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -6789,7 +6795,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; v531 = sub_46A6AC((int)dword_50BF30, 100, 4096); - ++a1.uItemType; + ++a1.uType; v726 = (Player *)v531; v696 = 0; v695 = 0; @@ -6798,7 +6804,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -7014,12 +7020,12 @@ v721 = v578; if ( *(short *)(v578 + 40) > 0 || (v579 = *(short *)(v578 + 176), v579 != 5) && v579 != 4 ) goto LABEL_200; - ++a1.uItemType; + ++a1.uType; a1.stru_24.Reset(); a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -7118,7 +7124,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = pParty->vPosition.x; a1.vPosition.y = pParty->vPosition.y; a1.uAttributes = 0; @@ -7192,7 +7198,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - v60 = pObjectList->ObjectIDByItemID(a1.uItemType); + v60 = pObjectList->ObjectIDByItemID(a1.uType); v61 = v599; LABEL_1086: v600 = pActors[v61].vPosition.y; @@ -7225,7 +7231,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; HIDWORD(v733) = 0; - memset(&pStru179, 0, 0xFA0u); + memset(&achievedAwardsIndex, 0, 4000); _this = 0; v605 = (char *)pParty->pHirelings; do @@ -7233,7 +7239,7 @@ if ( *(int *)v605) { v606 = HIDWORD(v733)++; - pStru179.field_0[v606] = (int)((char *)&_this->uItemID + 1); + achievedAwardsIndex[v606] = (int)((char *)&_this->uItemID + 1); } _this = (ItemGen *)((char *)_this + 1); v605 += 76; @@ -7340,7 +7346,7 @@ a1.field_48 = v3->spellnum; a1.field_4C = v2; a1.field_50 = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; @@ -8114,131 +8120,6 @@ return result; } -//----- (0042F5ED) -------------------------------------------------------- -int LayingItem::Create(int yaw, int pitch, int a4, int a5) -{ - LayingItem *v5; // eax@1 - signed int v6; // ebx@2 - char *v7; // ecx@2 - signed int result; // eax@6 - LayingItem *v9; // ebx@7 - int v10; // edx@11 - int v11; // edi@18 - __int16 v12; // ax@18 - int v13; // ST2C_4@20 - int v14; // eax@20 - int v15; // [sp-28h] [bp-38h]@14 - int v16; // [sp-24h] [bp-34h]@11 - Vec3_int_ v17; // [sp-20h] [bp-30h]@11 - int *v18; // [sp-14h] [bp-24h]@11 - int *v19; // [sp-10h] [bp-20h]@11 - int *v20; // [sp-Ch] [bp-1Ch]@11 - signed int v21; // [sp+8h] [bp-8h]@2 - int angle; // [sp+Ch] [bp-4h]@1 - int a4a; // [sp+1Ch] [bp+Ch]@20 - int a4b; // [sp+1Ch] [bp+Ch]@20 - int a5a; // [sp+20h] [bp+10h]@20 - - auto a1 = this; - angle = yaw; - v5 = a1; - if ( !a1->uObjectDescID ) - return -1; - v6 = 0; - v7 = (char *)&pLayingItems[0].uObjectDescID; - v21 = 0; - do - { - if ( !*(short *)v7 ) - break; - v7 += 112; - ++v6; - v21 = v6; - } - while ( (signed int)v7 < (signed int)((char *)&pObjectList->uNumObjects + 2) ); - if ( v6 >= 1000 ) - return -1; - *(int *)&v5->field_62[2] = v5->vPosition.x; - *(int *)&v5->field_62[6] = v5->vPosition.y; - v9 = &pLayingItems[v6]; - *(int *)&v5->field_62[10] = v5->vPosition.z; - memcpy(v9, v5, 0x70u); - if ( a5 == 1 ) - { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; - v17.z = v5->vPosition.z; - *(_QWORD *)&v17.x = *(_QWORD *)&v5->vPosition.x; - v16 = 0; - v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; - goto LABEL_16; - } - if ( a5 == 2 ) - { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; - v17.z = v5->vPosition.z; - *(_QWORD *)&v17.x = *(_QWORD *)&v5->vPosition.x; - v16 = 0; - v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; - goto LABEL_14; - } - if ( a5 == 3 ) - { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; - v17.z = v5->vPosition.z; - *(_QWORD *)&v17.x = *(_QWORD *)&v5->vPosition.x; - v16 = 0; - v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; -LABEL_14: - v15 = 8; -LABEL_17: - Vec3_int_::Rotate(v15, v10, v16, v17, v18, v19, v20); - goto LABEL_18; - } - if ( a5 == 4 ) - { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; - v17.z = v5->vPosition.z; - *(_QWORD *)&v17.x = *(_QWORD *)&v5->vPosition.x; - v16 = 0; - v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; -LABEL_16: - v15 = 24; - goto LABEL_17; - } -LABEL_18: - v11 = a4; - v12 = 0; - if ( a4 ) - { - a4a = stru_5C6E00->Cos(angle); - v13 = (unsigned __int64)(a4a * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - a4b = stru_5C6E00->Sin(angle); - a5a = (unsigned __int64)(a4b * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - v14 = stru_5C6E00->Sin(pitch); - v9->vVelocity.x = (unsigned int)(v13 * v11) >> 16; - v9->vVelocity.y = (unsigned int)(a5a * v11) >> 16; - v12 = (unsigned int)(v14 * v11) >> 16; - } - else - { - v9->vVelocity.y = 0; - v9->vVelocity.x = 0; - } - v9->vVelocity.z = v12; - result = v21; - if ( v21 >= (signed int)uNumLayingItems ) - uNumLayingItems = v21 + 1; - return result; -} - //----- (0042F7EB) -------------------------------------------------------- bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9) { @@ -8252,7 +8133,7 @@ int v16; // eax@18 int v17; // edi@20 int v18; // esi@20 - //LayingItem a1a; // [sp+Ch] [bp-78h]@1 + //SpriteObject a1a; // [sp+Ch] [bp-78h]@1 int v21; // [sp+7Ch] [bp-8h]@1 unsigned int v22; // [sp+80h] [bp-4h]@1 @@ -8260,8 +8141,8 @@ v21 = x; v22 = uSpriteID; - LayingItem a1a; // [sp+Ch] [bp-78h]@1 - //LayingItem::LayingItem(&a1a); + SpriteObject a1a; // [sp+Ch] [bp-78h]@1 + //SpriteObject::SpriteObject(&a1a); a1a.stru_24.Reset(); if ( a9 ) @@ -8274,7 +8155,7 @@ a1a.field_4C = 0; a1a.field_48 = 0; a1a.field_54 = 0; - a1a.uItemType = v9; + a1a.uType = v9; if ( (signed int)pObjectList->uNumObjects <= 0 ) { LABEL_7: @@ -8366,13 +8247,13 @@ unsigned __int16 v7; // ax@5 signed int v8; // eax@6 signed int v9; // eax@7 - //LayingItem a1; // [sp+Ch] [bp-70h]@1 + //SpriteObject a1; // [sp+Ch] [bp-70h]@1 v3 = x; v4 = y; - LayingItem a1; // [sp+Ch] [bp-70h]@1 - //LayingItem::LayingItem(&a1); + SpriteObject a1; // [sp+Ch] [bp-70h]@1 + //SpriteObject::SpriteObject(&a1); a1.stru_24.Reset(); v5 = 0; @@ -8380,7 +8261,7 @@ a1.field_4C = 0; a1.field_48 = 0; a1.field_54 = 0; - a1.uItemType = 800; + a1.uType = 800; if ( (signed int)pObjectList->uNumObjects <= 0 ) { LABEL_5: @@ -8418,18 +8299,18 @@ } //----- (0042FA22) -------------------------------------------------------- -LayingItem *__cdecl sub_42FA22_mess_with_laying_item_list() +SpriteObject *__cdecl sub_42FA22_mess_with_laying_item_list() { size_t v0; // edx@1 int v1; // ebp@1 - LayingItem *result; // eax@1 - LayingItem *v3; // ebx@1 + SpriteObject *result; // eax@1 + SpriteObject *v3; // ebx@1 v0 = 0; v1 = 0; - //result = (char *)&pLayingItems[0].uObjectDescID; - result = pLayingItems; - v3 = pLayingItems; + //result = (char *)&pSpriteObjects[0].uObjectDescID; + result = pSpriteObjects; + v3 = pSpriteObjects; do { if ( result->uObjectDescID ) @@ -8446,8 +8327,8 @@ ++v1; } //while ( (signed int)result < (signed int)((char *)&pObjectList->uNumObjects + 2) ); - while( result <= &pLayingItems[999] ); - uNumLayingItems = v0; + while( result <= &pSpriteObjects[999] ); + uNumSpriteObjects = v0; return result; } @@ -8461,14 +8342,14 @@ int v10; // eax@10 signed int result; // eax@11 __int16 v12; // ax@12 - //LayingItem a1a; // [sp+Ch] [bp-74h]@1 + //SpriteObject a1a; // [sp+Ch] [bp-74h]@1 int v14; // [sp+7Ch] [bp-4h]@1 v6 = a1; v7 = a2; - LayingItem a1a; // [sp+Ch] [bp-74h]@1 - //LayingItem::LayingItem(&a1a); - a1a.uItemType = 600; + SpriteObject a1a; // [sp+Ch] [bp-74h]@1 + //SpriteObject::SpriteObject(&a1a); + a1a.uType = 600; a1a.stru_24.Reset(); a1a.field_48 = 6; @@ -8483,7 +8364,7 @@ else { v8 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)a1a.uItemType != *(short *)v8 ) + while ( (short)a1a.uType != *(short *)v8 ) { ++v14; v8 += 56; diff -r cf366ba68de5 -r 1bd8758f50b8 mm7_data.cpp --- a/mm7_data.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/mm7_data.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -48,8 +48,8 @@ #include "stru279.h" stru279 stru_51076C; -#include "stru179.h" -stru179 pStru179; + +int achievedAwardsIndex[1000]; #include "stru123.h" stru123 stru_5E4C90; @@ -485,8 +485,8 @@ 0x83, 0xD8, 0x1D, 0xBA, 0x58, 0x77, 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, 0x7B, 0xD8, 0x23, 0xB8, 0x62, 0x77, 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, }; -stru332 stru_511698; -stru333 stru_511718; +stru332 stru_511698[2]; +stru333 stru_511718[4]; stru334 array_4E2940[26]; stru348 stru_4E1890[13]; @@ -686,10 +686,7 @@ char _4E2B21_buff_spell_tooltip_colors[80]; char byte_4E2B70[777]; // weak char byte_4E2BC8; // weak -int pChestSmthn1ByType[8] = {42, 18, 18, 42, 42, 42, 18, 42}; -int pChestSmthn2ByType[8] = {34, 30, 30, 34, 34, 34, 30, 34}; -int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; -int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; + char aSS[777]; // idb char ascii_4E2C54[6]; char ascii_4E2C5C[7]; @@ -1105,14 +1102,7 @@ char aEWorkMsdevMm_7[777]; // idb char aGammaControlNo[777]; // idb __int16 word_4E8152[11] = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30}; -char byte_4E8168[7][14]={ //byte_4E8178 - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - { 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, - { 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4}, - { 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5}, - { 2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6}, - { 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}}; + char aD3dTextureName[777]; // idb char aLogd3d_txt[777]; // idb char byte_4E8394[204] = @@ -1830,10 +1820,10 @@ int dword_506364; // weak Texture *dword_506404[12]; // weak Texture *dword_50640C[12]; // weak -unsigned int uTextureID_506438; +unsigned int uExitCancelTextureId; int dword_50651C; // weak -int dword_506520; // weak -int dword_506524; // weak +int awards_count; // weak +int awards_count2; // weak int dword_506528; // weak int dword_50652C; // weak int dword_506530; // weak @@ -1962,7 +1952,7 @@ char pStartingMapName[777]; // idb unsigned __int8 IsPlayerWearingWatersuit[5]; char byte_5111C0[54]; -char byte_5111F6[18]; +char byte_5111F6[16]; unsigned int papredoll_dbrds[16]; unsigned int papredoll_drhs[4]; unsigned int papredoll_dlhus[4]; @@ -2035,6 +2025,7 @@ int dword_5B65D0_dialogue_actor_npc_id; // weak int dword_5C3418; // weak int dword_5C341C; // weak +int _5C3420_pDecoration; char byte_5C3427[777]; // weak char GameUI_StatusBar_TimedString[200]; char pStatusBarString[200]; diff -r cf366ba68de5 -r 1bd8758f50b8 mm7_data.h --- a/mm7_data.h Mon Mar 04 09:22:29 2013 +0600 +++ b/mm7_data.h Mon Mar 04 09:22:38 2013 +0600 @@ -1,7 +1,7 @@ #pragma once #include #include "OSAPI.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "VectorTypes.h" typedef char _UNKNOWN; @@ -474,10 +474,7 @@ extern char _4E2B21_buff_spell_tooltip_colors[80]; extern char byte_4E2B70[]; // weak extern char byte_4E2BC8; // weak -extern int pChestSmthn1ByType[8]; -extern int pChestSmthn2ByType[8]; -extern int pChestWidthsByType[8]; -extern int pChestHeightsByType[8]; + extern char aSS[]; // idb extern char ascii_4E2C54[6]; extern char ascii_4E2C5C[7]; @@ -1005,7 +1002,7 @@ extern __int16 word_4F0576[]; // weak //extern __int16 word_4F05AE[]; // weak -extern char uItemsAmountPerShopType[]; // weak + //extern __int16 word_4F063E[290]; //extern __int16 word_4F06D8[22]; extern int guild_mambership_flags[32]; @@ -1153,10 +1150,10 @@ extern char byte_506360; // weak extern int dword_506364; // weak extern Texture *dword_50640C[]; // weak -extern unsigned int uTextureID_506438; +extern unsigned int uExitCancelTextureId; extern int dword_50651C; // weak -extern int dword_506520; // weak -extern int dword_506524; // weak +extern int awards_count; // weak +extern int awards_count2; // weak extern int dword_506528; // weak extern int dword_50652C; // weak extern int dword_506530; // weak @@ -1285,7 +1282,7 @@ extern char pStartingMapName[]; // idb extern unsigned __int8 IsPlayerWearingWatersuit[5]; extern char byte_5111C0[54]; -extern char byte_5111F6[18]; +extern char byte_5111F6[]; extern unsigned int papredoll_dbrds[16]; extern unsigned int papredoll_drhs[4]; extern unsigned int papredoll_dlhus[4]; @@ -1358,6 +1355,7 @@ extern int dword_5B65D0_dialogue_actor_npc_id; // weak extern int dword_5C3418; // weak extern int dword_5C341C; // weak +extern int _5C3420_pDecoration; extern char byte_5C3427[]; // weak extern char GameUI_StatusBar_TimedString[200]; extern char pStatusBarString[200]; @@ -1409,7 +1407,7 @@ extern char *pClassTXT_Raw; extern char *pStatsTXT_Raw; extern char *pSkillDescTXT_Raw; - +extern int achievedAwardsIndex[1000]; extern struct FactionTable *pFactionTable; extern char byte_5C8D1A[]; // weak @@ -1760,7 +1758,7 @@ bool __fastcall sub_4077F1(int a1, int a2, int a3, struct ODMFace *a4, struct BSPVertexBuffer *a5); bool __fastcall sub_407A1C(int x, int z, int y, struct Vec3_int_ v); // idb void InitializeActors(); -void InitializeLayingItems(); +void InitializeSpriteObjects(); int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6); unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors); unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID); @@ -1869,13 +1867,13 @@ char __cdecl CharacterUI_SkillsTab_ShowHint(); char __cdecl CharacterUI_StatsTab_ShowHint(); char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID); // idb -int __cdecl sub_419100(); +void FillAwardsData(); void __cdecl sub_419220(); void __cdecl sub_419379(); void __cdecl CharacterUI_SkillScreen_Draw(); void __cdecl sub_4196A0(); char __fastcall CharacterUI_SkillsTab_Draw(unsigned int uPlayerID); // idb -unsigned int __fastcall CharacterUI_AwardsTab_Draw(unsigned int uPlayerID); // idb +void CharacterUI_AwardsTab_Draw(unsigned int uPlayerID); // idb unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels); void __fastcall CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2); void __cdecl draw_leather(); @@ -1903,7 +1901,7 @@ void __cdecl RestUI_Initialize(); void __cdecl RestUI_Draw(); // idb void __cdecl sub_42038D(); -void __fastcall sub_420B13(int a1, int a2); + void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); // idb void __cdecl sub_420E01(); void __cdecl GameUI_WritePointedObjectStatusString(); @@ -1939,7 +1937,7 @@ signed int __cdecl sub_42F4DA(); bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9); void __fastcall sub_42F960_create_object(int x, int y, int z); // idb -LayingItem *__cdecl sub_42FA22_mess_with_laying_item_list(); +SpriteObject *__cdecl sub_42FA22_mess_with_laying_item_list(); signed int __fastcall _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6); bool __fastcall sub_42FB5C(signed int a1); // int __cdecl crt_sub_42FBB7(); @@ -1970,7 +1968,7 @@ void Software_ResetNewEdges(); // int __cdecl crt_deconstruct_43B9E3(); int __stdcall DirectInputMouse_enumerator(int, int); // weak -int __cdecl CharacterUI_LoadPaperdollTextures(); +void CharacterUI_LoadPaperdollTextures(); int __fastcall _43C91D_FormItemTextureFilename(char *a1, signed int a2, int a3, int a4); void __fastcall CharacterUI_DrawPaperdoll(unsigned int uPlayerID); // idb void __fastcall CharacterUI_DrawPaperdollWithRingOverlay(unsigned int uPlayerID); // idb @@ -2044,7 +2042,7 @@ char *__fastcall sub_44987B(const char *pMapName, unsigned int uStartingPointType); // idb void __thiscall TeleportToStartingPoint(unsigned int uPointType); // idb __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb -unsigned int __fastcall _449B57_test_bit(unsigned __int8 *a1, __int16 a2); +bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2); void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb void __cdecl sub_44A56A(); void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds); @@ -2054,7 +2052,7 @@ // int __cdecl crt_deconstruct_44C42C(); void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); -void __cdecl sub_450218_prolly_generate_chests_loot(); +void sub_450218_prolly_generate_chests_loot(); signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6); int __fastcall sub_45063B(struct MapInfo *a1, int a2); void RespawnGlobalDecorations(); @@ -2165,7 +2163,7 @@ int __thiscall _46E44E_collide_against_faces_and_portals(unsigned int b1); // idb int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0); int _46ED1B_collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb -void __fastcall _46ED8A_collide_against_layingItems(unsigned int _this); +void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this); int __thiscall _46EF01_collision_chech_player(int a1); // idb signed int __cdecl _46F04E_collide_against_portals(); void __cdecl BLV_UpdateDoors(); diff -r cf366ba68de5 -r 1bd8758f50b8 stru179.h --- a/stru179.h Mon Mar 04 09:22:29 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -#pragma once - - -/* 172 */ -#pragma pack(push, 1) -struct stru179 -{ - int field_0[1000]; -}; -#pragma pack(pop) - -extern struct stru179 pStru179; \ No newline at end of file diff -r cf366ba68de5 -r 1bd8758f50b8 stru6.cpp --- a/stru6.cpp Mon Mar 04 09:22:29 2013 +0600 +++ b/stru6.cpp Mon Mar 04 09:22:38 2013 +0600 @@ -1,5 +1,5 @@ #include "stru6.h" -#include "LayingItem.h" +#include "SpriteObject.h" #include "IndoorCameraD3D.h" #include "ParticleEngine.h" #include "Game.h" @@ -146,10 +146,10 @@ } //----- (004A73AA) -------------------------------------------------------- -void stru6::_4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(LayingItem *a2, unsigned int uDiffuse, unsigned int uTextureID) +void stru6::_4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(SpriteObject *a2, unsigned int uDiffuse, unsigned int uTextureID) { stru6 *v4; // edi@1 - LayingItem *v5; // esi@1 + SpriteObject *v5; // esi@1 int v6; // eax@1 stru6_stru2 *v7; // eax@2 double v8; // st7@2 @@ -217,7 +217,7 @@ } //----- (004A75CC) -------------------------------------------------------- -void stru6::_4A75CC_single_spell_collision_particle(LayingItem *a1, unsigned int uDiffuse, unsigned int uTextureID) +void stru6::_4A75CC_single_spell_collision_particle(SpriteObject *a1, unsigned int uDiffuse, unsigned int uTextureID) { double v4; // st7@1 signed int v5; // edi@1 @@ -246,9 +246,9 @@ } //----- (004A7688) -------------------------------------------------------- -void stru6::_4A7688_fireball_collision_particle(LayingItem *a2) +void stru6::_4A7688_fireball_collision_particle(SpriteObject *a2) { - LayingItem *v2; // esi@1 + SpriteObject *v2; // esi@1 double v3; // st7@1 double v4; // st7@2 double v5; // st7@4 @@ -309,9 +309,9 @@ } //----- (004A77FD) -------------------------------------------------------- -void stru6::_4A77FD_some_stuff_d3d(LayingItem *a1) +void stru6::_4A77FD_some_stuff_d3d(SpriteObject *a1) { - LayingItem *v2; // esi@1 + SpriteObject *v2; // esi@1 stru6 *v3; // edi@1 double v4; // st7@1 double v5; // st7@2 @@ -343,7 +343,7 @@ } //----- (004A78AE) -------------------------------------------------------- -void stru6::_4A78AE_sparks_spell(LayingItem *a1) +void stru6::_4A78AE_sparks_spell(SpriteObject *a1) { ObjectDesc *v2; // esi@1 unsigned int v3; // eax@1 @@ -369,7 +369,7 @@ } //----- (004A7948) -------------------------------------------------------- -void stru6::_4A7948_mind_blast_after_effect(LayingItem *a1) +void stru6::_4A7948_mind_blast_after_effect(SpriteObject *a1) { ObjectDesc *v2; // esi@1 unsigned int v3; // eax@1 @@ -404,7 +404,7 @@ } //----- (004A7A27) -------------------------------------------------------- -bool stru6::AddMobileLight(LayingItem *a1, unsigned int uDiffuse, int uRadius) +bool stru6::AddMobileLight(SpriteObject *a1, unsigned int uDiffuse, int uRadius) { return pMobileLightsStack->AddLight( a1->vPosition.x, @@ -420,7 +420,7 @@ // 4E94D3: using guessed type char byte_4E94D3; //----- (004A7A66) -------------------------------------------------------- -void stru6::_4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(LayingItem *a1, unsigned int uDiffuse, unsigned int uTextureID, float a4) +void stru6::_4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(SpriteObject *a1, unsigned int uDiffuse, unsigned int uTextureID, float a4) { int v5; // eax@1 char v6; // al@1 @@ -488,10 +488,10 @@ } //----- (004A7C07) -------------------------------------------------------- -void stru6::_4A7C07(LayingItem *a2) +void stru6::_4A7C07(SpriteObject *a2) { stru6 *v2; // edi@1 - LayingItem *v3; // esi@1 + SpriteObject *v3; // esi@1 int v4; // eax@1 ObjectDesc *v5; // ebx@1 stru6_stru2 *v6; // eax@2 @@ -563,7 +563,7 @@ } //----- (004A7E05) -------------------------------------------------------- -void stru6::AddProjectile(LayingItem *a2, int a3, unsigned int uTextureID) +void stru6::AddProjectile(SpriteObject *a2, int a3, unsigned int uTextureID) { int v4; // edx@1 float v5; // ST14_4@2 @@ -710,7 +710,7 @@ } //----- (004A80DC) -------------------------------------------------------- -void stru6::_4A80DC_some_stuff_sw(LayingItem *a2) +void stru6::_4A80DC_some_stuff_sw(SpriteObject *a2) { stru6 *v2; // esi@1 signed int v3; // ebx@1 @@ -739,7 +739,7 @@ } //----- (004A81CA) -------------------------------------------------------- -bool stru6::_4A81CA(LayingItem *a2) +bool stru6::_4A81CA(SpriteObject *a2) { stru6 *v2; // ebx@1 int result; // eax@1 @@ -761,7 +761,7 @@ int v19; // eax@141 int v20; // eax@151 unsigned int v21; // [sp-8h] [bp-20h]@66 - LayingItem *v22; // [sp-8h] [bp-20h]@81 + SpriteObject *v22; // [sp-8h] [bp-20h]@81 unsigned int v23; // [sp-4h] [bp-1Ch]@4 unsigned int v24; // [sp-4h] [bp-1Ch]@5 unsigned int v25; // [sp-4h] [bp-1Ch]@30 @@ -779,7 +779,7 @@ __debugbreak(); // need to refactor carefully & collect data v2 = this; - result = a2->uItemType; + result = a2->uType; if ( result <= 545 ) { if ( result != 545 ) diff -r cf366ba68de5 -r 1bd8758f50b8 stru6.h --- a/stru6.h Mon Mar 04 09:22:29 2013 +0600 +++ b/stru6.h Mon Mar 04 09:22:38 2013 +0600 @@ -118,21 +118,21 @@ void DoAddProjectile(float srcX, float srcY, float srcZ, float dstX, float dstY, float dstZ, unsigned int uTextureID); void DrawProjectiles(); - void _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(struct LayingItem *a2, unsigned int uDiffuse, unsigned int uTextureID); - void _4A75CC_single_spell_collision_particle(struct LayingItem *a1, unsigned int uDiffuse, unsigned int uTextureID); - void _4A7688_fireball_collision_particle(struct LayingItem *a2); - void _4A77FD_some_stuff_d3d(struct LayingItem *a1); - void _4A78AE_sparks_spell(struct LayingItem *a1); - void _4A7948_mind_blast_after_effect(struct LayingItem *a1); - bool AddMobileLight(struct LayingItem *a1, unsigned int uDiffuse, int uRadius); - void _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(LayingItem *a1, unsigned int uDiffuse, unsigned int uTextureID, float a4); - void _4A7C07(struct LayingItem *a2); - void AddProjectile(struct LayingItem *a2, int a3, unsigned int uTextureID); + void _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(struct SpriteObject *a2, unsigned int uDiffuse, unsigned int uTextureID); + void _4A75CC_single_spell_collision_particle(struct SpriteObject *a1, unsigned int uDiffuse, unsigned int uTextureID); + void _4A7688_fireball_collision_particle(struct SpriteObject *a2); + void _4A77FD_some_stuff_d3d(struct SpriteObject *a1); + void _4A78AE_sparks_spell(struct SpriteObject *a1); + void _4A7948_mind_blast_after_effect(struct SpriteObject *a1); + bool AddMobileLight(struct SpriteObject *a1, unsigned int uDiffuse, int uRadius); + void _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(SpriteObject *a1, unsigned int uDiffuse, unsigned int uTextureID, float a4); + void _4A7C07(struct SpriteObject *a2); + void AddProjectile(struct SpriteObject *a2, int a3, unsigned int uTextureID); void _4A7E89_sparkles_on_actor_after_it_casts_buff(struct Actor *pActor, unsigned int uDiffuse); void _4A7F74(int x, int y, int z); int _4A806F(struct Actor *pActor); - void _4A80DC_some_stuff_sw(struct LayingItem *a2); - bool _4A81CA(struct LayingItem *a2); + void _4A80DC_some_stuff_sw(struct SpriteObject *a2); + bool _4A81CA(struct SpriteObject *a2); void SetPlayerBuffAnim(unsigned __int16 uSpellID, unsigned __int16 uPlayerID); void FadeScreen__like_Turn_Undead_and_mb_Armageddon(unsigned int uDiffuseColor, unsigned int uFadeTime); int _4A8BFC();