Fixed #348 Added Random in the possible cloud cover settings

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3376 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 4a3930e19f6ff213c6784b7b95c6c4c16720c8e5
Former-commit-id: 27d89e170a6edffe641c180453f1c29308d81c8e
This commit is contained in:
pouillot 2011-02-19 17:25:56 +00:00
parent 9663df8813
commit 60b31c9478
6 changed files with 43 additions and 44 deletions

View file

@ -382,8 +382,9 @@ typedef struct RmInfo
#define RM_VAL_CLOUDS_SCARCE "scarce clouds" #define RM_VAL_CLOUDS_SCARCE "scarce clouds"
#define RM_VAL_CLOUDS_MANY "many clouds" #define RM_VAL_CLOUDS_MANY "many clouds"
#define RM_VAL_CLOUDS_FULL "full cover" #define RM_VAL_CLOUDS_FULL "full cover"
#define RM_VAL_CLOUDS_RANDOM "random"
#define RM_VALS_CLOUDS { RM_VAL_CLOUDS_NONE, RM_VAL_CLOUDS_FEW, RM_VAL_CLOUDS_SCARCE, \ #define RM_VALS_CLOUDS { RM_VAL_CLOUDS_NONE, RM_VAL_CLOUDS_FEW, RM_VAL_CLOUDS_SCARCE, \
RM_VAL_CLOUDS_MANY, RM_VAL_CLOUDS_FULL } RM_VAL_CLOUDS_MANY, RM_VAL_CLOUDS_FULL, RM_VAL_CLOUDS_RANDOM }
#define RM_VAL_RAIN_NONE "none" #define RM_VAL_RAIN_NONE "none"
#define RM_VAL_RAIN_LITTLE "little" #define RM_VAL_RAIN_LITTLE "little"

View file

@ -586,13 +586,14 @@ typedef struct TrackLocalInfo
#define TR_CLOUDS_SCARCE 2 #define TR_CLOUDS_SCARCE 2
#define TR_CLOUDS_MANY 3 #define TR_CLOUDS_MANY 3
#define TR_CLOUDS_FULL 4 #define TR_CLOUDS_FULL 4
#define TR_CLOUDS_RANDOM 5 // Must not be used in the clouds field. Race engine only.
int rain; /**< Rain strength / strength spec (warning : consistency with RM_VAL_RAIN_*) */ int rain; /**< Rain strength / strength spec (warning : consistency with RM_VAL_RAIN_*) */
#define TR_RAIN_NONE 0 #define TR_RAIN_NONE 0
#define TR_RAIN_LITTLE 1 #define TR_RAIN_LITTLE 1
#define TR_RAIN_MEDIUM 2 #define TR_RAIN_MEDIUM 2
#define TR_RAIN_HEAVY 3 #define TR_RAIN_HEAVY 3
#define TR_RAIN_RANDOM 4 #define TR_RAIN_RANDOM 4 // Must not be used in the rain field. Race engine only.
int water; /**< Water "level" on the ground (very simple constant model) */ int water; /**< Water "level" on the ground (very simple constant model) */
#define TR_WATER_NONE 0 #define TR_WATER_NONE 0

View file

@ -103,7 +103,7 @@ ReInit(void)
GfTracks::self()->setTrackInterface(&ReInfo->_reTrackItf); GfTracks::self()->setTrackInterface(&ReInfo->_reTrackItf);
/* The graphic modules isn't loaded at this moment, so make sure _reGraphicItf equals NULL */ /* The graphic modules isn't loaded at this moment, so make sure _reGraphicItf equals NULL */
memset (&ReInfo->_reGraphicItf, 0, sizeof(tGraphicItf)); //memset (&ReInfo->_reGraphicItf, 0, sizeof(tGraphicItf)); // Already done by calloc.
// Initialize the movie capture system. // Initialize the movie capture system.
tRmMovieCapture *capture = &(ReInfo->movieCapture); tRmMovieCapture *capture = &(ReInfo->movieCapture);

View file

