Skip to content

Commit

Permalink
Modify resetWaterLevel argument handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Lpsd committed Jun 19, 2024
1 parent dfb1ea1 commit 366780b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
12 changes: 3 additions & 9 deletions Client/mods/deathmatch/logic/luadefs/CLuaWaterDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,20 @@ int CLuaWaterDefs::TestLineAgainstWater(lua_State* luaVM)

bool CLuaWaterDefs::ResetWaterLevel(std::variant<std::monostate, bool, std::vector<CClientWater*>, CClientWater*> resetElements)
{
CStaticFunctionDefinitions::ResetWorldWaterLevel();

CClientWaterManager* pWaterManager = g_pClientGame->GetManager()->GetWaterManager();

switch (resetElements.index())
{
case 0:
CStaticFunctionDefinitions::ResetWorldWaterLevel();
break;

case 1:
{
if (std::get<bool>(resetElements) == true)
{
pWaterManager->ResetAllElementWaterLevel();
}
else
CStaticFunctionDefinitions::ResetWorldWaterLevel();

break;
}
Expand All @@ -175,11 +174,6 @@ bool CLuaWaterDefs::ResetWaterLevel(std::variant<std::monostate, bool, std::vect
pWaterManager->ResetElementWaterLevel(pWaterElement);
break;
}

default:
{
throw std::invalid_argument("Invalid argument supplied for 'resetElements' - expected bool, table or element.");
}
}

return true;
Expand Down
13 changes: 3 additions & 10 deletions Server/mods/deathmatch/logic/luadefs/CLuaWaterDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,20 @@ int CLuaWaterDefs::SetWaterLevel(lua_State* luaVM)

bool CLuaWaterDefs::ResetWaterLevel(std::variant<std::monostate, bool, std::vector<CWater*>, CWater*> resetElements)
{
CStaticFunctionDefinitions::ResetWorldWaterLevel();

CWaterManager* pWaterManager = g_pGame->GetWaterManager();

switch (resetElements.index())
{
case 0:
CStaticFunctionDefinitions::ResetWorldWaterLevel();
break;

case 1:
{
if (std::get<bool>(resetElements) == true)
{
pWaterManager->ResetAllElementWaterLevel();
}
else
CStaticFunctionDefinitions::ResetWorldWaterLevel();

break;
}
Expand All @@ -203,13 +202,7 @@ bool CLuaWaterDefs::ResetWaterLevel(std::variant<std::monostate, bool, std::vect
pWaterManager->ResetElementWaterLevel(pWaterElement);
break;
}

default:
{
throw std::invalid_argument("Invalid argument supplied for 'resetElements' - expected bool, table or element.");
}
}


return true;
}
Expand Down

0 comments on commit 366780b

Please sign in to comment.