1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Allow managing object observers

-----

Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
This commit is contained in:
Lars Mueller 2023-11-12 15:28:29 +01:00 committed by sfan5
parent cc8e7a569e
commit 6874c358ea
15 changed files with 284 additions and 22 deletions

View file

@ -116,6 +116,8 @@ void *ServerThread::run()
m_server->setAsyncFatalError(e.what());
} catch (LuaError &e) {
m_server->setAsyncFatalError(e);
} catch (ModError &e) {
m_server->setAsyncFatalError(e.what());
}
float dtime = 0.0f;
@ -142,6 +144,8 @@ void *ServerThread::run()
m_server->setAsyncFatalError(e.what());
} catch (LuaError &e) {
m_server->setAsyncFatalError(e);
} catch (ModError &e) {
m_server->setAsyncFatalError(e.what());
}
dtime = 1e-6f * (porting::getTimeUs() - t0);
@ -781,6 +785,12 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
//infostream<<"Server: Checking added and deleted active objects"<<std::endl;
MutexAutoLock envlock(m_env_mutex);
// This guarantees that each object recomputes its cache only once per server step,
// unless get_effective_observers is called.
// If we were to update observer sets eagerly in set_observers instead,
// the total costs of calls to set_observers could theoretically be higher.
m_env->invalidateActiveObjectObserverCaches();
{
ClientInterface::AutoLock clientlock(m_clients);
const RemoteClientMap &clients = m_clients.getClientList();