From 69209c38968c6f4066a772e0a51a2928749217de Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Fri, 9 Dec 2011 19:00:23 +0000 Subject: Re-indenting the code to use standard tabs. Yes, I know this is pretty pointless, but who cares? --- Stars45/Weather.cpp | 224 ++++++++++++++++++++++++++-------------------------- 1 file changed, 112 insertions(+), 112 deletions(-) (limited to 'Stars45/Weather.cpp') diff --git a/Stars45/Weather.cpp b/Stars45/Weather.cpp index a55ec6c..8fc083e 100644 --- a/Stars45/Weather.cpp +++ b/Stars45/Weather.cpp @@ -1,15 +1,15 @@ /* Project Starshatter 5.0 - Destroyer Studios LLC - Copyright © 1997-2007. All Rights Reserved. + Destroyer Studios LLC + Copyright © 1997-2007. All Rights Reserved. - SUBSYSTEM: Stars.exe - FILE: Weather.cpp - AUTHOR: John DiCamillo + SUBSYSTEM: Stars.exe + FILE: Weather.cpp + AUTHOR: John DiCamillo - OVERVIEW - ======== - Manages local weather conditions according to the system stardate + OVERVIEW + ======== + Manages local weather conditions according to the system stardate */ #include "MemDebug.h" @@ -21,15 +21,15 @@ Weather::Weather() { - state = CLEAR; - period = 7 * 20 * 3600; - ceiling = 0; - visibility = 1; + state = CLEAR; + period = 7 * 20 * 3600; + ceiling = 0; + visibility = 1; - for (int i = 0; i < NUM_STATES; i++) - chances[i] = 0; + for (int i = 0; i < NUM_STATES; i++) + chances[i] = 0; - chances[0] = 1; + chances[0] = 1; } // +--------------------------------------------------------------------+ @@ -42,50 +42,50 @@ Weather::~Weather() void Weather::SetChance(int n, double c) { - if (n >= 0 && n < NUM_STATES) { - if (c > 1 && c <= 100) - chances[n] = c / 100; + if (n >= 0 && n < NUM_STATES) { + if (c > 1 && c <= 100) + chances[n] = c / 100; - else if (c < 1) - chances[n] = c; - } + else if (c < 1) + chances[n] = c; + } } void Weather::NormalizeChances() { - double total = 0; + double total = 0; - for (int i = 1; i < NUM_STATES; i++) - total += chances[i]; + for (int i = 1; i < NUM_STATES; i++) + total += chances[i]; - if (total <= 1) { - chances[0] = 1 - total; - } + if (total <= 1) { + chances[0] = 1 - total; + } - else { - chances[0] = 0; + else { + chances[0] = 0; - for (int i = 1; i < NUM_STATES; i++) - chances[i] /= total; - } + for (int i = 1; i < NUM_STATES; i++) + chances[i] /= total; + } - int index = 0; - double level = 0; + int index = 0; + double level = 0; - for (int i = 0; i < NUM_STATES; i++) { - if (chances[i] > 0) { - level += chances[i]; + for (int i = 0; i < NUM_STATES; i++) { + if (chances[i] > 0) { + level += chances[i]; - active_states[index] = (STATE) i; - thresholds[index] = level; + active_states[index] = (STATE) i; + thresholds[index] = level; - index++; - } - } + index++; + } + } - while (index < NUM_STATES) - thresholds[index++] = 10; + while (index < NUM_STATES) + thresholds[index++] = 10; } // +--------------------------------------------------------------------+ @@ -93,51 +93,51 @@ Weather::NormalizeChances() void Weather::Update() { - NormalizeChances(); - - double weather = (sin(StarSystem::Stardate() * 2 * PI / period)+1)/2; - - state = active_states[0]; - - for (int i = 1; i < NUM_STATES; i++) { - if (weather > thresholds[i-1] && weather <= thresholds[i]) { - state = active_states[i]; - break; - } - } - - switch (state) { - default: - case CLEAR: - ceiling = 0; - visibility = 1.0; - break; - - case HIGH_CLOUDS: - ceiling = 0; - visibility = 0.9; - break; - - case MODERATE_CLOUDS: - ceiling = 0; - visibility = 0.8; - break; - - case OVERCAST: - ceiling = 6000; - visibility = 0.7; - break; - - case FOG: - ceiling = 3500; - visibility = 0.6; - break; - - case STORM: - ceiling = 7500; - visibility = 0.5; - break; - } + NormalizeChances(); + + double weather = (sin(StarSystem::Stardate() * 2 * PI / period)+1)/2; + + state = active_states[0]; + + for (int i = 1; i < NUM_STATES; i++) { + if (weather > thresholds[i-1] && weather <= thresholds[i]) { + state = active_states[i]; + break; + } + } + + switch (state) { + default: + case CLEAR: + ceiling = 0; + visibility = 1.0; + break; + + case HIGH_CLOUDS: + ceiling = 0; + visibility = 0.9; + break; + + case MODERATE_CLOUDS: + ceiling = 0; + visibility = 0.8; + break; + + case OVERCAST: + ceiling = 6000; + visibility = 0.7; + break; + + case FOG: + ceiling = 3500; + visibility = 0.6; + break; + + case STORM: + ceiling = 7500; + visibility = 0.5; + break; + } } // +--------------------------------------------------------------------+ @@ -145,34 +145,34 @@ Weather::Update() Text Weather::Description() const { - Text description; + Text description; - switch (state) { - default: - case CLEAR: - description = Game::GetText("weather.clear"); - break; + switch (state) { + default: + case CLEAR: + description = Game::GetText("weather.clear"); + break; - case HIGH_CLOUDS: - description = Game::GetText("weather.high-clouds"); - break; + case HIGH_CLOUDS: + description = Game::GetText("weather.high-clouds"); + break; - case MODERATE_CLOUDS: - description = Game::GetText("weather.partly-cloudy"); - break; + case MODERATE_CLOUDS: + description = Game::GetText("weather.partly-cloudy"); + break; - case OVERCAST: - description = Game::GetText("weather.overcast"); - break; + case OVERCAST: + description = Game::GetText("weather.overcast"); + break; - case FOG: - description = Game::GetText("weather.fog"); - break; + case FOG: + description = Game::GetText("weather.fog"); + break; - case STORM: - description = Game::GetText("weather.storm"); - break; - } + case STORM: + description = Game::GetText("weather.storm"); + break; + } - return description; + return description; } \ No newline at end of file -- cgit v1.1