Skip to content

Commit

Permalink
Send world light level only when it has changed (#3832)
Browse files Browse the repository at this point in the history
  • Loading branch information
marmichalski authored and DSpeichert committed May 9, 2022
1 parent a4f53ef commit df1c8e4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4572,11 +4572,15 @@ void Game::checkDecay()
void Game::checkLight()
{
g_scheduler.addEvent(createSchedulerTask(EVENT_LIGHTINTERVAL, std::bind(&Game::checkLight, this)));
uint8_t previousLightLevel = lightLevel;
updateWorldLightLevel();
LightInfo lightInfo = getWorldLightInfo();

if (previousLightLevel != lightLevel) {
LightInfo lightInfo = getWorldLightInfo();

for (const auto& it : players) {
it.second->sendWorldLight(lightInfo);
for (const auto& it : players) {
it.second->sendWorldLight(lightInfo);
}
}
}

Expand Down

0 comments on commit df1c8e4

Please sign in to comment.