Changeset View
Changeset View
Standalone View
Standalone View
source/lib/external_libraries/enet.h
/* Copyright (C) 2011 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
Show All 12 Lines | |||||
/* | /* | ||||
* bring in ENet header, with version check | * bring in ENet header, with version check | ||||
*/ | */ | ||||
#ifndef INCLUDED_ENET | #ifndef INCLUDED_ENET | ||||
#define INCLUDED_ENET | #define INCLUDED_ENET | ||||
#include "lib/config2.h" // CONFIG2_SYSTEM_ENET | |||||
#if OS_WIN | #if OS_WIN | ||||
// enet/win32.h wants to include winsock2.h which causes conflicts. | // enet/win32.h wants to include winsock2.h which causes conflicts. | ||||
// provide some required definitions from winsock.h, then pretend | // provide some required definitions from winsock.h, then pretend | ||||
// we already included winsock.h | // we already included winsock.h | ||||
typedef uintptr_t SOCKET; | typedef uintptr_t SOCKET; | ||||
#define INVALID_SOCKET (SOCKET)(~0) | #define INVALID_SOCKET (SOCKET)(~0) | ||||
struct fd_set; | struct fd_set; | ||||
#define _WINSOCK2API_ // winsock2.h include guard | #define _WINSOCK2API_ // winsock2.h include guard | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
# define WIN32 | # define WIN32 | ||||
#endif | #endif | ||||
#endif // OS_WIN | #endif // OS_WIN | ||||
#if CONFIG2_SYSTEM_ENET | |||||
#include <enet/enet.h> | #include <enet/enet.h> | ||||
#else | |||||
#include "third_party/enet/enet.h" | |||||
#endif | |||||
#if defined(ENET_VERSION_MAJOR) && !(ENET_VERSION_MAJOR > 1 || ENET_VERSION_MINOR > 2) | #if defined(ENET_VERSION_MAJOR) && !(ENET_VERSION_MAJOR > 1 || ENET_VERSION_MINOR > 2) | ||||
#error The game currently requires ENet 1.3.x. You are using an older version, which\ | #error The game currently requires ENet 1.3.x. You are using an older version, which\ | ||||
has an incompatible API and network protocol. Please switch to a newer version. | has an incompatible API and network protocol. Please switch to a newer version. | ||||
#endif | #endif | ||||
#ifdef ENET_IPV6 | |||||
static inline bool operator==(const in6_addr& lhs, const in6_addr& rhs) | |||||
{ | |||||
return !memcmp(&lhs, &rhs, sizeof(in6_addr)); | |||||
} | |||||
using enet_host_type = in6_addr; | |||||
elexis: `typedef a b;` -> `using b = a;` | |||||
#else | |||||
typedef enet_host_type = u32; | |||||
#endif // #ifdef ENET_IPV6 | |||||
// workaround undefined ENET_EVENT_TYPE_DISCONNECT_TIMEOUT enum value | |||||
#ifndef ENET_EVENT_TYPE_DISCONNECT_TIMEOUT | |||||
#define ENET_EVENT_TYPE_DISCONNECT_TIMEOUT 4 | |||||
#endif | |||||
#endif // #ifndef INCLUDED_ENET | #endif // #ifndef INCLUDED_ENET |
Wildfire Games · Phabricator
typedef a b; -> using b = a;