Network/ENet: Clean up time functions
This commit is contained in:
@@ -13,6 +13,14 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
constexpr UInt32 ENetTimeOverflow = 24 * 60 * 60 * 1000;
|
||||
|
||||
inline UInt32 ENetTimeDifference(UInt32 a, UInt32 b);
|
||||
inline bool ENetTimeLess(UInt32 a, UInt32 b);
|
||||
inline bool ENetTimeLessEqual(UInt32 a, UInt32 b);
|
||||
inline bool ENetTimeGreater(UInt32 a, UInt32 b);
|
||||
inline bool ENetTimeGreaterEqual(UInt32 a, UInt32 b);
|
||||
|
||||
class ENetPeer;
|
||||
|
||||
// Constants for the ENet implementation and protocol
|
||||
@@ -294,4 +302,6 @@ namespace Nz
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <Nazara/Network/ENetProtocol.inl>
|
||||
|
||||
#endif // NAZARA_ENETPROTOCOL_HPP
|
||||
|
||||
34
include/Nazara/Network/ENetProtocol.inl
Normal file
34
include/Nazara/Network/ENetProtocol.inl
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Network module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Network/ENetProtocol.hpp>
|
||||
#include <Nazara/Network/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
UInt32 ENetTimeDifference(UInt32 a, UInt32 b)
|
||||
{
|
||||
return (ENetTimeLess(a, b)) ? b - a : a - b;
|
||||
}
|
||||
|
||||
bool ENetTimeLess(UInt32 a, UInt32 b)
|
||||
{
|
||||
return (a - b >= ENetTimeOverflow);
|
||||
}
|
||||
|
||||
bool ENetTimeLessEqual(UInt32 a, UInt32 b)
|
||||
{
|
||||
return !ENetTimeGreater(a, b);
|
||||
}
|
||||
|
||||
bool ENetTimeGreater(UInt32 a, UInt32 b)
|
||||
{
|
||||
return ENetTimeLess(b, a);
|
||||
}
|
||||
|
||||
bool ENetTimeGreaterEqual(UInt32 a, UInt32 b)
|
||||
{
|
||||
return !ENetTimeLess(a, b);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user