CubicMC/cubic-server

Quality of life changes

STMiki opened this issue ยท 7 comments

  • Add a simpler way to add a config entry
  • Logger - the code is... Well... Bad.
  • Player.cpp file LOL (>1k lines)
  • Force quit when smashing ctrl + c multiple times
  • Remove Global from identifier in types.hpp
  • Vector return reference on operator overlaod
  • Add logger level NETWORK and maybe DEV
  • Improve call to Message
  • Change where the soundSystem is tick
  • Make all enum streamable
  • Add a common header file for define used everywhere
  • Change the way the height map are calculated (do a new function set block without height map calculation and an other function update height maps)
  • Rework some function naming (Player.cpp playerPickupItem())

I was thinking of maybe change to a external log library altogether (spdlog for example, which we can add sinks to make the gui code better than currently).

For player.cpp I don't think we can do much about it, because it makes sense to have all that code here. It is kinda painful to go through but overall I don't see how we can change that :/.

For the Player.cpp I think there are parts that can be optimized (the registry cough cough). But most of the code are event handling, so we can reduce it a little, but not by much unfortunately

The registry is already planned to be reworked, but for the event handling I think that it is fine. Putting that stuff in other folders might just make the code less maintainable overall (Just a supposition).

Sound System is ticked in the worldGroup running cycle

_soundSystem->tick();

Make all enum's streamable to be able to use them in the logger without having to cast everywhere.

change where some define are to put them all in a specific file (like UNUSED who is in Server.hpp)

#define _SEND_PACKET_DECLARATION(packet, debug)                 \
    void Player::send##packet(const protocol::packet &data) \
    {                                                    \
        auto pck = protocol::create##packet(data);          \
        _cli->_sendData(*pck);                           \
        LDEBUG(debug);              \
    }

#define SEND_PACKET_DECLARATION_WITH_DEBUG(packet, debug) _SEND_PACKET_DECLARATION(packet, debug)
#define SEND_PACKET_DECLARATION(packet) _SEND_PACKET_DECLARATION(packet, "Sent a" #packet " packet")

Idea for reducing the size of player.cpp