Skip to content

Commit 47d78e0

Browse files
uramerCapostrophic
authored andcommitted
Improve weather documentation and prevent division by 0
See merge request OpenMW/openmw!4966 (cherry-picked from 8b2be21)
1 parent 8df9310 commit 47d78e0

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
8282
set(OPENMW_VERSION_MAJOR 0)
8383
set(OPENMW_VERSION_MINOR 50)
8484
set(OPENMW_VERSION_RELEASE 0)
85-
set(OPENMW_LUA_API_REVISION 96)
85+
set(OPENMW_LUA_API_REVISION 97)
8686
set(OPENMW_POSTPROCESSING_API_REVISION 3)
8787

8888
set(OPENMW_VERSION_COMMITHASH "")

apps/openmw/mwlua/weatherbindings.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ namespace MWLua
161161
weatherT["cloudsMaximumPercent"]
162162
= sol::property([](const MWWorld::Weather& w) { return w.mCloudsMaximumPercent; },
163163
[](MWWorld::Weather& w, const FiniteFloat cloudsMaximumPercent) {
164+
if (cloudsMaximumPercent <= 0.f)
165+
throw std::runtime_error("Value must be greater than 0");
164166
w.mCloudsMaximumPercent = cloudsMaximumPercent;
165167
});
166168
weatherT["isStorm"] = sol::property([](const MWWorld::Weather& w) { return w.mIsStorm; },
@@ -172,7 +174,11 @@ namespace MWLua
172174
weatherT["rainSpeed"] = sol::property([](const MWWorld::Weather& w) { return w.mRainSpeed; },
173175
[](MWWorld::Weather& w, const FiniteFloat rainSpeed) { w.mRainSpeed = rainSpeed; });
174176
weatherT["rainEntranceSpeed"] = sol::property([](const MWWorld::Weather& w) { return w.mRainEntranceSpeed; },
175-
[](MWWorld::Weather& w, const FiniteFloat rainEntranceSpeed) { w.mRainEntranceSpeed = rainEntranceSpeed; });
177+
[](MWWorld::Weather& w, const FiniteFloat rainEntranceSpeed) {
178+
if (rainEntranceSpeed <= 0.f)
179+
throw std::runtime_error("Value must be greater than 0");
180+
w.mRainEntranceSpeed = rainEntranceSpeed;
181+
});
176182
weatherT["rainEffect"] = sol::property(
177183
[](const MWWorld::Weather& w) -> sol::optional<std::string> {
178184
if (w.mRainEffect.empty())

files/lua_api/openmw/core.lua

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,24 +1305,24 @@
13051305
-- Weather data
13061306
-- @type WeatherRecord
13071307
-- @field #string recordId
1308-
-- @field #number scriptId
1309-
-- @field #string name
1310-
-- @field #number windSpeed
1308+
-- @field #number scriptId Read-only ID used in mwscript and dialogue
1309+
-- @field #string name Read-only weather name
1310+
-- @field #number windSpeed Affects the angle of falling rain
13111311
-- @field #number cloudSpeed
13121312
-- @field #string cloudTexture
1313-
-- @field #number cloudsMaximumPercent
1314-
-- @field #boolean isStorm
1313+
-- @field #number cloudsMaximumPercent Affects the speed of weather transitions (0, 1]
1314+
-- @field #boolean isStorm Controls whether the weather is considered a storm for animation and movement purposes
13151315
-- @field openmw.util#Vector3 stormDirection
1316-
-- @field #number glareView
1317-
-- @field #number rainSpeed
1318-
-- @field #number rainEntranceSpeed
1316+
-- @field #number glareView Strength of the sun glare [0, 1]
1317+
-- @field #number rainSpeed The speed at which rain falls
1318+
-- @field #number rainEntranceSpeed The number of seconds between rain particle batches being created
13191319
-- @field #string rainEffect Will return nil if weather has no rainEffect
1320-
-- @field #number rainMaxRaindrops
1321-
-- @field #number rainDiameter
1322-
-- @field #number rainMaxHeight
1323-
-- @field #number rainMinHeight
1320+
-- @field #number rainMaxRaindrops The maximum number of rain particle batches to create every rainEntranceSpeed
1321+
-- @field #number rainDiameter The area around the player to spawn rain in
1322+
-- @field #number rainMaxHeight The maximum height relative to the player to spawn rain at
1323+
-- @field #number rainMinHeight The minimum height relative to the player to spawn rain at
13241324
-- @field #string rainLoopSoundID
1325-
-- @field #table thunderSoundID An array containing the recordIds of the thunder sounds
1325+
-- @field #table thunderSoundID A read-only array containing the recordIds of the thunder sounds
13261326
-- @field #string ambientLoopSoundID
13271327
-- @field #string particleEffect Will return nil if weather has no particleEffect
13281328
-- @field #number distantLandFogFactor

0 commit comments

Comments
 (0)