# HG changeset patch # User Ritor1 # Date 1394767962 -21600 # Node ID 8193a64c74613c7712d19ccce9830f0128f886b0 # Parent 90f56da08d761f9e0d9c283834b5083ed0954e42# Parent 42b6a910b5d8badf3e3da4981ec318ea91cade81 Слияние diff -r 90f56da08d76 -r 8193a64c7461 Build/Visual Studio 2012/World of Might and Magic.vcxproj --- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj Fri Mar 14 09:32:25 2014 +0600 +++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj Fri Mar 14 09:32:42 2014 +0600 @@ -168,6 +168,7 @@ + diff -r 90f56da08d76 -r 8193a64c7461 Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters --- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Fri Mar 14 09:32:25 2014 +0600 +++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Fri Mar 14 09:32:42 2014 +0600 @@ -334,6 +334,7 @@ UI\Books + diff -r 90f56da08d76 -r 8193a64c7461 Chest.cpp --- a/Chest.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/Chest.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -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 90f56da08d76 -r 8193a64c7461 Conditions.cpp --- a/Conditions.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/Conditions.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -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 90f56da08d76 -r 8193a64c7461 DecalBuilder.cpp --- a/DecalBuilder.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/DecalBuilder.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -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 90f56da08d76 -r 8193a64c7461 DecorationList.cpp --- a/DecorationList.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/DecorationList.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -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 90f56da08d76 -r 8193a64c7461 Events.cpp --- a/Events.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/Events.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -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 90f56da08d76 -r 8193a64c7461 GUIButton.cpp --- a/GUIButton.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/GUIButton.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -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 90f56da08d76 -r 8193a64c7461 GUIFont.cpp --- a/GUIFont.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/GUIFont.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -55,8 +55,6 @@ return pFont; } - - //----- (0044D2FD) -------------------------------------------------------- void GUIFont::_44D2FD_prolly_draw_credits_entry( GUIFont *pSecondFont, int uFrameX, int uFrameY, unsigned int w, unsigned int h, unsigned __int16 firstColor, unsigned __int16 secondColor, const char *pString, @@ -110,8 +108,6 @@ } } - - //----- (0044D1E7) -------------------------------------------------------- void GUIFont::DrawTextLine( unsigned int uDefaultColor, signed int uX, signed int uY, const char *text, int max_len_pix ) @@ -649,5 +645,5 @@ //----- (00414174) -------------------------------------------------------- void uGameUIFontShadow_initialize() { - uGameUIFontShadow = Color16(0xE6u, 214u, 193u); + uGameUIFontShadow = Color16(0xE6u, 214, 193); } \ No newline at end of file diff -r 90f56da08d76 -r 8193a64c7461 GUIProgressBar.cpp --- a/GUIProgressBar.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/GUIProgressBar.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -60,7 +60,7 @@ } while ( v4 <= 5 ); if ( v5 == 5 ) - memset(&field_10, 0, 8u); + memset(&field_10, 0, 8); v7 = rand() % 5 + 1; if ( *(&field_10 + v7) == 1 ) { @@ -125,48 +125,41 @@ //----- (004435CD) -------------------------------------------------------- void GUIProgressBar::Progress() { - unsigned __int8 v1; // al@1 - ++this->uProgressCurrent; - v1 = this->uProgressMax; - if ( this->uProgressCurrent > v1 ) - this->uProgressCurrent = v1; + if ( this->uProgressCurrent > this->uProgressMax ) + this->uProgressCurrent = this->uProgressMax; Draw(); } //----- (004435E2) -------------------------------------------------------- void GUIProgressBar::Release() { - GUIProgressBar *v1; // esi@1 - char v2; // al@5 int v3; // edi@7 - v1 = this; - if ( v1->uType == 1 ) + if ( this->uType == 1 ) { - if ( !v1->pLoadingBg.pPixels ) + if ( !this->pLoadingBg.pPixels ) return; - v2 = v1->uProgressMax; - if ( v1->uProgressCurrent != v2 ) + if ( this->uProgressCurrent != this->uProgressMax ) { - v1->uProgressCurrent = v2 - 1; + this->uProgressCurrent = this->uProgressMax - 1; Progress(); } - free(v1->pLoadingBg.pPixels); - v3 = (int)&v1->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask; - free(v1->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask); - free(v1->pLoadingProgress.pPalette16); - v1->pLoadingProgress.pPalette16 = 0; - v1->pLoadingBg.pPixels = 0; + free(this->pLoadingBg.pPixels); + v3 = (int)&this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask; + free(this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask); + free(this->pLoadingProgress.pPalette16); + this->pLoadingProgress.pPalette16 = 0; + this->pLoadingBg.pPixels = 0; } else { - if ( !v1->pBardata.pLevelOfDetail0_prolly_alpha_mask ) + if ( !this->pBardata.pLevelOfDetail0_prolly_alpha_mask ) return; - free(v1->pBardata.pLevelOfDetail0_prolly_alpha_mask); - v3 = (int)&v1->pBardata.pPalette16; - free(v1->pBardata.pPalette16); - v1->pBardata.pLevelOfDetail0_prolly_alpha_mask = 0; + free(this->pBardata.pLevelOfDetail0_prolly_alpha_mask); + v3 = (int)&this->pBardata.pPalette16; + free(this->pBardata.pPalette16); + this->pBardata.pLevelOfDetail0_prolly_alpha_mask = 0; } *(int *)v3 = 0; } @@ -179,7 +172,7 @@ { if (pBardata.pLevelOfDetail0_prolly_alpha_mask) { - pRenderer->Sub01(); + pRenderer->Sub01(); pRenderer->DrawTextureIndexed(80, 122, &pBardata);// pRenderer->DrawTextureTransparent(100, 146, &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconID_TurnHour, 0)->uTextureID]); diff -r 90f56da08d76 -r 8193a64c7461 GUIWindow.cpp --- a/GUIWindow.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/GUIWindow.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -80,41 +80,27 @@ uNumMessages = pMessages[0].field_8 != 0; } - //----- (004356B9) -------------------------------------------------------- void GUIMessageQueue::PopMessage(enum UIMessageType *pType, int *pParam, int *a4) { - signed int v4; // edx@1 - GUIMessage *v5; // eax@2 - - v4 = 0; if ( this->uNumMessages ) { - v5 = this->pMessages; *pType = this->pMessages[0].eType; *pParam = this->pMessages[0].param; *a4 = this->pMessages[0].field_8; if ( (signed int)(this->uNumMessages - 1) > 0 ) { - do + for ( uint i = 0; i < (signed int)(this->uNumMessages - 1); ++i ) { - v5->eType = v5[1].eType; - v5->param = v5[1].param; - v5->field_8 = v5[1].field_8; - ++v4; - ++v5; + this->pMessages[i].eType = this->pMessages[i + 1].eType; + this->pMessages[i].param = this->pMessages[i + 1].param; + this->pMessages[i].field_8 = this->pMessages[i + 1].field_8; } - while ( v4 < (signed int)(this->uNumMessages - 1) ); } --this->uNumMessages; } } - - - - - //----- (0041B4E1) -------------------------------------------------------- int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall) { @@ -160,9 +146,6 @@ return result; } - - - //----- (0041B438) -------------------------------------------------------- GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey) { @@ -343,9 +326,7 @@ case WINDOW_null: return; default: - { break; - } } //v8 = this->pControlsHead; if ( this->pControlsHead ) @@ -373,11 +354,6 @@ uNumVisibleWindows = uNumVisibleWindows - 1; } - - - - - //----- (0041CD3B) -------------------------------------------------------- GUIButton *GUIWindow::GetControl(unsigned int uID) { @@ -647,30 +623,14 @@ void GUIWindow::DrawMessageBox(int arg0) { unsigned int v2; // edi@1 - GUIWindow *v3; // ebx@1 signed int v4; // esi@2 unsigned int v5; // eax@2 - unsigned int v6; // edx@4 - unsigned int v7; // ecx@6 - unsigned int v8; // eax@9 - __int32 v9; // eax@10 - unsigned int v10; // eax@18 - LONG v11; // ecx@18 - unsigned int v12; // edx@18 - unsigned int v13; // eax@18 - const char *v14; // ecx@18 - int v15; // eax@19 unsigned int v16; // esi@19 - const char *v17; // ebx@25 - int v18; // eax@26 - GUIWindow v19; // [sp+Ch] [bp-60h]@18 - POINT a2; // [sp+60h] [bp-Ch]@8 - unsigned int v21; // [sp+68h] [bp-4h]@18 + GUIWindow current_window; // [sp+Ch] [bp-60h]@18 + POINT cursor; // [sp+60h] [bp-Ch]@8 unsigned int v22; // [sp+74h] [bp+8h]@2 - unsigned int v23; // [sp+74h] [bp+8h]@18 v2 = 0; - v3 = this; if ( arg0 ) { v4 = pViewport->uViewportTL_X; @@ -684,108 +644,82 @@ v5 = window->GetWidth(); v22 = window->GetHeight(); } - v6 = this->uFrameX; + pMouse->GetCursorPos(&cursor); if ( (signed int)this->uFrameX >= v4 ) { - v7 = this->uFrameWidth; - if ( (signed int)(v7 + v6) <= (signed int)v5 ) - goto LABEL_9; - v3->uFrameX = v5 - v7; + if ( (signed int)(this->uFrameWidth + this->uFrameX) > (signed int)v5 ) + { + this->uFrameX = v5 - this->uFrameWidth; + this->uFrameY = cursor.y + 30; + } } else { this->uFrameX = v4; + this->uFrameY = cursor.y + 30; } - v3->uFrameY = pMouse->GetCursorPos(&a2)->y + 30; -LABEL_9: - v8 = v3->uFrameY; - if ( (signed int)v8 >= (signed int)v2 ) + + if ( (signed int)this->uFrameY >= (signed int)v2 ) { - if ( (signed int)(v8 + v3->uFrameHeight) <= (signed int)v22 ) - goto LABEL_14; - v9 = pMouse->GetCursorPos(&a2)->y - v3->uFrameHeight - 30; + if ( (signed int)(this->uFrameY + this->uFrameHeight) > (signed int)v22 ) + this->uFrameY = cursor.y - this->uFrameHeight - 30; } else - { - v9 = pMouse->GetCursorPos(&a2)->y + 30; - } - v3->uFrameY = v9; -LABEL_14: - if ( (signed int)v3->uFrameY < (signed int)v2 ) - v3->uFrameY = v2; - if ( (signed int)v3->uFrameX < v4 ) - v3->uFrameX = v4; - v10 = v3->uFrameWidth; - v11 = v3->uFrameX; - v12 = v3->uFrameY; - v21 = v10; - a2.y = v11; - v3->uFrameZ = v10 + v11 - 1; - v13 = v3->uFrameHeight; - v3->uFrameW = v13 + v12 - 1; - memcpy(&v19, v3, sizeof(v19)); - v19.uFrameX += 12; - v19.uFrameWidth -= 24; - v19.uFrameY += 12; - v19.uFrameHeight -= 12; - v19.uFrameZ = v19.uFrameWidth + v19.uFrameX - 1; - v23 = v12; - v19.uFrameW = v19.uFrameHeight + v19.uFrameY - 1; - v14 = v3->Hint; - if ( v14 ) - { - v15 = pFontLucida->CalcTextHeight(v14, &v19, 0, 0); - v12 = v23; - v16 = v15 + 24; - } + this->uFrameY = cursor.y + 30; + if ( (signed int)this->uFrameY < (signed int)v2 ) + this->uFrameY = v2; + if ( (signed int)this->uFrameX < v4 ) + this->uFrameX = v4; + this->uFrameZ = this->uFrameWidth + this->uFrameX - 1; + this->uFrameW = this->uFrameHeight + this->uFrameY - 1; + memcpy(¤t_window, this, sizeof(current_window)); + current_window.uFrameX += 12; + current_window.uFrameWidth -= 24; + current_window.uFrameY += 12; + current_window.uFrameHeight -= 12; + current_window.uFrameZ = current_window.uFrameWidth + current_window.uFrameX - 1; + current_window.uFrameW = current_window.uFrameHeight + current_window.uFrameY - 1; + if ( this->Hint ) + v16 = pFontLucida->CalcTextHeight(this->Hint, ¤t_window, 0, 0) + 24; else - { - v16 = v13; - } + v16 = this->uFrameHeight; if ( (signed int)v16 < 64 ) v16 = 64; - if ( (signed int)(v16 + v12) > 479 ) - v16 = 479 - v12; - DrawPopupWindow(a2.y, v12, v21, v16); - v17 = v3->Hint; - if ( v17 ) - { - v18 = pFontLucida->CalcTextHeight(v17, &v19, 0, 0); - v19.DrawTitleText(pFontLucida, 0, (signed int)(v16 - v18) / 2 - 14, 0, v17, 3); - } + if ( (signed int)(v16 + this->uFrameY) > 479 ) + v16 = 479 - this->uFrameY; + DrawPopupWindow(this->uFrameX, this->uFrameY, this->uFrameWidth, v16); + if ( this->Hint ) + current_window.DrawTitleText(pFontLucida, 0, (signed int)(v16 - pFontLucida->CalcTextHeight(this->Hint, ¤t_window, 0, 0)) / 2 - 14, 0, this->Hint, 3); } - - - //----- (00411B59) -------------------------------------------------------- void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer) { - unsigned int v2; // esi@1 - unsigned int v3; // edi@1 + //unsigned int v2; // esi@1 + //unsigned int v3; // edi@1 FILE *v4; // ebx@1 FILE *v5; // eax@2 char pContainerName[64]; // [sp+Ch] [bp-44h]@1 - unsigned int v7; // [sp+4Ch] [bp-4h]@1 + //unsigned int v7; // [sp+4Ch] [bp-4h]@1 - v2 = uSlot; - v7 = uPlayer; - v3 = uSlot + 1; + //v2 = uSlot; + //v7 = uPlayer; + //v3 = uSlot + 1; sprintf(pContainerName, "data\\lloyd%d%d.pcx", uPlayer, uSlot + 1); v4 = fopen(pContainerName, "rb"); if ( v4 ) { - pSavegameThumbnails[v2].LoadFromFILE(v4, 0, 1u); + pSavegameThumbnails[uSlot].LoadFromFILE(v4, 0, 1); fclose(v4); } else { - sprintf(pContainerName, "lloyd%d%d.pcx", v7, v3); + sprintf(pContainerName, "lloyd%d%d.pcx", uPlayer, uSlot + 1); v5 = pNew_LOD->FindContainer(pContainerName, 1); if ( v5 ) - pSavegameThumbnails[v2].LoadFromFILE(v5, 0, 0); + pSavegameThumbnails[uSlot].LoadFromFILE(v5, 0, 0); else - *((int *)&pSavegameThumbnails.data()->pPixels + 10 * v2) = 0; + *((int *)&pSavegameThumbnails.data()->pPixels + 10 * uSlot) = 0; } } @@ -900,9 +834,7 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } return; } if ( current_npc_text ) @@ -925,9 +857,7 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } return; } for ( v8 = 0; v8 < uNumDialogueNPCPortraits; ++v8 ) @@ -964,9 +894,7 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } return; } v4 = (char *)pDialogueNPCCount - 1; @@ -981,15 +909,11 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } return; } if ( v4 || !dword_591080 )// - { SimpleHouseDialog(); - } else { sprintfex( pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], @@ -1058,9 +982,7 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } } //----- (004B1854) -------------------------------------------------------- @@ -1117,13 +1039,11 @@ this->DrawTitleText(pFontArrus, 0, (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), this, 0, 0)) / 2 + 101, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3); } - - //----- (0044D406) -------------------------------------------------------- void GUIWindow::DrawTitleText( GUIFont *a2, signed int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing ) { - GUIWindow *pWindow; // esi@1 + //GUIWindow *pWindow; // esi@1 unsigned int v8; // ebx@1 char *v9; // eax@1 unsigned int v11; // edi@1 @@ -1132,14 +1052,14 @@ GUIFont *pFont; // [sp+Ch] [bp-4h]@1 const char *Stra; // [sp+24h] [bp+14h]@5 - pWindow = this; + //pWindow = this; pFont = a2; v8 = this->uFrameWidth - uHorizontalMargin; ui_current_text_color = uDefaultColor; v9 = FitTextInAWindow(pInString, a2, this, uHorizontalMargin, 0); Stra = strtok(v9, "\n"); - v11 = uHorizontalMargin + pWindow->uFrameX; - v12 = uVerticalMargin + pWindow->uFrameY; + v11 = uHorizontalMargin + this->uFrameX; + v12 = uVerticalMargin + this->uFrameY; while ( 1 ) { if ( !Stra ) @@ -1154,8 +1074,6 @@ } // 5C6DB4: using guessed type int ui_current_text_color; - - //----- (0044CE08) -------------------------------------------------------- void GUIWindow::DrawText( GUIFont *a2, signed int uX, int uY, unsigned int uFontColor, const char *Str, int a7, int a8, signed int uFontShadowColor ) { @@ -1202,9 +1120,7 @@ if ( !uX ) uX = 12; if ( a8 ) - { v32 = Str; - } else { v11 = (int)FitTextInAWindow(Str, v10, v9, uX, 0); @@ -1230,7 +1146,7 @@ switch ( (unsigned __int8)v11 ) { case 9u: - strncpy(Dest, &v32[v14 + 1], 3u); + strncpy(Dest, &v32[v14 + 1], 3); Dest[3] = 0; pInString += 3; v29 = atoi(Dest); @@ -1244,17 +1160,21 @@ v13 = uY + v31->uFrameY; v12 = uX + v29 + v31->uFrameX; if ( a8 ) - goto LABEL_36; + { + v11 = v11 + v13 - 3; + if ( v11 > a8 ) + return; + } break; case 0xCu: - strncpy(Dest, &v32[v14 + 1], 5u); + strncpy(Dest, &v32[v14 + 1], 5); Dest[5] = 0; v11 = atoi(Dest); pInString += 5; uFontColor = v11; break; case 0xDu: - strncpy(Dest, &v32[v14 + 1], 3u); + strncpy(Dest, &v32[v14 + 1], 3); Dest[3] = 0; pInString += 3; v18 = atoi(Dest); @@ -1264,7 +1184,6 @@ if ( a8 ) { v11 = LOBYTE(v10->uFontHeight); -LABEL_36: v11 = v11 + v13 - 3; if ( v11 > a8 ) return; @@ -1285,24 +1204,11 @@ v12 += v10->pMetrics[v15].uLeftSpacing; v17 = (int)((char *)&v10[1] + v10->font_pixels_offset[v15]); if ( (short)uFontColor ) - pRenderer->DrawText( - v12, - v13, - (unsigned __int8 *)v17, - v16, - LOBYTE(v10->uFontHeight), - v10->pFontPalettes[0], - uFontColor, - uFontShadowColor); + pRenderer->DrawText(v12, v13, (unsigned __int8 *)v17, v16, LOBYTE(v10->uFontHeight), + v10->pFontPalettes[0], uFontColor, uFontShadowColor); else - pRenderer->DrawTextPalette( - v12, - v13, - (unsigned char*)v17, - v16, - LOBYTE(v10->uFontHeight), - v10->pFontPalettes[0], - a7); + pRenderer->DrawTextPalette(v12, v13, (unsigned char*)v17, v16, LOBYTE(v10->uFontHeight), + v10->pFontPalettes[0], a7); LOBYTE(v11) = v30; v12 += v28; if ( (signed int)pInString < (signed int)v30 ) @@ -1325,8 +1231,7 @@ //----- (0044CB4F) -------------------------------------------------------- int GUIWindow::DrawTextInRect( GUIFont *pFont, unsigned int uX, unsigned int uY, unsigned int uColor, const char *text, int rect_width, int reverse_text ) - { - +{ int pLineWidth; // ebx@1 int text_width; // esi@3 unsigned __int8 v12; // cl@7 @@ -1368,7 +1273,7 @@ if ( reverse_text ) _strrev(pTmpBuf2.data()); Str1a = 0; - for (i=0; i= rect_width ) break; @@ -1390,7 +1295,7 @@ text_width += pFont->pMetrics[v12].uWidth; if ( i < pNumLen ) text_width += pFont->pMetrics[v12].uRightSpacing; - } + } } } pTmpBuf2[i - 1] = 0; @@ -1456,10 +1361,8 @@ v13 += v20; if ( i < (signed int)pNumLen ) v13 += pFont->pMetrics[v15].uRightSpacing; - } + } } - - } return v28; } @@ -1528,7 +1431,7 @@ //----- (0041C432) -------------------------------------------------------- GUIWindow * GUIWindow::Create( unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eWindowType, int pButton, const char* hint ) - { +{ unsigned int uNextFreeWindowID; // ebp@1 //int *v8; // eax@1 //GUIWindow *pWindow; // esi@4 @@ -1665,9 +1568,7 @@ pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, UIMSG_SelectNPCDialogueOption, 0x4Cu, 0, pTmpBuf.data(), 0); } else - { pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, UIMSG_SelectNPCDialogueOption, 0x4Cu, 0, pGlobalTXT_LocalizationStrings[406], 0);// - } num_menu_buttons = 2; } } @@ -1675,7 +1576,8 @@ } break; } - case WINDOW_ChangeLocation: { + case WINDOW_ChangeLocation: + { pMainScreenNum = pCurrentScreen; pCurrentScreen = SCREEN_CHANGE_LOCATION; pBtn_ExitCancel = pWindow->CreateButton( 566, 445, 75, 33, 1, 0, UIMSG_CHANGE_LOCATION_ClickCencelBtn, 0, 'N', pGlobalTXT_LocalizationStrings[156], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);// @@ -1683,7 +1585,7 @@ pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63, 73, 1, 0, UIMSG_OnTravelByFoot, 1, ' ', pWindow->Hint, 0, 0, 0); pWindow->CreateButton( 8, 8, 460, 344, 1, 0, UIMSG_OnTravelByFoot, 1, 0, pWindow->Hint, 0); break; - } + } case WINDOW_SpellBook: {// InitializeBookTextures(); pWindow->OpenSpellBook(); @@ -1700,11 +1602,11 @@ return pWindow; } //LABEL_62: - pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, '1', "", 0); - pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, '2', "", 0); - pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, '3', "", 0); - pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, '4', "", 0); - pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0); + pWindow->CreateButton(61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + pWindow->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + pWindow->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + pWindow->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9, "", 0); return pWindow; } if (eWindowType == WINDOW_HouseInterior) @@ -1927,9 +1829,7 @@ if ( pParty->PartyTimes._shop_ban_times[window_SpeakInHouse->par1C] <=pParty->uTimePlayed ) { if ( window_SpeakInHouse->par1C < 53 ) - { pParty->PartyTimes._shop_ban_times[window_SpeakInHouse->par1C] = 0; - } continue; } pNumMessages = pMessageQueue_50CBD0->uNumMessages; @@ -2212,9 +2112,7 @@ continue; } default: - { continue; - } } } if ( GetCurrentMenuID() == -1 ) @@ -2255,9 +2153,6 @@ Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3); } - - - int modal_window_prev_screen; //----- (004141CA) -------------------------------------------------------- @@ -2299,10 +2194,9 @@ //----- (00467FB6) -------------------------------------------------------- void CreateScrollWindow() - { +{ unsigned int v0; // eax@1 char *v1; // ST18_4@3 - unsigned int v2; // eax@3 GUIWindow a1; // [sp+Ch] [bp-54h]@1 memcpy(&a1, pGUIWindow_ScrollWindow, sizeof(a1)); @@ -2311,8 +2205,7 @@ a1.uFrameY = 1; a1.uFrameWidth = 468; v0 = pFontSmallnum->CalcTextHeight(pScrolls[pGUIWindow_ScrollWindow->par1C], &a1, 0, 0) - + 2 * LOBYTE(pFontCreate->uFontHeight) - + 24; + + 2 * LOBYTE(pFontCreate->uFontHeight) + 24; a1.uFrameHeight = v0; if ( (signed int)(v0 + a1.uFrameY) > 479 ) { @@ -2329,31 +2222,20 @@ a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1; a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName; - v2 = Color16(0xFFu, 0xFFu, 0x9Bu); - sprintf(pTmpBuf.data(), format_4E2D80, v2, v1); - a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3u); - a1.DrawText( - pFontSmallnum, - 1, - LOBYTE(pFontCreate->uFontHeight) - 3, - 0, - pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], - 0, - 0, - 0); + sprintf(pTmpBuf.data(), format_4E2D80, Color16(0xFFu, 0xFFu, 0x9Bu), v1); + a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3); + a1.DrawText(pFontSmallnum, 1, LOBYTE(pFontCreate->uFontHeight) - 3, 0, + pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], 0, 0, 0); } //----- (00467F48) -------------------------------------------------------- void CreateMsgScrollWindow( signed int mscroll_id ) - { - signed int v1; // esi@1 - - v1 = mscroll_id; +{ if ( !pGUIWindow_ScrollWindow && mscroll_id >= 700 ) { if ( mscroll_id <= 782 ) { uTextureID_720980 = pIcons_LOD->LoadTexture("leather", TEXTURE_16BIT_PALETTE); - pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Scroll, v1 - 700, 0); + pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Scroll, mscroll_id - 700, 0); } } } diff -r 90f56da08d76 -r 8193a64c7461 Game.cpp --- a/Game.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/Game.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -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; @@ -2987,7 +2984,7 @@ { if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) ) continue; - v173 = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName; + v173 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName; sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s" GameUI_SetFooterString(pTmpBuf.data()); continue; @@ -3002,7 +2999,7 @@ GameUI_SetFooterString(pTmpBuf.data()); continue; } - v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName; + v174 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName; sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], (unsigned int)pMapName, v174);// "Set %s over %s" GameUI_SetFooterString(pTmpBuf.data()); continue; diff -r 90f56da08d76 -r 8193a64c7461 GammaControl.cpp --- a/GammaControl.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/GammaControl.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -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 90f56da08d76 -r 8193a64c7461 IconFrameTable.cpp --- a/IconFrameTable.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/IconFrameTable.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -7,83 +7,44 @@ //----- (00494F3A) -------------------------------------------------------- unsigned int IconFrameTable::FindIcon(const char *pIconName) { - IconFrameTable *v2; // esi@1 - int v3; // ebx@1 - unsigned int uID; // edi@1 - unsigned int result; // eax@4 - - v2 = this; - v3 = 0; - uID = 0; - if ( (signed int)this->uNumIcons <= 0 ) + for ( uint i = 0; i < (signed int)this->uNumIcons; i++ ) { -LABEL_4: - result = 0; + if ( !_stricmp(pIconName, this->pIcons[i].pAnimationName) ) + return i; } - else - { - while ( _stricmp(pIconName, v2->pIcons[v3].pAnimationName) ) - { - ++uID; - ++v3; - if ( (signed int)uID >= (signed int)v2->uNumIcons ) - goto LABEL_4; - } - result = uID; - } - return result; + return 0; } //----- (00494F70) -------------------------------------------------------- IconFrame *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int uFrameID) { - //IconFrame *v3; // edi@1 - IconFrame *v4; // ecx@1 - //__int16 v5; // dx@2 int v6; // edx@3 - //unsigned int v7; // eax@3 - char *i; // ecx@3 - int v9; // esi@5 - IconFrame *result; // eax@6 + uint i; - v4 = &this->pIcons[uIconID]; - if ( v4->uFlags & 1 && v4->uAnimLength != 0 ) + if ( this->pIcons[uIconID].uFlags & 1 && this->pIcons[uIconID].uAnimLength != 0 ) { - v6 = ((signed int)uFrameID >> 3) % (unsigned __int16)v4->uAnimLength; - for ( i = (char *)&v4->uAnimTime; ; i += 32 ) - { - v9 = *(short *)i; - if ( v6 <= v9 ) - break; - v6 -= v9; - ++uIconID; - } - result = &this->pIcons[uIconID]; + v6 = ((signed int)uFrameID >> 3) % (unsigned __int16)this->pIcons[uIconID].uAnimLength; + for ( i = uIconID; v6 > this->pIcons[i].uAnimTime; i++ ) + v6 -= this->pIcons[i].uAnimTime; + return &this->pIcons[i]; } else - { - result = &this->pIcons[uIconID]; - } - return result; + return &this->pIcons[uIconID]; } //----- (00494FBF) -------------------------------------------------------- void IconFrameTable::InitializeAnimation(unsigned int uIconID) { - IconFrameTable *v2; // esi@1 unsigned int v3; // edi@3 const char *i; // eax@3 - IconFrame *v5; // eax@5 - v2 = this; if ( (signed int)uIconID <= (signed int)this->uNumIcons && (uIconID & 0x80000000u) == 0 ) { v3 = uIconID; - for ( i = this->pIcons[uIconID].pTextureName; ; i = v5[v3].pTextureName ) + for ( i = this->pIcons[uIconID].pTextureName; ; i = this->pIcons[v3].pTextureName ) { - v2->pIcons[v3].uTextureID = pIcons_LOD->LoadTexture(i, TEXTURE_16BIT_PALETTE); - v5 = v2->pIcons; - if ( !(v5[v3].uFlags & 1) ) + this->pIcons[v3].uTextureID = pIcons_LOD->LoadTexture(i, TEXTURE_16BIT_PALETTE); + if ( !(this->pIcons[v3].uFlags & 1) ) break; ++v3; } @@ -93,20 +54,20 @@ //----- (0049500A) -------------------------------------------------------- void IconFrameTable::ToFile() { - IconFrameTable *v1; // esi@1 + //IconFrameTable *v1; // esi@1 FILE *v2; // eax@1 - FILE *v3; // edi@1 + //FILE *v3; // edi@1 - IconFrameTable* Str = this; + //IconFrameTable* Str = this; - v1 = Str; + //v1 = Str; v2 = fopen("data\\dift.bin", "wb"); - v3 = v2; + //v3 = v2; if ( !v2 ) Error("Unable to save dift.bin!"); - fwrite(v1, 4u, 1u, v2); - fwrite(v1->pIcons, 0x20u, v1->uNumIcons, v3); - fclose(v3); + fwrite(this, 4, 1, v2); + fwrite(this->pIcons, 0x20u, this->uNumIcons, v2); + fclose(v2); } //----- (00495056) -------------------------------------------------------- @@ -129,7 +90,7 @@ //----- (0049509D) -------------------------------------------------------- int IconFrameTable::FromFileTxt(const char *Args) { - IconFrameTable *v2; // ebx@1 + //IconFrameTable *v2; // ebx@1 FILE *v3; // eax@1 int v4; // esi@3 void *v5; // eax@10 @@ -153,8 +114,9 @@ FILE *File; // [sp+300h] [bp-4h]@1 int Argsa; // [sp+30Ch] [bp+8h]@26 - v2 = this; + //v2 = this; //TileTable::dtor((TileTable *)this); + __debugbreak();//Ritor1: this function not used v3 = fopen(Args, "r"); File = v3; if ( !v3 ) @@ -179,13 +141,13 @@ while ( fgets(&Buf, 490, File) ); v4 = v21; } - v2->uNumIcons = v4; + this->uNumIcons = v4; v5 = malloc(32 * v4);//, "I Frames"); - v2->pIcons = (IconFrame *)v5; + this->pIcons = (IconFrame *)v5; if ( v5 ) { v6 = File; - v2->uNumIcons = 0; + this->uNumIcons = 0; fseek(v6, 0, 0); for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) { @@ -193,38 +155,38 @@ memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); if ( v20.uPropCount && *v20.pProperties[0] != 47 ) { - strcpy(v2->pIcons[v2->uNumIcons].pAnimationName, v20.pProperties[0]); - strcpy(v2->pIcons[v2->uNumIcons].pTextureName, v20.pProperties[1]); + strcpy(this->pIcons[this->uNumIcons].pAnimationName, v20.pProperties[0]); + strcpy(this->pIcons[this->uNumIcons].pTextureName, v20.pProperties[1]); v8 = v20.pProperties[2]; - v2->pIcons[v2->uNumIcons].uFlags = 0; + this->pIcons[this->uNumIcons].uFlags = 0; if ( !_stricmp(v8, "new") ) { - v9 = (int)&v2->pIcons[v2->uNumIcons].uFlags; + v9 = (int)&this->pIcons[this->uNumIcons].uFlags; *(char *)v9 |= 4u; } - v2->pIcons[v2->uNumIcons].uAnimTime = atoi(v20.pProperties[3]); - v2->pIcons[v2->uNumIcons].uAnimLength = 0; - v2->pIcons[v2->uNumIcons++].uTextureID = 0; + this->pIcons[this->uNumIcons].uAnimTime = atoi(v20.pProperties[3]); + this->pIcons[this->uNumIcons].uAnimLength = 0; + this->pIcons[this->uNumIcons++].uTextureID = 0; } } fclose(File); v10 = 0; - if ( (signed int)(v2->uNumIcons - 1) > 0 ) + if ( (signed int)(this->uNumIcons - 1) > 0 ) { v11 = 0; do { - v12 = (int)&v2->pIcons[v11]; + v12 = (int)&this->pIcons[v11]; if ( !(*(char *)(v12 + 60) & 4) ) *(char *)(v12 + 28) |= 1u; ++v10; ++v11; } - while ( v10 < (signed int)(v2->uNumIcons - 1) ); + while ( v10 < (signed int)(this->uNumIcons - 1) ); } - for ( j = 0; j < (signed int)v2->uNumIcons; *(short *)(Argsa + 26) = v15 ) + for ( j = 0; j < (signed int)this->uNumIcons; *(short *)(Argsa + 26) = v15 ) { - v14 = v2->pIcons; + v14 = this->pIcons; Argsa = (int)&v14[j]; v15 = *(short *)(Argsa + 24); if ( *(char *)(Argsa + 28) & 1 ) diff -r 90f56da08d76 -r 8193a64c7461 Indoor.cpp --- a/Indoor.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/Indoor.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -93,18 +93,9 @@ //----- (0043F39E) -------------------------------------------------------- void __fastcall PrepareDrawLists_BLV() { - //int *v1; // ecx@1 - //double v2; // ST30_8@3 - //double v3; // ST30_8@6 - //double v4; // ST28_8@6 int v5; // eax@4 - //int v6; // eax@7 unsigned int v7; // ebx@8 BLVSector *v8; // esi@8 - //unsigned __int16 *v9; // edi@8 - //int i; // [sp+18h] [bp-8h]@7 - //unsigned __int8 v11; // [sp+1Ch] [bp-4h]@3 - //signed int v12; // [sp+1Ch] [bp-4h]@8 pBLVRenderParams->Reset(); pMobileLightsStack->uNumLightsActive = 0; @@ -137,46 +128,25 @@ PrepareItemsRenderList_BLV(); PrepareActorRenderList_BLV(); - //v6 = 0; for (uint i = 0; i < pBspRenderer->uNumVisibleNotEmptySectors; ++i) { v7 = pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[i]; - //v12 = 0; v8 = &pIndoor->pSectors[pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[i]]; - //v9 = v8->pDecorationIDs; for (uint j = 0; j < v8->uNumDecorations; ++j) - //if ( v8->uNumDecorations > 0 ) - { - // do PrepareDecorationsRenderList_BLV(v8->pDecorationIDs[j], v7); - // while ( v12 < v8->uNumDecorations ); - } - //v6 = i + 1; } FindBillboardsLightLevels_BLV(); pGame->PrepareBloodsplats(); } - - //----- (004407D9) -------------------------------------------------------- void BLVRenderParams::Reset() { - //IndoorLocation_drawstru *v2; // ebx@1 - //int v4; // ST08_4@1 - //int v5; // ST04_4@1 - //int v6; // ST00_4@1 int v7; // eax@1 int v8; // ST08_4@2 int v9; // ST04_4@2 int v10; // ST00_4@2 - //unsigned int v11; // edi@4 - //unsigned int v12; // ecx@4 - //int v13; // edx@4 - //signed int v14; // ecx@4 - //unsigned int v15; // edx@4 - //unsigned int v16; // eax@4 double v17; // st7@5 int v18; // eax@5 double v19; // st7@5 @@ -188,7 +158,6 @@ int v25; // eax@5 int v26; // eax@5 signed int v27; // eax@6 - //int result; // eax@6 int v29; // [sp+24h] [bp+8h]@5 this->field_0_timer_ = pEventTimer->uTotalGameTimeElapsed; @@ -295,21 +264,17 @@ //----- (00440B44) -------------------------------------------------------- void IndoorLocation::ExecDraw(bool bD3D) { - int v2; // eax@3 - //IndoorCameraD3D_Vec4 *v3; // edx@4 - //unsigned int v5; // ecx@9 - //RenderVertexSoft *v6; // [sp-4h] [bp-8h]@4 - if (bD3D) { pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); for (uint i = 0; i < pBspRenderer->num_faces; ++i) { - //v2 = pBspRenderer->faces[i].uNodeID; if (pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].viewing_portal_id == -1) IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, nullptr, 4, nullptr); else - IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].std__vector_0007AC, 4, pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].pPortalBounding); + IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, + pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].std__vector_0007AC, 4, + pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].pPortalBounding); } } else for (uint j = 0; j < pBspRenderer->num_faces; ++j ) @@ -373,9 +338,6 @@ } */ - - - //----- (00441BD4) -------------------------------------------------------- void IndoorLocation::Draw() { @@ -870,9 +832,7 @@ return true; } else - { return false; - } } //----- (00444810) -------------------------------------------------------- @@ -895,8 +855,8 @@ if ( bToggle ) pIndoor->pLights[sLightID].uAtributes &= 0xFFFFFFF7u; else - pIndoor->pLights[sLightID].uAtributes |= 8u; - pParty->uFlags |= 2u; + pIndoor->pLights[sLightID].uAtributes |= 8; + pParty->uFlags |= 2; } } @@ -1958,7 +1918,7 @@ //v201 = pFilename; *(int *)pDest = 1; File = pGames_LOD->FindContainer(pFilename, 0); - fread(&header, 0x10u, 1u, File); + fread(&header, 0x10u, 1, File); uint v155 = header.uCompressedSize; uint Count = header.uDecompressedSize; BLVFace* Src = (BLVFace *)malloc(header.uDecompressedSize); @@ -1966,9 +1926,7 @@ if ( v155 <= Count ) { if ( v155 == Count ) - { fread(Src, 1, Count, File); - } else { void* _uSourceLen = malloc(v155); @@ -1978,9 +1936,7 @@ } } else - { - MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1195", 0); - } + MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1195", 0); pData = ((char *)Src + 40); //v154 = 875; goto LABEL_140; @@ -2375,7 +2331,6 @@ v4 = v43[0]; if ( v55 == 1 ) return this->pFaces[v4].uSectorID; - v37 = 0; if ( !v55 ) return 0; pSectorID = 0; @@ -2383,38 +2338,25 @@ if ( v55 > 0 ) { v39 = sY; - while ( 1 ) + for ( v37 = 0; v37 < v55; ++v37 ) { - pFace = &this->pFaces[v43[v37]]; - //pPolygonType = pFace->uPolygonType; - if ( pFace->uPolygonType == POLYGON_Floor ) + if ( this->pFaces[v43[v37]].uPolygonType == POLYGON_Floor ) + v39 = sZ - this->pVertices[*this->pFaces[v43[v37]].pVertexIDs].z; + if ( this->pFaces[v43[v37]].uPolygonType == POLYGON_InBetweenFloorAndWall ) { - v42 = this->pVertices[*pFace->pVertexIDs].z; - v39 = sZ - v42; - //goto LABEL_47; + v39 = sZ - ((fixpoint_mul(this->pFaces[v43[v37]].zCalc1, (sX << 16)) + + fixpoint_mul(this->pFaces[v43[v37]].zCalc2, (sY << 16)) + + this->pFaces[v43[v37]].zCalc3 + + 0x8000) >> 16); } - if ( pFace->uPolygonType == POLYGON_InBetweenFloorAndWall ) - { - //v51 = pFace->zCalc1; - v57 = fixpoint_mul(pFace->zCalc1, (sX << 16)); - //v56 = sY << 16; - //v51 = pFace->zCalc2; - v56 = fixpoint_mul(pFace->zCalc2, (sY << 16)); - v42 = (v56 + pFace->zCalc3 + v57 + 32768) >> 16; - v39 = sZ - v42; - } -//LABEL_47: if ( v39 >= 0 ) { if ( v39 < v53 ) { - pSectorID = pFace->uSectorID; + pSectorID = this->pFaces[v43[v37]].uSectorID; v53 = v39; } } - ++v37; - if ( v37 >= v55 ) - return pSectorID; } } return pSectorID; @@ -2498,7 +2440,7 @@ //----- (0044C23B) -------------------------------------------------------- bool BLVFaceExtra::HasEventint() - { +{ signed int event_index; // eax@1 _evt_raw* start_evt; _evt_raw* end_evt; @@ -2548,8 +2490,6 @@ unsigned __int16 v50; // ax@48 unsigned int v51; // eax@51 unsigned __int16 v52; // ax@54 - int v53; // ecx@57 - unsigned __int64 v55; // qax@57 int v56; // ecx@58 int v57; // eax@58 Vec3_int_ v67; @@ -2650,7 +2590,11 @@ v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16; v31 = (v85 + v83 + v84) * (signed __int64)v29; v32 = v31 >> 16; - goto LABEL_58; + v57 = -v32; + v28->sTextureDeltaV = v57; + v28->sTextureDeltaU += door->pDeltaUs[v88]; + v28->sTextureDeltaV = v57 + door->pDeltaVs[v88]; + continue; }*/ v28->sTextureDeltaU = 0; v28->sTextureDeltaV = 0; @@ -2696,7 +2640,7 @@ v28->sTextureDeltaV -= v40; else { - if ( face->uAttributes & 0x20000 ) + if ( face->uAttributes & FACE_UNKNOW7 ) { if ( face->uBitmapID != -1 ) v28->sTextureDeltaV -= v82 + pBitmaps_LOD->GetTexture(face->uBitmapID)->uTextureHeight; @@ -2708,16 +2652,13 @@ v82 = fixpoint_mul(door->vDirection.y, v70.y); v83 = fixpoint_mul(door->vDirection.z, v70.z); v75 = v84 + v82 + v83; - v53 = v89; v82 = fixpoint_mul(v75, v89); v28->sTextureDeltaU = -v82; v84 = fixpoint_mul(door->vDirection.x, v67.x); v82 = fixpoint_mul(door->vDirection.y, v67.y); v83 = fixpoint_mul(door->vDirection.z, v67.z); v75 = v84 + v82 + v83; - v55 = v75 * (signed __int64)v53; - v32 = v55 >> 16; -LABEL_58: + v32 = fixpoint_mul(v75, v89); v57 = -v32; v28->sTextureDeltaV = v57; v28->sTextureDeltaU += door->pDeltaUs[v88]; diff -r 90f56da08d76 -r 8193a64c7461 Items.cpp --- a/Items.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/Items.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -1,5 +1,6 @@ #define _CRT_SECURE_NO_WARNINGS #include +#include #include "Items.h" #include "MapInfo.h" @@ -14,6 +15,22 @@ #include "texts.h" #include "mm7_data.h" +struct ci_less : std::binary_function +{ + // case-independent (ci) compare_less binary function + struct nocase_compare : public std::binary_function + { + bool operator() (const unsigned char& c1, const unsigned char& c2) const { + return tolower (c1) < tolower (c2); + } + }; + bool operator() (const std::string & s1, const std::string & s2) const { + return std::lexicographical_compare + (s1.begin (), s1.end (), // source range + s2.begin (), s2.end (), // dest range + nocase_compare ()); // comparison + } +}; struct ITEM_VARIATION @@ -309,15 +326,55 @@ //----- (00456D84) -------------------------------------------------------- void ItemsTable::Initialize() - { +{ + std::map equipStatMap; + equipStatMap["weapon"] = EQUIP_SINGLE_HANDED; + equipStatMap["weapon2"] = EQUIP_TWO_HANDED; + equipStatMap["weapon1or2"] = EQUIP_SINGLE_HANDED; + equipStatMap["missile"] = EQUIP_BOW; + equipStatMap["bow"] = EQUIP_BOW; + equipStatMap["armor"] = EQUIP_ARMOUR; + equipStatMap["shield"] = EQUIP_SHIELD; + equipStatMap["helm"] = EQUIP_HELMET; + equipStatMap["belt"] = EQUIP_BELT; + equipStatMap["cloak"] = EQUIP_CLOAK; + equipStatMap["gauntlets"] = EQUIP_GAUNTLETS; + equipStatMap["boots"] = EQUIP_BOOTS; + equipStatMap["ring"] = EQUIP_RING; + equipStatMap["amulet"] = EQUIP_AMULET; + equipStatMap["weaponw"] = EQUIP_WAND; + equipStatMap["herb"] = EQUIP_REAGENT; + equipStatMap["reagent"] = EQUIP_REAGENT; + equipStatMap["bottle"] = EQUIP_POTION; + equipStatMap["sscroll"] = EQUIP_SPELL_SCROLL; + equipStatMap["book"] = EQUIP_BOOK; + equipStatMap["mscroll"] = EQUIP_MESSAGE_SCROLL; + equipStatMap["gold"] = EQUIP_GOLD; + equipStatMap["gem"] = EQUIP_GEM; + + std::map equipSkillMap; + equipSkillMap["staff"] = PLAYER_SKILL_STAFF; + equipSkillMap["sword"] = PLAYER_SKILL_SWORD; + equipSkillMap["dagger"] = PLAYER_SKILL_DAGGER; + equipSkillMap["axe"] = PLAYER_SKILL_AXE; + equipSkillMap["spear"] = PLAYER_SKILL_SPEAR; + equipSkillMap["bow"] = PLAYER_SKILL_BOW; + equipSkillMap["mace"] = PLAYER_SKILL_MACE; + equipSkillMap["blaster"] = PLAYER_SKILL_BLASTER; + equipSkillMap["shield"] = PLAYER_SKILL_SHIELD; + equipSkillMap["leather"] = PLAYER_SKILL_LEATHER; + equipSkillMap["chain"] = PLAYER_SKILL_CHAIN; + equipSkillMap["plate"] = PLAYER_SKILL_PLATE; + equipSkillMap["club"] = PLAYER_SKILL_CLUB; + + std::map materialMap; + materialMap["artifact"] = MATERIAL_ARTEFACT; + materialMap["relic"] = MATERIAL_RELIC; + materialMap["special"] = MATERIAL_SPECIAL; + int i,j; - char* test_string; - unsigned char c; - bool break_loop; - unsigned int temp_str_len; - char* tmp_pos; - int decode_step; - int item_counter; + char* test_string; + int item_counter; pMapStats = new MapStats; pMapStats->Initialize(); @@ -348,44 +405,14 @@ for (i=0;i<24;++i) { test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (decode_step) - { - case 0: - pEnchantments[i].pBonusStat=RemoveQuotes(test_string); - break; - case 1: - pEnchantments[i].pOfName= RemoveQuotes(test_string); - break; - default: - pEnchantments[i].to_item[decode_step-2]=atoi(test_string); - } - } - else - { - if (decode_step) - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<11)&&!break_loop); - } + auto tokens = Tokenize(test_string, '\t'); + pEnchantments[i].pBonusStat=RemoveQuotes(tokens[0]); + pEnchantments[i].pOfName=RemoveQuotes(tokens[1]); + for (int j = 0; j < 9; j++) + { + pEnchantments[i].to_item[j]=atoi(tokens[j+2]); + } + } memset(&pEnchantmentsSumm, 0, 36); for(i=0;i<9;++i) @@ -401,31 +428,13 @@ strtok(NULL, "\r"); strtok(NULL, "\r"); for(i=0;i<6;++i) //counted from 1 - { - test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (decode_step==2) - bonus_ranges[i].minR = atoi(test_string); - else if (decode_step==3) - bonus_ranges[i].maxR =atoi(test_string); - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<4)&&!break_loop); - } + { + test_string = strtok(NULL, "\r") + 1; + auto tokens = Tokenize(test_string, '\t'); + Assert(tokens.size() == 4, "Invalid number of tokens"); + bonus_ranges[i].minR = atoi(tokens[2]); + bonus_ranges[i].maxR =atoi(tokens[3]); + } pSpcItemsTXT_Raw = 0; @@ -435,67 +444,34 @@ strtok(NULL, "\r"); strtok(NULL, "\r"); for (i=0;i<72;++i) - { - test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (decode_step) - { - case 0: - pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(test_string); - break; - case 1: - pSpecialEnchantments[i].pNameAdd= RemoveQuotes(test_string); - break; - case 14: - int res; - res=atoi(test_string); - if(!res) - { - ++test_string; - while (*test_string==' ')//fix X 2 case - ++test_string; - res=atoi(test_string); - } - pSpecialEnchantments[i].iValue=res; - break; - case 15: - pSpecialEnchantments[i].iTreasureLevel= tolower(*test_string) - 97;; - break; - default: - pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string); - } - } - else - { - if (decode_step) - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<16)&&!break_loop); - } + { + test_string = strtok(NULL, "\r") + 1; + auto tokens = Tokenize(test_string, '\t'); + Assert(tokens.size() >= 17, "Invalid number of tokens"); + pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(tokens[0]); + pSpecialEnchantments[i].pNameAdd= RemoveQuotes(tokens[1]); + for (int j = 0; j < 12; j++) + { + pSpecialEnchantments[i].to_item_apply[j]=atoi(tokens[j+2]); + } + int res; + res=atoi(tokens[14]); + if(!res) + { + ++tokens[14]; + while (*tokens[14]==' ')//fix X 2 case + ++tokens[14]; + res=atoi(tokens[14]); + } + pSpecialEnchantments[i].iValue=res; + pSpecialEnchantments[i].iTreasureLevel= tolower(tokens[15][0]) - 97; + } pSpecialEnchantments_count = 71; memset(&pSpecialEnchantmentsSumm, 0, 96); for(i=0;i<12;++i) { - for (j=0;j<=pSpecialEnchantments_count;++j) + for (unsigned int j=0;j<=pSpecialEnchantments_count;++j) pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i]; } @@ -507,346 +483,81 @@ strtok(NULL, "\r"); uAllItemsCount = 0; item_counter = 0; - while (true) + while (item_counter < 800) { test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (decode_step) - { - case 0: //Item # - item_counter=atoi(test_string); - uAllItemsCount=item_counter; - break; - case 1: //Pic File - pItems[item_counter].pIconName = RemoveQuotes(test_string); - break; - case 2: //Name - pItems[item_counter].pName = RemoveQuotes(test_string); - break; - case 3: //Value - pItems[item_counter].uValue=atoi(test_string); - break; - case 4: //Equip Stat - { - if ( !_stricmp(test_string, "weapon") ) - { - pItems[item_counter].uEquipType = EQUIP_SINGLE_HANDED; - break; - } - if ( !_stricmp(test_string, "weapon2") ) - { - pItems[item_counter].uEquipType = EQUIP_TWO_HANDED; - break; - } - if ( !_stricmp(test_string, "weapon1or2") ) - { - pItems[item_counter].uEquipType = EQUIP_SINGLE_HANDED; - break; - } - if ( !(_stricmp(test_string, "missile")&&_stricmp(test_string, "bow"))) - { - pItems[item_counter].uEquipType = EQUIP_BOW; - break; - } - if ( !_stricmp(test_string, "armor") ) - { - pItems[item_counter].uEquipType = EQUIP_ARMOUR; - break; - } - if ( !_stricmp(test_string, "shield") ) - { - pItems[item_counter].uEquipType = EQUIP_SHIELD; - break; - } - if ( !_stricmp(test_string, "helm") ) - { - pItems[item_counter].uEquipType = EQUIP_HELMET; - break; - } - if ( !_stricmp(test_string, "belt") ) - { - pItems[item_counter].uEquipType = EQUIP_BELT; - break; - } - if ( !_stricmp(test_string, "cloak") ) - { - pItems[item_counter].uEquipType = EQUIP_CLOAK; - break; - } - if ( !_stricmp(test_string, "gauntlets") ) - { - pItems[item_counter].uEquipType = EQUIP_GAUNTLETS; - break; - } - if ( !_stricmp(test_string, "boots") ) - { - pItems[item_counter].uEquipType = EQUIP_BOOTS; - break; - } - if ( !_stricmp(test_string, "ring") ) - { - pItems[item_counter].uEquipType = EQUIP_RING; - break; - } - if ( !_stricmp(test_string, "amulet") ) - { - pItems[item_counter].uEquipType = EQUIP_AMULET; - break; - } - if ( !_stricmp(test_string, "weaponw") ) - { - pItems[item_counter].uEquipType = EQUIP_WAND; - break; - } - if ( !(_stricmp(test_string, "herb")&&_stricmp(test_string, "reagent"))) - { - pItems[item_counter].uEquipType = EQUIP_REAGENT; - break; - } - if ( !_stricmp(test_string, "bottle") ) - { - pItems[item_counter].uEquipType = EQUIP_POTION; - break; - } - if ( !_stricmp(test_string, "sscroll") ) - { - pItems[item_counter].uEquipType = EQUIP_SPELL_SCROLL; - break; - } - if ( !_stricmp(test_string, "book") ) - { - pItems[item_counter].uEquipType = EQUIP_BOOK; - break; - } - if ( !_stricmp(test_string, "mscroll") ) - { - pItems[item_counter].uEquipType = EQUIP_MESSAGE_SCROLL; - break; - } - if ( !_stricmp(test_string, "gold") ) - { - pItems[item_counter].uEquipType = EQUIP_GOLD; - break; - } - if ( !_stricmp(test_string, "gem") ) - { - pItems[item_counter].uEquipType = EQUIP_GEM; - break; - } - pItems[item_counter].uEquipType = EQUIP_NONE; - break; - } - case 5: //Skill Group - { - if ( !_stricmp(test_string, "staff") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_STAFF; - break; - } - if ( !_stricmp(test_string, "sword") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_SWORD; - break; - } - if ( !_stricmp(test_string, "dagger") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_DAGGER; - break; - } - if ( !_stricmp(test_string, "axe") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_AXE; - break; - } - if ( !_stricmp(test_string, "spear") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_SPEAR; - break; - } - if ( !_stricmp(test_string, "bow") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_BOW; - break; - } - if ( !_stricmp(test_string, "mace") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_MACE; - break; - } - if ( !_stricmp(test_string, "blaster") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_BLASTER; - break; - } - if ( !_stricmp(test_string, "shield") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_SHIELD; - break; - } - if ( !_stricmp(test_string, "leather") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_LEATHER; - break; - } - if ( !_stricmp(test_string, "chain") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_CHAIN; - break; - } - if ( !_stricmp(test_string, "plate") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_PLATE; - break; - } - if ( !_stricmp(test_string, "club") ) - { - pItems[item_counter].uSkillType = PLAYER_SKILL_CLUB; - break; - } - pItems[item_counter].uSkillType = PLAYER_SKILL_MISC; - break; - } - case 6: //Mod1 - { - int ii; - char* test_char; - int tst_len; - tst_len=strlen(test_string); - pItems[item_counter].uDamageDice=0; - pItems[item_counter].uDamageRoll=0; - test_char=test_string; - for (ii=0; iisecond; + auto findResult2 = equipSkillMap.find(tokens[5]); + pItems[item_counter].uSkillType = findResult2 == equipSkillMap.end() ? PLAYER_SKILL_MISC : findResult2->second; + auto tokens2 = Tokenize(tokens[6], 'd'); + if (tokens2.size() == 2) + { + pItems[item_counter].uDamageDice=atoi(tokens2[0]); + pItems[item_counter].uDamageRoll=atoi(tokens2[1]); + } + else if (tolower(tokens2[0][0]) != 's') + { + pItems[item_counter].uDamageDice=atoi(tokens2[0]); + pItems[item_counter].uDamageRoll=1; + } + else + { + pItems[item_counter].uDamageDice=0; + pItems[item_counter].uDamageRoll=0; + } + pItems[item_counter].uDamageMod=atoi(tokens[7]); + auto findResult3 = materialMap.find(tokens[8]); + pItems[item_counter].uMaterial = findResult3 == materialMap.end() ? MATERIAL_COMMON : findResult->second; + pItems[item_counter].uItemID_Rep_St=atoi(tokens[9]); + pItems[item_counter].pUnidentifiedName = RemoveQuotes(tokens[10]); + pItems[item_counter].uSpriteID=atoi(tokens[11]); - break; - } - case 13: //VarB - if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type)) - { - char b_s=atoi(test_string); - if (b_s) - pItems[item_counter]._bonus_strength=b_s; - else - pItems[item_counter]._bonus_strength=1; - } - else - pItems[item_counter]._bonus_strength=0; - break; - case 14: //Equip X - pItems[item_counter].uEquipX=atoi(test_string); - break; - case 15: //Equip Y - pItems[item_counter].uEquipY=atoi(test_string); - break; - case 16: //Notes - pItems[item_counter].pDescription = RemoveQuotes(test_string); - break; + pItems[item_counter]._additional_value=0; + pItems[item_counter]._bonus_type=0; + if (pItems[item_counter].uMaterial==MATERIAL_SPECIAL) + { + for(int ii=0; ii<24; ++ii) + { + if (!_stricmp(tokens[12],pEnchantments[ii].pOfName)) + { + pItems[item_counter]._bonus_type=ii+1; + break; + } + } + if (!pItems[item_counter]._bonus_type) + { + for(int ii=0; ii<72; ++ii) + { + if (!_stricmp(tokens[12],pSpecialEnchantments[ii].pNameAdd)) + { + pItems[item_counter]._additional_value=ii+1; + } + } + } + } - } - } - else - { - if (decode_step) - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<17)&&!break_loop); - ++item_counter; - if (item_counter>799) - break; - } - + if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type)) + { + char b_s=atoi(tokens[13]); + if (b_s) + pItems[item_counter]._bonus_strength=b_s; + else + pItems[item_counter]._bonus_strength=1; + } + else + pItems[item_counter]._bonus_strength=0; + pItems[item_counter].uEquipX=atoi(tokens[14]); + pItems[item_counter].uEquipY=atoi(tokens[15]); + pItems[item_counter].pDescription = RemoveQuotes(tokens[16]); + item_counter++; + } pRndItemsTXT_Raw = NULL; uAllItemsCount = item_counter; @@ -855,64 +566,19 @@ strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); - item_counter = 0; - while (true) + for (item_counter = 0; item_counter < 619; item_counter++) { test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (decode_step) - { - case 0: - item_counter=atoi(test_string); - break; - case 2: - pItems[item_counter].uChanceByTreasureLvl1=atoi(test_string); - break; - case 3: - pItems[item_counter].uChanceByTreasureLvl2=atoi(test_string); - break; - case 4: - pItems[item_counter].uChanceByTreasureLvl3=atoi(test_string); - break; - case 5: - pItems[item_counter].uChanceByTreasureLvl4=atoi(test_string); - break; - case 6: - pItems[item_counter].uChanceByTreasureLvl5=atoi(test_string); - break; - case 7: - pItems[item_counter].uChanceByTreasureLvl6=atoi(test_string); - break; - } - } - else - { - if (decode_step) - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<8)&&!break_loop); - ++item_counter; - if (item_counter>618) - break; - } + auto tokens = Tokenize(test_string, '\t'); + Assert(tokens.size() > 7, "Invalid number of tokens"); + item_counter = atoi(tokens[0]); + pItems[item_counter].uChanceByTreasureLvl1=atoi(tokens[2]); + pItems[item_counter].uChanceByTreasureLvl2=atoi(tokens[3]); + pItems[item_counter].uChanceByTreasureLvl3=atoi(tokens[4]); + pItems[item_counter].uChanceByTreasureLvl4=atoi(tokens[5]); + pItems[item_counter].uChanceByTreasureLvl5=atoi(tokens[6]); + pItems[item_counter].uChanceByTreasureLvl6=atoi(tokens[7]); + } //ChanceByTreasureLvl Summ - to calculate chance memset(&uChanceByTreasureLvlSumm, 0, 24); @@ -930,119 +596,35 @@ for (i=0;i<3;++i) { test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (decode_step) - { - case 2: - switch (i) - { - case 0: - uBonusChanceStandart[0]=atoi(test_string); - break; - case 1: - uBonusChanceSpecial[0]=atoi(test_string); - break; - case 2: - uBonusChanceWpSpecial[0]=atoi(test_string); - break; - } - break; - case 3: - switch (i) - { - case 0: - uBonusChanceStandart[1]=atoi(test_string); - break; - case 1: - uBonusChanceSpecial[1]=atoi(test_string); - break; - case 2: - uBonusChanceWpSpecial[1]=atoi(test_string); - break; - } - break; - case 4: - switch (i) - { - case 0: - uBonusChanceStandart[2]=atoi(test_string); - break; - case 1: - uBonusChanceSpecial[2]=atoi(test_string); - break; - case 2: - uBonusChanceWpSpecial[2]=atoi(test_string); - break; - } - break; - case 5: - switch (i) - { - case 0: - uBonusChanceStandart[3]=atoi(test_string); - break; - case 1: - uBonusChanceSpecial[3]=atoi(test_string); - break; - case 2: - uBonusChanceWpSpecial[3]=atoi(test_string); - break; - } - break; - case 6: - switch (i) - { - case 0: - uBonusChanceStandart[4]=atoi(test_string); - break; - case 1: - uBonusChanceSpecial[4]=atoi(test_string); - break; - case 2: - uBonusChanceWpSpecial[4]=atoi(test_string); - break; - } - break; - case 7: - switch (i) - { - case 0: - uBonusChanceStandart[5]=atoi(test_string); - break; - case 1: - uBonusChanceSpecial[5]=atoi(test_string); - break; - case 2: - uBonusChanceWpSpecial[5]=atoi(test_string); - break; - } - break; - } - } - else - { - if (decode_step) - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<8)&&!break_loop); + auto tokens = Tokenize(test_string, '\t'); + Assert(tokens.size() > 7, "Invalid number of tokens"); + switch (i) + { + case 0: + uBonusChanceStandart[0]=atoi(tokens[2]); + uBonusChanceStandart[1]=atoi(tokens[3]); + uBonusChanceStandart[2]=atoi(tokens[4]); + uBonusChanceStandart[3]=atoi(tokens[5]); + uBonusChanceStandart[4]=atoi(tokens[6]); + uBonusChanceStandart[5]=atoi(tokens[7]); + break; + case 1: + uBonusChanceSpecial[0]=atoi(tokens[2]); + uBonusChanceSpecial[1]=atoi(tokens[3]); + uBonusChanceSpecial[2]=atoi(tokens[4]); + uBonusChanceSpecial[3]=atoi(tokens[5]); + uBonusChanceSpecial[4]=atoi(tokens[6]); + uBonusChanceSpecial[5]=atoi(tokens[7]); + break; + case 2: + uBonusChanceWpSpecial[0]=atoi(tokens[2]); + uBonusChanceWpSpecial[1]=atoi(tokens[3]); + uBonusChanceWpSpecial[2]=atoi(tokens[4]); + uBonusChanceWpSpecial[3]=atoi(tokens[5]); + uBonusChanceWpSpecial[4]=atoi(tokens[6]); + uBonusChanceWpSpecial[5]=atoi(tokens[7]); + break; + } } if ( pRndItemsTXT_Raw ) @@ -1057,51 +639,14 @@ for (i=0; i<37; ++i) { test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (decode_step) - { - case 1: - pSkillDesc[i] = RemoveQuotes(test_string); - break; - case 2: - pNormalSkillDesc[i] = RemoveQuotes(test_string); - break; - case 3: - pExpertSkillDesc[i] = RemoveQuotes(test_string); - break; - case 4: - pMasterSkillDesc[i] = RemoveQuotes(test_string); - break; - case 5: - pGrandSkillDesc[i] = RemoveQuotes(test_string); - break; - } - } - else - { - if (decode_step) - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<6)&&!break_loop); - } + auto tokens = Tokenize(test_string, '\t'); + Assert(tokens.size() >= 6, "Invalid number of tokens"); + pSkillDesc[i] = RemoveQuotes(tokens[1]); + pNormalSkillDesc[i] = RemoveQuotes(tokens[2]); + pExpertSkillDesc[i] = RemoveQuotes(tokens[3]); + pMasterSkillDesc[i] = RemoveQuotes(tokens[4]); + pGrandSkillDesc[i] = RemoveQuotes(tokens[5]); + } pStatsTXT_Raw = 0; pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0); @@ -1109,139 +654,89 @@ for (i=0; i<26; ++i) { test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (i) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - pAttributeDescriptions[i] = RemoveQuotes(test_string); - break; - case 7: - pHealthPointsAttributeDescription = RemoveQuotes(test_string); - break; - case 8: - pArmourClassAttributeDescription = RemoveQuotes(test_string); - break; - case 9: - pSpellPointsAttributeDescription = RemoveQuotes(test_string); - break; - case 10: - pPlayerConditionAttributeDescription = RemoveQuotes(test_string); - break; - case 11: - pFastSpellAttributeDescription = RemoveQuotes(test_string); - break; - case 12: - pPlayerAgeAttributeDescription = RemoveQuotes(test_string); - break; - case 13: - pPlayerLevelAttributeDescription = RemoveQuotes(test_string); - break; - case 14: - pPlayerExperienceAttributeDescription = RemoveQuotes(test_string); - break; - case 15: - pAttackBonusAttributeDescription = RemoveQuotes(test_string); - break; - case 16: - pAttackDamageAttributeDescription = RemoveQuotes(test_string); - break; - case 17: - pMissleBonusAttributeDescription = RemoveQuotes(test_string); - break; - case 18: - pMissleDamageAttributeDescription = RemoveQuotes(test_string); - break; - case 19: - pFireResistanceAttributeDescription = RemoveQuotes(test_string); - break; - case 20: - pAirResistanceAttributeDescription = RemoveQuotes(test_string); - break; - case 21: - pWaterResistanceAttributeDescription = RemoveQuotes(test_string); - break; - case 22: - pEarthResistanceAttributeDescription = RemoveQuotes(test_string); - break; - case 23: - pMindResistanceAttributeDescription = RemoveQuotes(test_string); - break; - case 24: - pBodyResistanceAttributeDescription = RemoveQuotes(test_string); - break; - case 25: - pSkillPointsAttributeDescription = RemoveQuotes(test_string); - break; - } - } - else - { - if (decode_step) - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<2)&&!break_loop); - } - - + auto tokens = Tokenize(test_string, '\t'); + Assert(tokens.size() == 2, "Invalid number of tokens"); + switch (i) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + pAttributeDescriptions[i] = RemoveQuotes(tokens[1]); + break; + case 7: + pHealthPointsAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 8: + pArmourClassAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 9: + pSpellPointsAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 10: + pPlayerConditionAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 11: + pFastSpellAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 12: + pPlayerAgeAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 13: + pPlayerLevelAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 14: + pPlayerExperienceAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 15: + pAttackBonusAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 16: + pAttackDamageAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 17: + pMissleBonusAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 18: + pMissleDamageAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 19: + pFireResistanceAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 20: + pAirResistanceAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 21: + pWaterResistanceAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 22: + pEarthResistanceAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 23: + pMindResistanceAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 24: + pBodyResistanceAttributeDescription = RemoveQuotes(tokens[1]); + break; + case 25: + pSkillPointsAttributeDescription = RemoveQuotes(tokens[1]); + break; + } + } + pClassTXT_Raw = 0; pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0); strtok(pClassTXT_Raw, "\r"); for (i=0; i<36; ++i) { test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - //if(i) - pClassDescriptions[i]=RemoveQuotes(test_string); - } - else - { - if (decode_step) - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<2)&&!break_loop); - } + auto tokens = Tokenize(test_string, '\t'); + Assert(tokens.size() == 3, "Invalid number of tokens"); + pClassDescriptions[i]=RemoveQuotes(tokens[1]); + } @@ -1543,62 +1038,28 @@ ItemsTable *v5; // edi@1 int v6; // ebx@3 - int *v7; // ecx@33 + //int *v7; // ecx@33 //int v8; // eax@34 //int v9; // eax@39 int current_chance; // ebx@43 int tmp_chance; // ecx@47 - unsigned int *v12; // edx@48 - unsigned int v13; // eax@49 - signed int v14; // ebx@52 - int v15; // eax@53 - signed int v16; // eax@55 int v17; // ebx@57 int v18; // edx@62 - signed int v19; // ebx@70 - unsigned __int8 v20; // al@81 - int v21; // eax@84 - int v22; // ebx@85 - int v23; // eax@86 - int v24; // ebx@86 - int special_chance; // edx@86 - int v26; // edx@89 + unsigned int special_chance; // edx@86 + unsigned int v26; // edx@89 unsigned int v27; // eax@89 - int i; // ebx@89 - unsigned int v29; // ecx@90 - int v30; // ebx@91 - int v31; // eax@91 int v32; // ecx@91 int v33; // eax@91 - int v34; // eax@97 - unsigned __int8 v35; // sf@97 - unsigned __int8 v36; // of@97 - int v37; // ebx@98 - int v38; // edx@99 - signed int v39; // ebx@101 - int v40; // ecx@102 - char v41; // zf@107 - char v42; // al@108 - char v43; // al@111 - int *v44; // edx@118 + unsigned int v34; // eax@97 int v45; // eax@120 int v46; // edx@120 int j; // eax@121 - unsigned int v48; // ecx@123 - int v49; // eax@123 - int v50; // eax@123 int val_list[800]; // [sp+Ch] [bp-C88h]@33 int total_chance; // [sp+C8Ch] [bp-8h]@33 - int v53; // [sp+C90h] [bp-4h]@1 int v54; // [sp+C9Ch] [bp+8h]@3 //int v55; // [sp+CA0h] [bp+Ch]@34 signed int v56; // [sp+CA0h] [bp+Ch]@55 int v57; // [sp+CA0h] [bp+Ch]@62 - int *v58; // [sp+CA0h] [bp+Ch]@102 - int v59; // [sp+CA0h] [bp+Ch]@123 - //signed int a2a; // [sp+CA4h] [bp+10h]@33 - int a2b; // [sp+CA4h] [bp+10h]@101 - int a2c; // [sp+CA4h] [bp+10h]@120 v5 = this; if (!out_item) @@ -1770,7 +1231,7 @@ case EQUIP_BOW : if ( !uBonusChanceWpSpecial[v6] ) return; - if ((rand() % 100)>=uBonusChanceWpSpecial[v6]) + if ((uint)(rand() % 100)>=uBonusChanceWpSpecial[v6]) return; break; case EQUIP_ARMOUR : @@ -1827,7 +1288,7 @@ int spc_sum=0; int spc; memset(&val_list, 0, 3200); - for (int i=0; iGetMapInfo(pCurrentMapName); @@ -2859,10 +2309,6 @@ { int result; // eax@2 char v5; // zf@3 - const char *v6; // [sp-Ch] [bp-18h]@88 - signed int v7; // [sp-8h] [bp-14h]@61 - int v8; // [sp-4h] [bp-10h]@61 - signed int v9; // [sp-4h] [bp-10h]@69 result = 0; //BUG fn is void if ( item_id <= 500 ) diff -r 90f56da08d76 -r 8193a64c7461 MapInfo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MapInfo.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -0,0 +1,518 @@ +#include "MapInfo.h" +#include "LOD.h" +#include "ErrorHandling.h" +#include "mm7_data.h" +#include "texts.h" +#include "ObjectList.h" +#include "SpriteObject.h" +#include "Indoor.h" +#include "mm7_unsorted_subs.h" + + +//----- (00453F62) -------------------------------------------------------- +void MapStats::Initialize() +{ + char work_str[32]; // [sp+Ch] [bp-34h]@3 + int work_str_pos; + int work_str_len; + int i; + char* test_string; + unsigned char c; + bool break_loop; + unsigned int temp_str_len; + char* tmp_pos; + int decode_step; + int item_counter; + + if ( pMapStatsTXT_Raw ) + free(pMapStatsTXT_Raw); + pMapStatsTXT_Raw = NULL; + pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); + strtok(pMapStatsTXT_Raw, "\r"); + strtok(NULL, "\r"); + strtok(NULL, "\r"); + + for (i=1; i<77; ++i) + { + test_string = strtok(NULL, "\r") + 1; + break_loop = false; + decode_step=0; + do + { + c = *(unsigned char*)test_string; + temp_str_len = 0; + while((c!='\t')&&(c>0)) + { + ++temp_str_len; + c=test_string[temp_str_len]; + } + tmp_pos=test_string+temp_str_len; + if (*tmp_pos == 0) + break_loop = true; + *tmp_pos = 0; + if (temp_str_len) + { + switch (decode_step) + { + case 1: + pInfos[i].pName = RemoveQuotes(test_string); + break; + case 2: + pInfos[i].pFilename = RemoveQuotes(test_string); + break; + case 3: + pInfos[i].uNumResets = atoi(test_string); + break; + case 4: + pInfos[i].uFirstVisitedAt = atoi(test_string); + break; + case 5: + pInfos[i]._per = atoi(test_string); + break; + case 6: + pInfos[i].uRespawnIntervalDays = atoi(test_string); + break; + case 7: + pInfos[i]._alert_days = atoi(test_string); + break; + case 8: + pInfos[i]._steal_perm = atoi(test_string); + break; + case 9: + pInfos[i].LockX5 = atoi(test_string); + break; + case 10: + pInfos[i].Trap_D20 = atoi(test_string); + break; + case 11: + pInfos[i].Treasure_prob = atoi(test_string); + break; + case 12: + pInfos[i].Encounter_percent = atoi(test_string); + break; + case 13: + pInfos[i].EncM1percent = atoi(test_string); + break; + case 14: + pInfos[i].EncM2percent = atoi(test_string); + break; + case 15: + pInfos[i].EncM3percent = atoi(test_string); + break; + case 16: + pInfos[i].pEncounterMonster1Texture = RemoveQuotes(test_string); + break; + case 18: + pInfos[i].Dif_M1 = atoi(test_string); + break; + case 19: + pInfos[i].uEncounterMonster1AtLeast = 1; + pInfos[i].uEncounterMonster1AtMost = 1; + strcpy(work_str, test_string); + work_str_pos = 0; + work_str_len=strlen(work_str); + if (work_str_len ) + { + while (work_str[work_str_pos] != '-' ) + { + ++work_str_pos; + if (work_str_pos >= work_str_len ) + break; + } + work_str[work_str_pos] = 0; + pInfos[i].uEncounterMonster1AtLeast = atoi(work_str); + if ( work_str_pos < work_str_len ) + pInfos[i].uEncounterMonster1AtMost = atoi(&work_str[work_str_pos + 1]); + else + pInfos[i].uEncounterMonster1AtMost = pInfos[i].uEncounterMonster1AtLeast; + } + break; + case 20: + pInfos[i].pEncounterMonster2Texture = RemoveQuotes(test_string); + break; + case 22: + pInfos[i].Dif_M2 = atoi(test_string); + break; + case 23: + pInfos[i].uEncounterMonster2AtLeast = 1; + pInfos[i].uEncounterMonster2AtMost = 1; + strcpy(work_str, test_string); + work_str_pos = 0; + work_str_len=strlen(work_str); + if (work_str_len ) + { + while (work_str[work_str_pos] != '-' ) + { + ++work_str_pos; + if (work_str_pos >= work_str_len ) + break; + } + work_str[work_str_pos] = 0; + pInfos[i].uEncounterMonster2AtLeast = atoi(work_str); + if ( work_str_pos < work_str_len ) + pInfos[i].uEncounterMonster2AtMost = atoi(&work_str[work_str_pos + 1]); + else + pInfos[i].uEncounterMonster2AtMost = pInfos[i].uEncounterMonster2AtLeast; + } + break; + case 24: + pInfos[i].pEncounterMonster3Texture = RemoveQuotes(test_string); + break; + case 26: + pInfos[i].Dif_M3 = atoi(test_string); + break; + case 27: + pInfos[i].uEncounterMonster3AtLeast = 1; + pInfos[i].uEncounterMonster3AtMost = 1; + strcpy(work_str, test_string); + work_str_pos = 0; + work_str_len=strlen(work_str); + if (work_str_len ) + { + while (work_str[work_str_pos] != '-' ) + { + ++work_str_pos; + if (work_str_pos >= work_str_len ) + break; + } + work_str[work_str_pos] = 0; + pInfos[i].uEncounterMonster3AtLeast = atoi(work_str); + if ( work_str_pos < work_str_len ) + pInfos[i].uEncounterMonster3AtMost = atoi(&work_str[work_str_pos + 1]); + else + pInfos[i].uEncounterMonster3AtMost = pInfos[i].uEncounterMonster3AtLeast; + } + break; + case 28: + pInfos[i].uRedbookTrackID = atoi(test_string); + break; + case 29: + { + if ( !strcmp(test_string, "CAVE") ) + { + pInfos[i].uEAXEnv = 8; + break; + } + if ( !strcmp(test_string, "STONEROOM") ) + { + pInfos[i].uEAXEnv = 5; + break; + } + if ( !strcmp(test_string, "MOUNTAINS") ) + { + pInfos[i].uEAXEnv = 17; + break; + } + if ( !strcmp(test_string, "PLAIN") ) + { + pInfos[i].uEAXEnv = 19; + break; + } + if ( !strcmp(test_string, "FOREST") ) + { + pInfos[i].uEAXEnv = 15; + break; + } + if ( !strcmp(test_string, "CITY") ) + { + pInfos[i].uEAXEnv = 16; + break; + } + if ( !strcmp(test_string, "UNDERWATER") ) + { + pInfos[i].uEAXEnv = 22; + break; + } + if ( !strcmp(test_string, "ARENA") ) + { + pInfos[i].uEAXEnv = 9; + break; + } + if ( !strcmp(test_string, "GENERIC") ) + { + pInfos[i].uEAXEnv = 0; + break; + } + if ( !strcmp(test_string, "PADDEDCELL") ) + { + pInfos[i].uEAXEnv = 1; + break; + } + if ( !strcmp(test_string, "ROOM") ) + { + pInfos[i].uEAXEnv = 2; + break; + } + if ( !strcmp(test_string, "BATHROOM") ) + { + pInfos[i].uEAXEnv = 3; + break; + } + if ( !strcmp(test_string, "LIVINGROOM") ) + { + pInfos[i].uEAXEnv = 4; + break; + } + if ( !strcmp(test_string, "AUDITORIUM") ) + { + pInfos[i].uEAXEnv = 6; + break; + } + if ( !strcmp(test_string, "CONCERTHALL") ) + { + pInfos[i].uEAXEnv = 7; + break; + } + if ( !strcmp(test_string, "HANGAR") ) + { + pInfos[i].uEAXEnv = 10; + break; + } + if ( !strcmp(test_string, "CARPETEDHALLWAY") ) + { + pInfos[i].uEAXEnv = 11; + break; + } + if ( !strcmp(test_string, "HALLWAY") ) + { + pInfos[i].uEAXEnv = 12; + break; + } + if ( !strcmp(test_string, "STONECORRIDOR") ) + { + pInfos[i].uEAXEnv = 13; + break; + } + if ( !strcmp(test_string, "ALLEY") ) + { + pInfos[i].uEAXEnv = 14; + break; + } + if ( !strcmp(test_string, "QUARRY") ) + { + pInfos[i].uEAXEnv = 18; + break; + } + if ( !strcmp(test_string, "PARKINGLOT") ) + { + pInfos[i].uEAXEnv = 20; + break; + } + if ( !strcmp(test_string, "SEWERPIPE") ) + { + pInfos[i].uEAXEnv = 21; + break; + } + if ( !strcmp(test_string, "DRUGGED") ) + { + pInfos[i].uEAXEnv = 23; + break; + } + if ( !strcmp(test_string, "DIZZY") ) + { + pInfos[i].uEAXEnv = 24; + break; + } + if ( !strcmp(test_string, "PSYCHOTIC") ) + { + pInfos[i].uEAXEnv = 25; + break; + } + pInfos[i].uEAXEnv = 26; + + } + break; + } + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<31)&&!break_loop); + } + + uNumMaps = 77; +} +// 453F62: using guessed type char Str[32]; + +//----- (00410D99) -------------------------------------------------------- +int MapStats::sub_410D99_get_map_index(int a1) +{ + for (int i = 1; i <= pMapStats->uNumMaps; i++) + { + if (_stricmp(pMapStats->pInfos[i].pFilename, pGames_LOD->pSubIndices[a1].pFilename) ) + return i; + } + Error("Map not found"); + return -1; +} + +//----- (004547A3) -------------------------------------------------------- +MAP_TYPE MapStats::GetMapInfo(const char *Str2) +{ + Assert(uNumMaps >= 2); + + for (uint i = 1; i < uNumMaps; ++i) + if (!_stricmp(pInfos[i].pFilename, Str2)) + return (MAP_TYPE)i; + + Error("Map not found!"); + return (MAP_TYPE)-1; +} + + +//----- (0044FFD8) -------------------------------------------------------- +int MapInfo::SpawnRandomTreasure(SpawnPointMM7 *a2) +{ + //MapInfo *v2; // ebx@1 + //SpawnPointMM7 *v3; // esi@1 + //int v4; // eax@1 + int v5; // edx@1 + int v6; // eax@1 + int v7; // ecx@1 + int v8; // ebx@1 + int v9; // eax@1 + signed int v10; // ebx@1 + signed int result; // eax@1 + signed __int64 v12; // qtt@1 + int v13; // ebx@1 + int v14; // edx@10 + signed int v15; // ebx@20 + unsigned __int16 v16; // dx@20 + ObjectDesc *v17; // ecx@21 + unsigned __int16 v18; // ax@24 + int v19; // ST0C_4@27 + int v20; // ST08_4@27 + int v21; // ST04_4@27 + int v22; // eax@27 + signed int v23; // ebx@29 + unsigned __int16 v24; // dx@29 + ObjectDesc *v25; // ecx@30 + unsigned __int16 v26; // ax@33 + //int v27; // ecx@35 + //int v28; // eax@35 + //int v29; // esi@35 + //__int16 v30; // ax@35 + 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 + + //auto a1 = this; + //v2 = a1; + //v3 = a2; + //v4 = rand(); + v34 = 0; + v5 = rand() % 100; + // v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14; + v7 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob]; + v8 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob + 1]; + //v32 = v5; + //v33 = v7; + v9 = rand(); + v10 = v8 - v7 + 1; + v12 = v9; + result = v9 / v10; + v13 = v7 + (unsigned __int64)(v12 % v10); + if ( v13 < 7 ) + { + if ( v5 < 20 ) + return result; + if ( v5 >= 60 ) + { + v19 = a2->vPosition.z; + v20 = a2->vPosition.y; + v21 = a2->vPosition.x; + v22 = rand(); + return sub_450521_ProllyDropItemAt(v13, v22 % 27 + 20, v21, v20, v19, 0); + } + if ( a2->uIndex == 1 ) + { + v14 = rand() % 51 + 50; + a1a.stru_24.uItemID = 197; + v34 = v14; + } + else if ( a2->uIndex == 2 ) + { + v14 = rand() % 101 + 100; + a1a.stru_24.uItemID = 197; + v34 = v14; + } + else if ( a2->uIndex == 3 ) + { + v14 = rand() % 301 + 200; + a1a.stru_24.uItemID = 198; + v34 = v14; + } + else if ( a2->uIndex == 4 ) + { + v14 = rand() % 501 + 500; + a1a.stru_24.uItemID = 198; + v34 = v14; + } + else if ( a2->uIndex == 5 ) + { + v14 = rand() % 1001 + 1000; + a1a.stru_24.uItemID = 199; + v34 = v14; + } + else if ( a2->uIndex == 6 ) + { + v14 = rand() % 3001 + 2000; + a1a.stru_24.uItemID = 199; + v34 = v14; + } + v15 = 0; + v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + v18 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) + { + if ( pObjectList->pObjects[i].uObjectID == v16 ) + { + v18 = i; + break; + } + } + a1a.stru_24.SetIdentified(); + a1a.uObjectDescID = v18; + a1a.stru_24.uSpecEnchantmentType = v34; + } + else + { + result = a1a.stru_24.GenerateArtifact(); + if ( !result ) + return result; + v23 = 0; + v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + v26 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) + { + if( v24 == pObjectList->pObjects[i].uObjectID ) + { + v26 = i; + break; + } + } + a1a.uObjectDescID = v26; + a1a.stru_24.Reset(); + } + a1a.vPosition.y = a2->vPosition.y; + a1a.uAttributes = 0; + a1a.uSoundID = 0; + a1a.uFacing = 0; + a1a.vPosition.z = a2->vPosition.z; + a1a.vPosition.x = a2->vPosition.x; + a1a.spell_skill = 0; + a1a.spell_level = 0; + a1a.spell_id = 0; + a1a.spell_target_pid = 0; + a1a.spell_caster_pid = 0; + a1a.uSpriteFrameID = 0; + a1a.uSectorID = pIndoor->GetSector(a2->vPosition.x, a2->vPosition.y, a2->vPosition.z);; + return a1a.Create(0, 0, 0, 0); +} + diff -r 90f56da08d76 -r 8193a64c7461 MapInfo.h --- a/MapInfo.h Fri Mar 14 09:32:25 2014 +0600 +++ b/MapInfo.h Fri Mar 14 09:32:42 2014 +0600 @@ -86,9 +86,11 @@ { void Initialize(); MAP_TYPE GetMapInfo(const char *Str2); - + int sub_410D99_get_map_index(int a1); MapInfo pInfos[77]; unsigned int uNumMaps; + + }; #pragma pack(pop) diff -r 90f56da08d76 -r 8193a64c7461 Render.cpp --- a/Render.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/Render.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -8486,18 +8486,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; diff -r 90f56da08d76 -r 8193a64c7461 UI/Books/UIMapBook.cpp --- a/UI/Books/UIMapBook.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/UI/Books/UIMapBook.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -137,7 +137,7 @@ { pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook); pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[BeaconID], pLloydsBeaconsPreviewYs[BeaconID], &pSavegameThumbnails[BeaconID]); - Str = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName; + Str = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName; pTextHeight = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0); pWindow.uFrameY += -6 - pTextHeight; pWindow.DrawTitleText(pSpellFont, 0, 0, 1, Str, 3); diff -r 90f56da08d76 -r 8193a64c7461 mm7_2.cpp --- a/mm7_2.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/mm7_2.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -1389,159 +1389,6 @@ return result; } -//----- (0044FFD8) -------------------------------------------------------- -int MapInfo::SpawnRandomTreasure(SpawnPointMM7 *a2) -{ - //MapInfo *v2; // ebx@1 - //SpawnPointMM7 *v3; // esi@1 - //int v4; // eax@1 - int v5; // edx@1 - int v6; // eax@1 - int v7; // ecx@1 - int v8; // ebx@1 - int v9; // eax@1 - signed int v10; // ebx@1 - signed int result; // eax@1 - signed __int64 v12; // qtt@1 - int v13; // ebx@1 - int v14; // edx@10 - signed int v15; // ebx@20 - unsigned __int16 v16; // dx@20 - ObjectDesc *v17; // ecx@21 - unsigned __int16 v18; // ax@24 - int v19; // ST0C_4@27 - int v20; // ST08_4@27 - int v21; // ST04_4@27 - int v22; // eax@27 - signed int v23; // ebx@29 - unsigned __int16 v24; // dx@29 - ObjectDesc *v25; // ecx@30 - unsigned __int16 v26; // ax@33 - //int v27; // ecx@35 - //int v28; // eax@35 - //int v29; // esi@35 - //__int16 v30; // ax@35 - 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 - - //auto a1 = this; - //v2 = a1; - //v3 = a2; - //v4 = rand(); - v34 = 0; - v5 = rand() % 100; - // v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14; - v7 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob]; - v8 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob + 1]; - //v32 = v5; - //v33 = v7; - v9 = rand(); - v10 = v8 - v7 + 1; - v12 = v9; - result = v9 / v10; - v13 = v7 + (unsigned __int64)(v12 % v10); - if ( v13 < 7 ) - { - if ( v5 < 20 ) - return result; - if ( v5 >= 60 ) - { - v19 = a2->vPosition.z; - v20 = a2->vPosition.y; - v21 = a2->vPosition.x; - v22 = rand(); - return sub_450521_ProllyDropItemAt(v13, v22 % 27 + 20, v21, v20, v19, 0); - } - if ( a2->uIndex == 1 ) - { - v14 = rand() % 51 + 50; - a1a.stru_24.uItemID = 197; - v34 = v14; - } - else if ( a2->uIndex == 2 ) - { - v14 = rand() % 101 + 100; - a1a.stru_24.uItemID = 197; - v34 = v14; - } - else if ( a2->uIndex == 3 ) - { - v14 = rand() % 301 + 200; - a1a.stru_24.uItemID = 198; - v34 = v14; - } - else if ( a2->uIndex == 4 ) - { - v14 = rand() % 501 + 500; - a1a.stru_24.uItemID = 198; - v34 = v14; - } - else if ( a2->uIndex == 5 ) - { - v14 = rand() % 1001 + 1000; - a1a.stru_24.uItemID = 199; - v34 = v14; - } - else if ( a2->uIndex == 6 ) - { - v14 = rand() % 3001 + 2000; - a1a.stru_24.uItemID = 199; - v34 = v14; - } - v15 = 0; - v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - v18 = 0; - for( int i = 0; i < pObjectList->uNumObjects; i++ ) - { - if ( pObjectList->pObjects[i].uObjectID == v16 ) - { - v18 = i; - break; - } - } - a1a.stru_24.SetIdentified(); - a1a.uObjectDescID = v18; - a1a.stru_24.uSpecEnchantmentType = v34; - } - else - { - result = a1a.stru_24.GenerateArtifact(); - if ( !result ) - return result; - v23 = 0; - v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - v26 = 0; - for( int i = 0; i < pObjectList->uNumObjects; i++ ) - { - if( v24 == pObjectList->pObjects[i].uObjectID ) - { - v26 = i; - break; - } - } - a1a.uObjectDescID = v26; - a1a.stru_24.Reset(); - } - a1a.vPosition.y = a2->vPosition.y; - a1a.uAttributes = 0; - a1a.uSoundID = 0; - a1a.uFacing = 0; - a1a.vPosition.z = a2->vPosition.z; - a1a.vPosition.x = a2->vPosition.x; - a1a.spell_skill = 0; - a1a.spell_level = 0; - a1a.spell_id = 0; - a1a.spell_target_pid = 0; - a1a.spell_caster_pid = 0; - a1a.uSpriteFrameID = 0; - a1a.uSectorID = pIndoor->GetSector(a2->vPosition.x, a2->vPosition.y, a2->vPosition.z);; - return a1a.Create(0, 0, 0, 0); -} - //----- (00450521) -------------------------------------------------------- int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6) { @@ -2241,345 +2088,7 @@ return 0; } -//----- (00453F62) -------------------------------------------------------- -void MapStats::Initialize() -{ - char work_str[32]; // [sp+Ch] [bp-34h]@3 - int work_str_pos; - int work_str_len; - int i; - char* test_string; - unsigned char c; - bool break_loop; - unsigned int temp_str_len; - char* tmp_pos; - int decode_step; - int item_counter; - - if ( pMapStatsTXT_Raw ) - free(pMapStatsTXT_Raw); - pMapStatsTXT_Raw = NULL; - pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); - strtok(pMapStatsTXT_Raw, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - - for (i=1; i<77; ++i) - { - test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (decode_step) - { - case 1: - pInfos[i].pName = RemoveQuotes(test_string); - break; - case 2: - pInfos[i].pFilename = RemoveQuotes(test_string); - break; - case 3: - pInfos[i].uNumResets = atoi(test_string); - break; - case 4: - pInfos[i].uFirstVisitedAt = atoi(test_string); - break; - case 5: - pInfos[i]._per = atoi(test_string); - break; - case 6: - pInfos[i].uRespawnIntervalDays = atoi(test_string); - break; - case 7: - pInfos[i]._alert_days = atoi(test_string); - break; - case 8: - pInfos[i]._steal_perm = atoi(test_string); - break; - case 9: - pInfos[i].LockX5 = atoi(test_string); - break; - case 10: - pInfos[i].Trap_D20 = atoi(test_string); - break; - case 11: - pInfos[i].Treasure_prob = atoi(test_string); - break; - case 12: - pInfos[i].Encounter_percent = atoi(test_string); - break; - case 13: - pInfos[i].EncM1percent = atoi(test_string); - break; - case 14: - pInfos[i].EncM2percent = atoi(test_string); - break; - case 15: - pInfos[i].EncM3percent = atoi(test_string); - break; - case 16: - pInfos[i].pEncounterMonster1Texture = RemoveQuotes(test_string); - break; - case 18: - pInfos[i].Dif_M1 = atoi(test_string); - break; - case 19: - pInfos[i].uEncounterMonster1AtLeast = 1; - pInfos[i].uEncounterMonster1AtMost = 1; - strcpy(work_str, test_string); - work_str_pos = 0; - work_str_len=strlen(work_str); - if (work_str_len ) - { - while (work_str[work_str_pos] != '-' ) - { - ++work_str_pos; - if (work_str_pos >= work_str_len ) - break; - } - work_str[work_str_pos] = 0; - pInfos[i].uEncounterMonster1AtLeast = atoi(work_str); - if ( work_str_pos < work_str_len ) - pInfos[i].uEncounterMonster1AtMost = atoi(&work_str[work_str_pos + 1]); - else - pInfos[i].uEncounterMonster1AtMost = pInfos[i].uEncounterMonster1AtLeast; - } - break; - case 20: - pInfos[i].pEncounterMonster2Texture = RemoveQuotes(test_string); - break; - case 22: - pInfos[i].Dif_M2 = atoi(test_string); - break; - case 23: - pInfos[i].uEncounterMonster2AtLeast = 1; - pInfos[i].uEncounterMonster2AtMost = 1; - strcpy(work_str, test_string); - work_str_pos = 0; - work_str_len=strlen(work_str); - if (work_str_len ) - { - while (work_str[work_str_pos] != '-' ) - { - ++work_str_pos; - if (work_str_pos >= work_str_len ) - break; - } - work_str[work_str_pos] = 0; - pInfos[i].uEncounterMonster2AtLeast = atoi(work_str); - if ( work_str_pos < work_str_len ) - pInfos[i].uEncounterMonster2AtMost = atoi(&work_str[work_str_pos + 1]); - else - pInfos[i].uEncounterMonster2AtMost = pInfos[i].uEncounterMonster2AtLeast; - } - break; - case 24: - pInfos[i].pEncounterMonster3Texture = RemoveQuotes(test_string); - break; - case 26: - pInfos[i].Dif_M3 = atoi(test_string); - break; - case 27: - pInfos[i].uEncounterMonster3AtLeast = 1; - pInfos[i].uEncounterMonster3AtMost = 1; - strcpy(work_str, test_string); - work_str_pos = 0; - work_str_len=strlen(work_str); - if (work_str_len ) - { - while (work_str[work_str_pos] != '-' ) - { - ++work_str_pos; - if (work_str_pos >= work_str_len ) - break; - } - work_str[work_str_pos] = 0; - pInfos[i].uEncounterMonster3AtLeast = atoi(work_str); - if ( work_str_pos < work_str_len ) - pInfos[i].uEncounterMonster3AtMost = atoi(&work_str[work_str_pos + 1]); - else - pInfos[i].uEncounterMonster3AtMost = pInfos[i].uEncounterMonster3AtLeast; - } - break; - case 28: - pInfos[i].uRedbookTrackID = atoi(test_string); - break; - case 29: - { - if ( !strcmp(test_string, "CAVE") ) - { - pInfos[i].uEAXEnv = 8; - break; - } - if ( !strcmp(test_string, "STONEROOM") ) - { - pInfos[i].uEAXEnv = 5; - break; - } - if ( !strcmp(test_string, "MOUNTAINS") ) - { - pInfos[i].uEAXEnv = 17; - break; - } - if ( !strcmp(test_string, "PLAIN") ) - { - pInfos[i].uEAXEnv = 19; - break; - } - if ( !strcmp(test_string, "FOREST") ) - { - pInfos[i].uEAXEnv = 15; - break; - } - if ( !strcmp(test_string, "CITY") ) - { - pInfos[i].uEAXEnv = 16; - break; - } - if ( !strcmp(test_string, "UNDERWATER") ) - { - pInfos[i].uEAXEnv = 22; - break; - } - if ( !strcmp(test_string, "ARENA") ) - { - pInfos[i].uEAXEnv = 9; - break; - } - if ( !strcmp(test_string, "GENERIC") ) - { - pInfos[i].uEAXEnv = 0; - break; - } - if ( !strcmp(test_string, "PADDEDCELL") ) - { - pInfos[i].uEAXEnv = 1; - break; - } - if ( !strcmp(test_string, "ROOM") ) - { - pInfos[i].uEAXEnv = 2; - break; - } - if ( !strcmp(test_string, "BATHROOM") ) - { - pInfos[i].uEAXEnv = 3; - break; - } - if ( !strcmp(test_string, "LIVINGROOM") ) - { - pInfos[i].uEAXEnv = 4; - break; - } - if ( !strcmp(test_string, "AUDITORIUM") ) - { - pInfos[i].uEAXEnv = 6; - break; - } - if ( !strcmp(test_string, "CONCERTHALL") ) - { - pInfos[i].uEAXEnv = 7; - break; - } - if ( !strcmp(test_string, "HANGAR") ) - { - pInfos[i].uEAXEnv = 10; - break; - } - if ( !strcmp(test_string, "CARPETEDHALLWAY") ) - { - pInfos[i].uEAXEnv = 11; - break; - } - if ( !strcmp(test_string, "HALLWAY") ) - { - pInfos[i].uEAXEnv = 12; - break; - } - if ( !strcmp(test_string, "STONECORRIDOR") ) - { - pInfos[i].uEAXEnv = 13; - break; - } - if ( !strcmp(test_string, "ALLEY") ) - { - pInfos[i].uEAXEnv = 14; - break; - } - if ( !strcmp(test_string, "QUARRY") ) - { - pInfos[i].uEAXEnv = 18; - break; - } - if ( !strcmp(test_string, "PARKINGLOT") ) - { - pInfos[i].uEAXEnv = 20; - break; - } - if ( !strcmp(test_string, "SEWERPIPE") ) - { - pInfos[i].uEAXEnv = 21; - break; - } - if ( !strcmp(test_string, "DRUGGED") ) - { - pInfos[i].uEAXEnv = 23; - break; - } - if ( !strcmp(test_string, "DIZZY") ) - { - pInfos[i].uEAXEnv = 24; - break; - } - if ( !strcmp(test_string, "PSYCHOTIC") ) - { - pInfos[i].uEAXEnv = 25; - break; - } - pInfos[i].uEAXEnv = 26; - - } - break; - } - } - else - { - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<31)&&!break_loop); - } - - uNumMaps = 77; -} -// 453F62: using guessed type char Str[32]; - -//----- (004547A3) -------------------------------------------------------- -MAP_TYPE MapStats::GetMapInfo(const char *Str2) -{ - assert(uNumMaps >= 2); - - for (uint i = 1; i < uNumMaps; ++i) - if (!_stricmp(pInfos[i].pFilename, Str2)) - return (MAP_TYPE)i; - - assert(false && "Map not found!"); -} + //----- (004547E4) -------------------------------------------------------- void FactionTable::Initialize() diff -r 90f56da08d76 -r 8193a64c7461 mm7_5.cpp --- a/mm7_5.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/mm7_5.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -1060,33 +1060,6 @@ } } -//----- (00410D99) -------------------------------------------------------- -int __fastcall sub_410D99_get_map_index(int a1) -{ - int v1; // edi@1 - signed int v2; // ebp@1 - const char **v3; // esi@2 - char *v4; // ebx@2 - - __debugbreak();//Ritor1 - v1 = a1; - v2 = 1; - if ( _stricmp(pMapStats->pInfos[1].pFilename, (const char *)&pGames_LOD->pSubIndices[a1]) ) - { - v3 = (const char **)&pMapStats->pInfos[1].pFilename; - v4 = (char *)&pMapStats->pInfos[1].pFilename; - do - { - if ( !*(int *)v4 ) - break; - v3 += 17; - ++v2; - v4 = (char *)v3; - } - while ( _stricmp(*v3, (const char *)&pGames_LOD->pSubIndices[v1]) ); - } - return v2; -} // 4E28F8: using guessed type int pCurrentScreen; diff -r 90f56da08d76 -r 8193a64c7461 mm7_unsorted_subs.h --- a/mm7_unsorted_subs.h Fri Mar 14 09:32:25 2014 +0600 +++ b/mm7_unsorted_subs.h Fri Mar 14 09:32:42 2014 +0600 @@ -37,7 +37,6 @@ void __fastcall ZBuffer_DoFill(int *pZBuffer, struct Texture *pTex, int uZValue); void __fastcall ZBuffer_DoFill2(int *pZBuffer, struct Texture *a2, int a3); // idb void SetMoonPhaseNames(); -int __fastcall sub_410D99_get_map_index(int a1); void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer); void SetAttributeNames(); void uGameUIFontMain_initialize(); diff -r 90f56da08d76 -r 8193a64c7461 texts.cpp --- a/texts.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/texts.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -6,6 +6,21 @@ #include "texts.h" +std::vector Tokenize( char* input, const char separator ) +{ + std::vector retVect; + retVect.push_back(input); + while (*input) + { + if (*input == separator) + { + *input = '\0'; + retVect.push_back(input + 1); + } + ++input; + } + return retVect; +} diff -r 90f56da08d76 -r 8193a64c7461 texts.h --- a/texts.h Fri Mar 14 09:32:25 2014 +0600 +++ b/texts.h Fri Mar 14 09:32:42 2014 +0600 @@ -1,5 +1,6 @@ #pragma once #include +#include int sprintfex(char *buf, const char *format, ...); @@ -9,6 +10,7 @@ char *RemoveQuotes(char *Str); void InitializeGameText(); +std::vector Tokenize(char* input, const char separator); enum GLOBAL_LOCALIZ_INDEX {