Fix names

This commit is contained in:
Abaresk 2022-10-15 13:29:30 +00:00
parent b538239f18
commit e67d55bfc4
2 changed files with 74 additions and 74 deletions

View file

@ -75,12 +75,12 @@ struct Weather
u8 snowflakeSpriteCount; u8 snowflakeSpriteCount;
u8 targetSnowflakeSpriteCount; u8 targetSnowflakeSpriteCount;
// Thunderstorm // Thunderstorm
u16 tStormTimer; // general-purpose timer for state transitions u16 thunderTimer; // general-purpose timer for state transitions
u16 tStormThunderTimer; // timer for thunder sound effect u16 thunderSETimer; // timer for thunder sound effect
bool8 tStormAllowEnd; bool8 thunderAllowEnd;
bool8 tStormLongBolt; // true if the cycle will end in a long lightning bolt bool8 thunderLongBolt; // true if this cycle will end in a long lightning bolt
u8 tStormShortBolts; u8 thunderShortBolts; // the number of short bolts this cycle
bool8 tStormWaitThunder; // true if a thunder sound effect is enqueued bool8 thunderEnqueued;
// Horizontal fog // Horizontal fog
u16 fogHScrollPosX; u16 fogHScrollPosX;
u16 fogHScrollCounter; u16 fogHScrollCounter;

View file

