Merge remote-tracking branch 'refs/remotes/origin/master' into enet_wip_nothing_to_see_here
This commit is contained in:
commit
17d9cd6e7d
|
|
@ -133,9 +133,9 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Box<T>::Contains(T X, T Y, T Z) const
|
bool Box<T>::Contains(T X, T Y, T Z) const
|
||||||
{
|
{
|
||||||
return X >= x && X <= x + width &&
|
return X >= x && X < x + width &&
|
||||||
Y >= y && Y <= y + height &&
|
Y >= y && Y < y + height &&
|
||||||
Z >= z && Z <= z + depth;
|
Z >= z && Z < z + depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -117,8 +117,8 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Rect<T>::Contains(T X, T Y) const
|
bool Rect<T>::Contains(T X, T Y) const
|
||||||
{
|
{
|
||||||
return X >= x && X <= (x + width) &&
|
return X >= x && X < (x + width) &&
|
||||||
Y >= y && Y <= (y + height);
|
Y >= y && Y < (y + height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,16 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Network/Config.hpp>
|
#include <Nazara/Network/Config.hpp>
|
||||||
|
#include <Nazara/Network/Enums.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
NAZARA_NETWORK_API const char* ErrorToString(Nz::ResolveError resolveError);
|
||||||
|
NAZARA_NETWORK_API const char* ErrorToString(Nz::SocketError socketError);
|
||||||
|
|
||||||
NAZARA_NETWORK_API bool ParseIPAddress(const char* addressPtr, UInt8 result[16], UInt16* port = nullptr, bool* isIPv6 = nullptr, const char** endOfRead = nullptr);
|
NAZARA_NETWORK_API bool ParseIPAddress(const char* addressPtr, UInt8 result[16], UInt16* port = nullptr, bool* isIPv6 = nullptr, const char** endOfRead = nullptr);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ namespace Nz
|
||||||
* \param number Optional argument to return the number parsed
|
* \param number Optional argument to return the number parsed
|
||||||
* \param endOfRead Optional argument to determine where parsing stopped
|
* \param endOfRead Optional argument to determine where parsing stopped
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool ParseDecimal(const char* str, unsigned int* number, const char** endOfRead)
|
bool ParseDecimal(const char* str, unsigned int* number, const char** endOfRead)
|
||||||
{
|
{
|
||||||
const char* ptr = str;
|
const char* ptr = str;
|
||||||
|
|
@ -52,7 +51,6 @@ namespace Nz
|
||||||
* \param number Optional argument to return the number parsed
|
* \param number Optional argument to return the number parsed
|
||||||
* \param endOfRead Optional argument to determine where parsing stopped
|
* \param endOfRead Optional argument to determine where parsing stopped
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool ParseHexadecimal(const char* str, unsigned int* number, const char** endOfRead)
|
bool ParseHexadecimal(const char* str, unsigned int* number, const char** endOfRead)
|
||||||
{
|
{
|
||||||
const char* ptr = str;
|
const char* ptr = str;
|
||||||
|
|
@ -78,6 +76,111 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup network
|
||||||
|
* \brief Returns the text representation of an error
|
||||||
|
* \return Text representation of an error
|
||||||
|
*
|
||||||
|
* \param resolveError Error enumeration
|
||||||
|
*/
|
||||||
|
const char* ErrorToString(Nz::ResolveError resolveError)
|
||||||
|
{
|
||||||
|
switch (resolveError)
|
||||||
|
{
|
||||||
|
case Nz::ResolveError_NoError:
|
||||||
|
return "No error";
|
||||||
|
|
||||||
|
case Nz::ResolveError_Internal:
|
||||||
|
return "An internal error occurred";
|
||||||
|
|
||||||
|
case Nz::ResolveError_ResourceError:
|
||||||
|
return "The operating system lacks the resources to proceed";
|
||||||
|
|
||||||
|
case Nz::ResolveError_NonRecoverable:
|
||||||
|
return "A nonrecoverable error occurred";
|
||||||
|
|
||||||
|
case Nz::ResolveError_NotFound:
|
||||||
|
return "No such host is known";
|
||||||
|
|
||||||
|
case Nz::ResolveError_NotInitialized:
|
||||||
|
return "Nazara Network has not been initialized";
|
||||||
|
|
||||||
|
case Nz::ResolveError_ProtocolNotSupported:
|
||||||
|
return "A specified protocol is not supported by the server";
|
||||||
|
|
||||||
|
case Nz::ResolveError_TemporaryFailure:
|
||||||
|
return "A temporary failure occurred, try again";
|
||||||
|
|
||||||
|
case Nz::ResolveError_Unknown:
|
||||||
|
return "An unknown error occurred";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "Invalid error value";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup network
|
||||||
|
* \brief Returns the text representation of an error
|
||||||
|
* \return Text representation of an error
|
||||||
|
*
|
||||||
|
* \param socketError Error enumeration
|
||||||
|
*/
|
||||||
|
const char* ErrorToString(Nz::SocketError socketError)
|
||||||
|
{
|
||||||
|
switch (socketError)
|
||||||
|
{
|
||||||
|
case Nz::SocketError_NoError:
|
||||||
|
return "No error";
|
||||||
|
|
||||||
|
case Nz::SocketError_AddressNotAvailable:
|
||||||
|
return "The address is already in use";
|
||||||
|
|
||||||
|
case Nz::SocketError_ConnectionClosed:
|
||||||
|
return "The connection has been closed";
|
||||||
|
|
||||||
|
case Nz::SocketError_ConnectionRefused:
|
||||||
|
return "The connection attempt was refused";
|
||||||
|
|
||||||
|
case Nz::SocketError_DatagramSize:
|
||||||
|
return "The datagram size is over the system limit";
|
||||||
|
|
||||||
|
case Nz::SocketError_Internal:
|
||||||
|
return "An internal error occurred";
|
||||||
|
|
||||||
|
case Nz::SocketError_Packet:
|
||||||
|
return "Packet encoding or decoding failed";
|
||||||
|
|
||||||
|
case Nz::SocketError_NetworkError:
|
||||||
|
return "Networking subsystem failed";
|
||||||
|
|
||||||
|
case Nz::SocketError_NotInitialized:
|
||||||
|
return "Network module has not been initialized";
|
||||||
|
|
||||||
|
case Nz::SocketError_NotSupported:
|
||||||
|
return "This operation is not supported";
|
||||||
|
|
||||||
|
case Nz::SocketError_ResolveError:
|
||||||
|
return "The hostname couldn't be resolved";
|
||||||
|
|
||||||
|
case Nz::SocketError_ResourceError:
|
||||||
|
return "The operating system lacks the resources to proceed";
|
||||||
|
|
||||||
|
case Nz::SocketError_TimedOut:
|
||||||
|
return "The operation timed out";
|
||||||
|
|
||||||
|
case Nz::SocketError_Unknown:
|
||||||
|
return "An unknown error occurred";
|
||||||
|
|
||||||
|
case Nz::SocketError_UnreachableHost:
|
||||||
|
return "The host is not reachable";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "Invalid error value";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \ingroup network
|
* \ingroup network
|
||||||
* \brief Parse a textual IPv4 or IPv6 address
|
* \brief Parse a textual IPv4 or IPv6 address
|
||||||
|
|
@ -97,7 +200,6 @@ namespace Nz
|
||||||
* \remark Produces a NazaraAssert if addressPtr is invalid
|
* \remark Produces a NazaraAssert if addressPtr is invalid
|
||||||
* \remark Produces a NazaraAssert if result is invalid
|
* \remark Produces a NazaraAssert if result is invalid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool ParseIPAddress(const char* addressPtr, UInt8 result[16], UInt16* port, bool* isIPv6, const char** endOfRead)
|
bool ParseIPAddress(const char* addressPtr, UInt8 result[16], UInt16* port, bool* isIPv6, const char** endOfRead)
|
||||||
{
|
{
|
||||||
NazaraAssert(addressPtr, "Invalid address string");
|
NazaraAssert(addressPtr, "Invalid address string");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue