Mercurial > mm7
changeset 772:6fef3dae2551
Слияние
author | Ritor1 |
---|---|
date | Sat, 23 Mar 2013 22:23:18 +0600 |
parents | fbae3100f991 (current diff) f24fb0d64a5c (diff) |
children | b1b991f67d40 |
files | mm7_data.cpp |
diffstat | 14 files changed, 1076 insertions(+), 1191 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sat Mar 23 22:23:05 2013 +0600 +++ b/Actor.cpp Sat Mar 23 22:23:18 2013 +0600 @@ -25,7 +25,7 @@ Actor pActors[500]; -size_t uNumActors; +int uNumActors; stru319 stru_50C198; // idb
--- a/Actor.h Sat Mar 23 22:23:05 2013 +0600 +++ b/Actor.h Sat Mar 23 22:23:18 2013 +0600 @@ -287,4 +287,4 @@ extern Actor pActors[500]; -extern size_t uNumActors; \ No newline at end of file +extern int uNumActors; \ No newline at end of file
--- a/Outdoor.cpp Sat Mar 23 22:23:05 2013 +0600 +++ b/Outdoor.cpp Sat Mar 23 22:23:18 2013 +0600 @@ -42,7 +42,11 @@ Edge stru_80C9A4; Edge stru_80C9D8; - +//for future sky textures? +int dword_4EC268[9]={3,3,3,3,3,3,3,3,3}; // weak +int dword_4EC28C[7]={3,3,3,3,3,3,3}; // weak +int dword_4EC2A8=9; // weak +int dword_4EC2AC=7; // weak @@ -739,18 +743,18 @@ pAllocator->FreeChunk(pAttributemap); pAttributemap = nullptr; } - if (ptr_C) + if (pDmap) { - pAllocator->FreeChunk(ptr_C); - ptr_C = nullptr; + pAllocator->FreeChunk(pDmap); + pDmap = nullptr; } _47C7A9(); } //----- (0047C80A) -------------------------------------------------------- -int OutdoorLocationTerrain::_47C80A(int a2, int a3, int a4, int a5) -{ +void OutdoorLocationTerrain::FillDMap( int X, int Y, int W, int Z ) + { OutdoorLocationTerrain *pOutLocTerrain; // ebx@1 double v6; // st7@1 double v7; // st7@2 @@ -819,30 +823,30 @@ v46 = v8; v47 = v8; } - result = a3; - if ( a3 > a5 ) + result = Y; + if ( Y > Z ) { - v10 = a5 ^ a3; - a5 ^= a3 ^ a5; - result = a5 ^ v10; + v10 = Z ^ Y; + Z ^= Y ^ Z; + result = Z ^ v10; } - v11 = a2; - if ( a2 > a4 ) + v11 = X; + if ( X > W ) { - v12 = a4 ^ a2; - a4 ^= a2 ^ a4; - v11 = a4 ^ v12; + v12 = W ^ X; + W ^= X ^ W; + v11 = W ^ v12; } v13 = result - 1; v48 = result - 1; - if ( result - 1 <= a5 ) + if ( result - 1 <= Z ) { v39 = v11 - 1; do { v14 = v39; v50 = v39; - if ( v39 <= a4 ) + if ( v39 <= W ) { result = (v39 - 63) << 9; v49 = (v39 - 63) << 9; @@ -864,6 +868,8 @@ v24 = v22 - v19; v40 = 32 * *(char *)v23; v42 = 32 * *(char *)(v23 + 1); + + v25 = v49 - 512 - v49; v26 = (double)-((v20 - v21) * v24); v51 = v26; @@ -886,7 +892,8 @@ v31 = 31.0; v44 = 2 * (v50 + v48 * pOutLocTerrain2->field_10); pOutLocTerrain = pOutLocTerrain2; - *((char *)pOutLocTerrain2->ptr_C + v44 + 1) = (signed __int64)v31; + *((char *)pOutLocTerrain2->pDmap + v44 + 1) = (signed __int64)v31; + v32 = v49 - (v49 - 512); v33 = (double)-((v42 - v40) * (v19 - v41)); v52 = v33; @@ -908,7 +915,7 @@ if ( v38 > 31.0 ) v38 = 31.0; v13 = v48; - *((char *)pOutLocTerrain2->ptr_C + v44) = (signed __int64)v38; + *((char *)pOutLocTerrain2->pDmap + v44) = (signed __int64)v38; v14 = v50; result = v49; } @@ -917,14 +924,13 @@ v50 = v14; v49 = result; } - while ( v14 <= a4 ); + while ( v14 <= W ); } ++v13; v48 = v13; } - while ( v13 <= a5 ); + while ( v13 <= Z ); } - return result; } //----- (0047CB57) -------------------------------------------------------- @@ -1032,7 +1038,7 @@ memset(this->pHeightmap, 0, 0x4000u); memset(v1->pTilemap, 90, 0x4000u); memset(v1->pAttributemap, 0, 0x4000u); - memset(v1->ptr_C, 0, 0x8000u); + memset(v1->pDmap, 0, 0x8000u); v1->field_12 = 128; v1->field_10 = 128; v1->field_16 = 7; @@ -1045,31 +1051,15 @@ //----- (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; - } + pHeightmap= (unsigned __int8 *)pAllocator->AllocNamedChunk(pHeightmap, 0x4000u, "HMAP");//height map + pTilemap = (unsigned __int8 *)pAllocator->AllocNamedChunk(pTilemap, 0x4000u, "TMAP");//tile map + pAttributemap = (unsigned __int8 *)pAllocator->AllocNamedChunk(pAttributemap, 0x4000u, "AMAP");// + pDmap=(struct DMap *)pAllocator->AllocNamedChunk(pDmap, 0x8000u, "DMAP"); + if (pHeightmap&&pTilemap&&pAttributemap&&pDmap) + return true; else - { - result = 0; - } - return result; + return false; } //----- (0047CDE2) -------------------------------------------------------- @@ -1101,12 +1091,12 @@ 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; + v1->pTerrain.FillDMap(0, 0, 128, 128); + pAllocator->FreeChunk(v1->pCmap); + v1->pCmap = 0; v2 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); v3 = v1->pOMAP; - v1->ptr_D4 = v2; + v1->pCmap = v2; pAllocator->FreeChunk(v3); v1->pOMAP = 0; v4 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); @@ -1169,10 +1159,10 @@ pTerrain.Release(); - if (ptr_D4) + if (pCmap) { - pAllocator->FreeChunk(ptr_D4); - ptr_D4 = nullptr; + pAllocator->FreeChunk(pCmap); + pCmap = nullptr; } if (pOMAP) { @@ -1731,13 +1721,13 @@ //v43 = (char *)v43 + 16384; //v108 = (int)ptr_D4; - if (ptr_D4) + if (pCmap) { - pAllocator->FreeChunk(ptr_D4); - ptr_D4 = nullptr; + pAllocator->FreeChunk(pCmap); + pCmap = nullptr; } - ptr_D4 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); - pTerrain._47C80A(0, 0, 128, 128); + pCmap = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); + pTerrain.FillDMap(0, 0, 128, 128); pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumTerrainNormals, pSrc, 4); @@ -1875,7 +1865,7 @@ { v62 = pBitmaps_LOD->LoadTexture(texFilename); //v63 = (ODMFace *)pFilename; - BYTE1(face->uAttributes) &= 0xBFu; + face->uAttributes &= 0xFFBFu; LABEL_68: face->uTextureID = v62; //v145 = (signed __int16)v62 != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62] : 0; @@ -1889,9 +1879,9 @@ if (face->sCogTriggeredID) { if (face->HasEventHint()) - BYTE2(face->uAttributes) |= 0x10u; + face->uAttributes |= 0x1000u; else - BYTE2(face->uAttributes) &= 0xEFu; + face->uAttributes &= 0xEFFFu; } //++v144; //v60 = pBModels; @@ -1920,7 +1910,7 @@ assert(sizeof(LevelDecoration) == 32); //pFilename = (char *)(32 * uNumLevelDecorations); memcpy(pLevelDecorations, pSrc + 4, uNumLevelDecorations * sizeof(LevelDecoration)); - pSrc += 4 + 32 * uNumLevelDecorations; + pSrc += 4 + sizeof(LevelDecoration) * uNumLevelDecorations; pGameLoadingUI_ProgressBar->Progress(); @@ -1929,8 +1919,8 @@ for (uint i = 0; i < uNumLevelDecorations; ++i) { char name[256]; - memcpy(name, pSrc, 32); - pSrc += 32; + memcpy(name, pSrc, sizeof(LevelDecoration)); + pSrc += sizeof(LevelDecoration); pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(name); } @@ -2175,9 +2165,9 @@ if (face.sCogTriggeredID) { if (face.HasEventHint()) - BYTE2(face.uAttributes) |= 0x10u; + face.uAttributes |= 0x1000u; else - BYTE2(face.uAttributes) &= 0xEFu; + face.uAttributes &= 0xEFFFu; } //++thisa; //v89 = pBModels; @@ -2263,7 +2253,6 @@ pTileTable->InitializeTileset(Tileset_Dirt); pTileTable->InitializeTileset(Tileset_Snow); - //thisa = (int)pTileTypes; //v108 = pTileTypes[0].uTileGroup; pTileTable->InitializeTileset(pTileTypes[0].tileset); //v108 = pTileTypes[1].uTileGroup; @@ -2289,22 +2278,21 @@ //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 ( (signed int)((signed int)(signed __int64)((double)uLastVisitDay * 0.234375) / 60 / 60 / 24) % 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); + sprintf(sky_texture_name, "plansky%d", v108); } } else { - strcpy(field_4F8, "plansky3"); + strcpy(sky_texture_name, "plansky3"); } //v101 = pBitmaps_LOD->LoadTexture(field_4F8); - uSky_TextureID = pBitmaps_LOD->LoadTexture(field_4F8); + uSky_TextureID = pBitmaps_LOD->LoadTexture(sky_texture_name); if (uSky_TextureID != -1) pBitmaps_LOD->pTextures[uSky_TextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uSky_TextureID].palette_id1); @@ -2315,60 +2303,41 @@ pSoundList->LoadSound(96, 0); pSoundList->LoadSound(64, 0); pSoundList->LoadSound(103, 0); - v102 = thisa; - thisa = 3; - do + for (int i=0; i<3;++i) { - if ( *(short *)v102 ) - { - switch ( *(short *)v102 ) + + switch ( pTileTypes[i].tileset ) { - case 1: + case Tileset_Grass: + pSoundList->LoadSound(54, 0); + pSoundList->LoadSound(93, 0); + break; + case Tileset_Snow: pSoundList->LoadSound(58, 0); - v108 = 0; - v107 = 97; + pSoundList->LoadSound(97, 0); break; - case 2: + case Tileset_2: pSoundList->LoadSound(52, 0); - v108 = 0; - v107 = 91; + pSoundList->LoadSound(91, 0); break; - case 3: + case Tileset_3: pSoundList->LoadSound(51, 0); - v108 = 0; - v107 = 90; + pSoundList->LoadSound(90, 0); break; - case 5: + case Tileset_Water: pSoundList->LoadSound(62, 0); - v108 = 0; - v107 = 101; + pSoundList->LoadSound(101, 0); break; - case 6: + case Tileset_6: pSoundList->LoadSound(49, 0); - v108 = 0; - v107 = 88; - break; - default: - if ( *(short *)v102 != 7 ) - goto LABEL_175; - pSoundList->LoadSound(61, 0); - v108 = 0; - v107 = 100; + pSoundList->LoadSound(88, 0); break; - } - } - else - { - pSoundList->LoadSound(54, 0); - v108 = 0; - v107 = 93; - } - pSoundList->LoadSound(v107, v108); -LABEL_175: - v102 += 4; - --thisa; + case Tileset_Swamp: + pSoundList->LoadSound(61, 0); + pSoundList->LoadSound(100, 0); + break; + } } - while ( thisa ); return true; } @@ -2796,95 +2765,83 @@ //----- (0047F2D3) -------------------------------------------------------- bool OutdoorLocation::InitalizeActors(int a1) { - int v2; // ebx@1 Actor *v3; // esi@2 int v4; // eax@3 __int16 v5; // ax@11 - int v8; // [sp+348h] [bp-8h]@1 + int alert_status; // [sp+348h] [bp-8h]@1 int v9; // [sp+34Ch] [bp-4h]@1 - v2 = 0; - v8 = 0; - v9 = 0; - if ( (signed int)uNumActors > 0 ) - { - v3 = pActors;//[0].uAttributes; - while ( v9 < (signed int)uNumActors ) - { - v4 = v3->uAttributes; + alert_status = 0; + for(int i=0; i<uNumActors; ++i) + { + v4 = pActors[i].uAttributes; if ( !(v4 & 0x100000) ) - { - if ( v8 != 1 ) - { - v3->uCurrentActionTime = v2; - v3->uCurrentActionLength = v2; - if ( v4 & 0x10000 ) - v3->uAIState = (AIState) 19; - v5 = v3->uAIState; - if ( v5 != 11 && v5 != 19 && (v3->sCurrentHP == (short)v2 || v3->pMonsterInfo.uHP == v2) ) - v3->uAIState = (AIState) 5; - v3->vVelocity.x = v2; - v3->vVelocity.y = v2; - v3->vVelocity.z = v2; - v3->UpdateAnimation(); - v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; - v3->PrepareSprites(0); - v2 = 0; - } - else - { - v3->uAIState = (AIState) 19; - v3->uAttributes = v4 | 0x10000; - } - } - else if ( a1 == v2 ) - { - v3->uAIState = (AIState) 19; - v3->uAttributes = v4 | 0x10000; - } - else if ( v8 != v2 ) - { - v3->uCurrentActionTime = v2; - v3->uCurrentActionLength = v2; - if ( v4 & 0x10000 ) - v3->uAIState = (AIState) 19; - v5 = v3->uAIState; - if ( v5 != 11 && v5 != 19 && (v3->sCurrentHP == (short)v2 || v3->pMonsterInfo.uHP == v2) ) - v3->uAIState = (AIState) 5; - v3->vVelocity.x = v2; - v3->vVelocity.y = v2; - v3->vVelocity.z = v2; - v3->UpdateAnimation(); - v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; - v3->PrepareSprites(0); - v2 = 0; - } - else - { - v3->uAIState = (AIState) 19; - v3->uAttributes = v4 | 0x10000; - v8 = GetAlertStatus(); - } - ++v9; - ++v3; - } - } + { + if ( alert_status != 1 ) + { + pActors[i].uCurrentActionTime = 0; + pActors[i].uCurrentActionLength = 0; + if ( v4 & 0x10000 ) + pActors[i].uAIState = AIState::Disabled; + if ( pActors[i].uAIState != AIState::Removed && pActors[i].uAIState != AIState::Disabled && + (pActors[i].sCurrentHP == 0 || pActors[i].pMonsterInfo.uHP == 0) ) + pActors[i].uAIState = AIState::Dead; + pActors[i].vVelocity.x = 0; + pActors[i].vVelocity.y = 0; + pActors[i].vVelocity.z = 0; + pActors[i].UpdateAnimation(); + pActors[i].pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; + pActors[i].PrepareSprites(0); + } + else + { + pActors[i].uAIState = AIState::Disabled; + pActors[i].uAttributes = v4 | 0x10000; + } + } + else if ( a1 == 0 ) + { + pActors[i].uAIState = AIState::Disabled; + pActors[i].uAttributes = v4 | 0x10000; + } + else if ( alert_status != 0 ) + { + pActors[i].uCurrentActionTime = 0; + pActors[i].uCurrentActionLength = 0; + if ( v4 & 0x10000 ) + pActors[i].uAIState = AIState::Disabled; + v5 = pActors[i].uAIState; + if ( pActors[i].uAIState != AIState::Removed && pActors[i].uAIState != AIState::Disabled && + (pActors[i].sCurrentHP == 0 || pActors[i].pMonsterInfo.uHP == 0) ) + pActors[i].uAIState = AIState::Dead; + pActors[i].vVelocity.x = 0; + pActors[i].vVelocity.y = 0; + pActors[i].vVelocity.z = 0; + pActors[i].UpdateAnimation(); + pActors[i].pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; + pActors[i].PrepareSprites(0); + } + else + { + pActors[i].uAIState = AIState::Disabled; + pActors[i].uAttributes = v4 | 0x10000; + alert_status = GetAlertStatus(); + } + } + pGameLoadingUI_ProgressBar->Progress(); - - Actor thisa; - thisa.pMonsterInfo.uID = 45; - thisa.PrepareSprites(v2); + //no use for this +// Actor thisa; +// thisa.pMonsterInfo.uID = 45; +// thisa.PrepareSprites(0); return 1; } //----- (0047F3EA) -------------------------------------------------------- bool OutdoorLocation::LoadRoadTileset() { - OutdoorLocationTileType *v1; // esi@1 - - v1 = &this->pTileTypes[3]; - pTileTypes[3].uTileID = pTileTable->method_487ED6(pTileTypes[3].tileset, 1); - pTileTable->InitializeTileset(v1->tileset); + pTileTypes[3].uTileID = pTileTable->GetTileForTerrainType(pTileTypes[3].tileset, 1); + pTileTable->InitializeTileset(pTileTypes[3].tileset); return 1; } @@ -2892,7 +2849,7 @@ bool OutdoorLocation::LoadTileGroupIds() { for (uint i = 0; i < 3; ++i) - pTileTypes[i].uTileID = pTileTable->method_487ED6(pTileTypes[i].tileset, 1); + pTileTypes[i].uTileID = pTileTable->GetTileForTerrainType(pTileTypes[i].tileset, 1); return true; }
--- a/Outdoor.h Sat Mar 23 22:23:05 2013 +0600 +++ b/Outdoor.h Sat Mar 23 22:23:18 2013 +0600 @@ -5,7 +5,6 @@ #include "TileFrameTable.h" - /* 256 */ #pragma pack(push, 1) struct ODMHeader @@ -28,8 +27,13 @@ }; #pragma pack(pop) - - +#pragma pack(push, 1) +struct DMap + { + unsigned __int8 field0; + unsigned __int8 field1; + }; +#pragma pack(pop) /* 79 */ #pragma pack(push, 1) @@ -38,18 +42,19 @@ //----- (0047C794) -------------------------------------------------------- inline OutdoorLocationTerrain() { - this->pHeightmap = 0; - this->pTilemap = 0; - this->ptr_C = 0; + pHeightmap = NULL; + pTilemap = NULL; + pAttributemap = NULL; + pDmap = NULL;; this->field_10 = 0; this->field_12 = 0; - pAttributemap = nullptr; + } void _47C7A9(); void Release(); - int _47C80A(int a2, int a3, int a4, int a5); + void FillDMap(int X, int Y, int W, int Z); int _47CB57(int a1, int a2, int a3); bool ZeroLandscape(); bool Initialize(); @@ -58,7 +63,7 @@ unsigned __int8 *pHeightmap; unsigned __int8 *pTilemap; unsigned __int8 *pAttributemap; - void *ptr_C; + struct DMap *pDmap; __int16 field_10; __int16 field_12; __int16 field_14; @@ -138,7 +143,7 @@ //DLVHeader::DLVHeader(&v1->ddm); pSpawnPoints = 0; pBModels = 0; - ptr_D4 = 0; + pCmap = 0; pFaceIDLIST = 0; pOMAP = 0; } @@ -186,7 +191,7 @@ OutdoorLocationTileType pTileTypes[4]; // [3] road tileset unsigned int uNumBModels; struct OutdoorLocationTerrain pTerrain; - void *ptr_D4; + void *pCmap; struct BSPModel *pBModels; unsigned int numFaceIDListElems; unsigned __int16 *pFaceIDLIST; @@ -201,7 +206,7 @@ struct SpawnPointMM7 *pSpawnPoints; struct DDM_DLV_Header ddm; unsigned __int64 uLastVisitDay; - char field_4F8[12]; + char sky_texture_name[12]; int day_attrib; int day_fogrange_1; int day_fogrange_2;
--- a/Player.cpp Sat Mar 23 22:23:05 2013 +0600 +++ b/Player.cpp Sat Mar 23 22:23:18 2013 +0600 @@ -8276,7 +8276,7 @@ currPlayerId = 1; else if ( this == pPlayers[3] ) currPlayerId = 2; - else if ( this == pPlayers[4] ); + else if ( this == pPlayers[4] ) currPlayerId = 3; if ( var_type > VAR_AutoNotes ) {
--- a/TileFrameTable.h Sat Mar 23 22:23:05 2013 +0600 +++ b/TileFrameTable.h Sat Mar 23 22:23:18 2013 +0600 @@ -21,7 +21,7 @@ }; -enum Tileset: unsigned __int16 +enum Tileset: signed __int16 { Tileset_Grass = 0, Tileset_Snow = 1, @@ -33,12 +33,13 @@ Tileset_Swamp = 7, Tileset_8 = 8, Tileset_9 = 9, - Tileset_RoadGrassCobble = 10 + Tileset_RoadGrassCobble = 10, + Tileset_NULL =-1 }; /* 48 */ #pragma pack(push, 1) -struct TileDesc +struct TileDesc //26 { char pTileName[16]; unsigned __int16 uTileID; @@ -57,19 +58,19 @@ TileTable() { this->pTiles = nullptr; - this->uNumTiles = 0; + this->sNumTiles = 0; } ~TileTable(); TileDesc *GetTileById(unsigned int uTileID); void InitializeTileset(Tileset tileset); - int method_487ED6(signed int a1, int a2); + int GetTileForTerrainType(signed int a1, bool a2); unsigned int GetTileId(unsigned int uTerrainType, unsigned int uSection); void ToFile(); void FromFile(void *pSerialized); int FromFileTxt(const char *pFilename); - unsigned int uNumTiles; + signed int sNumTiles; struct TileDesc *pTiles; }; #pragma pack(pop)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TileTable.cpp Sat Mar 23 22:23:18 2013 +0600 @@ -0,0 +1,796 @@ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "TileFrameTable.h" +#include "FrameTableInc.h" +#include "Allocator.h" +#include "PaletteManager.h" +#include "LOD.h" + +#include "mm7_data.h" + + +//----- (00487E1D) -------------------------------------------------------- +TileTable::~TileTable() +{ + if ( pTiles ) + { + pAllocator->FreeChunk(pTiles); + pTiles = nullptr; + } + sNumTiles = 0; +} + +//----- (00487E3B) -------------------------------------------------------- +TileDesc *TileTable::GetTileById(unsigned int uTileID) +{ + /*TileDesc *result; // eax@3 + + if ( (uTileID & 0x80000000u) != 0 || (signed int)uTileID > (signed int)(this->uNumTiles - 1) ) + result = this->pTiles; + else + result = &this->pTiles[uTileID]; + return result;*/ + + assert(uTileID < sNumTiles); + return &pTiles[uTileID]; +} + +//----- (00487E58) -------------------------------------------------------- +void TileTable::InitializeTileset(Tileset tileset) +{ + for (int i = 0; i < sNumTiles; ++i ) + { + if (pTiles[i].tileset == tileset && pTiles[i].pTileName[0] ) + { + pTiles[i].uBitmapID = pBitmaps_LOD->LoadTexture(pTiles[i].pTileName); + if ( pTiles[i].uBitmapID != -1 ) + pBitmaps_LOD->pTextures[pTiles[i].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pTiles[i].uBitmapID].palette_id1); + } + } +} + +//----- (00487ED6) -------------------------------------------------------- +int TileTable::GetTileForTerrainType( signed int terrain_type, bool not_random ) + { + int v5; // edx@3 + int v6; // edx@11 + + if ( not_random || terrain_type > 8 ) + { + return GetTileId(terrain_type, 0); + } + v5 = rand() % 50; + if ( v5 < 20) + { + return GetTileId(terrain_type, 0); + } + else if ( v5 < 30 ) + { + return GetTileId(terrain_type, 1); + } + else if ( v5 < 40 ) + { + return GetTileId(terrain_type, 2); + } + else if ( v5 < 48 ) + { + return GetTileId(terrain_type, 3); + } + v6 = rand() % 8; + return GetTileId(terrain_type, v6+4); + return 0; +} + +//----- (00487F84) -------------------------------------------------------- +unsigned int TileTable::GetTileId(unsigned int uTerrainType, unsigned int uSection) +{ + for (int i=0; i<sNumTiles; ++i) + { + if( (pTiles[i].tileset==uTerrainType)&&(pTiles[i].uSection==uSection)) + return i; + } + return 0; +} + +//----- (00487FB4) -------------------------------------------------------- +void TileTable::ToFile() +{ + TileTable *v1; // esi@1 + FILE *v2; // eax@1 + FILE *v3; // edi@1 + + auto Str = this; + + v1 = Str; + v2 = fopen("data\\dtile.bin", "wb"); + v3 = v2; + if ( !v2 ) + Abortf("Unable to save dtile.bin!"); + fwrite(v1, 4u, 1u, v2); + fwrite(v1->pTiles, 0x1Au, v1->sNumTiles, v3); + fclose(v3); +} + +//----- (00488000) -------------------------------------------------------- +void TileTable::FromFile(void *pSerialized) +{ + sNumTiles = *(int *)pSerialized; + pTiles = (TileDesc *)pAllocator->AllocNamedChunk(pTiles, sizeof(TileDesc) * sNumTiles, "Tile Descrip"); + memcpy(pTiles, (char *)pSerialized + 4, sizeof(TileDesc) * sNumTiles); +} + +//----- (00488047) -------------------------------------------------------- +int TileTable::FromFileTxt(const char *pFilename) +{ + TileTable *v2; // ebp@1 + FILE *v3; // eax@1 + unsigned int v4; // ebx@3 + void *v5; // eax@9 + unsigned __int16 v6; // ax@14 + const char *v7; // ST14_4@14 + unsigned __int16 v8; // ax@14 + const char *v9; // esi@14 + int v10; // eax@17 + int v11; // eax@20 + int v12; // eax@22 + int v13; // eax@24 + int v14; // eax@26 + int v15; // eax@28 + int v16; // eax@30 + int v17; // eax@32 + int v18; // eax@34 + int v19; // eax@36 + int v20; // eax@38 + int v21; // eax@40 + int v22; // eax@42 + int v23; // eax@44 + int v24; // eax@46 + int v25; // eax@48 + int v26; // eax@50 + int v27; // eax@52 + int v28; // eax@54 + int v29; // eax@56 + int v30; // eax@58 + int v31; // eax@60 + int v32; // eax@62 + int v33; // eax@64 + int v34; // eax@66 + const char *v35; // esi@67 + int v36; // eax@70 + int v37; // eax@73 + int v38; // eax@75 + int v39; // eax@77 + int v40; // eax@79 + int v41; // eax@81 + int v42; // eax@83 + int v43; // eax@85 + int v44; // eax@87 + int v45; // eax@89 + int v46; // eax@91 + int v47; // eax@93 + int v48; // eax@108 + int v49; // eax@110 + int v50; // eax@112 + int v51; // eax@114 + int v52; // eax@116 + int v53; // eax@118 + int v54; // eax@120 + int v55; // eax@122 + int v56; // eax@124 + int v57; // eax@126 + int v58; // eax@128 + int v59; // eax@130 + int v60; // eax@132 + int v61; // eax@134 + int v62; // eax@136 + int v63; // eax@138 + int v64; // eax@140 + int v65; // eax@142 + int v66; // eax@144 + int v67; // eax@146 + int v68; // eax@148 + int v69; // eax@150 + int v70; // eax@151 + int j; // edi@152 + const char *v72; // esi@153 + int v73; // eax@154 + int v74; // eax@156 + int v75; // eax@160 + int v76; // eax@162 + int v77; // eax@164 + int v78; // eax@166 + int v79; // eax@168 + int v80; // eax@170 + FILE *i; // [sp-10h] [bp-304h]@3 + FILE *File; // [sp+4h] [bp-2F0h]@1 + FrameTableTxtLine v84; // [sp+8h] [bp-2ECh]@4 + FrameTableTxtLine v85; // [sp+84h] [bp-270h]@4 + char Buf; // [sp+100h] [bp-1F4h]@4 + + v2 = this; + v3 = fopen(pFilename, "r"); + File = v3; + if ( !v3 ) + Abortf("TileTable::load - Unable to open file: %s."); + v4 = 0; + for ( i = v3; fgets(&Buf, 490, i); i = File ) + { + *strchr(&Buf, 10) = 0; + memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); + if ( v84.uPropCount && *v84.pProperties[0] != 47 ) + ++v4; + } + v2->sNumTiles = v4; + v5 = pAllocator->AllocNamedChunk(v2->pTiles, 26 * v4, "Tile Descrip"); + v2->pTiles = (TileDesc *)v5; + if ( !v5 ) + Abortf("TileTable::Load - Out of Memory!"); + memset(v5, 0, 26 * v2->sNumTiles); + v2->sNumTiles = 0; + fseek(File, 0, 0); + if ( fgets(&Buf, 490, File) ) + { + while ( 1 ) + { + *strchr(&Buf, 10) = 0; + memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); + if ( v84.uPropCount ) + { + if ( *v84.pProperties[0] != 47 ) + break; + } +LABEL_173: + if ( !fgets(&Buf, 490, File) ) + goto LABEL_174; + } + strcpy(v2->pTiles[v2->sNumTiles].pTileName, v84.pProperties[0]); + v6 = atoi(v84.pProperties[1]); + v7 = v84.pProperties[2]; + v2->pTiles[v2->sNumTiles].uTileID = v6; + v8 = atoi(v7); + v9 = v84.pProperties[3]; + v2->pTiles[v2->sNumTiles].uBitmapID = v8; + v2->pTiles[v2->sNumTiles].tileset = Tileset_Grass; + if ( _strcmpi(v9, "TTtype_NULL") ) + { + if ( _strcmpi(v9, "TTtype_Start") ) + { + if ( _strcmpi(v9, "TTtype_Grass") ) + { + if ( _strcmpi(v9, "TTtype_Cracked") ) + { + if ( _strcmpi(v9, "TTtype_Snow") ) + { + if ( _strcmpi(v9, "TTtype_Sand") ) + { + if ( _strcmpi(v9, "TTtype_Volcano") ) + { + if ( _strcmpi(v9, "TTtype_Dirt") ) + { + if ( _strcmpi(v9, "TTtype_Water") ) + { + if ( _strcmpi(v9, "TTtype_Tropical") ) + { + if ( _strcmpi(v9, "TTtype_Swamp") ) + { + if ( _strcmpi(v9, "TTtype_City") ) + { + if ( _strcmpi(v9, "TTtype_RoadGrassCobble") ) + { + if ( _strcmpi(v9, "TTtype_RoadGrassDirt") ) + { + if ( _strcmpi(v9, "TTtype_RoadCrackedCobble") ) + { + if ( _strcmpi(v9, "TTtype_RoadCrackedDirt") ) + { + if ( _strcmpi(v9, "TTtype_RoadSandCobble") ) + { + if ( _strcmpi(v9, "TTtype_RoadSandDirt") ) + { + if ( _strcmpi(v9, "TTtype_RoadVolcanoCobble") ) + { + if ( _strcmpi(v9, "TTtype_RoadVolcanoDirt") ) + { + if ( _strcmpi(v9, "TTtype_RoadSwampCobble") ) + { + if ( _strcmpi(v9, "TTtype_RoadSwampDirt") ) + { + if ( _strcmpi(v9, "TTtype_RoadTropicalCobble") ) + { + if ( _strcmpi(v9, "TTtype_RoadTropicalDirt") ) + { + if ( _strcmpi(v9, "TTtype_RoadSnowCobble") ) + { + if ( _strcmpi(v9, "TTtype_RoadSnowDirt") ) + { + if ( !_strcmpi(v9, "TTtype_RoadCityStone") ) + { + v34 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v34 |= 0x1Cu; + } + } + else + { + v33 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v33 |= 0xDu; + } + } + else + { + v32 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v32 |= 0xCu; + } + } + else + { + v31 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v31 |= 0x1Bu; + } + } + else + { + v30 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v30 |= 0x1Au; + } + } + else + { + v29 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v29 |= 0x19u; + } + } + else + { + v28 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v28 |= 0x18u; + } + } + else + { + v27 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v27 |= 0x11u; + } + } + else + { + v26 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v26 |= 0x10u; + } + } + else + { + v25 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v25 |= 0xFu; + } + } + else + { + v24 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v24 |= 0xEu; + } + } + else + { + v23 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v23 |= 0x17u; + } + } + else + { + v22 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v22 |= 0x16u; + } + } + else + { + v21 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v21 |= 0xBu; + } + } + else + { + v20 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v20 |= 0xAu; + } + } + else + { + v19 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v19 |= 9u; + } + } + else + { + v18 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v18 |= 7u; + } + } + else + { + v17 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v17 |= 8u; + } + } + else + { + v16 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v16 |= 5u; + } + } + else + { + v15 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v15 |= 4u; + } + } + else + { + v14 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v14 |= 3u; + } + } + else + { + v13 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v13 |= 2u; + } + } + else + { + v12 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v12 |= 1u; + } + } + else + { + v11 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v11 |= 6u; + } + } + } + else + { + v10 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v10 |= 0xFEu; + } + } + else + { + LOBYTE(v2->pTiles[v2->sNumTiles].tileset) = -1; + } + v35 = v84.pProperties[4]; + v2->pTiles[v2->sNumTiles].uSection = 0; + v2->pTiles[v2->sNumTiles].uAttributes = 0; + if ( !_strcmpi(v35, "TTsect_NULL") ) + { + LOBYTE(v2->pTiles[v2->sNumTiles].uSection) = -1; +LABEL_152: + for ( j = 5; j < v84.uPropCount; ++j ) + { + v72 = v84.pProperties[j]; + if ( _strcmpi(v84.pProperties[j], "TTattr_Burn") ) + { + if ( _strcmpi(v72, "TTattr_Water") ) + { + if ( _strcmpi(v72, "TTattr_Water2") ) + { + if ( _strcmpi(v72, "TTattr_Block") ) + { + if ( _strcmpi(v72, "TTattr_Repulse") ) + { + if ( _strcmpi(v72, "TTattr_Flat") ) + { + if ( _strcmpi(v72, "TTattr_Wave") ) + { + if ( _strcmpi(v72, "TTattr_NoDraw") ) + { + if ( !_strcmpi(v72, "TTattr_Transition") ) + { + v80 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(short *)v80 |= 0x200u; + } + } + else + { + v79 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v79 |= 0x40u; + } + } + else + { + v78 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v78 |= 0x20u; + } + } + else + { + v77 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v77 |= 0x10u; + } + } + else + { + v76 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v76 |= 8u; + } + } + else + { + v75 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v75 |= 4u; + } + } + else + { + HIBYTE(v2->pTiles[v2->sNumTiles].uAttributes) |= 1u; + } + } + else + { + v74 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v74 |= 2u; + } + } + else + { + v73 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v73 |= 1u; + } + } + ++v2->sNumTiles; + goto LABEL_173; + } + if ( !_strcmpi(v35, "TTsect_Start") ) + { + v36 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v36 |= 0xFEu; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Base1") ) + goto LABEL_152; + if ( !_strcmpi(v35, "TTsect_Base2") ) + { + v37 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v37 |= 1u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Base3") ) + { + v38 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v38 |= 2u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Base4") ) + { + v39 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v39 |= 3u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Special1") ) + { + v40 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v40 |= 4u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Special2") ) + { + v41 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v41 |= 5u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Special3") ) + { + v42 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v42 |= 6u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Special4") ) + { + v43 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v43 |= 7u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Special5") ) + { + v44 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v44 |= 8u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Special6") ) + { + v45 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v45 |= 9u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Special7") ) + { + v46 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v46 |= 0xAu; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_Special8") ) + { + v47 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v47 |= 0xBu; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_NE1") ) + goto LABEL_130; + if ( !_strcmpi(v35, "TTsect_NW1") ) + goto LABEL_134; + if ( !_strcmpi(v35, "TTsect_SE1") ) + goto LABEL_130; + if ( !_strcmpi(v35, "TTsect_SW1") ) + goto LABEL_134; + if ( !_strcmpi(v35, "TTsect_E1") ) + goto LABEL_138; + if ( !_strcmpi(v35, "TTsect_W1") ) + goto LABEL_140; + if ( !_strcmpi(v35, "TTsect_N1") ) + goto LABEL_142; + if ( !_strcmpi(v35, "TTsect_S1") ) + goto LABEL_144; + if ( !_strcmpi(v35, "TTsect_XNE1") ) + goto LABEL_146; + if ( _strcmpi(v35, "TTsect_XNW1") ) + { + if ( !_strcmpi(v35, "TTsect_XSE1") ) + goto LABEL_146; + if ( _strcmpi(v35, "TTsect_XSW1") ) + { + if ( !_strcmpi(v35, "TTsect_CROS") ) + { +LABEL_151: + v70 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(short *)v70 |= 0x200u; + goto LABEL_152; + } + if ( !_strcmpi(v35, "TTsect_NS") ) + { + v48 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v48 |= 1u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_EW") ) + { + v49 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v49 |= 2u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_N_E") ) + { + v50 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v50 |= 3u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_N_W") ) + { + v51 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v51 |= 4u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_S_E") ) + { + v52 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v52 |= 5u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_S_W") ) + { + v53 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v53 |= 6u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_NS_E") ) + { + v54 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v54 |= 7u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_NS_W") ) + { + v55 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v55 |= 8u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_EW_N") ) + { + v56 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v56 |= 9u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_EW_S") ) + { + v57 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v57 |= 0xAu; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_NCAP") ) + { + v58 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v58 |= 0xBu; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_ECAP") ) + { +LABEL_130: + v59 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v59 |= 0xCu; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_SCAP") ) + { + v60 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v60 |= 0xDu; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_WCAP") ) + { +LABEL_134: + v61 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v61 |= 0xEu; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_DN") ) + { + v62 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v62 |= 0xFu; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_DS") ) + { +LABEL_138: + v63 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v63 |= 0x10u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_DW") ) + { +LABEL_140: + v64 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v64 |= 0x11u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_DE") ) + { +LABEL_142: + v65 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v65 |= 0x12u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_DSW") ) + { +LABEL_144: + v66 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v66 |= 0x13u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_DNE") ) + { +LABEL_146: + v67 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v67 |= 0x14u; + goto LABEL_151; + } + if ( !_strcmpi(v35, "TTsect_DSE") ) + { + v68 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v68 |= 0x15u; + goto LABEL_151; + } + if ( _strcmpi(v35, "TTsect_DNW") ) + goto LABEL_152; + } + } + v69 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v69 |= 0x16u; + goto LABEL_151; + } +LABEL_174: + fclose(File); + return 1; +} +
--- a/UIHouses.cpp Sat Mar 23 22:23:05 2013 +0600 +++ b/UIHouses.cpp Sat Mar 23 22:23:18 2013 +0600 @@ -409,7 +409,7 @@ dword_F8B1E4 = 0; dword_F8B1F4 = 0; memset(byte_F8B1F0, 0, 4); - memset(byte_F8B148, 0, 16); + memset(player_levels, 0, 16); pRenderer->ClearZBuffer(0, 479); if (((uCloseTime - 1 <= uOpenTime)&&((pParty->uCurrentHour <uOpenTime)&&(pParty->uCurrentHour >(uCloseTime - 1))))|| @@ -738,7 +738,7 @@ } if ( v1 > pParty->uNumGold ) { - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); v2 = pParty->uNumGold; } if ( v2 > pParty->uFine ) @@ -834,7 +834,7 @@ } if ( v6 > pParty->uNumGold ) { - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); v7 = pParty->uNumGold; } if ( v7 ) @@ -881,7 +881,7 @@ { if ( v2 > pParty->uNumGoldInBank ) { - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); v3 = pParty->uNumGoldInBank; } if ( v3 ) @@ -1194,7 +1194,7 @@ { Party::TakeGold((unsigned int)pOutString); v27 = (int)window_SpeakInHouse->ptr_1C; - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); dialog_menu_id = HOUSE_DIALOGUE_NULL; sub_4BD8B5(); sub_4B1D27(); @@ -1553,7 +1553,7 @@ v106.x = 0; do { - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID);//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) ++v106.x; ++v55; } @@ -2056,7 +2056,7 @@ v114 = 0; do { - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID); + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID) { v46 = ItemsInShopTexture[v114]; v47 = 152 - v46->uTextureHeight; @@ -2083,7 +2083,7 @@ v114 = 0; do { - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID); + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID) { v50 = ItemsInShopTexture[v114 + 6]; v51 = 308 - v50->uTextureHeight; @@ -2116,7 +2116,7 @@ v109 = 0; do { - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID); + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID) ++v109; ++v62; } @@ -2702,7 +2702,7 @@ v149 = 0; for(int i=0; i<8; ++i) { - if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID); + if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID) ++v149; } @@ -3242,7 +3242,7 @@ if ( pParty->uNumGold < v63 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); //"You don't have enough gold" - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); } else { @@ -3726,7 +3726,7 @@ { LABEL_55: ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); goto LABEL_46; } Party::TakeGold(v2); @@ -3844,7 +3844,7 @@ } //----- (004B4710) -------------------------------------------------------- -int __cdecl TrainingDialog() +void TrainingDialog() { //Player *v0; // ebx@1 int color2; // eax@1 @@ -3858,7 +3858,7 @@ double v9; // st7@6 signed int v10; // esi@6 int v11; // ecx@6 - int result; // eax@9 + //int result; // eax@9 GUIWindow *v13; // edi@14 signed int v14; // esi@14 unsigned int v15; // esi@16 @@ -3874,29 +3874,29 @@ unsigned int v25; // ecx@28 int v26; // eax@28 unsigned __int16 v27; // ax@28 - int v28; // eax@32 + //int v28; // eax@32 unsigned __int16 v29; // ST14_2@34 int v30; // eax@34 - const char *v31; // ST18_4@36 - unsigned __int16 v32; // ST14_2@36 + //const char *v31; // ST18_4@36 + //unsigned __int16 v32; // ST14_2@36 int v33; // eax@36 int v34; // eax@37 unsigned int v35; // edi@38 unsigned int v36; // eax@38 - int v37; // ecx@41 - char *v38; // eax@41 - int *v39; // eax@45 + //int v37; // ecx@41 + //char *v38; // eax@41 + //int *v39; // eax@45 unsigned int v40; // eax@46 - void *v41; // ecx@46 + //void *v41; // ecx@46 unsigned int v42; // eax@46 GUIWindow *v43; // ecx@59 int v44; // edx@59 char **v45; // esi@60 - int v46; // eax@62 + //int v46; // eax@62 int v47; // eax@68 - int v48; // edx@69 + //int v48; // edx@69 int v49; // ebx@69 - unsigned __int8 v50; // sf@69 + //unsigned __int8 v50; // sf@69 char **v51; // edi@70 GUIButton *v52; // eax@71 GUIButton *v53; // esi@71 @@ -3905,12 +3905,12 @@ int v56; // eax@71 unsigned __int16 v57; // ax@71 unsigned __int16 v58; // [sp-Ch] [bp-90h]@38 - const char *v59; // [sp-Ch] [bp-90h]@63 + //const char *v59; // [sp-Ch] [bp-90h]@63 char *v60; // [sp-8h] [bp-8Ch]@38 - char *v61; // [sp-8h] [bp-8Ch]@63 + //char *v61; // [sp-8h] [bp-8Ch]@63 unsigned int v62; // [sp-4h] [bp-88h]@38 int v63; // [sp-4h] [bp-88h]@52 - char *v64; // [sp-4h] [bp-88h]@63 + //char *v64; // [sp-4h] [bp-88h]@63 GUIWindow v65; // [sp+Ch] [bp-78h]@1 //__int64 v66; // [sp+60h] [bp-24h]@3 unsigned int white; // [sp+68h] [bp-1Ch]@1 @@ -3926,7 +3926,7 @@ v65.uFrameX = 483; v65.uFrameWidth = 148; v65.uFrameZ = 334; - white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); + white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255); color2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u); //v71 = color2; //v2 = v0->uLevel; @@ -3938,7 +3938,7 @@ v5 = 1000ui64 * pPlayers[uActiveCharacter]->uLevel * (pPlayers[uActiveCharacter]->uLevel + 1) / 2; // E n = n(n + 1) / 2 //v6 = HIDWORD(v0->uExperience); //v7 = window_SpeakInHouse->ptr_1C; - v68 = pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89]; + v68 = pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_TRAINING_HALL_EMERALD_ISLE]; //v66 = 1000 * v3; if (pPlayers[uActiveCharacter]->uExperience >= v5) { @@ -3955,18 +3955,16 @@ v11 = v10 / 3; //i = v11; } - result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); - if ( result ) + + if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) { if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) { - if ( dialog_menu_id != HOUSE_DIALOGUE_TRAININGHALL_17 ) + if ( dialog_menu_id != HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) { - result = dialog_menu_id - 96; if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) { - result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); - if ( result ) + if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) { //i = 0; int _v0 = 0; @@ -4000,11 +3998,11 @@ v73 = (signed int)(149 - _v0) / v72; if ( v73 > 32 ) v73 = 32; - result = v13->pStartingPosActiveItem; + //result = v13->pStartingPosActiveItem; v19 = (signed int)(149 - v72 * v73 - _v0) / 2 - v73 / 2 + 162; - int _v1 = result; + int _v1 = v13->pStartingPosActiveItem; v68 = v19; - if ( result < result + v13->pNumPresenceButton ) + if (v13->pStartingPosActiveItem < v13->pStartingPosActiveItem + v13->pNumPresenceButton ) { v72 = 2; do @@ -4034,12 +4032,10 @@ v27 = white; v65.DrawTitleText(pFontArrus, 0, v25, v27, v23, 3u); } - v28 = v13->pStartingPosActiveItem; ++_v1; - result = v13->pNumPresenceButton + v28; ++v72; } - while ( (signed int)_v1 < result ); + while ( (signed int)_v1 < v13->pStartingPosActiveItem + v13->pNumPresenceButton ); } } else @@ -4051,21 +4047,20 @@ strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." v29 = color2; v30 = pFontArrus->CalcTextHeight(pTmpBuf, &v65, 0, 0); - result = (int)v65.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf, 3u); + (int)v65.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf, 3u); } } } - return result; + return; } if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { - v31 = pNPCTopics[122].pText; - v32 = color2; + //v31 = pNPCTopics[122].pText; + //v32 = color2; v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &v65, 0, 0); - v65.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, v32, v31, 3); - result = (int)pDialogueWindow; + v65.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, color2, pNPCTopics[122].pText, 3); pDialogueWindow->pNumPresenceButton = 0; - return result; + return; } v34 = pPlayers[uActiveCharacter]->uLevel; if ( v34 < v68 ) @@ -4075,28 +4070,28 @@ if ( pParty->uNumGold >= v11) { Party::TakeGold(v11); - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); ++pPlayers[uActiveCharacter]->uLevel; pPlayers[uActiveCharacter]->uSkillPoints += pPlayers[uActiveCharacter]->uLevel / 10 + 5; pPlayers[uActiveCharacter]->sHealth = pPlayers[uActiveCharacter]->GetMaxHealth(); pPlayers[uActiveCharacter]->sMana = pPlayers[uActiveCharacter]->GetMaxMana(); - v37 = 0; - v38 = byte_F8B148; - do + + uint max_level_in_party = player_levels[0]; + for (uint _it = 1; _it < 4; ++_it) { - if ( *(int *)v38 > v37 ) - v37 = *(int *)v38; - v38 += 4; + if (player_levels[_it] > max_level_in_party) + max_level_in_party = player_levels[_it]; } - while ( (signed int)v38 < (signed int)word_F8B158 ); - v39 = &dword_F8B144 + uActiveCharacter; - ++*v39; - if ( *v39 > v37 ) + + ++player_levels[uActiveCharacter - 1]; + if (player_levels[uActiveCharacter - 1] > max_level_in_party) // if we reach new maximum party level + // feature is broken thou, since this array is always zeroed in EnterHouse { - v40 = sub_494820(pParty->uCurrentHour); - v41 = window_SpeakInHouse->ptr_1C; + v40 = _494820_training_time(pParty->uCurrentHour); + //v41 = window_SpeakInHouse->ptr_1C; v42 = 60 * (v40 + 4) - pParty->uCurrentMinute; - if ( v41 == (void *)94 || v41 == (void *)95 ) + if ((unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_94 || + (unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_95) v42 += 720; RestAndHeal((signed int)(v42 + 10080)); if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) @@ -4107,7 +4102,7 @@ // "%s is now Level %lu and has earned %lu Skill Points!" ShowStatusBarString(pTmpBuf, 2); pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - return true; + return; } ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" v63 = 4; @@ -4125,7 +4120,7 @@ } return result;*/ pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - return 1; // void function actually + return; } sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[538], (unsigned int)(v5 - pPlayers[uActiveCharacter]->uExperience), v34 + 1);// // "You need %d more experience to train to level %d" @@ -4150,8 +4145,8 @@ v63 = 3; goto LABEL_55; } - result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); - if ( result ) + + if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) { v43 = pDialogueWindow; v72 = 0; @@ -4164,31 +4159,21 @@ v45 = pShopOptions; do { - if ( v43->GetControl(v73)->uControlParam == 17 ) + if ( v43->GetControl(v73)->uControlParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) { - v46 = pPlayers[uActiveCharacter]->uLevel; - if ( v46 < v68 ) - { - if ( (signed __int64)pPlayers[uActiveCharacter]->uExperience < v5 ) - { - v64 = (char *)(v46 + 1); - v61 = (char *)(v5 - LODWORD(pPlayers[uActiveCharacter]->uExperience)); - v59 = pGlobalTXT_LocalizationStrings[538];// "You need %d more experience to train to level %d" - } - else - { - v64 = (char *)v11; - v61 = (char *)(v46 + 1); - v59 = pGlobalTXT_LocalizationStrings[537];// "Train to level %d for %d gold" - } - } + //v46 = pPlayers[uActiveCharacter]->uLevel; + if (pPlayers[uActiveCharacter]->uLevel >= v68) + sprintfex(*v45, "%s\n \n%s", + pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]); //"With your skills, you should be working here as a teacher." "Sorry, but we are unable to train you." else { - v64 = pGlobalTXT_LocalizationStrings[529];// ""Sorry, but we are unable to train you."" - v61 = pGlobalTXT_LocalizationStrings[536];// ""With your skills, you should be working here as a teacher."" - v59 = "%s\n \n%s"; + if (pPlayers[uActiveCharacter]->uExperience < v5) + sprintfex(*v45, pGlobalTXT_LocalizationStrings[538], // "You need %d more experience to train to level %d" + (uint)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1); + else + sprintfex(*v45, pGlobalTXT_LocalizationStrings[537], // "Train to level %d for %d gold" + pPlayers[uActiveCharacter]->uLevel + 1, v11); } - sprintfex(*v45, v59, v61, v64); } v47 = pFontArrus->CalcTextHeight(*v45, &v65, 0, 0); v43 = pDialogueWindow; @@ -4198,13 +4183,10 @@ } while ( v73 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); } - //HIDWORD(v66) = (174 - v72) / 2; - result = v43->pStartingPosActiveItem; - v48 = result + v43->pNumPresenceButton; + v49 = (2 * (87 - (174 - v72) / 2) - v72) / 2 - (174 - v72) / 2 / 2 + 138; - v50 = -v43->pNumPresenceButton < 0; v73 = v43->pStartingPosActiveItem; - if ( v50 ^ result < v48 ) + if (v43->pStartingPosActiveItem < v43->pStartingPosActiveItem + v43->pNumPresenceButton) { int _v3 = 2; v51 = pShopOptions; @@ -4227,13 +4209,11 @@ ++_v3; ++v51; ++v73; - result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; } - while ( v73 < result ); + while ( v73 < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton); } } } - return result; } @@ -4753,7 +4733,7 @@ do { // if ( pParty->field_777C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID); + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID) { v50 = ItemsInShopTexture[v49]; v51 = 152 - v50->uTextureHeight; @@ -4786,7 +4766,7 @@ do { //if ( pParty->field_777C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] ) - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122+1].uItemID); + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122+1].uItemID) { v54 = ItemsInShopTexture[v122 + 6]; v55 = 306 - v54->uTextureHeight; @@ -4882,12 +4862,12 @@ if ( result ) { v66 = 0; - v117 = 0; + v117 = 0;\ if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { do { - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID); //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) ++v117; ++v66; }
--- a/UIHouses.h Sat Mar 23 22:23:05 2013 +0600 +++ b/UIHouses.h Sat Mar 23 22:23:18 2013 +0600 @@ -21,7 +21,7 @@ HOUSE_DIALOGUE_14 = 14, HOUSE_DIALOGUE_TAVERN_REST = 15, HOUSE_DIALOGUE_TAVERN_BUY_FOOD = 16, - HOUSE_DIALOGUE_TRAININGHALL_17 = 17, + HOUSE_DIALOGUE_TRAININGHALL_TRAIN = 17, HOUSE_DIALOGUE_GULD_BUY_BOOKS = 18, //... HOUSE_DIALOGUE_GUILD_LEARN_SKILL = 72, @@ -55,7 +55,14 @@ HOUSE_STABLES_HARMONDALE = 54, HOUSE_TEMPLE_EMERALD_ISLE = 74, HOUSE_TEMPLE_HARMONDALE = 75, + HOUSE_TRAINING_HALL_EMERALD_ISLE = 89, HOUSE_TRAINING_HALL_HARMONDALE = 90, + HOUSE_TRAINING_HALL_91 = 91, + HOUSE_TRAINING_HALL_92 = 92, + HOUSE_TRAINING_HALL_93 = 93, + HOUSE_TRAINING_HALL_94 = 94, + HOUSE_TRAINING_HALL_95 = 95, + HOUSE_TOWNHALL_HARMONDALE = 102, HOUSE_TAVERN_EMERALD_ISLE = 107, HOUSE_BANK_HARMONDALE = 128, @@ -82,13 +89,13 @@ enum HouseSoundID: unsigned __int32 { - HouseSound_Greeting = 1, - HouseSound_NotEnoughMoney = 2, - HouseSound_Greeting_2 = 3, // good greeting when you're guild member + HouseSound_Greeting = 1, // General greeting + HouseSound_NotEnoughMoney_TrainingSuccessful = 2, + HouseSound_Greeting_2 = 3, // Polite Greeting when you're guild member HouseSound_Goodbye = 4 // farewells when bought something }; -int __cdecl TrainingDialog(); +void TrainingDialog(); char *__cdecl JailDialog(); void MagicShopDialog(); void GuildDialog();
--- a/mm7_2.cpp Sat Mar 23 22:23:05 2013 +0600 +++ b/mm7_2.cpp Sat Mar 23 22:23:18 2013 +0600 @@ -1590,7 +1590,7 @@ do { // if ( pParty->field_777C[9 * (v48 + 12 * (int)v47)] ) - if ( pParty->StandartItemsInShops[(int)v47][v48].uItemID); + if ( pParty->StandartItemsInShops[(int)v47][v48].uItemID) { v49 = rand(); v8 = window_SpeakInHouse;
--- a/mm7_4.cpp Sat Mar 23 22:23:05 2013 +0600 +++ b/mm7_4.cpp Sat Mar 23 22:23:18 2013 +0600 @@ -1522,863 +1522,6 @@ -//----- (00487E1D) -------------------------------------------------------- -TileTable::~TileTable() -{ - if ( this->pTiles ) - { - pAllocator->FreeChunk(this->pTiles); - pTiles = nullptr; - } - uNumTiles = 0; -} - -//----- (00487E3B) -------------------------------------------------------- -TileDesc *TileTable::GetTileById(unsigned int uTileID) -{ - /*TileDesc *result; // eax@3 - - if ( (uTileID & 0x80000000u) != 0 || (signed int)uTileID > (signed int)(this->uNumTiles - 1) ) - result = this->pTiles; - else - result = &this->pTiles[uTileID]; - return result;*/ - - assert(uTileID < uNumTiles); - return &pTiles[uTileID]; -} - -//----- (00487E58) -------------------------------------------------------- -void TileTable::InitializeTileset(Tileset tileset) -{ - TileTable *v2; // edi@1 - int v3; // ebx@1 - TileDesc *v4; // eax@2 - signed int i; // [sp+8h] [bp-4h]@1 - - v2 = this; - v3 = 0; - for ( i = 0; i < (signed int)v2->uNumTiles; ++v3 ) - { - v4 = &v2->pTiles[v3]; - if (v4->tileset == tileset && v4->pTileName[0] ) - { - v2->pTiles[v3].uBitmapID = pBitmaps_LOD->LoadTexture(v4->pTileName); - if ( v2->pTiles[v3].uBitmapID != -1 ) - pBitmaps_LOD->pTextures[v2->pTiles[v3].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2->pTiles[v3].uBitmapID].palette_id1); - } - ++i; - } -} - -//----- (00487ED6) -------------------------------------------------------- -int TileTable::method_487ED6(signed int a1, int a2) -{ - int v3; // esi@1 - TileTable *v4; // edi@1 - int v5; // edx@3 - int v6; // edx@11 - unsigned int v8; // [sp-4h] [bp-10h]@4 - - v3 = 0; - v4 = this; - if ( a1 > 8 ) - { - v8 = 0; - return v4->GetTileId(a1, v8); - } - if ( a2 || (v5 = rand() % 50, v5 < 20) ) - { - v8 = 0; - return v4->GetTileId(a1, v8); - } - if ( v5 < 30 ) - { - v8 = 1; - return v4->GetTileId(a1, v8); - } - if ( v5 < 40 ) - { - v8 = 2; - return v4->GetTileId(a1, v8); - } - if ( v5 < 48 ) - { - v8 = 3; - return v4->GetTileId(a1, v8); - } - v6 = rand() % 8; - if ( !v6 ) - { - v8 = 4; - return v4->GetTileId(a1, v8); - } - if ( v6 == 1 ) - { - v8 = 5; - return v4->GetTileId(a1, v8); - } - if ( v6 == 2 ) - { - v8 = 6; - return v4->GetTileId(a1, v8); - } - if ( v6 == 3 ) - { - v8 = 7; - return v4->GetTileId(a1, v8); - } - if ( v6 == 4 ) - { - v8 = 8; - return v4->GetTileId(a1, v8); - } - if ( v6 == 5 ) - { - v8 = 9; - return v4->GetTileId(a1, v8); - } - if ( v6 == 6 ) - { - v8 = 10; - return v4->GetTileId(a1, v8); - } - if ( v6 == 7 ) - { - v8 = 11; - return v4->GetTileId(a1, v8); - } - return v3; -} - -//----- (00487F84) -------------------------------------------------------- -unsigned int TileTable::GetTileId(unsigned int uTerrainType, unsigned int uSection) -{ - unsigned int v3; // edx@1 - unsigned int result; // eax@1 - unsigned __int16 *v5; // ecx@2 - - v3 = this->uNumTiles; - result = 0; - if ( (signed int)this->uNumTiles <= 0 ) - { -LABEL_6: - result = 0; - } - else - { - v5 = &this->pTiles->uSection; - while ( (signed __int16)*(v5 - 1) != uTerrainType || (signed __int16)*v5 != uSection ) - { - ++result; - v5 += 13; - if ( (signed int)result >= (signed int)v3 ) - goto LABEL_6; - } - } - return result; -} - -//----- (00487FB4) -------------------------------------------------------- -void TileTable::ToFile() -{ - TileTable *v1; // esi@1 - FILE *v2; // eax@1 - FILE *v3; // edi@1 - - auto Str = this; - - v1 = Str; - v2 = fopen("data\\dtile.bin", "wb"); - v3 = v2; - if ( !v2 ) - Abortf("Unable to save dtile.bin!"); - fwrite(v1, 4u, 1u, v2); - fwrite(v1->pTiles, 0x1Au, v1->uNumTiles, v3); - fclose(v3); -} - -//----- (00488000) -------------------------------------------------------- -void TileTable::FromFile(void *pSerialized) -{ - uNumTiles = *(int *)pSerialized; - pTiles = (TileDesc *)pAllocator->AllocNamedChunk(pTiles, 26 * uNumTiles, "Tile Descrip"); - memcpy(pTiles, (char *)pSerialized + 4, 26 * uNumTiles); -} - -//----- (00488047) -------------------------------------------------------- -int TileTable::FromFileTxt(const char *pFilename) -{ - TileTable *v2; // ebp@1 - FILE *v3; // eax@1 - unsigned int v4; // ebx@3 - void *v5; // eax@9 - unsigned __int16 v6; // ax@14 - const char *v7; // ST14_4@14 - unsigned __int16 v8; // ax@14 - const char *v9; // esi@14 - int v10; // eax@17 - int v11; // eax@20 - int v12; // eax@22 - int v13; // eax@24 - int v14; // eax@26 - int v15; // eax@28 - int v16; // eax@30 - int v17; // eax@32 - int v18; // eax@34 - int v19; // eax@36 - int v20; // eax@38 - int v21; // eax@40 - int v22; // eax@42 - int v23; // eax@44 - int v24; // eax@46 - int v25; // eax@48 - int v26; // eax@50 - int v27; // eax@52 - int v28; // eax@54 - int v29; // eax@56 - int v30; // eax@58 - int v31; // eax@60 - int v32; // eax@62 - int v33; // eax@64 - int v34; // eax@66 - const char *v35; // esi@67 - int v36; // eax@70 - int v37; // eax@73 - int v38; // eax@75 - int v39; // eax@77 - int v40; // eax@79 - int v41; // eax@81 - int v42; // eax@83 - int v43; // eax@85 - int v44; // eax@87 - int v45; // eax@89 - int v46; // eax@91 - int v47; // eax@93 - int v48; // eax@108 - int v49; // eax@110 - int v50; // eax@112 - int v51; // eax@114 - int v52; // eax@116 - int v53; // eax@118 - int v54; // eax@120 - int v55; // eax@122 - int v56; // eax@124 - int v57; // eax@126 - int v58; // eax@128 - int v59; // eax@130 - int v60; // eax@132 - int v61; // eax@134 - int v62; // eax@136 - int v63; // eax@138 - int v64; // eax@140 - int v65; // eax@142 - int v66; // eax@144 - int v67; // eax@146 - int v68; // eax@148 - int v69; // eax@150 - int v70; // eax@151 - int j; // edi@152 - const char *v72; // esi@153 - int v73; // eax@154 - int v74; // eax@156 - int v75; // eax@160 - int v76; // eax@162 - int v77; // eax@164 - int v78; // eax@166 - int v79; // eax@168 - int v80; // eax@170 - FILE *i; // [sp-10h] [bp-304h]@3 - FILE *File; // [sp+4h] [bp-2F0h]@1 - FrameTableTxtLine v84; // [sp+8h] [bp-2ECh]@4 - FrameTableTxtLine v85; // [sp+84h] [bp-270h]@4 - char Buf; // [sp+100h] [bp-1F4h]@4 - - v2 = this; - v3 = fopen(pFilename, "r"); - File = v3; - if ( !v3 ) - Abortf("TileTable::load - Unable to open file: %s."); - v4 = 0; - for ( i = v3; fgets(&Buf, 490, i); i = File ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); - if ( v84.uPropCount && *v84.pProperties[0] != 47 ) - ++v4; - } - v2->uNumTiles = v4; - v5 = pAllocator->AllocNamedChunk(v2->pTiles, 26 * v4, "Tile Descrip"); - v2->pTiles = (TileDesc *)v5; - if ( !v5 ) - Abortf("TileTable::Load - Out of Memory!"); - memset(v5, 0, 26 * v2->uNumTiles); - v2->uNumTiles = 0; - fseek(File, 0, 0); - if ( fgets(&Buf, 490, File) ) - { - while ( 1 ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); - if ( v84.uPropCount ) - { - if ( *v84.pProperties[0] != 47 ) - break; - } -LABEL_173: - if ( !fgets(&Buf, 490, File) ) - goto LABEL_174; - } - strcpy(v2->pTiles[v2->uNumTiles].pTileName, v84.pProperties[0]); - v6 = atoi(v84.pProperties[1]); - v7 = v84.pProperties[2]; - v2->pTiles[v2->uNumTiles].uTileID = v6; - v8 = atoi(v7); - v9 = v84.pProperties[3]; - v2->pTiles[v2->uNumTiles].uBitmapID = v8; - v2->pTiles[v2->uNumTiles].tileset = Tileset_Grass; - if ( _strcmpi(v9, "TTtype_NULL") ) - { - if ( _strcmpi(v9, "TTtype_Start") ) - { - if ( _strcmpi(v9, "TTtype_Grass") ) - { - if ( _strcmpi(v9, "TTtype_Cracked") ) - { - if ( _strcmpi(v9, "TTtype_Snow") ) - { - if ( _strcmpi(v9, "TTtype_Sand") ) - { - if ( _strcmpi(v9, "TTtype_Volcano") ) - { - if ( _strcmpi(v9, "TTtype_Dirt") ) - { - if ( _strcmpi(v9, "TTtype_Water") ) - { - if ( _strcmpi(v9, "TTtype_Tropical") ) - { - if ( _strcmpi(v9, "TTtype_Swamp") ) - { - if ( _strcmpi(v9, "TTtype_City") ) - { - if ( _strcmpi(v9, "TTtype_RoadGrassCobble") ) - { - if ( _strcmpi(v9, "TTtype_RoadGrassDirt") ) - { - if ( _strcmpi(v9, "TTtype_RoadCrackedCobble") ) - { - if ( _strcmpi(v9, "TTtype_RoadCrackedDirt") ) - { - if ( _strcmpi(v9, "TTtype_RoadSandCobble") ) - { - if ( _strcmpi(v9, "TTtype_RoadSandDirt") ) - { - if ( _strcmpi(v9, "TTtype_RoadVolcanoCobble") ) - { - if ( _strcmpi(v9, "TTtype_RoadVolcanoDirt") ) - { - if ( _strcmpi(v9, "TTtype_RoadSwampCobble") ) - { - if ( _strcmpi(v9, "TTtype_RoadSwampDirt") ) - { - if ( _strcmpi(v9, "TTtype_RoadTropicalCobble") ) - { - if ( _strcmpi(v9, "TTtype_RoadTropicalDirt") ) - { - if ( _strcmpi(v9, "TTtype_RoadSnowCobble") ) - { - if ( _strcmpi(v9, "TTtype_RoadSnowDirt") ) - { - if ( !_strcmpi(v9, "TTtype_RoadCityStone") ) - { - v34 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v34 |= 0x1Cu; - } - } - else - { - v33 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v33 |= 0xDu; - } - } - else - { - v32 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v32 |= 0xCu; - } - } - else - { - v31 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v31 |= 0x1Bu; - } - } - else - { - v30 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v30 |= 0x1Au; - } - } - else - { - v29 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v29 |= 0x19u; - } - } - else - { - v28 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v28 |= 0x18u; - } - } - else - { - v27 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v27 |= 0x11u; - } - } - else - { - v26 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v26 |= 0x10u; - } - } - else - { - v25 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v25 |= 0xFu; - } - } - else - { - v24 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v24 |= 0xEu; - } - } - else - { - v23 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v23 |= 0x17u; - } - } - else - { - v22 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v22 |= 0x16u; - } - } - else - { - v21 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v21 |= 0xBu; - } - } - else - { - v20 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v20 |= 0xAu; - } - } - else - { - v19 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v19 |= 9u; - } - } - else - { - v18 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v18 |= 7u; - } - } - else - { - v17 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v17 |= 8u; - } - } - else - { - v16 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v16 |= 5u; - } - } - else - { - v15 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v15 |= 4u; - } - } - else - { - v14 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v14 |= 3u; - } - } - else - { - v13 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v13 |= 2u; - } - } - else - { - v12 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v12 |= 1u; - } - } - else - { - v11 = (int)&v2->pTiles[v2->uNumTiles].tileset; - *(char *)v11 |= 6u; - } - } - } - else - { - v10 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v10 |= 0xFEu; - } - } - else - { - LOBYTE(v2->pTiles[v2->uNumTiles].tileset) = -1; - } - v35 = v84.pProperties[4]; - v2->pTiles[v2->uNumTiles].uSection = 0; - v2->pTiles[v2->uNumTiles].uAttributes = 0; - if ( !_strcmpi(v35, "TTsect_NULL") ) - { - LOBYTE(v2->pTiles[v2->uNumTiles].uSection) = -1; -LABEL_152: - for ( j = 5; j < v84.uPropCount; ++j ) - { - v72 = v84.pProperties[j]; - if ( _strcmpi(v84.pProperties[j], "TTattr_Burn") ) - { - if ( _strcmpi(v72, "TTattr_Water") ) - { - if ( _strcmpi(v72, "TTattr_Water2") ) - { - if ( _strcmpi(v72, "TTattr_Block") ) - { - if ( _strcmpi(v72, "TTattr_Repulse") ) - { - if ( _strcmpi(v72, "TTattr_Flat") ) - { - if ( _strcmpi(v72, "TTattr_Wave") ) - { - if ( _strcmpi(v72, "TTattr_NoDraw") ) - { - if ( !_strcmpi(v72, "TTattr_Transition") ) - { - v80 = (int)&v2->pTiles[v2->uNumTiles].uAttributes; - *(short *)v80 |= 0x200u; - } - } - else - { - v79 = (int)&v2->pTiles[v2->uNumTiles].uAttributes; - *(char *)v79 |= 0x40u; - } - } - else - { - v78 = (int)&v2->pTiles[v2->uNumTiles].uAttributes; - *(char *)v78 |= 0x20u; - } - } - else - { - v77 = (int)&v2->pTiles[v2->uNumTiles].uAttributes; - *(char *)v77 |= 0x10u; - } - } - else - { - v76 = (int)&v2->pTiles[v2->uNumTiles].uAttributes; - *(char *)v76 |= 8u; - } - } - else - { - v75 = (int)&v2->pTiles[v2->uNumTiles].uAttributes; - *(char *)v75 |= 4u; - } - } - else - { - HIBYTE(v2->pTiles[v2->uNumTiles].uAttributes) |= 1u; - } - } - else - { - v74 = (int)&v2->pTiles[v2->uNumTiles].uAttributes; - *(char *)v74 |= 2u; - } - } - else - { - v73 = (int)&v2->pTiles[v2->uNumTiles].uAttributes; - *(char *)v73 |= 1u; - } - } - ++v2->uNumTiles; - goto LABEL_173; - } - if ( !_strcmpi(v35, "TTsect_Start") ) - { - v36 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v36 |= 0xFEu; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Base1") ) - goto LABEL_152; - if ( !_strcmpi(v35, "TTsect_Base2") ) - { - v37 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v37 |= 1u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Base3") ) - { - v38 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v38 |= 2u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Base4") ) - { - v39 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v39 |= 3u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Special1") ) - { - v40 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v40 |= 4u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Special2") ) - { - v41 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v41 |= 5u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Special3") ) - { - v42 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v42 |= 6u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Special4") ) - { - v43 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v43 |= 7u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Special5") ) - { - v44 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v44 |= 8u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Special6") ) - { - v45 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v45 |= 9u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Special7") ) - { - v46 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v46 |= 0xAu; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_Special8") ) - { - v47 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v47 |= 0xBu; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_NE1") ) - goto LABEL_130; - if ( !_strcmpi(v35, "TTsect_NW1") ) - goto LABEL_134; - if ( !_strcmpi(v35, "TTsect_SE1") ) - goto LABEL_130; - if ( !_strcmpi(v35, "TTsect_SW1") ) - goto LABEL_134; - if ( !_strcmpi(v35, "TTsect_E1") ) - goto LABEL_138; - if ( !_strcmpi(v35, "TTsect_W1") ) - goto LABEL_140; - if ( !_strcmpi(v35, "TTsect_N1") ) - goto LABEL_142; - if ( !_strcmpi(v35, "TTsect_S1") ) - goto LABEL_144; - if ( !_strcmpi(v35, "TTsect_XNE1") ) - goto LABEL_146; - if ( _strcmpi(v35, "TTsect_XNW1") ) - { - if ( !_strcmpi(v35, "TTsect_XSE1") ) - goto LABEL_146; - if ( _strcmpi(v35, "TTsect_XSW1") ) - { - if ( !_strcmpi(v35, "TTsect_CROS") ) - { -LABEL_151: - v70 = (int)&v2->pTiles[v2->uNumTiles].uAttributes; - *(short *)v70 |= 0x200u; - goto LABEL_152; - } - if ( !_strcmpi(v35, "TTsect_NS") ) - { - v48 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v48 |= 1u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_EW") ) - { - v49 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v49 |= 2u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_N_E") ) - { - v50 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v50 |= 3u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_N_W") ) - { - v51 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v51 |= 4u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_S_E") ) - { - v52 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v52 |= 5u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_S_W") ) - { - v53 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v53 |= 6u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_NS_E") ) - { - v54 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v54 |= 7u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_NS_W") ) - { - v55 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v55 |= 8u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_EW_N") ) - { - v56 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v56 |= 9u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_EW_S") ) - { - v57 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v57 |= 0xAu; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_NCAP") ) - { - v58 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v58 |= 0xBu; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_ECAP") ) - { -LABEL_130: - v59 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v59 |= 0xCu; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_SCAP") ) - { - v60 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v60 |= 0xDu; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_WCAP") ) - { -LABEL_134: - v61 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v61 |= 0xEu; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_DN") ) - { - v62 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v62 |= 0xFu; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_DS") ) - { -LABEL_138: - v63 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v63 |= 0x10u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_DW") ) - { -LABEL_140: - v64 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v64 |= 0x11u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_DE") ) - { -LABEL_142: - v65 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v65 |= 0x12u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_DSW") ) - { -LABEL_144: - v66 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v66 |= 0x13u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_DNE") ) - { -LABEL_146: - v67 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v67 |= 0x14u; - goto LABEL_151; - } - if ( !_strcmpi(v35, "TTsect_DSE") ) - { - v68 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v68 |= 0x15u; - goto LABEL_151; - } - if ( _strcmpi(v35, "TTsect_DNW") ) - goto LABEL_152; - } - } - v69 = (int)&v2->pTiles[v2->uNumTiles].uSection; - *(char *)v69 |= 0x16u; - goto LABEL_151; - } -LABEL_174: - fclose(File); - return 1; -} - - //----- (0048958E) -------------------------------------------------------- stru12_MemoryBlock::stru12_MemoryBlock(int a2) @@ -3730,14 +2873,14 @@ } //----- (00494820) -------------------------------------------------------- -unsigned int __fastcall sub_494820(unsigned int a1) +unsigned int __fastcall _494820_training_time(unsigned int a1) { signed int v1; // eax@1 v1 = 5; - if ( a1 % 0x18 >= 5 ) + if ( a1 % 24 >= 5 ) v1 = 29; - return v1 - a1 % 0x18; + return v1 - a1 % 24; } //----- (00494836) -------------------------------------------------------- @@ -7207,7 +6350,7 @@ sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);// // "%s is in no condition to %s" // "do anything" - v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); + v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 0x9Bu); v3 = pFontArrus->CalcTextHeight(pTmpBuf, &v4, 0, 0); v4.DrawTitleText(pFontArrus, 0, (212 - v3) / 2 + 101, v2, pTmpBuf, 3u); result = 0; @@ -9793,7 +8936,7 @@ pParty->uFallStartY = pParty->vPosition.z; pParty->sRotationY = v5->field_18; } - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); v12 = v5->uTravelTime; int _v47; if ( (signed int)window_SpeakInHouse->ptr_1C >= 63 )
--- a/mm7_5.cpp Sat Mar 23 22:23:05 2013 +0600 +++ b/mm7_5.cpp Sat Mar 23 22:23:18 2013 +0600 @@ -1579,7 +1579,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; dword_50CDC8 = v0; sub_42FBDD(); - PlayHouseSound(uCurrentHouse_Animation, HouseSound_NotEnoughMoney); + PlayHouseSound(uCurrentHouse_Animation, HouseSound_NotEnoughMoney_TrainingSuccessful); pVideoPlayer->Unload(); sub_44603D(); viewparams->bRedrawGameUI = v0; @@ -2561,7 +2561,7 @@ case UIMSG_OpenRestUI: dword_506F14 = 2; RestUI_Initialize(); - v86 = 60 * (sub_494820(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute; + v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute; _506F18_num_hours_to_sleep = v86; if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 ) _506F18_num_hours_to_sleep = v86 + 720; @@ -2733,7 +2733,7 @@ } GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, WINDOW_5A, (int)pButton_RestUI_WaitUntilDawn, (int)pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn" - v97 = sub_494820(pParty->uCurrentHour); + v97 = _494820_training_time(pParty->uCurrentHour); dword_506F14 = v0; _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute; continue;
--- a/mm7_data.cpp Sat Mar 23 22:23:05 2013 +0600 +++ b/mm7_data.cpp Sat Mar 23 22:23:18 2013 +0600 @@ -983,10 +983,7 @@ char aAmap[777]; // idb char aTmap[777]; // idb char aHmap[777]; // idb -int dword_4EC268[777]; // weak -int dword_4EC28C[777]; // weak -int dword_4EC2A8; // weak -int dword_4EC2AC; // weak + char aInvalidGroundT[777]; // idb char aInvalidSkyTexH[777]; // idb char aIdlist[777]; // idb @@ -2246,8 +2243,8 @@ int dword_AE3370; // weak char byte_AE5B91; // weak int dword_F1B430[32]; // weak -int dword_F8B144; // idb -char byte_F8B148[16]; +//int dword_F8B144; // nexindex [-1] to the following +int player_levels[4] = {1, 1, 1, 1}; __int16 word_F8B158[777]; // weak struct Texture *ShopTexture; // idb struct Texture *ItemsInShopTexture[12];
--- a/mm7_data.h Sat Mar 23 22:23:05 2013 +0600 +++ b/mm7_data.h Sat Mar 23 22:23:18 2013 +0600 @@ -1678,8 +1678,7 @@ extern int dword_AE3370; // weak extern char byte_AE5B91; // weak extern int dword_F1B430[32]; // weak -extern int dword_F8B144; // idb -extern char byte_F8B148[16]; +extern int player_levels[4]; extern __int16 word_F8B158[]; // weak extern struct Texture *ShopTexture; // idb extern struct Texture *ItemsInShopTexture[12]; @@ -2240,7 +2239,7 @@ int __cdecl _493938_regenerate(); void sub_493F79(struct stru351_summoned_item *_this, __int64 a2); void __cdecl _494035_timed_effects__water_walking_damage__etc(); -unsigned int __fastcall sub_494820(unsigned int a1); +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);