Mercurial > mm7
diff Outdoor.cpp @ 767:45615cacad31
Fog fixed
author | Nomad |
---|---|
date | Sat, 23 Mar 2013 21:11:15 +0200 |
parents | a84db04439a4 |
children | 67b77b052ef3 |
line wrap: on
line diff
--- a/Outdoor.cpp Sat Mar 23 20:22:51 2013 +0200 +++ b/Outdoor.cpp Sat Mar 23 21:11:15 2013 +0200 @@ -42,6 +42,32 @@ Edge stru_80C9A4; Edge stru_80C9D8; + +struct FogProbabilityTableEntry +{ + unsigned char small_fog_chance; + unsigned char average_fog_chance; + unsigned char dense_fog_chance; + unsigned char __unused; +} fog_probability_table[15] = +{ + { 20, 10, 5, 0}, // MAP_EMERALD_ISLE + { 20, 10, 5, 0}, // MAP_HARMONDALE + { 20, 10, 5, 0}, // MAP_STEADWICK + { 20, 10, 5, 0}, // MAP_PIERPONT + { 20, 10, 5, 0}, // MAP_DEYJA + { 10, 5, 0, 0}, // MAP_BRAKADA_DESERT + { 0, 0, 0, 0}, // MAP_CELESTIA + { 0, 0, 0, 0}, // MAP_THE_PIT + { 20, 30, 50, 0}, // MAP_EVENMORN_ISLE + { 30, 20, 10, 0}, // MAP_MOUNT_NIGHON + { 10, 5, 0, 0}, // MAP_BARROW_DOWNS + { 20, 10, 5, 0}, // MAP_LAND_OF_GIANTS + { 20, 10, 5, 0}, // MAP_TATALIA + { 20, 10, 5, 0}, // MAP_AVLEE + { 0, 100, 0, 0} // MAP_SHOALS +}; + //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 @@ -288,9 +314,9 @@ MessageBoxA(0, "Error!", "Couldn't Load Map!", 0); CreateDebugLocation(); } - day_attrib = v5->day_attrib; - day_fogrange_1 = v5->day_fogrange_1; - day_fogrange_2 = v5->day_fogrange_2; + ::day_attrib = v5->day_attrib; + ::day_fogrange_1 = v5->day_fogrange_1; + ::day_fogrange_2 = v5->day_fogrange_2; if ( Is_out15odm_underwater() ) SetUnderwaterFog(); _6BE134_odm_main_tile_group = v5->pTileTypes[0].tileset; @@ -545,63 +571,50 @@ } return 1; } -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); -// 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); + //----- (00489487) -------------------------------------------------------- -int OutdoorLocation::SetFog() +void OutdoorLocation::SetFog() { - int result; // eax@1 - int v2; // esi@1 - int v3; // edx@5 - unsigned __int8 *v4; // eax@5 - int v5; // ecx@5 - int v6; // esi@7 - unsigned __int8 v7; // al@9 + strcpy(pOutdoor->pLevelFilename, pCurrentMapName); - strcpy(pOutdoor->pLevelFilename, pCurrentMapName); - result = pMapStats->GetMapInfo(pCurrentMapName); - v2 = result; - if ( result < 1 || result == 7 || result == 8 || result > 15 ) - return result; - day_attrib &= 0xFFFFFFFEu; - v3 = rand() % 100; - v4 = (unsigned __int8 *)&byte_4ECB0C[4 * v2]; - v5 = *v4; - if ( v3 < v5 ) + auto map_id = pMapStats->GetMapInfo(pCurrentMapName); + if (map_id == MAP_INVALID || map_id == MAP_CELESTIA || map_id == MAP_THE_PIT || map_id > MAP_SHOALS) + return; + + uint chance = rand() % 100; + + if (chance < fog_probability_table[map_id - 1].small_fog_chance) { - day_fogrange_1 = 4096; - day_fogrange_2 = 8192; -LABEL_13: - day_attrib |= 1u; - goto LABEL_14; + ::day_fogrange_1 = 4096; + ::day_fogrange_2 = 8192; + ::day_attrib |= DAY_ATTRIB_FOG; } - v6 = v4[1]; - if ( v3 < v6 + v5 ) + else if (chance < fog_probability_table[map_id - 1].small_fog_chance + + fog_probability_table[map_id - 1].average_fog_chance) { - day_fogrange_2 = 4096; -LABEL_12: - day_fogrange_1 = 0; - goto LABEL_13; + ::day_fogrange_2 = 4096; + ::day_fogrange_1 = 0; + ::day_attrib |= DAY_ATTRIB_FOG; } - v7 = v4[2]; - if ( v7 && v3 < v5 + v6 + v7 ) + else if (fog_probability_table[map_id - 1].dense_fog_chance && + chance < fog_probability_table[map_id - 1].small_fog_chance + + fog_probability_table[map_id - 1].average_fog_chance + + fog_probability_table[map_id - 1].dense_fog_chance) { - day_fogrange_2 = 2048; - goto LABEL_12; + ::day_fogrange_2 = 2048; + ::day_fogrange_1 = 0; + ::day_attrib |= DAY_ATTRIB_FOG; } -LABEL_14: + else + ::day_attrib &= ~DAY_ATTRIB_FOG; + if ( Is_out15odm_underwater() ) SetUnderwaterFog(); - pOutdoor->day_fogrange_1 = day_fogrange_1; - pOutdoor->day_fogrange_2 = day_fogrange_2; - result = day_attrib; - pOutdoor->day_attrib = day_attrib; - return result; + pOutdoor->day_fogrange_1 = ::day_fogrange_1; + pOutdoor->day_fogrange_2 = ::day_fogrange_2; + pOutdoor->day_attrib = ::day_attrib; } -// 6BE030: using guessed type int day_attrib; -// 6BE040: using guessed type int day_fogrange_1; -// 6BE044: using guessed type int day_fogrange_2; //----- (00482170) -------------------------------------------------------- bool ODMFace::IsBackfaceCulled(ODMFace *a1, RenderVertexSoft *a2, stru148 *a3)