Skip to content

Commit f101193

Browse files
author
Marek Kulik
committed
Clamp rain level in setRainLevel
1 parent a381f24 commit f101193

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.World.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,14 +1416,17 @@ int CLuaFunctionDefs::GetRainLevel ( lua_State* luaVM )
14161416
int CLuaFunctionDefs::SetRainLevel ( lua_State* luaVM )
14171417
{
14181418
// bool setRainLevel ( float amount )
1419-
float fAmount;
1419+
float fRainLevel;
14201420

14211421
CScriptArgReader argStream ( luaVM );
1422-
argStream.ReadNumber ( fAmount );
1422+
argStream.ReadNumber ( fRainLevel );
14231423

14241424
if ( !argStream.HasErrors () )
14251425
{
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 );
14271430

14281431
lua_pushboolean ( luaVM, true );
14291432
return 1;

Server/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,9 @@ int CLuaWorldDefs::setRainLevel ( lua_State* luaVM )
849849

850850
if ( !argStream.HasErrors ( ) )
851851
{
852+
// Clamp amount of rain to avoid game freezing/crash
853+
fRainLevel = Clamp( 0.0f, fRainLevel, 10.0f );
854+
852855
if ( CStaticFunctionDefinitions::SetRainLevel ( fRainLevel ) )
853856
{
854857
lua_pushboolean ( luaVM, true );

0 commit comments

Comments
 (0)