mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Reduce transitive includes by moving a class
This commit is contained in:
parent
b146673c3d
commit
dea95c7339
12 changed files with 40 additions and 40 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "SMeshBuffer.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include "../particles.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 <cstdint>
|
||||
|
||||
#include <irrTypes.h>
|
||||
|
||||
using namespace irr;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "objdef.h"
|
||||
#include "nodedef.h"
|
||||
#include "noise.h"
|
||||
#include "debug.h" // FATAL_ERROR_IF
|
||||
|
||||
class Server;
|
||||
class Settings;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "irr_v2d.h"
|
||||
#include "mapblock.h"
|
||||
#include <ostream>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "network/networkprotocol.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
namespace con
|
||||
|
@ -24,7 +25,6 @@ class ConnectionSendThread;
|
|||
|
||||
class Peer;
|
||||
|
||||
// FIXME: Peer refcounting should generally be replaced by std::shared_ptr
|
||||
class PeerHelper
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -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<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
|
||||
{
|
||||
|
||||
|
||||
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)
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "irrlichttypes_bloated.h"
|
||||
#include "networkprotocol.h"
|
||||
#include <SColor.h>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
class NetworkPacket
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "irrTypes.h"
|
||||
using namespace irr;
|
||||
#include "irrlichttypes.h"
|
||||
|
||||
extern const u16 LATEST_PROTOCOL_VERSION;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "irrlichttypes_bloated.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <memory> // shared_ptr
|
||||
#include <map>
|
||||
#include "mapnode.h"
|
||||
#include "nameidmapping.h"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "test.h"
|
||||
|
||||
#include <memory>
|
||||
#include "log.h"
|
||||
#include "settings.h"
|
||||
#include "network/socket.h"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// Copyright (C) 2018 nerzhul, Loic BLOT <loic.blot@unix-experience.fr>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,26 +5,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "irrlichttypes.h"
|
||||
#include "debug.h" // For assert()
|
||||
#include "util/basic_macros.h"
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <memory> // std::shared_ptr
|
||||
#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>
|
||||
class Buffer
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue