Mercurial > mm7
changeset 1441:b67a3e0d6fc3
Слияние
author | Ritor1 |
---|---|
date | Sat, 27 Jul 2013 09:36:55 +0600 |
parents | a72236d60edc (current diff) 2423bc2af692 (diff) |
children | c3bfa7e7cee1 |
files | Chest.cpp Indoor.cpp Outdoor_stuff.h Render.cpp UI/UIHouses.cpp mm7_2.cpp mm7_3.cpp stru220.h |
diffstat | 37 files changed, 2049 insertions(+), 2416 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/Actor.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -3041,7 +3041,7 @@ //----- (00402CED) -------------------------------------------------------- void Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID) { - Actor *v2; // eax@1 + //Actor *v2; // eax@1 unsigned __int16 v3; // dx@1 int v4; // eax@3 int v5; // eax@4 @@ -3053,19 +3053,18 @@ unsigned int v11; // [sp-Ch] [bp-10h]@10 int v12; // [sp-8h] [bp-Ch]@10 - v2 = &pActors[uActorID]; - v3 = v2->pSoundSampleIDs[uSoundID]; + //v2 = &pActors[uActorID]; + v3 = pActors[uActorID].pSoundSampleIDs[uSoundID]; if ( v3 ) { - if ( (signed __int64)v2->pActorBuffs[3].uExpireTime <= 0 ) + if ( (signed __int64)pActors[uActorID].pActorBuffs[3].uExpireTime <= 0 ) { v12 = 0; - v8 = -1; } else { - v4 = v2->pActorBuffs[3].uPower - 2; + v4 = pActors[uActorID].pActorBuffs[3].uPower - 2; if ( v4 ) { v5 = v4 - 1; @@ -3086,7 +3085,6 @@ v6 = 33075; } v12 = v6; - v8 = 0; } pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, PID(OBJECT_Actor, uActorID), 0, v8, 0, 0, 0, v12);
--- a/AudioPlayer.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/AudioPlayer.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -67,8 +67,6 @@ //----- (004A9953) -------------------------------------------------------- void SoundList::Initialize() { - SoundList *pSoundList; // esi@1 - signed int v2; // edi@2 SoundDesc *pSoundDesc; // eax@5 void *pSoundData; // ebx@7 unsigned int uSoundSize; // eax@7 @@ -78,72 +76,52 @@ char pSoundName[120]; // [sp+4h] [bp-A4h]@4 AILSOUNDINFO pInfo; // [sp+7Ch] [bp-2Ch]@10 int v12; // [sp+A0h] [bp-8h]@12 - int a2; // [sp+A4h] [bp-4h]@1 - pSoundList = this; - a2 = 1; if ( sNumSounds > 1 ) { - v2 = 1; - //while ( 1 ) - do + for ( uint i = 1; i < pSoundList->sNumSounds; ++i ) { - sprintf(pSoundName, "%s", pSounds[v2].pSoundName); - // pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID); //Ritor1: it's error - result: no sound - pSoundDesc = &pSoundList->pSounds[v2]; - if ( pSoundList->pSounds[v2].eType != SOUND_DESC_SYSTEM || (sprintf(pSoundName, "%s", pSounds[v2].pSoundName), - pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID), + sprintf(pSoundName, "%s", pSounds[i].pSoundName); + pSoundDesc = &pSoundList->pSounds[i]; + if ( pSoundList->pSounds[i].eType != SOUND_DESC_SYSTEM || (sprintf(pSoundName, "%s", pSounds[i].pSoundName), + pSoundList->pSounds[i].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[i].uSoundID), !pAudioPlayer->b3DSoundInitialized) - || (pSoundDesc = &pSoundList->pSounds[v2], !(pSoundDesc->uFlags & SOUND_DESC_SWAP)) - || !pSoundDesc->pSoundData[0] ) // - goto LABEL_17; + || (pSoundDesc = &pSoundList->pSounds[i], !(pSoundDesc->uFlags & SOUND_DESC_SWAP)) + || !pSoundDesc->pSoundData[0] ) + continue; pSoundData = pSoundDesc->pSoundData[0]; uSoundSize = *(int *)pSoundData; pSoundBytes = (char *)pSoundData + 4; pType = AIL_file_type(pSoundBytes, uSoundSize); if ( !pType ) - //goto LABEL_15; - { - pSoundList->pSounds[v2].bDecompressed = false; - goto LABEL_16; - } + { + pSoundList->pSounds[i].bDecompressed = false; + pSoundList->UnloadSound(i, 1); + continue; + } v8 = pType - 1; if ( v8 ) - { - /*break; - pSoundList->pSounds[v2].p3DSound = pSoundList->pSounds[v2].pSoundData[0]; -LABEL_16: - pSoundList->_4A9DCD(a2, 1); -LABEL_17: - ++a2; - ++v2; - if ( a2 >= (signed int)pSoundList->uNumSounds ) - return; - }*/ - if ( v8 == 1 ) { - if ( AIL_WAV_info(pSoundBytes, &pInfo) && pInfo.uChannels != 2 ) + if ( v8 == 1 ) { - if ( !AIL_decompress_ADPCM(&pInfo, &pSoundList->pSounds[v2].p3DSound, &v12) ) + if ( AIL_WAV_info(pSoundBytes, &pInfo) && pInfo.uChannels != 2 ) { - pSoundList->pSounds[v2].p3DSound = 0; - pSoundList->pSounds[v2].bDecompressed = true; + if ( !AIL_decompress_ADPCM(&pInfo, &pSoundList->pSounds[i].p3DSound, &v12) ) + { + pSoundList->pSounds[i].p3DSound = 0; + pSoundList->pSounds[i].bDecompressed = true; + } } + pSoundList->UnloadSound(i, 1); + continue; } - goto LABEL_16; + pSoundList->pSounds[i].bDecompressed = false; + pSoundList->UnloadSound(i, 1); + continue; } -//LABEL_15: - pSoundList->pSounds[v2].bDecompressed = false; - goto LABEL_16; + pSoundList->pSounds[i].p3DSound = pSoundList->pSounds[i].pSoundData[0]; + pSoundList->UnloadSound(i, 1); } - pSoundList->pSounds[v2].p3DSound = pSoundList->pSounds[v2].pSoundData[0]; -LABEL_16: - pSoundList->UnloadSound(a2, 1); -LABEL_17: - ++a2; - ++v2; - } - while ( a2 < pSoundList->sNumSounds ); } } @@ -318,32 +296,23 @@ //----- (004A9D3E) -------------------------------------------------------- SoundDesc *SoundList::Release() { - SoundList *v1; // esi@1 - signed int v2; // ebx@1 - int v3; // edi@2 SoundDesc *result; // eax@3 void *v5; // ecx@3 - v1 = this; - v2 = 0; if ( (signed int)this->sNumSounds > 0 ) { - v3 = 0; - do + for ( uint i = 0; i < (signed int)this->sNumSounds; ++i ) { - result = v1->pSounds; - v5 = result[v3].pSoundData[0]; + result = this->pSounds; + v5 = result[i].pSoundData[0]; if ( v5 ) { ReleaseSoundData(v5); - v1->pSounds[v3].pSoundData[0] = 0; - result = (SoundDesc *)((char *)&v1->pSounds[v3] + 40); + this->pSounds[i].pSoundData[0] = 0; + result = (SoundDesc *)((char *)&this->pSounds[i] + 40); *(int *)&result->pSoundName[0] &= 0xFFFFFFFEu; } - ++v2; - ++v3; } - while ( v2 < (signed int)v1->sNumSounds ); } return result; } @@ -847,12 +816,6 @@ } } } - - - - - - LABEL_123: for (uint i = 0; i < uMixerChannels; ++i) { @@ -862,12 +825,10 @@ { if (channel->uSourceTrackIdx == sound_id) return; // already playing the same sound from the same source - return - AIL_end_sample(channel->hSample); // requested new sound from the same source - end & switch FreeChannel(channel); } } - LABEL_133: v62 = start_channel; //pAudioPlayer4 = pAudioPlayer; @@ -1040,9 +1001,6 @@ return; } - - - __debugbreak(); // 3d sound stuff, refactor v12 = 13; if ( a3 < 0 ) @@ -1347,7 +1305,6 @@ { pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; v43 = (double)pParty->vPosition.y; -LABEL_100: pRenderVertexSoft.vWorldPosition.y = v43; v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_101; @@ -1361,7 +1318,9 @@ } pRenderVertexSoft.vWorldPosition.x = (double)PartyX; v43 = (double)PartyY; - goto LABEL_100; + pRenderVertexSoft.vWorldPosition.y = v43; + v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; + goto LABEL_101; } } } @@ -1373,7 +1332,6 @@ } - //----- (004AAFCF) -------------------------------------------------------- void AudioPlayer::UpdateSounds() { @@ -1391,7 +1349,7 @@ SpriteObject *v12; // eax@14 Actor *v13; // eax@15 signed int v14; // edx@15 - BLVDoor *v15; // eax@19 + BLVDoor *pDoor; // eax@19 double v16; // st7@22 double v17; // st6@22 double v18; // st5@23 @@ -1454,181 +1412,172 @@ return; } - //v3 = this->b3DSoundInitialized == 0; - if (b3DSoundInitialized) + //v3 = this->b3DSoundInitialized == 0; + if ( b3DSoundInitialized ) + { + __debugbreak(); // refactor refactor + //v3 = this->uNum3DSamples == 0; + //v5 = this->uNum3DSamples < 0; + v59 = 0; + if (uNum3DSamples > 0) + { + v6 = this->p3DSamples; + while ( 1 ) { - __debugbreak(); // refactor refactor - //v3 = this->uNum3DSamples == 0; - //v5 = this->uNum3DSamples < 0; - v59 = 0; - if (uNum3DSamples > 0) + v7 = PID_TYPE(v6->field_4); + if ( AIL_3D_sample_status(v6->hSample) == 2 ) + { + AIL_end_3D_sample(v6->hSample); + pAudioPlayer->_4ABF23(v6); + } + if ( AIL_3D_sample_status(v6->hSample) != 4 ) + goto LABEL_35; + v8 = v7 - 1;// + if ( v8 )//> 1 + break; + if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )//==1 + goto LABEL_31; + pDoor = &pIndoor->pDoors[PID_ID(v6->field_4)]; + if ( pDoor->uDoorID ) + { + uNumRepeats = *pDoor->pXOffsets; + a1.vWorldPosition.x = (double)uNumRepeats; + uNumRepeats = *pDoor->pYOffsets; + a1.vWorldPosition.y = (double)uNumRepeats; + uNumRepeats = *pDoor->pZOffsets; + v11 = (double)uNumRepeats; + goto LABEL_21; + } +LABEL_35: + ++v59; + ++v6; + if ( v59 >= pAudioPlayer->uNum3DSamples ) + { + v2 = 0; + goto LABEL_37; + } + } + + v9 = v8 - 1;// + if ( v9 )//> 2 + { + v10 = v9 - 1;// + if ( !v10 )//3 { - v6 = this->p3DSamples; - while ( 1 ) + v13 = &pActors[PID_ID(v6->field_4)]; + uNumRepeats = v13->vPosition.x; + v14 = v13->vPosition.y; + a1.vWorldPosition.x = (double)uNumRepeats; + uNumRepeats = v13->vPosition.z; + a1.vWorldPosition.y = (double)v14; + v11 = (double)uNumRepeats; + goto LABEL_21; + } + if ( v10 != 2 )//4 + { + a1.vWorldPosition.x = (double)pParty->vPosition.x; + a1.vWorldPosition.y = (double)pParty->vPosition.y; + v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; + goto LABEL_21; + }//5 + v12 = (SpriteObject *)&pLevelDecorations[PID_ID(v6->field_4)]; + } + else//2 + { + v12 = &pSpriteObjects[PID_ID(v6->field_4)]; + } + a1.vWorldPosition.x = (double)v12->vPosition.x; + a1.vWorldPosition.y = (double)v12->vPosition.y; + v11 = (double)v12->vPosition.z; +LABEL_21: + a1.vWorldPosition.z = v11; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v16 = pBLVRenderParams->fCosineNegX; + v17 = pBLVRenderParams->fSineNegX; + v55 = pBLVRenderParams->fCosineY; + v56 = pBLVRenderParams->fSineY; + if ( pBLVRenderParams->sPartyRotX ) + { + v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; + *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; + v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z; + if ( pRenderer->pRenderD3D ) { - v7 = PID_TYPE(v6->field_4); - if ( AIL_3D_sample_status(v6->hSample) == 2 ) - { - AIL_end_3D_sample(v6->hSample); - pAudioPlayer->_4ABF23(v6); - } - if ( AIL_3D_sample_status(v6->hSample) != 4 ) - goto LABEL_35; - v8 = v7 - 1; - if ( v8 ) - break; - if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) - goto LABEL_31; - v15 = &pIndoor->pDoors[PID_ID(v6->field_4)]; - if ( v15->uDoorID ) - { - uNumRepeats = *v15->pXOffsets; - a1.vWorldPosition.x = (double)uNumRepeats; - uNumRepeats = *v15->pYOffsets; - a1.vWorldPosition.y = (double)uNumRepeats; - uNumRepeats = *v15->pZOffsets; - v11 = (double)uNumRepeats; - goto LABEL_21; - } -LABEL_35: - ++v59; - ++v6; - if ( v59 >= pAudioPlayer->uNum3DSamples ) - { - v2 = 0; - goto LABEL_37; - } - } - - v9 = v8 - 1; - if ( v9 ) - { - v10 = v9 - 1; - if ( !v10 ) - { - v13 = &pActors[PID_ID(v6->field_4)]; - uNumRepeats = v13->vPosition.x; - v14 = v13->vPosition.y; - a1.vWorldPosition.x = (double)uNumRepeats; - uNumRepeats = v13->vPosition.z; - a1.vWorldPosition.y = (double)v14; - v11 = (double)uNumRepeats; - goto LABEL_21; - } - if ( v10 != 2 ) - { - a1.vWorldPosition.x = (double)pParty->vPosition.x; - a1.vWorldPosition.y = (double)pParty->vPosition.y; - v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; - goto LABEL_21; - } - v12 = (SpriteObject *)&pLevelDecorations[PID_ID(v6->field_4)]; + v19 = *(float *)&uNumRepeats * v56 + v58 * v55; + v20 = v58 * v56 - *(float *)&uNumRepeats * v55; } else { - v12 = &pSpriteObjects[PID_ID(v6->field_4)]; + v19 = v58 * v55 - *(float *)&uNumRepeats * v56; + v20 = v58 * v56 + *(float *)&uNumRepeats * v55; } - a1.vWorldPosition.x = (double)v12->vPosition.x; - a1.vWorldPosition.y = (double)v12->vPosition.y; - v11 = (double)v12->vPosition.z; -LABEL_21: - a1.vWorldPosition.z = v11; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + a1.vWorldViewPosition.x = v19 * v16 - v18 * v17; + a1.vWorldViewPosition.y = v20; + a1.vWorldViewPosition.z = v19 * v17 + v18 * v16; + } + else + { + v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; + *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; + if ( pRenderer->pRenderD3D ) { - v16 = pBLVRenderParams->fCosineNegX; - v17 = pBLVRenderParams->fSineNegX; - v55 = pBLVRenderParams->fCosineY; - v56 = pBLVRenderParams->fSineY; - if ( pBLVRenderParams->sPartyRotX ) - { - v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; - *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; - v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z; - if ( pRenderer->pRenderD3D ) - { - v19 = *(float *)&uNumRepeats * v56 + v58 * v55; - v20 = v58 * v56 - *(float *)&uNumRepeats * v55; - } - else - { - v19 = v58 * v55 - *(float *)&uNumRepeats * v56; - v20 = v58 * v56 + *(float *)&uNumRepeats * v55; - } - a1.vWorldViewPosition.x = v19 * v16 - v18 * v17; - a1.vWorldViewPosition.y = v20; - a1.vWorldViewPosition.z = v19 * v17 + v18 * v16; - } - else - { - v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; - *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; - if ( pRenderer->pRenderD3D ) - { - a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55; - v21 = v58 * v56 - *(float *)&uNumRepeats * v55; - } - else - { - a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56; - v21 = v58 * v56 + *(float *)&uNumRepeats * v55; - } - a1.vWorldViewPosition.y = v21; - a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z; - } + a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55; + v21 = v58 * v56 - *(float *)&uNumRepeats * v55; } else { -LABEL_31: - pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u); + a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56; + v21 = v58 * v56 + *(float *)&uNumRepeats * v55; } - v58 = a1.vWorldViewPosition.y * -0.012207031; - v22 = a1.vWorldViewPosition.x * 0.012207031; - *(float *)&uNumRepeats = v22; - v23 = abs((signed __int64)v22); - v24 = abs(0); - v25 = abs((signed __int64)v58); - if ( int_get_vector_length(v25, v24, v23) <= 100 ) - { - AIL_set_3D_position(v6->hSample, LODWORD(v58), 0.0, uNumRepeats); - v26 = -*(float *)&uNumRepeats; - v27 = -v58; - AIL_set_3D_orientation(v6->hSample, LODWORD(v27), 0.0, LODWORD(v26), 0.0, 1.0, 0.0); - } - else - { - AIL_end_3D_sample(v6->hSample); - pAudioPlayer->_4ABF23(v6); - } - goto LABEL_35; + a1.vWorldViewPosition.y = v21; + a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z; } } - - - - - - + else + { +LABEL_31: + pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u); + } + v58 = a1.vWorldViewPosition.y * -0.012207031; + v22 = a1.vWorldViewPosition.x * 0.012207031; + *(float *)&uNumRepeats = v22; + v23 = abs((signed __int64)v22); + v24 = abs(0); + v25 = abs((signed __int64)v58); + if ( int_get_vector_length(v25, v24, v23) <= 100 ) + { + AIL_set_3D_position(v6->hSample, LODWORD(v58), 0.0, uNumRepeats); + v26 = -*(float *)&uNumRepeats; + v27 = -v58; + AIL_set_3D_orientation(v6->hSample, LODWORD(v27), 0.0, LODWORD(v26), 0.0, 1.0, 0.0); + } + else + { + AIL_end_3D_sample(v6->hSample); + pAudioPlayer->_4ABF23(v6); + } + goto LABEL_35; + } + } LABEL_37: for (uint i = 0; i < uMixerChannels; ++i) { - auto channel = pMixerChannels + i; - - if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) + if (AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Done) { - AIL_end_sample(channel->hSample); - FreeChannel(channel); + AIL_end_sample(pMixerChannels[i].hSample); + FreeChannel(&pMixerChannels[i]); } } for (uint i = 0; i < uMixerChannels; ++i) { - auto channel = pMixerChannels + i; - if (channel->source_pid <= 0) + if (pMixerChannels[i].source_pid <= 0) continue; - int source_type = PID_TYPE(channel->source_pid), - source_id = PID_ID(channel->source_pid); + int source_type = PID_TYPE(pMixerChannels[i].source_pid), + source_id = PID_ID(pMixerChannels[i].source_pid); int source_x, source_y, source_z; @@ -1645,46 +1594,42 @@ assert(uCurrentlyLoadedLevelType == LEVEL_Indoor); assert(source_id < pIndoor->uNumDoors); - auto door = pIndoor->pDoors + source_id; - if (!door->uDoorID) + if (!pIndoor->pDoors[source_id].uDoorID) continue; - source_x = door->pXOffsets[0]; - source_y = door->pYOffsets[0]; - source_z = door->pZOffsets[0]; + source_x = pIndoor->pDoors[source_id].pXOffsets[0]; + source_y = pIndoor->pDoors[source_id].pYOffsets[0]; + source_z = pIndoor->pDoors[source_id].pZOffsets[0]; } break; case OBJECT_Item: { assert(source_id < uNumSpriteObjects); - auto object = &pSpriteObjects[source_id]; - source_x = object->vPosition.x; - source_y = object->vPosition.y; - source_z = object->vPosition.z; + source_x = pSpriteObjects[source_id].vPosition.x; + source_y = pSpriteObjects[source_id].vPosition.y; + source_z = pSpriteObjects[source_id].vPosition.z; } break; case OBJECT_Decoration: { assert(source_id < uNumLevelDecorations); - auto object = (SpriteObject *)&pLevelDecorations[source_id]; - source_x = object->vPosition.x; - source_y = object->vPosition.y; - source_z = object->vPosition.z; + source_x = pLevelDecorations[source_id].vPosition.x; + source_y = pLevelDecorations[source_id].vPosition.y; + source_z = pLevelDecorations[source_id].vPosition.z; } break; case OBJECT_Actor: { assert(source_id < uNumActors); - auto actor = &pActors[source_id]; - source_x = actor->vPosition.x; - source_y = actor->vPosition.y; - source_z = actor->vPosition.z; + source_x = pActors[source_id].vPosition.x; + source_y = pActors[source_id].vPosition.y; + source_z = pActors[source_id].vPosition.z; } break; @@ -1695,13 +1640,13 @@ if (auto sound_strength = GetSoundStrengthByDistanceFromParty(source_x, source_y, source_z)) { - AIL_set_sample_volume(channel->hSample, sound_strength); - AIL_set_sample_pan(channel->hSample, sub_4AB66C(source_x, source_y)); + AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength); + AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(source_x, source_y)); } else { - AIL_end_sample(channel->hSample); - FreeChannel(channel); + AIL_end_sample(pMixerChannels[i].hSample); + FreeChannel(&pMixerChannels[i]); } } @@ -1758,9 +1703,39 @@ if (!decor_desc->SoundOnDawn()) { if (!decor_desc->SoundOnDusk()) - goto LABEL_84; + { + if ( v55 == 0.0 ) + { + if ( v56 != 0.0 ) + { + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); + } + continue; + } + if ( !decor->field_1A ) + decor->field_1A = (rand() % 15 + 1) << 7; + if ( v56 != 0.0 ) + { + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); + } + continue; + } if ( v55 != 0.0 ) - goto LABEL_85; + { + if ( !decor->field_1A ) + decor->field_1A = (rand() % 15 + 1) << 7; + if ( v56 != 0.0 ) + { + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); + } + continue; + } } v56 = 0.0; @@ -1771,26 +1746,28 @@ LODWORD(v56) = 1; LODWORD(v55) = 1; } -LABEL_84: - if ( v55 == 0.0 ) + if ( v55 == 0.0 ) + { + if ( v56 != 0.0 ) { -LABEL_87: - if ( v56 != 0.0 ) - { - v53 = 8 * _6807B8_level_decorations_ids[i]; - LOBYTE(v53) = v53 | OBJECT_Decoration; - PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); - } - continue; + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); } -LABEL_85: - if ( !decor->field_1A ) - decor->field_1A = (rand() % 15 + 1) << 7; - goto LABEL_87; + continue; + } + if ( !decor->field_1A ) + decor->field_1A = (rand() % 15 + 1) << 7; + if ( v56 != 0.0 ) + { + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); + } + continue; } } - //----- (004AB66C) -------------------------------------------------------- int __fastcall sub_4AB66C(int a1, int a2) { @@ -1805,42 +1782,34 @@ // 4AB66C: using guessed type int __fastcall sub_4AB66C(int, int); //----- (004AB6B1) -------------------------------------------------------- -int __fastcall GetSoundStrengthByDistanceFromParty(int a1, int a2, int a3) +int GetSoundStrengthByDistanceFromParty(int x, int y, int z) { - int v3; // esi@1 - int v4; // edi@1 - int v5; // ST08_4@1 - int v6; // esi@1 - int v7; // eax@1 - int v9; // [sp+10h] [bp+8h]@1 + int dir_x; // ST08_4@1 + int dir_y; // esi@1 + int dir_z; // eax@1 + int length; // [sp+10h] [bp+8h]@1 - v3 = a2; - v4 = a1; - v5 = abs(a3 - pParty->vPosition.z); - v6 = abs(v3 - pParty->vPosition.y); - v7 = abs(v4 - pParty->vPosition.x); - v9 = int_get_vector_length(v7, v6, v5); - if ( v9 <= 8192 ) - return 114 - (unsigned __int64)(signed __int64)((double)v9 * 0.0001220703125 * 100.0); + dir_z = abs(z - pParty->vPosition.z); + dir_y = abs(y - pParty->vPosition.y); + dir_x = abs(x - pParty->vPosition.x); + length = int_get_vector_length(dir_x, dir_y, dir_z); + if ( length <= 8192 ) + return 114 - (unsigned __int64)(signed __int64)((double)length * 0.0001220703125 * 100.0); else return 0; } - - //----- (004AB71F) -------------------------------------------------------- void AudioPlayer::StopChannels(int uStartChannel, int uEndChannel) { //AudioPlayer *v3; // esi@1 int v4; // ecx@1 - AudioPlayer_3DSample *v5; // edi@4 + //AudioPlayer_3DSample *v5; // edi@4 int v6; // ebx@12 MixerChannel *pChannel; // edi@14 //_STREAM *v8; // esi@23 int v9; // [sp+4h] [bp-4h]@3 - //v3 = this; - v4 = 0; if ( bPlayerReady ) { if ( b3DSoundInitialized ) @@ -1848,30 +1817,27 @@ v9 = 0; if ( uNum3DSamples > 0 ) { - v5 = p3DSamples;//;(char *)&p3DSamples[0].field_8; - do + //v5 = p3DSamples;//;(char *)&p3DSamples[0].field_8; + for ( v4 = 0; v4 < uNum3DSamples; ++v4 ) { if ( (uStartChannel == -1 || v4 < uStartChannel || v4 > uEndChannel) - && v5->field_8 - && pSoundList->pSounds[v5->field_8].eType != SOUND_DESC_SYSTEM) + && p3DSamples[v4].field_8 + && pSoundList->pSounds[p3DSamples[v4].field_8].eType != SOUND_DESC_SYSTEM) { - AIL_end_3D_sample(v5->hSample); - _4ABF23(v5); - v5->field_4 = 0; + AIL_end_3D_sample(p3DSamples[v4].hSample); + _4ABF23(&p3DSamples[v4]); + p3DSamples[v4].field_4 = 0; v4 = v9; } - ++v4; - v5 += 16; + //v5 += 16; v9 = v4; } - while ( v4 < uNum3DSamples ); } } - v6 = 0; if ( hDigDriver && uMixerChannels > 0 ) { pChannel = pMixerChannels; - do + for ( v6 = 0; v6 < uMixerChannels; ++v6 ) { if ( (uStartChannel == -1 || v6 < uStartChannel || v6 > uEndChannel) && pSoundList->pSounds[pChannel->uSourceTrackIdx].eType != SOUND_DESC_SYSTEM) @@ -1880,10 +1846,8 @@ FreeChannel(pChannel); pChannel->source_pid = 0; } - ++v6; ++pChannel; } - while (v6 < uMixerChannels); } if (hSequence) AIL_end_sequence(hSequence); @@ -1893,7 +1857,6 @@ } } - //----- (004AB818) -------------------------------------------------------- void AudioPlayer::LoadAudioSnd() { @@ -1960,6 +1923,7 @@ bEAXSupported = 0; b3DSoundInitialized = 0; ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128u, "NONE"); + __debugbreak(); // audioplayer.cpp(1926): warning C4700: uninitialized local variable 'v5' used CheckA3DSupport(v5); while ( AIL_enumerate_3D_providers(&v14, (HPROVIDER *)&hWnd, &Str1) ) { @@ -2094,7 +2058,6 @@ } } - //----- (004ABC9B) -------------------------------------------------------- LSTATUS AudioPlayer::CheckA3DSupport(char a2) { @@ -2130,18 +2093,11 @@ //----- (004ABD5B) -------------------------------------------------------- void AudioPlayer::Release() // { - AudioPlayer *pAudioPlayer; // esi@1 - int v2; // edi@1 MixerChannel *pMixerChannel; // ebx@3 char v4; // dl@5 - int v5; // ebx@6 AudioPlayer_3DSample *p3DSample; // edi@7 - //int v7; // edx@14 - int v8; // ecx@14 void *v9; // ecx@15 - pAudioPlayer = this; - v2 = 0; if ( this->bPlayerReady ) { CloseHandle(pVideoPlayer->hMagicVid); @@ -2150,32 +2106,27 @@ if ( pAudioPlayer->uMixerChannels > 0 ) { pMixerChannel = pAudioPlayer->pMixerChannels; - do + for ( uint i = 0; i < pAudioPlayer->uMixerChannels; ++i ) { AIL_release_sample_handle(pMixerChannel->hSample); - ++v2; ++pMixerChannel; } - while ( v2 < pAudioPlayer->uMixerChannels ); } if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 ) { - v5 = 0; pAudioPlayer->CheckA3DSupport(0);// pAudioPlayer->CheckA3DSupport(v4); if ( pAudioPlayer->uNum3DSamples > 0 ) { p3DSample = pAudioPlayer->p3DSamples; - do + for ( uint i = 0; i < pAudioPlayer->uNum3DSamples; ++i ) { if ( p3DSample->hSample ) { AIL_release_3D_sample_handle(p3DSample->hSample); p3DSample->hSample = 0; } - ++v5; ++p3DSample; } - while ( v5 < pAudioPlayer->uNum3DSamples ); } if ( pAudioPlayer->h3DSoundProvider ) { @@ -2183,11 +2134,10 @@ pAudioPlayer->h3DSoundProvider = 0; } } - v8 = (int)&pAudioPlayer->hAILRedbook; if ( pAudioPlayer->hAILRedbook ) { AIL_redbook_stop(pAudioPlayer->hAILRedbook); - AIL_redbook_set_volume((HREDBOOK)v8, pAudioPlayer->sRedbookVolume); + AIL_redbook_set_volume((HREDBOOK)&pAudioPlayer->hAILRedbook, pAudioPlayer->sRedbookVolume); AIL_redbook_close(pAudioPlayer->hAILRedbook); } AIL_shutdown(); @@ -2202,28 +2152,26 @@ //----- (004ABE55) -------------------------------------------------------- void AudioPlayer::FreeChannel(MixerChannel *pChannel) { - int v2; // ebx@1 + //int v2; // ebx@1 //AudioPlayer *v3; // esi@1 - SoundDesc *v4; // eax@2 + //SoundDesc *v4; // eax@2 unsigned __int8 v5; // zf@5 - unsigned __int8 v6; // sf@5 - char *v7; // edi@6 + //unsigned __int8 v6; // sf@5 + //char *v7; // edi@6 int num_same_sound_on_channels; // eax@8 - int v9; // ST04_4@8 + //int v9; // ST04_4@8 int v10; // ecx@12 int v11; // edi@13 int v12; // eax@13 - unsigned __int8 v13; // of@13 + //unsigned __int8 v13; // of@13 int v14[16]; // [sp+Ch] [bp-48h]@8 int num_playing_channels; // [sp+4Ch] [bp-8h]@5 - int v16; // [sp+50h] [bp-4h]@5 + //int v16; // [sp+50h] [bp-4h]@5 - v2 = 0; - //v3 = this; if (!pSoundList->pSounds) return; - v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx]; + //v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx]; if ( pSoundList->pSounds[pChannel->uSourceTrackIdx].eType == SOUND_DESC_SWAP) { if ( pSoundList->pSounds[pChannel->uSourceTrackIdx].pSoundData[0] && @@ -2231,19 +2179,17 @@ { num_playing_channels = 0; num_same_sound_on_channels = 0; - if ( this->uMixerChannels <=0 ) + if ( this->uMixerChannels <= 0 ) goto LABEL_16; - do + for ( uint i = 0; i < uMixerChannels; i++ ) { - if ( pChannel->uSourceTrackID ==pMixerChannels[v2].uSourceTrackID ) + if ( pChannel->uSourceTrackID == pMixerChannels[i].uSourceTrackID ) { - v14[num_same_sound_on_channels++] = v2; - if ( AIL_sample_status((HSAMPLE)pMixerChannels[v2].hSample) == AIL::Sample::Playing) + v14[num_same_sound_on_channels++] = i; + if ( AIL_sample_status((HSAMPLE)pMixerChannels[i].hSample) == AIL::Sample::Playing) ++num_playing_channels; } - ++v2; } - while ( v2 < uMixerChannels ); if ( !num_playing_channels ) { LABEL_16: @@ -2256,85 +2202,17 @@ v11 = v14[v10]; v12 = 16 * (v14[v10++] + 47); pMixerChannels[v11].uSourceTrackID = 0; - v13 = __OFSUB__(v10, num_same_sound_on_channels); - v6 = v10 - num_same_sound_on_channels < 0; + //v13 = __OFSUB__(v10, num_same_sound_on_channels); + //v6 = v10 - num_same_sound_on_channels < 0; *(unsigned int *)((char *)&bEAXSupported + v12) = 0; } - while (v10<num_same_sound_on_channels); + while (v10 < num_same_sound_on_channels); } } } } } - - -//----- (004AAEA6) -------------------------------------------------------- -int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1) -{ - double v1; // st7@1 - double v2; // st6@1 - int result; // eax@1 - double v4; // st5@2 - double v5; // st4@3 - double v6; // st3@3 - double v7; // st7@6 - double v8; // st6@7 - float v9; // [sp+0h] [bp-10h]@1 - float v10; // [sp+4h] [bp-Ch]@1 - float v11; // [sp+8h] [bp-8h]@2 - float v12; // [sp+8h] [bp-8h]@6 - float v13; // [sp+Ch] [bp-4h]@2 - float v14; // [sp+Ch] [bp-4h]@6 - - v1 = pBLVRenderParams->fCosineNegX; - v2 = pBLVRenderParams->fSineNegX; - v9 = pBLVRenderParams->fCosineY; - v10 = pBLVRenderParams->fSineY; - result = 0; - if ( pBLVRenderParams->sPartyRotX ) - { - v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x; - v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y; - v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z; - if ( pRenderer->pRenderD3D ) - { - v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY; - v6 = v13 * pBLVRenderParams->fSineY - v11 * pBLVRenderParams->fCosineY; - } - else - { - v5 = v13 * pBLVRenderParams->fCosineY - v11 * pBLVRenderParams->fSineY; - v6 = v13 * pBLVRenderParams->fSineY + v11 * pBLVRenderParams->fCosineY; - } - a1->vWorldViewPosition.x = v5 * v1 - v4 * v2; - a1->vWorldViewPosition.y = v6; - a1->vWorldViewPosition.z = v5 * v2 + v4 * v1; - } - else - { - v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x; - v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y; - v7 = a1->vWorldPosition.z - (double)pParty->vPosition.z; - if ( pRenderer->pRenderD3D ) - { - a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY; - v8 = v14 * v10 - v12 * v9; - } - else - { - a1->vWorldViewPosition.x = v14 * pBLVRenderParams->fCosineY - v12 * pBLVRenderParams->fSineY; - v8 = v14 * v10 + v12 * v9; - } - a1->vWorldViewPosition.y = v8; - a1->vWorldViewPosition.z = v7; - } - return result; -} - - - - //----- (004ABF23) -------------------------------------------------------- void AudioPlayer::_4ABF23(AudioPlayer_3DSample *a2) { @@ -2422,20 +2300,14 @@ //----- (004AC004) -------------------------------------------------------- void AudioPlayer::SetEAXPreferences() { - AudioPlayer *v1; // edi@1 - _PROVIDER *v2; // ST00_4@2 - _PROVIDER *v3; // ST00_4@2 float v4; // [sp+4h] [bp-4h]@2 - v1 = this; if ( this->bEAXSupported ) { - v2 = this->h3DSoundProvider; v4 = 0.0; - AIL_set_3D_provider_preference(v2, "EAX effect volume", (int *)&v4); - v3 = v1->h3DSoundProvider; + AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX effect volume", (int *)&v4); v4 = 1.0; - AIL_set_3D_provider_preference(v3, "EAX damping", (int *)&v4); + AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX damping", (int *)&v4); } } // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int); @@ -2443,24 +2315,22 @@ //----- (004AC041) -------------------------------------------------------- void AudioPlayer::SetMapEAX() { - AudioPlayer *v1; // esi@1 - unsigned int v2; // eax@1 + unsigned int pMapID; // eax@1 int v3; // [sp+4h] [bp-4h]@3 - v1 = this; - v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); - if ( v1->b3DSoundInitialized && v1->bEAXSupported ) + pMapID = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( this->b3DSoundInitialized && this->bEAXSupported ) { - v3 = pMapStats->pInfos[v2].uEAXEnv; + v3 = pMapStats->pInfos[pMapID].uEAXEnv; if ( (unsigned int)v3 >= 0x1A ) { SetEAXPreferences(); - v1->field_214 = -1; + this->field_214 = -1; } else { - AIL_set_3D_provider_preference(v1->h3DSoundProvider, "EAX environment selection", &v3); - v1->field_214 = v3; + AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX environment selection", &v3); + this->field_214 = v3; } } } @@ -2540,154 +2410,110 @@ return 1; } - //----- (004A96BE) -------------------------------------------------------- void ReleaseSoundData(void *_this) { - int pID; // esi@1 - char *v2; // eax@1 - - pID = 0; - v2 = (char *)&pSounds[0].pSoundData; - while ( *(void **)v2 != _this ) + for ( uint i = 0; (void *)&pSounds[i].pSoundData < (void *)&pSounds[2999].pSoundData; i++ ) { - v2 += 128; - ++pID; - if ( v2 > (void *)&pSounds[2999].pSoundData)//(signed int)&pAudioPlayer->p3DSamples[6].field_8 ) - return; + if ( pSounds[i].pSoundData == _this ) + { + pAllocator->FreeChunk(_this); + memset(&pSounds[i], 0, 0x80u); + } } - pAllocator->FreeChunk(_this); - memset(&pSounds[pID], 0, 0x80u); + } //----- (004A96FF) -------------------------------------------------------- -SoundHeader *__fastcall FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName) +struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName) { - unsigned int v3; // ebx@1 - unsigned int v4; // esi@1 - SoundHeader *result; // eax@2 +/* SoundHeader *result; // eax@2 + SoundHeader *pSound; signed int v6; // ebx@11 - int v7; // edi@13 - unsigned int v8; // esi@14 - unsigned int v9; // esi@20 - unsigned int v10; // [sp+Ch] [bp-4h]@1 - v3 = uEnd; - v10 = uEnd; - v4 = uStart; while ( 1 ) { - v6 = v3 - v4; - result = &pAudioPlayer->pSoundHeaders[v6 / 2 + v4]; - if ( !result ) - return result; - result = (SoundHeader *)_stricmp(pName, result->pSoundName); - if ( !result ) - uFindSound_BinSearch_ResultID = v6 / 2 + v4; - if ( v4 == v10 ) - goto LABEL_17; - if ( (signed int)result < 0 ) - break; - if ( v6 <= 4 ) + v6 = uEnd - uStart; + pSound = &pAudioPlayer->pSoundHeaders[v6 / 2 + uStart]; + if ( !pSound ) + return false; + result = (SoundHeader *)_stricmp(pName, pSound->pSoundName); + if ( !_stricmp(pName, pSound->pSoundName) ) + uFindSound_BinSearch_ResultID = v6 / 2 + uStart; + if ( uStart == uEnd ) { - v7 = v4; - if ( (signed int)v4 < (signed int)v10 ) - { - v9 = v4; - do - { - result = (SoundHeader *)_stricmp(pName, pAudioPlayer->pSoundHeaders[v9].pSoundName); - if ( !result ) - goto LABEL_24; - ++v7; - ++v9; - } - while ( v7 < (signed int)v10 ); - } -LABEL_17: uFindSound_BinSearch_ResultID = -1; return result; } - v4 += v6 / 2; + if ( (signed int)result < 0 ) + break; + + if ( v6 <= 4 ) + { + if ( (signed int)uStart < (signed int)uEnd ) + { + for ( uint i = uStart; i < (signed int)uEnd; ++i ) + { + if ( !_stricmp(pName, pAudioPlayer->pSoundHeaders[i].pSoundName) ) + { + uFindSound_BinSearch_ResultID = i; + return &pAudioPlayer->pSoundHeaders[i]; + } + } + } + uFindSound_BinSearch_ResultID = -1; + return false; + } + + uStart += v6 / 2; LABEL_10: - v3 = v10; + ; } if ( v6 > 4 ) { - v10 = v6 / 2 + v4; + uEnd = v6 / 2 + uStart; goto LABEL_10; } - v7 = v4; - if ( (signed int)v4 >= (signed int)v10 ) - goto LABEL_17; - v8 = v4; - while ( 1 ) + if ( (signed int)uStart >= (signed int)uEnd ) + { + uFindSound_BinSearch_ResultID = -1; + return false; + }*/ + for ( uint i = uStart; i < (signed int)uEnd; ++i ) { - result = (SoundHeader *)_stricmp(pName, pAudioPlayer->pSoundHeaders[v8].pSoundName); - if ( !result ) - break; - ++v7; - ++v8; - if ( v7 >= (signed int)v10 ) - goto LABEL_17; + if ( !_stricmp(pName, pAudioPlayer->pSoundHeaders[i].pSoundName) ) + { + uFindSound_BinSearch_ResultID = i; + return &pAudioPlayer->pSoundHeaders[i]; + } } -LABEL_24: - uFindSound_BinSearch_ResultID = v7; - return result; + uFindSound_BinSearch_ResultID = -1; + return false; } // F1B4C8: using guessed type int uFindSound_BinSearch_ResultID; //----- (004A97C6) -------------------------------------------------------- SoundData *LoadSound(const char *pSoundName, SoundData *pOutBuff, unsigned int uID) { - SoundData *v3; // edi@1 - int v4; // ecx@1 - //Sound *v5; // eax@1 - SoundHeader *v6; // esi@5 - unsigned int *pDecompressedSize; // ebx@5 - unsigned int v8; // eax@5 - unsigned int v9; // eax@7 - SoundData *result; // eax@9 - int v11; // esi@15 - int v12; // eax@15 - char *v13; // ecx@16 - int v14; // eax@19 - std::string v15; // [sp-18h] [bp-34h]@12 - const char *v16; // [sp-8h] [bp-24h]@12 - int v17; // [sp-4h] [bp-20h]@12 - char v18; // [sp+Ch] [bp-10h]@12 - int v19; // [sp+10h] [bp-Ch]@5 DWORD NumberOfBytesRead; // [sp+14h] [bp-8h]@8 - const char *pSoundName_; // [sp+18h] [bp-4h]@1 - pSoundName_ = pSoundName; - v3 = pOutBuff; - v4 = 0; for (uint i = 0; i < 3000; ++i) - { - if (pSounds[i].uID == uID) - return pSounds[i].pSoundData; - } - FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName_); - if ( uFindSound_BinSearch_ResultID == -1 ) { - result = 0; - return result; + if (pSounds[i].uID == uID) + return pSounds[i].pSoundData; } - v6 = &pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID]; - pDecompressedSize = &v6->uDecompressedSize; - v8 = v6->uDecompressedSize; - v19 = v6->uDecompressedSize; - if ( v3 == (SoundData *)-1 ) - v3 = (SoundData *)pAllocator->AllocNamedChunk(0, v8 + 4, pSoundName_); - SetFilePointer(pAudioPlayer->hAudioSnd, v6->uFileOffset, 0, 0); - v9 = *pDecompressedSize; - if ( (signed int)v6->uCompressedSize >= (signed int)*pDecompressedSize ) + FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName); + if ( uFindSound_BinSearch_ResultID == -1 ) + return 0; + if ( pOutBuff == (SoundData *)-1 ) + pOutBuff = (SoundData *)pAllocator->AllocNamedChunk(0, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize + 4, pSoundName); + SetFilePointer(pAudioPlayer->hAudioSnd, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uFileOffset, 0, 0); + if ( (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize >= (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize ) { - v6->uCompressedSize = v9; - if ( v9 ) + pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize = pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize; + if ( pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize ) { - ReadFile(pAudioPlayer->hAudioSnd, (char *)v3 + 4, v9, &NumberOfBytesRead, 0); + ReadFile(pAudioPlayer->hAudioSnd, (char *)pOutBuff + 4, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize, &NumberOfBytesRead, 0); } else { @@ -2696,38 +2522,25 @@ } else { - uID = (unsigned int)malloc(v6->uCompressedSize); - ReadFile(pAudioPlayer->hAudioSnd, (LPVOID)uID, v6->uCompressedSize, &NumberOfBytesRead, 0); - zlib::MemUnzip((char *)v3 + 4, &v6->uDecompressedSize, (const void *)uID, v6->uCompressedSize); + uID = (unsigned int)malloc(pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize); + ReadFile(pAudioPlayer->hAudioSnd, (LPVOID)uID, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize, &NumberOfBytesRead, 0); + zlib::MemUnzip((char *)pOutBuff + 4, &pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize, (const void *)uID, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize); free((void *)uID); } - if ( v3 ) + if ( pOutBuff ) { - v11 = v19; - v12 = 0; - *(int *)v3 = v19; + *(int *)pOutBuff = pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize; uLastLoadedSoundID = 0; if ( pSounds[0].pSoundData ) { - v13 = (char *)&pSounds[0].pSoundData; - do - { - v13 += 128; - ++v12; - } - while ( *(int *)v13 ); - uLastLoadedSoundID = v12; + for ( uint i = 0; pSounds[i].pSoundData; i++ ) + ++uLastLoadedSoundID; } - v16 = pSounds[v12].SoundName; - strcpy((char *)v16, pSoundName_); - v14 = uLastLoadedSoundID++ << 7; - pSoundList->uTotalLoadedSoundSize += v11; - pSounds[uLastLoadedSoundID].pSoundData = v3; - result = v3; + strcpy((char *)pSounds[uLastLoadedSoundID].SoundName, pSoundName); + pSoundList->uTotalLoadedSoundSize += pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize; + pSounds[uLastLoadedSoundID].pSoundData = pOutBuff; + return pOutBuff; } else - { - result = 0; - } - return result; + return 0; }
--- a/CastSpellInfo.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/CastSpellInfo.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -166,8 +166,8 @@ int v440; // eax@843 int v441; // eax@847 signed int v445; // edi@857 - int v446; // ecx@862 - LevelDecoration *v447; // edi@864 + //int v446; // ecx@862 + //LevelDecoration *v447; // edi@864 __int16 v448; // ax@864 char *v449; // esi@870 int v450; // eax@870 @@ -255,7 +255,7 @@ int v671; // [sp+4h] [bp-E80h]@146 int v675; // [sp+4h] [bp-E80h]@800 int v676; // [sp+4h] [bp-E80h]@807 - int v677; // [sp+4h] [bp-E80h]@861 + //int v677; // [sp+4h] [bp-E80h]@861 int v679[800]; // [sp+14h] [bp-E70h]@515 AIDirection a3; // [sp+C94h] [bp-1F0h]@21 int v681[4]; // [sp+CB0h] [bp-1D4h]@1137 @@ -1955,6 +1955,8 @@ { v730 = 0; } + + __debugbreak(); // castspellinfo.cpp(1962): warning C4700: uninitialized local variable 'v271' used if ( rand() % 100 < 10 * v2 || (rand() % 100 < 80 && (v731 == 3 || v731 == 4 )) || v245->GetValue() < 450 || @@ -1966,6 +1968,7 @@ { v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType]; v245->uEnchantmentType = 0; + __debugbreak(); // castspellinfo.cpp(1971): warning C4700: uninitialized local variable 'v294' used for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1]; ; kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1] ) @@ -2971,31 +2974,26 @@ LODWORD(v727) = 1; break; } - dword_507CD8 = 1; - v677 = 1; + OpenedTelekinesis = true; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - v446 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID; + v448 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID; else - v446 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID; - EventProcessor(v446, a2, v677); + v448 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID; + EventProcessor(v448, a2, 1); LODWORD(v727) = 1; break; } - v447 = &pLevelDecorations[v445]; - dword_507CD8 = 1; - v448 = v447->field_16_event_id; - if (v448) + OpenedTelekinesis = true; + if ( pLevelDecorations[v445].field_16_event_id ) { - v677 = 1; - v446 = v448; - EventProcessor(v446, a2, v677); + EventProcessor(v448, a2, 1); LODWORD(v727) = 1; break; } - if ( v447->IsInteractive() ) + if ( pLevelDecorations[v445].IsInteractive() ) { - activeLevelDecoration = v447; - EventProcessor(stru_5E4C90._decor_events[v447->_idx_in_stru123 - 75] + 380, 0, 1); + activeLevelDecoration = &pLevelDecorations[v445]; + EventProcessor(stru_5E4C90._decor_events[pLevelDecorations[v445]._idx_in_stru123 - 75] + 380, 0, 1); activeLevelDecoration = NULL; } }
--- a/Chest.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/Chest.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -43,44 +43,30 @@ //----- (0042041E) -------------------------------------------------------- bool Chest::Open( signed int uChestID ) { - unsigned int v2; // eax@8 - GUIWindow *v3; // eax@15 - int v5; // edx@16 + unsigned int pMapID; // eax@8 + int pRandom; // edx@16 int v6; // eax@16 - ODMFace *pOdmFace; // eax@19 - int v8; // edx@19 - int v9; // edi@19 - signed int v10; // ebx@19 - int v11; // ecx@19 - int v12; // eax@19 - BLVFace *pBlvFace; // eax@20 - int v14; // ebx@21 - int v15; // edi@21 - __int64 v17; // qax@22 - double v18; // st7@23 - double v19; // st6@23 - double v20; // st7@23 - int v21; // ecx@26 - char v22[12]; // ST4C_12@28 - unsigned int *v23; // edi@28 - unsigned __int16 v24; // di@28 - signed int v25; // ecx@28 - char *v26; // edx@29 - unsigned __int16 v27; // ax@32 - int v29[4]; // [sp+84h] [bp-40h]@16 - float v33; // [sp+94h] [bp-30h]@23 + ODMFace *pODMFace; // eax@19 + BLVFace *pBLVFace; // eax@20 + int pObjectX; // ebx@21 + int pObjectZ; // edi@21 + double dir_x; // st7@23 + double dir_y; // st6@23 + double length_vector; // st7@23 + int pDepth; // ecx@26 + Vec3_int_ v; // ST4C_12@28 + bool flag_shout; // edi@28 + int pSpriteID[4]; // [sp+84h] [bp-40h]@16 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 - int a4; // [sp+ACh] [bp-18h]@1 - int v38; // [sp+B0h] [bp-14h]@21 + int pObjectY; // [sp+B0h] [bp-14h]@21 int sRotX; // [sp+B4h] [bp-10h]@23 - float v40; // [sp+B8h] [bp-Ch]@23 - float v41; // [sp+BCh] [bp-8h]@23 + float dir_z; // [sp+BCh] [bp-8h]@23 int sRotY; // [sp+C0h] [bp-4h]@8 - SpriteObject a1; // [sp+14h] [bp-B0h]@28 + SpriteObject pSpellObject; // [sp+14h] [bp-B0h]@28 - assert(uChestID < 20); - if ((uChestID <0)&&(uChestID >=20) ) - return false; + assert( uChestID < 20 ); + if ( ( uChestID < 0 ) && ( uChestID >= 20 ) ) + return false; auto chest = &pChests[uChestID]; ++pIcons_LOD->uTexturePacksCount; @@ -92,144 +78,118 @@ if ( !uActiveCharacter ) return false; - *(float *)&sRotY = 0.0; - v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); - if ( !chest->Trapped() || !v2 ) - goto LABEL_12; - if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) + flag_shout = false; + pMapID = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( chest->Trapped() && pMapID ) { - v29[0] = 811; - v29[1] = 812; - v29[2] = 813; - v29[3] = 814; - v5 = rand() % 4; - v6 = PID_ID(EvtTargetObj); - if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) + if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[pMapID].LockX5 ) { - v14 = pLevelDecorations[v6].vPosition.x; - v38 = pLevelDecorations[v6].vPosition.y; - v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight; - v15 = pLevelDecorations[v6].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1); - } - else - { - if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel) - goto LABEL_12; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pSpriteID[0] = 811; + pSpriteID[1] = 812; + pSpriteID[2] = 813; + pSpriteID[3] = 814; + pRandom = rand() % 4; + v6 = PID_ID(EvtTargetObj); + if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) + { + pObjectX = pLevelDecorations[v6].vPosition.x; + pObjectY = pLevelDecorations[v6].vPosition.y; + pObjectZ = pLevelDecorations[v6].vPosition.z + ( pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight / 2 ); + } + if ( PID_TYPE(EvtTargetObj) == OBJECT_BModel) { - pOdmFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; - v8 = pOdmFace->pBoundingBox.y1; - v9 = pOdmFace->pBoundingBox.z2; - v10 = pOdmFace->pBoundingBox.x1 + pOdmFace->pBoundingBox.x2; - v11 = pOdmFace->pBoundingBox.y2; - v12 = pOdmFace->pBoundingBox.z1; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + pODMFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; + pObjectX = ( pODMFace->pBoundingBox.x1 + pODMFace->pBoundingBox.x2 ) / 2; + pObjectY = ( pODMFace->pBoundingBox.y1 + pODMFace->pBoundingBox.y2 ) / 2; + pObjectZ = ( pODMFace->pBoundingBox.z1 + pODMFace->pBoundingBox.z2 ) / 2; + } + else//Indoor + { + pBLVFace = &pIndoor->pFaces[v6]; + pObjectX = ( pBLVFace->pBounding.x1 + pBLVFace->pBounding.x2 ) / 2; + pObjectY = ( pBLVFace->pBounding.y1 + pBLVFace->pBounding.y2 ) / 2; + pObjectZ = ( pBLVFace->pBounding.z1 + pBLVFace->pBounding.z2 ) / 2; + } + } + dir_x = (double)pParty->vPosition.x - (double)pObjectX; + dir_y = (double)pParty->vPosition.y - (double)pObjectY; + dir_z = ( (double)pParty->sEyelevel + (double)pParty->vPosition.z ) - (double)pObjectZ; + length_vector = sqrt( (dir_x * dir_x) + (dir_y * dir_y) + (dir_z * dir_z) ); + if ( length_vector <= 1.0 ) + { + *(float *)&sRotX = 0.0; + *(float *)&sRotY = 0.0; } else { - pBlvFace = &pIndoor->pFaces[v6]; - v8 = pBlvFace->pBounding.y1; - v9 = pBlvFace->pBounding.z2; - v10 = pBlvFace->pBounding.x1 + pBlvFace->pBounding.x2; - v11 = pBlvFace->pBounding.y2; - v12 = pBlvFace->pBounding.z1; + sRotY = (signed __int64)sqrt(dir_x * dir_x + dir_y * dir_y); + sRotX = stru_5C6E00->Atan2((signed __int64)dir_x, (signed __int64)dir_y); + sRotY = stru_5C6E00->Atan2(dir_y * dir_y, (signed __int64)dir_z); } - v14 = v10 >> 1; - v38 = (v8 + v11) >> 1; - v15 = (v12 + v9) >> 1; - } - v18 = (double)pParty->vPosition.x - (double)v14; - *(float *)&a4 = v18; - v19 = (double)pParty->vPosition.y - (double)v38; - v33 = v19; - v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15; - *(float *)&sRotY = v19 * v19; - *(float *)&sRotX = v18 * v18; - v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY); - v40 = v20; - if ( v20 <= 1.0 ) - { - *(float *)&sRotX = 0.0; - *(float *)&sRotY = 0.0; - } - else - { - sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY); - sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33); - sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41); - } - v21 = 256; - if ( v40 < 256.0 ) - v21 = (signed __int64)v40 / 4; - *(int *)&v22[8] = v15; - *(_QWORD *)v22 = __PAIR__(v38, v14); - Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y); - v23 = (unsigned int *)(&v29 + v5); - sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); + pDepth = 256; + if ( length_vector < 256.0 ) + pDepth = (signed __int64)length_vector / 4; + v.x = pObjectX; + v.y = pObjectY; + v.z = pObjectZ; + Vec3_int_::Rotate(pDepth, sRotX, sRotY, v, &pOut.x, &pOut.z, &pOut.y); + sub_42F7EB_DropItemAt(pSpriteID[pRandom], pOut.x, pOut.z, pOut.y, 0, 1, 0, 48, 0); - a1.stru_24.Reset(); - v24 = *(short *)v23; - v25 = 0; - a1.spell_skill = 0; - a1.spell_level = 0; - a1.spell_id = 0; - a1.field_54 = 0; - a1.uType = v24; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_32: - v27 = 0; - } - else - { - v26 = (char *)&pObjectList->pObjects->uObjectID; - while ( v24 != *(short *)v26 ) + pSpellObject.stru_24.Reset(); + pSpellObject.spell_skill = 0; + pSpellObject.spell_level = 0; + pSpellObject.spell_id = 0; + pSpellObject.field_54 = 0; + pSpellObject.uType = pSpriteID[pRandom]; + pSpellObject.uObjectDescID = 0; + if ( pObjectList->uNumObjects ) { - ++v25; - v26 += 56; - if ( v25 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_32; + for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) + { + if ( pSpriteID[pRandom] == pObjectList->pObjects[i].uObjectID ) + pSpellObject.uObjectDescID = i; + } } - v27 = v25; + pSpellObject.vPosition.y = pOut.z; + pSpellObject.vPosition.x = pOut.x; + pSpellObject.vPosition.z = pOut.y; + pSpellObject.uSoundID = 0; + pSpellObject.uAttributes = 48; + pSpellObject.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); + pSpellObject.uSpriteFrameID = 0; + pSpellObject.spell_caster_pid = 0; + pSpellObject.spell_target_pid = 0; + pSpellObject.uFacing = 0; + pSpellObject.Create(0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); + pSpellObject.ExplosionTraps(); + chest->uFlags &= 0xFEu; + if ( uActiveCharacter && !qword_A750D8 && !OpenedTelekinesis ) + { + qword_A750D8 = 256i64; + PlayerSpeechID = SPEECH_5; + uSpeakingCharacter = uActiveCharacter; + } + pIcons_LOD->RemoveTexturesPackFromTextureList(); + OpenedTelekinesis = false; + return false; } - a1.uObjectDescID = v27; - a1.vPosition.y = pOut.z; - a1.vPosition.x = pOut.x; - a1.vPosition.z = pOut.y; - a1.uSoundID = 0; - a1.uAttributes = 48; - a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = 0; - a1.spell_target_pid = 0; - a1.uFacing = 0; - a1.Create(0, 0, 0, 0); - pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); - a1._438E35(); - chest->SetInitialized(false);//*v34 &= 0xFEu; - if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) - { - qword_A750D8 = 256i64; - word_A750E0 = 5; - word_A750E2 = uActiveCharacter; - } - pIcons_LOD->RemoveTexturesPackFromTextureList(); - dword_507CD8 = 0; - return false; + chest->uFlags &= 0xFEu; + flag_shout = true; } - chest->SetInitialized(false);//*v1 &= 0xFEu; - sRotY = 1; -LABEL_12: pAudioPlayer->StopChannels(-1, -1); pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0); - if ( *(float *)&sRotY != 0.0 ) + if ( flag_shout == true ) { - if ( !dword_507CD8 ) + if ( !OpenedTelekinesis ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); } - dword_507CD8 = 0; + OpenedTelekinesis = false; pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0); - pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit - pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); + pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit + pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); pCurrentScreen = SCREEN_CHEST; pEventTimer->Pause(); return true;
--- a/DecalBuilder.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/DecalBuilder.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -401,6 +401,7 @@ { v40 = (int)&a8; v39 = v12->pVertices; + __debugbreak(); // warning C4700: uninitialized local variable 'v31' used pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, &a8b); v40 = (int)v31; v39 = v12->pVertices;
--- a/Events2D.h Sat Jul 27 09:36:29 2013 +0600 +++ b/Events2D.h Sat Jul 27 09:36:55 2013 +0600 @@ -1,46 +1,46 @@ #pragma once /* 296 */ -enum BildingType: unsigned short +enum BuildingType: unsigned short { - BildingType_WeaponShop = 1, - BildingType_ArmorShop = 2, - BildingType_MagicShop = 3, - BildingType_AlchemistShop = 4, - BildingType_FireGuild = 5, - BildingType_AirGuild = 6, - BildingType_WaterGuild = 7, - BildingType_EarthGuild = 8, - BildingType_SpiritGuild = 9, - BildingType_MindGuild = 10, - BildingType_BodyGuild = 11, - BildingType_LightGuild = 12, - BildingType_DarkGuild = 13, - BildingType_14 = 14, - BildingType_15 = 15, - BildingType_16 = 16, - BildingType_TownHall = 17, - BildingType_18 = 18, - BildingType_19 = 19, - BildingType_Throne_Room = 20, - BildingType_Tavern = 21, - BildingType_Bank = 22, - BildingType_Temple = 23, + BuildingType_WeaponShop = 1, + BuildingType_ArmorShop = 2, + BuildingType_MagicShop = 3, + BuildingType_AlchemistShop = 4, + BuildingType_FireGuild = 5, + BuildingType_AirGuild = 6, + BuildingType_WaterGuild = 7, + BuildingType_EarthGuild = 8, + BuildingType_SpiritGuild = 9, + BuildingType_MindGuild = 10, + BuildingType_BodyGuild = 11, + BuildingType_LightGuild = 12, + BuildingType_DarkGuild = 13, + BuildingType_14 = 14, + BuildingType_15 = 15, + BuildingType_16 = 16, + BuildingType_TownHall = 17, + BuildingType_18 = 18, + BuildingType_19 = 19, + BuildingType_Throne_Room = 20, + BuildingType_Tavern = 21, + BuildingType_Bank = 22, + BuildingType_Temple = 23, BuildingType_24 = 24, - BildingType_Unic = 25, - BildingType_1A = 26, - BildingType_Stables = 27, - BildingType_Boats = 28, - BildingType_House = 29, - BildingType_Training = 30, - BildingType_Jail = 31 + BuildingType_Unic = 25, + BuildingType_1A = 26, + BuildingType_Stables = 27, + BuildingType_Boats = 28, + BuildingType_House = 29, + BuildingType_Training = 30, + BuildingType_Jail = 31 }; /* 168 */ #pragma pack(push, 1) struct _2devent { - BildingType uType; + BuildingType uType; unsigned __int16 uAnimationID; char *pName; const char *pProprieterName;
--- a/GUIWindow.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/GUIWindow.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -249,11 +249,11 @@ //----- (0041D08F) -------------------------------------------------------- -void GUIWindow::_41D08F_set_keyboard_control_group(int a2, int a3, int a4, int a5) +void GUIWindow::_41D08F_set_keyboard_control_group(int num_buttons, int a3, int a4, int a5) { - if ( a2 ) + if (num_buttons) { - this->pNumPresenceButton = a2; + this->pNumPresenceButton = num_buttons; this->field_30 = a3; this->field_34 = a4; this->pCurrentPosActiveItem = a5; @@ -468,7 +468,8 @@ else if ( v18 & 0x40 ) max_beacons = 3; - + + __debugbreak(); // warning C4700: uninitialized local variable 'v19' used for (int i =0; i< max_beacons; ++i) CreateButton(pLloydsBeaconsPreviewXs[v19], pLloydsBeaconsPreviewYs[v19], 92, 68, 1, 180, UIMSG_InstallBeacon, i, 0, "", 0); @@ -670,7 +671,7 @@ { if ( v4 ) { - v5 = BuilDialogueString(v4, uActiveCharacter - 1, 0, 0, 0, v3); + v5 = BuildDialogueString(v4, uActiveCharacter - 1, 0, 0, 0, v3); v6 = pAutonoteFont->CalcTextHeight(v5, &v26, 1, 0); v7 = (v6 - 3) / (signed int)v26.uFrameHeight; v8 = v7 + 1; @@ -949,7 +950,7 @@ pWindow.uFrameZ += 8; if ( !pDialogueNPCCount ) { - if ( in_current_building_type == BildingType_Jail ) + if ( in_current_building_type == BuildingType_Jail ) { JailDialog(); if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) @@ -1056,56 +1057,56 @@ pWindow.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, pColor2, pTmpBuf.data(), 3); switch ( in_current_building_type ) { - case BildingType_WeaponShop: + case BuildingType_WeaponShop: WeaponShopDialog(); break; - case BildingType_ArmorShop: + case BuildingType_ArmorShop: ArmorShopDialog(); break; - case BildingType_MagicShop: + case BuildingType_MagicShop: MagicShopDialog(); break; - case BildingType_AlchemistShop: + case BuildingType_AlchemistShop: AlchemistDialog(); break; - case BildingType_FireGuild: - case BildingType_AirGuild: - case BildingType_WaterGuild: - case BildingType_EarthGuild: - case BildingType_SpiritGuild: - case BildingType_MindGuild: - case BildingType_BodyGuild: - case BildingType_LightGuild: - case BildingType_DarkGuild: + case BuildingType_FireGuild: + case BuildingType_AirGuild: + case BuildingType_WaterGuild: + case BuildingType_EarthGuild: + case BuildingType_SpiritGuild: + case BuildingType_MindGuild: + case BuildingType_BodyGuild: + case BuildingType_LightGuild: + case BuildingType_DarkGuild: GuildDialog(); break; - case BildingType_18: + case BuildingType_18: __debugbreak(); //What over the dialog? sub_4B6478(); break; - case BildingType_TownHall: + case BuildingType_TownHall: TownHallDialog(); break; - case BildingType_Tavern: + case BuildingType_Tavern: TavernDialog(); break; - case BildingType_Bank: + case BuildingType_Bank: BankDialog(); break; - case BildingType_Temple: + case BuildingType_Temple: TempleDialog(); break; - case BildingType_Stables: + case BuildingType_Stables: TravelByTransport(); break; - case BildingType_Training: + case BuildingType_Training: TrainingDialog(); break; - case BildingType_Jail: + case BuildingType_Jail: JailDialog(); break; default: - __debugbreak();//New BildingType + __debugbreak();//New BuildingType break; } }
--- a/GUIWindow.h Sat Jul 27 09:36:29 2013 +0600 +++ b/GUIWindow.h Sat Jul 27 09:36:55 2013 +0600 @@ -337,7 +337,7 @@ void DrawMessageBox(int arg0); GUIButton *GetControl(unsigned int uID); void Release(); - void _41D08F_set_keyboard_control_group(int a2, int a3, int a4, int a5); + void _41D08F_set_keyboard_control_group(int num_buttons, int a3, int a4, int a5); void _41D73D_draw_buff_tooltip(); static GUIWindow *Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eWindowType, int pButton, const char* hint);
--- a/Indoor.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/Indoor.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -62,7 +62,6 @@ stru320 stru_F8AD28; // idb stru337 stru_F81018; -stru167_wrap array_5118E8; BspRenderer_PortalViewportData stru_F8A590; BspRenderer *pBspRenderer = new BspRenderer; // idb stru141 stru_721530; @@ -412,7 +411,7 @@ sub_440BED(&_this); pParty->uFlags &= ~2; pGame->DrawParticles(); - array_5118E8._440F07(); + trail_particle_generator.UpdateParticles(); } //----- (004C0EF2) -------------------------------------------------------- @@ -4011,8 +4010,8 @@ if ( pDest ) { qword_A750D8 = 256i64; - word_A750E0 = 46; - word_A750E2 = LOWORD(v34[rand() % v30]); + PlayerSpeechID = SPEECH_46; + uSpeakingCharacter = LOWORD(v34[rand() % v30]); } } } @@ -6908,4 +6907,51 @@ PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; } return bottom_num_vertices; +} + +//----- (004AAEA6) -------------------------------------------------------- +int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1) +{ + double v4; // st5@2 + double v5; // st4@3 + float v11; // [sp+8h] [bp-8h]@2 + float v12; // [sp+8h] [bp-8h]@6 + float v13; // [sp+Ch] [bp-4h]@2 + float v14; // [sp+Ch] [bp-4h]@6 + + if ( pBLVRenderParams->sPartyRotX ) + { + v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x; + v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y; + v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z; + if ( pRenderer->pRenderD3D ) + { + v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY; + a1->vWorldViewPosition.y = v13 * pBLVRenderParams->fSineY - v11 * pBLVRenderParams->fCosineY; + } + else + { + v5 = v13 * pBLVRenderParams->fCosineY - v11 * pBLVRenderParams->fSineY; + a1->vWorldViewPosition.y = v13 * pBLVRenderParams->fSineY + v11 * pBLVRenderParams->fCosineY; + } + a1->vWorldViewPosition.x = v5 * pBLVRenderParams->fCosineNegX - v4 * pBLVRenderParams->fSineNegX; + a1->vWorldViewPosition.z = v5 * pBLVRenderParams->fSineNegX + v4 * pBLVRenderParams->fCosineNegX; + } + else + { + v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x; + v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y; + a1->vWorldViewPosition.z = a1->vWorldPosition.z - (double)pParty->vPosition.z; + if ( pRenderer->pRenderD3D ) + { + a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY; + a1->vWorldViewPosition.y = v14 * pBLVRenderParams->fSineY - v12 * pBLVRenderParams->fCosineY; + } + else + { + a1->vWorldViewPosition.x = v14 * pBLVRenderParams->fCosineY - v12 * pBLVRenderParams->fSineY; + a1->vWorldViewPosition.y = v14 * pBLVRenderParams->fSineY + v12 * pBLVRenderParams->fCosineY; + } + } + return 0; } \ No newline at end of file
--- a/Indoor_stuff.h Sat Jul 27 09:36:29 2013 +0600 +++ b/Indoor_stuff.h Sat Jul 27 09:36:55 2013 +0600 @@ -111,52 +111,6 @@ -/* 160 */ -#pragma pack(push, 1) -struct stru167 -{ - char field_0; - char field_1; - char field_2; - char field_3; - char field_4; - char field_5; - __int16 field_6_rnd_value; - __int16 field_8_rnd_value; - __int16 field_A_rnd_value; - __int16 field_C_time_left; - __int16 field_E_time_to_live; - char field_10; - char field_11; - char field_12; - char field_13; - __int16 bgr16; - char field_16; - char field_17; -}; -#pragma pack(pop) - - - -/* 363 */ -#pragma pack(push, 1) -struct stru167_wrap -{ - void _440F07(); - int Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr); - void _440E91(__int16 x, int y, int z, int a5, __int16 bgr); - - stru167 pElements[100]; - int uNumElements; - int field_964; -}; -#pragma pack(pop) -extern stru167_wrap array_5118E8; - - - - -
--- a/LightmapBuilder.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/LightmapBuilder.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -741,6 +741,7 @@ v5 = (char *)&a1->flt_2C; do { + __debugbreak(); // warning C4700: uninitialized local variable 'v7' used if ( *(float *)v5 < 0.0 || (v6 = *(float *)v5, /*UNDEF(v7),*/ v8 = 1.0 < v6, v9 = 0, v10 = 1.0 == v6, LOWORD(result) = v7, v6 <= 1.0) ) { @@ -749,6 +750,7 @@ v14 = 0.0 < v12; v15 = 0; v16 = 0.0 == v12; + __debugbreak(); // warning C4700: uninitialized local variable 'v13' used LOWORD(result) = v13; if ( v12 >= 0.0 ) v11 = *(float *)v5; @@ -880,6 +882,7 @@ a1.Normalize(); if ( uLightType & 4 ) { + __debugbreak(); // warning C4700: uninitialized local variable 'v18' used v22[1] = v18; uLightType = dword_4D86D8; v22[0] = v18; @@ -1473,6 +1476,7 @@ v25 = 1.0; } v9->field_10 = v25; + __debugbreak(); // warning C4700: uninitialized local variable 'v27' used if ( v9->field_14 < 0.0 || (v26 = v9->field_14, //UNDEF(v27), @@ -1487,6 +1491,7 @@ v34 = 0.0 < v32; v35 = 0; v36 = 0.0 == v32; + __debugbreak(); // warning C4700: uninitialized local variable 'v33' used BYTE1(result) = HIBYTE(v33); if ( v32 >= 0.0 ) v31 = v9->field_14;
--- a/NPC.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/NPC.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -1312,7 +1312,7 @@ { case 13: current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession); - current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); + current_npc_text = BuildDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); NPCHireableDialogPrepare(); dialogue_show_profession_details = false; goto _return; @@ -1391,7 +1391,7 @@ else v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pBenefits; current_npc_text = v17; - v18 = BuilDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); + v18 = BuildDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); dialogue_show_profession_details = ~dialogue_show_profession_details; current_npc_text = v18; } @@ -1511,7 +1511,7 @@ dialogue_show_profession_details = false; uDialogueType = 13; current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText; - current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); + current_npc_text = BuildDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); if ( uActiveCharacter ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); @@ -1657,7 +1657,7 @@ pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); if ( pDialogueNPCCount == 1 && dword_591080 ) { - sub_4B3B42(in_current_building_type); + InitializaDialogueOptions(in_current_building_type); } else {
--- a/Outdoor.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/Outdoor.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -28,6 +28,7 @@ #include "Time.h" #include "Viewport.h" #include "Events.h" +#include "ParticleEngine.h" #include "mm7_data.h" #include "MM7.h" @@ -195,7 +196,7 @@ pGame->DrawParticles(); pWeather->Draw(); - array_5118E8._440F07(); + trail_particle_generator.UpdateParticles(); } //----- (00488E23) -------------------------------------------------------- @@ -782,7 +783,7 @@ a3d = v22 * v19 - v21 * v18; v16 = a3d + 6.7553994e15; v3->v_18.z = LODWORD(v16); - v3->_486089_normalize_v_18(); + v3->_normalize_v_18(); a3e = -((double)v3->v_18.x * v4->vWorldViewPosition.x) - (double)v3->v_18.y * v4->vWorldViewPosition.y - (double)v3->v_18.z * v4->vWorldViewPosition.z;
--- a/Outdoor_stuff.h Sat Jul 27 09:36:29 2013 +0600 +++ b/Outdoor_stuff.h Sat Jul 27 09:36:55 2013 +0600 @@ -18,7 +18,7 @@ int _479295(); void DrawBorderTiles(); //void _48276F_sr(); - void _486089_normalize_v_18(); + void _normalize_v_18(); void _48607B(struct stru149 *a2); float field_0;
--- a/ParticleEngine.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/ParticleEngine.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -12,6 +12,47 @@ #include "OutdoorCamera.h" #include "mm7_data.h" +TrailParticleGenerator trail_particle_generator; + + +//----- (00440DF5) -------------------------------------------------------- +void TrailParticleGenerator::AddParticle(int x, int y, int z, int bgr16) +{ + particles[num_particles].x = x; + particles[num_particles].y = y; + particles[num_particles].z = z; + particles[num_particles].time_to_live = rand() % 64 + 256; + particles[num_particles].time_left = particles[num_particles].time_to_live; + particles[num_particles].bgr16 = bgr16; + + num_particles++; + assert(num_particles < 100); +} + +//----- (00440E91) -------------------------------------------------------- +void TrailParticleGenerator::GenerateTrailParticles(int x, int y, int z, int bgr16) +{ + for (int i = 0; i < 5 + rand() % 6; ++i) + AddParticle(rand() % 33 + x - 16, + rand() % 33 + y - 16, + rand() % 33 + z, bgr16); +} + +//----- (00440F07) -------------------------------------------------------- +void TrailParticleGenerator::UpdateParticles() +{ + for (uint i = 0; i < 100; ++i) + { + if (particles[i].time_left > 0) + { + particles[i].x += rand() % 5 + 4; + particles[i].y += rand() % 5 - 2; + particles[i].z += rand() % 5 - 2; + particles[i].time_left -= pEventTimer->uTimeElapsed; + } + } +} + //----- (0048AAC5) -------------------------------------------------------- ParticleEngine::ParticleEngine() {
--- a/ParticleEngine.h Sat Jul 27 09:36:29 2013 +0600 +++ b/ParticleEngine.h Sat Jul 27 09:36:55 2013 +0600 @@ -127,4 +127,73 @@ int uEndParticle; int uTimeElapsed; }; -#pragma pack(pop) \ No newline at end of file +#pragma pack(pop) + + + + + + + + + + + +/* 160 */ +#pragma pack(push, 1) +struct TrailParticle // stru167 +{ + inline TrailParticle() + { + x = 0; + y = 0; + z = 0; + time_left = 0; + time_to_live = 0; + bgr16 = 0; + } + + char field_0; + char field_1; + char field_2; + char field_3; + char field_4; + char field_5; + __int16 x; + __int16 y; + __int16 z; + __int16 time_left; + __int16 time_to_live; + char field_10; + char field_11; + char field_12; + char field_13; + __int16 bgr16; + char field_16; + char field_17; +}; +#pragma pack(pop) + + +/* 363 */ +#pragma pack(push, 1) +struct TrailParticleGenerator // stru167_wrap +{ + public: + inline TrailParticleGenerator() + { + num_particles = 0; + } + + void GenerateTrailParticles(int x, int y, int z, int bgr16); + void UpdateParticles(); + + protected: + void AddParticle(int x, int y, int z, int bgr16); + + TrailParticle particles[100]; + int num_particles; + int field_964; +}; +#pragma pack(pop) +extern TrailParticleGenerator trail_particle_generator; // 005118E8 \ No newline at end of file
--- a/Player.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/Player.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -529,35 +529,22 @@ { signed int speechCount = 0; // esi@4 signed int expressionCount = 0; // esi@4 - unsigned __int8 v8; // al@6 int pickedVariant; // esi@10 - int v14; // eax@12 CHARACTER_EXPRESSION_ID expression; // ebx@17 - signed int v17; // ecx@19 - unsigned int pSoundID; // edi@20 + signed int pSoundID; // ecx@19 int speechVariantArray[5]; // [sp+Ch] [bp-1Ch]@7 int expressionVariantArray[5]; - int pPlayerNum; // [sp+24h] [bp-4h]@1 unsigned int pickedSoundID; // [sp+30h] [bp+8h]@4 unsigned int expressionDuration = 0; - pPlayerNum = 1; - for (int i = 0; i < 4; ++i) - if (&pParty->pPlayers[i] == this) - { - pPlayerNum = i + 1; - break; - } - pickedSoundID = 0; if (uVoicesVolumeMultiplier) { for (int i = 0; i < 2; i++) { - v8 = SoundSetAction[speech][i]; - if ( v8 ) - { - speechVariantArray[speechCount] = v8; + if ( SoundSetAction[speech][i] ) + { + speechVariantArray[speechCount] = SoundSetAction[speech][i]; speechCount++; } } @@ -568,17 +555,16 @@ if (numberOfSubvariants > 0) { pickedSoundID = rand() % numberOfSubvariants + 2 * (pickedVariant + 50 * uVoiceID) + 4998; - pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, pPlayerNum + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0); + pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, uActiveCharacter + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0); } } } for (int i = 0; i < 5; i++) { - v14 = SoundSetAction[speech][i + 3]; - if ( v14 ) - { - expressionVariantArray[expressionCount] = v14; + if ( SoundSetAction[speech][i + 3] ) + { + expressionVariantArray[expressionCount] = SoundSetAction[speech][i + 3]; expressionCount++; } } @@ -587,25 +573,16 @@ expression = (CHARACTER_EXPRESSION_ID)expressionVariantArray[rand() % expressionCount]; if (expression == CHARACTER_EXPRESSION_21 && pickedSoundID ) { - if ( (signed int)pSoundList->sNumSounds <= 0 ) - { - v17 = 0; - } - else - { - pSoundID = pSoundList->pSounds[0].uSoundID; - v17 = 0; + pSoundID = 0; + if ( pSoundList->sNumSounds ) + { for (int i = 0; i < pSoundList->sNumSounds; i++) { - v17 = i; - if (pSoundID == pickedSoundID) - { - break; - } - pSoundID += 120; + if (pSoundList->pSounds[i].uSoundID == pickedSoundID) + pSoundID = i; } } - if ( pSoundList->pSounds[v17].pSoundData[0] ) + if ( pSoundList->pSounds[pSoundID].pSoundData[0] ) expressionDuration = (sLastTrackLengthMS << 7) / 1000; } PlayEmotion(expression, expressionDuration); @@ -1089,25 +1066,25 @@ switch (building_type) { - case BildingType_WeaponShop: + case BuildingType_WeaponShop: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) return 5; if (equipType > EQUIP_BOW) return 4; break; - case BildingType_ArmorShop: + case BuildingType_ArmorShop: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) return 5; if ( equipType < EQUIP_ARMOUR || equipType > EQUIP_BOOTS) return 4; break; - case BildingType_MagicShop: + case BuildingType_MagicShop: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) return 5; if ( pItemsTable->pItems[idemId].uSkillType != PLAYER_SKILL_MISC ) return 4; break; - case BildingType_AlchemistShop: + case BuildingType_AlchemistShop: if ((idemId >= ITEM_ARTIFACT_HERMES_SANDALS && idemId < ITEM_RECIPE_REJUVENATION) || idemId > ITEM_RECIPE_BODY_RESISTANCE) return 5; if ( !(equipType == EQUIP_REAGENT || equipType == EQUIP_POTION || equipType == EQUIP_MESSAGE_SCROLL)) @@ -2891,6 +2868,7 @@ { if ( HasItemEquipped((ITEM_EQUIP_TYPE)v14) ) { + __debugbreak(); // player.cpp(2871): warning C4700: uninitialized local variable 'v15' used if ( v15 == EQUIP_ARMOUR ) v46[v4++] = LOBYTE(v5->pEquipment.uArmor) - 1; if ( (!v15 || v15 == 1) && GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v15) == 4 ) @@ -2906,6 +2884,7 @@ { if ( HasItemEquipped((ITEM_EQUIP_TYPE)v16) ) { + __debugbreak(); // player.cpp(2886): warning C4700: uninitialized local variable 'v17' used if ( v17 == 2 ) v46[v4++] = LOBYTE(v5->pEquipment.uBow) - 1; if ( (!v17 || v17 == 1) @@ -3710,7 +3689,7 @@ Player *v21; // ecx@75 int v22; // eax@76 int v23; // edx@76 - int v24; // eax@79 + //int v24; // eax@79 int v25; // ecx@80 int v26; // edi@80 Player *v27; // ecx@84 @@ -4408,16 +4387,15 @@ v23 = this->pOwnItems[this->pEquipment.uMainHand].uItemID; if ( v6->pEquipment.uShield || pItemsTable->pItems[v23].uSkillType != 4 ) { - v24 = v23; v26 = pItemsTable->pItems[v23].uDamageRoll; v25 = pItemsTable->pItems[v23].uDamageDice; } else { - v25 = pItemsTable->pItems[v24].uDamageRoll; - v26 = pItemsTable->pItems[v24].uDamageDice + 1; + v25 = pItemsTable->pItems[v23].uDamageRoll; + v26 = pItemsTable->pItems[v23].uDamageDice + 1; } - v5 = pItemsTable->pItems[v24].uDamageMod + v25 * v26; + v5 = pItemsTable->pItems[v23].uDamageMod + v25 * v26; } } } @@ -5271,6 +5249,7 @@ assert(false && "Unknown attribute!"); + return 0; } //----- (00490109) -------------------------------------------------------- @@ -5352,10 +5331,9 @@ case 0x15u: case 0x18u: return SEX_FEMALE; - - default: - assert(false); - } + } + assert(false); + return SEX_MALE; } //----- (00490188) -------------------------------------------------------- @@ -5603,6 +5581,8 @@ ++counter; } } + + assert(false); } @@ -8655,6 +8635,9 @@ return false; } } + + assert(false); + return false; } // 5B65C4: using guessed type int dword_5B65C4; // 5B65CC: using guessed type int dword_5B65CC; @@ -8768,6 +8751,7 @@ result = Player_has_item(v5, *pPlayers, 0); if ( !result ) break; + __debugbreak(); // player.cpp(8748): warning C4700: uninitialized local variable 'v6' used result = v6->pEquipment.uArmor; if ( !result ) break; @@ -8782,6 +8766,8 @@ goto LABEL_6; } result = Player_has_item(604u, ::pPlayers[a1], 0); + __debugbreak(); // player.cpp(8764): warning C4700: uninitialized local variable 'v2' used + __debugbreak(); // player.cpp(8764): warning C4700: uninitialized local variable 'v3' used if ( !result || (result = v2->pEquipment.uArmor) == 0 || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) ) @@ -9382,8 +9368,8 @@ if ( v38 == OBJECT_Player && !qword_A750D8 ) { qword_A750D8 = 256i64; - word_A750E0 = 44; - word_A750E2 = uActorID + 1; + PlayerSpeechID = SPEECH_44; + uSpeakingCharacter = uActorID + 1; } return; }
--- a/Render.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/Render.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -25,7 +25,6 @@ #include "Time.h" #include "Game.h" #include "LightmapBuilder.h" -#include "stru220.h" #include "ObjectList.h" #include "SpriteObject.h" #include "DecorationList.h" @@ -517,7 +516,7 @@ v6 = abs(v83);//v6 = 13108 --X; //__debugbreak(); // uncoment & refactor following large if - v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; + v93 = (int)&terrain_76E5C8[(v5 << 7) + v6]; /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), ((a8 = v9, @@ -538,8 +537,8 @@ WorldPosToGridCellZ(sY), !byte_4D864C) || !(pGame->uFlags & 0x80)) - && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ - /*if ( !&stru_76E5C8[(v5 << 7) + v6] ) + && !_481EFA_clip_terrain_poly(v8, v9, v101, pVertices, 1)) )*/ + /*if ( !&terrain_76E5C8[(v5 << 7) + v6] ) goto LABEL_162*/ v8 = &pVerticesSR_806210[v4]; //pVertices2 = &pVerticesSR_801A10[v4 + 1]; @@ -560,7 +559,7 @@ v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); /*WorldPosToGridCellX(sX); WorldPosToGridCellZ(sY); - if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) + if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !_481EFA_clip_terrain_poly(v8, pVertices, v101, pVertices2, 1)) if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) break;*/ @@ -572,6 +571,7 @@ pTile->field_32 = 0; pTile->field_59 = 1; pTile->terrain_grid_x = (char)v97; + __debugbreak(); // warning C4700: uninitialized local variable 'v93' used pTile->field_34 = *(_WORD *)(v93 + 2); pTile->terrain_grid_z = v89; v22 = pTerrainNormalIndices[2 * (v97 + 128 * v89) + 1]; @@ -589,12 +589,13 @@ if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; ++pOutdoorCamera->uNumPolygons; - //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary + //if ( !_481FC9_terrain(v8, pVertices, v101, v16) )//Ritor1: It's temporary //goto LABEL_126; //{ //--pOutdoorCamera->uNumPolygons; //goto LABEL_162; //} + __debugbreak(); // warning C4700: uninitialized local variable 'v102' used memcpy(&array_50AC10[0], v102, 0x30u); array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[0].u = 0.0; @@ -603,6 +604,7 @@ array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[1].u = 0.0; array_50AC10[1].v = 1.0; + __debugbreak(); // warning C4700: uninitialized local variable 'pVertices2' used memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[2].u = 1.0; @@ -728,7 +730,7 @@ if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; ++pOutdoorCamera->uNumPolygons; - /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary + /*if ( !_481FC9_terrain(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary //goto LABEL_77; { --pOutdoorCamera->uNumPolygons; @@ -857,7 +859,7 @@ if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; ++pOutdoorCamera->uNumPolygons; - if ( !sub_481FC9(v101, v102, pVertices2, v59) ) + if ( !_481FC9_terrain(v101, v102, pVertices2, v59) ) { //LABEL_126: --pOutdoorCamera->uNumPolygons; @@ -1012,11 +1014,12 @@ billboard.uFlags = pBillboard->field_1E; if (pBillboard->uHwSpriteID != -1) { - if (pRenderer->pRenderD3D) + if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering + //if (pRenderer->pRenderD3D) pRenderer->TransformBillboard(&billboard, &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], pBillboard->dimming_level, pBillboard); - else + /*else { assert(false); @@ -1024,7 +1027,7 @@ if ( *(v1 - 10) & 2 ) v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); else - v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); + v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); v10 = (*(v1 - 9) & 1) == 0; billboard.pPalette = v9; if ( !v10 ) @@ -1039,7 +1042,7 @@ v13 = *((short *)v1 - 8); if ( v13 >= 0 ) pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); - } + }*/ } } } @@ -2356,6 +2359,7 @@ if ( v9 == v10 ) { ddsd2.dwFlags = 0x1007u; + __debugbreak(); // warning C4700: uninitialized local variable 'v11' used ddsd2.ddsCaps.dwCaps = v11; goto LABEL_12; } @@ -3076,7 +3080,9 @@ Dst = 124; if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) return; + __debugbreak(); // warning C4700: uninitialized local variable 'v20' used v42 = v20; + __debugbreak(); // warning C4700: uninitialized local variable 'v19' used v6 = v19 >> 1; v3 = 0; } @@ -4794,6 +4800,7 @@ pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; } + __debugbreak(); // warning C4700: uninitialized local variable 'v6' used v9 = (int)v6; v10 = pFrontBuffer; // BUG @@ -5457,6 +5464,7 @@ { d3d_vertex_buffer[i].specular = 0; } + __debugbreak(); // warning C4700: uninitialized local variable 'v20' used d3d_vertex_buffer[i].specular = v20; d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
--- a/SpriteObject.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/SpriteObject.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -53,46 +53,17 @@ //----- (0042F5ED) -------------------------------------------------------- int SpriteObject::Create(int yaw, int pitch, int a4, int a5) { - //SpriteObject *v5; // eax@1 signed int v6; // ebx@2 - //char *v7; // ecx@2 - //signed int result; // eax@6 - SpriteObject *v9; // ebx@7 - int v10; // edx@11 - int v11; // edi@18 - __int16 v12; // ax@18 int v13; // ST2C_4@20 - int v14; // eax@20 - int v15; // [sp-28h] [bp-38h]@14 - int v16; // [sp-24h] [bp-34h]@11 Vec3_int_ v17; // [sp-20h] [bp-30h]@11 - int *v18; // [sp-14h] [bp-24h]@11 - int *v19; // [sp-10h] [bp-20h]@11 - int *v20; // [sp-Ch] [bp-1Ch]@11 - //signed int v21; // [sp+8h] [bp-8h]@2 int angle; // [sp+Ch] [bp-4h]@1 - int a4a; // [sp+1Ch] [bp+Ch]@20 - int a4b; // [sp+1Ch] [bp+Ch]@20 int a5a; // [sp+20h] [bp+10h]@20 - //auto a1 = this; angle = yaw; - //v5 = a1; if (!uObjectDescID) return -1; v6 = 1000; - //v7 = (char *)&pSpriteObjects[0].uObjectDescID; - /*v21 = 0; - do - { - if ( !*(short *)v7 ) - break; - v7 += 112; - ++v6; - v21 = v6; - } - while ( (signed int)v7 < (signed int)((char *)&pObjectList->uNumObjects + 2) );*/ for (uint i = 0; i < MAX_SPRITE_OBJECTS; ++i) if (!pSpriteObjects[i].uObjectDescID) { @@ -104,89 +75,133 @@ return -1; field_64.x = vPosition.x; field_64.y = vPosition.y; - v9 = &pSpriteObjects[v6]; field_64.z = vPosition.z; assert(sizeof(SpriteObject) == 0x70); - memcpy(v9, this, sizeof(*this)); + memcpy(&pSpriteObjects[v6], this, sizeof(*this)); + if ( a5 == 0 ) + { + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; + } if ( a5 == 1 ) { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; v17.x = vPosition.x; v17.y = vPosition.y; v17.z = vPosition.z; - v16 = 0; - v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; - goto LABEL_16; + Vec3_int_::Rotate(24, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } if ( a5 == 2 ) { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; - v17.x = vPosition.x; - v17.y = vPosition.y; - v17.z = vPosition.z; - v16 = 0; - v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; - goto LABEL_14; - } - if ( a5 == 3 ) - { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; v17.x = vPosition.x; v17.y = vPosition.y; v17.z = vPosition.z; - v16 = 0; - v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; -LABEL_14: - v15 = 8; -LABEL_17: - Vec3_int_::Rotate(v15, v10, v16, v17, v18, v19, v20); - goto LABEL_18; + Vec3_int_::Rotate(8, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } - if ( a5 == 4 ) + if ( a5 == 3 ) { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; v17.x = vPosition.x; v17.y = vPosition.y; v17.z = vPosition.z; - v16 = 0; - v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; -LABEL_16: - v15 = 24; - goto LABEL_17; + Vec3_int_::Rotate(8, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } -LABEL_18: - v11 = a4; - v12 = 0; - if ( a4 ) + if ( a5 == 4 ) { - a4a = stru_5C6E00->Cos(angle); - v13 = (unsigned __int64)(a4a * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - a4b = stru_5C6E00->Sin(angle); - a5a = (unsigned __int64)(a4b * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - v14 = stru_5C6E00->Sin(pitch); - v9->vVelocity.x = (unsigned int)(v13 * v11) >> 16; - v9->vVelocity.y = (unsigned int)(a5a * v11) >> 16; - v12 = (unsigned int)(v14 * v11) >> 16; + v17.x = vPosition.x; + v17.y = vPosition.y; + v17.z = vPosition.z; + Vec3_int_::Rotate(24, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } - else - { - v9->vVelocity.y = 0; - v9->vVelocity.x = 0; - } - v9->vVelocity.z = v12; - if ( v6 >= (signed int)uNumSpriteObjects ) - uNumSpriteObjects = v6 + 1; - return v6; + assert(false); + return 0; } //----- (00471C03) -------------------------------------------------------- @@ -970,94 +985,73 @@ // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); //----- (00438E35) -------------------------------------------------------- -void SpriteObject::_438E35() +void SpriteObject::ExplosionTraps() { - SpriteObject *v1; // edi@1 MapInfo *pMapInfo; // esi@1 - int v3; // ebx@1 - int v4; // eax@1 - int v5; // ebx@1 - unsigned int v6; // ecx@1 + int dir_x; // ebx@1 int v7; // edx@2 - unsigned int v8; // edx@4 - unsigned int v9; // edx@6 unsigned int v10; // eax@7 signed int v11; // ebx@8 - Player **v12; // esi@18 signed int v13; // edi@20 - int v15; // [sp+Ch] [bp-Ch]@1 - int v16; // [sp+10h] [bp-8h]@1 - signed int v17; // [sp+14h] [bp-4h]@8 - int v18; // [sp+14h] [bp-4h]@14 + int dir_y; // [sp+Ch] [bp-Ch]@1 + int dir_z; // [sp+10h] [bp-8h]@1 + DAMAGE_TYPE pDamageType; // [sp+14h] [bp-4h]@14 - v1 = this; pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())]; - v3 = abs(pParty->vPosition.x - v1->vPosition.x); - v15 = abs(pParty->vPosition.y - v1->vPosition.y); - v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z); - v4 = v3; - v5 = v15; - v6 = v16; - if ( v4 < v15 ) + dir_x = abs(pParty->vPosition.x - this->vPosition.x); + dir_y = abs(pParty->vPosition.y - this->vPosition.y); + dir_z = abs(pParty->vPosition.z + pParty->sEyelevel - this->vPosition.z); + if ( dir_x < dir_y ) { - v7 = v4; - v4 = v15; - v5 = v7; + v7 = dir_x; + dir_x = dir_y; + dir_y = v7; } - if ( v4 < v16 ) + if ( dir_x < dir_z ) { - v8 = v4; - v4 = v16; - v6 = v8; + v7 = dir_x; + dir_x = dir_z; + dir_z = v7; } - if ( v5 < (signed int)v6 ) + if ( dir_y < dir_z ) { - v9 = v6; - v6 = v5; - v5 = v9; + v7 = dir_z; + dir_z = dir_y; + dir_y = v7; } - v10 = ((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4; + v10 = ((unsigned int)(11 * dir_y) >> 5) + (dir_z / 4) + dir_x; if ( (signed int)v10 <= 768 ) { - v17 = 0; v11 = 5; if ( pMapInfo->Trap_D20 ) { - do - { - ++v17; + for ( uint i = 0; i < pMapInfo->Trap_D20; ++i ) v11 += rand() % 20 + 1; - } - while ( v17 < pMapInfo->Trap_D20 ); } - switch ( v1->uType ) + switch ( this->uType ) { - case 0x32Bu: - v18 = 0; + case 811: + pDamageType = DMGT_FIRE; + break; + case 812: + pDamageType = DMGT_ELECTR; break; - case 0x32Cu: - v18 = 1; + case 813: + pDamageType = DMGT_COLD; break; - case 0x32Du: - v18 = 2; + case 814: + pDamageType = DMGT_BODY; break; default: - //LOWORD(v10) = v1->uItemType - 814; - if ( v1->uType != 814 ) - return; - v18 = 8; - break; + return; } - v12 = &pPlayers[1]; - do + for ( uint i = 1; i <= 4; ++i ) { - if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) ) - (*v12)->PlaySound(SPEECH_6, 0); + if ( pPlayers[i]->CanAct() && (v13 = pPlayers[i]->GetPerception() + 20, rand() % v13 > 20) ) + pPlayers[i]->PlaySound(SPEECH_6, 0); else - (*v12)->ReceiveDamage(v11, (DAMAGE_TYPE)v18); - ++v12; + pPlayers[i]->ReceiveDamage(v11, pDamageType); } - while ( (signed int)v12 <= (signed int)&pPlayers[4] ); } } @@ -1099,9 +1093,6 @@ (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10)) SpriteObject::OnInteraction(i); } - - for (uint i = 0; i < 100; ++i) - array_5118E8.pElements[i].field_C_time_left = 0; } //----- (0046BEF1) -------------------------------------------------------- void SpriteObject::_46BEF1_apply_spells_aoe()
--- a/SpriteObject.h Sat Jul 27 09:36:29 2013 +0600 +++ b/SpriteObject.h Sat Jul 27 09:36:55 2013 +0600 @@ -16,7 +16,7 @@ SpriteObject(); int Create(int yaw, int pitch, int a4, int a5); void _46BEF1_apply_spells_aoe(); - void _438E35(); + void ExplosionTraps(); static void UpdateObject_fn0_BLV(unsigned int uLayingItemID); static void UpdateObject_fn0_ODM(unsigned int uLayingItemID);
--- a/Texture.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/Texture.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -1680,6 +1680,7 @@ { *strchr(&Buf, 10) = 0; memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); + __debugbreak(); // warning C4700: uninitialized local variable 'Str1' used if ( v21 && *Str1 != 47 ) { if ( v21 < 2 ) @@ -1707,6 +1708,7 @@ if ( v21 && *Str1 != 47 ) { strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1); + __debugbreak(); // warning C4700: uninitialized local variable 'Str' used v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str); v9 = 2; for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 )
--- a/UI/Books/UINotesBooks.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/UI/Books/UINotesBooks.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -637,7 +637,7 @@ num_achieved_awards = 0; //v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6); v7 = (int)pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6); - v8 = BuilDialogueString( + v8 = BuildDialogueString( pStorylineText->StoreLine[v6].pText, uActiveCharacter - 1, 0,
--- a/UI/UIGuilds.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/UI/UIGuilds.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -182,8 +182,8 @@ v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14)); v16 = (int)window_SpeakInHouse->ptr_1C; uPlayerID = uActiveCharacter - 1; - v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BildingType_MagicShop, v16, 2); - v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); + v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BuildingType_MagicShop, v16, 2); + v18 = BuildDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorWhite, v18, 3); return;
--- a/UI/UIHouses.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/UI/UIHouses.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -13,7 +13,6 @@ #include "..\Mouse.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" -#include "..\Events2D.h" #include "..\Overlays.h" #include "..\Outdoor.h" #include "..\AudioPlayer.h" @@ -31,7 +30,7 @@ int dword_591080; // weak -int in_current_building_type; // 00F8B198 +BuildingType in_current_building_type; // 00F8B198 HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C #pragma pack(push, 1) @@ -315,6 +314,438 @@ }}; + +//----- (004B3A72) -------------------------------------------------------- +void InitializaDialogueOptions_Tavern(BuildingType type) +{ + int num_buttons; // esi@1 + + num_buttons = 0; + if (type == BuildingType_Tavern) + { + num_buttons = 2; + CreateButtonInColumn(0, 102); + CreateButtonInColumn(1, 103); + if ( pParty->HasItem(651) ) //Arcomage Deck + { + num_buttons = 3; + CreateButtonInColumn(2, 104); + } + } + pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2); + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; +} +// F8B1E0: using guessed type int dword_F8B1E0; + +//----- (004B3AD4) -------------------------------------------------------- +void InitializaDialogueOptions_Shops(BuildingType type) +{ + switch (type) + { + case BuildingType_WeaponShop: + case BuildingType_ArmorShop: + case BuildingType_MagicShop: + { + CreateButtonInColumn(0, 3); + CreateButtonInColumn(1, 4); + CreateButtonInColumn(2, 5); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_AlchemistShop: + { + CreateButtonInColumn(0, 3); + CreateButtonInColumn(1, 4); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + } + + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; +} +// F8B1E0: using guessed type int dword_F8B1E0; + +//----- (004B3B42) -------------------------------------------------------- +void InitializaDialogueOptions(BuildingType type) +{ + /*int v1; // ecx@18 + int v2; // ecx@19 + int v3; // ecx@20 + signed int v4; // esi@22 + signed int v5; // eax@22 + unsigned int v6; // edx@24 + int v7; // ecx@24 + int result; // eax@43 + int v9; // [sp-10h] [bp-14h]@28 + int v10; // [sp-Ch] [bp-10h]@28 + int v11; // [sp-8h] [bp-Ch]@28 + unsigned int v12; // [sp-4h] [bp-8h]@4 + unsigned int v13; // [sp-4h] [bp-8h]@5 + unsigned int v14; // [sp-4h] [bp-8h]@9 + unsigned int v15; // [sp-4h] [bp-8h]@10 + unsigned int v16; // [sp-4h] [bp-8h]@14 + int v17; // [sp-4h] [bp-8h]@28*/ + + switch (type) + { + case BuildingType_WeaponShop: + case BuildingType_ArmorShop: + case BuildingType_MagicShop: + case BuildingType_AlchemistShop: + { + CreateButtonInColumn(0, 2); + CreateButtonInColumn(1, 95); + CreateButtonInColumn(2, 94); + CreateButtonInColumn(3, 96); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_FireGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 48); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_AirGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 49); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_WaterGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 50); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_EarthGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 51); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_SpiritGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 52); + CreateButtonInColumn(2, 61); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_MindGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 53); + CreateButtonInColumn(2, 61); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_BodyGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 54); + CreateButtonInColumn(2, 61); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_LightGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 55); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_DarkGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 56); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_14: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 48); + CreateButtonInColumn(2, 49); + CreateButtonInColumn(3, 50); + CreateButtonInColumn(4, 51); + pDialogueWindow->_41D08F_set_keyboard_control_group(5, 1, 0, 2); + } + break; + + case BuildingType_15: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 52); + CreateButtonInColumn(2, 53); + CreateButtonInColumn(3, 54); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_16: + case BuildingType_TownHall: + { + int num_buttons = 1; + CreateButtonInColumn(0, 99); + + if (pParty->uFine) + { + num_buttons++; + CreateButtonInColumn(1, 100); + } + + pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2); + } + break; + + case BuildingType_Bank: + { + CreateButtonInColumn(0, 7); + CreateButtonInColumn(1, 8); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_Temple: + { + CreateButtonInColumn(0, 10); + CreateButtonInColumn(1, 11); + CreateButtonInColumn(2, 96); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_Stables: + case BuildingType_Boats: + { + CreateButtonInColumn(0, 105); + CreateButtonInColumn(1, 106); + CreateButtonInColumn(2, 107); + CreateButtonInColumn(3, 108); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_Training: + { + CreateButtonInColumn(0, 17); + CreateButtonInColumn(1, 96); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_18: + case BuildingType_19: + case BuildingType_Throne_Room: + case BuildingType_24: + case BuildingType_Unic: + case BuildingType_1A: + case BuildingType_House: + case BuildingType_Jail: + break; + + default: + assert(false && "Invalid enumeration value"); + } + +/* if ( a1 > 13 ) + { + if ( a1 > 22 ) + { + if ( a1 == 23 ) + { + CreateButtonInColumn(0, 0xAu); + CreateButtonInColumn(1, 0xBu); + v14 = 96; +LABEL_41: + CreateButtonInColumn(2, v14); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 3; + goto LABEL_42; + } + if ( a1 <= 26 ) + goto LABEL_43; + if ( a1 > 28 ) + { + if ( a1 != 30 ) + goto LABEL_43; + CreateButtonInColumn(0, 0x11u); + v16 = 96; + goto LABEL_37; + } + CreateButtonInColumn(0, 0x69u); + CreateButtonInColumn(1, 0x6Au); + CreateButtonInColumn(2, 0x6Bu); + v12 = 108; + } + else + { + if ( a1 == 22 ) + { + CreateButtonInColumn(0, 7u); + v16 = 8; + goto LABEL_37; + } + v1 = a1 - 14; + if ( !v1 ) // == 14 + { + CreateButtonInColumn(0, 0x12u); + CreateButtonInColumn(1, 0x30u); + CreateButtonInColumn(2, 0x31u); + CreateButtonInColumn(3, 0x32u); + CreateButtonInColumn(4, 0x33u); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 5; + goto LABEL_42; + } + v2 = v1 - 1; + if ( v2 ) // > 15 + { + v3 = v2 - 2; + if ( v3 ) // > 17 + { + if ( v3 != 4 ) // 18, 19, 20 + goto LABEL_43; + CreateButtonInColumn(0, 0xFu); // 21 + CreateButtonInColumn(1, 0x10u); + v4 = 3; + CreateButtonInColumn(2, 0x60u); + v5 = (signed int)window_SpeakInHouse->ptr_1C; + if ( v5 < 108 || v5 > 120 ) + goto LABEL_28; + v4 = 4; + v6 = 101; + v7 = 3; + } + else // 16, 17 + { + v4 = 1; + CreateButtonInColumn(0, 0x63u); + if ( !pParty->uFine ) + { +LABEL_28: + v17 = 2; + v11 = 0; + v10 = 1; + v9 = v4; +LABEL_42: + pDialogueWindow->_41D08F_set_keyboard_control_group(v9, v10, v11, v17); + goto LABEL_43; + } + v4 = 2; + v7 = 1; + v6 = 100; + } + CreateButtonInColumn(v7, v6); + goto LABEL_28; + } + CreateButtonInColumn(0, 0x12u); // 15 + CreateButtonInColumn(1, 0x34u); + CreateButtonInColumn(2, 0x35u); + v12 = 54; + } +LABEL_39: + CreateButtonInColumn(3, v12); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 4; + goto LABEL_42; + } + if ( a1 == 13 ) + { + CreateButtonInColumn(0, 0x12u); + v16 = 56; +LABEL_37: + CreateButtonInColumn(1, v16); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 2; + goto LABEL_42; + } + switch ( a1 ) + { + case 1: + case 2: + case 3: + case 4: + CreateButtonInColumn(0, 2u); + CreateButtonInColumn(1, 0x5Fu); + CreateButtonInColumn(2, 0x5Eu); + v12 = 96; + goto LABEL_39; + case 5: + CreateButtonInColumn(0, 0x12u); + v13 = 48; + goto LABEL_9; + case 6: + CreateButtonInColumn(0, 0x12u); + v13 = 49; + goto LABEL_9; + case 7: + CreateButtonInColumn(0, 0x12u); + v13 = 50; + goto LABEL_9; + case 8: + CreateButtonInColumn(0, 0x12u); + v13 = 51; +LABEL_9: + CreateButtonInColumn(1, v13); + v14 = 72; + goto LABEL_41; + case 9: + CreateButtonInColumn(0, 0x12u); + v15 = 52; + goto LABEL_13; + case 10: + CreateButtonInColumn(0, 0x12u); + v15 = 53; + goto LABEL_13; + case 11: + CreateButtonInColumn(0, 0x12u); + v15 = 54; +LABEL_13: + CreateButtonInColumn(1, v15); + v14 = 61; + goto LABEL_41; + case 12: + CreateButtonInColumn(0, 0x12u); + v16 = 55; + goto LABEL_37; + default: + break; + } +LABEL_43:*/ + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; +} +// F8B1E0: using guessed type int dword_F8B1E0; + + //----- (004B1784) -------------------------------------------------------- bool __cdecl HouseUI_CheckIfPlayerCanInteract() { @@ -441,13 +872,13 @@ pAudioPlayer->StopChannels(-1, -1); uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID; - in_current_building_type = pAnimatedRooms[uCurrentHouse_Animation].uBuildingType; - if ( in_current_building_type == BildingType_Throne_Room && pParty->uFine ) // going 2 jail + in_current_building_type = (BuildingType)pAnimatedRooms[uCurrentHouse_Animation].uBuildingType; + if ( in_current_building_type == BuildingType_Throne_Room && pParty->uFine ) // going 2 jail { uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID; uHouseID = HOUSE_JAIL; pParty->uTimePlayed = pParty->uTimePlayed + 0x7620000; - in_current_building_type = pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType; + in_current_building_type = (BuildingType)pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType; ++pParty->uNumPrisonTerms; pParty->uFine = 0; for (uint i = 0; i < 4; ++i) @@ -587,11 +1018,8 @@ //----- (004B1E92) -------------------------------------------------------- void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound) { - //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) ) - if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId ) - pAudioPlayer->PlaySound( - //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)), - (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)), + if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId ) + pAudioPlayer->PlaySound((SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)), 806, 0, -1, 0, 0, 0, 0); } @@ -667,7 +1095,7 @@ //else if (dialog_menu_id == HOUSE_DIALOGUE_MAIN) { - if ( in_current_building_type == BildingType_Training ) + if ( in_current_building_type == BuildingType_Training ) { if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) { @@ -695,12 +1123,12 @@ v8 = window_SpeakInHouse; } //else - if ( in_current_building_type != BildingType_Training ) + if ( in_current_building_type != BuildingType_Training ) { v8 = window_SpeakInHouse; - if ((in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) && + if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) && transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7] - || in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild ) + || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild ) { //LABEL_9: pDialogueWindow->Release(); @@ -721,9 +1149,9 @@ } //LABEL_11: dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; - if ( in_current_building_type < BildingType_19 ) + if ( in_current_building_type < BuildingType_19 ) { - v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE); + v9 = pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE); //v3 = dword_F8B198; ShopTexture = &pIcons_LOD->pTextures[v9]; //LABEL_13: @@ -732,20 +1160,20 @@ } //NEW - switch(in_current_building_type) + switch (in_current_building_type) { - case BildingType_FireGuild: - case BildingType_AirGuild: - case BildingType_WaterGuild: - case BildingType_EarthGuild: - case BildingType_SpiritGuild: - case BildingType_MindGuild: - case BildingType_BodyGuild: - case BildingType_LightGuild: - case BildingType_DarkGuild: - case BildingType_14: - case BildingType_15: - case BildingType_16: + case BuildingType_FireGuild: + case BuildingType_AirGuild: + case BuildingType_WaterGuild: + case BuildingType_EarthGuild: + case BuildingType_SpiritGuild: + case BuildingType_MindGuild: + case BuildingType_BodyGuild: + case BuildingType_LightGuild: + case BuildingType_DarkGuild: + case BuildingType_14: + case BuildingType_15: + case BuildingType_16: { if ( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472] >= (signed __int64)pParty->uTimePlayed && *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468] >= (signed __int64)pParty->uTimePlayed ) @@ -778,7 +1206,7 @@ //return; break; } - case BildingType_TownHall: + case BuildingType_TownHall: { if ( uMessageParam == 99 ) { @@ -984,20 +1412,20 @@ } break; } - case BildingType_Bank: + case BuildingType_Bank: { if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) pKeyActionMap->EnterText(1, 10, v8); return; break; } - case BildingType_WeaponShop: - case BildingType_ArmorShop: - case BildingType_MagicShop: - case BildingType_AlchemistShop: - case BildingType_Tavern: - case BildingType_Temple: - case BildingType_Training: + case BuildingType_WeaponShop: + case BuildingType_ArmorShop: + case BuildingType_MagicShop: + case BuildingType_AlchemistShop: + case BuildingType_Tavern: + case BuildingType_Temple: + case BuildingType_Training: { break; } @@ -1009,25 +1437,25 @@ } /* - if ( in_current_building_type > BildingType_Tavern ) + if ( in_current_building_type > BuildingType_Tavern ) { - if ( in_current_building_type == BildingType_Bank ) + if ( in_current_building_type == BuildingType_Bank ) { if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) pKeyActionMap->EnterText(1, 10, v8); return; } - if ( in_current_building_type != BildingType_Temple && in_current_building_type != BildingType_Training ) + if ( in_current_building_type != BuildingType_Temple && in_current_building_type != BuildingType_Training ) return; } //else - if ( in_current_building_type < BildingType_Tavern ) + if ( in_current_building_type < BuildingType_Tavern ) { if (in_current_building_type <= 0) return; - if ( in_current_building_type > BildingType_AlchemistShop ) + if ( in_current_building_type > BuildingType_AlchemistShop ) { - if ( in_current_building_type <= BildingType_16 ) + if ( in_current_building_type <= BuildingType_16 ) { if ( (signed __int64)__PAIR__( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472], @@ -1062,9 +1490,9 @@ } return; } - if ( in_current_building_type != BildingType_TownHall ) + if ( in_current_building_type != BuildingType_TownHall ) return; - if ( in_current_building_type == BildingType_TownHall ) + if ( in_current_building_type == BuildingType_TownHall ) { if ( uMessageParam == 99 ) { @@ -1287,7 +1715,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3A72(in_current_building_type); + InitializaDialogueOptions_Tavern(in_current_building_type); break; } case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES: @@ -1331,7 +1759,7 @@ } } } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v48 = 0; if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) @@ -1359,7 +1787,7 @@ } } } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v53 = 0; if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) @@ -1388,7 +1816,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3AD4(in_current_building_type); + InitializaDialogueOptions_Shops(in_current_building_type); break; } default: @@ -1411,7 +1839,7 @@ if ( pParty->uNumGold < v37 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); - if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) + if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern ) v39 = 4; else v39 = 2; @@ -1474,7 +1902,7 @@ if ( pParty->uNumGold < v37 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); - if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) + if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern ) v39 = 4; else v39 = 2; @@ -1496,7 +1924,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3AD4(in_current_building_type); + InitializaDialogueOptions_Shops(in_current_building_type); } } } @@ -1546,7 +1974,7 @@ //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v47 = v8->ptr_1C; v48 = 0; @@ -1591,7 +2019,7 @@ //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v52 = v8->ptr_1C; v53 = 0; @@ -1700,10 +2128,10 @@ auto color_selected = TargetColor(255, 255, 155); v3 = 52 * (unsigned int)v0->ptr_1C; //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50); - //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BildingType_Stables) - 1) & 0xFFFFFFE7) + 50); + //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BuildingType_Stables) - 1) & 0xFFFFFFE7) + 50); //v4 = (signed __int64)((double)(signed int)v59 * p2DEvents_minus1__20[v3 / 4]); - v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BildingType_Stables ? 25 : 50; + v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BuildingType_Stables ? 25 : 50; v4 *= p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier; s1 = v4 * (100 - v1->GetMerchant()) / 100; @@ -2538,7 +2966,7 @@ PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); dialog_menu_id = HOUSE_DIALOGUE_NULL; sub_4BD8B5(); - sub_4B1D27(); + GetHouseGoodbyeSpeech(); pVideoPlayer->Unload(); window_SpeakInHouse->Release(); window_SpeakInHouse = 0;
--- a/UI/UIHouses.h Sat Jul 27 09:36:29 2013 +0600 +++ b/UI/UIHouses.h Sat Jul 27 09:36:55 2013 +0600 @@ -1,4 +1,5 @@ #pragma once +#include "..\Events2D.h" enum HOUSE_DIALOGUE_MENU: __int32 { @@ -133,7 +134,12 @@ void __cdecl AlchemistDialog(); void __cdecl ArmorShopDialog(); + +void InitializaDialogueOptions_Tavern(BuildingType type); // idb +void InitializaDialogueOptions_Shops(BuildingType type); +void InitializaDialogueOptions(BuildingType type); + extern int uHouse_ExitPic; // weak extern int dword_591080; // weak -extern int in_current_building_type; // 00F8B198 +extern BuildingType in_current_building_type; // 00F8B198 extern HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C \ No newline at end of file
--- a/UI/UIShops.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/UI/UIShops.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -233,14 +233,14 @@ pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60]; if ( !v56 || !Str ) { - v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); - v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2); + v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -267,8 +267,8 @@ || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) ) return; v79 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; - v13 = pPlayer->SelectPhrasesTransaction(v79, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); - v7 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + v13 = pPlayer->SelectPhrasesTransaction(v79, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); + v7 = BuildDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); break; @@ -288,14 +288,14 @@ v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; if (!v4->Identified()) { - v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); - v7 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v10 = pPlayer->SelectPhrasesTransaction(v4, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); + v7 = BuildDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v7 = BuildDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -315,8 +315,8 @@ || (!(pPlayer->pOwnItems[pNumActiveItem-1].uAttributes& 2)) ) return; v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; - v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); - v7 = BuilDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v10 = pPlayer->SelectPhrasesTransaction(v4, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); + v7 = BuildDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); pTextHeight = (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorWhite, v7, 3); return; @@ -424,14 +424,14 @@ pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; if ( !v56 || !Str ) { - v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); - v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2); + v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -668,6 +668,8 @@ short text_color; int pActiveButton; + __debugbreak(); // uishops.cpp(952): warning C4700: uninitialized local variable 'v33' used + __debugbreak(); // uishops.cpp(981): warning C4700: uninitialized local variable 'v98' used memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); dialog_window.uFrameX = 483; dialog_window.uFrameWidth = 148; @@ -759,10 +761,10 @@ pItemCount = v74 - 1; selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74-1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0) - v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" - v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v36 = BuildDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -831,10 +833,10 @@ else selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v74 - 1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) - v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" - v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v36 = BuildDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -893,9 +895,9 @@ || (v10 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v10) ) return; v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v10 - 1]; - v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3); - v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; - v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3); + v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; + v36 = BuildDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -922,10 +924,10 @@ v5 = "%24"; else { - v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4); + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4); v5 = (char *)pMerchantsIdentifyPhrases[v8]; } - v6 = BuilDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v6 = BuildDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v115 = (174 - pFontArrus->CalcTextHeight(v6, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v6, 3); return; @@ -949,10 +951,11 @@ || (v32 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v32) || (!(pPlayers[uActiveCharacter]->pOwnItems[v32-1].uAttributes& 2)) ) return; + __debugbreak(); // warning C4700: uninitialized local variable 'v33' used v116 = &pPlayers[uActiveCharacter]->pInventoryItemList[v33 - 1]; - v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 5); + v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1], BuildingType_ArmorShop, window_SpeakInHouse->par1C, 5); v15 = (char *)pMerchantsRepairPhrases[v35]; - v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v36 = BuildDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -977,8 +980,9 @@ { --pItemCount; v97 = uActiveCharacter - 1; - v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 2); - v100 = BuilDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0); + __debugbreak(); // warning C4700: uninitialized local variable 'v98' used + v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2); + v100 = BuildDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0); v103 = pFontArrus->CalcTextHeight(v100, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, pWhiteColor, v100, 3); } @@ -1360,14 +1364,14 @@ v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { - v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); + v71 = pPlayer->SelectPhrasesTransaction(v70, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else { v38 = pGlobalTXT_LocalizationStrings[181]; } - v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v21 = BuildDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return ; @@ -1387,8 +1391,8 @@ || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) ) return; v87 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; - v45 = pPlayer->SelectPhrasesTransaction(v87, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); - v21 = BuilDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + v45 = pPlayer->SelectPhrasesTransaction(v87, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); + v21 = BuildDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v21, 3); return; @@ -1407,14 +1411,14 @@ v37 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; if (!v37->Identified()) { - v42 = pPlayer->SelectPhrasesTransaction(v37, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); + v42 = pPlayer->SelectPhrasesTransaction(v37, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); v38 = (char *)pMerchantsIdentifyPhrases[v42]; } else { v38 = "%24"; } - v21 = BuilDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v21 = BuildDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return; @@ -1563,14 +1567,14 @@ v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { - v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, v68, 2); + v71 = pPlayer->SelectPhrasesTransaction(v70, BuildingType_AlchemistShop, v68, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else { v38 = pGlobalTXT_LocalizationStrings[181]; } - v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v21 = BuildDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return; @@ -1943,10 +1947,10 @@ v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" else { - v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); + v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); v10 = (char *)pMerchantsBuyPhrases[v75]; } - v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v30 = BuildDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2074,10 +2078,10 @@ v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" else { - v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); + v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); v10 = (char *)pMerchantsBuyPhrases[v75]; } - v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v30 = BuildDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2138,8 +2142,8 @@ || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) ) return; item = &pPlayers[uActiveCharacter]->pInventoryItemList[result - 1]; - v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); - v30 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); + v30 = BuildDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2165,13 +2169,13 @@ item = &pPlayers[uActiveCharacter]->pInventoryItemList[result-1]; if ( item->uAttributes & 1 ) { - v5 = BuilDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v5 = BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v6 = (212 - pFontArrus->CalcTextHeight(v5, &dialog_window, 0, 0)) / 2 + 101; dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v5, 3); return; } - v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); - v30 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); + v30 = BuildDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v30, 3); return; @@ -2197,8 +2201,8 @@ || (!(pPlayers[uActiveCharacter]->pOwnItems[result-1].uAttributes& 2)) ) return; item = &pPlayers[uActiveCharacter]->pInventoryItemList[result - 1]; - v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[result - 1], BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); - v30 = BuilDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[result - 1], BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); + v30 = BuildDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2558,7 +2562,7 @@ if ( pParty->uNumGold < uPriceItemService ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" - if ( in_current_building_type == BildingType_Training ) + if ( in_current_building_type == BuildingType_Training ) v55 = 4; else v55 = 2; @@ -2600,7 +2604,7 @@ if ( in_current_building_type <= 0 ) return; - if ( in_current_building_type <= BildingType_AlchemistShop ) + if ( in_current_building_type <= BuildingType_AlchemistShop ) { if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { @@ -2631,7 +2635,7 @@ GameUI_DrawItemInfo(v7); return; } - if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) + if ( in_current_building_type <= BuildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) { v1 = pMouse->GetCursorPos(&a2); v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y]; @@ -2642,65 +2646,52 @@ } } //----- (004B1D27) -------------------------------------------------------- -void __cdecl sub_4B1D27() +void __cdecl GetHouseGoodbyeSpeech() { - int v0; // edx@2 - unsigned int v1; // ecx@7 signed int v2; // edi@10 - int v3; // esi@10 - __int16 v4; // ax@15 signed int v5; // edi@20 - int v6; // esi@20 int v7[4]; // [sp+Ch] [bp-10h]@12 if ( in_current_building_type > 0 ) { - v0 = 3; - if ( in_current_building_type > BildingType_MagicShop ) + if ( in_current_building_type > BuildingType_MagicShop ) { - if ( in_current_building_type == BildingType_Bank ) + if ( in_current_building_type == BuildingType_Bank ) { if ( !dword_F8B1E4 ) return; } else { - if ( in_current_building_type != BildingType_Temple ) + if ( in_current_building_type != BuildingType_Temple ) return; } - v1 = (unsigned int)window_SpeakInHouse->ptr_1C; - PlayHouseSound(v1, (HouseSoundID)v0); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Greeting_2); return; } - v1 = (unsigned int)window_SpeakInHouse->ptr_1C; - if ( (signed __int64)pParty->field_3C._shop_ban_times[v1 ]<= (signed __int64)pParty->uTimePlayed ) + if ( (signed __int64)pParty->field_3C._shop_ban_times[(unsigned int)window_SpeakInHouse->ptr_1C]<= (signed __int64)pParty->uTimePlayed ) { - if ( pParty->uNumGold <= 0x2710 ) + if ( pParty->uNumGold <= 10000 ) { if ( !dword_F8B1E4 ) return; - v0 = 4; - PlayHouseSound(v1, (HouseSoundID)v0); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Goodbye); return; } - PlayHouseSound(v1, (HouseSoundID)(dword_F8B1E4 + 3)); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)(dword_F8B1E4 + 3)); if ( !dword_F8B1E4 && !qword_A750D8 ) { v5 = 0; - v6 = 1; - do + for ( uint i = 1; i <= 4; ++i ) { - if ( pPlayers[v6]->CanAct() ) - v7[v5++] = v6; - ++v6; + if ( pPlayers[i]->CanAct() ) + v7[v5++] = i; } - while ( v6 <= 4 ); if ( v5 ) { qword_A750D8 = 256i64; - word_A750E0 = 80; - v4 = LOWORD(v7[rand() % v5]); - word_A750E2 = v4; + PlayerSpeechID = SPEECH_80; + uSpeakingCharacter = v7[rand() % v5]; return; } } @@ -2710,20 +2701,16 @@ if ( !qword_A750D8 ) { v2 = 0; - v3 = 1; - do + for ( uint i = 1; i <= 4; ++i ) { - if ( pPlayers[v3]->CanAct() ) - v7[v2++] = v3; - ++v3; + if ( pPlayers[i]->CanAct() ) + v7[v2++] = i; } - while ( v3 <= 4 ); if ( v2 ) { qword_A750D8 = 256i64; - word_A750E0 = 80; - v4 = LOWORD(v7[rand() % v2]); - word_A750E2 = v4; + PlayerSpeechID = SPEECH_80; + uSpeakingCharacter = v7[rand() % v2]; return; } }
--- a/UI/UiGame.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/UI/UiGame.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -287,7 +287,7 @@ a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u); a1.uFrameWidth -= 24; a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; - v14 = BuilDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); + v14 = BuildDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0); } } @@ -481,7 +481,7 @@ switch (uDialogueType) { case DIALOGUE_13: - pInString = BuilDialogueString(pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); break; case DIALOGUE_PROFESSION_DETAILS: @@ -489,11 +489,11 @@ auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; if (dialogue_show_profession_details) - pInString = BuilDialogueString(prof->pBenefits, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pBenefits, uActiveCharacter - 1, 0, 0, 0, 0); else if (pNPC->Hired()) - pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); else - pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); } break; @@ -535,9 +535,9 @@ auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; if (pNPC->Hired()) - pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); else - pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); } break; } @@ -2192,23 +2192,23 @@ int v16; // eax@57 int v19; // eax@62 Texture *pPortrait; // [sp-4h] [bp-1Ch]@27 - unsigned int v22; // [sp+14h] [bp-4h]@1 + //unsigned int v22; // [sp+14h] [bp-4h]@1 - v22 = _this; + //v22 = _this; if ( qword_A750D8 ) { qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed; if ( qword_A750D8 <= 0 ) { - if ( pPlayers[word_A750E2]->CanAct() ) - pPlayers[word_A750E2]->PlaySound((PlayerSpeech)word_A750E0, 0); + if ( pPlayers[uSpeakingCharacter]->CanAct() ) + pPlayers[uSpeakingCharacter]->PlaySound(PlayerSpeechID, 0); qword_A750D8 = 0i64; } } for (uint i = 0; i < 4; ++i) { - Player* pPlayer = pParty->pPlayers + i; + Player* pPlayer = &pParty->pPlayers[i]; if (pPlayer->IsEradicated()) { @@ -2263,7 +2263,7 @@ pFrame = pPlayerFrameTable->GetFrameBy_y(&pPlayer->_expression21_frameset, &pPlayer->_expression21_animtime, pMiscTimer->uTimeElapsed); else pFrame = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed); - if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || v22 ) + if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || _this ) { pPlayer->field_1AA2 = pFrame->uTextureID - 1; pFace = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID];
--- a/_deleted.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/_deleted.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -1677,6 +1677,104 @@ return result; } +//----- (0047BC6F) -------------------------------------------------------- +unsigned __int16 *__fastcall sr_GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4) +{ + int v4; // ebx@1 + int v6; // edx@4 + int v7; // ecx@5 + signed int v8; // eax@6 + signed __int64 v9; // qtt@11 + signed int v10; // eax@12 + int v11; // esi@17 + signed __int64 v12; // qtt@19 + double v13; // ST10_8@19 + int v14; // edi@25 + signed int v15; // edx@26 + signed __int64 v16; // qtt@29 + signed int v17; // eax@30 + int v18; // [sp+10h] [bp-8h]@1 + float a3a; // [sp+20h] [bp+8h]@19 + + v4 = a2; + v18 = a2; + if ( pParty->armageddon_timer ) + return PaletteManager::Get(a2); + if ( !pWeather->bNight ) + { + if (day_attrib & DAY_ATTRIB_FOG) + { + v14 = day_fogrange_1 << 16; + if ( a3 >= day_fogrange_1 << 16 ) + { + if ( a3 <= day_fogrange_2 << 16 ) + { + LODWORD(v16) = (a3 - v14) << 16; + HIDWORD(v16) = (a3 - v14) >> 16; + v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; + } + else + { + v15 = 27; + } + } + else + { + v15 = 0; + } + v17 = _43F55F_get_billboard_light_level(a1, v15); + if ( v17 > 27 ) + v17 = 27; + if ( !a3 ) + v17 = 27; + v7 = v18; + v6 = v17; + return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); + } + v11 = a4; + if ( a4 < 0 ) + v11 = 0; + LODWORD(v12) = a3 << 16; + HIDWORD(v12) = a3 >> 16; + a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20) + * pOutdoor->fFogDensity; + v13 = a3a + 6.7553994e15; + v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11); + if ( v10 > 27 ) + v10 = 27; + if ( v10 < a4 ) + v10 = a4; + if ( v10 > pOutdoor->max_terrain_dimming_level ) + v10 = pOutdoor->max_terrain_dimming_level; + return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); + } + v6 = 0; + if (pWeather->bNight) + { + v8 = 67108864; + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) + v8 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower << 26; + if ( a3 <= v8 ) + { + if ( a3 > 0 ) + { + LODWORD(v9) = a3 << 16; + HIDWORD(v9) = a3 >> 16; + v6 = (unsigned __int64)(27 * v9 / v8) >> 16; + } + } + else + { + v6 = 27; + } + v10 = _43F55F_get_billboard_light_level(a1, v6); + if ( v10 > 27 || !a3 ) + v10 = 27; + return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); + } + v7 = 0; + return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); +} //----- (00487389) -------------------------------------------------------- void Render::ExecOutdoorDrawSW() { @@ -3649,6 +3747,87 @@ return result; } +//----- (0047F4D3) -------------------------------------------------------- +void __fastcall _47F4D3_initialize_terrain_bezier_stuff(int band1, int band2, int band3) +{ + int v3; // edi@1 + //stru220 *v4; // esi@1 + double v5; // ST2C_8@3 + double v6; // st7@3 + //double v7; // [sp+18h] [bp-28h]@3 + //double v8; // [sp+20h] [bp-20h]@2 + int v9; // [sp+34h] [bp-Ch]@1 + int v10; // [sp+38h] [bp-8h]@1 + //signed int band3a; // [sp+48h] [bp+8h]@2 + + v9 = band2 * 512; + pOutdoorCamera->outdoor_grid_band_3 = band3; + v10 = band1 * 512; + v3 = band3 * 512; + pOutdoorCamera->uPickDepth = band3 * 512; + //v4 = terrain_76E5C8; // v4: 0 -> 65536 + for (uint i = 0; i < 16384; ++i) + //do + { + auto v4 = terrain_76E5C8[i]; + //band3a = 256; + //v8 = (double)(signed int)((char *)v4 + 256 - (int)terrain_76E5C8); + for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128 + { + v5 = pow(j * 512 + 256, 2.0); + v6 = pow(i * 4 + 256, 2.0); + //*((float *)&v5 + 1) = sqrt(v6 + v5); + int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15; + if (v7 >= v10) + { + if (v7 >= v9) + v4.field_0 = ((v7 >= v3) - 1) & 2; + else + v4.field_0 = 2; + } + else + { + v4.field_0 = 1; + } + //band3a += 512; + v4.distance = v7; + //++v4; + } + //while ( band3a < 65792 ); + } + //while ( (signed int)v4 < (signed int)arary_77E5C8 ); +} + +//----- (00481EFA) -------------------------------------------------------- +bool __fastcall _481EFA_clip_terrain_poly(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5) +{ + RenderVertexSoft *v5; // esi@1 + RenderVertexSoft *v6; // edx@1 + bool v7; // edi@2 + bool v8; // ecx@5 + bool v9; // esi@8 + bool v10; // eax@11 + double v11; // st7@14 + signed int v12; // esi@15 + signed int v13; // edx@18 + signed int v14; // ecx@21 + signed int v15; // eax@24 + RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1 + + v5 = a2; + v6 = a1; + v17 = v5; + v7 = a1->vWorldViewPosition.x < 8.0; + v8 = v5->vWorldViewPosition.x < 8.0; + v9 = a3->vWorldViewPosition.x < 8.0; + v10 = a4->vWorldViewPosition.x < 8.0; + return !(v8 & v9 & v10 & v7) + && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1), + v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1), + v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1), + v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1), + !(v13 & v14 & v15 & v12)); +} //----- (00481212) -------------------------------------------------------- void Render::DrawTerrainSW(int a1, int a2, int a3, int a4) { @@ -3779,7 +3958,7 @@ v7 = abs(X); v8 = abs(v86); --X; - v92 = &stru_76E5C8[(v7 << 7) + v8]; + v92 = &terrain_76E5C8[(v7 << 7) + v8]; if ( !v92->field_0 || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9], v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]), @@ -3807,7 +3986,7 @@ WorldPosToGridCellZ(v100), !byte_4D864C) || !(pGame->uFlags & 0x80)) - && !sub_481EFA(v10, v11, v102, v103, 1)) ) + && !_481EFA_clip_terrain_poly(v10, v11, v102, v103, 1)) ) goto LABEL_105; if ( v10->vWorldPosition.z != v11->vWorldPosition.z || v11->vWorldPosition.z != v103->vWorldPosition.z @@ -3851,7 +4030,7 @@ if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; ++pOutdoorCamera->uNumPolygons; - if ( !sub_481FC9(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) + if ( !_481FC9_terrain(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) goto LABEL_104; v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); memcpy(array_50AC10, v104, 0x30u); @@ -3972,7 +4151,7 @@ if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; ++pOutdoorCamera->uNumPolygons; - if ( !sub_481FC9((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) + if ( !_481FC9_terrain((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) goto LABEL_74; v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); memcpy(array_50AC10, v104, 0x30u); @@ -4062,7 +4241,7 @@ if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; ++pOutdoorCamera->uNumPolygons; - if ( !sub_481FC9(v102, v104, v103, v17) ) + if ( !_481FC9_terrain(v102, v104, v103, v17) ) { LABEL_104: --pOutdoorCamera->uNumPolygons; @@ -4147,12 +4326,43 @@ } } +//----- (00481FC9) -------------------------------------------------------- +int __fastcall _481FC9_terrain(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera +{ + float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; + + if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y) + a4->flags |= 0x10; + var_c = a1->vWorldViewPosition.x - a2->vWorldViewPosition.x; + var_14 = a1->vWorldViewPosition.y - a2->vWorldViewPosition.y; + arg_0 = a1->vWorldViewPosition.z - a2->vWorldViewPosition.z; + var_10 = a3->vWorldViewPosition.x - a2->vWorldViewPosition.x; + var_8 = a3->vWorldViewPosition.y - a2->vWorldViewPosition.y; + var_4 = a3->vWorldViewPosition.z - a2->vWorldViewPosition.z; + arg_4 = a3->vWorldPosition.y - a2->vWorldPosition.y; + if (((a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.x - a2->vWorldPosition.x) - (a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.y - a2->vWorldPosition.y)) * (pIndoorCamera->pos.y - a2->vWorldPosition.z) + + ((a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.y - a2->vWorldPosition.y) - (a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.z - a2->vWorldPosition.z)) * (pIndoorCamera->pos.x - a2->vWorldPosition.x) + + ((a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.z - a2->vWorldPosition.z) - (a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.x - a2->vWorldPosition.x)) * (pIndoorCamera->pos.z - a2->vWorldPosition.y) < 0) + { + arg_4 = var_4 * var_14 - var_8 * arg_0; + a4->v_18.x = floorf(arg_4 + 0.5f); + arg_4 = var_10 * arg_0 - var_4 * var_c; + a4->v_18.y = floorf(arg_4 + 0.5f); + arg_4 = var_8 * var_c - var_10 * var_14; + a4->v_18.z = floorf(arg_4 + 0.5f); + a4->_normalize_v_18(); + arg_4 = -(a4->v_18.x * a2->vWorldViewPosition.x) - a4->v_18.y * a2->vWorldViewPosition.y - a4->v_18.z * a2->vWorldViewPosition.z; + a4->field_24 = floorf(arg_4 + 0.5f); + return true; + } + else + return false; +} //----- (00438250) -------------------------------------------------------- void IndoorCameraD3D::sr_Reset_list_0037C() { this->list_0037C_size = 0; } - //----- (00438240) -------------------------------------------------------- void IndoorCameraD3D::sr_438240_draw_lits() {
--- a/mm7_2.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/mm7_2.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -572,6 +572,7 @@ v4 /= 2; goto LABEL_24; } + __debugbreak(); // warning C4700: uninitialized local variable 'v27' used if ( uDialogueType == 88 ) num_monsters = 2 * v4; else @@ -715,7 +716,7 @@ { UI_CreateEndConversationButton(); dialog_menu_id = HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT; - sub_4B3AD4(in_current_building_type); + InitializaDialogueOptions_Shops(in_current_building_type); } else { @@ -724,20 +725,20 @@ pVideoPlayer->_4BF5B2(); //LABEL_28: dialog_menu_id = HOUSE_DIALOGUE_MAIN; - sub_4B3B42(in_current_building_type); + InitializaDialogueOptions(in_current_building_type); return 1; } pVideoPlayer->_4BF5B2(); UI_CreateEndConversationButton(); dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN; - sub_4B3A72(in_current_building_type); + InitializaDialogueOptions_Tavern(in_current_building_type); } return 1; } pVideoPlayer->_4BF5B2(); UI_CreateEndConversationButton(); dialog_menu_id = HOUSE_DIALOGUE_MAIN; - sub_4B3B42(in_current_building_type); + InitializaDialogueOptions(in_current_building_type); return 1; } pDialogueNPCCount = 0; @@ -2339,6 +2340,7 @@ LOWORD(v7) = v5 & 0xE0; v12 = v7 + v11; LOWORD(v7) = v8 & 0xE0; + __debugbreak(); // warning C4700: uninitialized local variable 'v10' used return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00) + (v5 & 0x1C00) + v9 @@ -2993,9 +2995,9 @@ case 0x80: return 3; // Master case 0x40: return 2; // Expert case 0x00: return 1; // Normal - default: - assert(false); - } + } + assert(false); + return 0; } //----- (0045828B) -------------------------------------------------------- @@ -3342,33 +3344,29 @@ // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; //----- (004621DA) -------------------------------------------------------- -int __fastcall int_get_vector_length(signed int a1, signed int a2, signed int a3) +int int_get_vector_length(signed int x, signed int y, signed int z) { signed int v3; // eax@2 - signed int v4; // eax@3 - signed int v5; // esi@4 - signed int v6; // esi@6 - - if ( a1 < a2 ) - { - v3 = a1; - a1 = a2; - a2 = v3; - } - v4 = a3; - if ( a1 < a3 ) - { - v5 = a1; - a1 = a3; - v4 = v5; - } - if ( a2 < v4 ) - { - v6 = a2; - a2 = v4; - v4 = v6; - } - return (11 * a2 >> 5) + a1 + (v4 >> 2); + + if ( x < y ) + { + v3 = x; + x = y; + y = v3; + } + if ( x < z ) + { + v3 = x; + x = z; + z = v3; + } + if ( y < z ) + { + v3 = y; + y = z; + z = v3; + } + return (11 * y >> 5) + x + (z >> 2); } OPENFILENAMEA ofn; @@ -5369,7 +5367,7 @@ assert(sizeof(IndoorCamera) == 0x50); assert(sizeof(Bloodsplat) == 0x28); assert(sizeof(BloodsplatContainer) == 0xA0C); - assert(sizeof(stru167) == 0x18); + assert(sizeof(TrailParticle) == 0x18); assert(sizeof(EventIndex) == 0xC); assert(sizeof(_2devent) == 0x34); assert(sizeof(stru176) == 0x20); @@ -5777,7 +5775,7 @@ outdoor_grid_band_2 = 15; outdoor_grid_band_3 = 20; pOutdoorCamera->shading_dist_mist = 8192; - pOutdoorCamera->bNoSky = 0; + pOutdoorCamera->bNoSky = false; LOBYTE(viewparams->field_20) = 0; } mipmapping_terrain_mm1 = 1024; @@ -5791,7 +5789,11 @@ mipmapping_building_mm3 = 4096; pOutdoorCamera->shading_dist_shademist = 4096; pOutdoorCamera->outdoor_no_wavy_water = 0; - sub_47F4D3(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); + //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); + { + pOutdoorCamera->outdoor_grid_band_3 = outdoor_grid_band_3; + pOutdoorCamera->uPickDepth = outdoor_grid_band_3 * 512; + } } else { @@ -6361,8 +6363,8 @@ char *v11; // edx@20 unsigned __int16 v12; // ax@23 int v13; // eax@27 - //unsigned int v14; // ebx@33 - //unsigned __int16 v15; // ax@35 + unsigned int v14; // ebx@33 + unsigned __int16 v15; // ax@35 int v16; // eax@36 unsigned int v17; // eax@37 __int16 v18; // di@37 @@ -6472,15 +6474,15 @@ unsigned int v122; // eax@260 char *v123; // edx@261 int v124; // eax@267 - //int v125; // [sp-20h] [bp-4Ch]@28 - //signed int v126; // [sp-1Ch] [bp-48h]@27 - //unsigned int v127; // [sp-18h] [bp-44h]@27 - //signed int v128; // [sp-14h] [bp-40h]@27 - //signed int v129; // [sp-10h] [bp-3Ch]@27 - //int v130; // [sp-Ch] [bp-38h]@27 - //unsigned int v131; // [sp-8h] [bp-34h]@27 + int v125; // [sp-20h] [bp-4Ch]@28 + signed int v126; // [sp-1Ch] [bp-48h]@27 + unsigned int v127; // [sp-18h] [bp-44h]@27 + signed int v128; // [sp-14h] [bp-40h]@27 + signed int v129; // [sp-10h] [bp-3Ch]@27 + int v130; // [sp-Ch] [bp-38h]@27 + unsigned int v131; // [sp-8h] [bp-34h]@27 char v132; // [sp-8h] [bp-34h]@131 - //int v133; // [sp-4h] [bp-30h]@27 + int v133; // [sp-4h] [bp-30h]@27 char v134; // [sp-4h] [bp-30h]@131 signed int v135; // [sp-4h] [bp-30h]@217 int v136; // [sp+Ch] [bp-20h]@208 @@ -6534,13 +6536,13 @@ v6 = v2->uType; v7 = v2->uType; - if ( v2->uType > 3060 ) - { - if ( v2->uType > 6090 ) + if ( v7 > 3060 ) + { + if ( v7 > 6090 ) { - if ( v2->uType > 8090 ) + if ( v7 > 8090 ) { - if ( v2->uType == 9010 ) + if ( v7 == 9010 ) goto LABEL_247; if ( v7 != 9030 ) { @@ -6562,88 +6564,13 @@ ++v146; v144 += 56; if ( v146 >= (signed int)v99 ) - { - v46 = 0; - v2->uObjectDescID = v46; - if ( v46 == (short)v32 ) - SpriteObject::OnInteraction(v153); - v100 = v2->field_61; - v101 = v2->vPosition.z; - v2->uSpriteFrameID = v32; - v102 = 8 * v153; - v103 = v2->vPosition.y; - LOBYTE(v102) = PID(OBJECT_Item,v153); - v2->vVelocity.x = v32; - v2->vVelocity.y = v32; - v104 = v2->vPosition.x; - v2->vVelocity.z = v32; - v149 = v102; - stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor); - v105 = v2->uSoundID; - if ( v105 == (short)v32 ) - v47 = 0; - else - v47 = (signed __int16)v105 + 4; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32); - return 0; - } + goto LABEL_195; } - v46 = v146; - v2->uObjectDescID = v46; - if ( v46 == (short)v32 ) - SpriteObject::OnInteraction(v153); - v100 = v2->field_61; - v101 = v2->vPosition.z; - v2->uSpriteFrameID = v32; - v102 = 8 * v153; - v103 = v2->vPosition.y; - LOBYTE(v102) = PID(OBJECT_Item,v153); - v2->vVelocity.x = v32; - v2->vVelocity.y = v32; - v104 = v2->vPosition.x; - v2->vVelocity.z = v32; - v149 = v102; - stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor); - v105 = v2->uSoundID; - if ( v105 == (short)v32 ) - v47 = 0; - else - v47 = (signed __int16)v105 + 4; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32); - return 0; + goto LABEL_80; } +LABEL_195: v46 = 0; - v2->uObjectDescID = v46; - if ( v46 == (short)v32 ) - SpriteObject::OnInteraction(v153); - v100 = v2->field_61; - v101 = v2->vPosition.z; - v2->uSpriteFrameID = v32; - v102 = 8 * v153; - v103 = v2->vPosition.y; - LOBYTE(v102) = PID(OBJECT_Item,v153); - v2->vVelocity.x = v32; - v2->vVelocity.y = v32; - v104 = v2->vPosition.x; - v2->vVelocity.z = v32; - v149 = v102; - stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor); - v105 = v2->uSoundID; - if ( v105 == (short)v32 ) - v47 = 0; - else - v47 = (signed __int16)v105 + 4; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32); - return 0; + goto LABEL_196; } goto LABEL_93; } @@ -6665,10 +6592,7 @@ if ( v151 != OBJECT_Actor) { if ( v6 != 9030 || v2->spell_skill != 4 ) - { - SpriteObject::OnInteraction(v153); - return 0; - } + goto LABEL_246; v2->_46BEF1_apply_spells_aoe(); LABEL_233: if ( !v138 ) @@ -6705,12 +6629,19 @@ v114 = (signed __int16)v113 + 4; else v114 = 0; + v133 = 0; + v131 = 0; + v130 = v114; v115 = 8 * v153; + v129 = 0; + v128 = -1; LOBYTE(v115) = PID(OBJECT_Item,v153); - v116 = v143 + 1; - pAudioPlayer->PlaySound((SoundID)v116, v115, 0, -1, 0, 0, 0, 0); - return 0; + v127 = 0; + v126 = v115; + v116 = v143; + goto LABEL_269; } +LABEL_246: SpriteObject::OnInteraction(v153); return 0; } @@ -6761,8 +6692,12 @@ pActors[v108].uAIState = Standing; pActors[v108].UpdateAnimation(); } - pActors[v108].pActorBuffs[v136].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335), - v152, v150, 0, 0); + pActors[v108].pActorBuffs[v136].Apply( + pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335), + v152, + v150, + 0, + 0); } } else @@ -6799,67 +6734,11 @@ ++v52; v94 += 56; if ( v52 >= (signed int)v93 ) - { - v95 = 0; - v2->uObjectDescID = v95; - if ( v95 == (short)v9 ) - SpriteObject::OnInteraction(v153); - v96 = v2->uSoundID; - v2->vVelocity.z = v9; - v2->vVelocity.y = v9; - v2->vVelocity.x = v9; - v2->uSpriteFrameID = v9; - if ( v96 == (short)v9 ) - v97 = 0; - else - v97 = (signed __int16)v96 + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9); - return 0; - } + goto LABEL_181; } - v95 = v52; - v2->uObjectDescID = v95; - if ( v95 == (short)v9 ) - SpriteObject::OnInteraction(v153); - v96 = v2->uSoundID; - v2->vVelocity.z = v9; - v2->vVelocity.y = v9; - v2->vVelocity.x = v9; - v2->uSpriteFrameID = v9; - if ( v96 == (short)v9 ) - v97 = 0; - else - v97 = (signed __int16)v96 + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9); - return 0; + goto LABEL_202; } - v95 = 0; - v2->uObjectDescID = v95; - if ( v95 == (short)v9 ) - SpriteObject::OnInteraction(v153); - v96 = v2->uSoundID; - v2->vVelocity.z = v9; - v2->vVelocity.y = v9; - v2->vVelocity.x = v9; - v2->uSpriteFrameID = v9; - if ( v96 == (short)v9 ) - v97 = 0; - else - v97 = (signed __int16)v96 + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9); - return 0; + goto LABEL_181; } v79 = v7 == 8030; } @@ -6911,22 +6790,34 @@ v2->uObjectDescID = v58; if ( !v58 ) SpriteObject::OnInteraction(v153); + v14 = v153; v2->vVelocity.z = 0; v2->vVelocity.y = 0; v2->vVelocity.x = 0; v2->uSpriteFrameID = 0; sub_43A97E(v153, v145); - //v15 = v2->uSoundID; - if ( v2->uSoundID == (short)v9 ) +LABEL_35: + v15 = v2->uSoundID; + if ( v15 == (short)v9 ) v16 = 0; else - v16 = (signed __int16)v2->uSoundID + 4; - v92 = v153; + v16 = (signed __int16)v15 + 4; + v133 = v9; + v131 = v9; + v130 = v16; + v92 = v14; +LABEL_267: v124 = 8 * v92; + v129 = v9; + v128 = -1; LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v16, v9, v9); - return 0; + v127 = v9; + v126 = v124; +LABEL_268: + v116 = word_4EE088_sound_ids[v2->spell_id - 1]; +LABEL_269: + v125 = v116 + 1; + goto LABEL_29; } v59 = v6 + 2; v60 = pObjectList->uNumObjects; @@ -6975,17 +6866,10 @@ while ( v141 ); } LABEL_160: - SpriteObject::OnInteraction(v153); - if ( v2->uSoundID == (short)v9 ) - v16 = 0; - else - v16 = (signed __int16)v2->uSoundID + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v16, v9, v9); - return 0; + v14 = v153; +LABEL_34: + SpriteObject::OnInteraction(v14); + goto LABEL_35; } if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) ) return 1; @@ -7018,6 +6902,7 @@ v134 = 0; v72 = v153; v132 = 0; +LABEL_132: v73 = v2->vPosition.z; v74 = v2->vPosition.y; v75 = PID(OBJECT_Item,v72); @@ -7032,9 +6917,14 @@ v78 = 0; else v78 = (signed __int16)v77 + 4; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v75, v66, -1, v66, v78, v66, v66); - return 0; + v133 = v66; + v131 = v66; + v130 = v78; + v129 = v66; + v128 = -1; + v127 = v66; + v126 = v75; + goto LABEL_268; } if ( v7 == 4090 ) { @@ -7115,23 +7005,7 @@ v134 = 0; v72 = v153; v132 = v2->field_61; - v73 = v2->vPosition.z; - v74 = v2->vPosition.y; - v75 = PID(OBJECT_Item,v72); - v2->vVelocity.z = v66; - v2->vVelocity.y = v66; - v76 = v2->vPosition.x; - v2->vVelocity.x = v66; - v2->uSpriteFrameID = v66; - stru_50FE08.Add(v75, 512, v76, v74, v73, v132, v134); - v77 = v2->uSoundID; - if ( v77 == (short)v66 ) - v78 = 0; - else - v78 = (signed __int16)v77 + 4; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v75, v66, -1, v66, v78, v66, v66); - return 0; + goto LABEL_132; } if ( v7 == 4100 || v7 == 6010 ) goto LABEL_93; @@ -7197,33 +7071,21 @@ v9 = 0; v10 = 0; if ( (signed int)v8 <= 0 ) - { - v12 = 0; - goto LABEL_24; - } + goto LABEL_23; v11 = (char *)&pObjectList->pObjects->uObjectID; break; case 545: case 550: if ( v2->stru_24.uItemID != 405 && v2->stru_24.uSpecEnchantmentType != 3 ) { + v14 = v153; v9 = 0; v2->vVelocity.z = 0; v2->vVelocity.y = 0; v2->vVelocity.x = 0; v2->uSpriteFrameID = 0; sub_43A97E(v153, v145); - SpriteObject::OnInteraction(v153); - if ( v2->uSoundID == (short)v9 ) - v16 = 0; - else - v16 = (signed __int16)v2->uSoundID + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v16, v9, v9); - return 0; + goto LABEL_34; } v17 = pObjectList->uNumObjects; v18 = 0; @@ -7252,6 +7114,7 @@ v11 += 56; if ( v10 >= (signed int)v8 ) { +LABEL_23: v12 = 0; goto LABEL_24; } @@ -7267,12 +7130,7 @@ v2->vVelocity.x = 0; v2->uSpriteFrameID = 0; if ( !v44 ) - { - v13 = 8 * v153; - LOBYTE(v13) = PID(OBJECT_Item,v153); - pAudioPlayer->PlaySound((SoundID)8, v13, v9, -1, v9, v9, v9, v9); - return 0; - } + goto LABEL_27; } return 0; } @@ -7307,49 +7165,13 @@ ++v52; v53 += 56; if ( v52 >= (signed int)v51 ) - { - v95 = 0; - v2->uObjectDescID = v95; - if ( v95 == (short)v9 ) - SpriteObject::OnInteraction(v153); - v96 = v2->uSoundID; - v2->vVelocity.z = v9; - v2->vVelocity.y = v9; - v2->vVelocity.x = v9; - v2->uSpriteFrameID = v9; - if ( v96 == (short)v9 ) - v97 = 0; - else - v97 = (signed __int16)v96 + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9); - return 0; - } + goto LABEL_181; } - v95 = v52; - v2->uObjectDescID = v95; - if ( v95 == (short)v9 ) - SpriteObject::OnInteraction(v153); - v96 = v2->uSoundID; - v2->vVelocity.z = v9; - v2->vVelocity.y = v9; - v2->vVelocity.x = v9; - v2->uSpriteFrameID = v9; - if ( v96 == (short)v9 ) - v97 = 0; - else - v97 = (signed __int16)v96 + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9); - return 0; + goto LABEL_202; } +LABEL_181: v95 = 0; +LABEL_182: v2->uObjectDescID = v95; if ( v95 == (short)v9 ) SpriteObject::OnInteraction(v153); @@ -7362,12 +7184,11 @@ v97 = 0; else v97 = (signed __int16)v96 + 4; + v133 = v9; + v131 = v9; + v130 = v97; v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9); - return 0; + goto LABEL_267; } if ( v7 == 1100 ) goto LABEL_93; @@ -7410,10 +7231,16 @@ v2->uSpriteFrameID = 0; v147 = v38; stru_50FE08.Add(v38, 512, v40, v39, v37, 0, 0); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, 0, v3->uParticleTrailColor); - pAudioPlayer->PlaySound((SoundID)8, v147, 0, -1, 0, 0, 0, 0); - return 0; + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v3->uParticleTrailColor); + v133 = 0; + v131 = 0; + v130 = 0; + v129 = 0; + v128 = -1; + v127 = 0; + v126 = v147; + goto LABEL_28; } v27 = v26 - 410; if ( !v27 ) @@ -7442,36 +7269,11 @@ ++v146; v140 += 56; if ( v146 >= (signed int)v31 ) - { - v46 = 0; - v2->uObjectDescID = v46; - if ( v46 == (short)v32 ) - SpriteObject::OnInteraction(v153); - v100 = v2->field_61; - v101 = v2->vPosition.z; - v2->uSpriteFrameID = v32; - v102 = 8 * v153; - v103 = v2->vPosition.y; - LOBYTE(v102) = PID(OBJECT_Item,v153); - v2->vVelocity.x = v32; - v2->vVelocity.y = v32; - v104 = v2->vPosition.x; - v2->vVelocity.z = v32; - v149 = v102; - stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor); - v105 = v2->uSoundID; - if ( v105 == (short)v32 ) - v47 = 0; - else - v47 = (signed __int16)v105 + 4; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32); - return 0; - } + goto LABEL_195; } +LABEL_80: v46 = v146; +LABEL_196: v2->uObjectDescID = v46; if ( v46 == (short)v32 ) SpriteObject::OnInteraction(v153); @@ -7487,43 +7289,27 @@ v2->vVelocity.z = v32; v149 = v102; stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor); + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles( + v2->vPosition.x, + v2->vPosition.y, + v2->vPosition.z, + v3->uParticleTrailColor); v105 = v2->uSoundID; if ( v105 == (short)v32 ) v47 = 0; else v47 = (signed __int16)v105 + 4; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32); - return 0; + v133 = v32; + v131 = v32; + v130 = v47; + v129 = v32; + v128 = -1; + v127 = v32; + v126 = v149; + goto LABEL_268; } - v46 = 0; - v2->uObjectDescID = v46; - if ( v46 == (short)v32 ) - SpriteObject::OnInteraction(v153); - v100 = v2->field_61; - v101 = v2->vPosition.z; - v2->uSpriteFrameID = v32; - v102 = 8 * v153; - v103 = v2->vPosition.y; - LOBYTE(v102) = PID(OBJECT_Item,v153); - v2->vVelocity.x = v32; - v2->vVelocity.y = v32; - v104 = v2->vPosition.x; - v2->vVelocity.z = v32; - v149 = v102; - stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor); - v105 = v2->uSoundID; - if ( v105 == (short)v32 ) - v47 = 0; - else - v47 = (signed __int16)v105 + 4; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32); - return 0; + goto LABEL_195; } return 1; } @@ -7544,67 +7330,13 @@ ++v52; v123 += 56; if ( v52 >= (signed int)v122 ) - { - v95 = 0; - v2->uObjectDescID = v95; - if ( v95 == (short)v9 ) - SpriteObject::OnInteraction(v153); - v96 = v2->uSoundID; - v2->vVelocity.z = v9; - v2->vVelocity.y = v9; - v2->vVelocity.x = v9; - v2->uSpriteFrameID = v9; - if ( v96 == (short)v9 ) - v97 = 0; - else - v97 = (signed __int16)v96 + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9); - return 0; - } + goto LABEL_181; } +LABEL_202: v95 = v52; - v2->uObjectDescID = v95; - if ( v95 == (short)v9 ) - SpriteObject::OnInteraction(v153); - v96 = v2->uSoundID; - v2->vVelocity.z = v9; - v2->vVelocity.y = v9; - v2->vVelocity.x = v9; - v2->uSpriteFrameID = v9; - if ( v96 == (short)v9 ) - v97 = 0; - else - v97 = (signed __int16)v96 + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9); - return 0; + goto LABEL_182; } - v95 = 0; - v2->uObjectDescID = v95; - if ( v95 == (short)v9 ) - SpriteObject::OnInteraction(v153); - v96 = v2->uSoundID; - v2->vVelocity.z = v9; - v2->vVelocity.y = v9; - v2->vVelocity.x = v9; - v2->uSpriteFrameID = v9; - if ( v96 == (short)v9 ) - v97 = 0; - else - v97 = (signed __int16)v96 + 4; - v92 = v153; - v124 = 8 * v92; - LOBYTE(v124) = v124 | 2; - v116 = word_4EE088_sound_ids[v2->spell_id] + 1; - pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9); - return 0; + goto LABEL_181; } v117 = v6 + 1; v118 = pObjectList->uNumObjects; @@ -7636,8 +7368,19 @@ v2->vVelocity.y = 0; v2->vVelocity.x = 0; v2->uSpriteFrameID = 0; +LABEL_27: + v133 = v9; + v131 = v9; + v130 = v9; v13 = 8 * v153; + v129 = v9; + v128 = -1; LOBYTE(v13) = PID(OBJECT_Item,v153); - pAudioPlayer->PlaySound((SoundID)8, v13, v9, -1, v9, v9, v9, v9); + v127 = v9; + v126 = v13; +LABEL_28: + v125 = 8; +LABEL_29: + pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); return 0; }
--- a/mm7_3.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/mm7_3.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -42,7 +42,6 @@ #include "Time.h" #include "IconFrameTable.h" #include "TurnEngine.h" -#include "stru220.h" #include "Events2D.h" #include "stru176.h" #include "stru298.h" @@ -5611,8 +5610,8 @@ //int v5; // eax@8 //SpawnPointMM7 *v6; // edx@14 size_t v7; // eax@19 - char *v8; // eax@19 - char *v9; // eax@21 + //char *v8; // eax@19 + //char *v9; // eax@21 char Source[120]; // [sp+Ch] [bp-84h]@19 const char *pFilename; // [sp+84h] [bp-Ch]@1 //unsigned int v12; // [sp+88h] [bp-8h]@12 @@ -5621,7 +5620,7 @@ pFilename = pLevelFilename; thisa->AllocSoftwareDrawBuffers(); pOutdoorCamera->_485F64(); - pWeather->bRenderSnow = 0; + pWeather->bRenderSnow = false; pRenderer->ClearZBuffer(0, 479); thisa = (OutdoorCamera *)1; GetAlertStatus(); @@ -5691,22 +5690,16 @@ pOutdoor->UpdateSunlightVectors(); pOutdoorCamera->int_fov_rad = (signed __int64)pIndoorCamera->flt_1C_fov; pOutdoorCamera->int_fov_rad_inv = (signed __int64)pIndoorCamera->flt_20_inv_1C; - v8 = (char *)&array_77EC08[0].ptr_38; - do - { - *(int *)v8 = (int)&stru_8019C8; - v8 += 268; - } - while ( (signed int)v8 < (signed int)&unk_801A00 ); - v9 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v9 - 1) = 0; - *(int *)v9 = 0; - *((int *)v9 - 5) = 0; - v9 += 268; - } - while ( (signed int)v9 < (signed int)&unk_801A0C ); + + for (int i = 0; i < 20000; ++i) + { + array_77EC08[i].ptr_38 = &stru_8019C8; + + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + array_77EC08[i].ptr_48 = nullptr; + } + MM7Initialization(); } @@ -5748,139 +5741,33 @@ return v1; } -//----- (0047BC6F) -------------------------------------------------------- -unsigned __int16 *__fastcall GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4) -{ - int v4; // ebx@1 - int v6; // edx@4 - int v7; // ecx@5 - signed int v8; // eax@6 - signed __int64 v9; // qtt@11 - signed int v10; // eax@12 - int v11; // esi@17 - signed __int64 v12; // qtt@19 - double v13; // ST10_8@19 - int v14; // edi@25 - signed int v15; // edx@26 - signed __int64 v16; // qtt@29 - signed int v17; // eax@30 - int v18; // [sp+10h] [bp-8h]@1 - float a3a; // [sp+20h] [bp+8h]@19 - - v4 = a2; - v18 = a2; - if ( pParty->armageddon_timer ) - return PaletteManager::Get(a2); - if ( !pWeather->bNight ) - { - if (day_attrib & DAY_ATTRIB_FOG) - { - v14 = day_fogrange_1 << 16; - if ( a3 >= day_fogrange_1 << 16 ) - { - if ( a3 <= day_fogrange_2 << 16 ) - { - LODWORD(v16) = (a3 - v14) << 16; - HIDWORD(v16) = (a3 - v14) >> 16; - v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; - } - else - { - v15 = 27; - } - } - else - { - v15 = 0; - } - v17 = _43F55F_get_billboard_light_level(a1, v15); - if ( v17 > 27 ) - v17 = 27; - if ( !a3 ) - v17 = 27; - v7 = v18; - v6 = v17; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); - } - v11 = a4; - if ( a4 < 0 ) - v11 = 0; - LODWORD(v12) = a3 << 16; - HIDWORD(v12) = a3 >> 16; - a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20) - * pOutdoor->fFogDensity; - v13 = a3a + 6.7553994e15; - v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11); - if ( v10 > 27 ) - v10 = 27; - if ( v10 < a4 ) - v10 = a4; - if ( v10 > pOutdoor->max_terrain_dimming_level ) - v10 = pOutdoor->max_terrain_dimming_level; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v6 = 0; - if (pWeather->bNight) - { - v8 = 67108864; - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) - v8 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower << 26; - if ( a3 <= v8 ) - { - if ( a3 > 0 ) - { - LODWORD(v9) = a3 << 16; - HIDWORD(v9) = a3 >> 16; - v6 = (unsigned __int64)(27 * v9 / v8) >> 16; - } - } - else - { - v6 = 27; - } - v10 = _43F55F_get_billboard_light_level(a1, v6); - if ( v10 > 27 || !a3 ) - v10 = 27; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v7 = 0; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); -} //----- (0047C370) -------------------------------------------------------- -unsigned int __cdecl GetLevelFogColor() +unsigned int GetLevelFogColor() { - unsigned int result; // eax@2 signed __int64 v1; // qax@5 int v2; // eax@6 - if ( bUnderwater ) - { - result = 0xFF258F5C; - } - else - { - if (day_attrib & DAY_ATTRIB_FOG) - { + if (bUnderwater) + return 0xFF258F5C; + + if (day_attrib & DAY_ATTRIB_FOG) + { if ( pWeather->bNight ) // night-time fog { - __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad + __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad v2 = -(pWeather->bNight != 1); - result = (v2 & 0xE0E0E1) - 0xE0E0E1; + return (v2 & 0xE0E0E1) - 0xE0E0E1; } else { v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0); - result = v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); + return v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); } - } - else - return 0; - } - return result; + } + + return 0; } -// 6BE030: using guessed type int day_attrib; -// 6BE3C4: using guessed type char bUnderwater; //----- (0047C3D7) -------------------------------------------------------- int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3) @@ -6112,56 +5999,6 @@ return (64 - a1) << 9; } -//----- (0047F4D3) -------------------------------------------------------- -void __fastcall sub_47F4D3(int band1, int band2, int band3) -{ - int v3; // edi@1 - //stru220 *v4; // esi@1 - double v5; // ST2C_8@3 - double v6; // st7@3 - //double v7; // [sp+18h] [bp-28h]@3 - //double v8; // [sp+20h] [bp-20h]@2 - int v9; // [sp+34h] [bp-Ch]@1 - int v10; // [sp+38h] [bp-8h]@1 - //signed int band3a; // [sp+48h] [bp+8h]@2 - - v9 = band2 * 512; - pOutdoorCamera->outdoor_grid_band_3 = band3; - v10 = band1 * 512; - v3 = band3 * 512; - pOutdoorCamera->uPickDepth = band3 * 512; - //v4 = stru_76E5C8; // v4: 0 -> 65536 - for (uint i = 0; i < 16384; ++i) - //do - { - auto v4 = stru_76E5C8[i]; - //band3a = 256; - //v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8); - for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128 - { - v5 = pow(j * 512 + 256, 2.0); - v6 = pow(i * 4 + 256, 2.0); - //*((float *)&v5 + 1) = sqrt(v6 + v5); - int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15; - if (v7 >= v10) - { - if (v7 >= v9) - v4.field_0 = ((v7 >= v3) - 1) & 2; - else - v4.field_0 = 2; - } - else - { - v4.field_0 = 1; - } - //band3a += 512; - v4.distance = v7; - //++v4; - } - //while ( band3a < 65792 ); - } - //while ( (signed int)v4 < (signed int)arary_77E5C8 ); -} //----- (004811A3) -------------------------------------------------------- void Polygon::DrawBorderTiles() @@ -6178,24 +6015,15 @@ //----- (00481EB7) -------------------------------------------------------- -void __cdecl ResetPolygons() +void ResetPolygons() { - int v0; // ecx@1 - char *v1; // eax@2 - - v0 = pOutdoorCamera->uNumPolygons; - if ( pOutdoorCamera->uNumPolygons > 0 ) - { - v1 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v1 - 1) = 0; - *(int *)v1 = 0; - *((int *)v1 - 5) = 0; - v1 += 268; - --v0; - } - while ( v0 ); + for (auto i = 0; i < pOutdoorCamera->uNumPolygons; ++i) + { + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + + array_77EC08[i].flags = 0; + array_77EC08[i].field_32 = 0; } } @@ -6211,70 +6039,6 @@ pOutdoorCamera->field_44 = 0; } -//----- (00481EFA) -------------------------------------------------------- -bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5) -{ - RenderVertexSoft *v5; // esi@1 - RenderVertexSoft *v6; // edx@1 - bool v7; // edi@2 - bool v8; // ecx@5 - bool v9; // esi@8 - bool v10; // eax@11 - double v11; // st7@14 - signed int v12; // esi@15 - signed int v13; // edx@18 - signed int v14; // ecx@21 - signed int v15; // eax@24 - RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1 - - v5 = a2; - v6 = a1; - v17 = v5; - v7 = a1->vWorldViewPosition.x < 8.0; - v8 = v5->vWorldViewPosition.x < 8.0; - v9 = a3->vWorldViewPosition.x < 8.0; - v10 = a4->vWorldViewPosition.x < 8.0; - return !(v8 & v9 & v10 & v7) - && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1), - v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1), - v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1), - v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1), - !(v13 & v14 & v15 & v12)); -} - -//----- (00481FC9) -------------------------------------------------------- -int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera -{ - float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; - - if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y) - a4->flags |= 0x10; - var_c = a1->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_14 = a1->vWorldViewPosition.y - a2->vWorldViewPosition.y; - arg_0 = a1->vWorldViewPosition.z - a2->vWorldViewPosition.z; - var_10 = a3->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_8 = a3->vWorldViewPosition.y - a2->vWorldViewPosition.y; - var_4 = a3->vWorldViewPosition.z - a2->vWorldViewPosition.z; - arg_4 = a3->vWorldPosition.y - a2->vWorldPosition.y; - if (((a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.x - a2->vWorldPosition.x) - (a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.y - a2->vWorldPosition.y)) * (pIndoorCamera->pos.y - a2->vWorldPosition.z) + - ((a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.y - a2->vWorldPosition.y) - (a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.z - a2->vWorldPosition.z)) * (pIndoorCamera->pos.x - a2->vWorldPosition.x) + - ((a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.z - a2->vWorldPosition.z) - (a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.x - a2->vWorldPosition.x)) * (pIndoorCamera->pos.z - a2->vWorldPosition.y) < 0) - { - arg_4 = var_4 * var_14 - var_8 * arg_0; - a4->v_18.x = floorf(arg_4 + 0.5f); - arg_4 = var_10 * arg_0 - var_4 * var_c; - a4->v_18.y = floorf(arg_4 + 0.5f); - arg_4 = var_8 * var_c - var_10 * var_14; - a4->v_18.z = floorf(arg_4 + 0.5f); - a4->_486089_normalize_v_18(); - arg_4 = -(a4->v_18.x * a2->vWorldViewPosition.x) - a4->v_18.y * a2->vWorldViewPosition.y - a4->v_18.z * a2->vWorldViewPosition.z; - a4->field_24 = floorf(arg_4 + 0.5f); - return true; - } - else - return false; -} - //----- (004823F4) -------------------------------------------------------- bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) { @@ -6469,50 +6233,28 @@ } //----- (00486089) -------------------------------------------------------- -void Polygon::_486089_normalize_v_18() +void Polygon::_normalize_v_18() { - //Polygon *v1; // esi@1 double v2; // st7@1 double v3; // st6@1 - float v4; // ST18_4@2 double v5; // st5@1 - float v6; // ST14_4@2 - double v7; // st7@1 - float v8; // ST24_4@2 - float v9; // ST20_4@2 - double v10; // ST0C_8@2 - float v11; // ST18_4@2 - double v12; // ST0C_8@2 - float v13; // ST14_4@2 - double v14; // ST0C_8@2 - float v15; // [sp+20h] [bp-8h]@1 //v1 = this; v2 = (double)this->v_18.x; - v15 = v2; v3 = (double)this->v_18.y; v5 = (double)this->v_18.z; - v7 = sqrt(v5 * v5 + v3 * v3 + v2 * v2); - if ( v7 == 0.0 ) - { - this->v_18.x = 0; - this->v_18.y = 0; - this->v_18.z = 65536; + float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2); + if (fabsf(len) < 1e-6f) + { + v_18.x = 0; + v_18.y = 0; + v_18.z = 65536; } else { - v8 = 1.0 / v7; - v9 = v8 * v15 * 65536.0; - v10 = v9 + 6.7553994e15; - this->v_18.x = LODWORD(v10); - v4 = v3; - v11 = v8 * v4 * 65536.0; - v12 = v11 + 6.7553994e15; - this->v_18.y = LODWORD(v12); - v6 = v5; - v13 = v8 * v6 * 65536.0; - v14 = v13 + 6.7553994e15; - this->v_18.z = LODWORD(v14); + v_18.x = round(v2 / len * 65536.0); + v_18.y = round(v3 / len * 65536.0); + v_18.y = round(v5 / len * 65536.0); } } @@ -6651,58 +6393,6 @@ return result; } - -//----- (00440DF5) -------------------------------------------------------- -int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr) -{ - int result; // eax@1 - - pElements[uNumElements].field_6_rnd_value = a2; - pElements[uNumElements].field_8_rnd_value = a3; - pElements[uNumElements].field_A_rnd_value = a4; - pElements[uNumElements].field_C_time_left = rand() % 64 + 256; - pElements[uNumElements].field_E_time_to_live = pElements[uNumElements].field_C_time_left; - result = 3 * uNumElements; - pElements[uNumElements++].bgr16 = bgr; - if (uNumElements >= 100 ) - uNumElements = 0; - return result; -} - -//----- (00440E91) -------------------------------------------------------- -void stru167_wrap::_440E91(__int16 x, int y, int z, int a5, __int16 bgr) -{ - stru167_wrap *v6; // edi@1 - int i; // esi@1 - int v8; // ST08_4@2 - int v9; // ST04_4@2 - int v10; // eax@2 - - v6 = this; - for ( i = 0; i < rand() % 6 + 5; ++i ) - { - v8 = z + rand() % 33; - v9 = rand() % 33 + y - 16; - v10 = rand(); - Push(v10 % 33 + x - 16, v9, v8, a5, bgr); - } -} - -//----- (00440F07) -------------------------------------------------------- -void stru167_wrap::_440F07() -{ - for (uint i = 0; i < 100; ++i) - { - if (pElements[i].field_C_time_left > 0) - { - pElements[i].field_A_rnd_value += rand() % 5 + 4; - pElements[i].field_6_rnd_value += rand() % 5 - 2; - pElements[i].field_8_rnd_value += rand() % 5 - 2; - pElements[i].field_C_time_left -= (short)pEventTimer->uTimeElapsed; - } - } -} - //----- (0044100D) -------------------------------------------------------- bool sub_44100D() { @@ -6835,126 +6525,126 @@ { if ( !_strnicmp(test_string, "wea", 3) ) { - p2DEvents[i].uType = BildingType_WeaponShop; + p2DEvents[i].uType = BuildingType_WeaponShop; break; } if ( !_strnicmp(test_string, "arm", 3) ) { - p2DEvents[i].uType = BildingType_ArmorShop; + p2DEvents[i].uType = BuildingType_ArmorShop; break; } if ( !_strnicmp(test_string, "mag", 3) ) { - p2DEvents[i].uType = BildingType_MagicShop; + p2DEvents[i].uType = BuildingType_MagicShop; break; } if ( !_strnicmp(test_string, "alc", 3) ) { - p2DEvents[i].uType = BildingType_AlchemistShop; + p2DEvents[i].uType = BuildingType_AlchemistShop; break; } if ( !_strnicmp(test_string, "sta", 3) ) { - p2DEvents[i].uType = BildingType_Stables; + p2DEvents[i].uType = BuildingType_Stables; break; } if ( !_strnicmp(test_string, "boa", 3) ) { - p2DEvents[i].uType = BildingType_Boats; + p2DEvents[i].uType = BuildingType_Boats; break; } if ( !_strnicmp(test_string, "tem", 3) ) { - p2DEvents[i].uType = BildingType_Temple; + p2DEvents[i].uType = BuildingType_Temple; break; } if ( !_strnicmp(test_string, "tra", 3) ) { - p2DEvents[i].uType = BildingType_Training; + p2DEvents[i].uType = BuildingType_Training; break; } if ( !_strnicmp(test_string, "tow", 3) ) { - p2DEvents[i].uType = BildingType_TownHall; + p2DEvents[i].uType = BuildingType_TownHall; break; } if ( !_strnicmp(test_string, "tav", 3) ) { - p2DEvents[i].uType = BildingType_Tavern; + p2DEvents[i].uType = BuildingType_Tavern; break; } if ( !_strnicmp(test_string, "ban", 3) ) { - p2DEvents[i].uType = BildingType_Bank; + p2DEvents[i].uType = BuildingType_Bank; break; } if ( !_strnicmp(test_string, "fir", 3) ) { - p2DEvents[i].uType = BildingType_FireGuild; + p2DEvents[i].uType = BuildingType_FireGuild; break; } if ( !_strnicmp(test_string, "air", 3) ) { - p2DEvents[i].uType = BildingType_AirGuild; + p2DEvents[i].uType = BuildingType_AirGuild; break; } if ( !_strnicmp(test_string, "wat", 3) ) { - p2DEvents[i].uType = BildingType_WaterGuild; + p2DEvents[i].uType = BuildingType_WaterGuild; break; } if ( !_strnicmp(test_string, "ear", 3) ) { - p2DEvents[i].uType = BildingType_EarthGuild; + p2DEvents[i].uType = BuildingType_EarthGuild; break; } if ( !_strnicmp(test_string, "spi", 3) ) { - p2DEvents[i].uType = BildingType_SpiritGuild; + p2DEvents[i].uType = BuildingType_SpiritGuild; break; } if ( !_strnicmp(test_string, "min", 3) ) { - p2DEvents[i].uType = BildingType_MindGuild; + p2DEvents[i].uType = BuildingType_MindGuild; break; } if ( !_strnicmp(test_string, "bod", 3) ) { - p2DEvents[i].uType = BildingType_BodyGuild; + p2DEvents[i].uType = BuildingType_BodyGuild; break; } if ( !_strnicmp(test_string, "lig", 3) ) { - p2DEvents[i].uType = BildingType_LightGuild; + p2DEvents[i].uType = BuildingType_LightGuild; break; } if ( !_strnicmp(test_string, "dar", 3) ) { - p2DEvents[i].uType = BildingType_DarkGuild; + p2DEvents[i].uType = BuildingType_DarkGuild; break; } if ( !_strnicmp(test_string, "ele", 3) ) { - p2DEvents[i].uType = BildingType_14; + p2DEvents[i].uType = BuildingType_14; break; } if ( !_strnicmp(test_string, "sel", 3) ) { - p2DEvents[i].uType = BildingType_15; + p2DEvents[i].uType = BuildingType_15; break; } if ( !_strnicmp(test_string, "mir", 3) ) { - p2DEvents[i].uType = BildingType_16; + p2DEvents[i].uType = BuildingType_16; break; } if ( !_strnicmp(test_string, "mer", 3) ) { - p2DEvents[i].uType = BildingType_TownHall; + p2DEvents[i].uType = BuildingType_TownHall; break; } - p2DEvents[i].uType = BildingType_18; + p2DEvents[i].uType = BuildingType_18; } break; @@ -7243,7 +6933,7 @@ } //----- (00444360) -------------------------------------------------------- -void __thiscall Level_LoadEvtAndStr(const char *pLevelName) +void Level_LoadEvtAndStr(const char *pLevelName) { char pContainerName[120]; // [sp+8h] [bp-98h]@1 @@ -7341,7 +7031,7 @@ } //----- (00444D80) -------------------------------------------------------- -signed int __cdecl GetTravelTime() +int GetTravelTime() { signed int v0; // esi@1
--- a/mm7_4.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/mm7_4.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -1902,7 +1902,7 @@ } //----- (00495461) -------------------------------------------------------- -char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, __int64 *a6) +char *BuildDialogueString(char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, __int64 *a6) { unsigned __int8 v6; // bl@1 Player *pPlayer; // ebx@3 @@ -3258,14 +3258,17 @@ v11 += 37; } while ( v9 < 4 ); + __debugbreak(); // warning C4700: uninitialized local variable 'v29' used if ( v29 == v14 ) { v25 = pClassNames[v10 + 1]; } else { + __debugbreak(); // warning C4700: uninitialized local variable 'v30' used if ( v30 == v14 )//crash { + __debugbreak(); // warning C4700: uninitialized local variable 'v31' used if ( v31 == v14 ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[634], pClassNames[v10 + 2], pClassNames[v10 + 3]);// %s %s . @@ -3536,249 +3539,6 @@ return pTmpBuf2.data(); } -//----- (004B3A72) -------------------------------------------------------- -void sub_4B3A72( int a1 ) - { - int num_buttons; // esi@1 - - num_buttons = 0; - if ( a1 == 21 ) - { - CreateButtonInColumn(0, 0x66u); - num_buttons = 2; - CreateButtonInColumn(1, 0x67u); - if ( pParty->HasItem(651) ) //Arcomage Deck - { - num_buttons = 3; - CreateButtonInColumn(2, 0x68u); - } - } - pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2); - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; -} -// F8B1E0: using guessed type int dword_F8B1E0; - -//----- (004B3AD4) -------------------------------------------------------- -void sub_4B3AD4( signed int a1 ) - { - if ( a1 > 0 ) - { - if ( a1 <= 3 ) - { - CreateButtonInColumn(0, 3u); - CreateButtonInColumn(1, 4u); - CreateButtonInColumn(2, 5u); - pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); - } - if ( a1 == 4 ) - { - CreateButtonInColumn(0, 3u); - CreateButtonInColumn(1, 4u); - pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); - } - } - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; -} -// F8B1E0: using guessed type int dword_F8B1E0; - -//----- (004B3B42) -------------------------------------------------------- -void sub_4B3B42( signed int a1 ) - { - int v1; // ecx@18 - int v2; // ecx@19 - int v3; // ecx@20 - signed int v4; // esi@22 - signed int v5; // eax@22 - unsigned int v6; // edx@24 - int v7; // ecx@24 - int result; // eax@43 - int v9; // [sp-10h] [bp-14h]@28 - int v10; // [sp-Ch] [bp-10h]@28 - int v11; // [sp-8h] [bp-Ch]@28 - unsigned int v12; // [sp-4h] [bp-8h]@4 - unsigned int v13; // [sp-4h] [bp-8h]@5 - unsigned int v14; // [sp-4h] [bp-8h]@9 - unsigned int v15; // [sp-4h] [bp-8h]@10 - unsigned int v16; // [sp-4h] [bp-8h]@14 - int v17; // [sp-4h] [bp-8h]@28 - - if ( a1 > 13 ) - { - if ( a1 > 22 ) - { - if ( a1 == 23 ) - { - CreateButtonInColumn(0, 0xAu); - CreateButtonInColumn(1, 0xBu); - v14 = 96; -LABEL_41: - CreateButtonInColumn(2, v14); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 3; - goto LABEL_42; - } - if ( a1 <= 26 ) - goto LABEL_43; - if ( a1 > 28 ) - { - if ( a1 != 30 ) - goto LABEL_43; - CreateButtonInColumn(0, 0x11u); - v16 = 96; - goto LABEL_37; - } - CreateButtonInColumn(0, 0x69u); - CreateButtonInColumn(1, 0x6Au); - CreateButtonInColumn(2, 0x6Bu); - v12 = 108; - } - else - { - if ( a1 == 22 ) - { - CreateButtonInColumn(0, 7u); - v16 = 8; - goto LABEL_37; - } - v1 = a1 - 14; - if ( !v1 ) - { - CreateButtonInColumn(0, 0x12u); - CreateButtonInColumn(1, 0x30u); - CreateButtonInColumn(2, 0x31u); - CreateButtonInColumn(3, 0x32u); - CreateButtonInColumn(4, 0x33u); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 5; - goto LABEL_42; - } - v2 = v1 - 1; - if ( v2 ) - { - v3 = v2 - 2; - if ( v3 ) - { - if ( v3 != 4 ) - goto LABEL_43; - CreateButtonInColumn(0, 0xFu); - CreateButtonInColumn(1, 0x10u); - v4 = 3; - CreateButtonInColumn(2, 0x60u); - v5 = (signed int)window_SpeakInHouse->ptr_1C; - if ( v5 < 108 || v5 > 120 ) - goto LABEL_28; - v4 = 4; - v6 = 101; - v7 = 3; - } - else - { - v4 = 1; - CreateButtonInColumn(0, 0x63u); - if ( !pParty->uFine ) - { -LABEL_28: - v17 = 2; - v11 = 0; - v10 = 1; - v9 = v4; -LABEL_42: - pDialogueWindow->_41D08F_set_keyboard_control_group(v9, v10, v11, v17); - goto LABEL_43; - } - v4 = 2; - v7 = 1; - v6 = 100; - } - CreateButtonInColumn(v7, v6); - goto LABEL_28; - } - CreateButtonInColumn(0, 0x12u); - CreateButtonInColumn(1, 0x34u); - CreateButtonInColumn(2, 0x35u); - v12 = 54; - } -LABEL_39: - CreateButtonInColumn(3, v12); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 4; - goto LABEL_42; - } - if ( a1 == 13 ) - { - CreateButtonInColumn(0, 0x12u); - v16 = 56; -LABEL_37: - CreateButtonInColumn(1, v16); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 2; - goto LABEL_42; - } - switch ( a1 ) - { - case 1: - case 2: - case 3: - case 4: - CreateButtonInColumn(0, 2u); - CreateButtonInColumn(1, 0x5Fu); - CreateButtonInColumn(2, 0x5Eu); - v12 = 96; - goto LABEL_39; - case 5: - CreateButtonInColumn(0, 0x12u); - v13 = 48; - goto LABEL_9; - case 6: - CreateButtonInColumn(0, 0x12u); - v13 = 49; - goto LABEL_9; - case 7: - CreateButtonInColumn(0, 0x12u); - v13 = 50; - goto LABEL_9; - case 8: - CreateButtonInColumn(0, 0x12u); - v13 = 51; -LABEL_9: - CreateButtonInColumn(1, v13); - v14 = 72; - goto LABEL_41; - case 9: - CreateButtonInColumn(0, 0x12u); - v15 = 52; - goto LABEL_13; - case 10: - CreateButtonInColumn(0, 0x12u); - v15 = 53; - goto LABEL_13; - case 11: - CreateButtonInColumn(0, 0x12u); - v15 = 54; -LABEL_13: - CreateButtonInColumn(1, v15); - v14 = 61; - goto LABEL_41; - case 12: - CreateButtonInColumn(0, 0x12u); - v16 = 55; - goto LABEL_37; - default: - break; - } -LABEL_43: - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; -} -// F8B1E0: using guessed type int dword_F8B1E0; - //----- (004B3E1E) -------------------------------------------------------- void __cdecl sub_4B3E1E() { @@ -3808,7 +3568,8 @@ { int v1; // edi@1 char *v2; // edi@1 - + + __debugbreak(); v1 = a4; uDialogueType = 78; current_npc_text = (char *)pNPCTopics[a4 + 168].pText; @@ -3830,7 +3591,7 @@ //----- (004B46A5) -------------------------------------------------------- void __fastcall DrawTextAtStatusBar( const char *Str, int a5 ) - { +{ int v4; // eax@1 pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar); v4 = pFontLucida->AlignText_Center(450, Str); @@ -4090,22 +3851,22 @@ return 0; switch( p2DEvents[_2da_idx - 1].uType ) { - case BildingType_WeaponShop: + case BuildingType_WeaponShop: { test = pItemsTable->pItems[item->uItemID].uEquipType <= 2; break; } - case BildingType_ArmorShop: + case BuildingType_ArmorShop: { test = pItemsTable->pItems[item->uItemID].uEquipType >= 3; break; } - case BildingType_MagicShop: + case BuildingType_MagicShop: { test = pItemsTable->pItems[item->uItemID].uSkillType == 38 || pItemsTable->pItems[item->uItemID].uEquipType == 16; break; } - case BildingType_AlchemistShop: + case BuildingType_AlchemistShop: { test = pItemsTable->pItems[item->uItemID].uEquipType == 13 || pItemsTable->pItems[item->uItemID].uEquipType == 14 || (pItemsTable->pItems[item->uItemID].uEquipType > 14 && !(pItemsTable->pItems[item->uItemID].uEquipType != 17
--- a/mm7_5.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/mm7_5.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -1306,7 +1306,7 @@ if ( sub_4BD8B5() ) continue; } - sub_4B1D27(); + GetHouseGoodbyeSpeech(); pAudioPlayer->PlaySound(SOUND_7, 814, 0, -1, 0, 0, 0, 0); pVideoPlayer->Unload(); pGUIWindow_CurrentMenu = window_SpeakInHouse; @@ -2198,6 +2198,7 @@ default: if ( uMessageParam != 5 ) { + __debugbreak(); // warning C4700: uninitialized local variable 'v200' used sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v200); GameUI_SetFooterString(pTmpBuf.data()); continue; @@ -5530,4 +5531,5 @@ break; } assert(false); + return 0; } \ No newline at end of file
--- a/mm7_6.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/mm7_6.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -1607,118 +1607,74 @@ //----- (0042F7EB) -------------------------------------------------------- bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9) { - unsigned int v9; // edi@1 - signed int v10; // edx@3 - char *v11; // ecx@4 - unsigned __int16 v12; // ax@7 - unsigned int v13; // edx@9 - char *v14; // ecx@10 - int v15; // esi@17 - int v16; // eax@18 - int v17; // edi@20 - int v18; // esi@20 - //SpriteObject a1a; // [sp+Ch] [bp-78h]@1 - int v21; // [sp+7Ch] [bp-8h]@1 - unsigned int v22; // [sp+80h] [bp-4h]@1 - - v9 = uSpriteID; - v21 = x; - v22 = uSpriteID; + unsigned __int16 pObjectDescID; // ax@7 + SpriteObject pSpellObject; // [sp+Ch] [bp-78h]@1 - SpriteObject a1a; // [sp+Ch] [bp-78h]@1 - //SpriteObject::SpriteObject(&a1a); - a1a.stru_24.Reset(); - + pSpellObject.stru_24.Reset(); if ( a9 ) - { - memcpy(&a1a.stru_24, a9, sizeof(a1a.stru_24)); - v9 = v22; - } - v10 = 0; - a1a.spell_skill = 0; - a1a.spell_level = 0; - a1a.spell_id = 0; - a1a.field_54 = 0; - a1a.uType = v9; + memcpy(&pSpellObject.stru_24, a9, sizeof(pSpellObject.stru_24)); + pSpellObject.spell_skill = 0; + pSpellObject.spell_level = 0; + pSpellObject.spell_id = 0; + pSpellObject.field_54 = 0; + pSpellObject.uType = uSpriteID; if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_7: - v12 = 0; - } + pObjectDescID = 0; else { - v11 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)v9 != *(short *)v11 ) + pObjectDescID = 0; + for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) { - ++v10; - v11 += 56; - if ( v10 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_7; - } - v12 = v10; - } - a1a.uObjectDescID = v12; - a1a.vPosition.z = z; - a1a.vPosition.x = v21; - a1a.vPosition.y = y; - a1a.uSoundID = 0; - a1a.uAttributes = attributes; - a1a.uSectorID = pIndoor->GetSector(v21, y, z); - a1a.uSpriteFrameID = 0; - a1a.spell_caster_pid = 0; - a1a.spell_target_pid = 0; - if ( !(a1a.uAttributes & 0x10) ) - { - v13 = 0; - if ( (signed int)pItemsTable->uAllItemsCount > 0 ) - { - v14 = (char *)&pItemsTable->pItems[0].uSpriteID; - while ( *(short *)v14 != v9 ) - { - ++v13; - v14 += 48; - if ( (signed int)v13 >= (signed int)pItemsTable->uAllItemsCount ) - goto LABEL_16; - } - a1a.stru_24.uItemID = v13; + if ( (short)uSpriteID == pObjectList->pObjects[i].uObjectID ) + pObjectDescID = i; } } -LABEL_16: + pSpellObject.uObjectDescID = pObjectDescID; + pSpellObject.vPosition.x = x; + pSpellObject.vPosition.y = y; + pSpellObject.vPosition.z = z; + pSpellObject.uSoundID = 0; + pSpellObject.uAttributes = attributes; + pSpellObject.uSectorID = pIndoor->GetSector(x, y, z); + pSpellObject.uSpriteFrameID = 0; + pSpellObject.spell_caster_pid = 0; + pSpellObject.spell_target_pid = 0; + if ( !(pSpellObject.uAttributes & 0x10) ) + { + if ( pItemsTable->uAllItemsCount ) + { + for ( uint i = 0; i < pItemsTable->uAllItemsCount; ++i ) + { + if ( pItemsTable->pItems[i].uSpriteID == uSpriteID ) + pSpellObject.stru_24.uItemID = i; + } + } + } if ( a7 ) { - v15 = count; if ( count > 0 ) { - do + for ( uint i = count; i; --i ) { - a1a.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; - v16 = rand(); - a1a.Create( - (signed __int16)a1a.uFacing, - ((signed int)stru_5C6E00->uIntegerHalfPi >> 1) + (v16 % (signed int)stru_5C6E00->uIntegerHalfPi >> 1), - a4, - 0); - --v15; + pSpellObject.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; + pSpellObject.Create((signed __int16)pSpellObject.uFacing, + ((signed int)stru_5C6E00->uIntegerHalfPi / 2) + (rand() % ((signed int)stru_5C6E00->uIntegerHalfPi / 2)), a4, 0); + } - while ( v15 ); } } else { - v17 = count; - v18 = stru_5C6E00->uIntegerHalfPi; - a1a.uFacing = 0; + pSpellObject.uFacing = 0; if ( count > 0 ) { - do + for ( uint i = count; i; --i ) { - a1a.Create((signed __int16)a1a.uFacing, v18, a4, 0); - --v17; + pSpellObject.Create((signed __int16)pSpellObject.uFacing, stru_5C6E00->uIntegerHalfPi, a4, 0); } - while ( v17 ); } } - return 1; + return true; } //----- (0042F960) --------------------------------------------------------
--- a/mm7_data.cpp Sat Jul 27 09:36:29 2013 +0600 +++ b/mm7_data.cpp Sat Jul 27 09:36:55 2013 +0600 @@ -231,9 +231,6 @@ 0x00000031, 0x00000031, 0x0000002D, 0x00000041 }}; -#include "stru220.h" -std::array<stru220, 16384> stru_76E5C8; - #include "stru176.h" stru176 array_5B5928_timers[100]; @@ -964,7 +961,7 @@ int dword_507CC0_activ_ch; // weak __int64 GameUI_RightPanel_BookFlashTimer; // weak int _507CD4_RestUI_hourglass_anim_controller; // weak -int dword_507CD8; // weak +bool OpenedTelekinesis; std::array<int, 50> dword_50B570; // weak std::array<int, 50> dword_50B638; // weak stru367 PortalFace; @@ -1337,8 +1334,8 @@ std::array< std::array<struct Texture *, 56>, 4> pTextures_PlayerFaces; std::array<struct Player *, 5> pPlayers; __int64 qword_A750D8; // weak -__int16 word_A750E0; // weak -__int16 word_A750E2; // weak +enum PlayerSpeech PlayerSpeechID; +int uSpeakingCharacter; // weak std::array<char *, 36> pClassNames; std::array<char *, 19> aCharacterConditionNames; std::array<char *, 38> pSkillNames;
--- a/mm7_data.h Sat Jul 27 09:36:29 2013 +0600 +++ b/mm7_data.h Sat Jul 27 09:36:55 2013 +0600 @@ -607,7 +607,7 @@ extern int dword_507CC0_activ_ch; // weak extern __int64 GameUI_RightPanel_BookFlashTimer; // weak extern int _507CD4_RestUI_hourglass_anim_controller; // weak -extern int dword_507CD8; // weak +extern bool OpenedTelekinesis; // weak extern std::array<int, 50> dword_50B570; // weak extern std::array<int, 50> dword_50B638; // weak extern struct stru367 PortalFace; @@ -993,8 +993,8 @@ extern int dword_A75070; // weak extern std::array<struct Player *, 5> pPlayers; extern __int64 qword_A750D8; // weak -extern __int16 word_A750E0; // weak -extern __int16 word_A750E2; // weak +extern enum PlayerSpeech PlayerSpeechID; +extern int uSpeakingCharacter; // weak extern std::array<char *, 36> pClassNames; extern std::array<char *, 19> aCharacterConditionNames; extern std::array<char *, 38> pSkillNames; @@ -1217,10 +1217,10 @@ void __cdecl OnMapLeave(); void /*__usercall*/ OnMapLoad(); -void __thiscall Level_LoadEvtAndStr(const char *pLevelName); +void Level_LoadEvtAndStr(const char *pLevelName); const char *__cdecl sub_444564(); char *__thiscall GetEventHintString(unsigned int uEventID); // idb -signed int __cdecl GetTravelTime(); +int GetTravelTime(); void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4); void __cdecl sub_4452BB(); const char *GetProfessionActionText(int a1); @@ -1293,7 +1293,7 @@ void __fastcall PrepareToLoadODM(unsigned int bLoading, struct OutdoorCamera *a2); void __cdecl sub_461103(); int __cdecl sub_4613C4(); -int __fastcall int_get_vector_length(signed int a1, signed int a2, signed int a3); +int int_get_vector_length(signed int x, signed int y, signed int z); int __cdecl sub_46224A(); int __cdecl crt_init_globals_462620(); void __cdecl crt_init_globals_462659(); @@ -1376,21 +1376,17 @@ void __cdecl loc_47907F(); // idb bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused); void __thiscall ODM_LoadAndInitialize(const char *pLevelFilename, struct OutdoorCamera *thisa); -unsigned __int16 *__fastcall GetBillboardPalette(struct RenderBillboard *a1, int a2, signed int a3, int a4); -unsigned int __cdecl GetLevelFogColor(); +unsigned int GetLevelFogColor(); int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3); signed int __fastcall GetActorTintColor(int max_dim, int min_dim, float distance, int a4, struct RenderBillboard *a5); unsigned int __stdcall WorldPosToGridCellX(int); // weak unsigned int __stdcall WorldPosToGridCellZ(int); // weak int __stdcall GridCellToWorldPosX(int); // weak int __stdcall GridCellToWorldPosZ(int); // weak -void __fastcall sub_47F4D3(int band1, int band2, int band3); void __cdecl loc_48118F(); // idb void __cdecl loc_481199(); // idb -void __cdecl ResetPolygons(); +void ResetPolygons(); void __cdecl sub_481ED9_MessWithOutdoorCamera(); -bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5); -signed int __fastcall sub_481FC9(RenderVertexSoft *_ECX, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4); bool IsTerrainSlopeTooHigh(int pos_x, int pos_y); int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4); signed int __cdecl const_1_0(); @@ -1413,7 +1409,7 @@ unsigned int __fastcall _494820_training_time(unsigned int a1); char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2); char *GetReputationString(signed int a1); -char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6); +char *BuildDialogueString(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6); void PlayerCreationUI_Draw(); void PlayerCreationUI_Initialize(); void DeleteCCharFont(); @@ -1427,11 +1423,11 @@ void Present_ColorKey(); void Present_NoColorKey(); unsigned int ModulateColor(unsigned int diffuse, float multiplier); // idb -struct SoundHeader *__fastcall FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName); +struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName); struct SoundData *LoadSound(const char *pSoundName, struct SoundData *pOutBuff, unsigned int uID); int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1); int __fastcall sub_4AB66C(int, int); // weak -int __fastcall GetSoundStrengthByDistanceFromParty(int a1, int a2, int a3); +int GetSoundStrengthByDistanceFromParty(int x, int y, int z); struct _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void); void __cdecl PlayLevelMusic(); unsigned int __fastcall sub_4B0E07(unsigned int uFaceID); // idb @@ -1439,7 +1435,7 @@ void __thiscall sub_4B1523(int *_this); void __cdecl ShowPopupShopItem(); void __stdcall RestAndHeal(__int64 uNumMinutes); // idb -void __cdecl sub_4B1D27(); +void __cdecl GetHouseGoodbyeSpeech(); void __cdecl sub_4B1ECE(); void __fastcall ClickNPCTopic(signed int uMessageParam); @@ -1448,9 +1444,6 @@ void SimpleHouseAndBoatsDialog(); void CreateButtonInColumn(int a1, unsigned int a2); void FillAviableSkillsToTeach(int _this); -void sub_4B3A72(int a1); // idb -void sub_4B3AD4(signed int a1); -void sub_4B3B42(signed int a1); void __cdecl sub_4B3E1E(); void DrawJoinGuildWindow(int pEventCode); void __fastcall sub_4B3FE5(int a4);
--- a/stru159.h Sat Jul 27 09:36:29 2013 +0600 +++ b/stru159.h Sat Jul 27 09:36:55 2013 +0600 @@ -9,7 +9,7 @@ char *video_name; int field_4; int house_npc_id; - unsigned __int8 uBuildingType; + unsigned __int8 uBuildingType; // enum BuildingType unsigned __int8 uRoomSoundId; unsigned __int16 padding_e; };
--- a/stru220.h Sat Jul 27 09:36:29 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#pragma once - - - -/* 210 */ -#pragma pack(push, 1) -struct stru220 -{ - __int16 field_0;//char field_0; - //char field_1; - __int16 distance; -}; -#pragma pack(pop) -extern std::array<stru220, 16384> stru_76E5C8; \ No newline at end of file