# HG changeset patch # User Gloval # Date 1364044028 -14400 # Node ID f24fb0d64a5c7919183bd610e9fb4e0e64fc3609 # Parent 7f1487b74571af4413ed2c00ec9869c0d11d82c6# Parent b2468462a360e523702bdbd1c39c1f5a7d823fb3 TileTable File diff -r 7f1487b74571 -r f24fb0d64a5c Player.cpp --- a/Player.cpp Sat Mar 23 17:02:14 2013 +0400 +++ b/Player.cpp Sat Mar 23 17:07:08 2013 +0400 @@ -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 ) { diff -r 7f1487b74571 -r f24fb0d64a5c TileTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TileTable.cpp Sat Mar 23 17:07:08 2013 +0400 @@ -0,0 +1,796 @@ +#include +#include +#include +#include + +#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; ipTiles, 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; +} + diff -r 7f1487b74571 -r f24fb0d64a5c UIHouses.cpp --- a/UIHouses.cpp Sat Mar 23 17:02:14 2013 +0400 +++ b/UIHouses.cpp Sat Mar 23 17:07:08 2013 +0400 @@ -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 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; } diff -r 7f1487b74571 -r f24fb0d64a5c UIHouses.h --- a/UIHouses.h Sat Mar 23 17:02:14 2013 +0400 +++ b/UIHouses.h Sat Mar 23 17:07:08 2013 +0400 @@ -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(); diff -r 7f1487b74571 -r f24fb0d64a5c mm7_2.cpp --- a/mm7_2.cpp Sat Mar 23 17:02:14 2013 +0400 +++ b/mm7_2.cpp Sat Mar 23 17:07:08 2013 +0400 @@ -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; diff -r 7f1487b74571 -r f24fb0d64a5c mm7_4.cpp --- a/mm7_4.cpp Sat Mar 23 17:02:14 2013 +0400 +++ b/mm7_4.cpp Sat Mar 23 17:07:08 2013 +0400 @@ -2873,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) -------------------------------------------------------- @@ -6350,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; @@ -8936,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 ) diff -r 7f1487b74571 -r f24fb0d64a5c mm7_5.cpp --- a/mm7_5.cpp Sat Mar 23 17:02:14 2013 +0400 +++ b/mm7_5.cpp Sat Mar 23 17:07:08 2013 +0400 @@ -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; diff -r 7f1487b74571 -r f24fb0d64a5c mm7_data.cpp --- a/mm7_data.cpp Sat Mar 23 17:02:14 2013 +0400 +++ b/mm7_data.cpp Sat Mar 23 17:07:08 2013 +0400 @@ -2219,8 +2219,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]; diff -r 7f1487b74571 -r f24fb0d64a5c mm7_data.h --- a/mm7_data.h Sat Mar 23 17:02:14 2013 +0400 +++ b/mm7_data.h Sat Mar 23 17:07:08 2013 +0400 @@ -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);