@ -299,10 +299,13 @@ reTrackInitWeather(void)
} }
} }
// Take care of the random case for rain falls, clouds cover and ground water. // Take care of the random case for rain falls and ground water.
const char* pszWeatherSelect = "user-defined"; const bool bRandomRain = (rain == TR_RAIN_RANDOM);
if (rain == TR_RAIN_RANDOM) if (bRandomRain)
{ {
// Force random clouds, in case there is no rain at the end.
clouds = TR_CLOUDS_RANDOM;
// Random rain (if random[0,1] < trackLocal->anyrainlkhood, then it rains). // Random rain (if random[0,1] < trackLocal->anyrainlkhood, then it rains).
const tdble randDraw = (tdble)(rand()/(double)RAND_MAX); const tdble randDraw = (tdble)(rand()/(double)RAND_MAX);
@ -324,33 +327,36 @@ reTrackInitWeather(void)
// otherwise, random[0,1] >= medium + little rain likelyhood => rain = Heavy rain // otherwise, random[0,1] >= medium + little rain likelyhood => rain = Heavy rain
else else
rain = TR_RAIN_HEAVY; rain = TR_RAIN_HEAVY;
// Whatever rain level (except for none), heavy clouds.
clouds = TR_CLOUDS_FULL;
} }
else else
{ {
// No Rain. // No Rain.
rain = TR_RAIN_NONE; rain = TR_RAIN_NONE;
// Random clouds.
clouds = rand() % (TR_CLOUDS_FULL + 1);
} }
pszWeatherSelect = "randomly selected";
} }
else
// Take care of the random case for clouds cover.
const bool bRandomClouds = (clouds == TR_CLOUDS_RANDOM);
if (bRandomClouds)
{ {
if (rain != TR_RAIN_NONE) if (rain != TR_RAIN_NONE)
// Whatever rain level (except for none), heavy clouds. {
// If any rain level, heavy clouds.
clouds = TR_CLOUDS_FULL; clouds = TR_CLOUDS_FULL;
}
else
{
// Really random clouds.
clouds = rand() % (TR_CLOUDS_FULL + 1);
}
} }
// Ground water = rain for the moment (might change in the future). // Ground water = rain for the moment (might change in the future).
const int water = rain; const int water = rain;
GfLogInfo("Weather : Using %s rain (%d), clouds (%d) and ground water (%d) settings\n", GfLogInfo("Weather : Using %s rain (%d) and ground water (%d) + %s clouds (%d) settings\n",
pszWeatherSelect, rain, clouds, water); bRandomRain ? "random" : "user defined", rain, water,
bRandomClouds ? "random" : "user defined", clouds);
// Update track local info. // Update track local info.
trackLocal->rain = rain; trackLocal->rain = rain;

View file

