Server class code cleanups (#9769)
authorLoïc Blot <nerzhul@users.noreply.github.com>
Thu, 7 May 2020 20:38:41 +0000 (22:38 +0200)
committerGitHub <noreply@github.com>
Thu, 7 May 2020 20:38:41 +0000 (22:38 +0200)
commit454dbf83a9bf292910c1495a2aa49fd8b960c28f
treed3f53bb5914bae385198d3290863ee1c94832dfd
parent650168cadac2a45277a9527ae79efb288ba7a4a4
Server class code cleanups (#9769)

* Server::overrideDayNightRatio doesn't require to return bool
There is no sense to sending null player, the caller should send a valid object

* Server::init: make private & cleanup
This function is always called before start() and loads some variables which can be loaded in constructor directly.
Make it private and call it directly in start

* Split Server inventory responsibility to a dedicated object

This splits permit to found various historical issues:
* duplicate lookups on player connection
* sending inventory to non related player when a player connects
* non friendly lookups on detached inventories ownership

This reduce the detached inventory complexity and also increased the
lookup performance in a quite interesting way for servers with thousands
of inventories.
12 files changed:
src/client/game.cpp
src/main.cpp
src/network/serverpackethandler.cpp
src/script/lua_api/l_base.cpp
src/script/lua_api/l_base.h
src/script/lua_api/l_inventory.cpp
src/script/lua_api/l_object.cpp
src/server.cpp
src/server.h
src/server/CMakeLists.txt
src/server/serverinventorymgr.cpp [new file with mode: 0644]
src/server/serverinventorymgr.h [new file with mode: 0644]