@ -1014,29 +1014,29 @@ static void UpdateSnowflakeSprite(struct Sprite *sprite)
enum { enum {
// This block of states is run only once // This block of states is run only once
// when first setting up the thunderstorm // when first setting up the thunderstorm
TSTORM_STATE_LOAD_RAIN, THUNDER_STATE_LOAD_RAIN,
TSTORM_STATE_CREATE_RAIN, THUNDER_STATE_CREATE_RAIN,
TSTORM_STATE_INIT_RAIN, THUNDER_STATE_INIT_RAIN,
TSTORM_STATE_WAIT_CHANGE, THUNDER_STATE_WAIT_CHANGE,
// The thunderstorm loops through these states, // The thunderstorm loops through these states,
// not necessarily in order. // not necessarily in order.
TSTORM_STATE_NEW_CYCLE, THUNDER_STATE_NEW_CYCLE,
TSTORM_STATE_NEW_CYCLE_WAIT, THUNDER_STATE_NEW_CYCLE_WAIT,
TSTORM_STATE_INIT_CYCLE_1, THUNDER_STATE_INIT_CYCLE_1,
TSTORM_STATE_INIT_CYCLE_2, THUNDER_STATE_INIT_CYCLE_2,
TSTORM_STATE_SHORT_BOLT, THUNDER_STATE_SHORT_BOLT,
TSTORM_STATE_TRY_NEW_BOLT, THUNDER_STATE_TRY_NEW_BOLT,
TSTORM_STATE_WAIT_BOLT_SHORT, THUNDER_STATE_WAIT_BOLT_SHORT,
TSTORM_STATE_INIT_BOLT_LONG, THUNDER_STATE_INIT_BOLT_LONG,
TSTORM_STATE_WAIT_BOLT_LONG, THUNDER_STATE_WAIT_BOLT_LONG,
TSTORM_STATE_FADE_BOLT_LONG, THUNDER_STATE_FADE_BOLT_LONG,
TSTORM_STATE_END_BOLT_LONG, THUNDER_STATE_END_BOLT_LONG,
}; };
void Thunderstorm_InitVars(void) void Thunderstorm_InitVars(void)
{ {
gWeatherPtr->initStep = TSTORM_STATE_LOAD_RAIN; gWeatherPtr->initStep = THUNDER_STATE_LOAD_RAIN;
gWeatherPtr->weatherGfxLoaded = FALSE; gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->rainSpriteVisibleCounter = 0; gWeatherPtr->rainSpriteVisibleCounter = 0;
gWeatherPtr->rainSpriteVisibleDelay = 4; gWeatherPtr->rainSpriteVisibleDelay = 4;
@ -1045,7 +1045,7 @@ void Thunderstorm_InitVars(void)
gWeatherPtr->gammaTargetIndex = 3; gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment
gWeatherPtr->tStormWaitThunder = FALSE; gWeatherPtr->thunderEnqueued = FALSE;
SetRainStrengthFromSoundEffect(SE_THUNDERSTORM); SetRainStrengthFromSoundEffect(SE_THUNDERSTORM);
} }
@ -1065,7 +1065,7 @@ static void EnqueueThunder(u16);
void Downpour_InitVars(void) void Downpour_InitVars(void)
{ {
gWeatherPtr->initStep = TSTORM_STATE_LOAD_RAIN; gWeatherPtr->initStep = THUNDER_STATE_LOAD_RAIN;
gWeatherPtr->weatherGfxLoaded = FALSE; gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->rainSpriteVisibleCounter = 0; gWeatherPtr->rainSpriteVisibleCounter = 0;
gWeatherPtr->rainSpriteVisibleDelay = 4; gWeatherPtr->rainSpriteVisibleDelay = 4;
@ -1094,109 +1094,109 @@ void Thunderstorm_Main(void)
UpdateThunderSound(); UpdateThunderSound();
switch (gWeatherPtr->initStep) switch (gWeatherPtr->initStep)
{ {
case TSTORM_STATE_LOAD_RAIN: case THUNDER_STATE_LOAD_RAIN:
LoadRainSpriteSheet(); LoadRainSpriteSheet();
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
break; break;
case TSTORM_STATE_CREATE_RAIN: case THUNDER_STATE_CREATE_RAIN:
if (!CreateRainSprite()) if (!CreateRainSprite())
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
break; break;
case TSTORM_STATE_INIT_RAIN: case THUNDER_STATE_INIT_RAIN:
if (!UpdateVisibleRainSprites()) if (!UpdateVisibleRainSprites())
{ {
gWeatherPtr->weatherGfxLoaded = TRUE; gWeatherPtr->weatherGfxLoaded = TRUE;
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
} }
break; break;
case TSTORM_STATE_WAIT_CHANGE: case THUNDER_STATE_WAIT_CHANGE:
if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_CHANGING_WEATHER) if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_CHANGING_WEATHER)
gWeatherPtr->initStep = TSTORM_STATE_INIT_CYCLE_1; gWeatherPtr->initStep = THUNDER_STATE_INIT_CYCLE_1;
break; break;
case TSTORM_STATE_NEW_CYCLE: case THUNDER_STATE_NEW_CYCLE:
gWeatherPtr->tStormAllowEnd = TRUE; gWeatherPtr->thunderAllowEnd = TRUE;
gWeatherPtr->tStormTimer = (Random() % 360) + 360; gWeatherPtr->thunderTimer = (Random() % 360) + 360;
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
// fall through // fall through
case TSTORM_STATE_NEW_CYCLE_WAIT: case THUNDER_STATE_NEW_CYCLE_WAIT:
// Wait between 360-720 frames before starting a new cycle. // Wait between 360-720 frames before starting a new cycle.
if (--gWeatherPtr->tStormTimer == 0) if (--gWeatherPtr->thunderTimer == 0)
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
break; break;
case TSTORM_STATE_INIT_CYCLE_1: case THUNDER_STATE_INIT_CYCLE_1:
gWeatherPtr->tStormAllowEnd = TRUE; gWeatherPtr->thunderAllowEnd = TRUE;
gWeatherPtr->tStormLongBolt = Random() % 2; gWeatherPtr->thunderLongBolt = Random() % 2;
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
break; break;
case TSTORM_STATE_INIT_CYCLE_2: case THUNDER_STATE_INIT_CYCLE_2:
gWeatherPtr->tStormShortBolts = (Random() & 1) + 1; gWeatherPtr->thunderShortBolts = (Random() & 1) + 1;
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
// fall through // fall through
case TSTORM_STATE_SHORT_BOLT: case THUNDER_STATE_SHORT_BOLT:
// Short bolt of lightning strikes. // Short bolt of lightning strikes.
ApplyWeatherGammaShiftIfIdle(19); ApplyWeatherGammaShiftIfIdle(19);
// If final lightning bolt, enqueue thunder. // If final lightning bolt, enqueue thunder.
if (!gWeatherPtr->tStormLongBolt && gWeatherPtr->tStormShortBolts == 1) if (!gWeatherPtr->thunderLongBolt && gWeatherPtr->thunderShortBolts == 1)
EnqueueThunder(20); EnqueueThunder(20);
gWeatherPtr->tStormTimer = (Random() % 3) + 6; gWeatherPtr->thunderTimer = (Random() % 3) + 6;
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
break; break;
case TSTORM_STATE_TRY_NEW_BOLT: case THUNDER_STATE_TRY_NEW_BOLT:
if (--gWeatherPtr->tStormTimer == 0) if (--gWeatherPtr->thunderTimer == 0)
{ {
// Short bolt of lightning ends. // Short bolt of lightning ends.
ApplyWeatherGammaShiftIfIdle(3); ApplyWeatherGammaShiftIfIdle(3);
gWeatherPtr->tStormAllowEnd = TRUE; gWeatherPtr->thunderAllowEnd = TRUE;
if (--gWeatherPtr->tStormShortBolts != 0) if (--gWeatherPtr->thunderShortBolts != 0)
{ {
// Wait a little, then do another short bolt. // Wait a little, then do another short bolt.
gWeatherPtr->tStormTimer = (Random() % 16) + 60; gWeatherPtr->thunderTimer = (Random() % 16) + 60;
gWeatherPtr->initStep = TSTORM_STATE_WAIT_BOLT_SHORT; gWeatherPtr->initStep = THUNDER_STATE_WAIT_BOLT_SHORT;
} }
else if (!gWeatherPtr->tStormLongBolt) else if (!gWeatherPtr->thunderLongBolt)
{ {
// No more bolts, restart loop. // No more bolts, restart loop.
gWeatherPtr->initStep = TSTORM_STATE_NEW_CYCLE; gWeatherPtr->initStep = THUNDER_STATE_NEW_CYCLE;
} }
else else
{ {
// Set up long bolt. // Set up long bolt.
gWeatherPtr->initStep = TSTORM_STATE_INIT_BOLT_LONG; gWeatherPtr->initStep = THUNDER_STATE_INIT_BOLT_LONG;
} }
} }
break; break;
case TSTORM_STATE_WAIT_BOLT_SHORT: case THUNDER_STATE_WAIT_BOLT_SHORT:
if (--gWeatherPtr->tStormTimer == 0) if (--gWeatherPtr->thunderTimer == 0)
gWeatherPtr->initStep = TSTORM_STATE_SHORT_BOLT; gWeatherPtr->initStep = THUNDER_STATE_SHORT_BOLT;
break; break;
case TSTORM_STATE_INIT_BOLT_LONG: case THUNDER_STATE_INIT_BOLT_LONG:
gWeatherPtr->tStormTimer = (Random() % 16) + 60; gWeatherPtr->thunderTimer = (Random() % 16) + 60;
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
break; break;
case TSTORM_STATE_WAIT_BOLT_LONG: case THUNDER_STATE_WAIT_BOLT_LONG:
if (--gWeatherPtr->tStormTimer == 0) if (--gWeatherPtr->thunderTimer == 0)
{ {
// Do long bolt. Enqueue thunder with a potentially longer delay. // Do long bolt. Enqueue thunder with a potentially longer delay.
EnqueueThunder(100); EnqueueThunder(100);
ApplyWeatherGammaShiftIfIdle(19); ApplyWeatherGammaShiftIfIdle(19);
gWeatherPtr->tStormTimer = (Random() & 0xF) + 30; gWeatherPtr->thunderTimer = (Random() & 0xF) + 30;
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
} }
break; break;
case TSTORM_STATE_FADE_BOLT_LONG: case THUNDER_STATE_FADE_BOLT_LONG:
if (--gWeatherPtr->tStormTimer == 0) if (--gWeatherPtr->thunderTimer == 0)
{ {
// Fade long bolt out over time. // Fade long bolt out over time.
ApplyWeatherGammaShiftIfIdle_Gradual(19, 3, 5); ApplyWeatherGammaShiftIfIdle_Gradual(19, 3, 5);
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
} }
break; break;
case TSTORM_STATE_END_BOLT_LONG: case THUNDER_STATE_END_BOLT_LONG:
if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE) if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE)
{ {
gWeatherPtr->tStormAllowEnd = TRUE; gWeatherPtr->thunderAllowEnd = TRUE;
gWeatherPtr->initStep = TSTORM_STATE_NEW_CYCLE; gWeatherPtr->initStep = THUNDER_STATE_NEW_CYCLE;
} }
break; break;
} }
@ -1207,12 +1207,12 @@ bool8 Thunderstorm_Finish(void)
switch (gWeatherPtr->finishStep) switch (gWeatherPtr->finishStep)
{ {
case 0: case 0:
gWeatherPtr->tStormAllowEnd = FALSE; gWeatherPtr->thunderAllowEnd = FALSE;
gWeatherPtr->finishStep++; gWeatherPtr->finishStep++;
// fall through // fall through
case 1: case 1:
Thunderstorm_Main(); Thunderstorm_Main();
if (gWeatherPtr->tStormAllowEnd) if (gWeatherPtr->thunderAllowEnd)
{ {
if (gWeatherPtr->nextWeather == WEATHER_RAIN if (gWeatherPtr->nextWeather == WEATHER_RAIN
|| gWeatherPtr->nextWeather == WEATHER_RAIN_THUNDERSTORM || gWeatherPtr->nextWeather == WEATHER_RAIN_THUNDERSTORM
@ -1227,7 +1227,7 @@ bool8 Thunderstorm_Finish(void)
if (!UpdateVisibleRainSprites()) if (!UpdateVisibleRainSprites())
{ {
DestroyRainSprites(); DestroyRainSprites();
gWeatherPtr->tStormWaitThunder = FALSE; gWeatherPtr->thunderEnqueued = FALSE;
gWeatherPtr->finishStep++; gWeatherPtr->finishStep++;
return FALSE; return FALSE;
} }
@ -1241,18 +1241,18 @@ bool8 Thunderstorm_Finish(void)
// Enqueue a thunder sound effect for at most `waitFrames` frames from now. // Enqueue a thunder sound effect for at most `waitFrames` frames from now.
static void EnqueueThunder(u16 waitFrames) static void EnqueueThunder(u16 waitFrames)
{ {
if (!gWeatherPtr->tStormWaitThunder) if (!gWeatherPtr->thunderEnqueued)
{ {
gWeatherPtr->tStormThunderTimer = Random() % waitFrames; gWeatherPtr->thunderSETimer = Random() % waitFrames;
gWeatherPtr->tStormWaitThunder = TRUE; gWeatherPtr->thunderEnqueued = TRUE;
} }
} }
static void UpdateThunderSound(void) static void UpdateThunderSound(void)
{ {
if (gWeatherPtr->tStormWaitThunder == TRUE) if (gWeatherPtr->thunderEnqueued == TRUE)
{ {
if (gWeatherPtr->tStormThunderTimer == 0) if (gWeatherPtr->thunderSETimer == 0)
{ {
if (IsSEPlaying()) if (IsSEPlaying())
return; return;
@ -1262,11 +1262,11 @@ static void UpdateThunderSound(void)
else else
PlaySE(SE_THUNDER2); PlaySE(SE_THUNDER2);
gWeatherPtr->tStormWaitThunder = FALSE; gWeatherPtr->thunderEnqueued = FALSE;
} }
else else
{ {
gWeatherPtr->tStormThunderTimer--; gWeatherPtr->thunderSETimer--;
} }
} }
} }