Mercurial > might-and-magic-trilogy
view Outdoor.cpp @ 122:2546de5c70dd
Слияние
author | Ritor1 |
---|---|
date | Wed, 14 Nov 2012 09:14:31 +0600 |
parents | 62772029b56d |
children | 05b2d9653abc d2ca891da89f |
line wrap: on
line source
#include <assert.h> #include "Outdoor.h" #include "Party.h" #include "LayingItem.h" #include "LOD.h" #include "Render.h" #include "MapInfo.h" #include "Allocator.h" #include "Weather.h" #include "PaletteManager.h" #include "GUIProgressBar.h" #include "AudioPlayer.h" #include "IndoorCamera.h" #include "DecorationList.h" #include "TileFrameTable.h" #include "Math.h" #include "ObjectList.h" #include "Game.h" #include "Actor.h" #include "Chest.h" #include "stru123.h" #include "Time.h" #include "Viewport.h" #include "Events.h" #include "mm7_data.h" //#include "MM7.h" OutdoorLocation *pOutdoor = new OutdoorLocation; OutdoorCamera *pOutdoorCamera; stru149 stru_8019C8; stru148 array_77EC08[2000]; Surf stru_80C980; Edge defaultEdge; // weak Edge stru_80C9A4; Edge stru_80C9D8; //----- (0047A59E) -------------------------------------------------------- void OutdoorLocation::ExecDraw(unsigned int bRedraw) { int v1; // edi@1 unsigned int v2; // ebx@1 int v3; // ST18_4@3 int v4; // ST04_4@19 int v5; // eax@19 v1 = 0; v2 = bRedraw; if ( viewparams->field_54 ) v1 = 2; pIndoorCamera->sRotationX = pParty->sRotationX; pIndoorCamera->sRotationY = pParty->sRotationY; pIndoorCamera->pos.x = pParty->vPosition.x - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY) * (signed __int64)pParty->field_18) >> 16); v3 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi); pIndoorCamera->field_4C = v1; pIndoorCamera->pos.y = pParty->vPosition.y - ((unsigned __int64)(v3 * (signed __int64)pParty->field_18) >> 16); pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel; if ( v2 || pRenderer->pRenderD3D ) { ResetStru148s(); pOutdoorCamera->RotationToInts(); sub_481ED9_MessWithOutdoorCamera(); } pIndoorCamera->uMapGridCellX = WorldPosToGridCellX(pParty->vPosition.x); pIndoorCamera->uMapGridCellZ = WorldPosToGridCellZ(pParty->vPosition.y); if ( v2 ) { Software_ResetNewEdges(); sub_487DA9(); ptr_80C97C_Surfs = pSurfs; ptr_80C978_Edges = pEdges; } if ( pParty->uCurrentMinute != pOutdoor->uLastSunlightUpdateMinute ) pOutdoor->UpdateSunlightVectors(); pOutdoor->UpdateFog(); pGame->pIndoorCameraD3D->Reset_list_0037C(); if ( !v2 ) { if ( !pRenderer->pRenderD3D ) { pRenderer->OnOutdoorRedrawSW(); goto LABEL_16; } goto LABEL_14; } if ( pRenderer->pRenderD3D ) { LABEL_14: pRenderer->DrawSkyD3D(); pRenderer->DrawBuildingsD3D(); pRenderer->DrawBezierTerrain(); goto LABEL_16; } pRenderer->DrawBuildingsSW(); pRenderer->DrawBezierTerrain(); sr_sub_486F92_MessWithEdgesAndSpans(); pOutdoorCamera->_487355(); LABEL_16: pMobileLightsStack->uNumLightsActive = 0; pStationaryLightsStack->uNumLightsActive = 0; if ( !pRenderer->pRenderD3D ) { pRenderer->ExecOutdoorDrawSW(); pGame->pIndoorCameraD3D->_438240_draw_lits(); } pGame->PushStationaryLights(-1); pGame->PrepareBloodsplats(); if ( v2 ) { v4 = WorldPosToGridCellZ(pParty->vPosition.y); v5 = WorldPosToGridCellX(pParty->vPosition.x); pOutdoor->_47EF60(v5, v4, 1); } pGame->uFlags2 &= 0xFFFFFFFEu; if ( pRenderer->pRenderD3D && pRenderer->bUsingSpecular ) pGame->pLightmapBuilder->uFlags |= 1u; else pGame->pLightmapBuilder->uFlags &= 0xFFFFFFFEu; uNumDecorationsDrawnThisFrame = 0; _unused000 = 0; uNumSpritesDrawnThisFrame = 0; uNumBillboardsToDraw = 0; DrawActors(); if ( !pOutdoorCamera->bDoNotRenderDecorations ) pRenderer->DrawDecorations(); pRenderer->DrawLayingItems_Shooting_Magic_ODM(); pRenderer->TransformBillboardsAndSetPalettesODM(); sub_485F53((Vec2_int_ *)unnamed_6BE060); } //----- (00441CFF) -------------------------------------------------------- void OutdoorLocation::Draw() { unsigned int v0; // ecx@1 v0 = 1; if ( !(pParty->uFlags & 2) && !(pGame->uFlags2 & 1) ) v0 = 0; pOutdoor->ExecDraw(v0); pGame->DrawParticles(); pWeather->Draw(); array_5118E8._440F07(); } //----- (00488E23) -------------------------------------------------------- double OutdoorLocation::GetFogDensityByTime() { int v1; // eax@3 double v2; // st7@3 if ( pParty->uCurrentHour < 5 ) goto LABEL_9; if ( pParty->uCurrentHour >= 6 ) { if ( pParty->uCurrentHour < 0x14 ) { pWeather->field_FA0 = 0; v2 = 0.0; return v2 * 0.016666668; } if ( pParty->uCurrentHour < 0x15 ) { v1 = 0; v2 = (double)(pParty->uCurrentHour - 20) * 60.0 + (double)(signed int)pParty->uCurrentMinute; goto LABEL_4; } LABEL_9: v2 = 60.0; pWeather->field_FA0 = 1; return v2 * 0.016666668; } v1 = 0; v2 = 60.0 - (double)(60 * pParty->uCurrentHour + pParty->uCurrentMinute - 300); LABEL_4: pWeather->field_FA0 = v1; return v2 * 0.016666668; } //----- (00488EB1) -------------------------------------------------------- int OutdoorLocation::GetSomeOtherTileInfo(int sX, int sY) { OutdoorLocation *v3; // esi@1 unsigned int v4; // edi@1 unsigned int v5; // eax@1 int result; // eax@5 v3 = this; v4 = WorldPosToGridCellZ(sY); v5 = WorldPosToGridCellX(sX); if ( (v5 & 0x80000000u) != 0 || (signed int)v5 > 127 || (v4 & 0x80000000u) != 0 || (signed int)v4 > 127 ) result = 0; else result = ActuallyGetSomeOtherTileInfo(v5, v4); return result; } // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); //----- (00488EEF) -------------------------------------------------------- unsigned int OutdoorLocation::GetTileTexture(int sX, int sZ) { OutdoorLocation *v3; // esi@1 unsigned int v4; // edi@1 unsigned int v5; // eax@1 unsigned int result; // eax@5 v3 = this; v4 = WorldPosToGridCellZ(sZ); v5 = WorldPosToGridCellX(sX); if ( (v5 & 0x80000000u) != 0 || (signed int)v5 > 127 || (v4 & 0x80000000u) != 0 || (signed int)v4 > 127 ) result = -1; else result = DoGetTileTexture(v5, v4); return result; } // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); //----- (00488F2E) -------------------------------------------------------- int OutdoorLocation::GetHeightOnTerrain(int sX, int sZ) { int result; // eax@5 if ( sX < 0 || sX > 127 || sZ < 0 || sZ > 127 ) result = 0; else result = DoGetHeightOnTerrain(sX, sZ); return result; } //----- (00488F5C) -------------------------------------------------------- bool OutdoorLocation::Initialize(const char *pFilename, int File, size_t uRespawnInterval, int thisa) { OutdoorLocation *v5; // esi@1 bool result; // eax@2 v5 = this; if ( pFilename ) { Release(); pBitmaps_LOD->ReleaseAll2(); pSprites_LOD->DeleteSomeOtherSprites(); pSpriteFrameTable->ResetSomeSpriteFlags(); pIcons_LOD->ReleaseAll2(); sub_46080D(); TryLoadLevelFromLOD(); if ( !Load((char *)pFilename, (ODMFace *)File, uRespawnInterval, thisa) ) { MessageBoxA(0, "Error!", "Couldn't Load Map!", 0); CreateDebugLocation(); } day_attrib = v5->day_attrib; day_fogrange_1 = v5->day_fogrange_1; day_fogrange_2 = v5->day_fogrange_2; if ( Is_out15odm_underwater() ) SetUnderwaterFog(); _6BE134_odm_main_tile_group = v5->pTileTypes[0].uTileGroup; result = 1; } else { result = 0; } return result; } //----- (0048901B) -------------------------------------------------------- bool OutdoorLocation::Release2() { Release(); pOutdoorCamera->ReleaseSoftwareDrawBuffers(); return true; } //----- (0048902E) -------------------------------------------------------- bool OutdoorLocation::GetTravelDestination(signed int sPartyX, signed int sPartyZ, char *pOut, signed int a5) { OutdoorLocation *v5; // esi@1 char *v6; // eax@3 int v7; // eax@3 int v8; // edx@3 signed int v9; // esi@7 int v10; // esi@23 signed int v11; // eax@23 int v12; // ST14_4@25 signed int v14; // [sp-4h] [bp-84h]@6 char Str; // [sp+8h] [bp-78h]@3 int a5a; // [sp+94h] [bp+14h]@3 auto Source = this; v5 = Source; if ( a5 < 10 || strlen(Source->pLevelFilename) != 9 || (strcpy(&Str, v5->pLevelFilename), _strlwr(&Str), v6 = strtok(&Str, "out"), v6[2] = 0, v7 = atoi(v6), v8 = v7, a5a = v7, v7 < 1) || v7 > 15 ) return 0; if ( sPartyX < -22528 ) { v14 = 4; LABEL_7: v9 = v14; goto LABEL_14; } if ( sPartyX > 22528 ) { v14 = 3; goto LABEL_7; } if ( sPartyZ < -22528 ) { v14 = 2; goto LABEL_7; } if ( sPartyZ <= 22528 ) return 0; v9 = 1; LABEL_14: if ( v7 == 14 ) { if ( v9 == 4 ) { if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(0) ) { uDefaultTravelTime_ByFoot = 1; strcpy(pOut, "out15.odm"); uLevel_StartingPointType = 3; LABEL_18: LOWORD(pParty->uFlags) &= 0xFD7Bu; return 1; } v8 = a5a; } } else { if ( v7 == 15 && v9 == 3 ) { uDefaultTravelTime_ByFoot = 1; strcpy(pOut, "out14.odm"); uLevel_StartingPointType = 4; goto LABEL_18; } } v10 = v9 + 4 * v8; v11 = (unsigned __int8)aTiletableLoadU[v10 + 39]; if ( v11 >= 1 && v11 <= 15 ) { v12 = (unsigned __int8)aTiletableLoadU[v10 + 39]; uDefaultTravelTime_ByFoot = (unsigned __int8)byte_4ECA93[v10]; sprintfex(pOut, "out%02d.odm", v12); uLevel_StartingPointType = (unsigned __int8)byte_4ECACF[v10]; return 1; } return 0; } // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; // 6BE35C: using guessed type int uLevel_StartingPointType; //----- (0048917E) -------------------------------------------------------- void OutdoorLocation::MessWithLUN() { OutdoorLocation *v1; // esi@1 unsigned int *v2; // ebp@1 unsigned int v3; // eax@1 unsigned __int16 v4; // ax@1 signed int v5; // ebx@1 v1 = this; v2 = this->pSpriteIDs_LUN; this->pSpriteIDs_LUN[0] = -1; this->pSpriteIDs_LUN[2] = pSpriteFrameTable->FastFindSprite("LUN1-4"); v1->pSpriteIDs_LUN[4] = pSpriteFrameTable->FastFindSprite("LUN1-2"); v1->pSpriteIDs_LUN[6] = pSpriteFrameTable->FastFindSprite("LUN3-4"); v1->uSpriteID_LUNFULL = pSpriteFrameTable->FastFindSprite("LUNFULL"); v1->uSpriteID_LUN3_4_cp = pSpriteFrameTable->FastFindSprite("LUN3-4"); v1->uSpriteID_LUN1_2_cp = pSpriteFrameTable->FastFindSprite("LUN1-2"); v3 = pSpriteFrameTable->FastFindSprite("LUN1-4"); v1->field_D60 = -1; v1->uSpriteID_LUN1_4_cp = v3; v1->field_CF0 = 4; v1->field_CF8 = 4; v1->field_D00 = 4; LOWORD(v3) = *(short *)v2; v1->pSpriteIDs_LUN[1] = 0; v1->pSpriteIDs_LUN[3] = 0; v1->pSpriteIDs_LUN[5] = 0; v1->pSpriteIDs_LUN[7] = 0; v1->field_CE8 = 0; LOWORD(v1->field_D3C) = v3; v1->field_D40 = 0; v1->field_D44 = 0; v1->field_D48 = 0; v1->field_D4C = 131072; v1->field_D5C = 0; v1->field_D64 = 0; v4 = pSpriteFrameTable->FastFindSprite("LUN-SUN"); v1->field_D28 = -1; v1->field_D08 = 0; v1->field_D0C = 0; v1->field_D10 = 0; v1->field_D24 = 0; v1->field_D2C = 0; v1->uSpriteID_LUN_SUN = v4; v1->field_D14 = -131072; v5 = 8; do { pSpriteFrameTable->InitializeSprite(*v2); v2 += 2; --v5; } while ( v5 ); pSpriteFrameTable->InitializeSprite(v1->uSpriteID_LUN_SUN); } //----- (004892E6) -------------------------------------------------------- unsigned int OutdoorLocation::UpdateSunlightVectors() { unsigned int result; // eax@1 OutdoorLocation *v2; // esi@1 unsigned int v3; // edi@3 int v4; // ebx@3 int v5; // eax@3 int v6; // eax@3 int v7; // ecx@3 double v8; // st7@4 result = pParty->uCurrentHour; v2 = this; if ( pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 0x15 ) { v3 = pParty->uCurrentMinute + 60 * (pParty->uCurrentHour - 5); v4 = (signed int)(v3 * stru_5C6E00->uIntegerPi) / 960; v5 = stru_5C6E00->SinCos((signed int)(v3 * stru_5C6E00->uIntegerPi) / 960); v2->field_D1C = 0; v2->field_D18 = v5; v6 = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi); v7 = v2->field_D18; v2->field_D20 = v6; v2->vSunlight.x = -v7; v2->vSunlight.y = -v2->field_D1C; v2->vSunlight.z = -v6; if ( (signed int)v3 >= 480 ) v8 = (double)(signed int)(960 - v3); else v8 = (double)(signed int)v3; v2->field_CBC_terrain_triangles_shade_type = (signed __int64)(20.0 - v8 * 0.002083333333333333 * 20.0); result = pParty->uCurrentMinute; v2->uLastSunlightUpdateMinute = pParty->uCurrentMinute; } return result; } //----- (004893C1) -------------------------------------------------------- void OutdoorLocation::UpdateFog() { fFogDensity = GetFogDensityByTime(); } //----- (004893CF) -------------------------------------------------------- int OutdoorLocation::GetNumFoodRequiredToRestInCurrentPos(int x, signed int y, int z) { OutdoorLocation *v4; // ebx@1 signed int v5; // edi@4 int v6; // eax@4 int v7; // eax@4 int v8; // eax@4 int v9; // eax@5 int v10; // eax@6 int v11; // eax@7 int v12; // eax@8 int v15; // [sp+8h] [bp-8h]@2 int v16; // [sp+Ch] [bp-4h]@2 v4 = this; if ( pParty->uFlags & 8 || (v15 = 0, v16 = 0, sub_46D49E_prolly_get_world_y_under_party(x, y, z, pParty->uDefaultPartyHeight, &v15, &v16, 0), v16) || v15 ) return 2; v5 = WorldPosToGridCellX(pParty->vPosition.x); v6 = WorldPosToGridCellZ(pParty->vPosition.y); v7 = _47ED83(v5, v6 - 1); v8 = pTileTable->pTiles[_47ECC1(v7)].uTerrainType; if ( v8 ) { v9 = v8 - 1; if ( !v9 ) return 3; v10 = v9 - 1; if ( !v10 ) return 5; v11 = v10 - 1; if ( !v11 || (v12 = v11 - 3) == 0 ) return 4; if ( v12 == 1 ) return 3; return 2; } return 1; } // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); //----- (00489487) -------------------------------------------------------- int OutdoorLocation::SetFog() { int result; // eax@1 int v2; // esi@1 int v3; // edx@5 unsigned __int8 *v4; // eax@5 int v5; // ecx@5 int v6; // esi@7 unsigned __int8 v7; // al@9 strcpy(pOutdoor->pLevelFilename, pCurrentMapName); result = pMapStats->GetMapInfo(pCurrentMapName); v2 = result; if ( result < 1 || result == 7 || result == 8 || result > 15 ) return result; day_attrib &= 0xFFFFFFFEu; v3 = rand() % 100; v4 = (unsigned __int8 *)&byte_4ECB0C[4 * v2]; v5 = *v4; if ( v3 < v5 ) { day_fogrange_1 = 4096; day_fogrange_2 = 8192; LABEL_13: day_attrib |= 1u; goto LABEL_14; } v6 = v4[1]; if ( v3 < v6 + v5 ) { day_fogrange_2 = 4096; LABEL_12: day_fogrange_1 = 0; goto LABEL_13; } v7 = v4[2]; if ( v7 && v3 < v5 + v6 + v7 ) { day_fogrange_2 = 2048; goto LABEL_12; } LABEL_14: if ( Is_out15odm_underwater() ) SetUnderwaterFog(); pOutdoor->day_fogrange_1 = day_fogrange_1; pOutdoor->day_fogrange_2 = day_fogrange_2; result = day_attrib; pOutdoor->day_attrib = day_attrib; return result; } // 6BE030: using guessed type int day_attrib; // 6BE040: using guessed type int day_fogrange_1; // 6BE044: using guessed type int day_fogrange_2; //----- (00482170) -------------------------------------------------------- bool ODMFace::IsBackfaceCulled(ODMFace *a1, RenderVertexSoft *a2, stru148 *a3) { stru148 *v3; // edi@1 RenderVertexSoft *v4; // esi@1 unsigned int v5; // edx@1 RenderVertexSoft *v6; // ecx@2 double v7; // st7@5 double v8; // st6@5 double v9; // st5@5 double v10; // st6@9 double v11; // st5@9 double v12; // st4@9 bool result; // eax@16 double v14; // ST2C_8@17 double v15; // ST20_8@17 double v16; // ST0C_8@17 double v17; // ST0C_8@17 float v18; // [sp+8h] [bp-38h]@5 float v19; // [sp+10h] [bp-30h]@5 float v20; // [sp+14h] [bp-2Ch]@5 float v21; // [sp+18h] [bp-28h]@5 float v22; // [sp+1Ch] [bp-24h]@5 float v23; // [sp+24h] [bp-1Ch]@5 float v24; // [sp+28h] [bp-18h]@5 float v25; // [sp+30h] [bp-10h]@5 float v26; // [sp+34h] [bp-Ch]@5 float v27; // [sp+38h] [bp-8h]@5 float v28; // [sp+3Ch] [bp-4h]@5 float a3a; // [sp+48h] [bp+8h]@5 float a3b; // [sp+48h] [bp+8h]@17 float a3c; // [sp+48h] [bp+8h]@17 float a3d; // [sp+48h] [bp+8h]@17 float a3e; // [sp+48h] [bp+8h]@17 v3 = a3; v4 = a2; v5 = a3->uNumVertices; if ( (signed int)v5 < 3 ) goto LABEL_20; v6 = &v4[v5 - 1]; if ( v4->vWorldPosition.z == v4[1].vWorldPosition.z && v4[1].vWorldPosition.z == v6->vWorldPosition.z ) *(int *)&a3->flags |= 0x10u; v19 = v4[1].vWorldViewPosition.x - v4->vWorldViewPosition.x; v18 = v4[1].vWorldViewPosition.y - v4->vWorldViewPosition.y; v20 = v4[1].vWorldViewPosition.z - v4->vWorldViewPosition.z; v21 = v6->vWorldViewPosition.x - v4->vWorldViewPosition.x; v22 = v6->vWorldViewPosition.y - v4->vWorldViewPosition.y; v23 = v6->vWorldViewPosition.z - v4->vWorldViewPosition.z; v28 = v4[1].vWorldPosition.x - v4->vWorldPosition.x; v27 = v4[1].vWorldPosition.y - v4->vWorldPosition.y; a3a = v4[1].vWorldPosition.z - v4->vWorldPosition.z; v7 = v6->vWorldPosition.x - v4->vWorldPosition.x; v8 = v6->vWorldPosition.y - v4->vWorldPosition.y; v9 = v6->vWorldPosition.z - v4->vWorldPosition.z; v26 = v27 * v9 - v8 * a3a; v24 = v7 * a3a - v9 * v28; v25 = v8 * v28 - v7 * v27; if ( v26 == 0.0 && v24 == 0.0 && v25 == 0.0 ) { while ( 1 ) { --v5; if ( (signed int)v5 < 2 ) break; v10 = v6->vWorldPosition.x - v4->vWorldPosition.x; v11 = v6->vWorldPosition.y - v4->vWorldPosition.y; v12 = v6->vWorldPosition.z - v4->vWorldPosition.z; v26 = v27 * v12 - v11 * a3a; v24 = v10 * a3a - v12 * v28; v25 = v11 * v28 - v10 * v27; if ( v26 != 0.0 ) break; if ( v24 != 0.0 || v25 != 0.0 ) break; --v6; } v21 = v6->vWorldViewPosition.x - v4->vWorldViewPosition.x; v22 = v6->vWorldViewPosition.y - v4->vWorldViewPosition.y; v23 = v6->vWorldViewPosition.z - v4->vWorldViewPosition.z; } if ( ((double)pIndoorCamera->pos.x - v4->vWorldPosition.x) * v26 + ((double)pIndoorCamera->pos.z - v4->vWorldPosition.z) * v25 + ((double)pIndoorCamera->pos.y - v4->vWorldPosition.y) * v24 > 0.0 ) { a3b = v23 * v18 - v22 * v20; v14 = a3b + 6.7553994e15; v3->v_18.x = LODWORD(v14); a3c = v21 * v20 - v23 * v19; v15 = a3c + 6.7553994e15; v3->v_18.y = LODWORD(v15); a3d = v22 * v19 - v21 * v18; v16 = a3d + 6.7553994e15; v3->v_18.z = LODWORD(v16); v3->_486089_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; v17 = a3e + 6.7553994e15; v3->field_24 = LODWORD(v17); result = 1; } else { LABEL_20: result = 0; } return result; } //----- (0047C7A9) -------------------------------------------------------- void OutdoorLocationTerrain::_47C7A9() { this->field_10 = 0; this->field_12 = 0; this->field_16 = 0; this->field_14 = 0; this->field_1C = 0; this->field_18 = 0; } //----- (0047C7C2) -------------------------------------------------------- void OutdoorLocationTerrain::Release() { if (pHeightmap) { pAllocator->FreeChunk(this->pHeightmap); pHeightmap = nullptr; } if (pTilemap) { pAllocator->FreeChunk(pTilemap); pTilemap = nullptr; } if (pAttributemap) { pAllocator->FreeChunk(pAttributemap); pAttributemap = nullptr; } if (ptr_C) { pAllocator->FreeChunk(ptr_C); ptr_C = nullptr; } _47C7A9(); } //----- (0047C80A) -------------------------------------------------------- int OutdoorLocationTerrain::_47C80A(int a2, int a3, int a4, int a5) { OutdoorLocationTerrain *v5; // ebx@1 double v6; // st7@1 double v7; // st7@2 double v8; // st7@2 int result; // eax@3 int v10; // eax@4 int v11; // ecx@5 int v12; // ecx@6 int v13; // edi@7 int v14; // edx@9 int v15; // eax@15 unsigned __int8 *v16; // ebx@15 int v17; // eax@15 int v18; // ecx@15 int v19; // esi@15 int v20; // edi@15 int v21; // edx@15 int v22; // ecx@15 int v23; // ebx@15 int v24; // ecx@15 int v25; // ST28_4@15 double v26; // st7@15 double v27; // st6@15 double v28; // st5@15 double v29; // st7@15 double v30; // st7@16 double v31; // st7@17 int v32; // eax@21 double v33; // st7@21 double v34; // st6@21 double v35; // st5@21 double v36; // st7@21 double v37; // st7@22 double v38; // st7@23 int v39; // [sp+14h] [bp-34h]@8 int v40; // [sp+18h] [bp-30h]@15 int v41; // [sp+1Ch] [bp-2Ch]@15 int v42; // [sp+20h] [bp-28h]@15 OutdoorLocationTerrain *v43; // [sp+24h] [bp-24h]@1 int v44; // [sp+28h] [bp-20h]@21 float v45; // [sp+2Ch] [bp-1Ch]@1 float v46; // [sp+30h] [bp-18h]@1 float v47; // [sp+34h] [bp-14h]@1 int v48; // [sp+38h] [bp-10h]@7 int v49; // [sp+3Ch] [bp-Ch]@10 int v50; // [sp+40h] [bp-8h]@9 float v51; // [sp+44h] [bp-4h]@15 float v52; // [sp+44h] [bp-4h]@21 float v53; // [sp+50h] [bp+8h]@15 float v54; // [sp+50h] [bp+8h]@21 int v55; // [sp+54h] [bp+Ch]@15 float v56; // [sp+54h] [bp+Ch]@15 float v57; // [sp+54h] [bp+Ch]@21 v46 = -64.0; v47 = -64.0; v5 = this; v45 = 64.0; v43 = this; v6 = sqrt(12288.0); if ( v6 != 0.0 ) { v7 = 1.0 / v6; v45 = 64.0 * v7; v8 = v7 * -64.0; v46 = v8; v47 = v8; } result = a3; if ( a3 > a5 ) { v10 = a5 ^ a3; a5 ^= a3 ^ a5; result = a5 ^ v10; } v11 = a2; if ( a2 > a4 ) { v12 = a4 ^ a2; a4 ^= a2 ^ a4; v11 = a4 ^ v12; } v13 = result - 1; v48 = result - 1; if ( result - 1 <= a5 ) { v39 = v11 - 1; do { v14 = v39; v50 = v39; if ( v39 <= a4 ) { result = (v39 - 63) << 9; v49 = (v39 - 63) << 9; do { if ( v13 >= 0 && result >= -32256 && v13 <= 127 && result <= 32768 ) { v15 = v5->field_10; v55 = v15; v16 = v5->pHeightmap; v17 = (int)(&v16[v13 * v15] + v14); v18 = -v13; v19 = (64 - v13) << 9; v20 = 32 * *(char *)v17; v21 = 32 * *(char *)(v17 + 1); v22 = (v18 + 63) << 9; v41 = v22; v23 = (int)(&v16[v55 * (v48 + 1)] + v50); v24 = v22 - v19; v40 = 32 * *(char *)v23; v42 = 32 * *(char *)(v23 + 1); v25 = v49 - 512 - v49; v26 = (double)-((v20 - v21) * v24); v51 = v26; v27 = (double)-(v25 * (v42 - v21)); v53 = v27; v28 = (double)(v25 * v24); v56 = v28; v29 = sqrt(v28 * v28 + v27 * v27 + v26 * v26); if ( v29 != 0.0 ) { v30 = 1.0 / v29; v51 = v51 * v30; v53 = v53 * v30; v56 = v30 * v56; } v31 = (v56 * v47 + v53 * v46 + v51 * v45) * 31.0; if ( v31 < 0.0 ) v31 = 0.0; if ( v31 > 31.0 ) v31 = 31.0; v44 = 2 * (v50 + v48 * v43->field_10); v5 = v43; *((char *)v43->ptr_C + v44 + 1) = (signed __int64)v31; v32 = v49 - (v49 - 512); v33 = (double)-((v42 - v40) * (v19 - v41)); v52 = v33; v34 = (double)-(v32 * (v20 - v40)); v54 = v34; v35 = (double)(v32 * (v19 - v41)); v57 = v35; v36 = sqrt(v35 * v35 + v34 * v34 + v33 * v33); if ( v36 != 0.0 ) { v37 = 1.0 / v36; v52 = v52 * v37; v54 = v54 * v37; v57 = v37 * v57; } v38 = (v57 * v47 + v54 * v46 + v52 * v45) * 31.0; if ( v38 < 0.0 ) v38 = 0.0; if ( v38 > 31.0 ) v38 = 31.0; v13 = v48; *((char *)v43->ptr_C + v44) = (signed __int64)v38; v14 = v50; result = v49; } ++v14; result += 512; v50 = v14; v49 = result; } while ( v14 <= a4 ); } ++v13; v48 = v13; } while ( v13 <= a5 ); } return result; } //----- (0047CB57) -------------------------------------------------------- int OutdoorLocationTerrain::_47CB57(int a1, int a2, int a3) { signed int result; // eax@2 unsigned __int16 *v5; // edx@3 double v6; // st7@3 char v7; // bl@3 int v8; // eax@3 int v9; // eax@4 int v10; // eax@5 double v11; // st6@7 signed int v12; // edi@7 int v13; // esi@9 char *v14; // esi@10 signed int v15; // ecx@10 char v16[256]; // [sp+4h] [bp-124h]@9 unsigned __int16 *v17; // [sp+104h] [bp-24h]@3 unsigned int v18; // [sp+108h] [bp-20h]@3 unsigned int v19; // [sp+10Ch] [bp-1Ch]@3 unsigned int v20; // [sp+110h] [bp-18h]@3 unsigned int v21; // [sp+114h] [bp-14h]@3 float v22; // [sp+118h] [bp-10h]@3 float v23; // [sp+11Ch] [bp-Ch]@3 int i; // [sp+120h] [bp-8h]@3 unsigned int v25; // [sp+124h] [bp-4h]@5 signed int a2a; // [sp+134h] [bp+Ch]@3 unsigned int a2b; // [sp+134h] [bp+Ch]@7 float a3a; // [sp+138h] [bp+10h]@7 int a3b; // [sp+138h] [bp+10h]@9 if ( pRenderer->pRenderD3D ) { result = 0; } else { v5 = PaletteManager::Get_Dark_or_Red_LUT(a2, 0, 1); v6 = 0.0; v7 = LOBYTE(pRenderer->uTargetBBits); v19 = pRenderer->uTargetRMask; v21 = pRenderer->uTargetGMask; v22 = 0.0; v20 = pRenderer->uTargetBMask; v8 = 0; v17 = v5; v23 = 0.0; v18 = pRenderer->uTargetBBits; a2a = 0; for ( i = 0; i < a3; ++i ) { v9 = *(char *)(v8 + a1); if ( v9 ) { v10 = v5[v9]; v6 = v6 + (double)((signed int)(v19 & v10) >> (LOBYTE(pRenderer->uTargetBBits) + LOBYTE(pRenderer->uTargetGBits))); ++a2a; v25 = v20 & v10; v22 = (double)((signed int)(v21 & v10) >> SLOBYTE(pRenderer->uTargetBBits)) + v22; v23 = (double)(signed int)(v20 & v10) + v23; } v8 = i + 1; } v11 = 1.0 / (double)a2a; a3a = v11; v25 = (signed __int64)(a3a * v22); i = (signed __int64)(a3a * v23); v12 = 0; a2b = pRenderer->uTargetBBits + pRenderer->uTargetGBits; while ( 1 ) { v13 = v17[v12]; a3b = abs((__int64)(signed __int64)(v11 * v6) - ((signed int)(v19 & v17[v12]) >> a2b)); BYTE3(a3b) = abs((signed)v25 - ((signed int)(v21 & v13) >> v7)) + a3b; v16[v12++] = abs((signed)i - (signed)(v20 & v13)) + BYTE3(a3b); if ( v12 >= 256 ) break; v7 = v18; } result = 0; v14 = (char *)&pPaletteManager->field_D1600[42][23][116]; v15 = 0; do { if ( (unsigned __int8)v16[v15] < (signed int)v14 ) { v14 = (char *)(unsigned __int8)v16[v15]; result = v15; } ++v15; } while ( v15 < 256 ); } return result; } // 47CB57: using guessed type char var_124[256]; //----- (0047CCE2) -------------------------------------------------------- bool OutdoorLocationTerrain::ZeroLandscape() { OutdoorLocationTerrain *v1; // esi@1 v1 = this; memset(this->pHeightmap, 0, 0x4000u); memset(v1->pTilemap, 90, 0x4000u); memset(v1->pAttributemap, 0, 0x4000u); memset(v1->ptr_C, 0, 0x8000u); v1->field_12 = 128; v1->field_10 = 128; v1->field_16 = 7; v1->field_14 = 7; v1->field_1C = 127; v1->field_18 = 127; return 1; } //----- (0047CD44) -------------------------------------------------------- bool OutdoorLocationTerrain::Initialize() { OutdoorLocationTerrain *v1; // esi@1 void *v2; // eax@1 bool result; // eax@2 void *v4; // eax@3 void *v5; // eax@4 void *v6; // eax@5 v1 = this; v2 = pAllocator->AllocNamedChunk(this->pHeightmap, 0x4000u, "HMAP"); v1->pHeightmap = (unsigned __int8 *)v2; if ( v2 && (v4 = pAllocator->AllocNamedChunk(v1->pTilemap, 0x4000u, "TMAP"), (v1->pTilemap = (unsigned __int8 *)v4) != 0) && (v5 = pAllocator->AllocNamedChunk(v1->pAttributemap, 0x4000u, "AMAP"), (v1->pAttributemap = (unsigned __int8 *)v5) != 0) ) { v6 = pAllocator->AllocNamedChunk(v1->ptr_C, 0x8000u, "DMAP"); v1->ptr_C = v6; result = v6 != 0; } else { result = 0; } return result; } //----- (0047CDE2) -------------------------------------------------------- void OutdoorLocation::CreateDebugLocation() { OutdoorLocation *v1; // esi@1 void *v2; // eax@1 void *v3; // ST14_4@1 void *v4; // eax@1 void *v5; // ST14_4@1 void *v6; // eax@1 unsigned int v7; // eax@1 char v8; // zf@1 v1 = this; strcpy(this->pLevelFilename, "blank"); strcpy(v1->pLocationFileName, "i6.odm"); strcpy(v1->pLocationFileDescription, "MM6 Outdoor v1.00"); v1->uNumBModels = 0; v1->pTileTypes[0].uTileGroup = 0; v1->pTileTypes[1].uTileGroup = 5; v1->pTileTypes[2].uTileGroup = 6; v1->pTileTypes[3].uTileGroup = 10; v1->LoadTileGroupIds(); v1->_47F3EA(); pAllocator->FreeChunk(v1->pBModels); pAllocator->FreeChunk(v1->pSpawnPoints); v1->pBModels = 0; v1->pSpawnPoints = 0; v1->pTerrain.Initialize(); v1->pTerrain.ZeroLandscape(); v1->pTerrain._47C80A(0, 0, 128, 128); pAllocator->FreeChunk(v1->ptr_D4); v1->ptr_D4 = 0; v2 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); v3 = v1->pOMAP; v1->ptr_D4 = v2; pAllocator->FreeChunk(v3); v1->pOMAP = 0; v4 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); v1->pOMAP = (unsigned int *)v4; memset(v4, 0, 0x10000u); v5 = v1->pFaceIDLIST; v1->numFaceIDListElems = 0; pAllocator->FreeChunk(v5); v1->pFaceIDLIST = 0; v6 = pAllocator->AllocNamedChunk(0, 2u, "IDLIST"); v1->pFaceIDLIST = (unsigned __int16 *)v6; *(short *)v6 = 0; strcpy(v1->pSkyTextureName, pDefaultSkyTexture); v1->uSky_TextureID = pBitmaps_LOD->LoadTexture(v1->pSkyTextureName); strcpy(v1->pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); v7 = pBitmaps_LOD->LoadTexture(v1->pGroundTileset); v8 = v1->uSky_TextureID == -1; v1->uMainTile_BitmapID = v7; if ( v8 ) Abortf("Invalid Sky Tex Handle"); if ( v1->uMainTile_BitmapID == -1 ) Abortf("Invalid Ground Tex Handle"); } //----- (0047CF9C) -------------------------------------------------------- void OutdoorLocation::Release() { //OutdoorLocation *v1; // esi@1 //signed int v2; // edi@1 //int v3; // ebx@2 //void *v4; // ST24_4@4 //char *v5; // ebx@4 //void **v6; // esi@4 //v1 = this; strcpy(pLevelFilename, "blank"); strcpy(pLocationFileName, "default.odm"); strcpy(pLocationFileDescription, "MM6 Outdoor v1.00"); strcpy(pSkyTextureName, "sky043"); strcpy(pGroundTileset, "hm005"); if (pBModels) { for (uint i = 0; i < uNumBModels; ++i) pBModels[i].Release(); pAllocator->FreeChunk(pBModels); pBModels = nullptr; uNumBModels = 0; } if (pSpawnPoints) { pAllocator->FreeChunk(pSpawnPoints); pSpawnPoints = nullptr; } uNumSpawnPoints = 0; pTerrain.Release(); if (ptr_D4) { pAllocator->FreeChunk(ptr_D4); ptr_D4 = nullptr; } if (pOMAP) { pAllocator->FreeChunk(pOMAP); pOMAP = nullptr; } if (pFaceIDLIST) { pAllocator->FreeChunk(pFaceIDLIST); pFaceIDLIST = nullptr; } if (pTerrainNormals) { pAllocator->FreeChunk(pTerrainNormals); pTerrainNormals = nullptr; } } //----- (0047D0A6) -------------------------------------------------------- bool OutdoorLocation::Load(char *pFilename, ODMFace *File, size_t pNumItems, int thisa) { //OutdoorLocation *pOutdoorLocation; // esi@1 /*bool result; // eax@9 bool v7; // ebx@9 size_t v8; // eax@10 void *v9; // eax@10 void *v10; // eax@10 void *v11; // eax@10 int v12; // ebx@11 BSPModel *v13; // eax@12 void *v14; // eax@12 BSPModel *v15; // ecx@12 void *v16; // eax@12 BSPModel *v17; // ecx@12 BSPModel *v18; // eax@12 __int16 v19; // ax@15 __int16 v20; // ax@16 int v21; // ecx@16 ODMFace *v22; // ebx@26 LayingItem *pItems; // ecx@27 unsigned int v24; // eax@28 //unsigned __int8 v25; // zf@28 //unsigned __int8 v26; // sf@28 ODMFace *v27; // eax@28 const char *i; // edx@29 unsigned __int16 v29; // ax@33 unsigned __int16 v30; // ax@37 int v31; // ecx@37 int v32; // eax@38 void *v33; // eax@38 TileDesc *v34; // eax@43 unsigned int v35; // eax@43 unsigned int v36; // edi@43 unsigned int v37; // edi@45*/ //size_t v38; // eax@50 FILE *v39; // eax@50 //unsigned int v40; // edi@56 //void *v41; // eax@56 //void *v42; // ebx@56 //const void *v43; // ebx@59 //const void *v44; // ebx@59 //unsigned int v45; // eax@59 //BSPModel *v46; // eax@59 //unsigned int v47; // ecx@59 //int v48; // ebx@60 //BSPModel *v49; // eax@61 //BSPModel *v50; // eax@61 //BSPModel *v51; // eax@61 //BSPModel *v52; // eax@61 //BSPModel *v53; // eax@61 //BSPModel *v54; // ecx@61 //BSPModel *v55; // ecx@61 //BSPModel *v56; // ecx@61 //void *v57; // ST24_4@61 //BSPModel *v58; // ecx@61 //void *v59; // ST18_4@61 //BSPModel *v60; // eax@61 //__int16 v61; // ax@64 unsigned __int16 v62; // ax@65 //ODMFace *v63; // ecx@65 //unsigned __int16 v64; // ax@80 //const char *v65; // ecx@80 //int v66; // eax@81 //void *v67; // eax@81 //int v68; // ecx@81 //void *v69; // eax@81 //unsigned int v70; // eax@81 //SpawnPointMM7 *v71; // eax@81 //unsigned int v72; // ecx@81 //size_t v73; // eax@81 //int v74; // edi@87 //void *v75; // edi@88 //unsigned int v76; // edx@94 //int v77; // ecx@94 //char *v78; // eax@95 //unsigned int v79; // edx@97 //unsigned int v80; // eax@99 //int v81; // eax@107 //void *v82; // edi@114 //size_t v83; // eax@120 //const void *v84; // edi@120 //const void *v85; // edi@120 //BSPModel *v86; // eax@124 //unsigned int v87; // eax@124 //BSPModel *v88; // eax@126 //BSPModel *v89; // eax@127 //ODMFace *v90; // eax@129 //const void *v91; // edi@138 //const void *v92; // edi@141 //const void *v93; // edi@141 //const void *v94; // edi@144 //const void *v95; // edi@144 //const char *v96; // edi@147 //unsigned int v97; // eax@147 //TileDesc *v98; // eax@147 //unsigned int v99; // eax@147 //int v100; // ecx@150 //unsigned int v101; // eax@157 int v102; // edi@159 //void *v103; // [sp-14h] [bp-B94h]@55 //void *v104; // [sp-10h] [bp-B90h]@59 //size_t v105; // [sp-Ch] [bp-B8Ch]@59 //char *v106; // [sp-8h] [bp-B88h]@59 int v107; // [sp-4h] [bp-B84h]@12 int v108; // [sp+0h] [bp-B80h]@10 char Src[968]; // [sp+10h] [bp-B70h]@110 char Dst[968]; // [sp+3D8h] [bp-7A8h]@50 char Str[256]; // [sp+7A0h] [bp-3E0h]@50 /*char DstBuf; // [sp+8A0h] [bp-2E0h]@10 __int32 Offset; // [sp+8A4h] [bp-2DCh]@10 __int32 v114; // [sp+8B0h] [bp-2D0h]@10 __int32 v115; // [sp+8BCh] [bp-2C4h]@10 __int32 v116; // [sp+8C8h] [bp-2B8h]@10 __int32 v117; // [sp+8D4h] [bp-2ACh]@10 __int32 v118; // [sp+8E0h] [bp-2A0h]@10 __int32 v119; // [sp+8ECh] [bp-294h]@10 __int32 v120; // [sp+8F8h] [bp-288h]@10 __int32 v121; // [sp+904h] [bp-27Ch]@10 __int32 v122; // [sp+910h] [bp-270h]@10 __int32 v123; // [sp+91Ch] [bp-264h]@10 __int32 v124; // [sp+928h] [bp-258h]@26 __int32 v125; // [sp+934h] [bp-24Ch]@35 __int32 v126; // [sp+940h] [bp-240h]@38 __int32 v127; // [sp+94Ch] [bp-234h]@38 __int32 v128; // [sp+958h] [bp-228h]@38 __int32 v129; // [sp+964h] [bp-21Ch]@38 __int32 v130; // [sp+970h] [bp-210h]@38 __int32 v131; // [sp+97Ch] [bp-204h]@38 __int32 v132; // [sp+988h] [bp-1F8h]@38 __int32 v133; // [sp+994h] [bp-1ECh]@38 __int32 v134; // [sp+9A0h] [bp-1E0h]@38 __int32 v135; // [sp+9ACh] [bp-1D4h]@38 __int32 v136; // [sp+9D0h] [bp-1B0h]@10*/ //char FileName[8]; // [sp+A20h] [bp-160h]@8 //char v138; // [sp+A28h] [bp-158h]@12 //int v139; // [sp+B1Ch] [bp-64h]@10 //char pContainer[32]; // [sp+B20h] [bp-60h]@1 //int *v141; // [sp+B40h] [bp-40h]@50 //__int64 v142; // [sp+B44h] [bp-3Ch]@55 //size_t pSource; // [sp+B4Ch] [bp-34h]@56 //int v144; // [sp+B50h] [bp-30h]@61 //int v145; // [sp+B54h] [bp-2Ch]@68 ODMHeader header; // [sp+B58h] [bp-28h]@50 //unsigned int pDestLen; // [sp+B68h] [bp-18h]@13 //FILE *ptr; // [sp+B6Ch] [bp-14h]@12 //void *v149; // [sp+B70h] [bp-10h]@19 char *Str2; // [sp+B74h] [bp-Ch]@12 //int v151; // [sp+B78h] [bp-8h]@59 //void *uSourceLen; // [sp+B7Ch] [bp-4h]@59 //pOutdoorLocation = this; //strcpy(pContainer, pFilename); if (bUnderwater) { pPaletteManager->pPalette_tintColor[0] = 0x10; pPaletteManager->pPalette_tintColor[1] = 0xC2; pPaletteManager->pPalette_tintColor[2] = 0x99; pPaletteManager->pPalette_mistColor[0] = 0x25; pPaletteManager->pPalette_mistColor[1] = 0x8F; pPaletteManager->pPalette_mistColor[2] = 0x5C; } else { pPaletteManager->pPalette_tintColor[0] = 0; pPaletteManager->pPalette_tintColor[1] = 0; pPaletteManager->pPalette_tintColor[2] = 0; if (pPaletteManager->pPalette_mistColor[0] != 0x80 || pPaletteManager->pPalette_mistColor[1] != 0x80 || pPaletteManager->pPalette_mistColor[2] != 0x80) { pPaletteManager->pPalette_mistColor[0] = 0x80; pPaletteManager->pPalette_mistColor[1] = 0x80; pPaletteManager->pPalette_mistColor[2] = 0x80; pPaletteManager->RecalculateAll(); } } _6807E0_num_decorations_with_sounds_6807B8 = 0; /*sprintf(FileName, "levels\\%s", pContainer); if ( GetFileAttributesA(FileName) != -1 ) { result = (bool)fopen(FileName, "rb"); v7 = result; File = (ODMFace *)result; if ( !result ) return result; *(int *)thisa = 1; v8 = strlen(pContainer); v108 = 2; *((char *)&v139 + v8) = 0; viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pContainer, (enum TEXTURE_TYPE)v108); fread(&DstBuf, 0x180u, 1u, (FILE *)v7); fseek((FILE *)v7, Offset, 0); fread(this, 0xB0u, 1u, (FILE *)v7); LoadTileGroupIds(); _47F3EA(); strcpy(pGroundTileset, "grastyl"); fseek((FILE *)v7, v114, 0); fread(&uNumBModels, 4u, 1u, (FILE *)v7); fseek((FILE *)v7, v115, 0); fread(&uNumLayingItems, 4u, 1u, (FILE *)v7); fseek((FILE *)v7, v116, 0); fread(&uNumLevelDecorations, 4u, 1u, (FILE *)v7); fseek((FILE *)v7, v117, 0); fread(&uNumActors, 4u, 1u, (FILE *)v7); fseek((FILE *)v7, v118, 0); fread(&uNumChests, 4u, 1u, (FILE *)v7); pTerrain.Initialize(); fseek((FILE *)v7, v119, 0); fread(pTerrain.pHeightmap, 1u, 0x4000u, (FILE *)v7); fseek((FILE *)v7, v120, 0); fread(pTerrain.pTilemap, 1u, 0x4000u, (FILE *)v7); fseek((FILE *)v7, v121, 0); fread(pTerrain.pAttributemap, 1u, 0x4000u, (FILE *)v7); pTerrain._47C80A(0, 0, 128, 128); pAllocator->FreeChunk(ptr_D4); ptr_D4 = 0; v9 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); v108 = (int)pOMAP; ptr_D4 = v9; pAllocator->FreeChunk((void *)v108); pOMAP = 0; v10 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); v108 = 0; pOMAP = (unsigned int *)v10; fseek((FILE *)v7, v136, v108); fread(&uNumTerrainNormals, 4u, 1u, (FILE *)v7); fread(pTerrainSomeOtherData, 1u, 0x20000u, (FILE *)v7); fread(pTerrainNormalIndices, 1u, 0x10000u, (FILE *)v7); pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); fread(pTerrainNormals, 1u, 12 * uNumTerrainNormals, (FILE *)v7); v11 = pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata"); v108 = 0; pBModels = (BSPModel *)v11; fseek((FILE *)v7, v122, v108); fread(pBModels, 0xBCu, uNumBModels, (FILE *)v7); fseek((FILE *)v7, v123, 0); pNumItems = 0; if ( (signed int)uNumBModels > 0 ) { v12 = 0; while ( 1 ) { pBModels[v12].pVertices.pVertices = 0; pBModels[v12].pFaces = 0; pBModels[v12].pFacesOrdering = 0; pBModels[v12].pNodes = 0; FileName[0] = 0; v108 = (int)&pBModels[v12]; sprintfex(FileName, "%s", v108); v13 = pBModels; v138 = 0; pBModels[v12].pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(v13[v12].pVertices.pVertices, 12 * v13[v12].pVertices.uNumVertices, FileName); pBModels[v12].pFaces = (ODMFace *)pAllocator->AllocNamedChunk(pBModels[v12].pFaces, 308 * pBModels[v12].uNumFaces, FileName); pBModels[v12].pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(pBModels[v12].pFacesOrdering, 2 * pBModels[v12].uNumFaces, FileName); v14 = pAllocator->AllocNamedChunk(pBModels[v12].pNodes, 8 * pBModels[v12].uNumNodes, FileName); v15 = pBModels; v108 = (int)File; v15[v12].pNodes = (BSPNode *)v14; fread(pBModels[v12].pVertices.pVertices, 0xCu, pBModels[v12].pVertices.uNumVertices, (FILE *)v108); fread(pBModels[v12].pFaces, 0x134u, pBModels[v12].uNumFaces, (FILE *)File); fread(pBModels[v12].pFacesOrdering, 2u, pBModels[v12].uNumFaces, (FILE *)File); fread(pBModels[v12].pNodes, 8u, pBModels[v12].uNumNodes, (FILE *)File); v16 = malloc(10 * pBModels[v12].uNumFaces); v107 = (int)File; v17 = pBModels; ptr = (FILE *)v16; fread(v16, 0xAu, v17[v12].uNumFaces, (FILE *)File); v18 = pBModels; Str2 = 0; if ( (signed int)v18[v12].uNumFaces > 0 ) break; LABEL_25: free(ptr); ++pNumItems; ++v12; if ( (signed int)pNumItems >= (signed int)uNumBModels ) goto LABEL_26; } pDestLen = 0; pFilename = (char *)ptr; while ( 1 ) { thisa = (int)((char *)v18[v12].pFaces + pDestLen); if ( !(*(char *)(thisa + 29) & 0x40) ) break; v19 = pTextureFrameTable->FindTextureByName(pFilename); *(short *)(thisa + 272) = v19; if ( !v19 ) { v20 = pBitmaps_LOD->LoadTexture(pFilename); v21 = thisa; *(char *)(v21 + 29) &= 0xBFu; LABEL_19: *(short *)(v21 + 272) = v20; v149 = (void *)(v20 != -1 ? &pBitmaps_LOD->pTextures[v20] : 0); auto pTex = (Texture *)v149; if (pTex) pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1); goto LABEL_20; } pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(unsigned __int16 *)((char *)&pBModels[v12].pFaces->uTextureID + pDestLen)); LABEL_20: if ( *(short *)(thisa + 292) ) { if ( ((ODMFace *)thisa)->HasEventHint() ) *(char *)(thisa + 30) |= 0x10u; else *(char *)(thisa + 30) &= 0xEFu; } ++Str2; v18 = pBModels; pDestLen += 308; pFilename += 10; if ( (signed int)Str2 >= (signed int)v18[v12].uNumFaces ) goto LABEL_25; } v20 = pBitmaps_LOD->LoadTexture(pFilename); v21 = thisa; goto LABEL_19; } LABEL_26: v22 = File; fseek((FILE *)File, v124, 0); fread(pLayingItems, 0x70u, uNumLayingItems, (FILE *)v22); if ( (signed int)uNumLayingItems > 0 ) { pItems = pLayingItems; pNumItems = uNumLayingItems; do { v24 = pItems->stru_24.uItemID; thisa = 0; v27 = (ODMFace *)(48 * v24); v25 = pObjectList->uNumObjects == 0; v26 = (pObjectList->uNumObjects & 0x80000000u) != 0; LOWORD(v27) = *(short *)((char *)&v27->pFacePlane.vNormal.x + (int)((char *)&pItemsTable + 24)); File = v27; pItems->uItemType = (unsigned __int16)v27; if ( v26 | v25 ) { LABEL_33: v29 = 0; } else { for ( i = (const char *)&pObjectList->pObjects->uObjectID; (short)v27 != *(short *)i; i = pFilename ) { ++thisa; pFilename = (char *)i + 56; if ( thisa >= (signed int)pObjectList->uNumObjects ) goto LABEL_33; LOWORD(v27) = (short)File; } v29 = thisa; } pItems->uObjectDescID = v29; ++pItems; --pNumItems; } while ( pNumItems ); } fseek((FILE *)v22, v125, 0); fread(pLevelDecorations, 0x20u, uNumLevelDecorations, (FILE *)v22); pNumItems = 0; if ( (signed int)uNumLevelDecorations > 0 ) { thisa = (int)pLevelDecorations; do { fread(FileName, 1u, 0x20u, (FILE *)v22); v30 = pDecorationList->GetDecorIdByName(FileName); v31 = thisa; ++pNumItems; thisa += 32; *(short *)v31 = v30; } while ( (signed int)pNumItems < (signed int)uNumLevelDecorations ); } fseek((FILE *)v22, v126, 0); fread(pActors, 0x344u, uNumActors, (FILE *)v22); fseek((FILE *)v22, v127, 0); fread(pChests, 0x14CCu, uNumChests, (FILE *)v22); fseek((FILE *)v22, v128, 0); fread(&field_DC, 4u, 1u, (FILE *)v22); pAllocator->FreeChunk(pFaceIDLIST); v32 = field_DC; pFaceIDLIST = 0; v33 = pAllocator->AllocNamedChunk(0, 2 * v32, "IDLIST"); v108 = (int)v22; pFaceIDLIST = (unsigned __int16 *)v33; fread(v33, 2u, field_DC, (FILE *)v108); fseek((FILE *)v22, v129, 0); fread(pOMAP, 4u, 0x4000u, (FILE *)v22); fseek((FILE *)v22, v130, 0); fread(&uNumSpawnPoints, 4u, 1u, (FILE *)v22); pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); fseek((FILE *)v22, v131, 0); fread(pSpawnPoints, 0x18u, uNumSpawnPoints, (FILE *)v22); fseek((FILE *)v22, v132, 0); fread(&ddm, 0x28u, 1u, (FILE *)v22); fseek((FILE *)v22, v133, 0); fread(&stru_5E4C90, 1u, 0xC8u, (FILE *)v22); fseek((FILE *)v22, v134, 0); fread(&uLastVisitDay, 1u, 0x38u, (FILE *)v22); fseek((FILE *)v22, v135, 0); fread(&uLastVisitDay, 1u, 4u, (FILE *)v22); thisa = (int)pTileTypes; pTileTable->InitializeTileset(4); pTileTable->InitializeTileset(pTileTypes[0].uTileGroup); pTileTable->InitializeTileset(pTileTypes[1].uTileGroup); pTileTable->InitializeTileset(pTileTypes[2].uTileGroup); pTileTable->InitializeTileset(pTileTypes[3].uTileGroup); if ( this != (OutdoorLocation *)-96 && pSkyTextureName[0] ) { v108 = 0; v107 = (int)pSkyTextureName; } else { v108 = 0; v107 = (int)pDefaultSkyTexture; } uSky_TextureID = pBitmaps_LOD->LoadTexture((const char *)v107, (enum TEXTURE_TYPE)v108); strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); v34 = pTileTable->GetTileById(pTileTypes[0].uTileID); v35 = pBitmaps_LOD->LoadTexture(v34->pTileName); v36 = uSky_TextureID; uMainTile_BitmapID = v35; if ( v36 != -1 ) pBitmaps_LOD->pTextures[v36].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v36].palette_id1); v37 = uMainTile_BitmapID; if ( v37 != -1 ) pBitmaps_LOD->pTextures[v37].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v37].palette_id1); _47F0E2(); pGameLoadingUI_ProgressBar->Progress(); fclose((FILE *)v22); goto LABEL_150; }*/ assert(sizeof(BSPModel) == 188); if (!pGames_LOD->DoesContainerExist(pFilename)) Abortf("Unable to find %s in Games.LOD", pFilename); //strcpy(FileName, pContainer); strcpy(Str, pFilename); strcpy(Str + strlen(Str) - 4, ".odm"); viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(Str, TEXTURE_16BIT_PALETTE); //v141 = &v139; //v38 = strlen(pFilename); //strcpy((char *)&v139 + v38, ".odm"); v39 = pGames_LOD->FindContainer(Str, 1); //Str[strlen(Str) - 4] = 0; header.uCompressedSize = 0; header.uDecompressedSize = 0; //ptr = v39; header.uVersion = 91969; header.pMagic[0] = 'm'; header.pMagic[1] = 'v'; header.pMagic[2] = 'i'; header.pMagic[3] = 'i'; fread(&header, 0x10u, 1u, v39); if (header.uVersion != 91969 || header.pMagic[0] != 'm' || header.pMagic[1] != 'v' || header.pMagic[2] != 'i' || header.pMagic[3] != 'i') { MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:507", 0); } //v40 = header.uCompressedSize; //pSource = header.uDecompressedSize; //v41 = malloc(header.uDecompressedSize); auto pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); auto pSrc = pSrcMem; //v42 = v41; //HIDWORD(v142) = (uint32)pSrc; if (header.uCompressedSize < header.uDecompressedSize) { auto pComressedSrc = (char *)malloc(header.uCompressedSize); fread(pComressedSrc, header.uCompressedSize, 1, v39); uint actualDecompressedSize = header.uDecompressedSize; zlib::MemUnzip(pSrc, &actualDecompressedSize, pComressedSrc, header.uCompressedSize); free(pComressedSrc); } else { fread(pSrc, header.uDecompressedSize, 1, v39); } memcpy(pLevelFilename, pSrc, 0x20); memcpy(pLocationFileName, pSrc + 0x20, 0x20); memcpy(pLocationFileDescription, pSrc + 0x40, 0x20); memcpy(pSkyTextureName, pSrc + 0x60, 0x20); memcpy(pGroundTileset, pSrc + 0x80, 0x20); memcpy(pTileTypes, pSrc + 0xA0, 0x10); pSrc += 0xB0; //v43 = (char *)pSrc + 176; LoadTileGroupIds(); _47F3EA(); strcpy(pGroundTileset, "grastyl"); pGameLoadingUI_ProgressBar->Progress(); pTerrain.Initialize(); //v108 = 16384; //v107 = (int)v43; //v106 = (char *)pTerrain.pHeightmap; memcpy(pTerrain.pHeightmap, pSrc, 0x4000); pSrc += 0x4000; //v43 = (char *)v43 + 16384; //v105 = 16384; //v104 = (void *)v43; //v103 = pTerrain.pTilemap; memcpy(pTerrain.pTilemap, pSrc, 0x4000); pSrc += 0x4000; //v43 = (char *)v43 + 16384; memcpy(pTerrain.pAttributemap, pSrc, 0x4000); pSrc += 0x4000; //v43 = (char *)v43 + 16384; //v108 = (int)ptr_D4; if (ptr_D4) { pAllocator->FreeChunk(ptr_D4); ptr_D4 = nullptr; } ptr_D4 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); pTerrain._47C80A(0, 0, 128, 128); pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumTerrainNormals, pSrc, 4); //v43 = (char *)v43 + 4; memcpy(pTerrainSomeOtherData, pSrc + 4, 0x20000); pSrc += 4 + 0x20000; //v43 = (char *)v43 + 131072; memcpy(pTerrainNormalIndices, pSrc, 0x10000); pSrc += 0x10000; //v43 = (char *)v43 + 65536; //pFilename = (char *)(12 * uNumTerrainNormals); pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); memcpy(pTerrainNormals, pSrc, 12 * uNumTerrainNormals); pSrc += 12 * uNumTerrainNormals; //v44 = (char *)v43 + (int)pFilename; //v44 = (char *)v44 + 4; //v45 = uNumBModels; //v108 = (int)"BDdata"; pGameLoadingUI_ProgressBar->Progress(); //v107 = 188 * v45; //v106 = (char *)pBModels; //v46 = (BSPModel *)pAllocator->AllocNamedChunk(v106, 188 * v45, "BDdata"); //v47 = uNumBModels; memcpy(&uNumBModels, pSrc, 4); pBModels = (BSPModel *)pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata"); //pFilename = (char *)(188 * v47); memcpy(pBModels, pSrc + 4, 188 * uNumBModels); pSrc += 4 + 188 * uNumBModels; pGameLoadingUI_ProgressBar->Progress(); //uSourceLen = (char *)v44 + (int)pFilename; //v151 = 0; for (uint i = 0; i < uNumBModels; ++i) { //v48 = 0; auto model = pBModels + i; model->pVertices.pVertices = nullptr; model->pFaces = nullptr; model->pFacesOrdering = nullptr; model->pNodes = nullptr; //FileName[0] = 0; //v108 = (int)&pBModels[i]; //sprintf(FileName, "%s", v108); //v49 = pBModels; //v138 = 0; //v50 = &pBModels[v48]; //v108 = (int)FileName; //v107 = 12 * v50->pVertices.uNumVertices; //v106 = (char *)v50->pVertices.pVertices; assert(sizeof(Vec3_int_) == 12); uint verticesSize = model->pVertices.uNumVertices * sizeof(Vec3_int_); model->pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(model->pVertices.pVertices, verticesSize, ""); memcpy(model->pVertices.pVertices, pSrc, verticesSize); pSrc += verticesSize; //v51 = &pBModels[v48]; //v108 = (int)FileName; //v107 = 308 * v51->uNumFaces; //v106 = (char *)v51->pFaces; assert(sizeof(ODMFace) == 308); uint facesSize = model->uNumFaces * sizeof(ODMFace); model->pFaces = (ODMFace *)pAllocator->AllocNamedChunk(model->pFaces, facesSize, ""); memcpy(model->pFaces, pSrc, facesSize); pSrc += facesSize; //v52 = &pBModels[v48]; //v108 = (int)FileName; //v107 = 2 * v52->uNumFaces; //v106 = (char *)v52->pFacesOrdering; uint facesOrderingSize = model->uNumFaces * sizeof(short); model->pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(model->pFacesOrdering, facesOrderingSize, ""); memcpy(model->pFacesOrdering, pSrc, facesOrderingSize); pSrc += facesOrderingSize; //v53 = &pBModels[v48]; //v108 = (int)FileName; //v107 = 8 * v53->uNumNodes; //v106 = (char *)v53->pNodes; assert(sizeof(BSPNode) == 8); uint nodesSize = model->uNumNodes * sizeof(BSPNode); model->pNodes = (BSPNode *)pAllocator->AllocNamedChunk(model->pNodes, nodesSize, ""); memcpy(model->pNodes, pSrc, nodesSize); pSrc += nodesSize; //v54 = &pBModels[v48]; //v108 = 12 * v54->pVertices.uNumVertices; //pFilename = (char *)v108; //v107 = (int)uSourceLen; //v106 = (char *)v54->pVertices.pVertices; //memcpy(v106, uSourceLen, v108); //uSourceLen = (char *)uSourceLen + (int)pFilename; //v55 = &pBModels[v48]; //v105 = 308 * v55->uNumFaces; //v104 = uSourceLen; //v103 = v55->pFaces; //pFilename = (char *)v105; //memcpy(v103, uSourceLen, v105); //v56 = &pBModels[v48]; //uSourceLen = (char *)uSourceLen + (int)pFilename; //v57 = v56->pFacesOrdering; //pFilename = (char *)(2 * v56->uNumFaces); //memcpy(v57, uSourceLen, (size_t)pFilename); //v58 = &pBModels[v48]; //uSourceLen = (char *)uSourceLen + (int)pFilename; //v59 = v58->pNodes; //pFilename = (char *)(8 * v58->uNumNodes); //memcpy(v59, uSourceLen, (size_t)pFilename); //uSourceLen = (char *)uSourceLen + (int)pFilename; //ptr = (FILE *)malloc(10 * model->uNumFaces); auto textureFilenames = (const char *)malloc(10 * model->uNumFaces); //pFilename = (char *)(10 * pBModels[v48].uNumFaces); memcpy((char *)textureFilenames, pSrc, 10 * model->uNumFaces); pSrc += 10 * model->uNumFaces; //v144 = 0; //uSourceLen = (char *)uSourceLen + (int)pFilename; //v60 = pBModels; for (uint j = 0; j < model->uNumFaces; ++j) { auto texFilename = textureFilenames + j * 10; //v149 = 0; //Str2 = (char *)ptr; auto face = model->pFaces + j; //pFilename = (char *)v149 + (unsigned int)v60[v48].pFaces; if (~face->uAttributes & 0x40) { v62 = pBitmaps_LOD->LoadTexture(texFilename); // v63 = (ODMFace *)pFilename; goto LABEL_68; } //v61 = pTextureFrameTable->FindTextureByName(texFilename); face->uTextureID = pTextureFrameTable->FindTextureByName(texFilename); if (!face->uTextureID) { v62 = pBitmaps_LOD->LoadTexture(texFilename); //v63 = (ODMFace *)pFilename; BYTE1(face->uAttributes) &= 0xBFu; LABEL_68: face->uTextureID = v62; //v145 = (signed __int16)v62 != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62] : 0; //v108 = ((signed __int16)v62 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v62].palette_id1 : 36); if ((signed __int16)v62 != -1) pBitmaps_LOD->pTextures[v62].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v62].palette_id1); goto LABEL_69; } pTextureFrameTable->LoadAnimationSequenceAndPalettes(face->uTextureID); LABEL_69: if (face->sCogTriggeredID) { if (face->HasEventHint()) BYTE2(face->uAttributes) |= 0x10u; else BYTE2(face->uAttributes) &= 0xEFu; } //++v144; //v60 = pBModels; //v149 = (char *)v149 + 308; //Str2 += 10; //if ( v144 >= (signed int)v60[v48].uNumFaces ) //goto LABEL_74; } //LABEL_74: free((void *)textureFilenames); // ++v151; // ++v48; // if ( v151 >= (signed int)uNumBModels ) // goto LABEL_75; } //LABEL_75: pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumLevelDecorations, pSrc, 4u); //uSourceLen = (char *)uSourceLen + 4; if (uNumLevelDecorations > 3000) MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:678", 0); assert(sizeof(LevelDecoration) == 32); //pFilename = (char *)(32 * uNumLevelDecorations); memcpy(pLevelDecorations, pSrc + 4, uNumLevelDecorations * sizeof(LevelDecoration)); pSrc += 4 + 32 * uNumLevelDecorations; pGameLoadingUI_ProgressBar->Progress(); //v151 = 0; //uSourceLen = (char *)uSourceLen + (int)pFilename; for (uint i = 0; i < uNumLevelDecorations; ++i) { char name[256]; memcpy(name, pSrc, 32); pSrc += 32; pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(name); } pGameLoadingUI_ProgressBar->Progress(); memcpy(&numFaceIDListElems, pSrc, 4); //uSourceLen = (char *)uSourceLen + 4; //v108 = (int)pFaceIDLIST; if (pFaceIDLIST) { pAllocator->FreeChunk(pFaceIDLIST); pFaceIDLIST = nullptr; } //v66 = field_DC; //pFaceIDLIST = 0; //v67 = pAllocator->AllocNamedChunk(0, 2 * v66, "IDLIST"); uint faceIDListSize = 2 * numFaceIDListElems; pFaceIDLIST = (unsigned short *)pAllocator->AllocNamedChunk(0, faceIDListSize, "IDLIST"); //v68 = field_DC; //pFaceIDLIST = (unsigned __int16 *)v67; //pFilename = (char *)(2 * v68); memcpy(pFaceIDLIST, pSrc + 4, faceIDListSize); pSrc += 4 + faceIDListSize; //uSourceLen = (char *)uSourceLen + (int)pFilename; pGameLoadingUI_ProgressBar->Progress(); //v108 = (int)pOMAP; //pAllocator->FreeChunk((void *)v108); //pOMAP = 0; if (pOMAP) { pAllocator->FreeChunk(pOMAP); pOMAP = nullptr; } //v69 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); pOMAP = (unsigned int *)pAllocator->AllocNamedChunk(0, 0x10000, "OMAP"); //v108 = 65536; //pOMAP = (unsigned int *)v69; memcpy(pOMAP, pSrc, 65536); pSrc += 65536; //uSourceLen = (char *)uSourceLen + 65536; pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumSpawnPoints, pSrc, 4); //uSourceLen = (char *)uSourceLen + 4; pGameLoadingUI_ProgressBar->Progress(); //v70 = uNumSpawnPoints; //v108 = (int)"Spawn"; //v107 = 24 * v70; //v106 = (char *)pSpawnPoints; assert(sizeof(SpawnPointMM7) == 24); uint spawnPointsSize = uNumSpawnPoints * sizeof(SpawnPointMM7); pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, spawnPointsSize, "Spawn"); //v72 = uNumSpawnPoints; //pSpawnPoints = v71; memcpy(pSpawnPoints, pSrc + 4, spawnPointsSize); pSrc += 4 + spawnPointsSize; pGameLoadingUI_ProgressBar->Progress(); free(pSrcMem); //v108 = (int)".ddm"; //v73 = strlen(pContainer); strcpy(Str + strlen(Str) - 4, ".ddm"); //strcpy((char *)v141 + v73, (const char *)v108); v39 = pNew_LOD->FindContainer(Str, 1);// fread(&header, 0x10u, 1u, v39); Str2 = 0; if (header.uVersion != 91969 || header.pMagic[0] != 'm' || header.pMagic[1] != 'v' || header.pMagic[2] != 'i' || header.pMagic[3] != 'i' ) { MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:746", 0); Str2 = (char *)1; } //v74 = 0; //pFilename = (char *)header.uCompressedSize; //v149 = 0; //pDestLen = header.uDecompressedSize; if ( !Str2 ) { pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); pSrc = pSrcMem; //v149 = v75; if (header.uCompressedSize == header.uDecompressedSize) fread(pSrc, header.uDecompressedSize, 1u, v39); else if (header.uCompressedSize < header.uDecompressedSize) { auto compressedMem = malloc(header.uCompressedSize); fread(compressedMem, header.uCompressedSize, 1, v39); uint actualDecompressedSize = header.uDecompressedSize; zlib::MemUnzip(pSrc, &actualDecompressedSize, compressedMem, header.uCompressedSize); free(compressedMem); } else MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:765", 0); assert(sizeof(DDM_DLV_Header) == 0x28); memcpy(&ddm, pSrc, sizeof(DDM_DLV_Header)); pSrc += sizeof(DDM_DLV_Header); //v74 = (int)((char *)v75 + 40); } //v76 = uNumBModels; //v77 = actualNumFacesInLevel = 0; uint actualNumFacesInLevel = 0; for (uint i = 0; i < uNumBModels; ++i) actualNumFacesInLevel += pBModels[i].uNumFaces; //v79 = ddm.uNumFacesInBModels; if (ddm.uNumFacesInBModels) { if ( ddm.uNumBModels ) { //v80 = ddm.uNumDecorations; if (ddm.uNumDecorations) { if (ddm.uNumFacesInBModels != actualNumFacesInLevel || ddm.uNumBModels != uNumBModels || ddm.uNumDecorations != uNumLevelDecorations ) Str2 = (char *)1; } } } if ( BYTE1(dword_6BE364_game_settings_1) & 0x20 ) pNumItems = 29030400; if ( Str2 ) { memset(Dst, 0, 0x3C8u); memset(Src, 0, 0x3C8u); goto LABEL_112; } //v81 = ddm.uLastRepawnDay; if ((unsigned int)((char *)File - ddm.uLastRepawnDay) >= pNumItems || !ddm.uLastRepawnDay) { memcpy(Dst, pSrc, 0x3C8u); memcpy(Src, pSrc + 968, 0x3C8u); LABEL_112: free(pSrcMem); ddm.uLastRepawnDay = (int)File; if (Str2 == 0) ++ddm.uNumRespawns; v108 = 0; *(int *)thisa = 1; v39 = pGames_LOD->FindContainer(Str, 0); fread(&header, 0x10, 1u, v39); //pFilename = (char *)header.uCompressedSize; //pDestLen = header.uDecompressedSize; //v82 = malloc(header.uDecompressedSize); pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); //v149 = v82; if (header.uCompressedSize == header.uDecompressedSize) fread(pSrcMem, header.uDecompressedSize, 1, v39); else if (header.uCompressedSize < header.uDecompressedSize) { auto compressedMem = malloc(header.uCompressedSize); fread(compressedMem, header.uCompressedSize, 1u, v39); uint actualDecompressedSize = header.uDecompressedSize; zlib::MemUnzip(pSrcMem, &actualDecompressedSize, compressedMem, header.uCompressedSize); free(compressedMem); } else MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:857", 0); pSrc = pSrcMem + 40; goto LABEL_120; } *(int *)thisa = 0; LABEL_120: //v108 = (int)".odm"; //v83 = strlen(pContainer); //strcpy((char *)v141 + v83, (const char *)v108); memcpy(array_528, pSrc, 0x3C8); //v84 = (const void *)(v74 + 968); memcpy(array_8F0, pSrc + 0x3C8, 0x3C8); pSrc += 2 * 0x3C8; //v85 = (char *)v84 + 968; pGameLoadingUI_ProgressBar->Progress(); if ( *(int *)thisa ) { memcpy(array_528, Dst, 0x3C8u); memcpy(array_8F0, Src, 0x3C8u); } //v25 = uNumBModels == 0; //v26 = (uNumBModels & 0x80000000u) != 0; //v151 = 0; for (uint i = 0; i < uNumBModels; ++i) { auto model = pBModels + i; //pNumItems = 0; //do //{ //v86 = pBModels; //thisa = 0; //v87 = (unsigned int)((char *)v86 + pNumItems); for (uint j = 0; j < model->uNumFaces; ++j) { auto face = model->pFaces + j; //if ( *(int *)(v87 + 76) > 0 ) //{ //File = 0; //do //{ //v106 = (char *)&File->uAttributes + *(int *)(v87 + 84); memcpy(&face->uAttributes, pSrc, 4); pSrc += 4; //v88 = pBModels; //++File; //v85 = (char *)v85 + 4; //++thisa; //v87 = (unsigned int)((char *)v88 + pNumItems); //} //while ( thisa < *(int *)(v87 + 76) ); } //v89 = pBModels; //thisa = 0; for (uint j = 0; j < model->uNumFaces; ++j) { auto face = model->pFaces + j; //pFilename = 0; //do //{ //v90 = (ODMFace *)&pFilename[*(unsigned int *)((char *)&v89->pFaces + pNumItems)]; //File = v90; if (face->sCogTriggeredID) { if (face->HasEventHint()) BYTE2(face->uAttributes) |= 0x10u; else BYTE2(face->uAttributes) &= 0xEFu; } //++thisa; //v89 = pBModels; //pFilename += 308; //} //while ( thisa < *(signed int *)((char *)&v89->uNumFaces + pNumItems) ); } //++v151; //pNumItems += 188; //} //while ( v151 < (signed int)uNumBModels ); } pGameLoadingUI_ProgressBar->Progress(); //v151 = 0; for (uint i = 0; i < uNumLevelDecorations; ++i) { //thisa = (int)&pLevelDecorations[0].field_2; //do //{ memcpy(&pLevelDecorations[i].field_2, pSrc, 2); pSrc += 2; //thisa += 32; //v85 = (char *)v85 + 2; //++v151; //} //while ( v151 < (signed int)uNumLevelDecorations ); } pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumActors, pSrc, 4); //v91 = (char *)v85 + 4; if (uNumActors > 500) MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:939", 0); pGameLoadingUI_ProgressBar->Progress(); assert(sizeof(Actor) == 836); //pFilename = (char *)(836 * uNumActors); memcpy(pActors, pSrc + 4, uNumActors * sizeof(Actor)); pSrc += 4 + uNumActors * sizeof(Actor); //v92 = (char *)v91 + (int)pFilename; pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumLayingItems, pSrc, 4); //v93 = (char *)v92 + 4; if (uNumLayingItems > 1000) MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:954", 0); pGameLoadingUI_ProgressBar->Progress(); assert(sizeof(LayingItem) == 112); //pFilename = (char *)(112 * uNumLayingItems); memcpy(pLayingItems, pSrc + 4, uNumLayingItems * sizeof(LayingItem)); pSrc += 4 + uNumLayingItems * sizeof(LayingItem); //v94 = (char *)v93 + (int)pFilename; pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumChests, pSrc, 4); //v95 = (char *)v94 + 4; if (uNumChests > 20) MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:968", 0); pGameLoadingUI_ProgressBar->Progress(); assert(sizeof(Chest) == 5324); //pFilename = (char *)(5324 * uNumChests); memcpy(pChests, pSrc + 4 , uNumChests * sizeof(Chest)); pSrc += 4 + uNumChests * sizeof(Chest); //v96 = (char *)v95 + (int)pFilename; pGameLoadingUI_ProgressBar->Progress(); memcpy(&stru_5E4C90, pSrc, 0xC8); pSrc += 0xC8; pGameLoadingUI_ProgressBar->Progress(); memcpy(&uLastVisitDay, pSrc, 0x38u); free(pSrcMem); pTileTable->InitializeTileset(4); //thisa = (int)pTileTypes; //v108 = pTileTypes[0].uTileGroup; pTileTable->InitializeTileset(pTileTypes[0].uTileGroup); //v108 = pTileTypes[1].uTileGroup; pTileTable->InitializeTileset(pTileTypes[1].uTileGroup); //v108 = pTileTypes[2].uTileGroup; pTileTable->InitializeTileset(pTileTypes[2].uTileGroup); //v108 = pTileTypes[3].uTileGroup; pTileTable->InitializeTileset(pTileTypes[3].uTileGroup); strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); //v97 = pTileTypes[0].uTileID; //v108 = 0; auto v98 = pTileTable->GetTileById(pTileTypes[0].uTileID); //v99 = pBitmaps_LOD->LoadTexture(v98->pTileName, TEXTURE_DEFAULT); uMainTile_BitmapID = pBitmaps_LOD->LoadTexture(v98->pTileName, TEXTURE_DEFAULT); if (uMainTile_BitmapID != -1) pBitmaps_LOD->pTextures[uMainTile_BitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uMainTile_BitmapID].palette_id1); _47F0E2(); LABEL_150: //v100 = HIDWORD(uLastVisitDay); //LODWORD(v142) = LODWORD(uLastVisitDay); //HIDWORD(v142) = v100; if (uLastVisitDay) { auto v108 = 28; if ( (signed int)((signed int)(signed __int64)((double)uLastVisitDay * 0.234375) / 60 / 60 / 0x18u) % 28 != pParty->uDaysPlayed ) { if ( rand() % 100 >= 20 ) v108 = dword_4EC268[rand() % dword_4EC2A8]; else v108 = dword_4EC28C[rand() % dword_4EC2AC]; sprintf(field_4F8, "plansky%d", v108); } } else { strcpy(field_4F8, "plansky3"); } //v101 = pBitmaps_LOD->LoadTexture(field_4F8); uSky_TextureID = pBitmaps_LOD->LoadTexture(field_4F8); if (uSky_TextureID != -1) pBitmaps_LOD->pTextures[uSky_TextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uSky_TextureID].palette_id1); pPaletteManager->RecalculateAll(); pSoundList->_4A9A67(53, 0); pSoundList->_4A9A67(92, 0); pSoundList->_4A9A67(57, 0); pSoundList->_4A9A67(96, 0); pSoundList->_4A9A67(64, 0); pSoundList->_4A9A67(103, 0); v102 = thisa; thisa = 3; do { if ( *(short *)v102 ) { switch ( *(short *)v102 ) { case 1: pSoundList->_4A9A67(58, 0); v108 = 0; v107 = 97; break; case 2: pSoundList->_4A9A67(52, 0); v108 = 0; v107 = 91; break; case 3: pSoundList->_4A9A67(51, 0); v108 = 0; v107 = 90; break; case 5: pSoundList->_4A9A67(62, 0); v108 = 0; v107 = 101; break; case 6: pSoundList->_4A9A67(49, 0); v108 = 0; v107 = 88; break; default: if ( *(short *)v102 != 7 ) goto LABEL_175; pSoundList->_4A9A67(61, 0); v108 = 0; v107 = 100; break; } } else { pSoundList->_4A9A67(54, 0); v108 = 0; v107 = 93; } pSoundList->_4A9A67(v107, v108); LABEL_175: v102 += 4; --thisa; } while ( thisa ); return true; } //----- (0047ECC1) -------------------------------------------------------- int OutdoorLocation::_47ECC1(signed int a2) { signed int result; // eax@2 int v3; // eax@3 if ( a2 >= 90 ) { v3 = (a2 - 90) / 36; if ( v3 && v3 != 1 && v3 != 2 ) { if ( v3 == 3 ) result = this->pTileTypes[3].uTileID; else result = a2; } else { result = this->pTileTypes[v3].uTileID; } } else { result = 0; } return result; } //----- (0047ED08) -------------------------------------------------------- unsigned int OutdoorLocation::DoGetTileTexture(unsigned int uX, unsigned int uZ) { int v3; // esi@5 unsigned int result; // eax@9 if ( (uX & 0x80000000u) != 0 || (signed int)uX > 127 || (uZ & 0x80000000u) != 0 || (signed int)uZ > 127 ) { result = 0; } else { v3 = *(&this->pTerrain.pTilemap[128 * uZ] + uX); if ( v3 < 198 ) { if ( v3 >= 90 ) v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90; } else { v3 = v3 + this->pTileTypes[3].uTileID - 198; } result = pTileTable->pTiles[v3].uBitmapID; } return result; } //----- (0047ED83) -------------------------------------------------------- int OutdoorLocation::_47ED83(signed int a2, signed int a3) { int result; // eax@5 if ( a2 < 0 || a2 > 127 || a3 < 0 || a3 > 127 ) result = 0; else result = *(&this->pTerrain.pTilemap[128 * a3] + a2); return result; } //----- (0047EDB3) -------------------------------------------------------- int OutdoorLocation::ActuallyGetSomeOtherTileInfo(unsigned int uX, unsigned int uY) { int v3; // esi@5 int result; // eax@7 if ( (uX & 0x80000000u) != 0 || (signed int)uX > 127 || (uY & 0x80000000u) != 0 || (signed int)uY > 127 ) { result = 0; } else { v3 = *(&this->pTerrain.pTilemap[128 * uY] + uX); if ( v3 >= 90 ) v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90; result = pTileTable->pTiles[v3].uAttributes; } return result; } //----- (0047EE16) -------------------------------------------------------- int OutdoorLocation::DoGetHeightOnTerrain(unsigned int uX, unsigned int uZ) { int result; // eax@5 if ( (uX & 0x80000000u) != 0 || (signed int)uX > 127 || (uZ & 0x80000000u) != 0 || (signed int)uZ > 127 ) result = 0; else result = 32 * *(&this->pTerrain.pHeightmap[128 * uZ] + uX); return result; } //----- (0047EE49) -------------------------------------------------------- int OutdoorLocation::_47EE49(signed int a2, signed int a3, int a4) { signed int v4; // eax@5 signed int v5; // eax@7 int v6; // eax@8 signed int v8; // eax@9 int v9; // eax@12 int v10; // eax@13 int v11; // eax@14 int v12; // eax@16 int v13; // eax@17 int v14; // eax@18 int v15; // eax@19 int v16; // eax@20 int v17; // eax@21 int v18; // eax@28 int v19; // eax@29 int v20; // eax@30 if ( a2 < 0 || a2 > 127 || a3 < 0 || a3 > 127 ) v4 = 0; else v4 = *(&this->pTerrain.pTilemap[128 * a3] + a2); v5 = _47ECC1(v4); if ( !v5 ) { v6 = -(a4 != 0); LOBYTE(v6) = v6 & 0xD9; return v6 + 92; } v8 = pTileTable->pTiles[v5].uTerrainType; if ( v8 <= 6 ) { if ( v8 == 6 ) { v17 = -(a4 != 0); LOBYTE(v17) = v17 & 0xD9; return v17 + 88; } if ( v8 ) { v9 = v8 - 1; if ( !v9 ) { v15 = -(a4 != 0); LOBYTE(v15) = v15 & 0xD9; return v15 + 97; } v10 = v9 - 1; if ( !v10 ) { v14 = -(a4 != 0); LOBYTE(v14) = v14 & 0xD9; return v14 + 91; } v11 = v10 - 1; if ( !v11 ) { v13 = -(a4 != 0); LOBYTE(v13) = v13 & 0xD9; return v13 + 90; } if ( v11 == 2 ) { v12 = -(a4 != 0); LOBYTE(v12) = v12 & 0xD9; return v12 + 101; } LABEL_29: v19 = -(a4 != 0); LOBYTE(v19) = v19 & 0xD9; return v19 + 95; } goto LABEL_20; } if ( v8 != 7 ) { if ( v8 != 8 ) { if ( v8 > 9 && (v8 <= 17 || v8 > 21 && v8 <= 27) ) { v18 = -(a4 != 0); LOBYTE(v18) = v18 & 0xD9; return v18 + 96; } goto LABEL_29; } LABEL_20: v16 = -(a4 != 0); LOBYTE(v16) = v16 & 0xD9; return v16 + 93; } v20 = -(a4 != 0); LOBYTE(v20) = v20 & 0xD9; return v20 + 100; } //----- (0047EF60) -------------------------------------------------------- int OutdoorLocation::_47EF60(int a2, int a3, int a4) { int v4; // ecx@1 int v5; // edx@2 int v6; // edi@2 int v7; // esi@2 int v8; // eax@4 int v9; // ebx@4 int v10; // eax@5 int v11; // eax@7 int v12; // esi@12 char v13; // al@12 int v15; // [sp+4h] [bp-14h]@7 int v16; // [sp+8h] [bp-10h]@5 int v17; // [sp+Ch] [bp-Ch]@2 OutdoorLocation *v18; // [sp+10h] [bp-8h]@1 int v19; // [sp+14h] [bp-4h]@2 int i; // [sp+24h] [bp+Ch]@5 v18 = this; v4 = a3 - 10; if ( a3 - 10 < a3 + 10 ) { v5 = v4 - a3; v6 = 88 * (a3 - 30); v7 = a2; v19 = v4 - a3; v17 = a3 + 10 - v4; while ( 1 ) { v8 = abs(v5); v9 = v7 - 10; if ( v7 - 10 < v7 + 10 ) { v16 = v8 * v8; v10 = v9 - v7; for ( i = v9 - v7; ; v10 = i ) { v11 = abs(v10); v15 = v11 * v11 + v16; if ( v15 <= 100 && v9 >= 20 && v9 <= 107 && v6 >= 0 && v6 <= 7656 ) { v12 = (v6 + v9 - 20) >> 3; v13 = 1 << (8 - (v6 + v9 - 20) % 8 - 1); v18->array_8F0[v12] |= v13; if ( v15 <= 49 ) v18->array_528[v12] |= v13; v7 = a2; } ++v9; ++i; if ( v9 >= v7 + 10 ) break; } } v6 += 88; ++v19; --v17; if ( !v17 ) break; v5 = v19; } } return 1; } //----- (0047F04C) -------------------------------------------------------- bool OutdoorLocation::_47F04C(signed int a2, signed int a3) { bool result; // eax@5 if ( a2 < 0 || a2 >= 88 || a3 < 0 || a3 >= 88 ) result = 0; else result = (this->array_528[(a2 + 88 * a3) / 8] & (unsigned __int8)(1 << (7 - (a2 + 88 * a3) % 8))) != 0; return result; } //----- (0047F097) -------------------------------------------------------- bool OutdoorLocation::_47F097(signed int a2, signed int a3) { bool result; // eax@5 if ( a2 < 0 || a2 >= 88 || a3 < 0 || a3 >= 88 ) result = 0; else result = (this->array_8F0[(a2 + 88 * a3) / 8] & (unsigned __int8)(1 << (7 - (a2 + 88 * a3) % 8))) != 0; return result; } //----- (0047F0E2) -------------------------------------------------------- bool OutdoorLocation::_47F0E2() { signed int v1; // edi@1 OutdoorLocation *v2; // ebx@1 Texture *v3; // ebp@2 v1 = 0; v2 = this; if ( (signed int)pBitmaps_LOD->uNumLoadedFiles > 0 ) { v3 = pBitmaps_LOD->pTextures; do { if ( v1 != -1 ? (int)v3 : 0 ) v3->uDecompressedSize = v2->pTerrain._47CB57((int)v3->pLevelOfDetail0, v3->palette_id2, v3->uTextureWidth * v3->uTextureHeight); ++v1; ++v3; } while ( v1 < (signed int)pBitmaps_LOD->uNumLoadedFiles ); } return 1; } //----- (0047F138) -------------------------------------------------------- bool OutdoorLocation::PrepareDecorations() { signed int v1; // ebx@1 __int16 v4; // ax@5 int v5; // eax@7 __int16 v6; // ax@14 signed int v8; // [sp+Ch] [bp-4h]@1 v1 = 0; v8 = 0; if ( !_strcmpi(pCurrentMapName, "out09.odm") ) v8 = 1; for (uint i = 0; i < uNumLevelDecorations; ++i) { auto decor = pLevelDecorations + i; pDecorationList->InitializeDecorationSprite(decor->uDecorationDescID); v4 = pDecorationList->pDecorations[decor->uDecorationDescID].uSoundID; if ( v4 && _6807E0_num_decorations_with_sounds_6807B8 < 9 ) { pSoundList->_4A9A67(v4, 0); v5 = _6807E0_num_decorations_with_sounds_6807B8++; _6807B8_level_decorations_ids[v5] = i; } if ( v8 && decor->uCog == 20 ) LOBYTE(decor->field_2) |= 0x40u; if ( !decor->field_16_event_id ) { if ( decor->IsInteractive() ) { if ( v1 < 124 ) { v6 = v1 + 75; decor->_idx_in_stru123 = v6; if ( !stru_5E4C90._decor_events[v1++] ) LOBYTE(decor->field_2) |= 0x20u; } } } } pGameLoadingUI_ProgressBar->Progress(); return true; } // 6807E0: using guessed type int _6807E0_num_decorations_6807B8; //----- (0047F223) -------------------------------------------------------- int OutdoorLocation::_47F223_LooksLikeGenerateMonsterLoot() { signed int v1; // ebx@1 char *v2; // esi@2 int v3; // eax@7 OutdoorLocation *v5; // [sp+0h] [bp-4h]@1 v5 = this; v1 = 0; if ( (signed int)uNumLayingItems > 0 ) { v2 = (char *)&pLayingItems[0].uObjectDescID; do { if ( *(short *)v2 ) { if ( !(v2[24] & 8) && !(pObjectList->pObjects[*(short *)v2].uFlags & 0x10) ) *(int *)(v2 + 10) = GetTerrainHeightsAroundParty2(*(int *)(v2 + 2), *(int *)(v2 + 6), (int *)&v5, 0); v3 = *(int *)(v2 + 34); if ( v3 ) { if ( v3 != 220 && pItemsTable->pItems[v3].uEquipType == 14 && !*(int *)(v2 + 38) ) *(int *)(v2 + 38) = rand() % 15 + 5; pItemsTable->SetSpecialBonus((ItemGen *)(v2 + 34)); } } ++v1; v2 += 112; } while ( v1 < (signed int)uNumLayingItems ); } pGameLoadingUI_ProgressBar->Progress(); return 1; } //----- (0047F2D3) -------------------------------------------------------- bool OutdoorLocation::InitalizeActors(int a1) { int v2; // ebx@1 char *v3; // esi@2 int v4; // eax@3 __int16 v5; // ax@11 int v8; // [sp+348h] [bp-8h]@1 int v9; // [sp+34Ch] [bp-4h]@1 v2 = 0; v8 = 0; v9 = 0; if ( (signed int)uNumActors > 0 ) { v3 = (char *)&pActors[0].uAttributes; while ( 1 ) { v4 = *(int *)v3; if ( !(v4 & 0x100000) ) break; if ( a1 == v2 ) goto LABEL_8; if ( v8 != v2 ) goto LABEL_9; *((short *)v3 + 70) = 19; *(int *)v3 = v4 | 0x10000; v8 = GetAlertStatus(); LABEL_17: ++v9; v3 += 836; if ( v9 >= (signed int)uNumActors ) goto LABEL_18; } if ( v8 != 1 ) { LABEL_9: *((int *)v3 + 37) = v2; *((short *)v3 + 62) = v2; if ( v4 & 0x10000 ) *((short *)v3 + 70) = 19; v5 = *((short *)v3 + 70); if ( v5 != 11 && v5 != 19 && (*((short *)v3 + 2) == (short)v2 || *((int *)v3 + 18) == v2) ) *((short *)v3 + 70) = 5; *((short *)v3 + 56) = v2; *((short *)v3 + 57) = v2; *((short *)v3 + 58) = v2; ((Actor *)(v3 - 36))->UpdateAnimation(); v3[25] = 0; ((Actor *)(v3 - 36))->PrepareSprites(0); v2 = 0; goto LABEL_17; } LABEL_8: *((short *)v3 + 70) = 19; *(int *)v3 = v4 | 0x10000; goto LABEL_17; } LABEL_18: pGameLoadingUI_ProgressBar->Progress(); Actor thisa; thisa.pMonsterInfo.uID = 45; thisa.PrepareSprites(v2); return 1; } //----- (0047F3EA) -------------------------------------------------------- bool OutdoorLocation::_47F3EA() { OutdoorLocationTileType *v1; // esi@1 v1 = &this->pTileTypes[3]; this->pTileTypes[3].uTileID = pTileTable->method_487ED6(this->pTileTypes[3].uTileGroup, 1); pTileTable->InitializeTileset(v1->uTileGroup); return 1; } //----- (0047F420) -------------------------------------------------------- bool OutdoorLocation::LoadTileGroupIds() { for (uint i = 0; i < 3; ++i) pTileTypes[i].uTileID = pTileTable->method_487ED6(pTileTypes[i].uTileGroup, 1); return true; } //----- (0047B42C) -------------------------------------------------------- unsigned int OutdoorLocation::DrawActors() { unsigned int result; // eax@1 char *v1; // edi@2 __int16 v2; // ax@3 int v3; // esi@5 float v4; // ST48_4@8 double v5; // ST38_8@8 float v6; // ST48_4@10 double v7; // ST30_8@10 unsigned int v8; // eax@11 int v9; // edx@11 __int16 v10; // dx@11 unsigned int v11; // eax@13 signed int v12; // eax@16 __int16 v13; // cx@21 SpriteFrame *v14; // eax@24 SpriteFrame *v15; // ebx@25 //int *v16; // eax@25 int v17; // eax@35 int v18; // ST78_4@36 int v19; // eax@36 int v20; // ecx@38 int v21; // eax@38 int v22; // ecx@41 int v23; // ST5C_4@43 int v24; // esi@44 signed __int64 v25; // qtt@45 int v26; // ST54_4@45 int v27; // ecx@45 RenderBillboard *v28; // esi@45 __int16 v29; // ax@46 unsigned __int8 v30; // zf@46 unsigned __int8 v31; // sf@46 signed __int16 v32; // ax@49 signed int v33; // ecx@50 int v34; // ecx@54 MonsterDesc *v35; // edx@54 int v36; // ecx@54 unsigned __int8 v37; // zf@54 unsigned __int8 v38; // sf@54 unsigned int v39; // [sp-8h] [bp-68h]@23 unsigned int v40; // [sp-4h] [bp-64h]@23 int v41; // [sp+24h] [bp-3Ch]@11 int v42; // [sp+28h] [bp-38h]@38 int v43; // [sp+28h] [bp-38h]@45 int v44; // [sp+2Ch] [bp-34h]@36 int v45; // [sp+2Ch] [bp-34h]@44 int v46; // [sp+2Ch] [bp-34h]@45 int v47; // [sp+30h] [bp-30h]@36 int v48; // [sp+30h] [bp-30h]@41 signed int v49; // [sp+34h] [bp-2Ch]@5 int v50; // [sp+34h] [bp-2Ch]@36 int v51; // [sp+34h] [bp-2Ch]@41 int v52; // [sp+34h] [bp-2Ch]@50 int v53; // [sp+38h] [bp-28h]@36 int v54; // [sp+3Ch] [bp-24h]@2 int y; // [sp+40h] [bp-20h]@5 int x; // [sp+44h] [bp-1Ch]@5 int v57; // [sp+48h] [bp-18h]@45 int v58; // [sp+4Ch] [bp-14h]@45 signed int v59; // [sp+50h] [bp-10h]@1 int X; // [sp+54h] [bp-Ch]@36 __int16 v61; // [sp+58h] [bp-8h]@5 signed __int16 v62; // [sp+5Ch] [bp-4h]@25 result = 0; v59 = 0; if ( (signed int)uNumActors > 0 ) { v54 = 0; v1 = (char *)&pActors[0].vPosition.z; do { v2 = *((short *)v1 + 15); *(int *)(v1 - 110) &= 0xFFFFFFF7u; if ( v2 == 11 || v2 == 19 ) goto LABEL_58; v3 = *(short *)v1; v49 = 0; x = *((short *)v1 - 2); y = *((short *)v1 - 1); v61 = *(short *)v1; if ( v2 == 17 ) { if ( (v1[666] & 7) != 3 || pActors[*(int *)(v1 + 666) >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) { v6 = (double)*((short *)v1 - 4) * 0.5; v7 = v6 + 6.7553994e15; v3 += LODWORD(v7); v61 = v3; } else { v49 = 1; pGame->pStru6Instance->_4A7F74(*((short *)v1 - 2), *((short *)v1 - 1), v3); v4 = (1.0 - (double)*(signed int *)(v1 + 38) / (double)*((short *)v1 + 7)) * (double)(2 * (signed int)*((short *)v1 - 4)); v5 = v4 + 6.7553994e15; v3 -= LODWORD(v5); v61 = v3; if ( v3 > *(short *)v1 ) { v61 = *(short *)v1; v3 = *(short *)v1; } } } v8 = stru_5C6E00->Atan2( *((short *)v1 - 2) - pIndoorCamera->pos.x, *((short *)v1 - 1) - pIndoorCamera->pos.y); LOWORD(v9) = *((short *)v1 + 4); v41 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v9 - v8) >> 8) & 7; v10 = *((short *)v1 + 16); if ( pParty->bTurnBasedModeOn ) { if ( v10 != 1 ) { LABEL_17: v12 = *(int *)(v1 + 38); goto LABEL_18; } v11 = pMiscTimer->uTotalGameTimeElapsed; } else { if ( v10 != 1 ) goto LABEL_17; v11 = pEventTimer->uTotalGameTimeElapsed; } v12 = v54 + v11; LABEL_18: if ( *(_QWORD *)(v1 + 146) > 0i64 || *(_QWORD *)(v1 + 162) > 0i64 ) v12 = 0; v13 = *((short *)v1 + 15); if ( v13 == 17 && !v49 ) { v40 = v12; v39 = uSpriteID_Spell11; LABEL_24: v14 = pSpriteFrameTable->GetFrame(v39, v40); goto LABEL_25; } v40 = v12; v39 = *(short *)&v1[2 * v10 + 42]; if ( v13 != 16 ) goto LABEL_24; v14 = pSpriteFrameTable->GetFrameBy_x(v39, v12); LABEL_25: v62 = 0; v15 = v14; //v16 = (int *)v14->uFlags; if (v14->uFlags & 2) v62 = 2; if (v14->uFlags & 0x40000) v62 |= 0x40u; if (v14->uFlags & 0x20000) LOBYTE(v62) = v62 | 0x80; if ((256 << v41) & v14->uFlags) v62 |= 4u; if ( v15->uGlowRadius ) { //LOBYTE(v16) = byte_4E94D3; pMobileLightsStack->AddLight(x, y, v3, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); } v17 = (x - pIndoorCamera->pos.x) << 16; if ( pIndoorCamera->sRotationX ) { v18 = (y - pIndoorCamera->pos.y) << 16; v47 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) + ((unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); v50 = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; v53 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; v44 = (v3 - pIndoorCamera->pos.z) << 16; v19 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16) + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16); X = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16) + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16); if ( v19 < 262144 || v19 > pOutdoorCamera->shading_dist_mist << 16 ) goto LABEL_58; v20 = v53 - v50; v42 = v53 - v50; v21 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); } else { v48 = (y - pIndoorCamera->pos.y) << 16; v51 = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; v22 = (unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; X = v22 + v51; if ( v22 + v51 < 262144 || v22 + v51 > pOutdoorCamera->shading_dist_mist << 16 ) goto LABEL_58; v23 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; v20 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23; v42 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23; v21 = (v3 - pIndoorCamera->pos.z) << 16; } v45 = v21; v24 = abs(v20); if ( abs(X) >= v24 ) { LODWORD(v25) = 0; HIDWORD(v25) = SLOWORD(pOutdoorCamera->int_fov_rad); v58 = v25 / X; v26 = v25 / X; LODWORD(v25) = 0; HIDWORD(v25) = SLOWORD(pOutdoorCamera->int_fov_rad); v57 = v25 / X; v27 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v26 * (signed __int64)v42) >> 16) + 32768) >> 16); v43 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v26 * (signed __int64)v42) >> 16) + 32768) >> 16); v46 = pViewport->uScreenCenterY - ((signed int)(((unsigned __int64)(v25 / X * v45) >> 16) + 32768) >> 16); result = uNumBillboardsToDraw; v28 = &pBillboardRenderList[uNumBillboardsToDraw]; if ( (signed int)uNumBillboardsToDraw >= 500 ) return result; ++uNumBillboardsToDraw; ++uNumSpritesDrawnThisFrame; *(int *)(v1 - 110) |= 8u; v28->uHwSpriteID = v15->pHwSpriteIDs[v41]; v29 = v15->uPaletteIndex; v28->uIndoorSectorID = 0; v28->uPalette = v29; v28->field_0 = (unsigned __int64)(v15->scale * (signed __int64)v58) >> 16; v30 = *(int *)(v1 + 118) == 0; v31 = *(int *)(v1 + 118) < 0; v28->field_4 = (unsigned __int64)(v15->scale * (signed __int64)v57) >> 16; if ( v31 || v31 | v30 && *(int *)(v1 + 114) <= 0u ) { if ( *(_QWORD *)(v1 + 226) > 0i64 ) { v52 = (unsigned __int64)(pGame->pStru6Instance->_4A806F((Actor *)(v1 - 146)) * (signed __int64)v28->field_4) >> 16; LABEL_53: LOWORD(v27) = v43; v28->field_4 = v52; } } else { v32 = *((short *)v1 + 61); if ( v32 ) { v33 = *((short *)v1 + 61); v28->field_0 = (unsigned __int64)(65536 / (unsigned __int16)v32 * (signed __int64)v28->field_0) >> 16; v52 = (unsigned __int64)(65536 / v33 * (signed __int64)v28->field_4) >> 16; goto LABEL_53; } } v28->uScreenSpaceX = v27; v28->some_x = x; v28->uScreenSpaceY = v46; v28->some_y = y; v28->some_z = v61; HIWORD(v34) = HIWORD(X); LOWORD(v34) = 0; v28->uPaletteSubindex = 0; v28->sZValue = v34 + (8 * v59 | 3); v28->field_14 = v59; v35 = pMonsterList->pMonsters; v36 = *((short *)v1 - 25); v37 = *(int *)(v1 + 150) == 0; v38 = *(int *)(v1 + 150) < 0; v28->field_1E = v62 | 0x200; v28->pSpriteFrame = v15; v28->uTintColor = *((int *)&v35[v36] - 36); if ( !v38 && (!(v38 | v37) || *(int *)(v1 + 146)) ) v28->field_1E = v62 | 0x200; } LABEL_58: ++v59; v54 += 32; result = v59; v1 += 836; } while ( v59 < (signed int)uNumActors ); } return result; } // 4E94D3: using guessed type char byte_4E94D3; // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; //----- (0044C1E8) -------------------------------------------------------- bool ODMFace::HasEventHint() { signed int v1; // eax@1 Event *v2; // esi@2 bool result; // eax@5 signed int v4; // eax@6 v1 = 0; if ( (signed int)(uLevelEVT_NumEvents - 1) <= 0 ) goto LABEL_5; v2 = pLevelEVT_Events; while ( v2->uEventID != this->sCogTriggeredID ) { ++v1; ++v2; if ( v1 >= (signed int)(uLevelEVT_NumEvents - 1) ) goto LABEL_5; } v4 = v1; if ( pLevelEVT[pLevelEVT_Events[v4 + 1].uEventOffsetInEVT + 4] != 1 || pLevelEVT[pLevelEVT_Events[v4].uEventOffsetInEVT + 4] != 4 ) LABEL_5: result = 0; else result = 1; return result; }