File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Client/mods/deathmatch/logic/lua
Server/mods/deathmatch/logic/luadefs Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -1416,14 +1416,17 @@ int CLuaFunctionDefs::GetRainLevel ( lua_State* luaVM )
1416
1416
int CLuaFunctionDefs::SetRainLevel ( lua_State* luaVM )
1417
1417
{
1418
1418
// bool setRainLevel ( float amount )
1419
- float fAmount ;
1419
+ float fRainLevel ;
1420
1420
1421
1421
CScriptArgReader argStream ( luaVM );
1422
- argStream.ReadNumber ( fAmount );
1422
+ argStream.ReadNumber ( fRainLevel );
1423
1423
1424
1424
if ( !argStream.HasErrors () )
1425
1425
{
1426
- g_pGame->GetWeather ()->SetAmountOfRain ( fAmount );
1426
+ // Clamp amount of rain to avoid game freezing/crash
1427
+ fRainLevel = Clamp ( 0 .0f , fRainLevel , 10 .0f );
1428
+
1429
+ g_pGame->GetWeather ()->SetAmountOfRain ( fRainLevel );
1427
1430
1428
1431
lua_pushboolean ( luaVM, true );
1429
1432
return 1 ;
Original file line number Diff line number Diff line change @@ -849,6 +849,9 @@ int CLuaWorldDefs::setRainLevel ( lua_State* luaVM )
849
849
850
850
if ( !argStream.HasErrors ( ) )
851
851
{
852
+ // Clamp amount of rain to avoid game freezing/crash
853
+ fRainLevel = Clamp ( 0 .0f , fRainLevel , 10 .0f );
854
+
852
855
if ( CStaticFunctionDefinitions::SetRainLevel ( fRainLevel ) )
853
856
{
854
857
lua_pushboolean ( luaVM, true );
You can’t perform that action at this time.
0 commit comments