# HG changeset patch # User Grumpy7 # Date 1394574943 -3600 # Node ID f18dd2d1b56877330b3eea45ed63159b7dfe5ff7 # Parent b13ab8114e5d84752a33b37003ec7394afaf4e52# Parent fd788d2e9585139f5b1ca26960b7d749395f3028 Merge diff -r b13ab8114e5d -r f18dd2d1b568 Chest.cpp --- a/Chest.cpp Tue Mar 11 22:55:15 2014 +0100 +++ b/Chest.cpp Tue Mar 11 22:55:43 2014 +0100 @@ -302,26 +302,26 @@ item_texture = pIcons_LOD->GetTexture(item_texture_id); v6 = item_texture->uTextureWidth; if ( v6 < 14 ) - 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->SyncLoadedFilesCount(); - } + { + item_texture->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } 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 + { //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 ) { @@ -353,19 +353,17 @@ item_count = 0; max_items = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; if ( max_items <= 0 ) - { item_count = -1; - } else { while ( pChests[uChestID].igChestItems[item_count].uItemID ) { ++item_count; if ( item_count >= max_items ) - { - item_count = -1; - break; - } + { + item_count = -1; + break; + } } } return item_count; @@ -373,14 +371,13 @@ //----- (0041FFA2) -------------------------------------------------------- int Chest::PutItemInChest(int position, ItemGen *put_item, signed int uChestID) -{ - int v3; // eax@1 +{//(rus: положить предмет в ящик) ItemGen *v4; // edi@1 int v5; // esi@1 int result; // eax@11 unsigned int v7; // eax@12 int v8; // edx@12 - Texture *v9; // ecx@12 + Texture *texture; // ecx@12 signed int v10; // eax@12 signed int v11; // edi@14 unsigned int v12; // esi@14 @@ -397,11 +394,10 @@ int v23; // [sp+20h] [bp-4h]@19 v21 = 0; - v3 = pChests[uChestID].uChestBitmapID; v4 = put_item; - v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3]; + v5 = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; Src = put_item; - v19 = pChestWidthsByType[v3]; + v19 = pChestWidthsByType[pChests[uChestID].uChestBitmapID]; if ( position == -1 ) { item_in_chest_count = CountChestItems(uChestID); @@ -410,9 +406,7 @@ for( int _i = 0; _i < v5; _i++) { if ( Chest::CanPlaceItemAt(_i, v4->uItemID, pChestWindow->par1C) ) - { v21 = _i; - } } if ( v21 == v5 ) { @@ -422,18 +416,18 @@ } v7 = pIcons_LOD->LoadTexture(v4->GetIconName(), TEXTURE_16BIT_PALETTE); HIWORD(v8) = 0; - v9 = pIcons_LOD->GetTexture(v7); - v10 = v9->uTextureWidth; - if ( v10 < 14 ) + texture = pIcons_LOD->GetTexture(v7); + v10 = texture->uTextureWidth; + if ( texture->uTextureWidth < 14 ) v10 = 14; - v11 = v9->uTextureHeight; v12 = ((v10 - 14) >> 5) + 1; - if ( v11 < 14 ) + v11 = texture->uTextureHeight; + if ( texture->uTextureHeight < 14 ) v11 = 14; v13 = ((v11 - 14) >> 5) + 1; if ( !areWeLoadingTexture ) { - ((Texture *)v9)->Release(); + texture->Release(); pIcons_LOD->SyncLoadedFilesCount(); } if ( v13 > 0 ) @@ -466,62 +460,58 @@ result = v21 + 1; } else - { result = 1; - } return result; } // 506128: using guessed type int areWeLoadingTexture; //----- (0042013E) -------------------------------------------------------- void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int item_at_cell, signed 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 +{ + int uItemID; // edi@1 + int v6; // edx@4 + unsigned int v7; // eax@5 + Texture *texture; // 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 - 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) - { - v6 = rand() % 21 + 10; - pChests[ uChestID].igChestItems[item_at_cell].uNumCharges = v6; - pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6; - } - v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); - v8 = pIcons_LOD->GetTexture(v7); - v9 = v8->uTextureWidth; - 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->SyncLoadedFilesCount(); - } - chest_cell_width = pChestWidthsByType[pChests[ uChestID].uChestBitmapID]; - chest_cell_row_pos = 0; - for(int i=0; iSetSpecialBonus(&pChests[ uChestID].igChestItems[item_at_cell]); + if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[item_at_cell].uNumCharges) + { + v6 = rand() % 21 + 10; + pChests[ uChestID].igChestItems[item_at_cell].uNumCharges = v6; + pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6; + } + v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); + texture = pIcons_LOD->GetTexture(v7); + v9 = texture->uTextureWidth; + if ( texture->uTextureWidth < 14 ) + v9 = 14; + texture_cell_width = ((v9 - 14) >> 5) + 1; + v10 = texture->uTextureHeight; + if ( texture->uTextureHeight < 14 ) + v10 = 14; + textute_cell_height = ((v10 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + texture->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + chest_cell_width = pChestWidthsByType[pChests[ uChestID].uChestBitmapID]; + chest_cell_row_pos = 0; + for(int i = 0; i < textute_cell_height; ++i) + { + for (int j = 0; j < texture_cell_width; ++j) + pChests[uChestID].pInventoryIndices[put_cell_pos + chest_cell_row_pos+j]=(signed __int16)-(put_cell_pos+1); + chest_cell_row_pos += chest_cell_width; + } + pChests[uChestID].pInventoryIndices[put_cell_pos] = item_at_cell + 1; +} // 506128: using guessed type int areWeLoadingTexture; //----- (00420284) -------------------------------------------------------- @@ -581,34 +571,29 @@ //----- (00448A17) -------------------------------------------------------- void Chest::ToggleFlag(signed int uChestID, unsigned __int16 uFlag, unsigned int bToggle) - { - unsigned __int16 *pFlags; // eax@3 - - if ( uChestID >= 0 && uChestID <= 19 ) - { - pFlags = &pChests[uChestID].uFlags; - if ( bToggle ) - *pFlags |= uFlag; - else - *pFlags &= ~uFlag; - } - } +{ + if ( uChestID >= 0 && uChestID <= 19 ) + { + if ( bToggle ) + pChests[uChestID].uFlags |= uFlag; + else + pChests[uChestID].uFlags &= ~uFlag; + } +} //----- (00458B03) -------------------------------------------------------- void ChestList::ToFile() { - ChestList *v1; // esi@1 FILE *v2; // eax@1 FILE *v3; // edi@1 - v1 = this; v2 = fopen("data\\dchest.bin", "wb"); v3 = v2; if ( !v2 ) Error("Unable to save dchest.bin!"); - fwrite(v1, 4u, 1u, v2); - fwrite(v1->pChests, 0x24u, v1->uNumChests, v3); + fwrite(this, 4, 1, v2); + fwrite(this->pChests, 36, this->uNumChests, v3); fclose(v3); } @@ -634,7 +619,7 @@ //----- (00458B9C) -------------------------------------------------------- int ChestList::FromFileTxt(const char *Args) { - ChestList *v2; // ebx@1 + //ChestList *v2; // ebx@1 __int32 v3; // edi@1 FILE *v4; // eax@1 unsigned int v5; // esi@3 @@ -652,11 +637,11 @@ FILE *File; // [sp+2F4h] [bp-4h]@1 unsigned int Argsa; // [sp+300h] [bp+8h]@3 - v2 = this; + //v2 = this; free(this->pChests); v3 = 0; - v2->pChests = 0; - v2->uNumChests = 0; + this->pChests = 0; + this->uNumChests = 0; v4 = fopen(Args, "r"); File = v4; if ( !v4 ) @@ -677,16 +662,16 @@ v5 = Argsa; v3 = 0; } - v6 = v2->pChests; - v2->uNumChests = v5; + v6 = this->pChests; + this->uNumChests = v5; v7 = malloc(36 * v5); - v2->pChests = (ChestDesc *)v7; + this->pChests = (ChestDesc *)v7; if ( v7 == (void *)v3 ) Error("ChestDescriptionList::load - Out of Memory!"); - memset(v7, v3, 36 * v2->uNumChests); + memset(v7, v3, 36 * this->uNumChests); v8 = File; - v2->uNumChests = v3; + this->uNumChests = v3; fseek(v8, v3, v3); for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) { @@ -694,14 +679,14 @@ memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17)); if ( v17.uPropCount && *v17.pProperties[0] != 47 ) { - strcpy(v2->pChests[v2->uNumChests].pName, v17.pProperties[0]); + strcpy(this->pChests[this->uNumChests].pName, v17.pProperties[0]); v10 = atoi(v17.pProperties[1]); v11 = v17.pProperties[2]; - v2->pChests[v2->uNumChests].uWidth = v10; + this->pChests[this->uNumChests].uWidth = v10; v12 = atoi(v11); v13 = v17.pProperties[3]; - v2->pChests[v2->uNumChests].uHeight = v12; - v2->pChests[v2->uNumChests++].uTextureID = atoi(v13); + this->pChests[this->uNumChests].uHeight = v12; + this->pChests[this->uNumChests++].uTextureID = atoi(v13); } } fclose(File); @@ -710,11 +695,10 @@ //----- (00420B13) -------------------------------------------------------- void __fastcall sub_420B13(int a1, int a2) -{ +{ //Give item from chest(rus: Взять предмет из ящика) void *v2; // eax@1 - ItemGen *v3; // ebx@1 unsigned int v4; // eax@1 - Texture *v5; // ecx@1 + Texture *texture; // ecx@1 signed int v6; // eax@1 signed int v7; // edi@3 signed int v8; // eax@3 @@ -728,85 +712,68 @@ 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 - int 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 = (int)v2; - v2 = (void *)(5324 * (int)v2); - //v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4)); - v3 = &pChests[v20].igChestItems[a1]; - //v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)]; - v17 = pChestWidthsByType[pChests[v20].uChestBitmapID]; - v4 = pIcons_LOD->LoadTexture(v3->GetIconName(), TEXTURE_16BIT_PALETTE); - v5 = pIcons_LOD->GetTexture(v4); - v6 = v5->uTextureWidth; - if ( v6 < 14 ) - v6 = 14; + v2 = (void *)(5324 * (int)pChestWindow->ptr_1C); + v17 = pChestWidthsByType[pChests[(int)pChestWindow->ptr_1C].uChestBitmapID]; + v4 = pIcons_LOD->LoadTexture(pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].GetIconName(), TEXTURE_16BIT_PALETTE); + texture = pIcons_LOD->GetTexture(v4); + + v6 = texture->uTextureWidth; + if ( texture->uTextureWidth < 14 ) + v6 = 14; v7 = v6 - 14; - v8 = v5->uTextureHeight; v9 = (v7 >> 5) + 1; v18 = v9; - if ( v8 < 14 ) - v8 = 14; + + v8 = texture->uTextureHeight; + if ( texture->uTextureHeight < 14 ) + v8 = 14; v10 = ((v8 - 14) >> 5) + 1; v21 = v10; + if ( !areWeLoadingTexture ) { - v5->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - v10 = v21; + texture->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + v10 = v21; } if ( v10 > 0 ) { - v11 = 0; - v22 = v10; - do + v11 = 0; + for ( v22 = v10; v22; --v22 ) + { + if ( v9 > 0 ) { - if ( v9 > 0 ) - { - v12 = v9; - //v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20]; - v13 = &pChests[v20].pInventoryIndices[v19 + v11]; - 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; + v12 = v9; + v13 = &pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11]; + v14 = v12 & 1; + v12 >>= 1; + memset(&pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11], 0, 4 * v12); + v15 = (int)((char *)v13 + 4 * v12); + for ( i = v14; i; --i ) + { + *(short *)v15 = 0; + v15 += 2; + } + v9 = v18; } - while ( v22 ); + v11 += v17; + } } - v3->Reset(); + pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].Reset(); } // 506128: using guessed type int areWeLoadingTexture; //----- (00420E01) -------------------------------------------------------- void OnChestLeftClick() { - 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 - //SpriteObject v6; // [sp+Ch] [bp-80h]@1 - POINT v7; // [sp+7Ch] [bp-10h]@2 - POINT a2; // [sp+84h] [bp-8h]@2 + POINT cursor; // [sp+84h] [bp-8h]@2 SpriteObject v6; // [sp+Ch] [bp-80h]@1 - //SpriteObject::SpriteObject(&v6); - - chest_id = pGUIWindow_CurrentMenu->par1C; if ( pParty->pPickedItem.uItemID ) { if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) ) @@ -814,24 +781,22 @@ } else { - v1 = pMouse->GetCursorPos(&a2); - v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v7)->y]] & 0xFFFF; + pMouse->GetCursorPos(&cursor); + v2 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF; if ( v2 ) { if ( v2 ) v3 = v2 - 1; else v3 = -1; - v4 = pChests[chest_id].pInventoryIndices[v3] - 1; - if ( pChests[chest_id].igChestItems[v4].GetItemEquipType() == EQUIP_GOLD ) + v4 = pChests[(int)pGUIWindow_CurrentMenu->par1C].pInventoryIndices[v3] - 1; + if ( pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].GetItemEquipType() == EQUIP_GOLD ) { - pParty->PartyFindsGold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); + pParty->PartyFindsGold(pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].uSpecEnchantmentType, 0); viewparams->bRedrawGameUI = 1; } else - { - pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]); - } + pParty->SetHoldingItem(&pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4]); sub_420B13(v4, v3); } } diff -r b13ab8114e5d -r f18dd2d1b568 Conditions.cpp --- a/Conditions.cpp Tue Mar 11 22:55:15 2014 +0100 +++ b/Conditions.cpp Tue Mar 11 22:55:43 2014 +0100 @@ -28,16 +28,14 @@ bool ConditionProcessor::IsPlayerAffected( Player* inPlayer, int condToCheck, int blockable) { if ( !blockable ) - { return true; - } ConditionProcessor* thisProc = &conditionArray[condToCheck]; if (thisProc->m_IsBlockedByProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0) { if (!(thisProc->m_DoesNeedGmProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill < 4)) { --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1 ) pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); return false; } @@ -50,24 +48,18 @@ for (unsigned int i = 0; i < thisProc->m_equipmentPairs.size() / 2; i++) { if (thisProc->m_equipmentPairs[i * 2].m_ItemId == (ITEM_TYPE)0) - { return true; - } ITEM_TYPE itemId = thisProc->m_equipmentPairs[i * 2].m_ItemId; ITEM_EQUIP_TYPE slot = thisProc->m_equipmentPairs[i * 2 + 1].m_EquipSlot; if (slot == EQIUP_ANY) { if (inPlayer->WearsItemAnyWhere(itemId)) - { return false; - } } else { if (inPlayer->WearsItem(itemId, slot)) - { return false; - } } } return true; diff -r b13ab8114e5d -r f18dd2d1b568 DecalBuilder.cpp --- a/DecalBuilder.cpp Tue Mar 11 22:55:15 2014 +0100 +++ b/DecalBuilder.cpp Tue Mar 11 22:55:43 2014 +0100 @@ -32,16 +32,10 @@ result = 0.0; } else - { result = 1.0; - } return result; } - - - - //----- (0043B6EF) -------------------------------------------------------- void BloodsplatContainer::AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b) { @@ -53,7 +47,7 @@ if ( this->uNumBloodsplats == 64 ) v8 = 0; v9 = 5 * (v8 + 1); - v10 = &this->std__vector_pBloodsplats[8 * v9 / 0x28u]; + v10 = &this->std__vector_pBloodsplats[8 * v9 / 40]; v10->x = x; v10->y = y; v10->z = z; @@ -469,12 +463,12 @@ char DecalBuilder::ApplyDecals_OutdoorFace(ODMFace *pFace) { double v8; // st7@12 - unsigned int v10; // [sp+20h] [bp-1Ch]@1 + //unsigned int v10; // [sp+20h] [bp-1Ch]@1 Bloodsplat *pBloodsplat; this->uNumDecals = 0; - v10 = pBloodsplatContainer->std__vector_pBloodsplats_size; + //v10 = pBloodsplatContainer->std__vector_pBloodsplats_size; if ( !pFace->Indoor_sky() && !pFace->Fluid() ) { for(int i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; i++ ) @@ -506,28 +500,28 @@ bool DecalBuilder::_49BE8A(struct Polygon *a2, Vec3_float_ *_a3, float *a4, RenderVertexSoft *a5, unsigned int uStripType, char a7) { bool result; // eax@1 - RenderVertexSoft *v8; // edi@3 - Vec3_float_ *v9; // ebx@3 - Bloodsplat *v10; // esi@3 - float v11; // eax@5 + //RenderVertexSoft *v8; // edi@3 + //Vec3_float_ *v9; // ebx@3 + //Bloodsplat *v10; // esi@3 + //float v11; // eax@5 float v12; // eax@6 - double v13; // st7@13 + //double v13; // st7@13 double v14; // st7@19 - short v15; // eax@20 + //short v15; // eax@20 int v16; // eax@22 - int v17; // edx@24 - DecalBuilder *v18; // eax@24 + //int v17; // edx@24 + //DecalBuilder *v18; // eax@24 std::string v19; // [sp-18h] [bp-54h]@12 const char *v20; // [sp-8h] [bp-44h]@12 - int v21; // [sp-4h] [bp-40h]@12 + //int v21; // [sp-4h] [bp-40h]@12 double v22; // [sp+Ch] [bp-30h]@19 unsigned int v23; // [sp+14h] [bp-28h]@1 - DecalBuilder *v24; // [sp+18h] [bp-24h]@1 - int v25; // [sp+1Ch] [bp-20h]@19 + //DecalBuilder *v24; // [sp+18h] [bp-24h]@1 + //int v25; // [sp+1Ch] [bp-20h]@19 float v26; // [sp+20h] [bp-1Ch]@12 int v27; // [sp+24h] [bp-18h]@12 float v28; // [sp+28h] [bp-14h]@13 - float v29; // [sp+2Ch] [bp-10h]@7 + //float v29; // [sp+2Ch] [bp-10h]@7 float v30; // [sp+30h] [bp-Ch]@6 float v31; // [sp+34h] [bp-8h]@6 bool v32; // [sp+38h] [bp-4h]@2 @@ -535,92 +529,91 @@ this->uNumDecals = 0; result = pBloodsplatContainer->std__vector_pBloodsplats_size != 0; - v24 = this; + // v24 = this; v23 = pBloodsplatContainer->std__vector_pBloodsplats_size; if ( pBloodsplatContainer->std__vector_pBloodsplats_size ) { - v32 = 0; + if ( (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 ) { - v8 = a5; - v9 = _a3; - v10 = pBloodsplatContainer->std__vector_pBloodsplats; - while ( v32 < (signed int)v23) + //v8 = a5; + //v9 = _a3; + for ( v32 = 0; v32 < (signed int)v23; ++v32 ) { - if ( uStripType == 4 ) - { - a3 = v8->vWorldPosition.x; - v11 = v8[3].vWorldPosition.x; - v31 = v11; - v30 = v8[1].vWorldPosition.y; - v12 = v8->vWorldPosition.y; - v29 = v12; - } - else if ( uStripType == 3 ) + if ( uStripType == 4 ) + { + a3 = a5->vWorldPosition.x; + //v11 = v8[3].vWorldPosition.x; + v31 = a5[3].vWorldPosition.x; + v30 = a5[1].vWorldPosition.y; + v12 = a5->vWorldPosition.y; + //v29 = v12; + } + else if ( uStripType == 3 ) { if ( a7 ) { - a3 = v8->vWorldPosition.x; - v31 = v8[2].vWorldPosition.x; - v30 = v8[1].vWorldPosition.y; - v12 = v8[2].vWorldPosition.y; - v29 = v12; + a3 = a5->vWorldPosition.x; + v31 = a5[2].vWorldPosition.x; + v30 = a5[1].vWorldPosition.y; + v12 = a5[2].vWorldPosition.y; + //v29 = v12; } else { - a3 = v8[1].vWorldPosition.x; - v11 = v8[2].vWorldPosition.x; - v31 = v11; - v30 = v8[1].vWorldPosition.y; - v12 = v8->vWorldPosition.y; - v29 = v12; + a3 = a5[1].vWorldPosition.x; + //v11 = v8[2].vWorldPosition.x; + v31 = a5[2].vWorldPosition.x; + v30 = a5[1].vWorldPosition.y; + v12 = a5->vWorldPosition.y; + //v29 = v12; } } else MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:434", 0); - v21 = uStripType; - v13 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v8, uStripType); - v21 = uStripType; - v28 = v13; - v26 = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v8, uStripType); - if ( a3 - v10->radius < v10->x && - v31 + v10->radius > v10->x && - v30 - v10->radius < v10->y && - v29 + v10->radius > v10->y && - v28 - v10->radius < v10->z && - v26 + v10->radius > v10->z ) + //v21 = uStripType; + //v13 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v8, uStripType); + //v21 = uStripType; + v28 = pGame->pIndoorCameraD3D->GetPolygonMinZ(a5, uStripType); + v26 = pGame->pIndoorCameraD3D->GetPolygonMaxZ(a5, uStripType); + if ( a3 - pBloodsplatContainer->std__vector_pBloodsplats[v32].radius < pBloodsplatContainer->std__vector_pBloodsplats[v32].x && + v31 + pBloodsplatContainer->std__vector_pBloodsplats[v32].radius > pBloodsplatContainer->std__vector_pBloodsplats[v32].x && + v30 - pBloodsplatContainer->std__vector_pBloodsplats[v32].radius < pBloodsplatContainer->std__vector_pBloodsplats[v32].y && + v12 + pBloodsplatContainer->std__vector_pBloodsplats[v32].radius > pBloodsplatContainer->std__vector_pBloodsplats[v32].y && + v28 - pBloodsplatContainer->std__vector_pBloodsplats[v32].radius < pBloodsplatContainer->std__vector_pBloodsplats[v32].z && + v26 + pBloodsplatContainer->std__vector_pBloodsplats[v32].radius > pBloodsplatContainer->std__vector_pBloodsplats[v32].z ) { - Vec3_float_::NegDot(&v8->vWorldPosition, v9, a4); - v26 = v9->y * v10->y - + v9->z * v10->z - + v9->x * v10->x + Vec3_float_::NegDot(&a5->vWorldPosition, _a3, a4); + v26 = _a3->y * pBloodsplatContainer->std__vector_pBloodsplats[v32].y + + _a3->z * pBloodsplatContainer->std__vector_pBloodsplats[v32].z + + _a3->x * pBloodsplatContainer->std__vector_pBloodsplats[v32].x + *a4; v22 = v26 + 6.7553994e15; - v25 = LODWORD(v22); + //v25 = LODWORD(v22); v14 = (double)SLODWORD(v22); v28 = v14; - if ( v14 <= v10->radius ) + if ( v14 <= pBloodsplatContainer->std__vector_pBloodsplats[v32].radius ) { - v15 = a2->flags; + //v15 = a2->flags; if ( a2->flags & 2 || a2->flags & 0x100 ) { - v16 = v10->field_1C; - if ( !(v16 & 1) ) + v16 = pBloodsplatContainer->std__vector_pBloodsplats[v32].field_1C; + if ( !(pBloodsplatContainer->std__vector_pBloodsplats[v32].field_1C & 1) ) { LOBYTE(v16) = v16 | 1; - v10->field_1C = v16; - v10->field_20 = pEventTimer->Time(); + pBloodsplatContainer->std__vector_pBloodsplats[v32].field_1C = v16; + pBloodsplatContainer->std__vector_pBloodsplats[v32].field_20 = pEventTimer->Time(); } } - v17 = v32; - v10->dot_dist = LODWORD(v28); - v18 = v24; - v24->std__vector_30B00C[v24->uNumDecals] = v17; - ++v18->uNumDecals; + //v17 = v32; + pBloodsplatContainer->std__vector_pBloodsplats[v32].dot_dist = LODWORD(v28); + //v18 = this; + this->std__vector_30B00C[this->uNumDecals] = v32; + ++this->uNumDecals; } } - ++v32; - ++v10; + //++v32; + //++v10; result = v32; } } diff -r b13ab8114e5d -r f18dd2d1b568 DecorationList.cpp --- a/DecorationList.cpp Tue Mar 11 22:55:15 2014 +0100 +++ b/DecorationList.cpp Tue Mar 11 22:55:43 2014 +0100 @@ -66,7 +66,6 @@ unsigned __int8 v25; // of@16 int j; // edi@17 const char *v27; // esi@18 - int v28; // eax@19 int v29; // eax@21 int v30; // eax@23 int v31; // eax@25 @@ -224,10 +223,7 @@ } } else - { - v28 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; - *(char *)v28 |= 1u; - } + v2->pDecorations[v2->uNumDecorations].uFlags |= 1; } } ++v2->uNumDecorations; @@ -239,44 +235,28 @@ //----- (00458600) -------------------------------------------------------- void DecorationList::ToFile() { - DecorationList *v1; // esi@1 FILE *v2; // eax@1 FILE *v3; // edi@1 - v1 = this; v2 = fopen("data\\ddeclist.bin", "wb"); v3 = v2; if ( !v2 ) Error("Unable to save ddeclist.bin!"); - fwrite(v1, 4u, 1u, v2); - fwrite(v1->pDecorations, 0x54u, v1->uNumDecorations, v3); + fwrite(this, 4, 1, v2); + fwrite(this->pDecorations, 84, this->uNumDecorations, v3); fclose(v3); } //----- (004488B6) -------------------------------------------------------- unsigned __int16 DecorationList::GetDecorIdByName(const char *pName) { - DecorationList *v2; // esi@1 - signed int uID; // edi@2 - signed int v4; // ebx@3 - unsigned __int16 result; // ax@6 - - v2 = this; - if ( pName && (uID = 1, (signed int)this->uNumDecorations > 1) ) + if ( pName && (signed int)this->uNumDecorations > 1 ) { - v4 = 1; - while ( _stricmp(pName, v2->pDecorations[v4].pName) ) + for ( uint uID = 1; uID < (signed int)this->uNumDecorations; ++uID ) { - ++uID; - ++v4; - if ( uID >= (signed int)v2->uNumDecorations ) - return 0; + if ( !_stricmp(pName, this->pDecorations[uID].pName) ) + return uID; } - result = uID; } - else - { - result = 0; - } - return result; + return 0; } \ No newline at end of file diff -r b13ab8114e5d -r f18dd2d1b568 Events.cpp --- a/Events.cpp Tue Mar 11 22:55:15 2014 +0100 +++ b/Events.cpp Tue Mar 11 22:55:43 2014 +0100 @@ -282,17 +282,8 @@ { unsigned int v3; // eax@5 signed int v4; // esi@7 - //char *v5; // eax@8 - Player *v6; // ecx@8 - //char *v7; // ebp@8 - //signed int v8; // edx@10 - //int v9; // edi@12 - //ByteArray *v10; // esi@12 int v11; // eax@14 char *v12; // eax@15 - //char *v13; // edi@21 - int v14; // ebp@21 - int v15; // edi@21 const char *v16; // esi@21 bool v17; // edx@21 int v18; // ecx@22 @@ -302,11 +293,9 @@ int v22; // edx@40 int v23; // eax@40 unsigned __int16 v24; // ax@45 - int v25; // eax@54 LevelDecoration *v26; // eax@55 int v27; // eax@57 int v28; // ecx@57 - //int v29; // edx@58 int pEventID; // eax@58 int pNPC_ID; // ecx@58 int pIndex; // esi@58 @@ -317,12 +306,8 @@ int v37; // esi@62 int v38; // eax@78 int v39; // ecx@78 - size_t v40; // edx@78 - Actor *v41; // esi@79 int v42; // eax@84 int v43; // ecx@84 - size_t v44; // edx@84 - Actor *v45; // esi@85 void *v46; // eax@91 GUIWindow *v47; // eax@93 GUIButton *v48; // ecx@93 @@ -357,16 +342,9 @@ signed int v77; // ebp@186 int v78; // edx@186 Player *v79; // esi@187 - //signed int v80; // ebp@200 - //int v81; // edx@200 Player *v82; // esi@201 int v83; // eax@212 int v84; // ebp@220 - signed int v85; // ebp@224 - char v86; // al@224 - Player *v87; // esi@227 - Player *v88; // ecx@231 - int v89; // ecx@232 int v90; // eax@243 const char *v91; // ecx@247 int v92; // eax@251 @@ -378,37 +356,24 @@ unsigned int v98; // edx@265 const char *v99; // esi@267 int v100; // edx@267 - //char *v101; // edi@281 unsigned int v102; // esi@281 int v103; // edi@284 int v104; // eax@288 int v105; // edx@294 int v106; // [sp-20h] [bp-4C8h]@278 - signed int v107; // [sp-1Ch] [bp-4C4h]@278 - unsigned int v108; // [sp-18h] [bp-4C0h]@278 signed int v109; // [sp-14h] [bp-4BCh]@278 signed int v110; // [sp-10h] [bp-4B8h]@278 - int v111; // [sp-Ch] [bp-4B4h]@278 - // Event *v112; // [sp-8h] [bp-4B0h]@5 int v113; // [sp-8h] [bp-4B0h]@106 int v114; // [sp-8h] [bp-4B0h]@117 - signed int v115; // [sp-8h] [bp-4B0h]@231 - unsigned int v116; // [sp-8h] [bp-4B0h]@278 int v117; // [sp-4h] [bp-4ACh]@106 int v118; // [sp-4h] [bp-4ACh]@117 - int v119; // [sp-4h] [bp-4ACh]@231 - int v120; // [sp-4h] [bp-4ACh]@278 int v121; // [sp-4h] [bp-4ACh]@294 int curr_seq_num; // [sp+10h] [bp-498h]@4 - //char *v123; // [sp+14h] [bp-494h]@0 - signed int v124; // [sp+18h] [bp-490h]@7 - //signed int v125; // [sp+1Ch] [bp-48Ch]@155 int v126; // [sp+1Ch] [bp-48Ch]@262 int player_choose; // [sp+20h] [bp-488h]@4 int v128; // [sp+24h] [bp-484h]@21 int v129; // [sp+24h] [bp-484h]@262 signed int v130; // [sp+28h] [bp-480h]@0 - //int v131; // [sp+2Ch] [bp-47Ch]@1 int v132; // [sp+30h] [bp-478h]@262 signed int v133; // [sp+34h] [bp-474h]@1 int v134; // [sp+38h] [bp-470h]@262 @@ -422,7 +387,6 @@ char Str[120]; // [sp+ECh] [bp-3BCh]@21 Actor Dst; // [sp+164h] [bp-344h]@53 - //v131 = uEventID; v133 = 0; EvtTargetObj = targetObj; dword_5B65C4_cancelEventProcessing = 0; @@ -434,158 +398,129 @@ return; } */ if ( !uEventID ) - { + { if ( !GameUI_Footer_TimeLeft ) ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here return; - } + } player_choose = (uActiveCharacter == 0)?6:4; //4 - active or 6 - random player if active =0 curr_seq_num = entry_line; if ( activeLevelDecoration ) - { + { uSomeEVT_NumEvents = uGlobalEVT_NumEvents; pSomeEVT = pGlobalEVT.data(); memcpy(pSomeEVT_Events.data(), pGlobalEVT_Index.data(), sizeof(EventIndex)*4400); //4400 evts - } + } else - { + { uSomeEVT_NumEvents = uLevelEVT_NumEvents; pSomeEVT = pLevelEVT.data(); memcpy(pSomeEVT_Events.data(), pLevelEVT_Index.data(), sizeof(EventIndex)*4400); - } + } - v4 = 0; - v124 = 0; - //for (uint i = 0; i < uSomeEVT_NumEvents; ++i) - // { - //v6 = v123; - //v7 = ""; - while ( 1 ) + for ( v4 = 0; v4 < uSomeEVT_NumEvents; ++v4 ) + { + if ( dword_5B65C4_cancelEventProcessing ) { - if ( dword_5B65C4_cancelEventProcessing ) - goto LABEL_301; - //v8 = v4; + if ( v133 == 1 ) + OnMapLeave(); + return; + } if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num ) { - //v9 = pSomeEVT_Events[v8].uEventOffsetInEVT; - //v10 = (ByteArray *)&v5[v9]; _evt_raw * _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[v4].uEventOffsetInEVT); switch (_evt->_e_type) - { + { case EVENT_CheckSeason: - // if ( !sub_4465DF_check_season(_evt->v5) ) - { + { ++curr_seq_num; - v4 = v124; + //v4 = v124; break; - } - v124 = -1; + } + v4 = -1; curr_seq_num = _evt->v6 - 1; ++curr_seq_num; break; case EVENT_ShowMovie: - { + { strcpy(Source, (char *)&_evt->v7); v12 = (char *)&item.uExpireTime + strlen(Source) + 7; if ( *v12 == 32 ) *v12 = 0; - if (pVideoPlayer->bBufferLoaded) + if (pVideoPlayer->bBufferLoaded) pVideoPlayer->Unload(); pVideoPlayer->bStopBeforeSchedule = 0; pVideoPlayer->pResetflag = 0; v128 = pCurrentScreen; - //v13 = &pSomeEVT[v9]; - //v14 = (unsigned __int8)v13[5]; - //v15 = (unsigned __int8)v13[6]; - v14 = _evt->v5; - v15 = _evt->v6; strcpy(Str, Source); v16 = RemoveQuotes(Str); - pVideoPlayer->MovieLoop(v16, 0, v14, 1); + pVideoPlayer->MovieLoop(v16, 0, _evt->v5, 1); if ( !_stricmp(v16, "arbiter good") ) { pParty->alignment = PartyAlignment_Good; v18 = 0; LOBYTE(v17) = 1; SetUserInterface(PartyAlignment_Good, v17); - if ( !v15 || v128 == 3 ) - { + if ( !_evt->v6 || v128 == 3 ) + { pCurrentScreen = v128; if ( v128 == 3 ) pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; if ( v128 == 13 ) pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); - } - + } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; - } + } if ( !_stricmp(v16, "arbiter evil") ) - { + { v18 = 2; pParty->alignment = PartyAlignment_Evil; LOBYTE(v17) = 1; SetUserInterface(PartyAlignment_Evil, v17); - if ( !v15 || v128 == 3 ) - { + if ( !_evt->v6 || v128 == 3 ) + { pCurrentScreen = v128; if ( v128 == 3 ) pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; if ( v128 == 13 ) pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); - } + } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } + } if ( !_stricmp(v16, "pcout01") ) // moving to harmondale from emerald isle - { + { Rest(0x2760u); pParty->RestAndHeal(); pParty->days_played_without_rest = 0; - } - if ( !v15 || v128 == 3 ) - { + } + if ( !_evt->v6 || v128 == 3 ) + { pCurrentScreen = v128; if ( v128 == 3 ) pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; if ( v128 == 13 ) - pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); - } + pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1); + } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; } break; case EVENT_CheckSkill: - { + { v19 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((unsigned int)_evt->v10 << 8)) << 8)) << 8); if ( player_choose < 0 ) goto LABEL_47; if ( player_choose <= 3 ) - { v24 = pParty->pPlayers[0].pActiveSkills[3486 * player_choose + _evt->v5]; - } else { if ( player_choose == 4 ) - { v24 = pPlayers[uActiveCharacter]->pActiveSkills[_evt->v5]; - } else { if ( player_choose == 5 ) @@ -605,15 +540,12 @@ if ( v20 >= 4 ) { ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; } } - v11 = _evt->v11; - goto LABEL_130; + curr_seq_num = _evt->v11 - 1; + ++curr_seq_num; + break; } LABEL_47: //v10 = (ByteArray *)&v5[v9]; @@ -626,14 +558,11 @@ v139 = v24 & 0x100; if ( (v24 & 0x3F) >= v19 && *(&v136 + _evt->v6) ) { - v11 = _evt->v11; - goto LABEL_130; + curr_seq_num = _evt->v11 - 1; + ++curr_seq_num; + break; } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; } break; @@ -647,29 +576,19 @@ GameUI_InitializeDialogue(&Dst, false); } else - { bDialogueUI_InitializeActor_NPC_ID = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); - } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_ChangeEvent: - v25 = EVT_DWORD(_evt->v5); - if ( v25 ) - { + if ( EVT_DWORD(_evt->v5) ) stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration->_idx_in_stru123] = _evt->v5 - 124; - } else - { + { v26 = (LevelDecoration *)activeLevelDecoration; stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0; v26->uFlags |= LEVEL_DECORATION_INVISIBLE; - } + } ++curr_seq_num; - v4 = v124; break; case EVENT_SetNPCGreeting: @@ -677,10 +596,6 @@ pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu; pNPCStats->pNewNPCData[v27].greet = EVT_DWORD(_evt->v9); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_SetNPCTopic: { @@ -723,79 +638,48 @@ } ++curr_seq_num; } - v4 = v124; break; case EVENT_NPCSetItem: sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); ++curr_seq_num; - v4 = v124; - break; case EVENT_SetActorItem: Actor::GiveItem(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); ++curr_seq_num; - v4 = v124; 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; 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; break; case EVENT_ChangeGroup: v38 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); v39 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); - v40 = uNumActors; __debugbreak(); - if ( (signed int)uNumActors > 0 ) - { - v41 = pActors.data();//[0].uGroup; - do - { - if ( v41->uGroup == v38 ) - v41->uGroup = v39; - ++v41; - --v40; - } - while ( v40 ); - } + for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ ) + { + if ( pActors[actor_id].uGroup == v38 ) + pActors[actor_id].uGroup = v39; + } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_ChangeGroupAlly: v42 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); v43 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); - v44 = uNumActors; __debugbreak(); - if ( (signed int)uNumActors > 0 ) - { - v45 = pActors.data();//[0].uAlly; - do - { - if ( v45->uGroup == v42 ) - v45->uAlly = v43; - ++v45; - --v44; - } - while ( v44 ); - } + for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ ) + { + if ( pActors[actor_id].uGroup == v42 ) + pActors[actor_id].uAlly = v43; + } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_MoveNPC: { - pNPCStats->pNewNPCData[EVT_DWORD(_evt->v5)].Location2D =EVT_DWORD(_evt->v9); if ( window_SpeakInHouse ) { @@ -812,7 +696,7 @@ pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); v48 = window_SpeakInHouse->pControlsHead; - if ( v48 ) + if ( window_SpeakInHouse->pControlsHead ) { do { @@ -835,9 +719,7 @@ } } - ++curr_seq_num; - v4 = v124; - + ++curr_seq_num; break; case EVENT_Jmp: curr_seq_num = _evt->v5 - 1; @@ -852,33 +734,28 @@ pParty->pPlayers[uActiveCharacter].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); else if ( _evt->v5 == 5 ) //all players { - for(int i=0; i<4; ++i) + for(int i = 0; i < 4; ++i) pParty->pPlayers[i].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); } else //random player pParty->pPlayers[rand() % 4].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); ++curr_seq_num; - v4 = v124; - break; case EVENT_CharacterAnimation: - if ( _evt->v5 <= 3u ) //someone + if ( _evt->v5 <= 3 ) //someone pParty->pPlayers[_evt->v5].PlaySound((PlayerSpeech) _evt->v6, 0); else if ( _evt->v5 == 4 ) //active pParty->pPlayers[uActiveCharacter].PlaySound((PlayerSpeech) _evt->v6, 0); else if ( _evt->v5 == 5 ) //all - for(int i=0; i<4; ++i) + for(int i = 0; i < 4; ++i) pParty->pPlayers[i].PlaySound((PlayerSpeech) _evt->v6, 0); else //random pParty->pPlayers[rand() % 4].PlaySound((PlayerSpeech) _evt->v6, 0); ++curr_seq_num; - v4 = v124; - break; case EVENT_ForPartyMember: player_choose = _evt->v5; ++curr_seq_num; - v4 = v124; break; case EVENT_SummonItem: sub_42F7EB_DropItemAt(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), @@ -888,10 +765,6 @@ _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8), _evt->v25, _evt->v26, 0, 0); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_Compare: pValue = EVT_DWORD(_evt->v7); @@ -899,7 +772,7 @@ { if ( pPlayers[player_choose]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) { - v124 = -1; + // v124 = -1; curr_seq_num = _evt->v11 - 1; } } @@ -909,19 +782,19 @@ { if ( pPlayers[uActiveCharacter]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) { - v124 = -1; + // v124 = -1; curr_seq_num = _evt->v11 - 1; } } } else if ( player_choose == 5 )//all { - v130=0; + v130 = 0; for(int i = 1; i < 5; ++i) { if ( pPlayers[i]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) { - v124 = -1; + // v124 = -1; curr_seq_num = _evt->v11 - 1; break; } @@ -932,21 +805,21 @@ { if ( pPlayers[rand() % 4 + 1]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) { - v124 = -1; + // v124 = -1; curr_seq_num = _evt->v11 - 1; } } ++curr_seq_num; - v4 = v124; + v4 = -1; break; case EVENT_IsActorAlive: if (IsActorAlive(EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10))) - { - v124 = -1; + { + //v124 = -1; curr_seq_num = _evt->v11 - 1; - } + } ++curr_seq_num; - v4 = v124; + v4 = -1; break; case EVENT_Substract: pValue = EVT_DWORD(_evt->v7); @@ -1029,18 +902,11 @@ else if ( player_choose == 5 )//all { for(int i = 1; i < 5; ++i) - { pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } } else if ( player_choose == 6 ) //random - { - player_choose = rand() % 4; - pParty->pPlayers[player_choose].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } -//substract: + pParty->pPlayers[rand() % 4].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); ++curr_seq_num; - v4 = v124; break; case EVENT_Set: pValue = EVT_DWORD(_evt->v7); @@ -1053,18 +919,13 @@ } else if ( player_choose == 5 )//all { - //recheck v130 + //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 - { - player_choose = rand() % 4; - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } + pParty->pPlayers[rand() % 4].SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); ++curr_seq_num; - v4 = v124; break; case EVENT_Add: pValue = EVT_DWORD(_evt->v7); @@ -1084,10 +945,7 @@ pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } else if ( player_choose == 6 ) //random - { - player_choose = rand() % 4; - pParty->pPlayers[player_choose].AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } + pParty->pPlayers[rand() % 4].AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); v83 = EVT_WORD(_evt->v5); if (v83 == 21 || // gold well on emerald isle v83 == 22 || v83 == 23 || v83 == 24 ) @@ -1096,36 +954,25 @@ viewparams->bRedrawGameUI = true; } ++curr_seq_num; - v4 = v124; break; case EVENT_InputString: if ( !entry_line ) - { + { strcpy(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); - v105 = curr_seq_num; - v121 = 26; -LABEL_295: - sub_4451A8_press_any_key(uEventID, v105, v121); -LABEL_301: + sub_4451A8_press_any_key(uEventID, curr_seq_num, 26); if ( v133 == 1 ) OnMapLeave(); return; - } + } v84 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); if ( !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8)]]) || !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[v84]]) ) - { + { v11 = _evt->v17; -LABEL_130: - //v124 = -1; -LABEL_131: curr_seq_num = v11 - 1; - } + } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; + v4 = -1; break; case EVENT_RandomGoTo: //v124 = -1; @@ -1133,219 +980,131 @@ + (_evt->v10 != 0))); curr_seq_num = v11 - 1; ++curr_seq_num; - v4 = v124; + v4 = -1; break; case EVENT_ReceiveDamage: - v85 = EVT_DWORD(_evt->v7 ); - v86 = _evt->v5; - if ( (unsigned __int8)v86 <= 3 ) - { - v119 = _evt->v6; - v115 = EVT_DWORD(_evt->v7 ); - v89 = (unsigned __int8)v86; - v88 = &pParty->pPlayers[v89]; - v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); - ++curr_seq_num; - v4 = v124; - break; - } - if ( v86 == 4 ) - { - if ( !uActiveCharacter ) - { - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } - v119 = _evt->v6; - v88 = pPlayers[uActiveCharacter]; - v115 = EVT_DWORD(_evt->v7 ); - v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); + if ( (unsigned __int8)_evt->v5 <= 3 ) + { + pParty->pPlayers[(unsigned __int8)_evt->v5].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); ++curr_seq_num; - v4 = v124; break; - } - if ( v86 != 5 ) + } + if ( _evt->v5 == 4 ) + { + if ( !uActiveCharacter ) { - v119 = _evt->v6; - v115 = EVT_DWORD(_evt->v7 ); - v89 = rand() % 4; - v88 = &pParty->pPlayers[v89]; - v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); + ++curr_seq_num; + break; + } + pPlayers[uActiveCharacter]->ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; - } - v87 = pParty->pPlayers.data(); - do - { - v87->ReceiveDamage(v85, (DAMAGE_TYPE)_evt->v6); - ++v87; - } - while ( (signed int)v87 < (signed int)pParty->pHirelings.data() ); + } + if ( _evt->v5 != 5 ) + { + pParty->pPlayers[rand() % 4].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; + break; + } + for ( uint pl_id = 0;pl_id < 4; pl_id++ ) + pParty->pPlayers[pl_id].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); + ++curr_seq_num; break; case EVENT_ToggleIndoorLight: pIndoor->ToggleLight(EVT_DWORD(_evt->v5 ), _evt->v9); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_SetFacesBit: sub_44892E_set_faces_bit(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_ToggleChestFlag: Chest::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_ToggleActorFlag: Actor::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_ToggleActorGroupFlag: ToggleActorGroupFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_SetSnow: if ( !_evt->v5 ) pWeather->bRenderSnow = _evt->v6 != 0; ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_StatusText: v90 = EVT_DWORD(_evt->v5 ); if ( activeLevelDecoration ) - { + { if ( activeLevelDecoration == (LevelDecoration*)1 ) - { current_npc_text = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; - } if ( canShowMessages == 1 ) { v91 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; //LABEL_248: - ShowStatusBarString(v91, 2u); + ShowStatusBarString(v91, 2); } - } + } else - { + { if ( canShowMessages == 1 ) - { + { v91 = &pLevelStr[pLevelStrOffsets[v90]]; - ShowStatusBarString(v91, 2u); - } + ShowStatusBarString(v91, 2); } + } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_ShowMessage: - v92 = EVT_DWORD(_evt->v5 ); if ( activeLevelDecoration ) - { - v93 = (char *)pNPCTopics[v92-1].pText;//(&dword_721664)[8 * v92]; + { + current_npc_text = pNPCTopics[EVT_DWORD(_evt->v5 )-1].pText;//(&dword_721664)[8 * v92]; byte_5B0938[0] = 0; - current_npc_text = v93; - } + } else - { - strcpy(byte_5B0938.data(), &pLevelStr[pLevelStrOffsets[v92]]); - } + strcpy(byte_5B0938.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_CastSpell: EventCastSpell(_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; break; case EVENT_SetTexture: sub_44861E_set_texture(EVT_DWORD(_evt->v5 ), (char *)&_evt->v9); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_SetSprite: SetDecorationSprite(EVT_DWORD(_evt->v5 ), _evt->v9, (char *)&_evt->v10); ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_SummonMonsters: 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; - - //v6 = v123; - //v7 = ""; break; case EVENT_MouseOver: case EVENT_LocationName: --curr_seq_num; ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_ChangeDoorState: Door_switch_animation(_evt->v5, _evt->v6); ++curr_seq_num; - v4 = v124; break; case EVENT_OpenChest: if ( !Chest::Open(_evt->v5) ) - goto LABEL_301; + { + if ( v133 == 1 ) + OnMapLeave(); + return; + } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_MoveToMap: v94 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); @@ -1363,20 +1122,20 @@ TransitionUI_Load(_evt->v29, _evt->v30, v135, v132, v126, v129, v95, v134, (char *)&_evt->v31); dword_5C3418 = uEventID; dword_5C341C = curr_seq_num + 1; - goto LABEL_301; + if ( v133 == 1 ) + OnMapLeave(); + return; } _5B65AC_npcdata_fame_or_other = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); _5B65A8_npcdata_uflags_or_other = v94; _5B65B0_npcdata_rep_or_other = v126; if ( v129 == -1 ) - { v98 = _5B65B4_npcdata_loword_house_or_other; - } else - { + { v98 = v129 & stru_5C6E00->uDoublePiMask; _5B65B4_npcdata_loword_house_or_other = v129 & stru_5C6E00->uDoublePiMask; - } + } v99 = (char *)&_evt->v31; _5B65B8_npcdata_hiword_house_or_other = v95; dword_5B65BC = v97; @@ -1393,13 +1152,6 @@ if ( _5B65B4_npcdata_loword_house_or_other != -1 ) pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other; _5B65B4_npcdata_loword_house_or_other = -1; - v120 = 0; - v116 = 0; - v111 = 0; - v110 = 0; - v109 = -1; - v108 = 0; - v107 = 0; pParty->sRotationX = v95; pParty->uFallSpeed = v134; dword_5B65C0 = 0; @@ -1409,8 +1161,7 @@ _5B65AC_npcdata_fame_or_other = 0; _5B65A8_npcdata_uflags_or_other = 0; v106 = 232; -LABEL_280: - pAudioPlayer->PlaySound((SoundID)v106, v107, v108, v109, v110, v111, v116, v120); + pAudioPlayer->PlaySound((SoundID)v106, 0, 0, -1, 0, 0, 0, 0); } } else @@ -1444,34 +1195,22 @@ } } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_PlaySound: - v120 = 0; - v116 = 0; - v111 = 0; v110 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); v109 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); - v108 = 0; - v107 = 0; v106 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - goto LABEL_280; + pAudioPlayer->PlaySound((SoundID)v106, 0, 0, v109, v110, 0, 0, 0); + ++curr_seq_num; + break; case EVENT_GiveItem: item.Reset(); - //v101 = &pSomeEVT[v9]; - v102 = _evt->v7 - + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); + v102 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); pItemsTable->GenerateItem(_evt->v5, _evt->v6, &item); if ( v102 ) item.uItemID = v102; pParty->SetHoldingItem(&item); ++curr_seq_num; - v4 = v124; - //v6 = v123; - //v7 = ""; break; case EVENT_SpeakInHouse: if ( EnterHouse((enum HOUSE_ID)EVT_DWORD(_evt->v5))) @@ -1490,34 +1229,25 @@ window_SpeakInHouse->CreateButton( 0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0); } ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_PressAnyKey: - v121 = 33; - v105 = curr_seq_num + 1; - goto LABEL_295; + sub_4451A8_press_any_key(uEventID, curr_seq_num + 1, 33); + if ( v133 == 1 ) + OnMapLeave(); + return; case EVENT_Exit: if ( v133 == 1 ) OnMapLeave(); return; default: ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; break; } } - ++v4; - v124 = v4; - if ( v4 >= uSomeEVT_NumEvents ) - goto LABEL_301; - //} } + if ( v133 == 1 ) + OnMapLeave(); + return; } //----- (00444732) -------------------------------------------------------- @@ -1540,8 +1270,8 @@ { if ( pLevelEVT_Index[event_index].uEventID == uEventID ) { - test_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; - last_evt=test_evt; + test_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; + last_evt=test_evt; event_pos = pLevelEVT_Index[event_index+1].uEventOffsetInEVT; if ( test_evt->_e_type == EVENT_MouseOver ) break; @@ -1550,7 +1280,7 @@ if ( event_index >= uLevelEVT_NumEvents ) return NULL; } - test_evt=(_evt_raw*)&pLevelEVT[event_pos]; + test_evt=(_evt_raw*)&pLevelEVT[event_pos]; if ( test_evt->_e_type== EVENT_SpeakInHouse ) { str_index = EVT_DWORD(test_evt->v5); @@ -1558,10 +1288,10 @@ } else { - for ( i = event_index+1; pLevelEVT_Index[i].uEventID == uEventID; ++i ) + for ( i = event_index + 1; pLevelEVT_Index[i].uEventID == uEventID; ++i ) { event_pos = pLevelEVT_Index[i].uEventOffsetInEVT; - test_evt=(_evt_raw*)&pLevelEVT[event_pos]; + test_evt=(_evt_raw*)&pLevelEVT[event_pos]; if ( test_evt->_e_type == EVENT_SpeakInHouse ) { str_index = EVT_DWORD(test_evt->v5); diff -r b13ab8114e5d -r f18dd2d1b568 GUIButton.cpp --- a/GUIButton.cpp Tue Mar 11 22:55:15 2014 +0100 +++ b/GUIButton.cpp Tue Mar 11 22:55:43 2014 +0100 @@ -114,73 +114,51 @@ //----- (0041D0D8) -------------------------------------------------------- void GUIButton::Release() { - GUIWindow *v1; // eax@2 - GUIButton *v2; // edx@2 - GUIButton *v3; // eax@6 - GUIButton *ptr; - - ptr=this; - if ( ptr ) + if ( this ) { - v1 = ptr->pParent; - v2 = ptr->pNext; - if ( ptr == v1->pControlsHead ) + if ( this == this->pParent->pControlsHead ) { - if ( v2 ) + if ( this->pNext ) { - v1->pControlsHead = v2; - ptr->pNext->pPrev = 0; + this->pParent->pControlsHead = this->pNext; + this->pNext->pPrev = 0; } else { - v1->pControlsHead = 0; - ptr->pParent->pControlsTail = 0; + this->pParent->pControlsHead = 0; + this->pParent->pControlsTail = 0; } } else { - v3 = ptr->pPrev; - if ( v2 ) + if ( this->pNext ) { - v3->pNext = v2; - ptr->pNext->pPrev = v3; + this->pPrev->pNext = this->pNext; + this->pNext->pPrev = this->pPrev; } else { - v3->pNext = 0; - ptr->pParent->pControlsTail = v3; + this->pPrev->pNext = 0; + this->pParent->pControlsTail = this->pPrev; } } - --ptr->pParent->uNumControls; + --this->pParent->uNumControls; } } - //----- (00415180) -------------------------------------------------------- void GUIButton::DrawLabel( const char *label_text, struct GUIFont *pFont, int a5, int uFontShadowColor ) - { - const char *v5; // ebx@1 - GUIButton *v6; // esi@1 - int v7; // eax@1 - - v5 = label_text; - v6 = this; +{ //strlen(edx0); - v7 = pFont->GetLineWidth(label_text); - return pParent->DrawText( - pFont, - v6->uX + (signed int)(v6->uWidth - v7) / 2, - v6->uY + (signed int)(v6->uHeight - pFont->uFontHeight) / 2, - a5, - label_text, - 0, - 0, - uFontShadowColor); + return pParent->DrawText(pFont, + this->uX + (signed int)(this->uWidth - pFont->GetLineWidth(label_text)) / 2, + this->uY + (signed int)(this->uHeight - pFont->uFontHeight) / 2, + a5, label_text, 0, 0, uFontShadowColor); } //----- (004B36CC) -------------------------------------------------------- void CreateButtonInColumn( int column_pos, unsigned int control_id ) { - pDialogueWindow->CreateButton( 480, 30 * column_pos + 146, 140, 30, 1, 0, UIMSG_SelectShopDialogueOption, control_id, 0, "", 0); + pDialogueWindow->CreateButton( 480, 30 * column_pos + 146, 140, 30, 1, 0, UIMSG_SelectShopDialogueOption, control_id, 0, "", 0); } //----- (00419379) -------------------------------------------------------- void ReleaseAwardsScrollBar() diff -r b13ab8114e5d -r f18dd2d1b568 Game.cpp --- a/Game.cpp Tue Mar 11 22:55:15 2014 +0100 +++ b/Game.cpp Tue Mar 11 22:55:43 2014 +0100 @@ -72,14 +72,11 @@ //----- (0044103C) -------------------------------------------------------- void Game::Draw() { - //float v2; // ST24_4@11 - //double v3; // ST28_8@11 int v4; // edi@26 - //int v5; // eax@35 uFlags2 &= ~0x02; if ( pParty->_497FC5_check_party_perception_against_level() ) - uFlags2 |= 2u; + uFlags2 |= 2; pGame->pIndoorCameraD3D->sRotationX = pParty->sRotationX; pGame->pIndoorCameraD3D->sRotationY = pParty->sRotationY; diff -r b13ab8114e5d -r f18dd2d1b568 GammaControl.cpp --- a/GammaControl.cpp Tue Mar 11 22:55:15 2014 +0100 +++ b/GammaControl.cpp Tue Mar 11 22:55:43 2014 +0100 @@ -23,30 +23,25 @@ double v2; // st7@1 unsigned __int16 *v3; // ecx@1 double v4; // st6@2 - double result; // st7@7 signed int v6; // [sp+0h] [bp-8h]@1 signed int v7; // [sp+4h] [bp-4h]@1 - v7 = 0; v2 = 0.0; v6 = 256; v3 = a1->green; - do + for ( v7 = 0; v7 < 256; ++v7 ) { v4 = ((double)*(v3 - 256) + (double)v3[256] + (double)*v3) * 0.000015259022 * 0.33333334; if ( v4 == 0.0 ) --v6; else v2 = v2 + (double)v7 * 0.0039215689 / v4; - ++v7; ++v3; } - while ( v7 < 256 ); if ( v6 ) - result = v2 / (double)v6; + return v2 / (double)v6; else - result = 1.0; - return result; + return 1.0; } //----- (0044F408) -------------------------------------------------------- @@ -66,42 +61,33 @@ signed __int64 v4; // qax@3 signed int v6; // [sp+Ch] [bp-4h]@1 - v6 = 0; v2 = pRamp->green; - do + for ( v6 = 0; v6 < 256; ++v6 ) { v3 = (double)v6 * 0.0039215689 * this->fGamma; if ( v3 >= 1.0 || (v4 = (signed __int64)(v3 * 65535.0), (signed int)v4 > 65535) ) - { - LODWORD(v4) = 65535; - } + LODWORD(v4) = 65535; else if ( (signed int)v4 < 0 ) - { LODWORD(v4) = 0; - } else { if ( (signed int)v4 > 65535 ) LODWORD(v4) = 65535; } - ++v6; v2[256] = v4; *v2 = v4; *(v2 - 256) = v4; ++v2; } - while ( v6 < 256 ); return v4; } //----- (0044F4D9) -------------------------------------------------------- void GammaController::Initialize(float gamma) { - GammaController *v2; // esi@1 double v3; // st7@3 double v4; // st6@4 - v2 = this; //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || //pVersion->pVersionInfo.dwMajorVersion != 4) { @@ -117,19 +103,13 @@ v3 = gamma; } else - { v3 = 0.1; - } - v2->fGamma = v3; - InitGammaRamp(&v2->field_60C); - SetGammaRamp(&v2->field_60C); + this->fGamma = v3; + InitGammaRamp(&this->field_60C); + SetGammaRamp(&this->field_60C); } } - - - - //----- (0044F215) -------------------------------------------------------- GammaController::GammaController() { @@ -139,29 +119,20 @@ fGamma = flt_4D8670_default_gamma; } - - //----- (0044F24B) -------------------------------------------------------- void GammaController::InitializeFromSurface(IDirectDrawSurface4 *a2) { - GammaController *v2; // esi@1 - IDirectDrawGammaControl **v3; // edi@1 - IDirectDrawGammaControl *v4; // eax@1 - - v2 = this; - v3 = &this->pGammaControl; this->pSurface = a2; - v4 = this->pGammaControl; - if ( v4 ) + if ( this->pGammaControl ) { - v4->Release(); - *v3 = 0; + this->pGammaControl->Release(); + this->pGammaControl = 0; } if ( pRenderer->IsGammaSupported() ) { - ErrD3D(a2->QueryInterface(IID_IDirectDrawGammaControl, (LPVOID *)v3)); + ErrD3D(a2->QueryInterface(IID_IDirectDrawGammaControl, (LPVOID *)&this->pGammaControl)); GetRamp(); - memcpy(&v2->field_60C, &v2->pDefaultRamp, 0x600u); - fGamma = _44F377(&v2->field_60C); + memcpy(&this->field_60C, &this->pDefaultRamp, 0x600u); + fGamma = _44F377(&this->field_60C); } } \ No newline at end of file diff -r b13ab8114e5d -r f18dd2d1b568 Render.cpp --- a/Render.cpp Tue Mar 11 22:55:15 2014 +0100 +++ b/Render.cpp Tue Mar 11 22:55:43 2014 +0100 @@ -8485,18 +8485,18 @@ { //t = near_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); - array_507D30[out_num_vertices].vWorldViewPosition.y = fixpoint_mul((array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y), t) + array_50AC10[i].vWorldViewPosition.y; - array_507D30[out_num_vertices].vWorldViewPosition.z = fixpoint_mul((array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z), t) + array_50AC10[i].vWorldViewPosition.z; - array_507D30[out_num_vertices].u = fixpoint_mul((array_50AC10[i + 1].u - array_50AC10[i].u), t) + array_50AC10[i].u; - array_507D30[out_num_vertices].v = fixpoint_mul((array_50AC10[i + 1].v - array_50AC10[i].v), t) + array_50AC10[i].v; + array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; + array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; + array_507D30[out_num_vertices].u = (array_50AC10[i + 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; + array_507D30[out_num_vertices].v = (array_50AC10[i + 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; } else { t = (8.0 - array_50AC10[i + 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); - array_507D30[out_num_vertices].vWorldViewPosition.y = fixpoint_mul((array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y), t) + array_50AC10[i + 1].vWorldViewPosition.y; - array_507D30[out_num_vertices].vWorldViewPosition.z = fixpoint_mul((array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z), t) + array_50AC10[i + 1].vWorldViewPosition.z; - array_507D30[out_num_vertices].u = fixpoint_mul((array_50AC10[i].u - array_50AC10[i + 1].u), t) + array_50AC10[i + 1].u; - array_507D30[out_num_vertices].v = fixpoint_mul((array_50AC10[i].v - array_50AC10[i + 1].v), t) + array_50AC10[i + 1].v; + array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t + array_50AC10[i + 1].vWorldViewPosition.y; + array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t + array_50AC10[i + 1].vWorldViewPosition.z; + array_507D30[out_num_vertices].u = (array_50AC10[i].u - array_50AC10[i + 1].u) * t + array_50AC10[i + 1].u; + array_507D30[out_num_vertices].v = (array_50AC10[i].v - array_50AC10[i + 1].v) * t + array_50AC10[i + 1].v; } array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; array_507D30[out_num_vertices]._rhw = 1.0 / 8.0;