@ -220,16 +220,6 @@ rmChangeClouds(void *vp)
(GfRace::ECloudsSpec) (GfRace::ECloudsSpec)
((rmrpClouds + GfRace::nCloudsSpecNumber + delta) % GfRace::nCloudsSpecNumber); ((rmrpClouds + GfRace::nCloudsSpecNumber + delta) % GfRace::nCloudsSpecNumber);
GfuiLabelSetText(ScrHandle, rmrpCloudsEditId, CloudsValues[rmrpClouds]); GfuiLabelSetText(ScrHandle, rmrpCloudsEditId, CloudsValues[rmrpClouds]);
if (rmrpConfMask & RM_CONF_RAIN_FALL)
{
// Make rain level compatible if needed.
if (rmrpClouds != GfRace::eCloudsFull) // No heavy clouds => no rain
{
rmrpRain = GfRace::eRainNone;
GfuiLabelSetText(ScrHandle, rmrpRainEditId, RainValues[rmrpRain]);
}
}
} }
static void static void
@ -244,23 +234,22 @@ rmChangeRain(void *vp)
if (rmrpConfMask & RM_CONF_CLOUD_COVER) if (rmrpConfMask & RM_CONF_CLOUD_COVER)
{ {
// Make clouds state compatible if needed. // Make clouds state compatible if needed.
int cloudsComboVisibility; int cloudsComboEnabled = GFUI_ENABLE;
if (rmrpRain == GfRace::eRainRandom) // Random rain => Random clouds. if (rmrpRain == GfRace::eRainRandom) // Random rain => Random clouds.
{ {
cloudsComboVisibility = GFUI_INVISIBLE; cloudsComboEnabled = GFUI_DISABLE;
GfuiLabelSetText(ScrHandle, rmrpCloudsEditId, "random"); rmrpClouds = GfRace::eCloudsRandom;
} }
else else if (rmrpRain != GfRace::eRainNone)
{ {
cloudsComboVisibility = GFUI_VISIBLE; cloudsComboEnabled = GFUI_DISABLE;
if (rmrpRain != GfRace::eRainNone) rmrpClouds = GfRace::eCloudsFull; // Rain => Heavy clouds.
rmrpClouds = GfRace::eCloudsFull; // Rain => Heavy clouds.
GfuiLabelSetText(ScrHandle, rmrpCloudsEditId, CloudsValues[rmrpClouds]);
} }
GfuiLabelSetText(ScrHandle, rmrpCloudsEditId, CloudsValues[rmrpClouds]);
// Show / hide clouds combo arrow buttons (random rain => no sky choice).
GfuiVisibilitySet(ScrHandle, rmrpCloudsLeftArrowId, cloudsComboVisibility); // Show / hide clouds combo arrow buttons (any rain => no sky choice).
GfuiVisibilitySet(ScrHandle, rmrpCloudsRightArrowId, cloudsComboVisibility); GfuiEnable(ScrHandle, rmrpCloudsLeftArrowId, cloudsComboEnabled);
GfuiEnable(ScrHandle, rmrpCloudsRightArrowId, cloudsComboEnabled);
} }
} }
@ -366,7 +355,7 @@ RmRaceParamsMenu(void *vrp)
// 4) According to the competitors. // 4) According to the competitors.
if ((rmrpConfMask & RM_CONF_DISP_MODE) && MenuData->pRace->hasHumanCompetitors()) if ((rmrpConfMask & RM_CONF_DISP_MODE) && MenuData->pRace->hasHumanCompetitors())
{ {
GfLogTrace("Will not configure Display Mode as some human driver(s) in the session\n"); GfLogTrace("Will not configure Display Mode as some human driver(s) are in\n");
rmrpConfMask &= ~RM_CONF_DISP_MODE; rmrpConfMask &= ~RM_CONF_DISP_MODE;
} }
@ -387,6 +376,7 @@ RmRaceParamsMenu(void *vrp)
CreateLabelControl(ScrHandle, menuXMLDescHdle, "nooptionlabel"); CreateLabelControl(ScrHandle, menuXMLDescHdle, "nooptionlabel");
} }
// Otherwise, create and initialize the race length configuration controls.
if (rmrpConfMask & RM_CONF_RACE_LEN) if (rmrpConfMask & RM_CONF_RACE_LEN)
{ {
if (pRaceSessionParams->nDistance < 0) if (pRaceSessionParams->nDistance < 0)
@ -489,9 +479,9 @@ RmRaceParamsMenu(void *vrp)
GfuiLabelSetText(ScrHandle, rmrpTimeOfDayEditId, TimeOfDayValues[rmrpTimeOfDay]); GfuiLabelSetText(ScrHandle, rmrpTimeOfDayEditId, TimeOfDayValues[rmrpTimeOfDay]);
} }
// Create and initialize Clouds combo box (2 arrow buttons and a variable label).
if (rmrpConfMask & RM_CONF_CLOUD_COVER) if (rmrpConfMask & RM_CONF_CLOUD_COVER)
{ {
// Create and initialize Clouds combo box (2 arrow buttons and a variable label).
if (pRaceSessionParams->eCloudsSpec == GfRace::nCloudsSpecNumber) if (pRaceSessionParams->eCloudsSpec == GfRace::nCloudsSpecNumber)
rmrpClouds = GfRace::eCloudsNone; // Default value. rmrpClouds = GfRace::eCloudsNone; // Default value.
else else
@ -512,9 +502,9 @@ RmRaceParamsMenu(void *vrp)
GfuiLabelSetText(ScrHandle, rmrpCloudsEditId, CloudsValues[rmrpClouds]); GfuiLabelSetText(ScrHandle, rmrpCloudsEditId, CloudsValues[rmrpClouds]);
} }
// Create and initialize Rain combo box (2 arrow buttons and a variable label).
if ((rmrpConfMask & RM_CONF_RAIN_FALL) && (rmrpFeatures & RM_FEATURE_WETTRACK)) if ((rmrpConfMask & RM_CONF_RAIN_FALL) && (rmrpFeatures & RM_FEATURE_WETTRACK))
{ {
// Create and initialize Rain combo box (2 arrow buttons and a variable label).
if (pRaceSessionParams->eRainSpec == GfRace::nRainSpecNumber) if (pRaceSessionParams->eRainSpec == GfRace::nRainSpecNumber)
rmrpRain = GfRace::eRainNone; // Default value. rmrpRain = GfRace::eRainNone; // Default value.
else else
@ -535,6 +525,7 @@ RmRaceParamsMenu(void *vrp)
rmChangeRain(0); // Make cloud cover settings compatible if needed. rmChangeRain(0); // Make cloud cover settings compatible if needed.
} }
// Create and initialize Display mode combo-box-like control.
if (rmrpConfMask & RM_CONF_DISP_MODE) if (rmrpConfMask & RM_CONF_DISP_MODE)
{ {
if (pRaceSessionParams->eDisplayMode == GfRace::nDisplayModeNumber) if (pRaceSessionParams->eDisplayMode == GfRace::nDisplayModeNumber)

View file

@ -61,7 +61,7 @@ public:
eTimeDusk, eTimeNight, eTimeNow, eTimeFromTrack, eTimeDusk, eTimeNight, eTimeNow, eTimeFromTrack,
nTimeSpecNumber }; // Last = invalid value = nb of valid ones. nTimeSpecNumber }; // Last = invalid value = nb of valid ones.
enum ECloudsSpec { eCloudsNone, eCloudsFew, eCloudsScarce, eCloudsMany, eCloudsFull, enum ECloudsSpec { eCloudsNone, eCloudsFew, eCloudsScarce, eCloudsMany, eCloudsFull,
nCloudsSpecNumber}; // Last = invalid value = nb of valid ones. eCloudsRandom, nCloudsSpecNumber}; // Last = invalid value = nb of valid ones.
enum ERainSpec { eRainNone, eRainLittle, eRainMedium, eRainHeavy, eRainRandom, enum ERainSpec { eRainNone, eRainLittle, eRainMedium, eRainHeavy, eRainRandom,
nRainSpecNumber }; // Last = invalid value = nb of valid ones. nRainSpecNumber }; // Last = invalid value = nb of valid ones.
class Parameters class Parameters