Mercurial > mm7
changeset 289:92d443ed0cba
Слияние
author | Ritor1 |
---|---|
date | Mon, 18 Feb 2013 19:16:38 +0600 |
parents | 9a6052fecad4 (current diff) 250e49fef6f6 (diff) |
children | 4776715a964b |
files | Indoor.cpp MM7.vcxproj.filters Player.cpp mm7_5.cpp mm7_data.cpp |
diffstat | 42 files changed, 5015 insertions(+), 3813 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Actor.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -184,16 +184,13 @@ if ( !pParty->uAlignment ) { v14 = "-b"; -LABEL_7: strcat(pContainer, v14); - goto LABEL_8; } - if ( pParty->uAlignment == 2 ) + else if ( pParty->uAlignment == 2 ) { v14 = "-c"; - goto LABEL_7; + strcat(pContainer, v14); } -LABEL_8: v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); array_5913D8[6] = 0; uNumDialogueNPCPortraits = 1; @@ -203,43 +200,48 @@ pDialogueNPCPortraits[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)]; dword_591084 = areWeLoadingTexture; uTextureID_507B04 = uTextureID_right_panel; - if ( !(v5->uFlags & 0x80) && v5->house >= 0 ) + if ( !v5->Hired() && v5->house >= 0 ) { if ( (signed int)pParty->GetPartyFame() <= v5->fame || (v10 = v5->uFlags & 0xFFFFFF7F, (v5->uFlags & 0xFFFFFF7F & 0x80000000u) != 0) ) { -LABEL_16: v9 = 1; - goto LABEL_17; } - if ( v10 > 1 ) - { - if ( v10 == 2 ) - { - v16 = 3; - goto LABEL_36; - } - if ( v10 != 3 ) - { - if ( v10 == 4 ) - goto LABEL_17; - goto LABEL_16; - } -LABEL_35: - v16 = 2; -LABEL_36: - v9 = v16; - goto LABEL_17; - } - if ( v5->rep ) - goto LABEL_35; + else + { + if ( v10 > 1 ) + { + if ( v10 == 2 ) + { + v16 = 3; + v9 = v16; + } + else + { + if ( v10 != 3 ) + { + if ( v10 != 4 ) + v9 = 1; + } + else + { + v16 = 2; + v9 = v16; + } + } + } + else if ( v5->rep ) + { + v16 = 2; + v9 = v16; + } + } } -LABEL_17: if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 ) v9 = 4; v11 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)10, v9, 0); pDialogueWindow = v11; - if ( v5->uFlags & 0x80 ) + if (v5->Hired()) { if ( !v5->bHasUsedTheAbility ) { @@ -269,7 +271,7 @@ pDialogueWindow->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0); pDialogueWindow->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0); pDialogueWindow->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0); - if ( v17 && uActiveCharacter && !(v5->uFlags & 0x80) ) + if (v17 && uActiveCharacter && !v5->Hired()) { if (pParty->uCurrentHour < 5 || pParty->uCurrentHour > 21) pPlayers[uActiveCharacter]->PlaySound(SPEECH_GoodEvening, 0); @@ -2482,7 +2484,7 @@ v1 = uActiveCharacter; v7 = uActorID; - pPlayer = &pParty->pPlayers[uActiveCharacter-1];//(Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552]; + pPlayer = &pParty->pPlayers[uActiveCharacter-1]; result = pPlayer->CanAct(); if ( result ) { @@ -2977,7 +2979,6 @@ { v13 = &v14; v12 = 256; -LABEL_16: Actor::_403EB6(uActorID, v16, v12, v13); return; } @@ -2994,7 +2995,8 @@ { v13 = &v14; v12 = 256; - goto LABEL_16; + Actor::_403EB6(uActorID, v16, v12, v13); + return; } v11 = v5->uMovementSpeed; v5->uYawAngle = v10; @@ -3245,18 +3247,83 @@ if ( v8 > MONSTER_HARPY_3 ) { if ( v8 < MONSTER_OOZE_1 ) - goto LABEL_21; + { + if ( !_this.uItemID ) + { + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; + } + if ( rand() % 100 < 20 ) + { + v9 = rand(); + sub_42F7EB_DropItemAt( + pItemsTable->pItems[_this.uItemID].uSpriteID, + v1->vPosition.x, + v1->vPosition.y, + v1->vPosition.z + 16, + v9 % 200 + 200, + 1, + 1, + 0, + &_this); + } + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; + } if ( v8 <= MONSTER_OOZE_3 ) { _this.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE; - goto LABEL_21; + if ( !_this.uItemID ) + { + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; + } + if ( rand() % 100 < 20 ) + { + v9 = rand(); + sub_42F7EB_DropItemAt( + pItemsTable->pItems[_this.uItemID].uSpriteID, + v1->vPosition.x, + v1->vPosition.y, + v1->vPosition.z + 16, + v9 % 200 + 200, + 1, + 1, + 0, + &_this); + } + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; } if ( v8 <= MONSTER_PEASANT_GOBLIN_MALE_3_3 || v8 > MONSTER_TROLL_3 ) { -LABEL_21: if ( !_this.uItemID ) - goto LABEL_24; - goto LABEL_22; + { + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; + } + if ( rand() % 100 < 20 ) + { + v9 = rand(); + sub_42F7EB_DropItemAt( + pItemsTable->pItems[_this.uItemID].uSpriteID, + v1->vPosition.x, + v1->vPosition.y, + v1->vPosition.z + 16, + v9 % 200 + 200, + 1, + 1, + 0, + &_this); + } + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; } _this.uItemID = ITEM_TROLL_BLOOD; } @@ -3269,20 +3336,81 @@ else { if ( v8 < MONSTER_DEVIL_1 ) - goto LABEL_21; + { + if ( !_this.uItemID ) + { + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; + } + if ( rand() % 100 < 20 ) + { + v9 = rand(); + sub_42F7EB_DropItemAt( + pItemsTable->pItems[_this.uItemID].uSpriteID, + v1->vPosition.x, + v1->vPosition.y, + v1->vPosition.z + 16, + v9 % 200 + 200, + 1, + 1, + 0, + &_this); + } + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; + } if ( v8 > MONSTER_DEVIL_3 ) { if ( v8 <= MONSTER_DRAGON_3 ) { _this.uItemID = ITEM_DRAGON_EYE; - goto LABEL_22; + if ( rand() % 100 < 20 ) + { + v9 = rand(); + sub_42F7EB_DropItemAt( + pItemsTable->pItems[_this.uItemID].uSpriteID, + v1->vPosition.x, + v1->vPosition.y, + v1->vPosition.z + 16, + v9 % 200 + 200, + 1, + 1, + 0, + &_this); + } + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; } - goto LABEL_21; + if ( !_this.uItemID ) + { + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; + } + if ( rand() % 100 < 20 ) + { + v9 = rand(); + sub_42F7EB_DropItemAt( + pItemsTable->pItems[_this.uItemID].uSpriteID, + v1->vPosition.x, + v1->vPosition.y, + v1->vPosition.z + 16, + v9 % 200 + 200, + 1, + 1, + 0, + &_this); + } + if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) + Actor::Explode(v11); + return; } _this.uItemID = ITEM_DEVIL_ICHOR; } } -LABEL_22: if ( rand() % 100 < 20 ) { v9 = rand(); @@ -3297,7 +3425,6 @@ 0, &_this); } -LABEL_24: if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) Actor::Explode(v11); } @@ -3719,60 +3846,79 @@ v21 = 0; v24 = v6; v26 = 0; - if ( (signed int)uNumActors <= 0 ) - goto LABEL_26; - v7 = pActors; - do + if ( (signed int)uNumActors > 0 ) { - v8 = v7->uAIState; - if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) - goto LABEL_23; - if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) ) - goto LABEL_13; - if ( v7->IsAlive() == 1 ) - { - v24 = v4; - v3->uLastCharacterIDToHit = v4; -LABEL_13: - v10 = v3->GetActorsRelation(v7); - if ( v10 == v4 ) - goto LABEL_23; - goto LABEL_14; - } - v18 = v7->uGroup; - if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup ) - goto LABEL_23; - v10 = 4; -LABEL_14: - if ( v3->pMonsterInfo.uHostilityType ) - v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType; - v11 = dword_4DF380[v10]; - v23 = abs(v3->vPosition.x - v7->vPosition.x); - v27 = abs(v3->vPosition.y - v7->vPosition.y); - v12 = abs(v3->vPosition.z - v7->vPosition.z); - v19 = v12; - if ( v23 <= v11 - && v27 <= v11 - && v12 <= v11 - && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3) - && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) - { - v25 = v23 * v23 + v27 * v27 + v19 * v19; - v21 = v26; - } - v4 = 0; -LABEL_23: - ++v7; - v5 = v26++ + 1; + v7 = pActors; + do + { + v8 = v7->uAIState; + if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) + { + ++v7; + v5 = v26++ + 1; + continue; + } + if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) ) + { + v10 = v3->GetActorsRelation(v7); + if ( v10 == v4 ) + { + ++v7; + v5 = v26++ + 1; + continue; + } + } + else if ( v7->IsAlive() == 1 ) + { + v24 = v4; + v3->uLastCharacterIDToHit = v4; + v10 = v3->GetActorsRelation(v7); + if ( v10 == v4 ) + { + ++v7; + v5 = v26++ + 1; + continue; + } + } + else + { + v18 = v7->uGroup; + if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup ) + { + ++v7; + v5 = v26++ + 1; + continue; + } + v10 = 4; + } + if ( v3->pMonsterInfo.uHostilityType ) + v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType; + v11 = dword_4DF380[v10]; + v23 = abs(v3->vPosition.x - v7->vPosition.x); + v27 = abs(v3->vPosition.y - v7->vPosition.y); + v12 = abs(v3->vPosition.z - v7->vPosition.z); + v19 = v12; + if ( v23 <= v11 + && v27 <= v11 + && v12 <= v11 + && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3) + && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) + { + v25 = v23 * v23 + v27 * v27 + v19 * v19; + v21 = v26; + } + v4 = 0; + ++v7; + v5 = v26++ + 1; + } + while ( v26 < (signed int)uNumActors ); + if ( v25 != -1 ) + { + v13 = 8 * v21; + LOBYTE(v13) = 8 * v21 | 3; + *v20 = v13; + } } - while ( v26 < (signed int)uNumActors ); - if ( v25 != -1 ) - { - v13 = 8 * v21; - LOBYTE(v13) = 8 * v21 | 3; - *v20 = v13; - } -LABEL_26: if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= (signed int)v4 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > (signed int)v4 || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v4) ) a3 = v4; @@ -3870,45 +4016,33 @@ if ( a1 ) { v9 = a1->uAlly; - if ( (signed int)v9 <= 0 ) - { - if ( v9 != 9999 ) - goto LABEL_30; - } - else + if ( (signed int)v9 > 0 ) { if ( v9 != 9999 ) { v7 = a1->uAlly; - goto LABEL_30; } } - v7 = 0; -LABEL_30: + if(v9==9999) + v7 = 0; if ( (signed __int64)a1->pActorBuffs[12].uExpireTime > 0 ) v7 = 0; } - if ( !v2 ) - goto LABEL_40; - v10 = v2->uAlly; - if ( (signed int)v10 <= 0 ) - { - if ( v10 != 9999 ) - goto LABEL_38; - } - else + if ( v2 ) { - if ( v10 != 9999 ) - { - v8 = v2->uAlly; - goto LABEL_38; - } + v10 = v2->uAlly; + if ( (signed int)v10 > 0 ) + { + if ( v10 != 9999 ) + { + v8 = v2->uAlly; + } + } + if(v10==9999) + v8 = 0; + if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 ) + v8 = 0; } - v8 = 0; -LABEL_38: - if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 ) - v8 = 0; -LABEL_40: if ( a1 && (signed __int64)a1->pActorBuffs[1].uExpireTime > 0 && !v8 || v2 && (signed __int64)v2->pActorBuffs[1].uExpireTime > 0 && !v7 ) return 0; @@ -3917,7 +4051,15 @@ if ( v2 && a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && v2->uAttributes & 0x80000 ) { if ( v7 ) - goto LABEL_55; + { + if ( (signed int)v7 < 89 ) + { + if ( v8 < 89 ) + return pFactionTable->relations[v7][v8]; + return 0; + } + return 0; + } return 4; } if ( !v7 ) @@ -3925,16 +4067,18 @@ if ( (!v2 || (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 || !(v2->uAttributes & 0x80000)) && !pFactionTable->relations[v8][0]) { -LABEL_56: if ( v8 < 89 ) return pFactionTable->relations[v7][v8]; return 0; } return 4; } -LABEL_55: if ( (signed int)v7 < 89 ) - goto LABEL_56; + { + if ( v8 < 89 ) + return pFactionTable->relations[v7][v8]; + return 0; + } return 0; }
--- a/Actor.h Mon Feb 18 19:16:15 2013 +0600 +++ b/Actor.h Mon Feb 18 19:16:38 2013 +0600 @@ -23,7 +23,7 @@ int _427546(int a2); int CalcMagicalDamageToActor(struct Actor *pActor, int a2, signed int a3); bool GetMagicalResistance(struct Actor *pActor, unsigned int uType); - int FindClosesActor(int a2, int a3, int a4); + int FindClosestActor(int a2, int a3, int a4); char field_0; };
--- a/CShow.h Mon Feb 18 19:16:15 2013 +0600 +++ b/CShow.h Mon Feb 18 19:16:38 2013 +0600 @@ -41,6 +41,9 @@ //char v10; // [sp+4h] [bp-8h]@4 //int a3; // [sp+Bh] [bp-1h]@14 + if (bNoVideo) + return; + if (pAsyncMouse) pAsyncMouse->Suspend(); switch ( eVideo )
--- a/GUIButton.h Mon Feb 18 19:16:15 2013 +0600 +++ b/GUIButton.h Mon Feb 18 19:16:38 2013 +0600 @@ -21,7 +21,7 @@ unsigned int uControlID; unsigned int uControlParam; int field_28; - int field_2C; + int field_2C_is_pushed; GUIButton *pPrev; GUIButton *pNext; struct GUIWindow *pParent;
--- a/GUIWindow.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/GUIWindow.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -221,7 +221,7 @@ pRenderer->DrawTextureTransparent(uFrameX + 24, uFrameY + 24, v13); v16 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); sprintf(pTmpBuf, "\xC%05d", v16); - sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->classType]); + sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->classType]); strcat(pTmpBuf, pTmpBuf2); strcat(pTmpBuf, "\xC" "00000\n"); v20 = UI_GetHealthManaStringColor(pPlayer->sHealth, pPlayer->GetMaxHealth()); @@ -729,7 +729,7 @@ { if ( v4 ) { - v5 = sub_495461(v4, uActiveCharacter - 1, 0, 0, 0, v3); + v5 = BuilDialogueString(v4, uActiveCharacter - 1, 0, 0, 0, v3); v6 = pAutonoteFont->CalcTextHeight(v5, &v26, 1, 0); v7 = (v6 - 3) / (signed int)v26.uFrameHeight; v8 = v7 + 1; @@ -1155,7 +1155,7 @@ } else { - sprintf( pTmpBuf, pGlobalTXT_LocalizationStrings[429], + sprintfex( pTmpBuf, pGlobalTXT_LocalizationStrings[429], //p2DEvents_minus1_::08[13 * (unsigned int)ptr_507BC0->ptr_1C], p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].pProprieterName, //p2DEvents_minus1__10[13 * (unsigned int)ptr_507BC0->ptr_1C]); @@ -1727,7 +1727,7 @@ v15 = v14 + uWidth - 1; pButton->uZ = v15; v17 = pButton->uY; - pButton->field_2C = 0; + pButton->field_2C_is_pushed = 0; pButton->uW = v17 + uHeight - 1; pButton->field_1C = a7; pButton->uControlID = uControlID; @@ -1909,7 +1909,7 @@ if ( v12->joins ) { pWindow->CreateButton(0x1E0u, 0x82u, 0x8Cu, v11, 1, 0, 0x88u, 0x4Du, 0, pGlobalTXT_LocalizationStrings[407], 0);// - if ( v12->uFlags & 0x80 ) + if (v12->Hired()) { sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v12->pName); // pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x4Cu, 0, pTmpBuf, 0);
--- a/GUIWindow.h Mon Feb 18 19:16:15 2013 +0600 +++ b/GUIWindow.h Mon Feb 18 19:16:38 2013 +0600 @@ -25,10 +25,17 @@ enum DIALOGUE_TYPE { + DIALOGUE_9 = 9, DIALOGUE_13 = 0xD, DIALOGUE_18 = 0x12, + DIALOGUE_19 = 19, + DIALOGUE_20 = 20, + DIALOGUE_21 = 21, + DIALOGUE_22 = 22, + DIALOGUE_23 = 23, DIALOGUE_24 = 0x18, - DIALOGUE_77 = 0x4D, + DIALOGUE_76 = 76, + DIALOGUE_PROFESSION_DETAILS = 77, DIALOGUE_ARENA_WELCOME = 0x59, DIALOGUE_ARENA_FIGHT_NOT_OVER_YET = 0x5A, DIALOGUE_ARENA_REWARD = 0x5B, @@ -159,7 +166,7 @@ UIMSG_E = 0xE, UIMSG_F = 0xF, UIMSG_11 = 0x11, - UIMSG_17 = 0x17, + UIMSG_Attack = 23, UIMSG_19 = 0x19, UIMSG_1B = 0x1B, UIMSG_1C = 0x1C, @@ -230,7 +237,7 @@ UIMSG_85 = 0x85, UIMSG_StartHireling1Dialogue = 0x86, UIMSG_StartHireling2Dialogue = 0x87, - UIMSG_88 = 0x88, + UIMSG_SelectDialogueOption = 0x88, UIMSG_8C = 0x8C, UIMSG_8D = 0x8D, UIMSG_8E = 0x8E, @@ -388,6 +395,11 @@ + +void OnSelectDialogueOption(DIALOGUE_TYPE newDialogueType); + + + extern int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[]; // idb extern struct GUIWindow *pWindow_MainMenu; extern struct GUIWindow pWindowList[20]; \ No newline at end of file
--- a/Game.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Game.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -94,14 +94,14 @@ if ( !pRenderer->pRenderD3D ) pMouse->DrawCursorToTarget(); - if ( !sub_4226C2() || viewparams->field_48 == 1 ) + if ( !PauseGameDrawing() || viewparams->field_48 == 1 ) { if ( pRenderer->pRenderD3D ) { float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0; //v3 = v2 + 6.7553994e15; //pRenderer->field_1036A8_bitmapid = LODWORD(v3); - pRenderer->field_1036A8_bitmapid = floorf(v2 + 0.5f); + pRenderer->hd_water_current_frame = floorf(v2 + 0.5f); } if (uCurrentlyLoadedLevelType == LEVEL_Indoor) @@ -142,7 +142,7 @@ GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2); if (v4) { - if ( !sub_4226C2() && pRenderer->pRenderD3D) // clear game viewport with transparent color + if ( !PauseGameDrawing() && pRenderer->pRenderD3D) // clear game viewport with transparent color pRenderer->FillRectFast(pViewport->uViewportX, pViewport->uViewportY, pViewport->uViewportZ - pViewport->uViewportX, pViewport->uViewportW - pViewport->uViewportY + 1, pRenderer->uTargetGMask | pRenderer->uTargetBMask); @@ -1051,7 +1051,7 @@ //----- (0044EB12) -------------------------------------------------------- bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) { - if ( !pCurrentScreen && pVisInstance && pRenderer->pRenderD3D ) + if (pCurrentScreen == SCREEN_GAME && pVisInstance && pRenderer->pRenderD3D) { bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter);
--- a/Indoor.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Indoor.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -559,10 +559,10 @@ pFace->uSectorID); if (pFace->Animated() && - pFace->uBitmapID == pRenderer->field_1036AC_bitmapid ) + pFace->uBitmapID == pRenderer->hd_water_tile_id ) { __debugbreak(); - v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; goto LABEL_42; }
--- a/Items.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Items.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -53,7 +53,6 @@ UpdateTempBonus(pParty->uTimePlayed); if ( v4->uItemID == 501 ) { -LABEL_45: *v3 = 1; v10 = rand(); v17 = 10; @@ -73,13 +72,17 @@ return v9 + 9; } if ( v4->uItemID == 517 ) - goto LABEL_36; + { + v5 = 8; + *v3 = v5; + return v5; + } v8 = v4->uAdditionalValue; if ( v8 > 46 ) { -LABEL_42: v5 = 0; - goto LABEL_37; + *v3 = v5; + return v5; } if ( v8 == 46 ) { @@ -113,14 +116,14 @@ *a3 = 1; return v5; } - goto LABEL_42; + v5 = 0; + *v3 = v5; + return v5; } *v3 = 2; return 12; } -LABEL_36: v5 = 8; -LABEL_37: *v3 = v5; return v5; } @@ -160,9 +163,18 @@ return rand() % 7 + 4; } if ( v8 == 9 ) - goto LABEL_45; + { + *v3 = 1; + v10 = rand(); + v17 = 10; + return v10 % v17 + 6; + } if ( v8 != 10 ) - goto LABEL_42; + { + v5 = 0; + *v3 = v5; + return v5; + } *v3 = 0; v7 = 1; return GetDiceResult(v7, 6u); @@ -1381,7 +1393,7 @@ v1 = this; uBaseValue = pItemsTable->pItems[this->uItemID].uValue; if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->_456D5E_is_some_material(this) ) - goto LABEL_12; + return uBaseValue; if ( v1->_bonus_type ) { v3 = 100 * v1->_bonus_strength; @@ -1390,12 +1402,11 @@ v4 = v1->uAdditionalValue; if ( !v4 ) { -LABEL_12: result = uBaseValue; } else { - v3 = *(unsigned int *)&pItemsTable->pEnchantments[23].to_item[28 * v4 + 8]; + v3 = pItemsTable->pSpecialEnchantments[v4].iTreasureLevel; if ( (unsigned int)v3 > 0xA ) return uBaseValue + v3; result = uBaseValue * v3; @@ -1437,7 +1448,6 @@ v11 = pItemsTable->pItems[v2].pName; v4 = item__getname_buffer; v10 = "%s"; -LABEL_10: sprintf(v4, v10, v11); return v4; } @@ -1457,7 +1467,8 @@ v10 = pGlobalTXT_LocalizationStrings[655]; else v10 = pGlobalTXT_LocalizationStrings[654]; - goto LABEL_10; + sprintf(v4, v10, v11); + return v4; } } } @@ -1491,12 +1502,12 @@ sprintf( item__getname_buffer, "%s %s", - *(unsigned int *)&pItemsTable->pEnchantments[22].to_item[28 * v7 + 8], + pItemsTable->pSpecialEnchantments[v7].pBonusStatement, pItemsTable->pItems[v1->uItemID].pName); return v4; } strcat(item__getname_buffer, " "); - v9 = *(const char **)&pItemsTable->pEnchantments[22].to_item[28 * v1->uAdditionalValue + 8]; + v9 = pItemsTable->pSpecialEnchantments[v1->uAdditionalValue].pBonusStatement; } strcat(item__getname_buffer, v9); } @@ -1674,9 +1685,7 @@ --v14; } while ( v14 ); -LABEL_72: v4->_bonus_type = v15 * treasure_level; - goto LABEL_73; } } else @@ -1719,10 +1728,9 @@ --v19; } while ( v19 ); - goto LABEL_72; + v4->_bonus_type = v15 * treasure_level; } } -LABEL_73: if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) ) v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; @@ -1763,13 +1771,10 @@ v23 = rand(); v24 = *(unsigned int *)v22; v25 = v23 % 100; - if ( v23 % 100 < v24 ) - goto LABEL_127; - if ( !uBonusChanceSpecial[v6] ) + if ( !uBonusChanceSpecial[v6] && !(v23 % 100 < v24)) return; - if ( v25 < v24 ) + if ( v25 < v24 || v23 % 100 < v24) { -LABEL_127: v26 = rand() % 10;//v5->field_116D8[v5->pItems[v4->uItemID].uEquipType]; v27 = v4->uItemID; v4->_bonus_type = 0; @@ -1812,14 +1817,24 @@ { case 2: if ( !*(unsigned char *)v40 ) - goto LABEL_117; + { + v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); + if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) + { + v44 = v58; + ++v58; + *v44 = a2b; + } + ++a2b; + v40 += 28; + continue; + } v41 = *(unsigned char *)v40 == 1; break; case 3: v43 = *(unsigned char *)v40; if ( !*(unsigned char *)v40 || v43 == 1 ) { -LABEL_117: v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) { @@ -1827,24 +1842,49 @@ ++v58; *v44 = a2b; } - goto LABEL_119; + ++a2b; + v40 += 28; + continue; } v41 = v43 == 2; break; case 4: v42 = *(unsigned char *)v40; if ( *(unsigned char *)v40 == 1 || v42 == 2 ) - goto LABEL_117; + { + v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); + if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) + { + v44 = v58; + ++v58; + *v44 = a2b; + } + ++a2b; + v40 += 28; + continue; + } v41 = v42 == 3; break; default: if ( v6 != 5 ) - goto LABEL_119; + { + ++a2b; + v40 += 28; + continue; + } v41 = *(unsigned char *)v40 == 3; break; } if ( v41 ) - goto LABEL_117; + { + v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); + if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) + { + v44 = v58; + ++v58; + *v44 = a2b; + } + } LABEL_119: ++a2b; v40 += 28;
--- a/Items.h Mon Feb 18 19:16:15 2013 +0600 +++ b/Items.h Mon Feb 18 19:16:38 2013 +0600 @@ -26,6 +26,8 @@ ITEM_CROSSBOW_1 = 0x2F, ITEM_MACE_1 = 0x32, ITEM_STAFF_1 = 0x3D, + ITEM_BLASTER = 65, + ITEM_LASER_RIFLE = 66, ITEM_LEATHER_1 = 0x42, ITEM_CHAINMAIL_1 = 0x47, ITEM_PLATE_1 = 0x4C, @@ -94,6 +96,8 @@ Reset(); } + inline bool Broken() {return uAttributes & ITEM_BROKEN;} + bool GenerateArtifact(); unsigned int GetValue(); const char *GetDisplayName();
--- a/Keyboard.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Keyboard.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -36,6 +36,7 @@ KeyboardActionMapping::KeyboardActionMapping() { uLastKeyPressed = 0; + field_204 = 0; SetDefaultMapping(); ReadMappings();
--- a/LOD.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/LOD.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -2869,15 +2869,15 @@ ptr_011BB4 = new char[1000]; memset(ptr_011BB4, 0, 1000); } - if (strcmp(pContainer, "wtrdr"))//*v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' ) + if (strnicmp(pContainer, "wtrdr", 5))//*v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' ) { - if (strcmp(pContainer, "WtrTyl"))//if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' ) + if (strnicmp(pContainer, "WtrTyl", 6))//if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' ) { v14 = uNumLoadedFiles; } else { - pRenderer->field_1036AC_bitmapid = uNumLoadedFiles; + pRenderer->hd_water_tile_id = uNumLoadedFiles; v14 = uNumLoadedFiles; } v13 = pRenderer->LoadTexture(
--- a/LayingItem.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/LayingItem.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -64,14 +64,14 @@ { v17 = 0; v11 = 5; - if ( pMapInfo->field_2E ) + if ( pMapInfo->Trap_D20 ) { do { ++v17; v11 += rand() % 20 + 1; } - while ( v17 < pMapInfo->field_2E ); + while ( v17 < pMapInfo->Trap_D20 ); } switch ( v1->uItemType ) {
--- a/MM7.vcxproj.filters Mon Feb 18 19:16:15 2013 +0600 +++ b/MM7.vcxproj.filters Mon Feb 18 19:16:38 2013 +0600 @@ -317,8 +317,10 @@ <ClCompile Include="FrameTableInc.cpp" /> <ClCompile Include="mm7_6.cpp" /> <ClCompile Include="GameUIs.cpp" /> + <ClCompile Include="StorylineTextTable.cpp" /> <ClCompile Include="texts.cpp" /> - <ClCompile Include="StorylineTextTable.cpp" /> + <ClCompile Include="mm7text_ru.cpp" /> + <ClCompile Include="NPC.cpp" /> </ItemGroup> <ItemGroup> <ResourceCompile Include="Might and Magic Trilogy.rc" />
--- a/MapInfo.h Mon Feb 18 19:16:15 2013 +0600 +++ b/MapInfo.h Mon Feb 18 19:16:38 2013 +0600 @@ -20,20 +20,20 @@ int _steal_perm; int _per; char field_2C; - char field_2D; - char field_2E; - char field_2F; - char field_30; - char field_31; - char field_32; - char field_33; - char field_34; + char LockX5; + char Trap_D20; + char Treasure_prob; + char Encounter_percent; + char EncM1percent; + char EncM2percent; + char EncM3percent; + char Dif_M1; unsigned __int8 uEncounterMonster1AtLeast; unsigned __int8 uEncounterMonster1AtMost; - char field_37; + char Dif_M2; unsigned __int8 uEncounterMonster2AtLeast; unsigned __int8 uEncounterMonster2AtMost; - char field_3A; + char Dif_M3; unsigned __int8 uEncounterMonster3AtLeast; unsigned __int8 uEncounterMonster3AtMost; char field_3D;
--- a/Monsters.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Monsters.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -215,67 +215,49 @@ //----- (00454F4E) -------------------------------------------------------- void MonsterStats::InitializePlacements() { - char *v1; // ebx@1 - MonsterStats *v2; // edi@1 - char *v3; // eax@2 - char v4; // dl@3 - char *v5; // ecx@3 - int v6; // esi@7 - signed int v7; // [sp+Ch] [bp-10h]@1 - char **v8; // [sp+10h] [bp-Ch]@1 - signed int v9; // [sp+14h] [bp-8h]@2 - char *v10; // [sp+18h] [bp-4h]@2 + 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; - v1 = 0; - v2 = this; pMonsterPlacementTXT_Raw = (char *)pEvents_LOD->LoadRaw("placemon.txt", 0); strtok(pMonsterPlacementTXT_Raw, "\r"); - v2->uNumPlacements = 31; - v8 = v2->pPlacement.pSubstrings; - v7 = 30; - do - { - v3 = strtok(v1, "\r") + 1; - v10 = v1; - v9 = (signed int)v1; - do - { - v4 = *v3; - v5 = 0; - if ( *v3 != 9 ) - { - v1 = 0; - do - { - if ( !v4 ) - break; - ++v5; - v4 = v3[(unsigned int)v5]; - } - while ( v4 != 9 ); - } - v6 = (int)&v3[(unsigned int)v5]; - if ( v3[(unsigned int)v5] == (unsigned char)v1 ) - v9 = 1; - *(unsigned char *)v6 = (unsigned char)v1; - if ( v5 == v1 ) - { - v9 = 1; - } - else - { - if ( v10 == (char *)1 ) - *v8 = (char *)RemoveQuotes(v3); - } - ++v10; - v3 = (char *)(v6 + 1); - } - while ( (signed int)(v10 - 1) <= 31 && (char *)v9 == v1 ); - ++v8; - --v7; - } - while ( v7 ); - v2->uNumPlacements = 31; + for (i=1; i<31; ++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 (decode_step==1) + pPlaceStrings[i]=RemoveQuotes(test_string); + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<3)&&!break_loop); + } + uNumPlacements = 31; } //----- (0045501E) --------------------------------------------------------
--- a/Monsters.h Mon Feb 18 19:16:15 2013 +0600 +++ b/Monsters.h Mon Feb 18 19:16:38 2013 +0600 @@ -141,15 +141,8 @@ }; #pragma pack(pop) -/* 188 */ -#pragma pack(push, 1) -struct MonsterPlacement -{ - unsigned int uNumStrings; - char *pSubstrings[30]; -}; -#pragma pack(pop) + /* 189 */ #pragma pack(push, 1) struct MonsterStats @@ -160,10 +153,10 @@ static bool BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype); - MonsterInfo pInfos[265]; - MonsterPlacement pPlacement; - unsigned int uNumMonsters; - unsigned int uNumPlacements; + MonsterInfo pInfos[265]; //0 - 5b18h + char *pPlaceStrings[31];; //5B18h placement counts from 1 + unsigned int uNumMonsters; //5B94h + unsigned int uNumPlacements; //5B98h int field_5B9C; }; #pragma pack(pop)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NPC.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -0,0 +1,1202 @@ +#include <string.h> +#include <stdlib.h> + +#include "Allocator.h" +#include "texts.h" +#include "Party.h" +#include "LOD.h" +#include "Autonotes.h" +#include "Awards.h" +#include "mm7_data.h" +#include "MM7.h" +#include "NPC.h" + + +void InitializeAwards(); +void InitializeScrolls(); +void InitializeMerchants(); +void InitializeTransitions(); +void InitializeAutonotes(); +void InitializeQuests(); + + +//----- (00476977) -------------------------------------------------------- +void NPCStats::Initialize2() + { + int i; + char* test_string; + unsigned char c; + bool break_loop; + unsigned int temp_str_len; + char* tmp_pos; + int decode_step; + + if (pNPCTextTXT_Raw) + pAllocator->FreeChunk(pNPCTextTXT_Raw); + pNPCTextTXT_Raw =NULL; + pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); + strtok(pNPCTextTXT_Raw, "\r"); + + for (i=0; i<789; ++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 ( decode_step == 1) + pNPCTopics[i].pText =RemoveQuotes(test_string); + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<2)&&!break_loop); + } + + if (pNPCTopicTXT_Raw) + pAllocator->FreeChunk(pNPCTopicTXT_Raw); + pNPCTopicTXT_Raw =NULL; + pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0); + strtok(pNPCTopicTXT_Raw, "\r"); + + for (i=0; i<579; ++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 ( decode_step == 1) + pNPCTopics[i].pTopic = RemoveQuotes(test_string); + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<2)&&!break_loop); + } + + if (pNPCDistTXT_Raw) + pAllocator->FreeChunk(pNPCDistTXT_Raw); + pNPCDistTXT_Raw = NULL; + pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0); + strtok(pNPCDistTXT_Raw, "\r"); + strtok(NULL, "\r"); + + for (i=1; i<59; ++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 ((decode_step>0)&&(decode_step<77)) + { + array_16544[decode_step].field_4[i]=atoi(test_string); + } + else if (decode_step==0) + { + array_16544[0].field_4[i]=10; + } + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<78)&&!break_loop); + } + + for (i=0; i<78; ++i) + { + array_16544[i].field_0=0; + for (int ii=1; ii<59; ++ii) + { + array_16544[i].field_0+=array_16544[i].field_4[ii]; + } + } + + if (pNPCDistTXT_Raw) + { + pAllocator->FreeChunk(pNPCDistTXT_Raw); + pNPCDistTXT_Raw = NULL; + } + } + +//----- (00476C60) -------------------------------------------------------- +void NPCStats::_476C60() + { + for (unsigned int i = 1; i < uNumNewNPCs; ++i) + pNewNPCData[i].pName = pNPCNames2[i - 1]; + + if (pParty->pHirelings[0].pName) + pParty->pHirelings[0].pName = pParty->pHireling1Name; + if (pParty->pHirelings[1].pName) + pParty->pHirelings[1].pName = pParty->pHireling2Name; + } + +//----- (00476CB5) -------------------------------------------------------- +void NPCStats::Initialize1() + { + NPCStats *pNPCStats; // esi@1 + char *pRaw; // eax@1 + char *pHouse; // edi@1 + char *v4; // eax@2 + char v5; // dl@3 + int v6; // ecx@3 + char *v7; // eax@11 + char *v8; // eax@26 + char *v9; // ecx@27 + char v10; // dl@28 + int v11; // eax@28 + int v12; // edi@32 + char *v13; // eax@42 + char *v14; // eax@43 + char v15; // dl@44 + int v16; // ecx@44 + int v17; // edi@48 + char *v18; // eax@56 + char *v19; // eax@57 + char v20; // cl@58 + int v21; // edi@58 + int v22; // esi@62 + int v23; // [sp+Ch] [bp-14h]@7 + signed int v24; // [sp+10h] [bp-10h]@1 + signed int v25; // [sp+10h] [bp-10h]@26 + signed int v26; // [sp+10h] [bp-10h]@42 + signed int v27; // [sp+10h] [bp-10h]@56 + char *Str; // [sp+14h] [bp-Ch]@1 + NPCGreeting *pGreetings; // [sp+14h] [bp-Ch]@26 + unsigned __int16 *pGroups; // [sp+14h] [bp-Ch]@42 + char **pCatchPhrase; // [sp+14h] [bp-Ch]@56 + signed int v32; // [sp+18h] [bp-8h]@2 + signed int v33; // [sp+18h] [bp-8h]@27 + signed int v34; // [sp+18h] [bp-8h]@43 + signed int v35; // [sp+18h] [bp-8h]@57 + signed int v36; // [sp+1Ch] [bp-4h]@2 + signed int v37; // [sp+1Ch] [bp-4h]@27 + signed int v38; // [sp+1Ch] [bp-4h]@43 + signed int v39; // [sp+1Ch] [bp-4h]@57 + + pNPCStats = this; + pRaw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0); + pNPCStats->pNPCDataTXT_Raw = pRaw; + strtok(pRaw, "\r"); + strtok(0, "\r"); + pHouse = (char *)&pNPCStats->pNPCData[1].house; + Str = (char *)pNPCStats->pNPCNames2; + v24 = 500; + do + { + v32 = 0; + v4 = strtok(0, "\r") + 1; + v36 = -1; + do + { + v5 = *v4; + v6 = 0; + while ( v5 != 9 && v5 ) + { + ++v6; + v5 = v4[v6]; + } + v23 = (int)&v4[v6]; + if ( !v4[v6] ) + v32 = 1; + v4[v6] = 0; + if ( v6 ) + { + switch ( v36 ) + { + case 0: + v7 = RemoveQuotes(v4); + *((int *)pHouse - 5) = (int)v7; + *(int *)Str = (int)v7; + break; + case 1: + *((int *)pHouse - 4) = atoi(v4); + break; + case 5: + *(int *)pHouse = atoi(v4); + break; + case 6: + *((int *)pHouse + 1) = atoi(v4); + break; + case 7: + *((int *)pHouse + 2) = atoi(v4); + break; + case 8: + *((int *)pHouse + 3) = *v4 == 121; + break; + case 9: + *((int *)pHouse + 5) = atoi(v4); + break; + case 10: + *((int *)pHouse + 6) = atoi(v4); + break; + case 11: + *((int *)pHouse + 7) = atoi(v4); + break; + case 12: + *((int *)pHouse + 8) = atoi(v4); + break; + case 13: + *((int *)pHouse + 9) = atoi(v4); + break; + case 14: + *((int *)pHouse + 10) = atoi(v4); + break; + default: + break; + } + } + ++v36; + v4 = (char *)(v23 + 1); + } + while ( v36 + 1 <= 15 && !v32 ); + Str += 4; + pHouse += 76; + --v24; + } + while ( v24 ); + pNPCStats->uNumNewNPCs = 501; + v8 = (char *)pEvents_LOD->LoadRaw("npcgreet.txt", 0); + pNPCStats->pNPCGreetTXT_Raw = v8; + strtok(v8, "\r"); + pGreetings = pNPCStats->pNPCGreetings; + v25 = 205; + do + { + v37 = 0; + v33 = 0; + v9 = strtok(0, "\r") + 1; + do + { + v10 = *v9; + v11 = 0; + while ( v10 != 9 && v10 ) + { + ++v11; + v10 = v9[v11]; + } + v12 = (int)&v9[v11]; + if ( !v9[v11] ) + v33 = 1; + *(char *)v12 = 0; + if ( v11 ) + { + if ( v37 == 1 ) + { + pGreetings->pGreeting1 = (char *)RemoveQuotes(v9); + } + else + { + if ( v37 == 2 ) + pGreetings->pGreeting2 = (char *)RemoveQuotes(v9); + } + } + ++v37; + v9 = (char *)(v12 + 1); + } + while ( v37 <= 2 && !v33 ); + ++pGreetings; + --v25; + } + while ( v25 ); + v13 = (char *)pEvents_LOD->LoadRaw("npcgroup.txt", 0); + pNPCStats->pNCPGroupTXT_Raw = v13; + strtok(v13, "\r"); + pGroups = pNPCStats->pGroups; + v26 = 51; + do + { + v14 = strtok(0, "\r") + 1; + v38 = 0; + v34 = 0; + do + { + v15 = *v14; + v16 = 0; + while ( v15 != 9 && v15 ) + { + ++v16; + v15 = v14[v16]; + } + v17 = (int)&v14[v16]; + if ( !v14[v16] ) + v34 = 1; + *(char *)v17 = 0; + if ( v16 && v38 == 1 ) + *pGroups = atoi(v14); + ++v38; + v14 = (char *)(v17 + 1); + } + while ( v38 <= 1 && !v34 ); + ++pGroups; + --v26; + } + while ( v26 ); + v18 = (char *)pEvents_LOD->LoadRaw("npcnews.txt", 0); + pNPCStats->pNPCNewsTXT_Raw = v18; + strtok(v18, "\r"); + pCatchPhrase = pNPCStats->pCatchPhrases; + v27 = 51; + do + { + v19 = strtok(0, "\r") + 1; + v39 = 0; + v35 = 0; + do + { + v20 = *v19; + v21 = 0; + while ( v20 != 9 && v20 ) + { + ++v21; + v20 = v19[v21]; + } + v22 = (int)&v19[v21]; + if ( !v19[v21] ) + v35 = 1; + *(char *)v22 = 0; + if ( v21 && v39 == 1 ) + *pCatchPhrase = (char *)RemoveQuotes(v19); + ++v39; + v19 = (char *)(v22 + 1); + } + while ( v39 <= 1 && !v35 ); + ++pCatchPhrase; + --v27; + } + while ( v27 ); + } + +//----- (0047702F) -------------------------------------------------------- +void NPCStats::Initialize() + { + //NPCStats *v1; // edi@1 + char *v2; // ebx@1 + //char *v3; // eax@1 + char *v4; // ebx@3 + char v5; // al@4 + int v6; // ecx@4 + //char *v7; // eax@18 + char *v8; // ebx@18 + char *v9; // ecx@19 + char v10; // dl@20 + int v11; // eax@20 + char v12; // zf@41 + signed int v13; // [sp+Ch] [bp-14h]@18 + int v14; // [sp+10h] [bp-10h]@4 + int v15; // [sp+10h] [bp-10h]@24 + char *v16; // [sp+14h] [bp-Ch]@1 + signed int v17; // [sp+14h] [bp-Ch]@19 + unsigned int v18; // [sp+18h] [bp-8h]@1 + char *v19; // [sp+18h] [bp-8h]@18 + signed int v20; // [sp+1Ch] [bp-4h]@3 + signed int v21; // [sp+1Ch] [bp-4h]@19 + //v1 = this; + + Initialize1(); + Initialize2(); + + InitializeQuests(); + InitializeAutonotes(); + InitializeAwards(); + InitializeTransitions(); + InitializeMerchants(); + InitializeScrolls(); + v2 = 0; + field_17FC0 = 0; + pNPCNamesTXT_Raw = 0; + //v3 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); + pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); + strtok(pNPCNamesTXT_Raw, "\r"); + v18 = 0; + v16 = (char *)pNPCNames; + while ( 1 ) + { + v4 = strtok(v2, "\r") + 1; + v20 = 0; + do + { + v5 = *v4; + v6 = 0; + v14 = 0; + if ( *v4 == 9 ) + goto LABEL_45; + do + { + if ( !v5 ) + break; + if ( v5 == 10 ) + break; + ++v6; + v14 = v6; + v5 = v4[v6]; + } + while ( v5 != 9 ); + if ( v6 ) + { + v4[v6] = 0; + if ( v20 ) + { + if ( v20 == 1 ) + *((int *)v16 + 1) = (int)RemoveQuotes(v4); + } + else + { + *(int *)v16 = (int)RemoveQuotes(v4); + } + } + else + { +LABEL_45: + if ( v20 == 1 && !uNumNPCNames[1] ) + uNumNPCNames[1] = v18; + } + ++v20; + v4 += v14 + 1; + } + while ( v20 <= 1 ); + ++v18; + v16 += 8; + if ( (signed int)v18 >= 540 ) + break; + v2 = 0; + } + pNPCProfTXT_Raw = 0; + uNumNPCNames[0] = v18; + //v7 = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); + pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); + strtok(pNPCProfTXT_Raw, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + v8 = (char *)&pProfessions[0].pJoinText; + v19 = (char *)&pProfessions[0].pJoinText; + v13 = 58; + do + { + v21 = 0; + v9 = strtok(0, "\r") + 1; + v17 = 0; + do + { + v10 = *v9; + v11 = 0; + if ( *v9 != 9 ) + { + do + { + if ( !v10 ) + break; + ++v11; + v10 = v9[v11]; + } + while ( v10 != 9 ); + v8 = v19; + } + v15 = (int)&v9[v11]; + if ( !v9[v11] ) + v17 = 1; + *(char *)v15 = 0; + if ( v11 ) + { + switch ( v21 ) + { + case 2: + *((int *)v8 - 3) = atoi(v9); + break; + case 3: + *((int *)v8 - 1) = (int)RemoveQuotes(v9); + break; + case 4: + *((int *)v8 - 2) = (int)RemoveQuotes(v9); + break; + case 5: + *(int *)v8 = (int)RemoveQuotes(v9); + break; + case 6: + *((int *)v8 + 1) = (int)RemoveQuotes(v9); + break; + } + } + else + { + if ( !v21 ) + v17 = 1; + } + ++v21; + v9 = (char *)(v15 + 1); + } + while ( v21 <= 6 && !v17 ); + v8 += 20; + v12 = v13-- == 1; + v19 = v8; + } + while ( !v12 ); + uNumNPCProfessions = 59; + } + +//----- (00477266) -------------------------------------------------------- +void NPCStats::Release() + { + NPCStats *v1; // esi@1 + void *v2; // ST00_4@1 + int v3; // ebx@1 + + v1 = this; + pAllocator->FreeChunk(this->pNPCTopicTXT_Raw); + v2 = v1->pNPCTextTXT_Raw; + v1->pNPCNewsTXT_Raw = 0; + pAllocator->FreeChunk(v2); + v1->pNPCNewsTXT_Raw = 0; + pAllocator->FreeChunk(0); + v1->pNPCNewsTXT_Raw = 0; + pAllocator->FreeChunk(v1->pNPCProfTXT_Raw); + v1->pNPCProfTXT_Raw = 0; + pAllocator->FreeChunk(v1->pNPCNamesTXT_Raw); + v1->pNPCNamesTXT_Raw = 0; + pAllocator->FreeChunk(v1->pNPCDataTXT_Raw); + v1->pNPCDataTXT_Raw = 0; + pAllocator->FreeChunk(v1->pNPCDistTXT_Raw); + v1->pNPCDistTXT_Raw = 0; + v3 = (int)&v1->pNPCGreetTXT_Raw; + pAllocator->FreeChunk(v1->pNPCGreetTXT_Raw); + v1 = (NPCStats *)((char *)v1 + 98296); + *(int *)v3 = 0; + pAllocator->FreeChunk(v1->pNPCData[0].pName); + v1->pNPCData[0].pName = 0; + } + +//----- (0047730C) -------------------------------------------------------- +int __fastcall const_1(int a1, int) + { + return 1; + } +// 47730C: using guessed type int __stdcall const_1(int); + +//----- (0047732C) -------------------------------------------------------- +bool NPCStats::InitializeAdditionalNPCs(NPCData *a2, int a3, int a4, int a5) + { + //NPCStats *v5; // ebx@1 + signed __int64 v6; // qax@1 + int v7; // esi@1 + int v8; // edx@1 + NPCData *v9; // edi@1 + int v10; // eax@1 + //int v11; // eax@23 + int v12; // ecx@23 + int v13; // edx@28 + int v14; // esi@37 + int v15; // edx@37 + int v16; // ecx@37 + int v17; // eax@37 + int v18; // edx@37 + signed int result; // eax@39 + int v20; // [sp+Ch] [bp-Ch]@1 + signed int v21; // [sp+10h] [bp-8h]@1 + signed int v22; // [sp+14h] [bp-4h]@1 + int v23; // [sp+24h] [bp+Ch]@1 + + + v23 = a3 - 1; + //v5 = this; + v6 = (signed __int64)((double)v23 * -0.33333334); + v7 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 28]; + v20 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 116]; + v8 = rand() % uNumNPCNames[v7]; + v9 = a2; + a2->uSex = v7; + a2->pName = pNPCNames[v8][v7]; + v10 = 0; + v22 = 0; + v21 = 0; + + while ( 1 ) + { + if ( v20 == v10 ) + { + if ( v7 == v10 ) + { + v23 = 2; + a2 = (NPCData *)100; + } + else + { + if ( v7 - v10 == 1 ) + { + v23 = 201; + a2 = (NPCData *)250; + } + } + } + else + { + switch ( v20 - v10 ) + { + case 1: + if ( v7 == v10 ) + { + v23 = 400; + a2 = (NPCData *)430; + } + else + { + if ( v7 - v10 == 1 ) + { + v23 = 460; + a2 = (NPCData *)490; + } + } + break; + case 2: + if ( v7 == v10 ) + { + v23 = 500; + a2 = (NPCData *)520; + } + else + { + if ( v7 - v10 == 1 ) + { + v23 = 530; + a2 = (NPCData *)550; + } + } + break; + case 3: + if ( v7 == v10 ) + { + v23 = 300; + a2 = (NPCData *)330; + } + else + { + if ( v7 - v10 == 1 ) + { + v23 = 360; + a2 = (NPCData *)387; + } + } + break; + } + } + v12 = v23 + rand() % ((int)a2 - v23 + 1); + if ( const_1(v12, v7) == 1 ) + v21 = 1; + ++v22; + if ( v22 >= 4 ) + { + v12 = v23; + v21 = 1; + } + if ( v21 ) + break; + v10 = 0; + } + + v9->uPortraitID = v12; + v9->uFlags = 0; + v9->fame = 0; + v13 = rand() % 100 + 1; + + if ( v13 >= 60 ) + { + if ( v13 >= 90 ) + { + if ( v13 >= 95 ) + { + if ( v13 >= 98 ) + v9->rep = -600; + else + v9->rep = 400; + } + else + { + v9->rep = -300; + } + } + else + { + v9->rep = 200; + } + } + else + { + v9->rep = 0; + } + + //v14 = (int)((char *)v5 + 64 * a5); + //v15 = rand() % *(_DWORD *)(v14 + 91460); + v15 = rand() % array_16544[a5].field_0; + v16 = 0; + v17 = 0; + v18 = v15 + 1; + + if ( v18 > 0 ) + { + do + //v14 += *(char *)(v14 + v17++ + 0x16548); + v16 += array_16544[a5].field_4[v17++]; + while ( v16 < v18 ); + } + v9->uProfession = v17 - 1; + v9->house = a4; + v9->field_24 = 1; + v9->joins = 1; + return true; + } + + +//----- (00476387) -------------------------------------------------------- +bool PartyHasDragon() +{ + return pNPCStats->pNewNPCData[57].Hired(); +} + +//----- (00476395) -------------------------------------------------------- +//0x26 Wizard eye at skill level 2 +bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession) + { + bool result; // eax@2 + signed int v2; // esi@3 + char *v3; // eax@4 + + if ( bNoNPCHiring == 1 ) + return 0; + v2 = 0; + if ( (signed int)pNPCStats->uNumNewNPCs <= 0 ) + { +LABEL_8: + result = 0; + if ( pParty->pHirelings[0].uProfession != uProfession ) + { + LOBYTE(result) = pParty->pHirelings[1].uProfession == uProfession; + return result; + } + } + else + { + v3 = (char *)&pNPCStats->pNewNPCData[0].uFlags; + while ( *((int *)v3 + 4) != uProfession || !(*v3 & 0x80) ) + { + ++v2; + v3 += 76; + if ( v2 >= (signed int)pNPCStats->uNumNewNPCs ) + goto LABEL_8; + } + result = 0; + } + ++result; + return result; + } +// 6BE3C5: using guessed type char bNoNPCHiring; + +//----- (004763E0) -------------------------------------------------------- +void InitializeAwards() + { + + 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 ( pAwardsTXT_Raw ) + pAllocator->FreeChunk(pAwardsTXT_Raw); + pAwardsTXT_Raw = NULL; + pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0); + strtok(pAwardsTXT_Raw, "\r"); + + for (i=1; i<104; ++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 (decode_step==1) + pAwards[i].pText=RemoveQuotes(test_string); + else if (decode_step==2) + pAwards[i].uSort=atoi(test_string); + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<3)&&!break_loop); + } + + } +// 7241C8: using guessed type int dword_7241C8; + +//----- (004764C2) -------------------------------------------------------- +void InitializeScrolls() + { + + 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 ( pScrollsTXT_Raw ) + pAllocator->FreeChunk(pScrollsTXT_Raw); + pScrollsTXT_Raw = NULL; + pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0); + strtok(pScrollsTXT_Raw, "\r"); + for (i=0; i<82; ++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 ( decode_step == 1) + pScrolls[i]=RemoveQuotes(test_string); + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<2)&&!break_loop); + } + } + + +//----- (00476590) -------------------------------------------------------- +void InitializeMerchants() + { + 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 ( pMerchantsTXT_Raw ) + pAllocator->FreeChunk(pMerchantsTXT_Raw); + pMerchantsTXT_Raw = NULL; + pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0); + strtok(pMerchantsTXT_Raw, "\r"); + + for (i=0; i<7; ++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: + pMerchantsBuyPhrases[i]=RemoveQuotes(test_string); + break; + case 2: + pMerchantsSellPhrases[i]=RemoveQuotes(test_string); + break; + case 3: + pMerchantsRepairPhrases[i]=RemoveQuotes(test_string); + break; + case 4: + pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string); + break; + } + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<5)&&!break_loop); + } + + } + +//----- (00476682) -------------------------------------------------------- +void InitializeTransitions() + { + 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 ( pTransitionsTXT_Raw ) + pAllocator->FreeChunk(pTransitionsTXT_Raw); + pTransitionsTXT_Raw = NULL; + pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0); + strtok(pTransitionsTXT_Raw, "\r"); + + for (i=0; i<464; ++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 ( decode_step == 1) + pTransitionStrings[i]=RemoveQuotes(test_string); + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<2)&&!break_loop); + } + } + +//----- (00476750) -------------------------------------------------------- +void __cdecl InitializeAutonotes() + { + 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 ( pAutonoteTXT_Raw ) + pAllocator->FreeChunk(pAutonoteTXT_Raw); + pAutonoteTXT_Raw = 0; + pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0); + strtok(pAutonoteTXT_Raw, "\r"); + + for (i=0; i<195; ++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: + pAutonoteTxt[i].pText=RemoveQuotes(test_string); + break; + case 2: + { + if ( !_strcmpi(test_string, "potion")) + { + pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE; + break; + } + if ( !_strcmpi(test_string, "stat") ) + { + pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT; + break; + } + if ( !_strcmpi(test_string, "seer") ) + { + pAutonoteTxt[i].eType = AUTONOTE_SEER; + break; + } + if ( !_strcmpi(test_string, "obelisk") ) + { + pAutonoteTxt[i].eType = AUTONOTE_OBELISK; + break; + } + if ( !_strcmpi(test_string, "teacher") ) + { + pAutonoteTxt[i].eType = AUTONOTE_TEACHER; + break; + } + pAutonoteTxt[i].eType =AUTONOTE_MISC; + break; + } + } + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<3)&&!break_loop); + } + } + + +//----- (004768A9) -------------------------------------------------------- +void __cdecl InitializeQuests() + { + 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 ( pQuestsTXT_Raw ) + pAllocator->FreeChunk(pQuestsTXT_Raw); + pQuestsTXT_Raw = NULL; + pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0); + strtok(pQuestsTXT_Raw, "\r"); + + for (i=0; i<512; ++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 ( decode_step == 1) + pQuestTable[i] =RemoveQuotes(test_string); + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<2)&&!break_loop); + } + } +
--- a/NPC.h Mon Feb 18 19:16:15 2013 +0600 +++ b/NPC.h Mon Feb 18 19:16:38 2013 +0600 @@ -17,9 +17,11 @@ #pragma pack(push, 1) struct NPCData { + inline bool Hired() {return uFlags & 0x80;} + char *pName; unsigned int uPortraitID; - unsigned int uFlags; // & 0x80 no greeting on dialogue start + unsigned int uFlags; // & 0x80 no greeting on dialogue start; looks like hired int fame; int rep; int house; @@ -57,8 +59,8 @@ #pragma pack(push, 1) struct NPCStats_stru0 { - int field_0; - char field_4[60]; + int field_0; //summ + char field_4[60]; //prof position }; #pragma pack(pop) @@ -90,7 +92,7 @@ bool InitializeAdditionalNPCs(NPCData *a2, int a3, int a4, int a5); void _476C60(); - + NPCData pNPCData[501]; NPCData pNewNPCData[501]; char *pNPCNames[540][2]; @@ -103,7 +105,7 @@ NPCData array_13EF4[100]; char *pCatchPhrases[52]; char *pNPCNames2[500]; - NPCStats_stru0 array_16544[77]; + NPCStats_stru0 array_16544[77]; //16544h proffesion position in area int field_17884; int field_17888; NPCGreeting pNPCGreetings[205]; @@ -126,3 +128,5 @@ }; #pragma pack(pop) +bool PartyHasDragon(); +bool CheckHiredNPCSpeciality(unsigned int uProfession);
--- a/Outdoor.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Outdoor.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -36,7 +36,7 @@ stru149 stru_8019C8; -stru148 array_77EC08[2000]; +stru148 array_77EC08[2000 + 18000]; Surf stru_80C980; Edge defaultEdge; // weak Edge stru_80C9A4;
--- a/Outdoor_stuff.h Mon Feb 18 19:16:15 2013 +0600 +++ b/Outdoor_stuff.h Mon Feb 18 19:16:38 2013 +0600 @@ -7,6 +7,11 @@ #pragma pack(push, 1) struct stru148 { + inline stru148() + { + uNumVertices = 0; + } + int _479295(); void _4811A3(); void _48276F_sr(); @@ -94,7 +99,7 @@ float field_14; }; #pragma pack(pop) -extern stru148 array_77EC08[2000]; +extern stru148 array_77EC08[];
--- a/Party.h Mon Feb 18 19:16:15 2013 +0600 +++ b/Party.h Mon Feb 18 19:16:38 2013 +0600 @@ -37,7 +37,7 @@ PARTY_BUFF_HASTE = 0x8, PARTY_BUFF_HEROISM = 0x9, PARTY_BUFF_IMMOLATION = 0xA, - PARTY_BUFF_INVISIBILITY = 0xB, + PARTY_BUFF_INVISIBILITY = 11, PARTY_BUFF_RESIST_MIND = 0xC, PARTY_BUFF_PROTECTION_FROM_MAGIC = 0xD, PARTY_BUFF_SHIELD = 0xE,
--- a/Player.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Player.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -586,7 +586,7 @@ signed int v13; // esi@12 int v14; // eax@12 //int v15; // eax@17 - int pExpression; // ebx@17 + CHARACTER_EXPRESSION_ID expression; // ebx@17 signed int v17; // ecx@19 char *pSoundID; // edi@20 int v20[5]; // [sp+Ch] [bp-1Ch]@7 @@ -647,8 +647,8 @@ if ( v13 ) { pPlayerNum = 0; - pExpression = v20[rand() % v13]; - if ( pExpression == 21 && pSoundId ) + expression = (CHARACTER_EXPRESSION_ID)v20[rand() % v13]; + if (expression == CHARACTER_EXPRESSION_21 && pSoundId ) { v17 = 0; if ( (signed int)pSoundList->uNumSounds <= 0 ) @@ -670,7 +670,7 @@ if ( pSoundList->pSounds[v17].pSoundData[0] ) pPlayerNum = (sLastTrackLengthMS << 7) / 1000; } - /*LOWORD(v14) = */PlayEmotion((CHARACTER_EXPRESSION_ID)pExpression, pPlayerNum); + /*LOWORD(v14) = */PlayEmotion(expression, pPlayerNum); } //return v14; } @@ -5753,7 +5753,7 @@ } if ( CheckHiredNPCSpeciality(v5) ) v2 += 4; - if ( v9->classType == PLAYER_CLASS_31 && sub_476387() ) + if ( v9->classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) v2 += 3; LABEL_86: if ( uSkillType <= PLAYER_SKILL_DARK ) @@ -6972,7 +6972,7 @@ unsigned int thisa; // [sp+28h] [bp-4h]@22 thisb = this; - v3 = &pParty->pPlayers[a2-1];//(Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552]; + v3 = &pParty->pPlayers[a2-1]; v73 = 1; if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3) ) return; @@ -7000,7 +7000,7 @@ } v69 = 2; LABEL_111: - pParty->pPlayers[a2-1].Heal(v69);//((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->Heal(v69); + pParty->pPlayers[a2-1].Heal(v69); } LABEL_112: v3->PlaySound(SPEECH_36, 0); @@ -7173,7 +7173,7 @@ v33 = HIDWORD(v3->pConditions[15]); v34 = LODWORD(v3->pConditions[16]); v35 = HIDWORD(v3->pConditions[16]); - memset(&pParty->pPlayers[a2-1],0,0xA0u);//memset(&stru_AA1058[3].pSounds[6972 * a2 + 40552], 0, 0xA0u); + memset(&pParty->pPlayers[a2-1],0,0xA0u); HIDWORD(v3->pConditions[14]) = v31; LODWORD(v3->pConditions[15]) = v32; HIDWORD(v3->pConditions[15]) = v33; @@ -7544,7 +7544,7 @@ pMouse->RemoveHoldingItem(); return; } - if ( pParty->pPlayers[a2-1].CanAct() )//if ( ((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->CanAct() ) + if ( pParty->pPlayers[a2-1].CanAct() ) { sub_467F48(pParty->pPickedItem.uItemID); v65 = 0; @@ -7588,7 +7588,7 @@ pAudioPlayer->PlaySound(v37, v39, v41, v43, v45, v48, v52, v61); return; } - if ( !pParty->pPlayers[a2-1].CanAct() )//if ( !((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->CanAct() ) + if ( !pParty->pPlayers[a2-1].CanAct() ) { v66 = aCharacterConditionNames[v3->GetMajorConditionIdx()]; v57 = pGlobalTXT_LocalizationStrings[382]; @@ -7700,7 +7700,7 @@ } if ( pCurrentScreen == SCREEN_CASTING ) return; - if ( !pParty->pPlayers[a2-1].CanAct() )//if ( !((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->CanAct() ) + if ( !pParty->pPlayers[a2-1].CanAct() ) goto LABEL_89; if ( bUnderwater == 1 ) { @@ -7887,7 +7887,7 @@ LOBYTE(v6) = CheckHiredNPCSpeciality(a1); return v6; case VAR_NPCs2: - return pNPCStats->pNewNPCData[a1].uFlags & 0x80; + return pNPCStats->pNewNPCData[a1].Hired(); case VAR_MonthEquals|VAR_CurrentSP: v13 = 0x80u >> ((signed __int16)a1 - 1) % 8; v14 = this->field_1A50[((signed __int16)a1 - 1) >> 3];
--- a/Player.h Mon Feb 18 19:16:15 2013 +0600 +++ b/Player.h Mon Feb 18 19:16:38 2013 +0600 @@ -47,7 +47,7 @@ SPEECH_35 = 35, SPEECH_36 = 36, SPEECH_37 = 37, - SPEECH_38 = 38, + SPEECH_NotEnoughGold = 38, SPEECH_39 = 39, SPEECH_40 = 40, SPEECH_41 = 41, @@ -223,18 +223,41 @@ enum PLAYER_CLASS_TYPE: unsigned __int8 { PLAYER_CLASS_KNIGHT = 0, + PLAYER_CLASS_CHEVALIER = 1, + PLAYER_CLASS_CHAMPION = 2, + PLAYER_CLASS_BLACK_KNIGHT = 3, PLAYER_CLASS_THEIF = 4, - PLAYER_CLASS_BOUNTY_HUNTER = 0x7, - PLAYER_CLASS_MONK = 0x8, - PLAYER_CLASS_PALADIN = 0xC, - PLAYER_CLASS_SHOOTER = 0x10, - PLAYER_CLASS_RANGER = 0x14, + PLAYER_CLASS_ROGUE = 5, + PLAYER_CLASS_SPY = 6, + PLAYER_CLASS_ASSASSIN = 7, + PLAYER_CLASS_MONK = 8, + PLAYER_CLASS_INITIATE = 9, + PLAYER_CLASS_MASTER = 10, + PLAYER_CLASS_NINJA = 11, + PLAYER_CLASS_PALADIN = 12, + PLAYER_CLASS_CRUSADER = 13, + PLAYER_CLASS_HERO = 14, + PLAYER_CLASS_VILLIAN = 15, + PLAYER_CLASS_ARCHER = 16, + PLAYER_CLASS_WARRIOR_MAGE = 17, + PLAYER_CLASS_MASTER_ARCHER = 18, + PLAYER_CLASS_SNIPER = 19, + PLAYER_CLASS_RANGER = 20, + PLAYER_CLASS_HUNTER = 21, + PLAYER_CLASS_RANGER_LORD = 22, + PLAYER_CLASS_BOUNTY_HUNTER = 23, PLAYER_CLASS_CLERIC = 24, - PLAYER_CLASS_PRIEST_OF_MOON = 0x1B, + PLAYER_CLASS_PRIEST = 25, + PLAYER_CLASS_PRIEST_OF_SUN = 26, + PLAYER_CLASS_PRIEST_OF_MOON = 27, PLAYER_CLASS_DRUID = 28, - PLAYER_CLASS_31 = 31, + PLAYER_CLASS_GREAT_DRUID = 29, + PLAYER_CLASS_ARCH_DRUID = 30, + PLAYER_CLASS_WARLOCK = 31, PLAYER_CLASS_SORCERER = 32, - PLAYER_CLASS_LICH = 35, + PLAYER_CLASS_WIZARD = 33, + PLAYER_CLASS_ARCHMAGE = 34, + PLAYER_CLASS_LICH = 35 };
--- a/Render.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Render.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -1834,21 +1834,23 @@ v8->field_58 = 0; ++pOutdoorCamera->numStru148s; ++pOutdoorCamera->field_44; + assert(pOutdoorCamera->numStru148s < 20000); + v8->uBModelID = 0; v8->uBModelFaceID = 0; v31 = (8 * (0 | (0 << 6))); v8->field_50 = v31 | 6; - for (unsigned int k = 0; k < 4; ++k) + for (unsigned int k = 0; k < v8->uNumVertices; ++k) { memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); } bool transparent = false; - if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) + if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->hd_water_tile_id) { //v80 = false; - v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; } else { @@ -1862,7 +1864,7 @@ if (!strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX { pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE); // no Z writing: the shore tile will be draw in the same place, so taking care about z-fighting - pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]], false, true); + pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE); } @@ -2174,10 +2176,10 @@ //v37 = *(int *)&v16->flags; if ( ~v16->flags & 1 ) { - if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) + if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->hd_water_tile_id ) { v80 = false; - v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; } else { @@ -2324,10 +2326,10 @@ } else { - if ( v57 & 2 && v40->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) + if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) { v81 = 0; - v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; } else { @@ -2439,10 +2441,10 @@ v74 = v71->flags; if ( !(BYTE1(v74) & 1) ) { - if ( v74 & 2 && v71->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) + if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) { v80 = false; - v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; } else { @@ -4694,6 +4696,9 @@ v1->_gpu_memory_used = 0; uNumBillboardsToDraw = 0; bFogEnabled = false; + + hd_water_tile_id = -1; + hd_water_current_frame = 0; } bool Render::Initialize(bool bWindowed, uint uDefaultDevice,
--- a/Render.h Mon Feb 18 19:16:15 2013 +0600 +++ b/Render.h Mon Feb 18 19:16:38 2013 +0600 @@ -441,8 +441,8 @@ int field_103668; unsigned int pHDWaterBitmapIDs[7]; char field_103688[32]; - int field_1036A8_bitmapid; - int field_1036AC_bitmapid; + int hd_water_current_frame; + int hd_water_tile_id; IDirectDrawSurface4 *pSurface; IDirect3DTexture2 *pTexture; int field_1036B8;
--- a/Sprites.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Sprites.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -11,8 +11,6 @@ -//extern int (__cdecl *sprintfex)(char *a1, const char *a2, ...); - struct SpriteFrameTable *pSpriteFrameTable;
--- a/StorylineTextTable.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/StorylineTextTable.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -11,33 +11,23 @@ //----- (00453E6D) -------------------------------------------------------- void StorylineText::Initialize() -{ - char *v1; // ebx@1 - StorylineText *v2; // esi@1 - char *v3; // ecx@4 - char v4; // dl@5 - char *v5; // eax@5 - int v6; // esi@9 - int v7; // [sp+Ch] [bp-10h]@3 - int v8; // [sp+10h] [bp-Ch]@4 - char *v9; // [sp+14h] [bp-8h]@4 - int Str; // [sp+18h] [bp-4h]@3 - int i,j; + { + + int i; char* test_string; unsigned char c; bool break_loop; unsigned int temp_str_len; char* tmp_pos; int decode_step; - v1 = 0; - v2 = this; - if ( pHistoryTXT_Raw ) - pAllocator->FreeChunk(pHistoryTXT_Raw); - pHistoryTXT_Raw = NULL; - pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0); - strtok(pHistoryTXT_Raw, "\r"); - for (i=0;i<29;++i) + if ( pHistoryTXT_Raw ) + pAllocator->FreeChunk(pHistoryTXT_Raw); + pHistoryTXT_Raw = NULL; + pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0); + strtok(pHistoryTXT_Raw, "\r"); + + for (i=0;i<29;++i) { test_string = strtok(NULL, "\r") + 1; break_loop = false; @@ -72,10 +62,10 @@ } else { - break_loop = true; + break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<4)&&!break_loop); } -} \ No newline at end of file + } \ No newline at end of file
--- a/VideoPlayer.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/VideoPlayer.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -295,9 +295,8 @@ pVideoPlayer->bStopBeforeSchedule = false; pVideoPlayer->pResetflag = 0; bGameoverLoop = 1; - if ( !bNoVideo ) + if (!bNoVideo) { - bNoVideo = 0; pRenderer->PresentBlackScreen(); pGame->pCShow->PlayMovie(MOVIE_3DOLogo, 1); if ( !pVideoPlayer->bStopBeforeSchedule )
--- a/Weather.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/Weather.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -197,7 +197,7 @@ } //----- (004C2F0B) -------------------------------------------------------- -bool Weather::_4C2F0B(__int16 a2) +bool Weather::OnPlayerTurn(__int16 a2) { int v3; // edx@3 signed int v4; // ebx@3
--- a/Weather.h Mon Feb 18 19:16:15 2013 +0600 +++ b/Weather.h Mon Feb 18 19:16:38 2013 +0600 @@ -12,7 +12,7 @@ int DrawSnow(); int Initialize(); int Draw(); - bool _4C2F0B(__int16 a2); + bool OnPlayerTurn(__int16 dangle);
--- a/mm7_1.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/mm7_1.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -207,7 +207,7 @@ v85 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; v86 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0); v79 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0); - pPlayer = &pParty->pPlayers[v1-1];//(Player *)&stru_AA1058[3].pSounds[6972 * v1 + 40552]; + pPlayer = &pParty->pPlayers[v1-1]; v3 = pIcons_LOD->LoadTexture("fr_skill", TEXTURE_16BIT_PALETTE); pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0)); v4 = v79; @@ -611,7 +611,7 @@ //----- (0041A000) -------------------------------------------------------- unsigned int __fastcall CharacterUI_AwardsTab_Draw(unsigned int uPlayerID) { - unsigned int v1; // esi@1 + //unsigned int v1; // esi@1 unsigned int v2; // ebx@1 unsigned int v3; // eax@1 unsigned int result; // eax@1 @@ -634,15 +634,13 @@ int v21; // [sp+C8h] [bp-8h]@14 int v22; // [sp+CCh] [bp-4h]@40 - v1 = uPlayerID; + auto player = pParty->pPlayers + uPlayerID - 1; + //v1 = uPlayerID; v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); v3 = pIcons_LOD->LoadTexture("fr_award", TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0)); - sprintf(pTmpBuf, "%s \f%05d", pGlobalTXT_LocalizationStrings[23], v2);// TODO check args - sprintf(Source, - pGlobalTXT_LocalizationStrings[429], - &pParty->pPlayers[v1-1].pName,//&stru_AA1058[3].pSounds[6972 * v1 + 40720], - pClassNames[pParty->pPlayers[v1-1].classType]);//&pClassNames[stru_AA1058[3].pSounds[6972 * v1 + 40737]]); + pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0)); + sprintfex(pTmpBuf, "%s\xC" "%05d", pGlobalTXT_LocalizationStrings[23], v2); + sprintfex(Source, pGlobalTXT_LocalizationStrings[429], player->pName, pClassNames[player->classType]); strcat(pTmpBuf, Source); strcat(pTmpBuf, "\xC" "00000"); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0); @@ -1057,7 +1055,7 @@ v49 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0); v46 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0); v1 = pIcons_LOD->LoadTexture("quikref", TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); + pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v1 != -1 ? &pIcons_LOD->pTextures[v1] : 0)); v43 = 0; v45 = LOBYTE(pFontArrus->uFontHeight) + 1; do @@ -2803,7 +2801,7 @@ int v8; // eax@4 unsigned __int16 v9; // dx@4 SpriteFrame *v10; // edi@17 - int v11; // esi@17 + LODSprite *v11; // esi@17 unsigned int v12; // ecx@17 Sprite *v13; // edi@18 int v14; // ecx@18 @@ -2853,7 +2851,6 @@ int v58; // eax@132 Actor *v59; // ecx@133 unsigned __int8 v60; // dl@138 - char *v61; // eax@145 char *v62; // eax@147 int v63; // eax@152 char *result; // eax@152 @@ -2877,27 +2874,8 @@ DDBLTFX Dst; // [sp+Ch] [bp-1E0h]@18 DDSURFACEDESC2 pDesc; // [sp+70h] [bp-17Ch]@18 RECT v84; // [sp+ECh] [bp-100h]@26 - char *v85; // [sp+FCh] [bp-F0h]@145 - char *v86; // [sp+100h] [bp-ECh]@145 - char *v87; // [sp+104h] [bp-E8h]@145 - char *v88; // [sp+108h] [bp-E4h]@145 - char *v89; // [sp+10Ch] [bp-E0h]@145 - char *v90; // [sp+110h] [bp-DCh]@145 - char *v91; // [sp+114h] [bp-D8h]@145 - char *v92; // [sp+118h] [bp-D4h]@145 - char *v93; // [sp+11Ch] [bp-D0h]@145 - char *v94; // [sp+120h] [bp-CCh]@145 - char *v95; // [sp+124h] [bp-C8h]@127 - char *v96; // [sp+128h] [bp-C4h]@127 - char *v97; // [sp+12Ch] [bp-C0h]@127 - char *v98; // [sp+130h] [bp-BCh]@127 - char *v99; // [sp+134h] [bp-B8h]@127 - char *v100; // [sp+138h] [bp-B4h]@127 - char *v101; // [sp+13Ch] [bp-B0h]@127 - char *v102; // [sp+140h] [bp-ACh]@127 - char *v103; // [sp+144h] [bp-A8h]@127 - char *v104; // [sp+148h] [bp-A4h]@127 - char *v105; // [sp+14Ch] [bp-A0h]@127 + char *v85[10]; // [sp+FCh] [bp-F0h]@145 + char *v95[11]; // [sp+124h] [bp-C8h]@127 RenderBillboardTransform_local0 v106; // [sp+150h] [bp-9Ch]@3 unsigned int v107; // [sp+1A0h] [bp-4Ch]@18 unsigned __int16 *v108; // [sp+1A4h] [bp-48h]@34 @@ -2976,7 +2954,7 @@ v10 = pSpriteFrameTable->GetFrame( v3->pSpriteIDs[(signed __int16)pMonsterInfoUI_Doll.uCurrentActionAnimation], pMonsterInfoUI_Doll.uCurrentActionTime); - v11 = 40 * v10->pHwSpriteIDs[0] + 7218180; + v11 = pSprites_LOD[v10->pHwSpriteIDs[0]].pSpriteHeaders;//40 * v10->pHwSpriteIDs[0] + 7218180; v106.pTarget = pRenderer->pTargetSurface; v106.pTargetZ = pRenderer->pActiveZBuffer; v106.uTargetPitch = pRenderer->uTargetSurfacePitch; @@ -2988,7 +2966,7 @@ v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2; v106._screenspace_x_scaler_packedfloat = 65536; v106._screenspace_y_scaler_packedfloat = 65536; - v106.uScreenSpaceY = v115 + v12 + *(short *)(v11 + 18); + v106.uScreenSpaceY = v115 + v12 + v11->uHeight; v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1); v106.sZValue = 0; v106.uFlags = 0; @@ -3063,99 +3041,101 @@ { memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - if ( !pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT)) - goto LABEL_51; - v20 = (char *)v124; - v110 = pDesc.lpSurface; - a2 = (Player *)v124; - if ( v124 < v119 ) - { - v111 = 2 * pRenderer->uTargetSurfacePitch; - v21 = (int)a4; - v22 = &pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; - v23 = i - v124; - v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; - v115 = i - v124; - while ( 1 ) - { - v124 = v21; - if ( v21 < (signed int)v116 ) - { - v24 = (int)&v20[v23]; - v25 = v107 - v21; - v109 = v24; - for ( i = v107 - v21; ; v25 = i ) - { - v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / v13->uAreaHeight); - v26 = (char *)v108 + pDesc.dwWidth * (v25 + v124++) / v13->uAreaWidth; - *v22 = *((short *)v110 + (int)v26); - ++v22; - if ( v124 >= (signed int)v116 ) - break; - } - v23 = v115; - } - v22 = (unsigned __int16 *)((char *)v120 + v111); - v20 = (char *)&a2->pConditions[0] + 1; - v28 = __OFSUB__((int)&a2->pConditions[0] + 1, v119); - v27 = (signed int)((char *)&a2->pConditions[0] + -v119 + 1) < 0; - a2 = (Player *)((char *)a2 + 1); - v120 = (SpellBuff *)((char *)v120 + v111); - if ( !(v27 ^ v28) ) - break; - v21 = (int)a4; - } - } - goto LABEL_37; - } - memset(&pDesc, 0, 0x7Cu); - pDesc.dwSize = 124; - if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT) ) - { - v108 = (unsigned __int16 *)pDesc.lpSurface; - a2 = (Player *)v124; - if ( v124 < v119 ) - { - v109 = 2 * pRenderer->uTargetSurfacePitch; - v29 = (int)a4; - v30 = (char *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; - v31 = i - v124; - v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; - v115 = i - v124; - while ( 1 ) - { - v124 = v29; - if ( v29 < (signed int)v116 ) - { - v32 = v107 - (int)a4; - v111 = (unsigned int)((char *)a2 + v31); - for ( i = v107 - (int)a4; ; v32 = i ) - { - v110 = (LPVOID)((pDesc.lPitch >> 1) * pDesc.dwHeight * v111 / v13->uAreaHeight); - v33 = v108[(int)((char *)v110 + pDesc.dwWidth * (v32 + v124) / v13->uAreaWidth)]; - v34 = v33 & 0x1F | 2 - * (unsigned __int16)(v108[(int)((char *)v110 - + pDesc.dwWidth * (v32 + v124++) / v13->uAreaWidth)] & 0xFFE0); - v35 = v124; - *(short *)v30 = v34; - v30 += 2; - if ( v35 >= (signed int)v116 ) - break; - } - v31 = v115; - } - a2 = (Player *)((char *)a2 + 1); - v30 = (char *)v120 + v109; - v120 = (SpellBuff *)((char *)v120 + v109); - if ( (signed int)a2 >= v119 ) - break; - v29 = (int)a4; - } - } -LABEL_37: - v222->Unlock(0); - goto LABEL_51; - } + if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT)) + { + v20 = (char *)v124; + v110 = pDesc.lpSurface; + a2 = (Player *)v124; + if ( v124 < v119 ) + { + v111 = 2 * pRenderer->uTargetSurfacePitch; + v21 = (int)a4; + v22 = &pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; + v23 = i - v124; + v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; + v115 = i - v124; + while ( 1 ) + { + v124 = v21; + if ( v21 < (signed int)v116 ) + { + v24 = (int)&v20[v23]; + v25 = v107 - v21; + v109 = v24; + for ( i = v107 - v21; ; v25 = i ) + { + v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / v13->uAreaHeight); + v26 = (char *)v108 + pDesc.dwWidth * (v25 + v124++) / v13->uAreaWidth; + *v22 = *((short *)v110 + (int)v26); + ++v22; + if ( v124 >= (signed int)v116 ) + break; + } + v23 = v115; + } + v22 = (unsigned __int16 *)((char *)v120 + v111); + v20 = (char *)&a2->pConditions[0] + 1; + v28 = __OFSUB__((int)&a2->pConditions[0] + 1, v119); + v27 = (signed int)((char *)&a2->pConditions[0] + -v119 + 1) < 0; + a2 = (Player *)((char *)a2 + 1); + v120 = (SpellBuff *)((char *)v120 + v111); + if ( !(v27 ^ v28) ) + break; + v21 = (int)a4; + } + } + v222->Unlock(0); + } + } + else + { + memset(&pDesc, 0, 0x7Cu); + pDesc.dwSize = 124; + if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT) ) + { + v108 = (unsigned __int16 *)pDesc.lpSurface; + a2 = (Player *)v124; + if ( v124 < v119 ) + { + v109 = 2 * pRenderer->uTargetSurfacePitch; + v29 = (int)a4; + v30 = (char *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; + v31 = i - v124; + v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; + v115 = i - v124; + while ( 1 ) + { + v124 = v29; + if ( v29 < (signed int)v116 ) + { + v32 = v107 - (int)a4; + v111 = (unsigned int)((char *)a2 + v31); + for ( i = v107 - (int)a4; ; v32 = i ) + { + v110 = (LPVOID)((pDesc.lPitch >> 1) * pDesc.dwHeight * v111 / v13->uAreaHeight); + v33 = v108[(int)((char *)v110 + pDesc.dwWidth * (v32 + v124) / v13->uAreaWidth)]; + v34 = v33 & 0x1F | 2 + * (unsigned __int16)(v108[(int)((char *)v110 + + pDesc.dwWidth * (v32 + v124++) / v13->uAreaWidth)] & 0xFFE0); + v35 = v124; + *(short *)v30 = v34; + v30 += 2; + if ( v35 >= (signed int)v116 ) + break; + } + v31 = v115; + } + a2 = (Player *)((char *)a2 + 1); + v30 = (char *)v120 + v109; + v120 = (SpellBuff *)((char *)v120 + v109); + if ( (signed int)a2 >= v119 ) + break; + v29 = (int)a4; + } + } + v222->Unlock(0); + } + } } else { @@ -3169,29 +3149,30 @@ if ( v36 >= 0 ) pSprites_LOD->pSpriteHeaders[v36]._4ACC38(&v106, 0); } -LABEL_51: if ( v121->uNPC_ID ) { v37 = v112[6]; if ( v37 ) { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], *v112, aNPCProfessionNames[(signed int)v37]); - goto LABEL_59; - } - v77 = 2000; - v72 = *v112; + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], *v112, aNPCProfessionNames[(signed int)v37]); + } + else + { + v77 = 2000; + v72 = *v112; + } } else { v38 = v121->dword_000334_unique_name; v77 = 2000; if ( v38 ) - v72 = (char *)*(&pMonsterStats->pPlacement.uNumStrings + v38); + v72 = pMonsterStats->pPlaceStrings[v38]; else v72 = pMonsterStats->pInfos[v121->pMonsterInfo.uID].pName; } - strncpy(pTmpBuf, v72, v77); -LABEL_59: + if(!v121->uNPC_ID || (v121->uNPC_ID && !v37)) + strncpy(pTmpBuf, v72, v77); v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf, 3u); Actor::DrawHealthBar(v121, a1); @@ -3204,77 +3185,93 @@ if ( !uActiveCharacter ) { v45 = 1; - goto LABEL_84; - } - LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID); - v120 = v40; - if ( !v40 ) - goto LABEL_72; - v41 = (unsigned __int8)v40 & 0x3F; - v42 = SkillToMastery((unsigned __int16)v40) - 1; - if ( !v42 ) - { - if ( v41 + 10 >= v121->pMonsterInfo.uLevel ) - { - v45 = 1; - v119 = 1; - goto LABEL_73; - } - goto LABEL_72; - } - v43 = v42 - 1; - if ( !v43 ) - { - if ( 2 * v41 + 10 >= v121->pMonsterInfo.uLevel ) - { - v45 = 1; - v119 = 1; - v116 = 1; - goto LABEL_73; - } - goto LABEL_72; - } - v44 = v43 - 1; - if ( !v44 ) - { - if ( 3 * v41 + 10 >= v121->pMonsterInfo.uLevel ) - { - v45 = 1; - v119 = 1; - v116 = 1; - i = 1; - goto LABEL_73; - } -LABEL_72: - v45 = 1; - goto LABEL_73; - } - if ( v44 != 1 ) - goto LABEL_72; - v45 = 1; - v119 = 1; - v116 = 1; - i = 1; - v112 = (char **)1; -LABEL_73: - v46 = v121->uAIState; - if ( v46 != 5 && v46 != 4 && !dword_507BF0_is_there_popup_onscreen && v120 ) - { - v47 = pPlayers[uActiveCharacter]; - if ( v119 | v116 | i | (unsigned int)v112 ) - { - if ( v121->pMonsterInfo.uLevel >= v47->uLevel - 5 ) - v73 = SPEECH_105; - else - v73 = SPEECH_104; - } - else - { - v73 = SPEECH_106; - } - v47->PlaySound((PlayerSpeech)v73, 0); - } -LABEL_84: + } + else + { + LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID); + v120 = v40; + if ( !v40 ) + v45 = 1; + else + { + v41 = (unsigned __int8)v40 & 0x3F; + v42 = SkillToMastery((unsigned __int16)v40) - 1; + if ( !v42 ) + { + if ( v41 + 10 >= v121->pMonsterInfo.uLevel ) + { + v45 = 1; + v119 = 1; + } + else + v45 = 1; + } + else + { + v43 = v42 - 1; + if ( !v43 ) + { + if ( 2 * v41 + 10 >= v121->pMonsterInfo.uLevel ) + { + v45 = 1; + v119 = 1; + v116 = 1; + } + else + v45 = 1; + } + else + { + v44 = v43 - 1; + if ( !v44 ) + { + if ( 3 * v41 + 10 >= v121->pMonsterInfo.uLevel ) + { + v45 = 1; + v119 = 1; + v116 = 1; + i = 1; + } + else + { + v45 = 1; + } + } + else + { + if ( v44 != 1 ) + v45 = 1; + else + { + v45 = 1; + v119 = 1; + v116 = 1; + i = 1; + v112 = (char **)1; + } + } + } + } + } + // LABEL_73: + v46 = v121->uAIState; + if ( v46 != 5 && v46 != 4 && !dword_507BF0_is_there_popup_onscreen && v120 ) + { + v47 = pPlayers[uActiveCharacter]; + if ( v119 | v116 | i | (unsigned int)v112 ) + { + if ( v121->pMonsterInfo.uLevel >= v47->uLevel - 5 ) + v73 = SPEECH_105; + else + v73 = SPEECH_104; + } + else + { + v73 = SPEECH_106; + } + v47->PlaySound((PlayerSpeech)v73, 0); + } + } a2 = pParty->pPlayers; do { @@ -3432,51 +3429,48 @@ a4 = (char *)v106.uViewportY; if ( v119 ) { - __debugbreak(); // following format strings are decompiled incorrectly - sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP); + sprintf(pTmpBuf, "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; v79 = v121->pMonsterInfo.uAC; v75 = 0; v70 = pGlobalTXT_LocalizationStrings[12]; - v67 = "%s"; + v67 = "%s\f%05u\t100%d\n"; } else { - __debugbreak(); // following format strings are decompiled incorrectly - sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]); + sprintf(pTmpBuf, "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); v79 = (unsigned int)pGlobalTXT_LocalizationStrings[630]; v75 = 0; v70 = pGlobalTXT_LocalizationStrings[12]; a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; - v67 = "%s"; + v67 = "%s\f%05u\t100%s\n"; } sprintf(pTmpBuf, v67, v70, v75, v79); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 6] + LOBYTE(v56->uFontHeight); - v95 = pGlobalTXT_LocalizationStrings[87]; - v96 = pGlobalTXT_LocalizationStrings[6]; - v97 = pGlobalTXT_LocalizationStrings[240]; - v98 = pGlobalTXT_LocalizationStrings[70]; - v99 = pGlobalTXT_LocalizationStrings[624]; - v100 = pGlobalTXT_LocalizationStrings[138]; - v101 = pGlobalTXT_LocalizationStrings[214]; - v102 = pGlobalTXT_LocalizationStrings[142]; - v103 = pGlobalTXT_LocalizationStrings[29]; - v104 = pGlobalTXT_LocalizationStrings[133]; - v105 = pGlobalTXT_LocalizationStrings[54]; + v95[0] = pGlobalTXT_LocalizationStrings[87]; + v95[1] = pGlobalTXT_LocalizationStrings[6]; + v95[2] = pGlobalTXT_LocalizationStrings[240]; + v95[3] = pGlobalTXT_LocalizationStrings[70]; + v95[4] = pGlobalTXT_LocalizationStrings[624]; + v95[5] = pGlobalTXT_LocalizationStrings[138]; + v95[6] = pGlobalTXT_LocalizationStrings[214]; + v95[7] = pGlobalTXT_LocalizationStrings[142]; + v95[8] = pGlobalTXT_LocalizationStrings[29]; + v95[9] = pGlobalTXT_LocalizationStrings[133]; + v95[10] = pGlobalTXT_LocalizationStrings[54]; if ( v116 ) { - __debugbreak(); // following format strings are decompiled incorrectly - sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, (&v95)[4 * v121->pMonsterInfo.uAttack1Type]); + sprintf(pTmpBuf, "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, v95[v121->pMonsterInfo.uAttack1Type]); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; v57 = v121->pMonsterInfo.uAttack1DamageBonus; if ( v57 ) sprintf( pTmpBuf, - "%s", + "%s\f%05u\t080%dd%d+%d\n", pGlobalTXT_LocalizationStrings[53], 0, v121->pMonsterInfo.uAttack1DamageDiceRolls, @@ -3485,7 +3479,7 @@ else sprintf( pTmpBuf, - "%s", + "%s\f%05u\t080%dd%d\n", pGlobalTXT_LocalizationStrings[53], 0, v121->pMonsterInfo.uAttack1DamageDiceRolls, @@ -3493,11 +3487,10 @@ } else { - __debugbreak(); // following format strings are decompiled incorrectly - sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]); + sprintf(pTmpBuf, "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; - sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]); + sprintf(pTmpBuf, "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]); } a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); @@ -3507,7 +3500,7 @@ v80 = pGlobalTXT_LocalizationStrings[630]; v76 = 0; v71 = pGlobalTXT_LocalizationStrings[628]; - v68 = "%s"; + v68 = "%s\f%05u\t080%s\n"; goto LABEL_144; } v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628]; @@ -3517,7 +3510,7 @@ v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629]; if ( v114 ) { - sprintf(pTmpBuf, "%s", v120, 0, pSpellStats->pInfos[v114].pShortName); + sprintf(pTmpBuf, "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); a4 = &a4[v58 - 3]; @@ -3526,9 +3519,7 @@ v60 = v59->pMonsterInfo.uSpell2ID; if ( v60 ) { - __debugbreak(); - const char *fmt = "\xC\x25\x30\x35\x75\x9\x30\x36\x30\x25\x73\n"; - sprintf(pTmpBuf, fmt, 0, pSpellStats->pInfos[v60].pShortName); + sprintf(pTmpBuf, "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); a4 = &a4[v58 - 3]; @@ -3539,7 +3530,7 @@ v80 = pGlobalTXT_LocalizationStrings[153]; v76 = 0; v71 = pGlobalTXT_LocalizationStrings[628]; - v68 = "%s"; + v68 = "%s\f%05u\t060%s\n"; LABEL_144: sprintf(pTmpBuf, v68, v71, v76, v80); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); @@ -3549,33 +3540,32 @@ a4 = &a4[v58 - 3]; a1->DrawText(v56, 150, (int)a4, a5, pGlobalTXT_LocalizationStrings[626], 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; - v85 = pGlobalTXT_LocalizationStrings[87]; - v86 = pGlobalTXT_LocalizationStrings[6]; - v87 = pGlobalTXT_LocalizationStrings[240]; - v88 = pGlobalTXT_LocalizationStrings[70]; - v89 = pGlobalTXT_LocalizationStrings[142]; - v90 = pGlobalTXT_LocalizationStrings[214]; - v91 = pGlobalTXT_LocalizationStrings[29]; - v92 = pGlobalTXT_LocalizationStrings[133]; - v93 = pGlobalTXT_LocalizationStrings[54]; - v94 = pGlobalTXT_LocalizationStrings[624]; - v96 = (char *)v121->pMonsterInfo.uResFire; - v97 = (char *)v121->pMonsterInfo.uResAir; - v98 = (char *)v121->pMonsterInfo.uResWater; - v99 = (char *)v121->pMonsterInfo.uResEarth; - v100 = (char *)v121->pMonsterInfo.uResMind; - v101 = (char *)v121->pMonsterInfo.uResSpirit; - v102 = (char *)v121->pMonsterInfo.uResBody; - v103 = (char *)v121->pMonsterInfo.uResLight; - v61 = (char *)v121->pMonsterInfo.uResPhysical; - v104 = (char *)v121->pMonsterInfo.uResDark; - v105 = v61; + v85[0] = pGlobalTXT_LocalizationStrings[87]; + v85[1] = pGlobalTXT_LocalizationStrings[6]; + v85[2] = pGlobalTXT_LocalizationStrings[240]; + v85[3] = pGlobalTXT_LocalizationStrings[70]; + v85[4] = pGlobalTXT_LocalizationStrings[142]; + v85[5] = pGlobalTXT_LocalizationStrings[214]; + v85[6] = pGlobalTXT_LocalizationStrings[29]; + v85[7] = pGlobalTXT_LocalizationStrings[133]; + v85[8] = pGlobalTXT_LocalizationStrings[54]; + v85[9] = pGlobalTXT_LocalizationStrings[624]; + v95[1] = (char *)v121->pMonsterInfo.uResFire; + v95[2] = (char *)v121->pMonsterInfo.uResAir; + v95[3] = (char *)v121->pMonsterInfo.uResWater; + v95[4] = (char *)v121->pMonsterInfo.uResEarth; + v95[5] = (char *)v121->pMonsterInfo.uResMind; + v95[6] = (char *)v121->pMonsterInfo.uResSpirit; + v95[7] = (char *)v121->pMonsterInfo.uResBody; + v95[8] = (char *)v121->pMonsterInfo.uResLight; + v95[9] = (char *)v121->pMonsterInfo.uResPhysical; + v95[10] = (char *)v121->pMonsterInfo.uResDark; if ( v112 ) { v124 = 0; do { - v62 = (&v96)[v124]; + v62 = v95[v124+1]; if ( v62 == (char *)200 ) { v81 = pGlobalTXT_LocalizationStrings[625]; @@ -3587,7 +3577,7 @@ else v81 = pGlobalTXT_LocalizationStrings[153]; } - sprintf(pTmpBuf, "%s", (&v85)[v124], 0, v81); + sprintf(pTmpBuf, "%s\f%05u\t070%s\n", v85[v124], 0, v81); a1->DrawText(v56, 170, (int)a4, a5, pTmpBuf, 0, 0, 0); v63 = LOBYTE(v56->uFontHeight); v124 += 4; @@ -3601,8 +3591,7 @@ i = 0; do { - __debugbreak(); // string argument is decompiled incorrectry - sprintf(pTmpBuf, "%s", (&v85)[4 * i], 0, pGlobalTXT_LocalizationStrings[630]); // "?" + sprintf(pTmpBuf, "%s\f%05u\t070%s\n", v85[i], 0, pGlobalTXT_LocalizationStrings[630]); // "?" a1->DrawText(v56, 170, (int)a4, a5, pTmpBuf, 0, 0, 0); v65 = LOBYTE(v56->uFontHeight); ++i; @@ -3710,7 +3699,7 @@ pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - if ( sub_476387() ) + if ( PartyHasDragon() ) { v0 = pParty->pPlayers;//[0].uClass; while ( v0 <= &pParty->pPlayers[3] ) @@ -3719,7 +3708,7 @@ if ( v0 > &pParty->pPlayers[3] ) break; } - if(v0->classType == PLAYER_CLASS_31) + if(v0->classType == PLAYER_CLASS_WARLOCK) ++uRestUI_FoodRequiredToRest; } if ( CheckHiredNPCSpeciality(0x1Du) ) @@ -4392,7 +4381,7 @@ v2 = pMapStats->GetMapInfo(pCurrentMapName); if ( !(*v1 & 1) || !v2 ) goto LABEL_12; - if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].field_2D ) + if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) { v29 = 811; v30 = 812; @@ -5184,7 +5173,7 @@ v28 = pTmpBuf; v29 = pActor->dword_000334_unique_name; if ( v29 ) - v40 = (char *)*(&pMonsterStats->pPlacement.uNumStrings + v29); + v40 = pMonsterStats->pPlaceStrings[v29]; else v40 = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].pName; strncpy(pTmpBuf, v40, 0x7D0u); @@ -5664,64 +5653,66 @@ && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 ) { memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u); + pMouse->RemoveHoldingItem(); } else { v12 = 0; v3 = pParty->pPlayers; - while ( 1 ) + while ( v3 <= &pParty->pPlayers[3] ) { v4 = v3->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID); if ( v4 ) - break; - ++v12; + { + memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u); + pMouse->RemoveHoldingItem(); + break; + } + ++v12; ++v3; - if ( (signed int)v3 >= (signed int)pParty->pHirelings ) - goto LABEL_10; - } - memcpy(&pParty->pPlayers[v12].spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4 + 5], &pParty->pPickedItem, 0x24u); - pMouse->RemoveHoldingItem(); -LABEL_10: - if ( v12 != 4 ) - goto LABEL_18; - v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; - v6 = 0; - a1.uItemType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_15: - LOWORD(v6) = 0; - } - else - { - v7 = (char *)&pObjectList->pObjects->uObjectID; - while ( v5 != *(short *)v7 ) - { - ++v6; - v7 += 56; - if ( v6 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_15; - } - } - a1.field_58 = 4; - a1.uObjectDescID = v6; - a1.vPosition.y = pParty->vPosition.y; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; - a1.uSoundID = 0; - a1.uFacing = 0; - a1.uAttributes = 8; - v8 = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->sEyelevel + pParty->vPosition.z); - a1.uSpriteFrameID = 0; - a1.uSectorID = v8; - memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); - a1.Create(pParty->sRotationY, 184, 200, 0); - } - pMouse->RemoveHoldingItem(); -LABEL_18: + } + if ( v12 == 4 ) + { + v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + v6 = 0; + a1.uItemType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + { + LOWORD(v6) = 0; + } + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( v5 != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.field_58 = 4; + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + v8 = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + a1.uSectorID = v8; + memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); + a1.Create(pParty->sRotationY, 184, 200, 0); + pMouse->RemoveHoldingItem(); + } + } if ( !v11 ) { v1->Release(); @@ -6207,18 +6198,18 @@ } //----- (004226C2) -------------------------------------------------------- -bool __cdecl sub_4226C2() +bool PauseGameDrawing() { - if ( pCurrentScreen + if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_NPC_DIALOGUE && pCurrentScreen != SCREEN_CHANGE_LOCATION ) { if ( pCurrentScreen == SCREEN_INPUT_BLV ) return pVideoPlayer->pSmackerMovie != 0; if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) - return 1; - } - return 0; + return true; + } + return false; } // 4E28F8: using guessed type int pCurrentScreen;
--- a/mm7_2.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/mm7_2.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -415,7 +415,7 @@ // F8B19C: using guessed type int dword_F8B19C; //----- (004B8285) -------------------------------------------------------- -void __cdecl sub_4B8285_prolly_draw_arcomage_result() +void __cdecl sub_4B8285_prolly_draw_arcomage_result()//Maybe TavernDialogue { GUIWindow *v0; // ebx@1 Player *v1; // edi@1 @@ -1463,7 +1463,7 @@ LABEL_13: v6 = uActiveCharacter - 1; LABEL_14: - v7 = sub_495461(v5, v6, v79, (char *)v81, v83, v85); + v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85); v86 = 3; v84 = v7; v82 = v105; @@ -1862,7 +1862,7 @@ LABEL_44: v39 = uActiveCharacter - 1; LABEL_45: - v21 = sub_495461(v38, v39, v87, (char *)v89, v91, v93); + v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93); v92 = 3; v90 = v21; v88 = v108; @@ -2429,7 +2429,7 @@ 2, (int)ptr_507BC0->ptr_1C, 2); - v100 = sub_495461((char *)pMerchantsBuyPhrases[v99], v97, v98, (char *)v96, 2, 0); + v100 = BuilDialogueString((char *)pMerchantsBuyPhrases[v99], v97, v98, (char *)v96, 2, 0); v101 = v100; v102 = v148; v103 = pFontArrus->CalcTextHeight(v100, &v144, 0, 0); @@ -2759,7 +2759,7 @@ v14 = uActiveCharacter - 1; } LABEL_36: - v36 = sub_495461(v15, v14, v116, (char *)v120, v122, v124); + v36 = BuilDialogueString(v15, v14, v116, (char *)v120, v122, v124); v123 = 3; v121 = v36; v119 = v148; @@ -2911,7 +2911,7 @@ v4 = uPlayerID; v5 = (char *)pMerchantsIdentifyPhrases[v8]; } - v6 = sub_495461(v5, v4, v114, (char *)v118, 4, 0); + v6 = BuilDialogueString(v5, v4, v114, (char *)v118, 4, 0); v123 = 3; v121 = v6; v119 = v148; @@ -3267,7 +3267,7 @@ ++v4; } while ( (signed int)v4 < (signed int)pParty->pHirelings ); - party_finds_gold(dword_F8B1B4, 0); + party_finds_gold(gold_transaction_amount, 0); pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0); pParty->field_7B5_in_arena_quest = -1; } @@ -3592,12 +3592,12 @@ else { v14 = v27; - v13 = dword_F8B1B4; + v13 = gold_transaction_amount; } } LABEL_55: i = 0; - for ( dword_F8B1B4 = v26 * v13; i < v14; ++i ) + for ( gold_transaction_amount = v26 * v13; i < v14; ++i ) { monster_y = pMonsterArenaPlacements[i].y; v21 = rand(); @@ -7565,7 +7565,7 @@ v11 = pMapInfo->uEncounterMonster1AtMost; pTexture = pMapInfo->pEncounterMonster1Texture; v12 = v10 % (v11 - v9 + 1); - v13 = pMapInfo->field_34; + v13 = pMapInfo->Dif_M1; goto LABEL_20; case 3u: pTexture = pMapInfo->pEncounterMonster1Texture; @@ -7585,7 +7585,7 @@ v15 = pMapInfo->uEncounterMonster2AtMost; pTexture = pMapInfo->pEncounterMonster2Texture; v12 = v14 % (v15 - v9 + 1); - v13 = pMapInfo->field_37; + v13 = pMapInfo->Dif_M2; goto LABEL_20; case 6u: pTexture = pMapInfo->pEncounterMonster1Texture; @@ -7605,7 +7605,7 @@ v17 = pMapInfo->uEncounterMonster3AtMost; pTexture = pMapInfo->pEncounterMonster3Texture; v12 = v16 % (v17 - v9 + 1); - v13 = pMapInfo->field_3A; + v13 = pMapInfo->Dif_M3; LABEL_20: v57 = v13; v56 = v9 + v12; @@ -7936,7 +7936,7 @@ v4 = rand(); v34 = 0; v5 = v4 % 100; - v6 = 2 * (v2->field_2F + 7 * v3->uIndex) - 14; + v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14; v7 = (unsigned __int8)byte_4E8168[v6 + 16]; v8 = (unsigned __int8)byte_4E8168[v6 + 17]; v32 = v5; @@ -8114,8 +8114,8 @@ if ( (v3->uItemID & 0x80000000u) == 0 ) goto LABEL_56; v4 = rand() % 5 + 1; - v5 = (unsigned __int8)byte_4E8168[2 * (v2->field_2F + 7 * abs((int)v3->uItemID)) + 2]; - v6 = (unsigned __int8)byte_4E8168[2 * (v2->field_2F + 7 * abs((int)v3->uItemID)) + 3]; + v5 = (unsigned __int8)byte_4E8168[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; + v6 = (unsigned __int8)byte_4E8168[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3]; v7 = rand(); v8 = v6 - v5 + 1; v9 = v5 + v7 % v8; @@ -9124,24 +9124,26 @@ } //----- (00452A9E) -------------------------------------------------------- -signed int __fastcall sub_452A9E(signed int a1) +int sub_452A9E(int square_distance) { signed int result; // eax@2 int v2; // edx@3 - signed int v3; // edi@3 - signed int v4; // ebx@3 + unsigned int v3; // edi@3 + //signed int v4; // ebx@3 int v5; // esi@4 - if ( a1 > 1 ) - { + if (square_distance < 1) + return square_distance; + + v2 = 0; - v3 = a1; + v3 = square_distance; result = 0; - v4 = 16; - do - { + //v4 = 16; + for (uint i = 0; i < 16; ++i) + { result *= 2; - v2 = ((unsigned int)v3 >> 30) | 4 * v2; + v2 = (v3 >> 30) | 4 * v2; v5 = 2 * result + 1; v3 *= 4; if ( v2 >= (unsigned int)v5 ) @@ -9149,17 +9151,11 @@ ++result; v2 -= v5; } - --v4; - } - while ( v4 ); - if ( a1 - result * result >= (unsigned int)(result - 1) ) + //--v4; + } + //while ( v4 ); + if ( square_distance - result * result >= (unsigned int)(result - 1) ) ++result; - } - else - { - result = a1; - } - return result; } //----- (00452AE2) -------------------------------------------------------- @@ -9245,393 +9241,328 @@ //----- (00453F62) -------------------------------------------------------- void MapStats::Initialize() { - MapStats *v1; // esi@1 - unsigned int v2; // ebx@3 - char *v3; // eax@4 - char *v4; // edi@4 - char v5; // cl@5 - int v6; // eax@5 - size_t v7; // eax@32 - size_t v8; // eax@35 - size_t v9; // eax@42 - size_t v10; // eax@45 - size_t v11; // eax@52 - size_t v12; // eax@55 - char Str[32]; // [sp+Ch] [bp-34h]@30 - char *v14; // [sp+2Ch] [bp-14h]@9 - int v15; // [sp+30h] [bp-10h]@4 - int v16; // [sp+34h] [bp-Ch]@4 - unsigned int v17; // [sp+38h] [bp-8h]@30 - MapStats *v18; // [sp+3Ch] [bp-4h]@30 - - v1 = this; + 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 ) pAllocator->FreeChunk(pMapStatsTXT_Raw); - pMapStatsTXT_Raw = 0; + pMapStatsTXT_Raw = NULL; pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); strtok(pMapStatsTXT_Raw, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - v2 = 1; - v1->uNumMaps = 77; - do - { - v3 = strtok(0, "\r"); - v16 = 0; - v15 = 0; - v4 = v3; - do - { - v5 = *v4; - v6 = 0; - while ( v5 != 9 && v5 ) - { - ++v6; - v5 = v4[v6]; - } - v14 = &v4[v6]; - if ( !v4[v6] ) - v15 = 1; - v4[v6] = 0; - if ( v6 ) - { - switch ( v16 ) - { - case 1: - v1->pInfos[v2].pName = (char *)RemoveQuotes(v4); - break; - case 2: - v1->pInfos[v2].pFilename = (char *)RemoveQuotes(v4); - break; - case 3: - v1->pInfos[v2].uNumResets = atoi(v4); - break; - case 4: - v1->pInfos[v2].uFirstVisitedAt = atoi(v4); - break; - case 5: - v1->pInfos[v2]._per = atoi(v4); - break; - case 6: - v1->pInfos[v2].uRespawnIntervalDays = atoi(v4); - break; - case 7: - v1->pInfos[v2]._alert_days = atoi(v4); - break; - case 8: - v1->pInfos[v2]._steal_perm = atoi(v4); - break; - case 9: - v1->pInfos[v2].field_2D = atoi(v4); - break; - case 10: - v1->pInfos[v2].field_2E = atoi(v4); - break; - case 11: - v1->pInfos[v2].field_2F = atoi(v4); - break; - case 12: - v1->pInfos[v2].field_30 = atoi(v4); - break; - case 13: - v1->pInfos[v2].field_31 = atoi(v4); - break; - case 14: - v1->pInfos[v2].field_32 = atoi(v4); - break; - case 15: - v1->pInfos[v2].field_33 = atoi(v4); - break; - case 16: - v1->pInfos[v2].pEncounterMonster1Texture = (char *)RemoveQuotes(v4); - break; - case 18: - v1->pInfos[v2].field_34 = atoi(v4); - break; - case 19: - v18 = (MapStats *)((char *)v1 + 68 * v2); - v18->pInfos[0].uEncounterMonster1AtLeast = 1; - strcpy(Str, v4); - v17 = 0; - if ( strlen(Str) ) - { - while ( Str[v17] != 45 ) - { - ++v17; - v7 = strlen(Str); - if ( v17 >= v7 ) - goto LABEL_35; - } - Str[v17] = 0; - v18->pInfos[0].uEncounterMonster1AtLeast = atoi(Str); - } -LABEL_35: - v8 = strlen(Str); - if ( v17 == v8 ) - v18->pInfos[0].uEncounterMonster1AtMost = atoi(&v4[v17 + 1]); - else - v18->pInfos[0].uEncounterMonster1AtMost = v18->pInfos[0].uEncounterMonster1AtLeast; - break; - case 20: - v1->pInfos[v2].pEncounterMonster2Texture = (char *)RemoveQuotes(v4); - break; - case 22: - v1->pInfos[v2].field_37 = atoi(v4); - break; - case 23: - v18 = (MapStats *)((char *)v1 + 68 * v2); - v18->pInfos[0].uEncounterMonster2AtLeast = 1; - strcpy(Str, v4); - v17 = 0; - if ( strlen(Str) ) - { - while ( Str[v17] != 45 ) - { - ++v17; - v9 = strlen(Str); - if ( v17 >= v9 ) - goto LABEL_45; - } - Str[v17] = 0; - v18->pInfos[0].uEncounterMonster2AtLeast = atoi(Str); - } -LABEL_45: - v10 = strlen(Str); - if ( v17 == v10 ) - v18->pInfos[0].uEncounterMonster2AtMost = atoi(&v4[v17 + 1]); - else - v18->pInfos[0].uEncounterMonster2AtMost = v18->pInfos[0].uEncounterMonster2AtLeast; - break; - case 24: - v1->pInfos[v2].pEncounterMonster3Texture = (char *)RemoveQuotes(v4); - break; - case 26: - v1->pInfos[v2].field_3A = atoi(v4); - break; - case 27: - v18 = (MapStats *)((char *)v1 + 68 * v2); - v18->pInfos[0].uEncounterMonster3AtLeast = 1; - strcpy(Str, v4); - v17 = 0; - if ( strlen(Str) ) - { - while ( Str[v17] != 45 ) - { - ++v17; - v11 = strlen(Str); - if ( v17 >= v11 ) - goto LABEL_55; - } - Str[v17] = 0; - v18->pInfos[0].uEncounterMonster3AtLeast = atoi(Str); - } -LABEL_55: - v12 = strlen(Str); - if ( v17 == v12 ) - v18->pInfos[0].uEncounterMonster3AtMost = atoi(&v4[v17 + 1]); - else - v18->pInfos[0].uEncounterMonster3AtMost = v18->pInfos[0].uEncounterMonster3AtLeast; - break; - case 28: - v1->pInfos[v2].uRedbookTrackID = atoi(v4); - break; - case 29: - if ( strcmp(v4, "GENERIC") ) - { - if ( strcmp(v4, "PADDEDCELL") ) - { - if ( strcmp(v4, "ROOM") ) - { - if ( strcmp(v4, "BATHROOM") ) - { - if ( strcmp(v4, "LIVINGROOM") ) - { - if ( strcmp(v4, "STONEROOM") ) - { - if ( strcmp(v4, "AUDITORIUM") ) - { - if ( strcmp(v4, "CONCERTHALL") ) - { - if ( strcmp(v4, "CAVE") ) - { - if ( strcmp(v4, "ARENA") ) - { - if ( strcmp(v4, "HANGAR") ) - { - if ( strcmp(v4, "CARPETEDHALLWAY") ) - { - if ( strcmp(v4, "HALLWAY") ) - { - if ( strcmp(v4, "STONECORRIDOR") ) - { - if ( strcmp(v4, "ALLEY") ) - { - if ( strcmp(v4, "FOREST") ) - { - if ( strcmp(v4, "CITY") ) - { - if ( strcmp(v4, "MOUNTAINS") ) - { - if ( strcmp(v4, "QUARRY") ) - { - if ( strcmp(v4, "PLAIN") ) - { - if ( strcmp(v4, "PARKINGLOT") ) - { - if ( strcmp(v4, "SEWERPIPE") ) - { - if ( strcmp(v4, "UNDERWATER") ) - { - if ( strcmp(v4, "DRUGGED") ) - { - if ( strcmp(v4, "DIZZY") ) - { - if ( strcmp(v4, "PSYCHOTIC") ) - v1->pInfos[v2].uEAXEnv = 26; - else - v1->pInfos[v2].uEAXEnv = 25; - } - else - { - v1->pInfos[v2].uEAXEnv = 24; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 23; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 22; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 21; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 20; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 19; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 18; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 17; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 16; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 15; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 14; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 13; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 12; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 11; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 10; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 9; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 8; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 7; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 6; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 5; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 4; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 3; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 2; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 1; - } - } - else - { - v1->pInfos[v2].uEAXEnv = 0; - } - break; - default: - break; - } - } - else - { - v15 = 1; - } - ++v16; - v4 = v14 + 1; - } - while ( v16 - 1 <= 29 && !v15 ); - ++v2; - } - while ( (signed int)v2 < 77 ); - v1->uNumMaps = v2; + 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]; @@ -9673,73 +9604,55 @@ //----- (004547E4) -------------------------------------------------------- void FactionTable::Initialize() { - char *v1; // ebx@1 - char *v2; // eax@4 - signed int v3; // edi@4 - int v4; // ebp@4 - char v5; // dl@5 - char *v6; // ecx@5 - int v7; // esi@9 - signed int v8; // [sp+4h] [bp-Ch]@3 - signed int v9; // [sp+8h] [bp-8h]@4 - char *v10; // [sp+Ch] [bp-4h]@1 - - v1 = 0; - v10 = (char *)relations; + 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 ( pHostileTXT_Raw ) pAllocator->FreeChunk(pHostileTXT_Raw); - pHostileTXT_Raw = 0; + pHostileTXT_Raw = NULL; pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0); strtok(pHostileTXT_Raw, "\r"); - v8 = 0; - do - { - v2 = strtok(v1, "\r") + 1; - v3 = 0; - v9 = (signed int)v1; - v4 = (int)&v10[v8-89]; - do - { - v5 = *v2; - v6 = 0; - if ( *v2 != 9 ) - { - v1 = 0; - do - { - if ( !v5 ) - break; - ++v6; - v5 = v2[(int)v6]; - } - while ( v5 != 9 ); - } - v7 = (int)&v2[(int)v6]; - if ( v2[(int)v6] == (char)v1 ) - v9 = 1; - *(char *)v7 = (char)v1; - if ( v6 == v1 ) - { - v9 = 1; - } - else - { - if ( v3 >= 1 && v3 <= 90 ) - *(char *)v4 = atoi(v2); - } - ++v3; - v4 += 89; - v2 = (char *)(v7 + 1); - } - while ( v3 - 1 <= 90 && (char *)v9 == v1 ); - ++v8; - } - while ( v8 < 89 ); - - if ( pHostileTXT_Raw != v1 ) + for (i=0; i<89; ++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 ( decode_step >= 1 && decode_step < 90 ) + relations[decode_step-1][i] = atoi(test_string); + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<92)&&!break_loop); + } + if ( pHostileTXT_Raw) { pAllocator->FreeChunk(pHostileTXT_Raw); - pHostileTXT_Raw = v1; + pHostileTXT_Raw = NULL; } } @@ -12971,18 +12884,6 @@ srand(GetTickCount()); - /*GetDiskFreeSpaceA(0, &SectorsPerCluster, &BytesPerSector, &hdc, &TotalNumberOfClusters); - v4 = hdc * BytesPerSector * SectorsPerCluster; - if ( (unsigned int)v4 < 0x1E00000 ) - { - sprintfex( - pTmpBuf, - "Due to Window Virtual Memory requirements Might and Magic VII\nrequires 30MB of free hard drive space to operate properly.\n\nAvailable on Current Drive = %luk", - (unsigned int)v4 / 1024i64); - v41 = 48; - v40 = "More Hard Drive Space Required"; - v39 = pTmpBuf; -*/ WNDCLASSEXW wcxw; { @@ -13485,11 +13386,9 @@ unsigned int startms; // [sp+8h] [bp-24h]@55 RECT Rect; // [sp+Ch] [bp-20h]@15 int a2[4]; // [sp+1Ch] [bp-10h]@15 -#ifdef MM7_TEXT_DLL - auto mm7text_dll = LoadLibraryW(L"mm7text.dll"); - sprintfex = (int (__cdecl *)(char *a1, const char *a2, ...))GetProcAddress(mm7text_dll, "_sprintfex"); -#endif - + + char test[1024]; + //sprintfex(test, "^Pi[%s]: ^R[;;]", ""); if (pCmdLine && *pCmdLine) { @@ -13508,7 +13407,7 @@ bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0; if (wcsstr(pCmdLine, L"-nowalksound")) bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20; - if (wcsstr(pCmdLine, L"-noanim")) + if (wcsstr(pCmdLine, L"-novideo")) { dword_6BE364_game_settings_1 |= 0x40; bNoVideo = true;
--- a/mm7_3.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/mm7_3.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -4703,1320 +4703,9 @@ return result; } -//----- (00476387) -------------------------------------------------------- -bool __cdecl sub_476387() -{ - return (pNPCStats->pNewNPCData[57].uFlags & 0x80) != 0; -} - -//----- (00476395) -------------------------------------------------------- -//0x26 Wizard eye at skill level 2 -bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession) -{ - bool result; // eax@2 - signed int v2; // esi@3 - char *v3; // eax@4 - - if ( bNoNPCHiring == 1 ) - return 0; - v2 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs <= 0 ) - { -LABEL_8: - result = 0; - if ( pParty->pHirelings[0].uProfession != uProfession ) - { - LOBYTE(result) = pParty->pHirelings[1].uProfession == uProfession; - return result; - } - } - else - { - v3 = (char *)&pNPCStats->pNewNPCData[0].uFlags; - while ( *((int *)v3 + 4) != uProfession || !(*v3 & 0x80) ) - { - ++v2; - v3 += 76; - if ( v2 >= (signed int)pNPCStats->uNumNewNPCs ) - goto LABEL_8; - } - result = 0; - } - ++result; - return result; -} -// 6BE3C5: using guessed type char bNoNPCHiring; - -//----- (004763E0) -------------------------------------------------------- -void __cdecl InitializeAwards() -{ - char *v0; // ebx@1 - char *v1; // eax@4 - char v2; // dl@5 - char *v3; // ecx@5 - int v4; // esi@9 - signed int v5; // [sp+Ch] [bp-Ch]@4 - char *v6; // [sp+10h] [bp-8h]@4 - Award *v7; // [sp+14h] [bp-4h]@3 - - v0 = 0; - if ( pAwardsTXT_Raw ) - pAllocator->FreeChunk(pAwardsTXT_Raw); - pAwardsTXT_Raw = 0; - pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0); - strtok(pAwardsTXT_Raw, "\r"); - v7 = pAwards; - for (uint i = 0; i < 104; ++i) - { - v1 = strtok(v0, "\r") + 1; - v6 = v0; - v5 = (signed int)v0; - do - { - v2 = *v1; - v3 = 0; - if ( *v1 != 9 ) - { - v0 = 0; - do - { - if ( !v2 ) - break; - ++v3; - v2 = v1[(int)v3]; - } - while ( v2 != 9 ); - } - v4 = (int)&v1[(int)v3]; - if ( v1[(int)v3] == (char)v0 ) - v5 = 1; - *(char *)v4 = (char)v0; - if ( v3 == v0 ) - { - v5 = 1; - } - else - { - if ( v6 == (char *)1 ) - { - v7->pText = RemoveQuotes(v1); - } - else - { - if ( v6 == (char *)2 ) - v7->uSort = atoi(v1); - } - } - ++v6; - v1 = (char *)(v4 + 1); - } - while ( (signed int)(v6 - 1) <= 2 && (char *)v5 == v0 ); - ++v7; - } - //while ( (signed int)v7 < (signed int)&dword_7241C8 ); -} -// 7241C8: using guessed type int dword_7241C8; - -//----- (004764C2) -------------------------------------------------------- -void __cdecl InitializeScrolls() -{ - char *v0; // ebx@1 - char *v1; // eax@4 - int v2; // edi@4 - char v3; // dl@5 - char *v4; // ecx@5 - int v5; // esi@9 - const char **v6; // [sp+10h] [bp-8h]@3 - signed int v7; // [sp+14h] [bp-4h]@4 - - v0 = 0; - if ( pScrollsTXT_Raw ) - pAllocator->FreeChunk(pScrollsTXT_Raw); - pScrollsTXT_Raw = 0; - pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0); - strtok(pScrollsTXT_Raw, "\r"); - v6 = pScrolls; - for (uint i = 0; i < 82; ++i) - { - v1 = strtok(v0, "\r") + 1; - v2 = 0; - v7 = (signed int)v0; - do - { - v3 = *v1; - v4 = 0; - if ( *v1 != 9 ) - { - v0 = 0; - do - { - if ( !v3 ) - break; - ++v4; - v3 = v1[(int)v4]; - } - while ( v3 != 9 ); - } - v5 = (int)&v1[(int)v4]; - if ( v1[(int)v4] == (char)v0 ) - v7 = 1; - *(char *)v5 = (char)v0; - if ( v4 == v0 ) - { - v7 = 1; - } - else - { - if ( v2 == 1 ) - *v6 = RemoveQuotes(v1); - } - ++v2; - v1 = (char *)(v5 + 1); - } - while ( v2 - 1 <= 1 && (char *)v7 == v0 ); - ++v6; - } - //while ( (signed int)v6 < (signed int)dword_723E80_award_related ); -} - - -//----- (00476590) -------------------------------------------------------- -void __cdecl InitializeMerchants() -{ - char *v0; // ebx@1 - //char **v1; // edi@3 - char *v2; // ecx@4 - char v3; // dl@5 - char *v4; // eax@5 - int v5; // esi@9 - signed int v6; // [sp+Ch] [bp-8h]@4 - char *v7; // [sp+10h] [bp-4h]@4 - - v0 = 0; - if ( pMerchantsTXT_Raw ) - pAllocator->FreeChunk(pMerchantsTXT_Raw); - pMerchantsTXT_Raw = 0; - pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0); - strtok(pMerchantsTXT_Raw, "\r"); - //v1 = (char **)pMerchantsRepairPhrases; - for (uint i = 0; i < 7; ++i) - { - v7 = v0; - v6 = (signed int)v0; - v2 = strtok(v0, "\r") + 1; - do - { - v3 = *v2; - v4 = 0; - if ( *v2 != 9 ) - { - v0 = 0; - do - { - if ( !v3 ) - break; - ++v4; - v3 = v2[(int)v4]; - } - while ( v3 != 9 ); - } - v5 = (int)&v2[(int)v4]; - if ( v2[(int)v4] == (char)v0 ) - v6 = 1; - *(char *)v5 = (char)v0; - if ( v4 == v0 ) - { - v6 = 1; - } - else - { - if ( v7 == (char *)1 ) - { - pMerchantsBuyPhrases[i] = RemoveQuotes(v2); - } - else - { - if ( v7 == (char *)2 ) - { - pMerchantsSellPhrases[i] = RemoveQuotes(v2); - } - else - { - if ( v7 == (char *)3 ) - { - pMerchantsRepairPhrases[i] = RemoveQuotes(v2); - } - else - { - if ( v7 - 3 == (char *)1 ) - pMerchantsIdentifyPhrases[i] = RemoveQuotes(v2); - } - } - } - } - ++v7; - v2 = (char *)(v5 + 1); - } - while ( (signed int)(v7 - 1) <= 4 && (char *)v6 == v0 ); - //++v1; - } - //while ( (signed int)v1 < (signed int)pMerchantsIdentifyPhrases ); -} - -//----- (00476682) -------------------------------------------------------- -void __cdecl InitializeTransitions() -{ - char *v0; // ebx@1 - char *v1; // eax@4 - int v2; // edi@4 - char v3; // dl@5 - char *v4; // ecx@5 - int v5; // esi@9 - char **v6; // [sp+10h] [bp-8h]@3 - signed int v7; // [sp+14h] [bp-4h]@4 - - v0 = 0; - if ( pTransitionsTXT_Raw ) - pAllocator->FreeChunk(pTransitionsTXT_Raw); - pTransitionsTXT_Raw = 0; - pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0); - strtok(pTransitionsTXT_Raw, "\r"); - v6 = pTransitionStrings; - for (uint i = 0; i < 464; ++i) - { - v1 = strtok(v0, "\r") + 1; - v2 = 0; - v7 = (signed int)v0; - do - { - v3 = *v1; - v4 = 0; - if ( *v1 != 9 ) - { - v0 = 0; - do - { - if ( !v3 ) - break; - ++v4; - v3 = v1[(int)v4]; - } - while ( v3 != 9 ); - } - v5 = (int)&v1[(int)v4]; - if ( v1[(int)v4] == (char)v0 ) - v7 = 1; - *(char *)v5 = (char)v0; - if ( v4 == v0 ) - { - v7 = 1; - } - else - { - if ( v2 == 1 ) - *v6 = (char *)RemoveQuotes(v1); - } - ++v2; - v1 = (char *)(v5 + 1); - } - while ( v2 - 1 <= 1 && (char *)v7 == v0 ); - ++v6; - } - //while ( (signed int)v6 < (signed int)"awards.txt" ); -} - -//----- (00476750) -------------------------------------------------------- -void __cdecl InitializeAutonotes() -{ - Autonote *v0; // ebp@3 - int v1; // ebx@4 - char *v2; // esi@4 - char v3; // cl@5 - int v4; // eax@5 - char *v5; // edi@9 - signed int v6; // [sp+0h] [bp-4h]@4 - - if ( pAutonoteTXT_Raw ) - pAllocator->FreeChunk(pAutonoteTXT_Raw); - pAutonoteTXT_Raw = 0; - pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0); - strtok(pAutonoteTXT_Raw, "\r"); - v0 = pAutonoteTxt; - for (uint i = 0; i < 195; ++i) - { - v1 = 0; - v2 = strtok(0, "\r") + 1; - v6 = 0; - do - { - v3 = *v2; - v4 = 0; - while ( v3 != 9 && v3 ) - { - ++v4; - v3 = v2[v4]; - } - v5 = &v2[v4]; - if ( !v2[v4] ) - v6 = 1; - *v5 = 0; - if ( v4 ) - { - if ( v1 == 1 ) - { - v0->pText = RemoveQuotes(v2); - } - else - { - if ( v1 == 2 ) - { - if ( _strcmpi(v2, "potion") ) - { - if ( _strcmpi(v2, "stat") ) - { - if ( _strcmpi(v2, "seer") ) - { - if ( _strcmpi(v2, "obelisk") ) - v0->eType = (AUTONOTE_TYPE)(5 - (_strcmpi(v2, "teacher") != 0)); - else - v0->eType = (AUTONOTE_TYPE)2; - } - else - { - v0->eType = (AUTONOTE_TYPE)3; - } - } - else - { - v0->eType = (AUTONOTE_TYPE)1; - } - } - else - { - v0->eType = (AUTONOTE_TYPE)0; - } - } - } - } - else - { - v6 = 1; - } - ++v1; - v2 = v5 + 1; - } - while ( v1 - 1 <= 2 && !v6 ); - ++v0; - } - //while ( (signed int)v0 < (signed int)&pScrolls[1] ); -} - - -//----- (004768A9) -------------------------------------------------------- -void __cdecl InitializeQuests() -{ - char *v0; // ebx@1 - char *v1; // eax@4 - int v2; // edi@4 - char v3; // dl@5 - char *v4; // ecx@5 - int v5; // esi@9 - //const char **v6; // [sp+10h] [bp-8h]@3 - signed int v7; // [sp+14h] [bp-4h]@4 - - v0 = 0; - if ( pQuestsTXT_Raw ) - pAllocator->FreeChunk(pQuestsTXT_Raw); - pQuestsTXT_Raw = 0; - pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0); - strtok(pQuestsTXT_Raw, "\r"); - - //v6 = pQuestTable; - for (uint i = 0; i < 512; ++i) - //do - { - v1 = strtok(v0, "\r") + 1; - v2 = 0; - v7 = (signed int)v0; - do - { - v3 = *v1; - v4 = 0; - if ( *v1 != '\t' ) - { - v0 = 0; - do - { - if ( !v3 ) - break; - ++v4; - v3 = v1[(int)v4]; - } - while ( v3 != '\t' ); - } - v5 = (int)&v1[(int)v4]; - if ( v1[(int)v4] == (char)v0 ) - v7 = 1; - *(char *)v5 = (char)v0; - if ( v4 == v0 ) - { - v7 = 1; - } - else - { - if ( v2 == 1 ) - pQuestTable[i] = RemoveQuotes(v1); - } - ++v2; - v1 = (char *)(v5 + 1); - } - while ( v2 - 1 <= 1 && (char *)v7 == v0 ); - //++v6; - } - //while ( (signed int)v6 < (signed int)&unk_723714 ); -} - - - -//----- (00476977) -------------------------------------------------------- -void NPCStats::Initialize2() -{ - char *v4; // eax@4 - char v5; // dl@5 - int v6; // ecx@5 - char *v7; // edi@9 - char *v9; // eax@21 - char v10; // dl@22 - int v11; // ecx@22 - char *v12; // edi@26 - char *v14; // eax@39 - char v15; // dl@40 - int v16; // ecx@40 - char *v17; // edi@44 - char v18; // zf@47 - NPCStats_stru0 *v19; // eax@57 - signed int v20; // edx@57 - signed int v21; // ecx@58 - int v22; // [sp+10h] [bp-10h]@4 - int v23; // [sp+10h] [bp-10h]@21 - int v25; // [sp+14h] [bp-Ch]@4 - int v26; // [sp+14h] [bp-Ch]@21 - signed int v27; // [sp+14h] [bp-Ch]@39 - //signed int v28; // [sp+18h] [bp-8h]@3 - //signed int v29; // [sp+18h] [bp-8h]@20 - signed int v30; // [sp+18h] [bp-8h]@37 - char *v31; // [sp+1Ch] [bp-4h]@37 - - //v1 = this; - //v2 = 0; - if (pNPCTextTXT_Raw) - pAllocator->FreeChunk(pNPCTextTXT_Raw); - - //v3 = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); - pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); - strtok(pNPCTextTXT_Raw, "\r"); - - for (uint i = 0; i < 789; ++i) - { - v4 = strtok(nullptr, "\r") + 1; - v22 = 0; - v25 = 0; - do - { - v5 = *v4; - v6 = 0; - if ( *v4 != 9 ) - { - do - { - if ( !v5 ) - break; - ++v6; - v5 = v4[v6]; - } - while ( v5 != 9 ); - //v2 = 0; - } - v7 = &v4[v6]; - if ( !v4[v6] ) - v25 = 1; - *v7 = 0; - if ( v6 == 0 ) - { - v25 = 1; - } - else - { - if ( v22 == 1 ) - pNPCTopics[i].pText = RemoveQuotes(v4); - } - ++v22; - v4 = v7 + 1; - } - while ( (signed int)(v22 - 1) <= 1 && !v25);// == nullptr ); - } - - if (pNPCTopicTXT_Raw) - pAllocator->FreeChunk(pNPCTopicTXT_Raw); - - //v8 = (char *)pEvents_LOD->LoadRaw("npctopic.txt", (int)v2); - pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0); - strtok(pNPCTopicTXT_Raw, "\r"); - - for (uint i = 0; i < 579; ++i) - { - v9 = strtok(nullptr, "\r") + 1; - v23 = 0; - v26 = 0; - do - { - v10 = *v9; - v11 = 0; - if ( *v9 != 9 ) - { - do - { - if ( !v10 ) - break; - ++v11; - v10 = v9[v11]; - } - while ( v10 != 9 ); - //v2 = 0; - } - v12 = &v9[v11]; - if ( !v9[v11] ) - v26 = 1; - *v12 = 0; - if ( v11 == 0 ) - { - v26 = 1; - } - else - { - if ( v23 == 1 ) - pNPCTopics[i].pTopic = RemoveQuotes(v9); - } - ++v23; - v9 = v12 + 1; - } - while ( (signed int)(v23 - 1) <= 1 && !v26 ); - } - - if (pNPCDistTXT_Raw) - pAllocator->FreeChunk(pNPCDistTXT_Raw); - - //v13 = (char *)pEvents_LOD->LoadRaw("npcdist.txt", (int)v2); - pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0); - strtok(pNPCDistTXT_Raw, "\r"); - strtok(nullptr, "\r"); - v30 = 1; - v31 = &array_16544[0].field_4[1]; - - char *v2 = 0; - while ( 2 ) - { - v14 = strtok(nullptr, "\r") + 1; - v27 = 0; - char *v24 = nullptr; - do - { - v15 = *v14; - v16 = 0; - if ( *v14 != 9 ) - { - do - { - if ( !v15 ) - break; - ++v16; - v15 = v14[v16]; - } - while ( v15 != 9 ); - v2 = v24; - } - v17 = &v14[v16]; - if ( !v14[v16] ) - v27 = 1; - *v17 = 0; - if ( !v16 ) - { - v27 = 1; - goto LABEL_54; - } - v18 = v2 == 0; - if ( (signed int)v2 > 0 ) - { - if ( (signed int)v2 < 77 ) - { - array_16544[(int)v2].field_4[v30] = atoi(v14); - goto LABEL_54; - } - v18 = v2 == 0; - } - if ( v18 ) - *v31 = 10; -LABEL_54: - ++v2; - v14 = v17 + 1; - v24 = v2; - } - while ( (signed int)(v2 - 1) <= 77 && !v27 ); - ++v30; - ++v31; - if ( v30 < 59 ) - { - v2 = 0; - continue; - } - break; - } - v19 = array_16544; - v20 = 77; - do - { - v19->field_0 = 0; - v21 = 1; - do - v19->field_0 += v19->field_4[v21++]; - while ( v21 < 59 ); - ++v19; - --v20; - } - while ( v20 ); - - if (pNPCDistTXT_Raw) - { - pAllocator->FreeChunk(pNPCDistTXT_Raw); - pNPCDistTXT_Raw = nullptr; - } -} - -//----- (00476C60) -------------------------------------------------------- -void NPCStats::_476C60() -{ - for (uint i = 1; i < uNumNewNPCs; ++i) - pNewNPCData[i].pName = pNPCNames2[i - 1]; - - if (pParty->pHirelings[0].pName) - pParty->pHirelings[0].pName = pParty->pHireling1Name; - if (pParty->pHirelings[1].pName) - pParty->pHirelings[1].pName = pParty->pHireling2Name; -} - -//----- (00476CB5) -------------------------------------------------------- -void NPCStats::Initialize1() -{ - NPCStats *pNPCStats; // esi@1 - char *pRaw; // eax@1 - char *pHouse; // edi@1 - char *v4; // eax@2 - char v5; // dl@3 - int v6; // ecx@3 - char *v7; // eax@11 - char *v8; // eax@26 - char *v9; // ecx@27 - char v10; // dl@28 - int v11; // eax@28 - int v12; // edi@32 - char *v13; // eax@42 - char *v14; // eax@43 - char v15; // dl@44 - int v16; // ecx@44 - int v17; // edi@48 - char *v18; // eax@56 - char *v19; // eax@57 - char v20; // cl@58 - int v21; // edi@58 - int v22; // esi@62 - int v23; // [sp+Ch] [bp-14h]@7 - signed int v24; // [sp+10h] [bp-10h]@1 - signed int v25; // [sp+10h] [bp-10h]@26 - signed int v26; // [sp+10h] [bp-10h]@42 - signed int v27; // [sp+10h] [bp-10h]@56 - char *Str; // [sp+14h] [bp-Ch]@1 - NPCGreeting *pGreetings; // [sp+14h] [bp-Ch]@26 - unsigned __int16 *pGroups; // [sp+14h] [bp-Ch]@42 - char **pCatchPhrase; // [sp+14h] [bp-Ch]@56 - signed int v32; // [sp+18h] [bp-8h]@2 - signed int v33; // [sp+18h] [bp-8h]@27 - signed int v34; // [sp+18h] [bp-8h]@43 - signed int v35; // [sp+18h] [bp-8h]@57 - signed int v36; // [sp+1Ch] [bp-4h]@2 - signed int v37; // [sp+1Ch] [bp-4h]@27 - signed int v38; // [sp+1Ch] [bp-4h]@43 - signed int v39; // [sp+1Ch] [bp-4h]@57 - - pNPCStats = this; - pRaw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0); - pNPCStats->pNPCDataTXT_Raw = pRaw; - strtok(pRaw, "\r"); - strtok(0, "\r"); - pHouse = (char *)&pNPCStats->pNPCData[1].house; - Str = (char *)pNPCStats->pNPCNames2; - v24 = 500; - do - { - v32 = 0; - v4 = strtok(0, "\r") + 1; - v36 = -1; - do - { - v5 = *v4; - v6 = 0; - while ( v5 != 9 && v5 ) - { - ++v6; - v5 = v4[v6]; - } - v23 = (int)&v4[v6]; - if ( !v4[v6] ) - v32 = 1; - v4[v6] = 0; - if ( v6 ) - { - switch ( v36 ) - { - case 0: - v7 = RemoveQuotes(v4); - *((int *)pHouse - 5) = (int)v7; - *(int *)Str = (int)v7; - break; - case 1: - *((int *)pHouse - 4) = atoi(v4); - break; - case 5: - *(int *)pHouse = atoi(v4); - break; - case 6: - *((int *)pHouse + 1) = atoi(v4); - break; - case 7: - *((int *)pHouse + 2) = atoi(v4); - break; - case 8: - *((int *)pHouse + 3) = *v4 == 121; - break; - case 9: - *((int *)pHouse + 5) = atoi(v4); - break; - case 10: - *((int *)pHouse + 6) = atoi(v4); - break; - case 11: - *((int *)pHouse + 7) = atoi(v4); - break; - case 12: - *((int *)pHouse + 8) = atoi(v4); - break; - case 13: - *((int *)pHouse + 9) = atoi(v4); - break; - case 14: - *((int *)pHouse + 10) = atoi(v4); - break; - default: - break; - } - } - ++v36; - v4 = (char *)(v23 + 1); - } - while ( v36 + 1 <= 15 && !v32 ); - Str += 4; - pHouse += 76; - --v24; - } - while ( v24 ); - pNPCStats->uNumNewNPCs = 501; - v8 = (char *)pEvents_LOD->LoadRaw("npcgreet.txt", 0); - pNPCStats->pNPCGreetTXT_Raw = v8; - strtok(v8, "\r"); - pGreetings = pNPCStats->pNPCGreetings; - v25 = 205; - do - { - v37 = 0; - v33 = 0; - v9 = strtok(0, "\r") + 1; - do - { - v10 = *v9; - v11 = 0; - while ( v10 != 9 && v10 ) - { - ++v11; - v10 = v9[v11]; - } - v12 = (int)&v9[v11]; - if ( !v9[v11] ) - v33 = 1; - *(char *)v12 = 0; - if ( v11 ) - { - if ( v37 == 1 ) - { - pGreetings->pGreeting1 = (char *)RemoveQuotes(v9); - } - else - { - if ( v37 == 2 ) - pGreetings->pGreeting2 = (char *)RemoveQuotes(v9); - } - } - ++v37; - v9 = (char *)(v12 + 1); - } - while ( v37 <= 2 && !v33 ); - ++pGreetings; - --v25; - } - while ( v25 ); - v13 = (char *)pEvents_LOD->LoadRaw("npcgroup.txt", 0); - pNPCStats->pNCPGroupTXT_Raw = v13; - strtok(v13, "\r"); - pGroups = pNPCStats->pGroups; - v26 = 51; - do - { - v14 = strtok(0, "\r") + 1; - v38 = 0; - v34 = 0; - do - { - v15 = *v14; - v16 = 0; - while ( v15 != 9 && v15 ) - { - ++v16; - v15 = v14[v16]; - } - v17 = (int)&v14[v16]; - if ( !v14[v16] ) - v34 = 1; - *(char *)v17 = 0; - if ( v16 && v38 == 1 ) - *pGroups = atoi(v14); - ++v38; - v14 = (char *)(v17 + 1); - } - while ( v38 <= 1 && !v34 ); - ++pGroups; - --v26; - } - while ( v26 ); - v18 = (char *)pEvents_LOD->LoadRaw("npcnews.txt", 0); - pNPCStats->pNPCNewsTXT_Raw = v18; - strtok(v18, "\r"); - pCatchPhrase = pNPCStats->pCatchPhrases; - v27 = 51; - do - { - v19 = strtok(0, "\r") + 1; - v39 = 0; - v35 = 0; - do - { - v20 = *v19; - v21 = 0; - while ( v20 != 9 && v20 ) - { - ++v21; - v20 = v19[v21]; - } - v22 = (int)&v19[v21]; - if ( !v19[v21] ) - v35 = 1; - *(char *)v22 = 0; - if ( v21 && v39 == 1 ) - *pCatchPhrase = (char *)RemoveQuotes(v19); - ++v39; - v19 = (char *)(v22 + 1); - } - while ( v39 <= 1 && !v35 ); - ++pCatchPhrase; - --v27; - } - while ( v27 ); -} - -//----- (0047702F) -------------------------------------------------------- -void NPCStats::Initialize() -{ - //NPCStats *v1; // edi@1 - char *v2; // ebx@1 - //char *v3; // eax@1 - char *v4; // ebx@3 - char v5; // al@4 - int v6; // ecx@4 - //char *v7; // eax@18 - char *v8; // ebx@18 - char *v9; // ecx@19 - char v10; // dl@20 - int v11; // eax@20 - char v12; // zf@41 - signed int v13; // [sp+Ch] [bp-14h]@18 - int v14; // [sp+10h] [bp-10h]@4 - int v15; // [sp+10h] [bp-10h]@24 - char *v16; // [sp+14h] [bp-Ch]@1 - signed int v17; // [sp+14h] [bp-Ch]@19 - unsigned int v18; // [sp+18h] [bp-8h]@1 - char *v19; // [sp+18h] [bp-8h]@18 - signed int v20; // [sp+1Ch] [bp-4h]@3 - signed int v21; // [sp+1Ch] [bp-4h]@19 - //v1 = this; - - Initialize1(); - Initialize2(); - - InitializeQuests(); - InitializeAutonotes(); - InitializeAwards(); - InitializeTransitions(); - InitializeMerchants(); - InitializeScrolls(); - v2 = 0; - field_17FC0 = 0; - pNPCNamesTXT_Raw = 0; - //v3 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); - pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); - strtok(pNPCNamesTXT_Raw, "\r"); - v18 = 0; - v16 = (char *)pNPCNames; - while ( 1 ) - { - v4 = strtok(v2, "\r") + 1; - v20 = 0; - do - { - v5 = *v4; - v6 = 0; - v14 = 0; - if ( *v4 == 9 ) - goto LABEL_45; - do - { - if ( !v5 ) - break; - if ( v5 == 10 ) - break; - ++v6; - v14 = v6; - v5 = v4[v6]; - } - while ( v5 != 9 ); - if ( v6 ) - { - v4[v6] = 0; - if ( v20 ) - { - if ( v20 == 1 ) - *((int *)v16 + 1) = (int)RemoveQuotes(v4); - } - else - { - *(int *)v16 = (int)RemoveQuotes(v4); - } - } - else - { -LABEL_45: - if ( v20 == 1 && !uNumNPCNames[1] ) - uNumNPCNames[1] = v18; - } - ++v20; - v4 += v14 + 1; - } - while ( v20 <= 1 ); - ++v18; - v16 += 8; - if ( (signed int)v18 >= 540 ) - break; - v2 = 0; - } - pNPCProfTXT_Raw = 0; - uNumNPCNames[0] = v18; - //v7 = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); - pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); - strtok(pNPCProfTXT_Raw, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - v8 = (char *)&pProfessions[0].pJoinText; - v19 = (char *)&pProfessions[0].pJoinText; - v13 = 58; - do - { - v21 = 0; - v9 = strtok(0, "\r") + 1; - v17 = 0; - do - { - v10 = *v9; - v11 = 0; - if ( *v9 != 9 ) - { - do - { - if ( !v10 ) - break; - ++v11; - v10 = v9[v11]; - } - while ( v10 != 9 ); - v8 = v19; - } - v15 = (int)&v9[v11]; - if ( !v9[v11] ) - v17 = 1; - *(char *)v15 = 0; - if ( v11 ) - { - switch ( v21 ) - { - case 2: - *((int *)v8 - 3) = atoi(v9); - break; - case 3: - *((int *)v8 - 1) = (int)RemoveQuotes(v9); - break; - case 4: - *((int *)v8 - 2) = (int)RemoveQuotes(v9); - break; - case 5: - *(int *)v8 = (int)RemoveQuotes(v9); - break; - case 6: - *((int *)v8 + 1) = (int)RemoveQuotes(v9); - break; - } - } - else - { - if ( !v21 ) - v17 = 1; - } - ++v21; - v9 = (char *)(v15 + 1); - } - while ( v21 <= 6 && !v17 ); - v8 += 20; - v12 = v13-- == 1; - v19 = v8; - } - while ( !v12 ); - uNumNPCProfessions = 59; -} - -//----- (00477266) -------------------------------------------------------- -void NPCStats::Release() -{ - NPCStats *v1; // esi@1 - void *v2; // ST00_4@1 - int v3; // ebx@1 - - v1 = this; - pAllocator->FreeChunk(this->pNPCTopicTXT_Raw); - v2 = v1->pNPCTextTXT_Raw; - v1->pNPCNewsTXT_Raw = 0; - pAllocator->FreeChunk(v2); - v1->pNPCNewsTXT_Raw = 0; - pAllocator->FreeChunk(0); - v1->pNPCNewsTXT_Raw = 0; - pAllocator->FreeChunk(v1->pNPCProfTXT_Raw); - v1->pNPCProfTXT_Raw = 0; - pAllocator->FreeChunk(v1->pNPCNamesTXT_Raw); - v1->pNPCNamesTXT_Raw = 0; - pAllocator->FreeChunk(v1->pNPCDataTXT_Raw); - v1->pNPCDataTXT_Raw = 0; - pAllocator->FreeChunk(v1->pNPCDistTXT_Raw); - v1->pNPCDistTXT_Raw = 0; - v3 = (int)&v1->pNPCGreetTXT_Raw; - pAllocator->FreeChunk(v1->pNPCGreetTXT_Raw); - v1 = (NPCStats *)((char *)v1 + 98296); - *(int *)v3 = 0; - pAllocator->FreeChunk(v1->pNPCData[0].pName); - v1->pNPCData[0].pName = 0; -} - -//----- (0047730C) -------------------------------------------------------- -int __fastcall const_1(int a1, int) -{ - return 1; -} -// 47730C: using guessed type int __stdcall const_1(int); - -//----- (0047732C) -------------------------------------------------------- -bool NPCStats::InitializeAdditionalNPCs(NPCData *a2, int a3, int a4, int a5) -{ - //NPCStats *v5; // ebx@1 - signed __int64 v6; // qax@1 - int v7; // esi@1 - int v8; // edx@1 - NPCData *v9; // edi@1 - int v10; // eax@1 - //int v11; // eax@23 - int v12; // ecx@23 - int v13; // edx@28 - int v14; // esi@37 - int v15; // edx@37 - int v16; // ecx@37 - int v17; // eax@37 - int v18; // edx@37 - signed int result; // eax@39 - int v20; // [sp+Ch] [bp-Ch]@1 - signed int v21; // [sp+10h] [bp-8h]@1 - signed int v22; // [sp+14h] [bp-4h]@1 - int v23; // [sp+24h] [bp+Ch]@1 - - - v23 = a3 - 1; - //v5 = this; - v6 = (signed __int64)((double)v23 * -0.33333334); - v7 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 28]; - v20 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 116]; - v8 = rand() % uNumNPCNames[v7]; - v9 = a2; - a2->uSex = v7; - a2->pName = pNPCNames[v8][v7]; - v10 = 0; - v22 = 0; - v21 = 0; - - while ( 1 ) - { - if ( v20 == v10 ) - { - if ( v7 == v10 ) - { - v23 = 2; - a2 = (NPCData *)100; - } - else - { - if ( v7 - v10 == 1 ) - { - v23 = 201; - a2 = (NPCData *)250; - } - } - } - else - { - switch ( v20 - v10 ) - { - case 1: - if ( v7 == v10 ) - { - v23 = 400; - a2 = (NPCData *)430; - } - else - { - if ( v7 - v10 == 1 ) - { - v23 = 460; - a2 = (NPCData *)490; - } - } - break; - case 2: - if ( v7 == v10 ) - { - v23 = 500; - a2 = (NPCData *)520; - } - else - { - if ( v7 - v10 == 1 ) - { - v23 = 530; - a2 = (NPCData *)550; - } - } - break; - case 3: - if ( v7 == v10 ) - { - v23 = 300; - a2 = (NPCData *)330; - } - else - { - if ( v7 - v10 == 1 ) - { - v23 = 360; - a2 = (NPCData *)387; - } - } - break; - } - } - v12 = v23 + rand() % ((int)a2 - v23 + 1); - if ( const_1(v12, v7) == 1 ) - v21 = 1; - ++v22; - if ( v22 >= 4 ) - { - v12 = v23; - v21 = 1; - } - if ( v21 ) - break; - v10 = 0; - } - - v9->uPortraitID = v12; - v9->uFlags = 0; - v9->fame = 0; - v13 = rand() % 100 + 1; - - if ( v13 >= 60 ) - { - if ( v13 >= 90 ) - { - if ( v13 >= 95 ) - { - if ( v13 >= 98 ) - v9->rep = -600; - else - v9->rep = 400; - } - else - { - v9->rep = -300; - } - } - else - { - v9->rep = 200; - } - } - else - { - v9->rep = 0; - } - - //v14 = (int)((char *)v5 + 64 * a5); - //v15 = rand() % *(_DWORD *)(v14 + 91460); - v15 = rand() % array_16544[a5].field_0; - v16 = 0; - v17 = 0; - v18 = v15 + 1; - - if ( v18 > 0 ) - { - do - //v14 += *(char *)(v14 + v17++ + 0x16548); - v16 += array_16544[a5].field_4[v17++]; - while ( v16 < v18 ); - } - v9->uProfession = v17 - 1; - v9->house = a4; - v9->field_24 = 1; - v9->joins = 1; - return true; -} + + + // 47730C: using guessed type int __stdcall const_1(int); //----- (0047752B) -------------------------------------------------------- @@ -6965,7 +5654,7 @@ v7->field_58 = 0; if ( v7->field_58 > 31 ) v7->field_58 = 31; - if ( pOutdoorCamera->numStru148s >= 1999 ) + if ( pOutdoorCamera->numStru148s >= 1999 + 5000) return result; ++pOutdoorCamera->numStru148s; ++pOutdoorCamera->field_44; @@ -7065,7 +5754,7 @@ if ( BYTE1(v33) & 0x3C ) v34 = pRenderer->pHDWaterBitmapIDs[0]; else - v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; } else @@ -9704,7 +8393,7 @@ ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); pRenderer->DrawTerrainPolygon(uNumVertices, this, - pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]], + pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_tile_id]], 0, 0); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1)); @@ -14519,7 +13208,7 @@ { int v5; // ebx@1 int v6; // edi@1 - unsigned int *v7; // eax@8 + BLVMapOutlines *v7; // eax@8 unsigned __int8 v8; // zf@8 unsigned __int8 v9; // sf@8 int v10; // esi@10 @@ -14535,7 +13224,7 @@ int v20; // eax@16 signed int v21; // esi@18 int v22; // ecx@21 - int v23; // ecx@21 + BLVMapOutline *v23; // ecx@21 Vec3_short_ *v24; // edx@21 Vec3_short_ *v25; // eax@21 int v26; // ecx@21 @@ -14544,7 +13233,7 @@ int v29; // eax@21 double v30; // st7@23 signed __int64 v31; // qax@23 - char *v32; // edx@23 + unsigned short *v32; // edx@23 int v33; // esi@23 signed int v34; // eax@23 signed int v35; // ecx@23 @@ -14552,12 +13241,12 @@ int v37; // ecx@27 int v38; // edx@31 unsigned int v39; // eax@33 - const void *v40; // esi@33 - unsigned __int16 *v41; // edi@33 + short *v40; // esi@33 + short *v41; // edi@33 unsigned __int8 v42; // cf@33 unsigned int v43; // ecx@33 - int v44; // edi@33 - int v45; // esi@33 + short *v44; // edi@33 + short *v45; // esi@33 int v46; // ecx@33 signed int v47; // esi@38 signed int v48; // ecx@38 @@ -14578,7 +13267,7 @@ signed int v63; // esi@85 int v64; // eax@87 unsigned int v65; // ebx@95 - char *v66; // edx@95 + unsigned short *v66; // edx@95 unsigned __int16 *v67; // esi@96 int v68; // edi@98 unsigned __int16 v69; // cx@99 @@ -14587,7 +13276,7 @@ unsigned int v72; // [sp-8h] [bp-4806Ch]@80 signed int v73; // [sp-4h] [bp-48068h]@59 unsigned __int16 v74; // [sp-4h] [bp-48068h]@79 - char v75; // [sp+Ch] [bp-48058h]@23 + unsigned short v75[131070]; // [sp+Ch] [bp-48058h]@23 int v76; // [sp+4800Ch] [bp-58h]@23 unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27 unsigned __int16 *v78; // [sp+48014h] [bp-50h]@23 @@ -14606,11 +13295,11 @@ unsigned int i; // [sp+48048h] [bp-1Ch]@9 unsigned int v92; // [sp+4804Ch] [bp-18h]@16 unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16 - unsigned int v94; // [sp+48054h] [bp-10h]@8 + signed int v94; // [sp+48054h] [bp-10h]@8 unsigned int v95; // [sp+48058h] [bp-Ch]@16 int v96; // [sp+4805Ch] [bp-8h]@10 const void *v97; // [sp+48060h] [bp-4h]@16 - char *a4a; // [sp+4806Ch] [bp+8h]@85 + unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85 int a5a; // [sp+48070h] [bp+Ch]@86 x_ = x; @@ -14630,9 +13319,17 @@ if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) v5 = 680; } - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - goto LABEL_8; -LABEL_23: + } + else + { + v6 = viewparams->field_38; + v86 = viewparams->field_38; + v84 = viewparams->field_3A; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + v5 = viewparams->field_2C - 34; + } + if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) + { v94 = a4 - x_ + 1; v92 = a5 - y_ + 1; v93 = &pRenderer->pTargetSurface[x_ + y_ * v79]; @@ -14645,7 +13342,7 @@ v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16); v96 = 32768 - black - v84; v31 = (signed __int64)((double)v96 / v30); - v32 = &v75; + v32 = v75; v33 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth; v34 = (int)v31 << 16; v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30); @@ -14668,7 +13365,7 @@ do { *(short *)v32 = v78[*((char *)v77 + v37)];//crash - v32 += 2; + ++v32; v97 = (char *)v97 + v87; v37 = (signed int)v97 >> 16; --i; @@ -14694,22 +13391,22 @@ if ( (signed int)v94 > 0 ) { v39 = v94; - v40 = v97; - v41 = v93; + v40 = (short *)v97; + v41 = (short *)v93; v42 = v94 & 1; v43 = v94 >> 1; - memcpy(v93, v97, 4 * (v94 >> 1)); - v45 = (int)((char *)v40 + 4 * v43); - v44 = (int)&v41[2 * v43]; + memcpy(v93, v97, 2 * (v94 >> 1)); + v45 = &v40[2 * v43]; + v44 = &v41[2 * v43]; v46 = v42; v39 *= 2; v93 = (unsigned __int16 *)((char *)v93 + v39); v97 = (char *)v97 + v39; while ( v46 ) { - *(short *)v44 = *(short *)v45; - v45 += 2; - v44 += 2; + *v44 = *v45; + ++v45; + ++v44; --v46; } v6 = v86; @@ -14722,16 +13419,9 @@ } else { - v6 = viewparams->field_38; - v86 = viewparams->field_38; - v84 = viewparams->field_3A; - if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) - goto LABEL_23; - v5 = viewparams->field_2C - 34; - LABEL_8: black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0); teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu); - v7 = (uint *)pIndoor->pMapOutlines; + v7 = pIndoor->pMapOutlines; uNumBlueFacesInBLVMinimap = 0; v8 = pIndoor->pMapOutlines->uNumOutlines == 0; v9 = pIndoor->pMapOutlines->uNumOutlines < 0; @@ -14780,13 +13470,13 @@ v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16), v90 - v92, black); - v7 = (uint *)pIndoor->pMapOutlines; + v7 = pIndoor->pMapOutlines; } } ++v94; i += 12; } - while ( (signed int)v94 < (signed int)*v7 ); + while ( v94 < (signed int)v7->uNumOutlines ); } v21 = 0; if ( (signed int)uNumBlueFacesInBLVMinimap > 0 ) @@ -14795,9 +13485,9 @@ { v22 = pBlueFacesInBLVMinimapIDs[v21]; v87 = v5; - v23 = (int)&v7[3 * v22 + 1]; - v24 = &pIndoor->pVertices[*(short *)v23]; - v25 = &pIndoor->pVertices[*(short *)(v23 + 2)]; + v23 = &v7->pOutlines[v22]; + v24 = &pIndoor->pVertices[v23->uVertex1ID]; + v25 = &pIndoor->pVertices[v23->uVertex2ID]; v26 = v25->x; v27 = (unsigned __int16 *)(v24->x - v86); v28 = v24->y - v84; @@ -14818,7 +13508,7 @@ ++v21; if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap ) break; - v7 = (uint *)pIndoor->pMapOutlines; + v7 = pIndoor->pMapOutlines; } v6 = v86; } @@ -14980,7 +13670,7 @@ v62 = (int)v61 << 16; teal = v60 >> 16; v63 = (signed __int16)v61; - a4a = &v75; + a4a = v75; result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xCu, 0xCu, 0xCu); v85 = 0; for ( i = result; v85 < (signed int)v95; result = v85 ) @@ -14998,14 +13688,14 @@ if ( pOutdoor->_47F097(v81, v96) ) { if ( !((a5a + v85) % 2) ) - *(short *)a4a = i; + *a4a = i; } else { - *(short *)a4a = 0; - } - } - a4a += 2; + *a4a = 0; + } + } + ++a4a; v97 = (char *)v97 + black; v64 = (signed int)v97 >> 16; ++a5a; @@ -15014,13 +13704,13 @@ } v62 += black; v97 = (const void *)v60; - a4a += 2 * (v90 - a5a); + a4a += v90 - a5a; v63 = v62 >> 16; ++v85; teal = (unsigned int)v78; } v65 = v95; - v66 = &v75; + v66 = v75; if ( (signed int)v95 > 0 ) { v67 = v77; @@ -15035,7 +13725,7 @@ v69 = *(short *)v66; if ( !*(short *)v66 || v69 == (short)i ) *v67 = v69; - v66 += 2; + ++v66; ++v67; --v68; } @@ -15246,322 +13936,259 @@ //----- (00443801) -------------------------------------------------------- -int __cdecl Initialize2DA() -{ - const char *v0; // esi@3 - _2devent *v1; // edi@3 - char *v2; // esi@5 - int v3; // edx@5 - char v4; // cl@6 - int v5; // eax@6 - int v6; // ebx@10 - int v7; // eax@60 - int result; // eax@78 - signed int v9; // [sp+10h] [bp-8h]@5 - signed int v10; // [sp+14h] [bp-4h]@5 - - int it = 0; - - if ( p2DEventsTXT_Raw ) - pAllocator->FreeChunk(p2DEventsTXT_Raw); - p2DEventsTXT_Raw = 0; - v0 = "\r"; - p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0); - strtok(p2DEventsTXT_Raw, "\r"); - strtok(0, "\r"); - v1 = p2DEvents; - while ( 1 ) - { - v2 = strtok(0, v0) + 1; - v10 = 0; - v3 = -2; - v9 = -2; - do - { - v4 = *v2; - v5 = 0; - while ( v4 != 9 && v4 ) - { - ++v5; - v4 = v2[v5]; - } - v6 = (int)&v2[v5]; - if ( !v2[v5] ) - v10 = 1; - *(char *)v6 = 0; - if ( v5 ) - { - switch ( v3 ) - { - case 0: - if ( _strnicmp(v2, "wea", 3u) ) - { - if ( _strnicmp(v2, "arm", 3u) ) - { - if ( _strnicmp(v2, "mag", 3u) ) - { - if ( _strnicmp(v2, "alc", 3u) ) - { - if ( _strnicmp(v2, "sta", 3u) ) - { - if ( _strnicmp(v2, "boa", 3u) ) - { - if ( _strnicmp(v2, "tem", 3u) ) - { - if ( _strnicmp(v2, "tra", 3u) ) - { - if ( _strnicmp(v2, "tow", 3u) ) - { - if ( _strnicmp(v2, "tav", 3u) ) - { - if ( _strnicmp(v2, "ban", 3u) ) - { - if ( _strnicmp(v2, "fir", 3u) ) - { - if ( _strnicmp(v2, "air", 3u) ) - { - if ( _strnicmp(v2, "wat", 3u) ) - { - if ( _strnicmp(v2, "ear", 3u) ) - { - if ( _strnicmp(v2, "spi", 3u) ) - { - if ( _strnicmp(v2, "min", 3u) ) - { - if ( _strnicmp(v2, "bod", 3u) ) - { - if ( _strnicmp(v2, "lig", 3u) ) - { - if ( _strnicmp(v2, "dar", 3u) ) - { - if ( _strnicmp(v2, "ele", 3u) ) - { - if ( _strnicmp(v2, "sel", 3u) ) - { - if ( _strnicmp(v2, "mir", 3u) ) - { - v7 = -(_strnicmp(v2, "mer", 3u) != 0); - LOBYTE(v7) = v7 & 0xEE; - v1->uType = v7 + 18; - } - else - { - v1->uType = 16; - } - } - else - { - v1->uType = 15; - } - } - else - { - v1->uType = 14; - } - } - else - { - v1->uType = 13; - } - } - else - { - v1->uType = 12; - } - } - else - { - v1->uType = 11; - } - } - else - { - v1->uType = 10; - } - } - else - { - v1->uType = 9; - } - } - else - { - v1->uType = 8; - } - } - else - { - v1->uType = 7; - } - } - else - { - v1->uType = 6; - } - } - else - { - v1->uType = 5; - } - } - else - { - v1->uType = 22; - } - } - else - { - v1->uType = 21; - } - } - else - { - v1->uType = 17; - } - } - else - { - v1->uType = 30; - } - } - else - { - v1->uType = 23; - } - } - else - { - v1->uType = 28; - } - } - else - { - v1->uType = 27; - } - } - else - { - v1->uType = 4; - } - } - else - { - v1->uType = 3; - } - } - else - { - v1->uType = 2; - } - } - else - { - v1->uType = 1; - } - break; - case 2: - v1->uAnimationID = atoi(v2); - break; - case 3: - v1->pName = (char *)RemoveQuotes(v2); - break; - case 4: - v1->pProprieterName = RemoveQuotes(v2); - break; - case 5: - v1->pProprieterTitle = RemoveQuotes(v2); - break; - case 6: - v1->field_14 = atoi(v2); - break; - case 7: - v1->_state = atoi(v2); - break; - case 8: - v1->_rep = atoi(v2); - break; - case 9: - v1->_per = atoi(v2); - break; - case 10: - v1->fPriceMultiplier = atof(v2); - break; - case 11: - v1->flt_24 = atof(v2); - break; - case 13: - v1->field_1C = atoi(v2); - break; - case 16: - v1->uOpenTime = atoi(v2); - break; - case 17: - v1->uCloseTime = atoi(v2); - break; - case 18: - v1->uExitPicID = atoi(v2); - break; - case 19: - v1->uExitMapID = atoi(v2); - break; - case 20: - v1->_quest_related = atoi(v2); - break; - case 21: - v1->pEnterText = RemoveQuotes(v2); - break; - default: - break; - } - } - v2 = (char *)(v6 + 1); - v3 = v9 + 1; - v9 = v3; - result = v3 + 1; - } - while ( v3 + 1 <= 23 && !v10 ); - ++v1; - //if ( (signed int)v1 >= (signed int)&unk_597F10 ) - if (++it >= 525) - return result; - v0 = "\r"; - } +void Initialize2DA() +{ + + int i; + char* test_string; + unsigned char c; + bool break_loop; + unsigned int temp_str_len; + char* tmp_pos; + int decode_step; + + if ( p2DEventsTXT_Raw ) + pAllocator->FreeChunk(p2DEventsTXT_Raw); + p2DEventsTXT_Raw = NULL; + p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0); + strtok(p2DEventsTXT_Raw, "\r"); + strtok(NULL, "\r"); + + for (i=0;i<525;++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: + { + if ( !_strnicmp(test_string, "wea", 3) ) + { + p2DEvents[i].uType = 1; + break; + } + if ( !_strnicmp(test_string, "arm", 3) ) + { + p2DEvents[i].uType = 2; + break; + } + if ( !_strnicmp(test_string, "mag", 3) ) + { + p2DEvents[i].uType = 3; + break; + } + if ( !_strnicmp(test_string, "alc", 3) ) + { + p2DEvents[i].uType = 4; + break; + } + if ( !_strnicmp(test_string, "sta", 3) ) + { + p2DEvents[i].uType = 27; + break; + } + if ( !_strnicmp(test_string, "boa", 3) ) + { + p2DEvents[i].uType = 28; + break; + } + if ( !_strnicmp(test_string, "tem", 3) ) + { + p2DEvents[i].uType = 23; + break; + } + if ( !_strnicmp(test_string, "tra", 3) ) + { + p2DEvents[i].uType = 30; + break; + } + if ( !_strnicmp(test_string, "tow", 3) ) + { + p2DEvents[i].uType = 17; + break; + } + + if ( !_strnicmp(test_string, "tav", 3) ) + { + p2DEvents[i].uType = 21; + break; + } + if ( !_strnicmp(test_string, "ban", 3) ) + { + p2DEvents[i].uType = 22; + break; + } + if ( !_strnicmp(test_string, "fir", 3) ) + { + p2DEvents[i].uType = 5; + break; + } + if ( !_strnicmp(test_string, "air", 3) ) + { + p2DEvents[i].uType = 6; + break; + } + if ( !_strnicmp(test_string, "wat", 3) ) + { + p2DEvents[i].uType = 7; + break; + } + if ( !_strnicmp(test_string, "ear", 3) ) + { + p2DEvents[i].uType = 8; + break; + } + if ( !_strnicmp(test_string, "spi", 3) ) + { + p2DEvents[i].uType = 9; + break; + } + if ( !_strnicmp(test_string, "min", 3) ) + { + p2DEvents[i].uType = 10; + break; + } + if ( !_strnicmp(test_string, "bod", 3) ) + { + p2DEvents[i].uType = 11; + break; + } + if ( !_strnicmp(test_string, "lig", 3) ) + { + p2DEvents[i].uType = 12; + break; + } + if ( !_strnicmp(test_string, "dar", 3) ) + { + p2DEvents[i].uType = 13; + break; + } + if ( !_strnicmp(test_string, "ele", 3) ) + { + p2DEvents[i].uType = 14; + break; + } + if ( !_strnicmp(test_string, "sel", 3) ) + { + p2DEvents[i].uType = 15; + break; + } + if ( !_strnicmp(test_string, "mir", 3) ) + { + p2DEvents[i].uType = 16; + break; + } + if ( !_strnicmp(test_string, "mer", 3) ) + { + p2DEvents[i].uType = 17; + break; + } + p2DEvents[i].uType = 18; + } + break; + + case 4: + p2DEvents[i].uAnimationID = atoi(test_string); + break; + case 5: + p2DEvents[i].pName = RemoveQuotes(test_string); + break; + case 6: + p2DEvents[i].pProprieterName = RemoveQuotes(test_string); + break; + case 7: + p2DEvents[i].pProprieterTitle = RemoveQuotes(test_string); + break; + case 8: + p2DEvents[i].field_14 = atoi(test_string); + break; + case 9: + p2DEvents[i]._state = atoi(test_string); + break; + case 10: + p2DEvents[i]._rep = atoi(test_string); + break; + case 11: + p2DEvents[i]._per = atoi(test_string); + break; + case 12: + p2DEvents[i].fPriceMultiplier = atof(test_string); + break; + case 13: + p2DEvents[i].flt_24 = atof(test_string); + break; + case 15: + p2DEvents[i].field_1C = atoi(test_string); + break; + case 18: + p2DEvents[i].uOpenTime = atoi(test_string); + break; + case 19: + p2DEvents[i].uCloseTime = atoi(test_string); + break; + case 20: + p2DEvents[i].uExitPicID = atoi(test_string); + break; + case 21: + p2DEvents[i].uExitMapID = atoi(test_string); + break; + case 22: + p2DEvents[i]._quest_related = atoi(test_string); + break; + case 23: + p2DEvents[i].pEnterText = RemoveQuotes(test_string); + break; + } + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<24)&&!break_loop); + } + } //----- (00443CE1) -------------------------------------------------------- -unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize) -{ - const char *v3; // edi@1 - FILE *v4; // eax@1 - unsigned int v5; // esi@3 - char Args; // [sp+8h] [bp-B4h]@6 - //Texture DstBuf; // [sp+6Ch] [bp-50h]@1 - void *Dst; // [sp+B4h] [bp-8h]@1 +unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize) +{ + FILE *pLodFile; // eax@1 + unsigned int uTextureSize; // esi@3 + char Args[60]; // [sp+8h] [bp-B4h]@6 void *ptr; // [sp+B8h] [bp-4h]@1 - - v3 = pContainerName; - Dst = a2; - ptr = pEvents_LOD->LoadRaw(pContainerName, 0); - Texture DstBuf; // [sp+6Ch] [bp-50h]@1 - //Texture::Texture(&DstBuf); - - v4 = pEvents_LOD->FindContainer(v3, 0); - if ( !v4 ) - Abortf("Unable to load %s", v3); - fread(&DstBuf, 1u, 0x30u, v4); - v5 = DstBuf.uDecompressedSize; + + ptr = pEvents_LOD->LoadRaw(pContainerName, 0); + pLodFile = pEvents_LOD->FindContainer(pContainerName, 0); + if ( !pLodFile ) + Abortf("Unable to load %s", pContainerName); + fread(&DstBuf, 1, 48, pLodFile); + uTextureSize = DstBuf.uDecompressedSize; if ( !DstBuf.uDecompressedSize ) - v5 = DstBuf.uTextureSize; - memset(&DstBuf, 0, 0x48u); - if ( (signed int)v5 >= (signed int)uBufferSize ) - { - sprintf(&Args, "File %s Size %lu - Buffer size %lu", v3, v5, uBufferSize); - Abortf(&Args); - } - memcpy(Dst, ptr, v5); + uTextureSize = DstBuf.uTextureSize; + memset(&DstBuf, 0, 72); + if ( uTextureSize >= (signed int)uBufferSize ) + { + sprintf(Args, "File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize); + Abortf(Args); + } + memcpy(pBuffer, ptr, uTextureSize); pAllocator->FreeChunk(ptr); - return v5; + return uTextureSize; } //----- (00443DA1) -------------------------------------------------------- @@ -16388,7 +15015,7 @@ //----- (00445308) -------------------------------------------------------- -const char *__fastcall sub_445308(int a1) +const char *GetProfessionActionText(int a1) { if ( a1 == 10 || a1 == 11 @@ -16401,12 +15028,11 @@ || a1 == 42 || a1 == 43 || a1 == 52 ) - return (const char *)*(&pNPCStats->field_13A60 + 5 * a1); + return pNPCStats->pProfessions[a1 - 1].pActionText; else return pNPCTopics[407].pTopic; } - //----- (00445350) -------------------------------------------------------- void __cdecl DrawDialogueUI() { @@ -16415,21 +15041,21 @@ unsigned __int16 v2; // di@2 //unsigned int v3; // eax@2 char *v4; // esi@3 - int v5; // eax@11 - char *v6; // ecx@13 - char *v7; // eax@16 - unsigned int v8; // edi@19 - char *v9; // ecx@27 + //int v5; // eax@11 + //char *v6; // ecx@13 + //char *v7; // eax@16 + //unsigned int v8; // edi@19 + //char *v9; // ecx@27 char *v10; // eax@29 - int v11; // eax@30 + //int v11; // eax@30 int v12; // esi@39 char *v13; // eax@41 GUIButton *v14; // eax@43 - GUIButton *v15; // edi@43 + //GUIButton *v15; // edi@43 signed int v16; // eax@44 - unsigned int v23; // eax@53 - const char *v24; // eax@59 - unsigned __int16 v30; // cx@83 + //unsigned int v23; // eax@53 + //const char *v24; // eax@59 + //unsigned __int16 v30; // cx@83 int v31; // ecx@86 int v32; // ebx@93 unsigned int v33; // eax@93 @@ -16453,8 +15079,8 @@ GUIWindow v51; // [sp+58h] [bp-BCh]@2 GUIWindow v52; // [sp+ACh] [bp-68h]@42 char *Str; // [sp+100h] [bp-14h]@104 - __int16 v54[2]; // [sp+104h] [bp-10h]@2 - unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82 + //int v54; // [sp+104h] [bp-10h]@2 + //unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82 GUIFont *pOutString; // [sp+10Ch] [bp-8h]@39 char *pInString=NULL; // [sp+110h] [bp-4h]@32 @@ -16465,408 +15091,249 @@ v1 = sub_445C8B(uDialogue_SpeakingActorNPC_ID); v51.uFrameWidth -= 10; v51.uFrameZ -= 10; - *(int *)v54 = v1; + //v54 = v1; GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u); v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background); - pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0)); + pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_507B04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507B04] : 0)); + pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pDialogueNPCPortraits[0]); - if ( pNPC->uProfession ) - { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s - } - else - { + + if (pNPC->uProfession) + { + assert(pNPC->uProfession < sizeof(aNPCProfessionNames) / sizeof(*aNPCProfessionNames)); // sometimes buffer overflows; errors emerge both here and in dialogue text + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s + } + else strcpy(pTmpBuf, pNPC->pName); - } + v51.DrawTitleText(pFontArrus, 483, 112, v2, pTmpBuf, 3); pParty->GetPartyFame(); - if ( (signed int)uDialogueType > DIALOGUE_ARENA_WELCOME ) - { - if ( uDialogueType == DIALOGUE_ARENA_FIGHT_NOT_OVER_YET ) - { - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[577], &pWindow, 13, 0) + 7;//"Get back in there you wimps:" - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pGlobalTXT_LocalizationStrings[577], &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[577], pFontArrus, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0); - } - else if ( uDialogueType == DIALOGUE_ARENA_REWARD ) - { - sprintf(v4, pGlobalTXT_LocalizationStrings[576], dword_F8B1B4);// "Congratulations on your win: here's your stuff: %u gold." - pInString = v4; - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - else if ( uDialogueType == DIALOGUE_ARENA_ALREADY_WON ) - { + + pInString = nullptr; + switch (uDialogueType) + { + case DIALOGUE_13: + pInString = BuilDialogueString(pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + break; + + case DIALOGUE_PROFESSION_DETAILS: + { + auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; + + if (dialogue_show_profession_details) + pInString = BuilDialogueString(prof->pBenefits, uActiveCharacter - 1, 0, 0, 0, 0); + else if (pNPC->Hired()) + pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + else + pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + } + break; + + + case DIALOGUE_ARENA_WELCOME: + pInString = pGlobalTXT_LocalizationStrings[574]; // "Welcome to the Arena of Life and Death. Remember, you are only allowed one arena combat per visit. To fight an arena battle, select the option that best describes your abilities and return to me- if you survive:" + break; + + case DIALOGUE_ARENA_FIGHT_NOT_OVER_YET: + pInString = pGlobalTXT_LocalizationStrings[577]; //"Get back in there you wimps:" + break; + + case DIALOGUE_ARENA_REWARD: + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[576], gold_transaction_amount);// "Congratulations on your win: here's your stuff: %u gold." + pInString = pTmpBuf; + break; + + case DIALOGUE_ARENA_ALREADY_WON: pInString = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:" - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - } - else - { - if ( uDialogueType == DIALOGUE_ARENA_WELCOME ) - { - v7 = pGlobalTXT_LocalizationStrings[574]; // "Welcome to the Arena of Life and Death. Remember, you are only allowed one arena combat per visit. To fight an arena battle, select the option that best describes your abilities and return to me- if you survive:" - pInString = v7; - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - else if ( uDialogueType == DIALOGUE_13 ) - { - v5 = 5 * pNPC->uProfession; - v6 = (char *)*(&pNPCStats->field_13A64 + v5); - v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0); - pInString = v7; - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - else if ( (signed int)uDialogueType > DIALOGUE_18 && !((signed int)uDialogueType > DIALOGUE_24 && uDialogueType != DIALOGUE_77 || byte_5B0938[0]) ) - { - if ( (signed int)uDialogueType > DIALOGUE_24 && uDialogueType == DIALOGUE_77 ) - { - v5 = 5 * pNPC->uProfession; - if ( byte_F8B1EC ) - { - v6 = (char *)*(&pNPCStats->field_13A5C + 5 * pNPC->uProfession); - v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0); - pInString = v7; - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - else if ( pNPC->uFlags & 0x80 ) - { - v6 = (char *)*(&pNPCStats->field_13A68 + 5 * pNPC->uProfession); - v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0); - pInString = v7; - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - else - { - v6 = (char *)*(&pNPCStats->field_13A64 + v5); - v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0); - pInString = v7; - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - } - else - { - v7 = (char *)ptr_F8B1E8; - pInString = v7; - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - } - else - { - if ( *(int *)v54 == 1 ) - { - v11 = pNPC->greet; - v8 = 0; - if ( v11 ) - { - v10 = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * v11); - if ( pInString != NULL ) - { - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - } - } - else - { - if ( *(int *)v54 == 2 ) - { - if ( pNPC->uFlags & 0x80 ) - v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pDismissText; - else - v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed" - pInString = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0); - if ( pInString != NULL ) - { - pWindow.uFrameWidth = 460; - pWindow.uFrameZ = 452; - pOutString = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) - { - pOutString = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - } - pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); - } - } - } - } - } + break; + + default: + if (uDialogueType > DIALOGUE_18 && uDialogueType < DIALOGUE_23 && !byte_5B0938[0]) + { + pInString = (char *)ptr_F8B1E8; + } + else if (v1 == 1) + { + if (pNPC->greet) + { + if ((pNPC->uFlags & 3) == 2) + pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting2; + else + pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting1; + } + } + else if (v1 == 2) + { + auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; + + if (pNPC->Hired()) + pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + else + pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + } + break; + } + + if (pInString) + { + pWindow.uFrameWidth = 460; + pWindow.uFrameZ = 452; + auto font = pFontArrus; + v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; + if ( 352 - v12 < 8 ) + { + font = pFontCreate; + v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; + } + if (uTextureID_Leather != -1) + pRenderer->_4A6A68(8, 352 - v12, &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - v12); + pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); + v13 = FitTextInAWindow(pInString, font, &pWindow, 0xDu, 0); + pDialogueWindow->DrawText(font, 13, 354 - v12, 0, v13, 0, 0, 0); + } + + memcpy(&v52, pDialogueWindow, sizeof(v52)); v52.uFrameX = 483; v52.uFrameWidth = 148; v52.uFrameZ = 334; - for ( pOutString = (GUIFont *)v52.pStartingPosActiveItem; - (signed int)pOutString < v52.pStartingPosActiveItem + v52.pNumPresenceButton; - pOutString = (GUIFont *)((char *)pOutString + 1) ) - { - v14 = v52.GetControl((unsigned int)pOutString); - v15 = v14; + for (int i = v52.pStartingPosActiveItem; + i < v52.pStartingPosActiveItem + v52.pNumPresenceButton; ++i) + { + v14 = v52.GetControl(i); + //v15 = v14; if ( !v14 ) break; v16 = v14->uControlParam; if ( v16 > 88 ) - { - v24 = ""; - } - else if ( v16 == 88 ) - v24 = pGlobalTXT_LocalizationStrings[581]; - else if ( v16 == 87 ) - v24 = pGlobalTXT_LocalizationStrings[580]; - else if ( v16 == 86 ) - v24 = pGlobalTXT_LocalizationStrings[579]; - else if ( v16 == 85 ) - v24 = pGlobalTXT_LocalizationStrings[578]; - else if ( v16 == 77 ) - v24 = pGlobalTXT_LocalizationStrings[407]; - else if ( v16 == 76 ) - { - if ( pNPC->uFlags & 0x80 ) - { - sprintf(pTmpBuf, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName); - v24 = pTmpBuf; - } - else - v24 = pGlobalTXT_LocalizationStrings[406]; - } - else if ( v16 == 24 ) - { - v23 = pNPC->evtf; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } - } - else if ( v16 == 9 ) - v24 = (const char *)sub_445308(pNPC->uProfession); - else if ( v16 == 19 ) + v14->pButtonName[0] = 0; + else if (v16 == 88) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[581]); // Lord + else if (v16 == 87) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[580]); // Knight + else if (v16 == 86) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[579]); // Squire + else if (v16 == 85) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[578]); // Page + else if (v16 == 77) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[407]); // Details + else if (v16 == 76) + { + if (pNPC->Hired()) + sprintf(v14->pButtonName, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s + else + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[406]); // Hire + } + else if (v16 == 24) + { + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evtf - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else + strcpy(v14->pButtonName, topic); + } + else if (v16 == 9) + strcpy(v14->pButtonName, GetProfessionActionText(pNPC->uProfession)); + else if (v16 == 19) { - v23 = pNPC->bDrawSomeAnim; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->bDrawSomeAnim - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 20 ) + else if (v16 == 20) { - v23 = pNPC->_anim_current_time; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->_anim_current_time - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 21 ) + else if (v16 == 21) { - v23 = pNPC->_anim_end_time; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->_anim_end_time - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 22 ) + else if (v16 == 22) { - v23 = pNPC->evtd; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evtd - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 23 ) + else if (v16 == 23) { - v23 = pNPC->evte; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evte - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 13 ) + else if (v16 == 13) { - if ( pNPC->uFlags & 0x80 ) - { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName); - v24 = pTmpBuf; - } - else - v24 = pGlobalTXT_LocalizationStrings[122]; + if (pNPC->Hired()) + sprintf(v14->pButtonName, pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s + else + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[122]); // Join } else - v24 = ""; + v14->pButtonName[0] = 0; - if ( pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1 ) - { + if (pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1) + { + int num_dead_actors = 0; pInString = 0; - if ( (signed int)uNumActors > 0 ) - { - v55 = (unsigned short *)&pActors[0].uAIState; - *(int *)v54 = uNumActors; - do - { - v30 = *v55; - if ( *v55 == Dead || v30 == Removed || v30 == Disabled || (v31 = *((int *)v55 + 159)) != 0 && (v31 & 7) == OBJECT_Player) - ++pInString; - v55 += 418; - --*(int *)v54; - } - while ( *(int *)v54 ); - } - if ( pInString == (char *)uNumActors ) - v24 = pGlobalTXT_LocalizationStrings[658]; - } - strcpy(v15->pButtonName, v24); - } + for (uint i = 0; i < uNumActors; ++i) + { + if (pActors[i].uAIState == Dead || pActors[i].uAIState == Removed || + pActors[i].uAIState == Disabled) + ++num_dead_actors; + else + { + int sumonner_type = pActors[i].uSummonerID & 7;; + if (sumonner_type == OBJECT_Player) + ++num_dead_actors; + } + } + if (num_dead_actors == uNumActors) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[658]); // Collect Prize + } + } + + v32 = 0; - pInString = (char *)GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); + //pInString = (char *)GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); v33 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u); v34 = pDialogueWindow; - *(int *)v54 = v33; + //v54 = v33; v35 = pDialogueWindow->pStartingPosActiveItem; for ( i = v35 + pDialogueWindow->pNumPresenceButton; v35 < i; i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) { @@ -16887,7 +15354,7 @@ pOutString = (GUIFont *)((174 - v32) / v39); if ( (174 - v32) / v39 > 32 ) pOutString = (GUIFont *)32; - v55 = (unsigned __int16 *)1; + int v55 = 1; v40 = 174 - (int)pOutString * v39 - v32; v41 = v34->pStartingPosActiveItem; v42 = v40 / 2 - (signed int)pOutString / 2 + 138; @@ -16902,22 +15369,22 @@ Str = v43->pButtonName; v44 = pFontArrus->CalcTextHeight(v43->pButtonName, &v52, 0, 0); v45 = v43->uY; - v46 = v55; + v46 = (unsigned short *)v55; v43->uHeight = v44; v42 = v45 + v44 - 1; v43->uW = v42; - v47 = v54[0]; + v47 = v33; if ( (unsigned __int16 *)pDialogueWindow->pCurrentPosActiveItem != v46 ) - v47 = (unsigned __int16)pInString; + v47 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); v52.DrawTitleText(pFontArrus, 0, v45, v47, Str, 3u); v34 = pDialogueWindow; - v55 = (unsigned __int16 *)((char *)v55 + 1); + ++v55; ++v41; } while ( (signed int)v41 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); } } - pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); + pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0)); } //----- (004459F9) -------------------------------------------------------- @@ -17035,7 +15502,7 @@ { for (i = 0; i < pNPCStats->uNumNewNPCs; ++i) { - if (pNPCStats->pNewNPCData[i].uFlags & 0x80) + if (pNPCStats->pNewNPCData[i].Hired()) { if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName)) { @@ -17121,7 +15588,7 @@ v16 = &pTmpBuf[v6]; do { - if ( v9->uFlags & 0x80 + if ( v9->Hired() && (!pParty->pHirelings[0].pName || strcmp(v9->pName, pParty->pHirelings[0].pName)) && (!pParty->pHirelings[1].pName || strcmp(v9->pName, pParty->pHirelings[1].pName)) ) { @@ -17187,7 +15654,7 @@ v8 = pNPCStats->pNewNPCData; do { - if ( v8->uFlags & 0x80 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) ) + if (v8->Hired() && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) ) { if ( !pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName) ) *v7++ = v1 + 2; @@ -20305,7 +18772,7 @@ for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i) { auto npc = pNPCStats->pNewNPCData + i; - if (npc->uFlags & 0x80 && + if (npc->Hired() && (!pParty->pHirelings[0].pName || strcmp(npc->pName, pParty->pHirelings[0].pName))) { if (!pParty->pHirelings[1].pName || strcmp(npc->pName, pParty->pHirelings[1].pName))
--- a/mm7_4.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/mm7_4.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -3519,7 +3519,7 @@ } } v44 = 0; - if ( sub_476387() == 1 ) + if (PartyHasDragon()) v44 = 1; v49 = 0; LABEL_25: @@ -3530,7 +3530,7 @@ v45 = 0; v48 = 0; v46 = 0; - if ( v44 && v21->classType == PLAYER_CLASS_31 ) + if ( v44 && v21->classType == PLAYER_CLASS_WARLOCK ) v50 = 1; if ( v21->classType == PLAYER_CLASS_LICH ) v48 = 1; @@ -4836,18 +4836,18 @@ } //----- (00495461) -------------------------------------------------------- -char *__fastcall sub_495461(char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, __int64 *a6) +char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, __int64 *a6) { unsigned __int8 v6; // bl@1 Player *pPlayer; // ebx@3 - NPCData *v9; // eax@4 - size_t v10; // eax@6 + //NPCData *v9; // eax@4 + //size_t v10; // eax@6 char *v11; // esi@7 - int v12; // edx@7 - ItemGen *v13; // edi@7 - char v14; // cl@8 - char *v15; // ecx@10 - int v16; // edx@10 + //int v12; // edx@7 + //ItemGen *v13; // edi@7 + //char v14; // cl@8 + //char *v15; // ecx@10 + //int v16; // edx@10 int v17; // eax@10 signed __int64 v18; // qax@18 unsigned int v19; // edi@32 @@ -4891,70 +4891,74 @@ stru351 v57; // [sp+9Ch] [bp-9Ch]@115 char a1[100]; // [sp+B8h] [bp-80h]@3 unsigned int v59; // [sp+11Ch] [bp-1Ch]@3 - size_t v60; // [sp+120h] [bp-18h]@3 - Player *v61; // [sp+124h] [bp-14h]@3 - char *Str; // [sp+128h] [bp-10h]@1 + //size_t v60; // [sp+120h] [bp-18h]@3 + //Player *v61; // [sp+124h] [bp-14h]@3 + //char *Str; // [sp+128h] [bp-10h]@1 int v63; // [sp+12Ch] [bp-Ch]@32 - int v64; // [sp+130h] [bp-8h]@6 - NPCData *v65; // [sp+134h] [bp-4h]@6 + //int v64; // [sp+130h] [bp-8h]@6 + //NPCData *v65; // [sp+134h] [bp-4h]@6 + //int packed; + + v6 = uPlayerID; - Str = lpsz; + //Str = lpsz; if ( IsBadStringPtrA(lpsz, 1u) ) return "Invalid String Passed"; - v60 = strlen(Str); + a1[0] = 0; pPlayer = &pParty->pPlayers[v6]; - v59 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); - v61 = pPlayer; - memset(pTmpBuf2, 0, 0x7D0u); + v59 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 155); + //v61 = pPlayer; + memset(pTmpBuf2, 0, sizeof(pTmpBuf2)); + + NPCData *npc = nullptr; if ( dword_5C35D4 ) - v9 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)]; - else - v9 = GetNPCData(uDialogue_SpeakingActorNPC_ID); - v65 = v9; - v10 = 0; - v64 = 0; - if ( (signed int)v60 > 0 ) - { - v11 = a4; - v12 = v64; - v13 = a3; - while ( 1 ) - { - v14 = Str[v12]; - if ( v14 == 37 ) - break; - pTmpBuf2[v10++] = v14; -LABEL_119: - ++v12; - v64 = v12; - if ( v12 >= (signed int)v60 ) - return pTmpBuf2; - } - v15 = &Str[v12 + 1]; - v16 = (unsigned __int8)Str[v12 + 2]; - v17 = v16 + 10 * (unsigned __int8)*v15 - 528; - if ( v17 <= 15 ) - { - if ( v17 != 15 ) - { - switch ( v16 + 10 * (unsigned __int8)*v15 ) - { - case 0x211: - v11 = v65->pName; - goto LABEL_118; - case 0x212: + { + __debugbreak(); // fix + npc = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)]; + } + else + npc = GetNPCData(uDialogue_SpeakingActorNPC_ID); + //v65 = v9; + //v10 = 0; + //v64 = 0; + + //int i = 0; + //if ( (signed int)v60 > 0 ) + v11 = a4; + + auto len = strlen(lpsz); + for (int i = 0, dst = 0; i < len; ++i) + { + //v12 = v64; + //v13 = a3; + //while ( 1 ) + //{ + char c = lpsz[i]; + if (c != '%') + pTmpBuf2[dst++] = c; + else + { + //v15 = &lpsz[v12 + 1]; + //v16 = (unsigned __int8)lpsz[v12 + 2]; + //packed = 10 * (int)lpsz[v12 + 1] + lpsz[v12 + 2]; + //v17 = packed - 528;// 10 * '0' + '0' + v17 = 10 * (int)(lpsz[i + 1] - '0') + lpsz[i + 2] - '0'; + + switch ( v17 ) + { + case 1: + v11 = npc->pName; + goto _continue_strcat; + case 2: v11 = pPlayer->pName; - goto LABEL_118; - case 0x213: - case 0x219: - if ( v65->uSex ) - v11 = pGlobalTXT_LocalizationStrings[384];// "her" - else - v11 = pGlobalTXT_LocalizationStrings[383];// "his" - goto LABEL_118; - case 0x215: + goto _continue_strcat; + case 3: + case 4: + v11 = a1; + goto _continue_strcat; + case 5: v18 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60 / 60 % 24; v11 = pGlobalTXT_LocalizationStrings[397];// "evening" if ( SHIDWORD(v18) <= 0 && SHIDWORD(v18) >= 0 && (unsigned int)v18 >= 5 && SHIDWORD(v18) <= 0 ) @@ -4969,22 +4973,23 @@ v11 = pGlobalTXT_LocalizationStrings[395];// "morning" } } - goto LABEL_118; - case 0x216: + goto _continue_strcat; + case 6: if ( pPlayer->uSex ) v11 = pGlobalTXT_LocalizationStrings[387];// "lady" else v11 = pGlobalTXT_LocalizationStrings[385];// "sir" - goto LABEL_118; - case 0x217: + goto _continue_strcat; + case 7: if ( pPlayer->uSex ) - goto LABEL_43; - v11 = pGlobalTXT_LocalizationStrings[386];// "Sir" - goto LABEL_118; - case 0x218: + v11 = pGlobalTXT_LocalizationStrings[389];// "Lady" + else + v11 = pGlobalTXT_LocalizationStrings[386];// "Sir" + goto _continue_strcat; + case 8: v19 = 0; v63 = 0; - v20 = (unsigned __int8 *)v61->field_152; + v20 = (unsigned __int8 *)pPlayer->field_152; do { if ( (unsigned __int16)_449B57_test_bit(v20, word_4EE150[v19]) ) @@ -5012,21 +5017,26 @@ { v11 = (char *)pNPCTopics[55].pText; } - pPlayer = v61; - v13 = a3; - goto LABEL_118; - case 0x21A: + //pPlayer = v61; + //v13 = a3; + goto _continue_strcat; + case 9: + if ( npc->uSex ) + v11 = pGlobalTXT_LocalizationStrings[384];// "her" + else + v11 = pGlobalTXT_LocalizationStrings[383];// "his" + goto _continue_strcat; + case 10: if ( pPlayer->uSex ) -LABEL_43: v11 = pGlobalTXT_LocalizationStrings[389];// "Lady" else v11 = pGlobalTXT_LocalizationStrings[388];// "Lord" - goto LABEL_118; - case 0x21B: + goto _continue_strcat; + case 11: v25 = GetPartyReputation(); goto LABEL_46; - case 0x21C: - v25 = v65->rep; + case 12: + v25 = npc->rep; LABEL_46: if ( v25 >= 25 ) { @@ -5053,79 +5063,91 @@ v11 = pGlobalTXT_LocalizationStrings[392]; } } - goto LABEL_118; - case 0x21D: + goto _continue_strcat; + case 13: v11 = sub_495366(pPlayer->pName[0], pPlayer->uSex); - goto LABEL_118; - case 0x21E: - goto LABEL_93; - case 0x214: - goto LABEL_117; - default: - goto LABEL_108; - } - goto LABEL_108; - } - v11 = pGlobalTXT_LocalizationStrings[393];// "daughter" -LABEL_118: - strcat(pTmpBuf2, v11); - v10 = strlen(pTmpBuf2); - v64 += 2; - v12 = v64; - goto LABEL_119; - } - if ( v17 <= 29 ) - { - if ( v17 == 29 ) - { - //v34 = p2DEvents_minus1__20[13 * (signed int)a4]; - v34 = p2DEvents[(signed int)a4 - 1].fPriceMultiplier; - } - else - { - if ( v16 + 10 * (unsigned __int8)*v15 == 544 ) - { -LABEL_93: - if ( v65->uSex ) - v11 = pGlobalTXT_LocalizationStrings[391];// "sister" - else - v11 = pGlobalTXT_LocalizationStrings[390];// "brother" - goto LABEL_118; - } - if ( v16 + 10 * (unsigned __int8)*v15 == 545 ) - { - v29 = *(&pNPCStats->field_13A58 + 5 * v65->uProfession) / 100; - goto LABEL_91; - } - if ( v16 + 10 * (unsigned __int8)*v15 == 551 ) - { - v47 = pMapStats->GetMapInfo(pCurrentMapName); - if ( v47 ) - v11 = pMapStats->pInfos[v47].pName; - else - v11 = pGlobalTXT_LocalizationStrings[394];// "Unknown" - goto LABEL_118; - } - if ( v16 + 10 * (unsigned __int8)*v15 == 552 ) - { - v46 = v13->GetDisplayName(); - sprintf(a1, format_4E2D80, v59, v46); -LABEL_117: + goto _continue_strcat; + case 14: + { + if ( npc->uSex ) + v11 = pGlobalTXT_LocalizationStrings[391];// "sister" + else + v11 = pGlobalTXT_LocalizationStrings[390];// "brother" + goto _continue_strcat; + } + + case 15: + { + v11 = pGlobalTXT_LocalizationStrings[393];// "daughter" +_continue_strcat: + strcat(pTmpBuf2, v11); + dst = strlen(pTmpBuf2); + //v64 += 2; + i += 2; + } + break; + + case 16: + { + if ( npc->uSex ) + v11 = pGlobalTXT_LocalizationStrings[391];// "sister" + else + v11 = pGlobalTXT_LocalizationStrings[390];// "brother" + goto _continue_strcat; + } + case 17: + { + auto pay_percentage = pNPCStats->pProfessions[npc->uProfession - 1].uHirePrice / 100; + if (!pay_percentage) + pay_percentage = 1; + + sprintf(a1, "%lu", pay_percentage); + v11 = a1; + goto _continue_strcat; + } + + case 18: + case 19: + case 20: + case 21: + case 22: + case 26: +_continue_strncpy: + strncpy(a1, lpsz + i + 1, 2); + v51 = atoi(a1); + sprintf(a1, "%lu", v51); v11 = a1; - goto LABEL_118; - } - if ( v16 + 10 * (unsigned __int8)*v15 == 553 ) - { - //v37 = &p2DEvents_minus1__20[13 * (signed int)a4]; - v37 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier; - v38 = *v37; - v39 = v13->GetValue(); - v29 = pPlayer->_4B8233(v39, v38); + goto _continue_strcat; + + case 23: + { + v47 = pMapStats->GetMapInfo(pCurrentMapName); + if ( v47 ) + v11 = pMapStats->pInfos[v47].pName; + else + v11 = pGlobalTXT_LocalizationStrings[394];// "Unknown" + goto _continue_strcat; + } + case 24: + { + v46 = a3->GetDisplayName(); + sprintf(a1, format_4E2D80, v59, v46); + v11 = a1; + goto _continue_strcat; + } + + + case 25: + { + v37 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier; + v38 = *v37; + v39 = a3->GetValue(); + v29 = pPlayer->_4B8233(v39, v38); switch ( a5 ) { case 3: v44 = *v37; - v45 = v13->GetValue(); + v45 = a3->GetValue(); v29 = pPlayer->_4B8213(v45, v44); break; case 4: @@ -5133,54 +5155,39 @@ break; case 5: v42 = *v37; - v43 = v13->GetValue(); + v43 = a3->GetValue(); v29 = pPlayer->_4B8265(v43, v42); break; case 6: v40 = *v37; - v41 = v13->GetValue(); + v41 = a3->GetValue(); v29 = pPlayer->_4B8213(v41, v40) / 2; break; - } - goto LABEL_98; - } - if ( v16 + 10 * (unsigned __int8)*v15 != 555 ) - { - if ( v16 + 10 * (unsigned __int8)*v15 == 556 ) - { - //v11 = (char *)p2DEvents_minus1__10[13 * (signed int)a4]; - v11 = (char *)p2DEvents[(signed int)a4 - 1].pProprieterTitle; - goto LABEL_118; - } -LABEL_108: - strncpy(a1, v15, 2u); - v51 = atoi(a1); - sprintf(a1, "%lu", v51); - goto LABEL_117; - } - v26 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier; + } + goto _continue_sprintf; + } + + case 27: + { + v26 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier; v27 = *v26; - v28 = v13->GetValue(); + v28 = a3->GetValue(); v29 = pPlayer->_4B8142(v28, v27); if ( a5 == 3 ) { v35 = *v26; - v36 = v13->GetValue(); + v36 = a3->GetValue(); v29 = pPlayer->_4B8102(v36, v35); - if ( v13->uAttributes & 2 ) - { -LABEL_77: + if ( a3->uAttributes & 2 ) v29 = 1; - goto LABEL_98; - } - goto LABEL_98; + goto _continue_sprintf; } if ( a5 != 4 ) { if ( a5 == 5 ) { v32 = *v26; - v33 = v13->GetValue(); + v33 = a3->GetValue(); v29 = pPlayer->_4B81C3(v33, v32); } else @@ -5188,69 +5195,80 @@ if ( a5 == 6 ) { v30 = *v26; - v31 = v13->GetValue(); + v31 = a3->GetValue(); v29 = pPlayer->_4B8102(v31, v30) / 2; - if ( v13->uAttributes & 2 ) + if ( a3->uAttributes & 2 ) + v29 = 1; + if (!v29) v29 = 1; -LABEL_91: - if ( v29 >= 1 ) - goto LABEL_98; - goto LABEL_77; + goto _continue_sprintf; } } -LABEL_98: +_continue_sprintf: sprintf(a1, "%lu", v29); - goto LABEL_117; + v11 = a1; + goto _continue_strcat; } v34 = *v26; - } + v48 = v34; v29 = pPlayer->_4B8179(v48); - goto LABEL_98; - } - if ( v17 != 30 ) - { - switch ( v17 ) - { - case 31: - v52 = pPlayers[1]; - break; - case 32: - v52 = pPlayers[2]; - break; - case 33: - v52 = pPlayers[3]; - break; - default: - if ( v17 != 34 ) - { + goto _continue_sprintf; + } + + case 28: + { + //v11 = (char *)p2DEvents_minus1__10[13 * (signed int)a4]; + v11 = (char *)p2DEvents[(signed int)a4 - 1].pProprieterTitle; + goto _continue_strcat; + } + + case 29: + { + //v34 = p2DEvents_minus1__20[13 * (signed int)a4]; + v34 = p2DEvents[(signed int)a4 - 1].fPriceMultiplier; + v48 = v34; + v29 = pPlayer->_4B8179(v48); + goto _continue_sprintf; + } + + case 30: + { + if ( !a6 ) + goto _continue_strcat; + sub_493F79(&v57, *a6); + v54 = v57.field_18; + v53 = v57.field_C + 1; + v50 = v57.field_14; + sprintf(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54); + v11 = a1; + goto _continue_strcat; + } + + case 31: + case 32: + case 33: + case 34: + v52 = &pParty->pPlayers[v17 - 31]; + v11 = v52->pName; + goto _continue_strcat; + + default: if ( v17 <= 50 || v17 > 70 ) - goto LABEL_108; - if ( v16 + 10 * (unsigned __int8)*v15 - 579 >= 20 ) - goto LABEL_118; + goto _continue_strncpy; + if ( v17 - 51 >= 20 ) + goto _continue_strcat; HIDWORD(v49) = pParty->field_3C.field_440[2 * v17 + 1]; LODWORD(v49) = pParty->field_3C.field_440[2 * v17]; sub_493F79(&v56, v49); v54 = v56.field_18; v53 = v56.field_C + 1; v50 = v56.field_14; -LABEL_116: sprintf(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54); - goto LABEL_117; - } - v52 = pPlayers[4]; - break; - } - v11 = v52->pName; - goto LABEL_118; - } - if ( !a6 ) - goto LABEL_118; - sub_493F79(&v57, *a6); - v54 = v57.field_18; - v53 = v57.field_C + 1; - v50 = v57.field_14; - goto LABEL_116; + v11 = a1; + goto _continue_strcat; + } + } } return pTmpBuf2; } @@ -5607,7 +5625,7 @@ pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[32]); pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, 2 * v128 + 417, v80, pClassNames[32], 0, 0, 0); v85 = uColorTeal; - if ( uClassType != PLAYER_CLASS_SHOOTER ) + if ( uClassType != PLAYER_CLASS_ARCHER ) v85 = uColorWhite; pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[16]); pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, 417, v85, pClassNames[16], 0, 0, 0); @@ -8980,26 +8998,12 @@ v5 = v13; if ( v4 > v5 ) v5 = v4; - sprintf( - pTmpBuf2, - "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s", - pSpellStats->pInfos[v1].pDescription, - pGlobalTXT_LocalizationStrings[431], // "Normal" - v5 + 3, - v5 + 10, - pSpellStats->pInfos[v1].pBasicSkillDesc, - pGlobalTXT_LocalizationStrings[433], // "Expert" - v5 + 3, - v5 + 10, - pSpellStats->pInfos[v1].pExpertSkillDesc, - pGlobalTXT_LocalizationStrings[432], // "Master" - v5 + 3, - v5 + 10, - pSpellStats->pInfos[v1].pMasterSkillDesc, - pGlobalTXT_LocalizationStrings[96], // "Grand" - v5 + 3, - v5 + 10, - pSpellStats->pInfos[v1].pGrandmasterSkillDesc); + sprintf(pTmpBuf2, "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s", + pSpellStats->pInfos[v1].pDescription, pGlobalTXT_LocalizationStrings[431], // "Normal" + v5 + 3, v5 + 10, pSpellStats->pInfos[v1].pBasicSkillDesc, pGlobalTXT_LocalizationStrings[433], // "Expert" + v5 + 3, v5 + 10, pSpellStats->pInfos[v1].pExpertSkillDesc, pGlobalTXT_LocalizationStrings[432], // "Master" + v5 + 3, v5 + 10, pSpellStats->pInfos[v1].pMasterSkillDesc, pGlobalTXT_LocalizationStrings[96], // "Grand" + v5 + 3, v5 + 10, pSpellStats->pInfos[v1].pGrandmasterSkillDesc); v6 = pFontSmallnum->CalcTextHeight(pTmpBuf2, &a1, 0, 0); a1.uFrameHeight += v6; if ( (signed int)a1.uFrameHeight < 150 ) @@ -9018,13 +9022,7 @@ a1.uFrameWidth = 108; a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v11 / 4 + 12], 3u); sprintf(pTmpBuf, "%s\n%d", pGlobalTXT_LocalizationStrings[522], *(&pSpellDatas[0].uNormalLevelMana + 10 * v1)); - return a1.DrawTitleText( - pFontComic, - 0xCu, - a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, - 0, - pTmpBuf, - 3u); + return a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf, 3); } @@ -9404,7 +9402,7 @@ char *v17; // ecx@63 char *v18; // eax@65 const char *v19; // ecx@68 - unsigned int v20; // eax@69 + //unsigned int v20; // eax@69 unsigned int v21; // ecx@70 char *v22; // [sp-Ch] [bp-18h]@73 int v23; // [sp-8h] [bp-14h]@49 @@ -9425,9 +9423,9 @@ if ( a1 == 13 ) { ptr_F8B1E8 = (char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession); - ptr_F8B1E8 = sub_495461((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0); + ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0); sub_4B40E6(); - byte_F8B1EC = 0; + dialogue_show_profession_details = false; goto _return; } switch ( a1 ) @@ -9494,13 +9492,13 @@ if ( a1 == 77 ) { v16 = v2->uProfession; - if ( byte_F8B1EC ) - v17 = (char *)*(&pNPCStats->field_13A64 + 5 * v16); + if (dialogue_show_profession_details) + v17 = pNPCStats->pProfessions[v2->uProfession - 1].pJoinText; else - v17 = (char *)*(&pNPCStats->field_13A5C + 5 * v16); + v17 = pNPCStats->pProfessions[v2->uProfession - 1].pBenefits; ptr_F8B1E8 = v17; - v18 = sub_495461(v17, uActiveCharacter - 1, 0, 0, 0, 0); - byte_F8B1EC ^= 1u; + v18 = BuilDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); + dialogue_show_profession_details = ~dialogue_show_profession_details; ptr_F8B1E8 = v18; } else @@ -9509,7 +9507,7 @@ { if ( dword_F8B1A8 ) { - Party::TakeGold(dword_F8B1B4); + Party::TakeGold(gold_transaction_amount); if ( uActiveCharacter ) { v12 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_something_todo_with_awards]; @@ -9544,7 +9542,7 @@ { if ( a1 == 82 && dword_F8B1A8 ) { - Party::TakeGold(dword_F8B1B4); + Party::TakeGold(gold_transaction_amount); v4 = pParty->pPlayers; do { @@ -9616,19 +9614,19 @@ ShowStatusBarString(v19, 2u); goto _return; } - v20 = v2->uProfession; - if ( v20 != 51 ) - { - v21 = *(&pNPCStats->field_13A58 + 5 * v20); + //v20 = v2->uProfession; + if ( v2->uProfession != 51 ) + { + v21 = pNPCStats->pProfessions[v2->uProfession - 1].uHirePrice; if ( pParty->uNumGold < v21 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); - byte_F8B1EC = 0; + dialogue_show_profession_details = false; uDialogueType = 13; - ptr_F8B1E8 = (char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession); - ptr_F8B1E8 = sub_495461((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0); + ptr_F8B1E8 = pNPCStats->pProfessions[v2->uProfession - 1].pJoinText; + ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0); if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_38, 0); + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); v19 = pGlobalTXT_LocalizationStrings[155]; goto LABEL_77; } @@ -9723,21 +9721,21 @@ { if ( v2 == 1 ) { - dword_F8B1B4 = 5000; + gold_transaction_amount = 5000; dword_F8B1B0 = 3; } else { if ( v2 == 2 ) { - dword_F8B1B4 = 8000; + gold_transaction_amount = 8000; dword_F8B1B0 = 4; } } } else { - dword_F8B1B4 = 2000; + gold_transaction_amount = 2000; dword_F8B1B0 = 2; } v5 = v1->classType; @@ -9826,7 +9824,7 @@ case 16: case 17: case 18: - dword_F8B1B4 = 4000; + gold_transaction_amount = 4000; goto LABEL_42; case 19: v19 = 114; @@ -9841,7 +9839,7 @@ v20 = v1->GetBaseWillpower(); goto LABEL_61; case 24: - dword_F8B1B4 = 2500; + gold_transaction_amount = 2500; v20 = v1->GetBaseEndurance(); goto LABEL_61; case 36: @@ -9858,13 +9856,13 @@ case 32: case 34: case 35: - dword_F8B1B4 = 2500; + gold_transaction_amount = 2500; goto LABEL_42; case 8: case 9: case 10: case 11: - dword_F8B1B4 = 3000; + gold_transaction_amount = 3000; goto LABEL_42; case 7: goto LABEL_67; @@ -9920,19 +9918,19 @@ case 32: case 34: case 35: - dword_F8B1B4 = 6000; + gold_transaction_amount = 6000; goto LABEL_42; case 8: case 9: case 10: case 11: - dword_F8B1B4 = 7000; + gold_transaction_amount = 7000; goto LABEL_42; case 7: break; } LABEL_67: - dword_F8B1B4 = 0; + gold_transaction_amount = 0; goto LABEL_41; } } @@ -9948,19 +9946,19 @@ && (dword_F8B1AC_something_todo_with_awards <= 33 || dword_F8B1AC_something_todo_with_awards > 35) ) { LABEL_41: - if ( !dword_F8B1B4 ) + if ( !gold_transaction_amount ) goto LABEL_79; goto LABEL_42; } LABEL_87: - dword_F8B1B4 = 500; + gold_transaction_amount = 500; goto LABEL_41; } if ( dword_F8B1AC_something_todo_with_awards >= 23 ) goto LABEL_87; if ( dword_F8B1AC_something_todo_with_awards == 7 ) { - dword_F8B1B4 = 0; + gold_transaction_amount = 0; goto LABEL_79; } if ( dword_F8B1AC_something_todo_with_awards <= 7 ) @@ -9971,29 +9969,29 @@ goto LABEL_41; goto LABEL_87; } - dword_F8B1B4 = 1000; + gold_transaction_amount = 1000; LABEL_42: - if ( dword_F8B1B4 > pParty->uNumGold ) + if ( gold_transaction_amount > pParty->uNumGold ) return (char *)pNPCTopics[124].pText; LABEL_79: dword_F8B1A8 = 1; if ( v34 == 2 ) { - v27 = dword_F8B1B4; + v27 = gold_transaction_amount; v24 = pSkillNames[v17]; v21 = pGlobalTXT_LocalizationStrings[433]; goto LABEL_90; } if ( v34 == 3 ) { - v27 = dword_F8B1B4; + v27 = gold_transaction_amount; v24 = pSkillNames[v17]; v21 = pGlobalTXT_LocalizationStrings[432]; goto LABEL_90; } if ( v34 == 4 ) { - v27 = dword_F8B1B4; + v27 = gold_transaction_amount; v24 = pSkillNames[v17]; v21 = pGlobalTXT_LocalizationStrings[225]; LABEL_90: @@ -10018,7 +10016,7 @@ v3 = a1 + 50; v4 = pPlayers[uActiveCharacter]; dword_F8B1AC_something_todo_with_awards = v3; - dword_F8B1B4 = dword_4F08EC[v1]; + gold_transaction_amount = dword_4F08EC[v1]; if ( v4->CanAct() ) { if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)v2->field_152, dword_F8B1AC_something_todo_with_awards) ) @@ -10027,7 +10025,7 @@ } else { - if ( dword_F8B1B4 <= pParty->uNumGold ) + if ( gold_transaction_amount <= pParty->uNumGold ) { dword_F8B1A8 = 1; return pNPCTopics[v1 + 110].pText; @@ -10138,7 +10136,7 @@ v7 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); v8 = v6->uProfession; if ( v8 ) - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]); else strcpy(pTmpBuf, v6->pName); a1.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v7, pTmpBuf, 3u); @@ -12269,7 +12267,7 @@ v4 = (char *)&_this->pInventoryItems[result-1]; if ( v4[20] & 1 ) { - v5 = sub_495461("%24", uActiveCharacter - 1, (ItemGen *)v4, (char *)ptr_507BC0->ptr_1C, 4, 0); + v5 = BuilDialogueString("%24", uActiveCharacter - 1, (ItemGen *)v4, (char *)ptr_507BC0->ptr_1C, 4, 0); v97 = 3; v95 = v5; v92 = white; @@ -12313,7 +12311,7 @@ v9 = uPlayerID; v10 = (char *)pMerchantsSellPhrases[v13]; LABEL_35: - v30 = sub_495461(v10, v9, v90, (char *)v93, v94, v96); + v30 = BuilDialogueString(v10, v9, v90, (char *)v93, v94, v96); v97 = 3; v95 = v30; v92 = white; @@ -12538,17 +12536,17 @@ } //----- (004BC49B) -------------------------------------------------------- -void __thiscall sub_4BC49B(unsigned int _this) -{ - unsigned int v1; // esi@1 +void OnSelectDialogueOption(DIALOGUE_TYPE newDialogueType) +{ + //unsigned int v1; // esi@1 NPCData *v2; // ebp@1 - unsigned int v3; // eax@1 + //unsigned int v3; // eax@1 int v4; // ecx@10 signed int v5; // edi@14 char *v6; // esi@15 const char *v7; // ecx@22 signed int v8; // edi@37 - unsigned int v9; // eax@56 + //unsigned int v9; // eax@56 unsigned int v10; // ecx@57 void *v11; // [sp-Ch] [bp-1Ch]@46 int v12; // [sp-8h] [bp-18h]@46 @@ -12556,36 +12554,36 @@ size_t v14; // [sp-4h] [bp-14h]@46 const char *v15; // [sp-4h] [bp-14h]@60 - v1 = _this; + //v1 = _this; v2 = GetNPCData(uDialogue_SpeakingActorNPC_ID); - v3 = v1; - uDialogueType = v1; + //v3 = v1; + uDialogueType = newDialogueType; if ( !v2->uFlags ) { v2->uFlags = 1; - v3 = uDialogueType; - } - if ( (signed int)v3 > 22 ) - { - if ( v3 == 23 ) + //v3 = uDialogueType; + } + if ( (signed int)newDialogueType > 22 ) + { + if ( newDialogueType == DIALOGUE_23 ) { v4 = v2->evte; goto LABEL_74; } - if ( v3 == 24 ) + if (newDialogueType == DIALOGUE_24) { v4 = v2->evtf; goto LABEL_74; } - if ( v3 != 76 ) - { - if ( v3 == 77 ) - { - byte_F8B1EC ^= 1u; + if (newDialogueType != DIALOGUE_76) + { + if (newDialogueType == DIALOGUE_PROFESSION_DETAILS) + { + dialogue_show_profession_details = ~dialogue_show_profession_details; } else { - if ( (signed int)v3 > 84 && (signed int)v3 <= 88 ) + if ( (signed int)newDialogueType > 84 && (signed int)newDialogueType <= 88 ) { ArenaFight(); return; @@ -12593,7 +12591,7 @@ } goto LABEL_87; } - if ( v2->uFlags & 0x80 ) + if (v2->Hired()) { v8 = 0; if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) @@ -12646,17 +12644,17 @@ ShowStatusBarString(v7, 2u); goto LABEL_87; } - v9 = v2->uProfession; - if ( v9 != 51 ) - { - v10 = *(&pNPCStats->field_13A58 + 5 * v9); + //v9 = v2->uProfession; + if ( v2->uProfession != 51 ) + { + v10 = pNPCStats->pProfessions[v2->uProfession - 1].uHirePrice; if ( pParty->uNumGold < v10 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold" - byte_F8B1EC = 0; + dialogue_show_profession_details = false; uDialogueType = 13; if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_38, 0); + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); v7 = pGlobalTXT_LocalizationStrings[155]; goto LABEL_64; } @@ -12691,12 +12689,12 @@ pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0); goto LABEL_87; } - if ( v3 == 22 ) + if (newDialogueType == DIALOGUE_22) { v4 = v2->evtd; goto LABEL_74; } - if ( v3 == 9 ) + if (newDialogueType == DIALOGUE_9) { if ( !sub_4BB756(v2->uProfession) ) { @@ -12714,12 +12712,12 @@ v7 = pGlobalTXT_LocalizationStrings[140]; goto LABEL_64; } - if ( v3 == 13 ) - { - if ( !(v2->uFlags & 0x80) ) + if (newDialogueType == DIALOGUE_13) + { + if (!v2->Hired()) { sub_4B3E1E(); - byte_F8B1EC = 0; + dialogue_show_profession_details = false; goto LABEL_87; } v5 = 0; @@ -12739,17 +12737,17 @@ } goto LABEL_44; } - if ( v3 == 19 ) + if (newDialogueType == DIALOGUE_19) { v4 = v2->bDrawSomeAnim; goto LABEL_74; } - if ( v3 == 20 ) + if (newDialogueType == DIALOGUE_20) { v4 = v2->_anim_current_time; goto LABEL_74; } - if ( v3 == 21 ) + if (newDialogueType == DIALOGUE_21) { v4 = v2->_anim_end_time; LABEL_74: @@ -12778,7 +12776,7 @@ } else { - dword_F8B1D8 = v3; + dword_F8B1D8 = newDialogueType; sub_4B3EF0(v4 - 400); } } @@ -13062,7 +13060,7 @@ 3, v16, 2); - v18 = sub_495461((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); + v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); v44 = 3; v43 = v18; v42 = v56; @@ -14053,9 +14051,7 @@ if ( v61 != (Player *)v2 ) { memcpy(&v32, (char *)&pMapStats + 68 * (unsigned __int8)byte_4F09B0[v26 * 4], 0x44u); - sprintf( - pTmpBuf, - pGlobalTXT_LocalizationStrings[404], + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[404], v66, *(int *)&v32, v33,
--- a/mm7_5.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/mm7_5.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -365,7 +365,7 @@ auto npc = pNPCStats->pNewNPCData + i; //do //{ - if (npc->uFlags & 0x80 && + if (npc->Hired() && (!pParty->pHirelings[0].pName || strcmp(npc->pName, pParty->pHirelings[0].pName)) && (!pParty->pHirelings[1].pName || strcmp(npc->pName, pParty->pHirelings[1].pName)) ) { @@ -398,8 +398,8 @@ case UIMSG_195: sub_4BCACC_bounties(uMessageParam); continue; - case UIMSG_88: - sub_4BC49B(uMessageParam); + case UIMSG_SelectDialogueOption: + OnSelectDialogueOption((DIALOGUE_TYPE)uMessageParam); continue; case UIMSG_19A: _4B4224_UpdateNPCTopics(uMessageParam); @@ -2729,7 +2729,8 @@ Actor::StealFrom(uMessageParam); } continue; - case 0x17: + + case UIMSG_Attack: if ( !uActiveCharacter ) //goto LABEL_90; { @@ -2901,13 +2902,13 @@ if ( !v90 ) v90 = rand() % (signed int)pMapStats->uNumMaps + 1; pMapInfo = &pMapStats->pInfos[v90]; - if ( rand() % 100 + 1 <= pMapInfo->field_30 ) + if ( rand() % 100 + 1 <= pMapInfo->Encounter_percent ) { v91 = rand() % 100; - v92 = pMapInfo->field_31; + v92 = pMapInfo->EncM1percent; v93 = v91 + 1; if ( v93 > v92 ) - pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->field_32) + 2); + pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2); else pNPCData4 = (NPCData *)v0; if ( !sub_45063B(pMapInfo, (int)pNPCData4) ) @@ -3479,7 +3480,7 @@ v158 = pParty->uNumGold + pParty->uNumGoldInBank; v146 = pGlobalTXT_LocalizationStrings[489];// "You have %d total gold, %d in the Bank"" //goto _sprintex_draw_status_and_continue; - sprintf(pTmpBuf, v146, v158, v174); + sprintfex(pTmpBuf, v146, v158, v174); sub_41C0B8_set_status_string(pTmpBuf); continue; case UIMSG_ShowStatus_DateTime: @@ -3505,7 +3506,7 @@ goto _sprintex_2args_draw_status_and_continue; case UIMSG_ShowStatus_Player: pPlayer5 = pPlayers[uMessageParam]; - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], pPlayer5->pName, pClassNames[pPlayer5->classType]);// "%s the %s" + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], pPlayer5->pName, pClassNames[pPlayer5->classType]);// "%s the %s" strcat(pTmpBuf, ": "); v107 = pPlayer5->GetMajorConditionIdx(); strcat(pTmpBuf, aCharacterConditionNames[v107]); @@ -8586,7 +8587,7 @@ unsigned int v1; // ebx@1 Player *pPlayer; // edi@1 int v3; // ecx@1 - int v4; // edi@3 + int *v4; // edi@3 unsigned int v5; // ebx@3 int v6; // eax@3 LODFile_IconsBitmaps *v7; // ecx@7 @@ -8628,7 +8629,7 @@ int v43; // [sp+10h] [bp-20h]@47 unsigned int a3; // [sp+14h] [bp-1Ch]@3 unsigned int a2; // [sp+18h] [bp-18h]@3 - int v46; // [sp+1Ch] [bp-14h]@1 + unsigned int *v46; // [sp+1Ch] [bp-14h]@1 Player *v47; // [sp+20h] [bp-10h]@1 int v48; // [sp+24h] [bp-Ch]@1 int v49; // [sp+24h] [bp-Ch]@26 @@ -8643,17 +8644,17 @@ pRenderer->DrawTextureIndexed(pCharacterScreen_DetalizBtn->uX, pCharacterScreen_DetalizBtn->uY, (Texture *)(uTextureID_5118C8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5118C8] : 0)); v3 = 0; - v46 = (int)&pPlayer->pEquipment.field_28; + v46 = &pPlayer->pEquipment.field_28; v48 = 0; do { - if ( !*(int *)v46 ) + if ( !*v46 ) goto LABEL_24; - v39 = *(int *)v46; - v4 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v46 + 5]; + v39 = *v46; + v4 = (int *)&pPlayer->pInventoryItems[*v46-1].uItemID; a3 = pPaperdollRingsY[v3]; a2 = pPaperdollRingsX[v3]; - v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v4].pIconName, TEXTURE_16BIT_PALETTE); + v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*v4].pIconName, TEXTURE_16BIT_PALETTE); v6 = *(int *)(v4 + 20); if ( *(int *)(v4 + 20) & 0xF0 ) { @@ -13570,7 +13571,7 @@ dword_506548 = 0; dword_506520 = 0; v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6); - v8 = sub_495461( + v8 = BuilDialogueString( pStorylineText->StoreLine[v6].pText, uActiveCharacter - 1, 0, @@ -16044,7 +16045,7 @@ while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );*/ for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i) { - if (pNPCStats->pNewNPCData[i].uFlags & 0x80) + if (pNPCStats->pNewNPCData[i].Hired()) { if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName)) { @@ -16096,7 +16097,7 @@ { v10 = v6->pName; v11 = pTmpBuf; - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]); } else { @@ -16108,7 +16109,7 @@ a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u); a1.uFrameWidth -= 24; a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; - v14 = sub_495461((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); + v14 = BuilDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0); } } @@ -16516,8 +16517,7 @@ y = pY; x = pX; } - if ( pCurrentScreen - || !dword_507B98_ctrl_pressed ) + if ( pCurrentScreen != SCREEN_GAME || !dword_507B98_ctrl_pressed ) goto LABEL_30; v4 = GetCurrentMenuID(); x = pX; @@ -16564,7 +16564,7 @@ if ( x >= (signed int)i->uX && x <= (signed int)i->uZ && y >= (signed int)i->uY && y <= (signed int)i->uW ) { LABEL_50: - i->field_2C = 1; + i->field_2C_is_pushed = 1; v10 = pMessageQueue_50CBD0->uNumMessages; if ( pMessageQueue_50CBD0->uNumMessages ) { @@ -16764,76 +16764,55 @@ } //----- (00417AD4) -------------------------------------------------------- -unsigned int __fastcall sub_417AD4(unsigned int uPlayerClass, enum PLAYER_SKILL_TYPE uPlayerSkillType, signed int a3) -{ - enum PLAYER_SKILL_TYPE v3; // ebx@1 - signed int v4; // edi@1 - unsigned int v5; // ecx@1 - int v6; // edx@1 - int v7; // eax@7 +unsigned int __fastcall GetSkillColor(unsigned int uPlayerClass, enum PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level) +{ int v8; // eax@10 - unsigned __int8 v9; // sf@10 - unsigned __int8 v10; // of@10 - int v11; // eax@11 int v12; // eax@14 unsigned int yellow; // [sp+Ch] [bp-Ch]@1 unsigned int red; // [sp+10h] [bp-8h]@1 unsigned int white; // [sp+14h] [bp-4h]@1 - v3 = uPlayerSkillType; - v4 = uPlayerClass; white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); red = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0); yellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0); - v5 = 0; - v6 = v4 % 4; - if ( !(v4 % 4) ) - { - v11 = 37 * v4 + v3; - if ( byte_4ED970_skill_learn_ability_by_class_table[0][v11] >= a3 ) - goto LABEL_8; - if ( byte_4ED970_skill_learn_ability_by_class_table[1][v11] < a3 - && byte_4ED970_skill_learn_ability_by_class_table[2][v11] < a3 ) - { - v12 = byte_4ED970_skill_learn_ability_by_class_table[3][v11]; - v10 = __OFSUB__(v12, a3); - v9 = v12 - a3 < 0; -LABEL_15: - v5 = red; - if ( v9 ^ v10 ) - return v5; + if ( !(uPlayerClass % 4) ) + { + if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level ) + return white; + if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level + && byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level ) + { + v12 = byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType]; + if ( v12 < skill_level ) + return red; } return yellow; } - if ( v6 == 1 ) - { - v7 = 37 * v4 + v3; - if ( byte_4ED970_skill_learn_ability_by_class_table[0][v7] >= a3 ) - goto LABEL_8; - if ( byte_4ED970_skill_learn_ability_by_class_table[1][v7] < a3 ) - { - v8 = byte_4ED970_skill_learn_ability_by_class_table[2][v7]; - v10 = __OFSUB__(v8, a3); - v9 = v8 - a3 < 0; - goto LABEL_15; + if ( (uPlayerClass % 4) == 1 ) + { + if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level ) + return white; + if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level ) + { + v8 = byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType]; + if ( v8 < skill_level) + return red; } return yellow; } - if ( v6 > 1 && v6 <= 3 ) - { - if ( byte_4ED970_skill_learn_ability_by_class_table[v4][v3] < a3 ) + if ( (uPlayerClass % 4) == 2 || (uPlayerClass % 4) == 3 ) + { + if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level ) return red; -LABEL_8: - v5 = white; - } - return v5; + } + return white; } //----- (00417BB5) -------------------------------------------------------- const char *__fastcall CharacterUI_GetSkillDescText(unsigned int uPlayerID, enum PLAYER_SKILL_TYPE uPlayerSkillType) { - enum PLAYER_SKILL_TYPE v2; // esi@1 - unsigned int v3; // ebx@1 + //enum PLAYER_SKILL_TYPE v2; // esi@1 + //unsigned int v3; // ebx@1 int v4; // edi@1 int v5; // eax@1 Player *pPlayer; // ebx@7 @@ -16865,11 +16844,11 @@ unsigned __int16 *v33; // [sp+534h] [bp-10h]@1 int v34; // [sp+538h] [bp-Ch]@1 unsigned __int16 *v35; // [sp+53Ch] [bp-8h]@1 - enum PLAYER_SKILL_TYPE v36; // [sp+540h] [bp-4h]@1 - - v2 = uPlayerSkillType; - v3 = uPlayerID; - v36 = uPlayerSkillType; + //enum PLAYER_SKILL_TYPE v36; // [sp+540h] [bp-4h]@1 + + //v2 = uPlayerSkillType; + //v3 = uPlayerID; + //v36 = uPlayerSkillType; v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);// Normal v34 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);// Expert v33 = (unsigned __int16 *)pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);// Master @@ -16881,73 +16860,58 @@ v35 = v33; if ( v5 > (signed int)v35 ) v35 = (unsigned __int16 *)v5; - pPlayer = &pParty->pPlayers[v3]; - v33 = &pPlayer->pActiveSkills[v2]; - v7 = pPlayer->GetActualSkillLevel(v2); - v8 = LOBYTE(pPlayer->pActiveSkills[v2]); + pPlayer = &pParty->pPlayers[uPlayerID]; + //v33 = &pPlayer->pActiveSkills[uPlayerSkillType]; + v7 = pPlayer->GetActualSkillLevel(uPlayerSkillType); + v8 = pPlayer->pActiveSkills[uPlayerSkillType]; a2[0] = 0; Source[0] = 0; if ( (v8 & 0x3F) == (v7 & 0x3F) ) { strcpy(a2, "%s\n\n"); - v24 = sub_417AD4(pPlayer->classType, v2, 1); + v24 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 1); sprintf(Source, format_4E2DC8, v24); strcat(a2, Source); strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); - v25 = sub_417AD4(pPlayer->classType, v36, 2); + v25 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 2); sprintf(Source, format_4E2DC8, v25); strcat(a2, Source); strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); - v26 = sub_417AD4(pPlayer->classType, v36, 3); + v26 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 3); sprintf(Source, format_4E2DC8, v26); strcat(a2, Source); strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); v27 = pPlayer->classType; - v28 = v36; - v29 = sub_417AD4(v27, v36, 4); + v28 = uPlayerSkillType; + v29 = GetSkillColor(v27, uPlayerSkillType, 4); sprintf(Source, format_4E2DC8, v29); strcat(a2, Source); strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); v23 = static_sub_417BB5_out_string; - sprintf( - static_sub_417BB5_out_string, - a2, - pSkillDesc[v28], - pGlobalTXT_LocalizationStrings[431], // Normal - (char *)v35 + 3, - v35 + 5, - pNormalSkillDesc[v28], - pGlobalTXT_LocalizationStrings[433], // Expert - (char *)v35 + 3, - v35 + 5, - pExpertSkillDesc[v28], - pGlobalTXT_LocalizationStrings[432], // Master - (char *)v35 + 3, - v35 + 5, - pMasterSkillDesc[v28], - pGlobalTXT_LocalizationStrings[96], // Grand - (char *)v35 + 3, - v35 + 5, - pGrandSkillDesc[v28]); + sprintf(static_sub_417BB5_out_string, a2, pSkillDesc[v28], pGlobalTXT_LocalizationStrings[431], // Normal + (char *)v35 + 3, v35 + 5, pNormalSkillDesc[v28], pGlobalTXT_LocalizationStrings[433], // Expert + (char *)v35 + 3, v35 + 5, pExpertSkillDesc[v28], pGlobalTXT_LocalizationStrings[432], // Master + (char *)v35 + 3, v35 + 5, pMasterSkillDesc[v28], pGlobalTXT_LocalizationStrings[96], // Grand + (char *)v35 + 3, v35 + 5, pGrandSkillDesc[v28]); } else { strcpy(a2, "%s\n\n"); - v9 = sub_417AD4(pPlayer->classType, v2, 1); + v9 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 1); sprintf(Source, format_4E2DC8, v9); strcat(a2, Source); strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); - v10 = sub_417AD4(pPlayer->classType, v36, 2); + v10 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 2); sprintf(Source, format_4E2DC8, v10); strcat(a2, Source); strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); - v11 = sub_417AD4(pPlayer->classType, v36, 3); + v11 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 3); sprintf(Source, format_4E2DC8, v11); strcat(a2, Source); strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); - v12 = v36; - v13 = sub_417AD4(pPlayer->classType, v36, 4); + v12 = uPlayerSkillType; + v13 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 4); sprintf(Source, format_4E2DC8, v13); strcat(a2, Source); strcat(a2, "%s\t%03d:\t%03d%s\t000\n\n"); @@ -16959,7 +16923,7 @@ v16 = (int)(v35 + 5); v15 = (PLAYER_SKILL_TYPE)((int)v15 * 4); v34 = (int)((char *)v35 + 3); - v17 = pPlayer->GetActualSkillLevel(v36); + v17 = pPlayer->GetActualSkillLevel(uPlayerSkillType); v18 = *(int *)((char *)pGrandSkillDesc + v15); v19 = *(int *)((char *)pMasterSkillDesc + v15); v20 = *(int *)((char *)pExpertSkillDesc + v15); @@ -17400,7 +17364,7 @@ int v137; // [sp+1Ch] [bp-4h]@27 int v138; // [sp+1Ch] [bp-4h]@33 - pPlayer = &pParty->pPlayers[uPlayerID-1];//(Player *)&stru_AA1058[3].pSounds[6972 * uPlayerID + 40552]; + pPlayer = &pParty->pPlayers[uPlayerID-1]; v2 = pIcons_LOD->LoadTexture("fr_stats", TEXTURE_16BIT_PALETTE); pRenderer->DrawTextureIndexed(8, 8, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0)); v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); @@ -17857,7 +17821,7 @@ } v12 = 0; a5 = pGUIWindow_CurrentMenu->uNumControls; - v18 = &pParty->pPlayers[v0-1]; //&stru_AA1058[3].pSounds[6972 * v0 + 40552]; + v18 = &pParty->pPlayers[v0-1]; v2 = pFontLucida; v14 = pWeaponSkills; v3 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
--- a/mm7_6.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/mm7_6.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -3323,7 +3323,7 @@ v666 = 1; else v666 = v1; - a2 = stru_50C198.FindClosesActor(5120, 1, v666); + a2 = stru_50C198.FindClosestActor(5120, 1, v666); v6 = pMouse->uPointingObjectID; if ( pMouse->uPointingObjectID != v1 && (v6 & 7) == OBJECT_Actor && pActors[v6 >> 3].CanAct() ) { @@ -7832,16 +7832,16 @@ } //----- (0042ECB5) -------------------------------------------------------- -bool __cdecl _42ECB5_PlayerAttacksActor() +void _42ECB5_PlayerAttacksActor() { - unsigned int v0; // ebx@1 - Player *v1; // esi@1 - bool result; // eax@1 + //unsigned int v0; // ebx@1 + //Player *v1; // esi@1 + //bool result; // eax@1 int v3; // edi@2 - unsigned int v4; // eax@7 + //unsigned int v4; // eax@7 char *v5; // eax@8 - int v6; // ecx@9 - signed int v7; // eax@16 + //int v6; // ecx@9 + //signed int v7; // eax@16 Actor *v8; // edi@20 unsigned int v9; // ecx@21 char *v10; // eax@26 @@ -7860,74 +7860,88 @@ int v23; // [sp-4h] [bp-40h]@44 SoundID v24; // [sp-4h] [bp-40h]@58 Vec3_int_ a3; // [sp+Ch] [bp-30h]@19 - unsigned int a2; // [sp+18h] [bp-24h]@20 - unsigned int v27; // [sp+1Ch] [bp-20h]@1 + //unsigned int a2; // [sp+18h] [bp-24h]@20 + //unsigned int v27; // [sp+1Ch] [bp-20h]@1 int v28; // [sp+20h] [bp-1Ch]@9 - unsigned int *v28b; + //unsigned int *v28b; int v29; // [sp+24h] [bp-18h]@16 int v30; // [sp+28h] [bp-14h]@16 - int v31; // [sp+2Ch] [bp-10h]@4 + //int v31; // [sp+2Ch] [bp-10h]@4 int v32; // [sp+30h] [bp-Ch]@7 - int v33; // [sp+34h] [bp-8h]@7 + //int v33; // [sp+34h] [bp-8h]@7 int v34; // [sp+38h] [bp-4h]@17 - v0 = uActiveCharacter; - v27 = 6972 * uActiveCharacter; - v1 = &pParty->pPlayers[uActiveCharacter-1];//(Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552]; - result = pParty->pPlayers[uActiveCharacter-1].CanAct();//((Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552])->CanAct(); - if ( result ) + //v0 = uActiveCharacter; + //v27 = 6972 * uActiveCharacter; + //v1 = &pParty->pPlayers[uActiveCharacter-1]; + //result = pParty->pPlayers[uActiveCharacter-1].CanAct(); + auto player = &pParty->pPlayers[uActiveCharacter - 1]; + if (!player->CanAct()) + return; + + pStru277->_427D48(uActiveCharacter); + v3 = 0; + if (pParty->Invisible()) + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); + + //v31 = player->pEquipment.uBow; + int bow_idx = player->pEquipment.uBow; + if (bow_idx && player->pInventoryItems[bow_idx - 1].Broken()) + bow_idx = 0; + + v32 = 0; + //v33 = 0; + //v4 = v1->pEquipment.uMainHand; + int laser_weapon_item_id = 0; + + int main_hand_idx = player->pEquipment.uMainHand; + if (main_hand_idx) { - pStru277->_427D48(v0); - v3 = 0; - if ( (signed __int64)pParty->pPartyBuffs[11].uExpireTime > 0 ) - pParty->pPartyBuffs[11].Reset(); - v31 = v1->pEquipment.uBow; - if ( v31 && v1->field_1F5[36 * v31 + 15] & 2 ) - v31 = 0; - v4 = v1->pEquipment.uMainHand; - v32 = 0; - v33 = 0; - if ( v4 ) - { + auto item = &player->pInventoryItems[main_hand_idx - 1]; //v5 = (char *)v1 + 36 * v4; - if ( !(v1->pInventoryItems[v4].field_1A & 2) )//v5[516] & 2) ) + if (!item->Broken()) + { + //v28b = &v1->pInventoryItems[v4].uItemID; + //v6 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124); + if (pItemsTable->pItems[item->uItemID].uEquipType == EQUIP_C) { - v28b = &v1->pInventoryItems[v4].uItemID; - v6 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124); - if ( pItemsTable->pItems[v6].uEquipType == 12 ) - { - if ( v1->pInventoryItems[v4]._bonus_type <= 0 ) - { - *v28b = 0; - v1->pEquipment.uMainHand = 0; - } - else - { - v32 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124); - } - } + if (item->_bonus_type <= 0) + player->pEquipment.uMainHand = 0; else - { - if ( v6 == 64 || v6 == 65 ) - v33 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124); - } + v32 = item->uItemID;//*((int *)v5 + 124); } + else if (item->uItemID == ITEM_BLASTER || item->uItemID == ITEM_LASER_RIFLE) + laser_weapon_item_id = item->uItemID;//*((int *)v5 + 124); } + } + v30 = 0; v29 = 0; v28 = 0; - v7 = pMouse->uPointingObjectID; - if ( (pMouse->uPointingObjectID & 7) != OBJECT_Actor || (v34 = pMouse->uPointingObjectID, !pActors[v7 >> 3].CanAct()) ) - v34 = stru_50C198.FindClosesActor(5120, 0, 0); + //v7 = pMouse->uPointingObjectID; + + int target_pid = pMouse->uPointingObjectID; + int target_type = target_pid & 7, + target_id = target_pid >> 3; + if (target_type != OBJECT_Actor || !pActors[target_id].CanAct()) + { + target_pid = stru_50C198.FindClosestActor(5120, 0, 0); + target_type = target_pid & 7; + target_id = target_pid >> 3; + } + + a3.z = 0; a3.y = 0; a3.x = 0; - if ( (v34 & 7) == OBJECT_Actor) - { - a2 = v34 >> 3; - v8 = &pActors[v34 >> 3]; - v34 = sub_452A9E((v8->vPosition.x - pParty->vPosition.x) * (v8->vPosition.x - pParty->vPosition.x) + (v8->vPosition.y - pParty->vPosition.y) * (v8->vPosition.y - pParty->vPosition.y) + (v8->vPosition.z - pParty->vPosition.z) * (v8->vPosition.z - pParty->vPosition.z)) - - v8->uActorRadius; + if (target_type == OBJECT_Actor) + { + //a2 = target_id; + v8 = &pActors[target_id]; + int distance_x = v8->vPosition.x - pParty->vPosition.x, + distance_y = v8->vPosition.y - pParty->vPosition.y, + distance_z = v8->vPosition.z - pParty->vPosition.z; + v34 = sub_452A9E(distance_x * distance_x + distance_y * distance_y + distance_z * distance_z) - v8->uActorRadius; if ( v34 >= 0 ) { v9 = 0; @@ -7937,15 +7951,15 @@ v9 = 0; v34 = 0; } - if ( v33 != v9 ) + if ( laser_weapon_item_id != v9 ) { v28 = 1; - v22 = v0 + 8; + v22 = uActiveCharacter + 8; v20 = v9; v18 = v9; v16 = 102; LABEL_34: - _42777D_CastSpell_UseWand_ShootArrow(v16, v0 - 1, v18, v20, v22); + _42777D_CastSpell_UseWand_ShootArrow(v16, uActiveCharacter - 1, v18, v20, v22); LABEL_28: v3 = 0; goto LABEL_29; @@ -7955,18 +7969,18 @@ v29 = 1; _42777D_CastSpell_UseWand_ShootArrow( *((int *)&pSpellDatas[66].field_8 - + *(int *)(&stru_AA1058[3].pSounds[36 * *(int *)&pParty->pArtifactsFound[v27 + 22] + 41048] + v27)), - v0 - 1, + + *(int *)(&stru_AA1058[3].pSounds[36 * *(int *)&pParty->pArtifactsFound[6972 * uActiveCharacter + 22] + 41048] + 6972 * uActiveCharacter)), + uActiveCharacter - 1, 8u, v9, - v0 + 8); - v10 = &v1->field_1F5[36 * v1->pEquipment.uMainHand + 11]; + uActiveCharacter + 8); + v10 = &player->field_1F5[36 * player->pEquipment.uMainHand + 11]; --*(int *)v10; - v11 = (char *)v1 + 36 * v1->pEquipment.uMainHand; + v11 = (char *)player + 36 * player->pEquipment.uMainHand; if ( *((int *)v11 + 128) <= 0 ) { *((int *)v11 + 124) = 0; - v1->pEquipment.uMainHand = 0; + player->pEquipment.uMainHand = 0; } goto LABEL_28; } @@ -7976,19 +7990,19 @@ a3.y = v8->vPosition.y - pParty->vPosition.y; a3.z = v8->vPosition.z - pParty->vPosition.z; Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z); - DamageMonsterFromParty((8 * v0 - 8) | 4, a2, &a3); - if ( v1->WearsItem(506, 1) || v1->WearsItem(506, 0) ) + DamageMonsterFromParty((8 * uActiveCharacter - 8) | OBJECT_Player, target_id, &a3); + if ( player->WearsItem(506, 1) || player->WearsItem(506, 0) ) _42FA66_do_explosive_impact( v8->vPosition.x, v8->vPosition.y, v8->vPosition.z + v8->uActorHeight / 2, 0, 512, - v0); + uActiveCharacter); } else { - if ( v31 != v9 ) + if ( bow_idx != v9 ) { v30 = 1; v22 = 0; @@ -8001,10 +8015,11 @@ v3 = 0; goto LABEL_39; } - if ( v33 ) + + if ( laser_weapon_item_id ) { v28 = 1; - v23 = v0 + 8; + v23 = uActiveCharacter + 8; v21 = 0; v19 = 0; v17 = 102; @@ -8013,33 +8028,33 @@ { if ( v32 ) { - v12 = v1->pEquipment.uMainHand; + v12 = player->pEquipment.uMainHand; v29 = 1; _42777D_CastSpell_UseWand_ShootArrow( - *((int *)&pSpellDatas[66].field_8 + *(int *)&v1->pInventoryItems[v12-1]), - v0 - 1, + *((int *)&pSpellDatas[66].field_8 + *(int *)&player->pInventoryItems[v12-1]), + uActiveCharacter - 1, 8u, 0, - v0 + 8); - v13 = &v1->field_1F5[36 * v1->pEquipment.uMainHand + 11]; + uActiveCharacter + 8); + v13 = &player->field_1F5[36 * player->pEquipment.uMainHand + 11]; --*(int *)v13; - v14 = (char *)v1 + 36 * v1->pEquipment.uMainHand; + v14 = (char *)player + 36 * player->pEquipment.uMainHand; if ( *((int *)v14 + 128) <= 0 ) { *((int *)v14 + 124) = 0; - v1->pEquipment.uMainHand = 0; + player->pEquipment.uMainHand = 0; } LABEL_29: v34 = v3; if ( v30 == v3 ) { if ( v29 != v3 ) - return 1; + return; if ( v28 == v3 ) { - v15 = v1->pEquipment.uMainHand; - if ( v1->HasItemEquipped(EQUIP_TWO_HANDED) ) - v34 = pItemsTable->pItems[*(int *)&v1->pInventoryItems[v15-1]].uSkillType; + v15 = player->pEquipment.uMainHand; + if ( player->HasItemEquipped(EQUIP_TWO_HANDED) ) + v34 = pItemsTable->pItems[*(int *)&player->pInventoryItems[v15-1]].uSkillType; pTurnEngine->_40471C(); } else @@ -8050,7 +8065,7 @@ else { v34 = 5; - v1->PlaySound(SPEECH_50, v3); + player->PlaySound(SPEECH_50, v3); } switch ( v34 ) { @@ -8081,18 +8096,18 @@ pAudioPlayer->PlaySound(v24, v3, v3, -1, v3, v3, v3, v3); break; default: - return 1; - } - return 1; + return; + } + return; } - if ( !v31 ) + if ( !bow_idx ) { LABEL_39: - v31 = v1->GetAttackRecoveryTime(v3); + int v31 = player->GetAttackRecoveryTime(v3); if ( v31 < 30 ) v31 = 30; if ( pParty->bTurnBasedModeOn == v3 ) - v1->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v31 * 2.133333333333333)); + player->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v31 * 2.133333333333333)); goto LABEL_29; } v23 = 0; @@ -8101,14 +8116,12 @@ v30 = 1; v17 = 100; } - _42777D_CastSpell_UseWand_ShootArrow(v17, v0 - 1, v19, v21, v23); + _42777D_CastSpell_UseWand_ShootArrow(v17, uActiveCharacter - 1, v19, v21, v23); goto LABEL_29; - } - return result; } //----- (0042F184) -------------------------------------------------------- -int stru319::FindClosesActor(int a2, int a3, int a4) +int stru319::FindClosestActor(int a2, int a3, int a4) { int v4; // edi@1 stru319 *v5; // esi@1 @@ -8899,7 +8912,7 @@ int v17; // [sp-14h] [bp-1Ch]@8 PartyAction partyAction; // [sp-14h] [bp-1Ch]@20 PartyAction partyAction_; // [sp-14h] [bp-1Ch]@54 - __int16 v20; // [sp-14h] [bp-1Ch]@60 + //__int16 v20; // [sp-14h] [bp-1Ch]@60 int v21; // [sp-14h] [bp-1Ch]@68 int v22; // [sp-Ch] [bp-14h]@158 InputAction inputAction; // [sp+0h] [bp-8h]@7 @@ -8941,7 +8954,7 @@ switch ( inputAction ) { case INPUT_MoveForward: - if ( pCurrentScreen ) + if (pCurrentScreen != SCREEN_GAME) break; if (!pParty->bTurnBasedModeOn) //goto _do_move_forward; @@ -8971,7 +8984,7 @@ break; case INPUT_MoveBackwards: //__debugbreak(); - if ( pCurrentScreen ) + if (pCurrentScreen != SCREEN_GAME) break; if (!pParty->bTurnBasedModeOn) //goto _do_move_backwards; @@ -9001,7 +9014,7 @@ break; case INPUT_StrafeLeft: //__debugbreak(); - if ( pCurrentScreen ) + if (pCurrentScreen != SCREEN_GAME) break; if (!pParty->bTurnBasedModeOn) //goto _do_strafe_left; @@ -9023,7 +9036,7 @@ break; case INPUT_StrafeRight: //__debugbreak(); - if ( pCurrentScreen ) + if (pCurrentScreen != SCREEN_GAME) break; if (!pParty->bTurnBasedModeOn) //goto _do_strafe_right; @@ -9044,7 +9057,7 @@ v5->Add(partyAction); break; case INPUT_TurnLeft: - if ( pCurrentScreen ) + if (pCurrentScreen != SCREEN_GAME) break; if ( GetAsyncKeyState(VK_CONTROL) ) // strafing { @@ -9066,14 +9079,11 @@ pActionQueue->Add(partyAction_); if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) { - v20 = 10; - //goto LABEL_75; - pWeather->_4C2F0B(v20); - break; + pWeather->OnPlayerTurn(10); } break; case INPUT_TurnRight: - if ( pCurrentScreen ) + if (pCurrentScreen != SCREEN_GAME) break; if ( GetAsyncKeyState(17) ) // strafing { @@ -9083,27 +9093,24 @@ break; pTurnEngine->uActionPointsLeft -= 26; } - v21 = 4; + v21 = PARTY_StrafeRight; } else { if ( pParty->uFlags2 & 2 ) - v21 = 19; + v21 = PARTY_FastTurnRight; else - v21 = 2; + v21 = PARTY_TurnRight; } pActionQueue->Add((PartyAction)v21); if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) { - v20 = -10; -//LABEL_75: - pWeather->_4C2F0B(v20); + pWeather->OnPlayerTurn(-10); } break; case INPUT_Jump: //__debugbreak(); - if ( pCurrentScreen - || pParty->bTurnBasedModeOn) + if (pCurrentScreen != SCREEN_GAME || pParty->bTurnBasedModeOn) break; partyAction = (PartyAction)12; //goto _add_action_and_continue_; @@ -9143,7 +9150,7 @@ break; case INPUT_Combat: //__debugbreak(); - if ( !pCurrentScreen ) + if (pCurrentScreen == SCREEN_GAME) { if (pParty->bTurnBasedModeOn) { @@ -9162,7 +9169,7 @@ break; case INPUT_CastReady: //__debugbreak(); - if ( pCurrentScreen ) + if (pCurrentScreen != SCREEN_GAME) break; if (pParty->bTurnBasedModeOn && pTurnEngine->field_4 == 3) //goto LABEL_118; @@ -9181,9 +9188,10 @@ { pActionQueue = pPartyActionQueue; LABEL_120: + if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)23; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Attack; //goto _send_message; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; @@ -9205,7 +9213,7 @@ break; case INPUT_Attack: //__debugbreak(); - if ( pCurrentScreen ) + if (pCurrentScreen != SCREEN_GAME) break; if (!pParty->bTurnBasedModeOn || pTurnEngine->field_4 != 3) goto LABEL_120; @@ -9213,11 +9221,11 @@ pTurnEngine->field_18 |= 8u; break; case INPUT_EventTrigger: - if ( !pCurrentScreen ) + if (pCurrentScreen == SCREEN_GAME) { if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) break; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)404; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Game_Action; //goto _send_message; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; @@ -9234,7 +9242,7 @@ v11 = 1; pMessageQueue_50CBD0->uNumMessages = 1; //LABEL_132: - pMessageQueue_50CBD0->pMessages[v11].eType = (UIMessageType)113; + pMessageQueue_50CBD0->pMessages[v11].eType = UIMSG_Escape; //_send_message: pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; @@ -9247,7 +9255,7 @@ if ( (signed int)v11 < 40 ) //goto LABEL_132; { - pMessageQueue_50CBD0->pMessages[v11].eType = (UIMessageType)113; + pMessageQueue_50CBD0->pMessages[v11].eType = UIMSG_Escape; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages;
--- a/mm7_data.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/mm7_data.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -321,8 +321,6 @@ //------------------------------------------------------------------------- // Data declarations -int (__cdecl *sprintfex)(char *a1, const char *a2, ...) = nullptr; - int pWindowList_at_506F50_minus1_indexing[1]; int dword_4C9890[10]; // weak int dword_4C9920[16]; // weak @@ -1264,7 +1262,53 @@ {17, 0, 0, 0, 0, 0, 0, 0} }; __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4] = {34, 149, 264, 379}; -char byte_4ED970_skill_learn_ability_by_class_table[32][37]; +char byte_4ED970_skill_learn_ability_by_class_table[36][37] = +{ + 2, 3, 2, 3, 3, 2, 3, 4, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 0, 2, 1, 0, 1, 2, 2, 0, 3, 0, 0, 1,//Knight + 2, 3, 2, 3, 3, 2, 3, 4, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 0, 2, 1, 0, 1, 2, 2, 0, 3, 0, 0, 1, + 2, 4, 2, 3, 4, 2, 3, 4, 4, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 0, 2, 1, 0, 1, 2, 2, 0, 4, 0, 0, 1, + 2, 4, 2, 3, 4, 2, 3, 4, 4, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 0, 2, 1, 0, 1, 2, 2, 0, 4, 0, 0, 1, + + 0, 3, 3, 0, 0, 2, 2, 4, 1, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 3, 3, 2, 0, 3, 3, 2, 2,//Thief + 0, 3, 3, 0, 0, 2, 2, 4, 1, 3, 2, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 3, 3, 2, 0, 3, 3, 2, 2, + 0, 3, 4, 0, 0, 2, 2, 4, 1, 4, 2, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 4, 3, 2, 0, 3, 4, 2, 2, + 0, 3, 4, 0, 0, 2, 2, 4, 1, 4, 2, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 4, 3, 2, 0, 3, 4, 2, 2, + + 3, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 2, 1, 0, 1, 3, 3, 2, 3, 1, 0, 3,//Monk + 3, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 3, 0, 2, 1, 0, 2, 3, 3, 2, 3, 1, 0, 3, + 4, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 4, 0, 2, 1, 0, 2, 4, 4, 2, 3, 1, 0, 4, + 4, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 4, 0, 2, 1, 0, 3, 4, 4, 2, 3, 2, 0, 4, + + 1, 3, 2, 2, 2, 2, 3, 4, 3, 2, 2, 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 2, 3, 3, 2, 1, 3, 0, 0, 1, 1, 0, 2, 0, 0, 1,//Paladin + 1, 3, 2, 2, 2, 2, 3, 4, 3, 2, 2, 3, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2, 3, 3, 2, 1, 3, 0, 0, 1, 1, 0, 2, 0, 0, 1, + 1, 3, 2, 2, 2, 2, 4, 4, 4, 2, 2, 3, 0, 0, 0, 0, 3, 3, 3, 1, 0, 0, 2, 4, 3, 2, 1, 4, 0, 0, 1, 1, 0, 2, 0, 0, 1, + 1, 3, 2, 2, 2, 2, 4, 4, 4, 2, 2, 3, 0, 0, 0, 0, 3, 3, 3, 0, 1, 0, 2, 4, 3, 2, 1, 4, 0, 0, 1, 1, 0, 2, 0, 0, 1, + + 1, 2, 2, 2, 3, 3, 0, 4, 0, 3, 3, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 0, 0, 1, 2, 1, 0, 2, 0, 0, 3,//Archer + 1, 2, 2, 2, 3, 3, 0, 4, 0, 3, 3, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 0, 0, 1, 2, 1, 0, 2, 0, 0, 3, + 1, 2, 2, 2, 3, 4, 0, 4, 0, 3, 4, 0, 3, 3, 3, 3, 0, 0, 0, 1, 0, 0, 2, 2, 2, 2, 4, 0, 0, 2, 2, 1, 0, 2, 0, 0, 3, + 1, 2, 2, 2, 3, 4, 0, 4, 0, 3, 4, 0, 3, 3, 3, 3, 0, 0, 0, 0, 1, 0, 2, 2, 2, 2, 4, 0, 0, 2, 2, 1, 0, 2, 0, 0, 3, + + 1, 2, 2, 3, 2, 3, 0, 4, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 3, 2, 2, 1, 2,//Ranger + 1, 2, 2, 3, 2, 3, 0, 4, 2, 3, 3, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 3, 2, 2, 1, 2, + 1, 2, 2, 4, 2, 3, 0, 4, 2, 3, 3, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 4, 2, 2, 1, 2, + 1, 2, 2, 4, 2, 3, 0, 4, 2, 3, 3, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 4, 2, 2, 1, 2, + + 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 3, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3,//Cleric + 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 3, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3, + 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 4, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3, + 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 4, 4, 4, 0, 4, 0, 4, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3, + + 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 0, 3, 2, 0, 0, 0, 0, 0, 2, 1, 0, 3, 3,//Druid + 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 0, 0, 3, 2, 0, 0, 0, 0, 0, 2, 1, 0, 3, 3, + 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 0, 0, 4, 2, 0, 0, 0, 0, 0, 2, 1, 0, 4, 3, + 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 0, 0, 4, 2, 0, 0, 0, 0, 0, 2, 1, 0, 4, 3, + + 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 3, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 3, 0, 0, 3, 3,//Sorcerer + 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 3, 0, 0, 3, 3, + 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 4, 0, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3, + 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3, +}; int dword_4EDEA0[777]; // weak int dword_4EDEB4[777]; // weak int dword_4EDEC4[777]; // weak @@ -2001,7 +2045,7 @@ int dword_F8B1A8; // weak int dword_F8B1AC_something_todo_with_awards; // idb int dword_F8B1B0; // weak -int dword_F8B1B4; // weak +int gold_transaction_amount; // F8B1B4 char *pShopOptions[4]; _UNKNOWN unk_F8B1C8; // weak int dword_F8B1D8; // weak @@ -2009,7 +2053,7 @@ int dword_F8B1E0; // weak int dword_F8B1E4; // weak const char *ptr_F8B1E8; // idb -char byte_F8B1EC; // weak +char dialogue_show_profession_details = false; // F8B1EC char byte_F8B1EF[777]; // weak char byte_F8B1F0[4]; int dword_F8B1F4; // weak
--- a/mm7_data.h Mon Feb 18 19:16:15 2013 +0600 +++ b/mm7_data.h Mon Feb 18 19:16:38 2013 +0600 @@ -310,7 +310,6 @@ //------------------------------------------------------------------------- // Data declarations -//extern int (__cdecl *sprintfex)(char *a1, const char *a2, ...); extern int pWindowList_at_506F50_minus1_indexing[1]; extern int dword_4C9890[10]; // weak @@ -982,7 +981,7 @@ extern unsigned char SoundSetAction[110][8]; // weak //extern unsigned char byte_4ED498; // weak extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4]; -extern char byte_4ED970_skill_learn_ability_by_class_table[32][37]; +extern char byte_4ED970_skill_learn_ability_by_class_table[36][37]; extern int dword_4EDEA0[]; // weak extern int dword_4EDEB4[]; // weak extern int dword_4EDEC4[]; // weak @@ -1649,7 +1648,7 @@ extern int dword_80AA1C; // weak extern int dword_80AA20; // weak extern unsigned int uNumElementsIn80AA28; -extern struct stru148 *ptr_80AA28[2000]; +extern struct stru148 *ptr_80AA28[]; extern struct Edge *pNewEdges; extern struct Surf *pSurfs; extern struct Edge *pEdges; @@ -1695,7 +1694,7 @@ extern int dword_F8B1A8; // weak extern int dword_F8B1AC_something_todo_with_awards; // idb extern int dword_F8B1B0; // weak -extern int dword_F8B1B4; // weak +extern int gold_transaction_amount; // F8B1B4 extern char *pShopOptions[4]; extern _UNKNOWN unk_F8B1C8; // weak extern int dword_F8B1D8; // weak @@ -1703,7 +1702,7 @@ extern int dword_F8B1E0; // weak extern int dword_F8B1E4; // weak extern const char *ptr_F8B1E8; // idb -extern char byte_F8B1EC; // weak +extern char dialogue_show_profession_details; // weak extern char byte_F8B1EF[]; // weak extern char byte_F8B1F0[4]; extern int dword_F8B1F4; // weak @@ -1864,7 +1863,7 @@ unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2); signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx); // idb char __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2); // idb -unsigned int __fastcall sub_417AD4(unsigned int uPlayerClass, enum PLAYER_SKILL_TYPE uPlayerSkillType, signed int a3); +unsigned int __fastcall GetSkillColor(unsigned int uPlayerClass, enum PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level); const char *__fastcall CharacterUI_GetSkillDescText(unsigned int uPlayerID, enum PLAYER_SKILL_TYPE uPlayerSkillType); char __cdecl CharacterUI_SkillsTab_ShowHint(); char __cdecl CharacterUI_StatsTab_ShowHint(); @@ -1913,7 +1912,7 @@ void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID); // idb void __cdecl sub_421EA6_OnInventoryLeftClick(); void __cdecl OnGameViewportClick(); -bool __cdecl sub_4226C2(); +bool PauseGameDrawing(); void __fastcall SetUserInterface(int a1, bool bReplace); void __cdecl reset_some_strus_flt_2Cs(); void __cdecl j_sub_423B4A(); @@ -1934,7 +1933,7 @@ bool __fastcall sub_427769_spell(unsigned int uSpellID); bool __fastcall _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6); int __fastcall sub_42EBBE(int, int); // weak -bool __cdecl _42ECB5_PlayerAttacksActor(); +void _42ECB5_PlayerAttacksActor(); void __thiscall InitializeTurnBasedAnimations(void *); signed int __cdecl sub_42F4DA(); bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9); @@ -2001,8 +2000,8 @@ __int16 __fastcall sub_441A4E(int a1); void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap); int __fastcall DrawBook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb -int __cdecl Initialize2DA(); -unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize); +void Initialize2DA(); +unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize); void __cdecl Initialize_GlobalEVT(); void __cdecl LoadLevel_InitializeLevelStr(); void __cdecl LoadLevel_InitializeLevelEvt(); @@ -2020,7 +2019,7 @@ void __cdecl DrawBranchlessDialogueUI(); void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4); void __cdecl sub_4452BB(); -const char *__fastcall sub_445308(int a1); +const char *GetProfessionActionText(int a1); void __cdecl DrawDialogueUI(); struct NPCData *__fastcall GetNPCData(unsigned int npcid); struct NPCData *__fastcall GetNewNPCData(signed int npcid, int a2); @@ -2053,8 +2052,6 @@ signed int __cdecl const_2(); bool __cdecl sub_44C28F_open_nwc_dungeon(); // int __cdecl crt_deconstruct_44C42C(); - - void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); void __cdecl sub_450218_prolly_generate_chests_loot(); @@ -2064,7 +2061,7 @@ bool __fastcall SpawnActor(unsigned int uMonsterID); int __cdecl GetAlertStatus(); unsigned int __fastcall sub_452442(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); -signed int __fastcall sub_452A9E(signed int a1); +int sub_452A9E(int a1); int __fastcall MakeColorMaskFromBitDepth(int a1); void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels); int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb @@ -2184,14 +2181,6 @@ bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4); bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, BLVFace *a4); bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9); -bool __cdecl sub_476387(); -bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession); -void __cdecl InitializeAwards(); -void __cdecl InitializeScrolls(); -void __cdecl InitializeMerchants(); -void __cdecl InitializeTransitions(); -void __cdecl InitializeAutonotes(); -void __cdecl InitializeQuests(); int __fastcall const_1(int, int); // weak int __cdecl GetPartyReputation(); void __cdecl sub_4783FA_construct_global_73D150(); @@ -2266,7 +2255,7 @@ unsigned int __fastcall sub_494820(unsigned int a1); char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2); char *__fastcall GetReputationString(signed int a1); -char *__fastcall sub_495461(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6); +char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6); void __cdecl PlayerCreationUI_Draw(); void __cdecl PlayerCreationUI_Initialize(); void __cdecl DeleteCCharFont(); @@ -2351,7 +2340,6 @@ void __cdecl sub_4BBCDD(); void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb void __cdecl ArenaFight(); -void __thiscall sub_4BC49B(unsigned int _this); struct Texture *__cdecl sub_4BC8D5(); struct GUIButton *__cdecl sub_4BCA33(); void __fastcall sub_4BCACC_bounties(signed int a1);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mm7text_ru.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -0,0 +1,1420 @@ +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <assert.h> + +#include "Log.h" + + +struct GenderTableEntry +{ + const char *name; + int gender; +} gender_table_caps[] = +{ + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 2}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"-", 0}, + {"-", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 2}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 2}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 2}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 2}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 2}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 1}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 1}, + {"", 2}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 1}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0}, + {"", 0} +}, + gender_table[] = +{ + {"", 0}, {"", 1}, {"", 0}, {"", 1}, {"", 0}, {"", 0}, {"", 1}, {"", 1}, {"", 0}, {"", 0}, {"", 1}, + {"", 0}, {"", 0}, {"", 1}, {"", 0}, {"", 0}, {"", 1}, {"", 1}, {"", 0}, {"", 1}, {"", 0}, {"", 0}, + {"", 0}, {"", 0}, {"", 0}, {"", 1}, {"", 0}, {"", 0}, {"", 1}, {"", 0}, {"", 0}, {"", 1}, {"", 1}, + {"", 0}, {"", 1}, {"", 0}, {"", 1}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 1}, {"", 0}, + {"", 1}, {"", 0}, {"", 0}, {"", 0}, {"", 1}, {"", 1}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 1}, + {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, + {"", 0}, {"", 2}, {"", 1}, {"", 0} +}; + + + +#include <mbstring.h> + +int GetGender(char *ansi_name, int name_len) +{ + auto name = (unsigned char *)ansi_name; + + GenderTableEntry *table = nullptr; + unsigned int table_size = 0; + if (name[0] >= (unsigned char)'' && name[0] <= (unsigned char)'') + { + table = gender_table; + table_size = sizeof(gender_table) / sizeof(*gender_table); + } + else if (name[0] >= (unsigned char)'' && name[0] <= (unsigned char)'') + { + table = gender_table_caps; + table_size = sizeof(gender_table_caps) / sizeof(*gender_table_caps); + } + else return 0; + + int left = 0, + right = table_size - 1, + match = 0; + while (left < right - 1) + { + match = left + (right - left) / 2; + int rval = _mbsncmp(name, (unsigned char *)table[match].name, name_len); + if (rval < 0) + right = match; + else if (!rval) + return table[match].gender; + else + left = match; + } + assert(false); + return 0; +} + + +bool IsSpecialName(const char *ansi_name) +{ + auto name = (unsigned char *)ansi_name; + return !_mbsncmp(name, (unsigned char *)" ", 8) || !_mbsncmp(name, (unsigned char *)" ", 6) || + !_mbsncmp(name, (unsigned char *)" ", 14) || !_mbsncmp(name, (unsigned char *)" ", 12); +} +int GetSpecialGender(const char *ansi_name) +{ + auto name = (unsigned char *)ansi_name; + if (!_mbsncmp(name, (unsigned char *)" ", 8)) + return 1; + if (!_mbsncmp(name, (unsigned char *)" ", 6)) + return 1; + if (!_mbsncmp(name, (unsigned char *)" ", 14)) + return 1; + if (!!_mbsncmp(name, (unsigned char *)" ", 12)) + return 0; + return 0; +} +const char *GetSpecialCase(const char *ansi_name, char c) +{ + auto name = (unsigned char *)ansi_name; + + if (!_mbsncmp(name, (unsigned char *)" ", 8)) + return " "; + if (!_mbsncmp(name, (unsigned char *)" ", 6)) + return " "; + + if (!_mbsncmp(name, (unsigned char *)" ", 14)) + switch (c) + { + case 'I': case 'i': return " "; + case 'R': case 'r': return " "; + case 'D': case 'd': return " "; + case 'V': case 'v': return " "; + case 'T': case 't': return " "; + case 'P': case 'p': return " "; + } + + if (!_mbsncmp(name, (unsigned char *)" ", 12)) + switch (c) + { + case 'I': case 'i': return " "; + case 'R': case 'r': return " "; + case 'D': case 'd': return " "; + case 'V': case 'v': return " "; + case 'T': case 't': return " "; + case 'P': case 'p': return " "; + } + + return nullptr; +} + +int __cdecl sprintfex_internal(char *str) +{ + auto p = strstr(str, "^"); + if (!p) + return strlen(str); + + char buf[8192]; + assert(strlen(str) < sizeof(buf)); + + bool integer_token_defined = false; + int integer_token = 0; + + bool gender_token_defined = false; + int gender_token = 0; + + auto src = buf, + dst = p; + strcpy(buf, str + (p - str)); + while (true) + { + switch (src[1]) + { + case 'I': + { + if (src[2] != '[') + goto _invalid_token; + src += 3; // ^I[ + + if (sscanf(src, "%d", &integer_token)) + integer_token_defined = true; + + auto int_begin = src; + while (*src++ != ']'); + + int int_len = src - int_begin - 1; + strncpy(dst, int_begin, int_len); + dst += int_len; + } + break; + + case 'L': + { + if (src[2] != '[') + goto _invalid_token; + assert(integer_token_defined); + src += 3; // ^L[ + + auto ending1 = src; + while (*src++ != ';'); + auto ending2 = src; + while (*src++ != ';'); + auto ending3 = src; + while (*src++ != ']'); + + char *actual_ending = nullptr; + int actual_ending_len = 0; + + int modulo = abs(integer_token) % 10; + if (modulo == 1) + { + actual_ending = ending1; + actual_ending_len = ending2 - ending1 - 1; + } + else if (modulo >= 2 && modulo <= 4) + { + actual_ending = ending2; + actual_ending_len = ending3 - ending2 - 1; + } + else + { + actual_ending = ending3; + actual_ending_len = src - ending3 - 1; + } + + strncpy(dst, actual_ending, actual_ending_len); + dst += actual_ending_len; + } + break; + + case 'R': + { + if (src[2] != '[') + goto _invalid_token; + assert(gender_token_defined); + + src += 3; // ^R[ + + auto ending1 = src; + while (*src++ != ';'); + auto ending2 = src; + while (*src++ != ';'); + auto ending3 = src; + while (*src++ != ']'); + + char *actual_ending = nullptr; + int actual_ending_len = 0; + + if (gender_token == 0) + { + actual_ending = ending1; + actual_ending_len = ending2 - ending1 - 1; + } + else if (gender_token == 1) + { + actual_ending = ending2; + actual_ending_len = ending3 - ending2 - 1; + } + else if (gender_token == 2) + { + actual_ending = ending3; + actual_ending_len = src - ending3 - 1; + } + else assert(false); + + strncpy(dst, actual_ending, actual_ending_len); + dst += actual_ending_len; + } + break; + + case 'P': + { + if (src[3] != '[') + goto _invalid_token; + switch (src[2]) + { + case 'I': case 'i': + case 'R': case 'r': + case 'D': case 'd': + case 'V': case 'v': + case 'T': case 't': + case 'P': case 'p': break; + default: + goto _invalid_token; + } + + if (IsSpecialName(src + 4)) + { + auto name = GetSpecialCase(src + 4, src[2]); + int name_len = strlen(name); + + gender_token = GetSpecialGender(src + 4); + gender_token_defined = true; + + strncpy(dst, name, name_len); + dst += name_len; + while (*src++ != ']'); + break; + } + + auto name_begin = src + 4; + int name_len = 0; + for (int i = 0; name_begin[i] != ']'; ++i) + name_len++; + gender_token = GetGender(name_begin, name_len); + gender_token_defined = true; + + switch (src[2]) + { + case 'I': case 'i': + { + strncpy(dst, name_begin, name_len); + dst += name_len; + } + break; + + case 'R': case 'r': + case 'D': case 'd': + case 'V': case 'v': + case 'T': case 't': + case 'P': case 'p': + { + auto token_begin = src; + int token_len = 0; + for (int i = 0; token_begin[i] != ']'; ++i) + token_len++; + strncpy(dst, token_begin, token_len); + dst += token_len; + } + } + while (*src++ != ']'); + } + break; + + default: + { +_invalid_token: + auto token_begin = src; + while (*src++ != ']'); + + int token_len = src - token_begin; + char token[1024]; + strncpy(token, token_begin, token_len); + token[token_len] = 0; + + Log::Warning(L"Invalid format token: %S", token); + assert(false); + } + break; + } + + *dst = 0; + + auto copy_begin = src; + src = strstr(src, "^"); + if (!src) + { + strcpy(dst, copy_begin); // just copy the rest + break; + } + + int copy_len = src - copy_begin; + strncpy(dst, copy_begin, copy_len); + dst += copy_len; + } + + return dst - str; +} + + + + + + +//mm6text.non -> c structure array + /*FILE *f = fopen("_1.txt", "w+t"); + FILE *in = fopen("mm6text.non", "rt"); + fscanf(in, "%*[^\n]\n"); + + int idx = 0; + auto pairs = new NameGender[8000]; + + char line[1024]; + while (fscanf(in, "%[^\n]\n", line) && !feof(in)) + { + char name1[100], name2[100], name3[100]; + int e = sscanf(line, "%s\t%s\t%s", pairs[idx].name, pairs[idx + 1].name, pairs[idx + 2].name); + pairs[idx].gender = 0; + pairs[idx+1].gender = 1; + pairs[idx+2].gender = 2; + idx += e; + } + + for (int i = 0; i < idx; ++i) + for (int j = 0; j < i; ++j) + { + if (_mbsicmp(pairs[i].name, pairs[j].name) < 0) + { + char n[1024]; + strcpy(n, (char *)pairs[j].name); + auto g = pairs[j].gender; + + strcpy((char *)pairs[j].name, (char *)pairs[i].name); + pairs[j].gender = pairs[i].gender; + + strcpy((char *)pairs[i].name, n); + pairs[i].gender = g; + } + } + + for (int i = 0; i < idx; ++i) + { + fprintf(f, " {\"%s\", %u},\n", pairs[i].name, pairs[i].gender); + } + fclose(f);*/ \ No newline at end of file
--- a/texts.cpp Mon Feb 18 19:16:15 2013 +0600 +++ b/texts.cpp Mon Feb 18 19:16:38 2013 +0600 @@ -15,6 +15,20 @@ char *pGlobalTXT_LocalizationStrings[MAX_LOC_STRINGS]; + +int __cdecl sprintfex(char *buf, const char *format, ...) +{ + va_list args_ptr; + va_start(args_ptr, format); + { + vsprintf(buf, format, args_ptr); + } + va_end(args_ptr); + + extern int __cdecl sprintfex_internal(char *buf); + return sprintfex_internal(buf); +} + //----- (00452B95) -------------------------------------------------------- void __cdecl SetSomeItemsNames() {