1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Reduce transitive includes by moving a class

This commit is contained in:
sfan5 2025-03-26 19:47:40 +01:00
parent b146673c3d
commit dea95c7339
12 changed files with 40 additions and 40 deletions

View file

@ -11,6 +11,7 @@
#include "SMeshBuffer.h" #include "SMeshBuffer.h"
#include <mutex> #include <mutex>
#include <memory>
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include "../particles.h" #include "../particles.h"

View file

@ -4,12 +4,7 @@
#pragma once #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 <cstdint> #include <cstdint>
#include <irrTypes.h> #include <irrTypes.h>
using namespace irr; using namespace irr;

View file

@ -8,6 +8,7 @@
#include "objdef.h" #include "objdef.h"
#include "nodedef.h" #include "nodedef.h"
#include "noise.h" #include "noise.h"
#include "debug.h" // FATAL_ERROR_IF
class Server; class Server;
class Settings; class Settings;

View file

@ -8,6 +8,7 @@
#include "irr_v2d.h" #include "irr_v2d.h"
#include "mapblock.h" #include "mapblock.h"
#include <ostream> #include <ostream>
#include <memory>
#include <map> #include <map>
#include <vector> #include <vector>

View file

@ -14,6 +14,7 @@
#include "network/networkprotocol.h" #include "network/networkprotocol.h"
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <memory>
#include <map> #include <map>
namespace con namespace con
@ -24,7 +25,6 @@ class ConnectionSendThread;
class Peer; class Peer;
// FIXME: Peer refcounting should generally be replaced by std::shared_ptr
class PeerHelper class PeerHelper
{ {
public: public:

View file

@ -33,7 +33,7 @@ channel:
/* /*
Packet types: 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. - When this is processed, nothing is handed to the user.
Header (2 byte): Header (2 byte):
[0] u8 type [0] u8 type
@ -48,25 +48,18 @@ controltype and data description:
packet to get a reply packet to get a reply
CONTROLTYPE_DISCO 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. checking at all.
- When this is processed, it is directly handed to the user. - When this is processed, it is directly handed to the user.
Header (1 byte): Header (1 byte):
[0] u8 type [0] u8 type
*/ */
//#define TYPE_ORIGINAL 1
#define ORIGINAL_HEADER_SIZE 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. data.
- When processed and all the packet_nums 0...packet_count-1 are - When processed and all the packet_nums 0...packet_count-1 are
present (this should be buffered), the resulting data shall be present (this should be buffered), the resulting data shall be
@ -80,10 +73,9 @@ data.
[3] u16 chunk_count [3] u16 chunk_count
[5] u16 chunk_num [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 and they shall be delivered in the same order as sent. This is done
with a buffer in the receiving and transmitting end. with a buffer in the receiving and transmitting end.
- When this is processed, the contents of each packet is recursively - 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 [1] u16 seqnum
*/ */
//#define TYPE_RELIABLE 3
#define RELIABLE_HEADER_SIZE 3 #define RELIABLE_HEADER_SIZE 3
#define SEQNUM_INITIAL 65500 #define SEQNUM_INITIAL 65500
#define SEQNUM_MAX 65535 #define SEQNUM_MAX 65535
/****/
template<typename T>
class ConstSharedPtr {
public:
ConstSharedPtr(T *ptr) : ptr(ptr) {}
ConstSharedPtr(const std::shared_ptr<T> &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<T> ptr;
};
namespace con namespace con
{ {
enum PacketType : u8 { enum PacketType : u8 {
PACKET_TYPE_CONTROL = 0, PACKET_TYPE_CONTROL = 0,
PACKET_TYPE_ORIGINAL = 1, PACKET_TYPE_ORIGINAL = 1,
@ -110,6 +116,13 @@ enum PacketType : u8 {
PACKET_TYPE_MAX 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) inline bool seqnum_higher(u16 totest, u16 base)
{ {
if (totest > base) if (totest > base)

View file

@ -8,6 +8,8 @@
#include "irrlichttypes_bloated.h" #include "irrlichttypes_bloated.h"
#include "networkprotocol.h" #include "networkprotocol.h"
#include <SColor.h> #include <SColor.h>
#include <string>
#include <string_view>
#include <vector> #include <vector>
class NetworkPacket class NetworkPacket

View file

@ -4,8 +4,7 @@
#pragma once #pragma once
#include "irrTypes.h" #include "irrlichttypes.h"
using namespace irr;
extern const u16 LATEST_PROTOCOL_VERSION; extern const u16 LATEST_PROTOCOL_VERSION;

View file

@ -7,6 +7,7 @@
#include "irrlichttypes_bloated.h" #include "irrlichttypes_bloated.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <memory> // shared_ptr
#include <map> #include <map>
#include "mapnode.h" #include "mapnode.h"
#include "nameidmapping.h" #include "nameidmapping.h"

View file

@ -4,6 +4,7 @@
#include "test.h" #include "test.h"
#include <memory>
#include "log.h" #include "log.h"
#include "settings.h" #include "settings.h"
#include "network/socket.h" #include "network/socket.h"

View file

@ -3,6 +3,7 @@
// Copyright (C) 2018 nerzhul, Loic BLOT <loic.blot@unix-experience.fr> // Copyright (C) 2018 nerzhul, Loic BLOT <loic.blot@unix-experience.fr>
#include <unordered_map> #include <unordered_map>
#include <memory>
#include "test.h" #include "test.h"
#include "client/event_manager.h" #include "client/event_manager.h"

View file

@ -5,26 +5,11 @@
#pragma once #pragma once
#include "irrlichttypes.h" #include "irrlichttypes.h"
#include "debug.h" // For assert() #include "util/basic_macros.h"
#include <cassert>
#include <cstring> #include <cstring>
#include <memory> // std::shared_ptr
#include <string_view> #include <string_view>
template<typename T>
class ConstSharedPtr {
public:
ConstSharedPtr(T *ptr) : ptr(ptr) {}
ConstSharedPtr(const std::shared_ptr<T> &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<T> ptr;
};
template <typename T> template <typename T>
class Buffer class Buffer
{ {