diff --git a/src/client/particles.h b/src/client/particles.h index 72294a552..fe7d68475 100644 --- a/src/client/particles.h +++ b/src/client/particles.h @@ -11,6 +11,7 @@ #include "SMeshBuffer.h" #include +#include #include #include #include "../particles.h" diff --git a/src/irrlichttypes.h b/src/irrlichttypes.h index 0994bbd94..0474786a1 100644 --- a/src/irrlichttypes.h +++ b/src/irrlichttypes.h @@ -4,12 +4,7 @@ #pragma once -/* - * IrrlichtMt already includes stdint.h in irrTypes.h. This works everywhere - * we need it to (including recent MSVC), so should be fine here too. - */ #include - #include using namespace irr; diff --git a/src/mapgen/mg_biome.h b/src/mapgen/mg_biome.h index 8adce5db6..37e09136e 100644 --- a/src/mapgen/mg_biome.h +++ b/src/mapgen/mg_biome.h @@ -8,6 +8,7 @@ #include "objdef.h" #include "nodedef.h" #include "noise.h" +#include "debug.h" // FATAL_ERROR_IF class Server; class Settings; diff --git a/src/mapsector.h b/src/mapsector.h index bc5a2a731..d977bc63c 100644 --- a/src/mapsector.h +++ b/src/mapsector.h @@ -8,6 +8,7 @@ #include "irr_v2d.h" #include "mapblock.h" #include +#include #include #include diff --git a/src/network/mtp/impl.h b/src/network/mtp/impl.h index a88012b22..3f81fe27b 100644 --- a/src/network/mtp/impl.h +++ b/src/network/mtp/impl.h @@ -14,6 +14,7 @@ #include "network/networkprotocol.h" #include #include +#include #include namespace con @@ -24,7 +25,6 @@ class ConnectionSendThread; class Peer; -// FIXME: Peer refcounting should generally be replaced by std::shared_ptr class PeerHelper { public: diff --git a/src/network/mtp/internal.h b/src/network/mtp/internal.h index e3ad39bde..dc3ad55d7 100644 --- a/src/network/mtp/internal.h +++ b/src/network/mtp/internal.h @@ -33,7 +33,7 @@ channel: /* Packet types: -CONTROL: This is a packet used by the protocol. +PACKET_TYPE_CONTROL: This is a packet used by the protocol. - When this is processed, nothing is handed to the user. Header (2 byte): [0] u8 type @@ -48,25 +48,18 @@ controltype and data description: packet to get a reply CONTROLTYPE_DISCO */ -enum ControlType : u8 { - CONTROLTYPE_ACK = 0, - CONTROLTYPE_SET_PEER_ID = 1, - CONTROLTYPE_PING = 2, - CONTROLTYPE_DISCO = 3, -}; /* -ORIGINAL: This is a plain packet with no control and no error +PACKET_TYPE_ORIGINAL: This is a plain packet with no control and no error checking at all. - When this is processed, it is directly handed to the user. Header (1 byte): [0] u8 type */ -//#define TYPE_ORIGINAL 1 #define ORIGINAL_HEADER_SIZE 1 /* -SPLIT: These are sequences of packets forming one bigger piece of +PACKET_TYPE_SPLIT: These are sequences of packets forming one bigger piece of data. - When processed and all the packet_nums 0...packet_count-1 are present (this should be buffered), the resulting data shall be @@ -80,10 +73,9 @@ data. [3] u16 chunk_count [5] u16 chunk_num */ -//#define TYPE_SPLIT 2 /* -RELIABLE: Delivery of all RELIABLE packets shall be forced by ACKs, +PACKET_TYPE_RELIABLE: Delivery of all RELIABLE packets shall be forced by ACKs, and they shall be delivered in the same order as sent. This is done with a buffer in the receiving and transmitting end. - When this is processed, the contents of each packet is recursively @@ -93,15 +85,29 @@ with a buffer in the receiving and transmitting end. [1] u16 seqnum */ -//#define TYPE_RELIABLE 3 #define RELIABLE_HEADER_SIZE 3 #define SEQNUM_INITIAL 65500 #define SEQNUM_MAX 65535 +/****/ + +template +class ConstSharedPtr { +public: + ConstSharedPtr(T *ptr) : ptr(ptr) {} + ConstSharedPtr(const std::shared_ptr &ptr) : ptr(ptr) {} + + const T* get() const noexcept { return ptr.get(); } + const T& operator*() const noexcept { return *ptr.get(); } + const T* operator->() const noexcept { return ptr.get(); } + +private: + std::shared_ptr ptr; +}; + namespace con { - enum PacketType : u8 { PACKET_TYPE_CONTROL = 0, PACKET_TYPE_ORIGINAL = 1, @@ -110,6 +116,13 @@ enum PacketType : u8 { PACKET_TYPE_MAX }; +enum ControlType : u8 { + CONTROLTYPE_ACK = 0, + CONTROLTYPE_SET_PEER_ID = 1, + CONTROLTYPE_PING = 2, + CONTROLTYPE_DISCO = 3, +}; + inline bool seqnum_higher(u16 totest, u16 base) { if (totest > base) diff --git a/src/network/networkpacket.h b/src/network/networkpacket.h index d5e687c68..107d07cfd 100644 --- a/src/network/networkpacket.h +++ b/src/network/networkpacket.h @@ -8,6 +8,8 @@ #include "irrlichttypes_bloated.h" #include "networkprotocol.h" #include +#include +#include #include class NetworkPacket diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h index 152534cbe..5ce3f4221 100644 --- a/src/network/networkprotocol.h +++ b/src/network/networkprotocol.h @@ -4,8 +4,7 @@ #pragma once -#include "irrTypes.h" -using namespace irr; +#include "irrlichttypes.h" extern const u16 LATEST_PROTOCOL_VERSION; diff --git a/src/nodedef.h b/src/nodedef.h index 24bb0c460..71a61896b 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -7,6 +7,7 @@ #include "irrlichttypes_bloated.h" #include #include +#include // shared_ptr #include #include "mapnode.h" #include "nameidmapping.h" diff --git a/src/unittest/test_address.cpp b/src/unittest/test_address.cpp index 7ae7f85cf..364e82fad 100644 --- a/src/unittest/test_address.cpp +++ b/src/unittest/test_address.cpp @@ -4,6 +4,7 @@ #include "test.h" +#include #include "log.h" #include "settings.h" #include "network/socket.h" diff --git a/src/unittest/test_eventmanager.cpp b/src/unittest/test_eventmanager.cpp index 0b1d3bbd1..76019f730 100644 --- a/src/unittest/test_eventmanager.cpp +++ b/src/unittest/test_eventmanager.cpp @@ -3,6 +3,7 @@ // Copyright (C) 2018 nerzhul, Loic BLOT #include +#include #include "test.h" #include "client/event_manager.h" @@ -94,4 +95,4 @@ void TestEventManager::testRealEventAfterDereg() // Push the new event & ensure we target the default value ev.put(new SimpleTriggerEvent(MtEvent::PLAYER_REGAIN_GROUND)); UASSERT(emt->getTestValue() == 0); -} \ No newline at end of file +} diff --git a/src/util/pointer.h b/src/util/pointer.h index fe90a3866..e260b4a5c 100644 --- a/src/util/pointer.h +++ b/src/util/pointer.h @@ -5,26 +5,11 @@ #pragma once #include "irrlichttypes.h" -#include "debug.h" // For assert() +#include "util/basic_macros.h" +#include #include -#include // std::shared_ptr #include - -template -class ConstSharedPtr { -public: - ConstSharedPtr(T *ptr) : ptr(ptr) {} - ConstSharedPtr(const std::shared_ptr &ptr) : ptr(ptr) {} - - const T* get() const noexcept { return ptr.get(); } - const T& operator*() const noexcept { return *ptr.get(); } - const T* operator->() const noexcept { return ptr.get(); } - -private: - std::shared_ptr ptr; -}; - template class Buffer {