Skip to content

Commit

Permalink
Apply fixes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Pirulax committed Sep 22, 2024
1 parent 8820691 commit 21d1965
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
35 changes: 16 additions & 19 deletions source/game_sa/Weather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,29 +310,26 @@ void CWeather::UpdateInTunnelness() {
plugin::Call<0x72B630>();
}

// 0x72A640
void CWeather::UpdateWeatherRegion(CVector* posn) {
CVector camPos = TheCamera.GetPosition();
if (posn) {
camPos = *posn;
// Based on 0x72A640
eWeatherRegion CWeather::FindWeatherRegion(CVector2D pos) {
if (pos.x > 1000.0f && pos.y > 910.0f) {
return WEATHER_REGION_LV;
}
if (camPos.x > 1000.0f && camPos.y > 910.0f) {
WeatherRegion = WEATHER_REGION_LV;
return;
if (pos.x > -850.0f && pos.x < 1000.0f && pos.y > 1280.0f) {
return WEATHER_REGION_DESERT;
}
if (camPos.x > -850.0f && camPos.x < 1000.0f && camPos.y > 1280.0f) {
WeatherRegion = WEATHER_REGION_DESERT;
return;
if (pos.x < -1430.0f && pos.y > -580.0f && pos.y < 1430.0f) {
return WEATHER_REGION_SF;
}
if (camPos.x < -1430.0f && camPos.y > -580.0f && camPos.y < 1430.0f) {
WeatherRegion = WEATHER_REGION_SF;
return;
if (pos.x > 250.0f && pos.x < 3000.0f && pos.y > -3000.0f && pos.y < -850.0f) {
return WEATHER_REGION_LA;
}
if (camPos.x > 250.0f && camPos.x < 3000.0f && camPos.y > -3000.0f && camPos.y < -850.0f) { // todo: maybe wrong
WeatherRegion = WEATHER_REGION_LA;
return;
}
WeatherRegion = WEATHER_REGION_DEFAULT;
return WEATHER_REGION_DEFAULT;
}

// 0x72A640
void CWeather::UpdateWeatherRegion(CVector* posn) {
WeatherRegion = FindWeatherRegion(posn ? *posn : TheCamera.GetPosition());
}

// 0x4ABF50
Expand Down
6 changes: 6 additions & 0 deletions source/game_sa/Weather.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class CWeather {
static void SetWeatherToAppropriateTypeNow();
static void Update();
static void UpdateInTunnelness();
/*!
* @notsa
* @detail Based on code @ `0x72A640`
* @return The corresponding weather region at a given 2D position, or `WEATHER_REGION_DEFAULT` if no specific region was found
*/
static eWeatherRegion FindWeatherRegion(CVector2D pos);
static void UpdateWeatherRegion(CVector* posn);
static bool IsRainy();

Expand Down

0 comments on commit 21d1965

Please sign in to comment.