1
0
forked from 0ad/0ad

Upgrade game and build system to ENet 1.3

This was SVN commit r9574.
This commit is contained in:
Ykkrosh 2011-05-29 20:57:28 +00:00
parent e3d87b0375
commit c2677b4bb0
6 changed files with 37 additions and 23 deletions

View File

@ -19,6 +19,7 @@ local function add_extern_lib_paths(extern_lib)
extern_lib == "cxxtest" or
extern_lib == "fcollada" or
extern_lib == "valgrind" or
(extern_lib == "enet" and not options["with-system-enet"]) or
(extern_lib == "nvtt" and not options["with-system-nvtt"])
then
tinsert(package.includepaths, libraries_dir .. extern_lib .. "/include")
@ -99,22 +100,9 @@ extern_lib_defs = {
win_names = { },
unix_names = { "dl" },
},
-- rationale: see libraries_dir..enet/lib/rationale.txt
enet = {
add_func = function()
if OS == "windows" then
tinsert(package.includepaths, libraries_dir.."enet/include")
tinsert(package.config["Debug" ].libpaths, libraries_dir.."enet/lib/debug")
tinsert(package.config["Testing"].libpaths, libraries_dir.."enet/lib/debug")
tinsert(package.config["Release"].libpaths, libraries_dir.."enet/lib/release")
tinsert(package.config["Debug" ].links, "enet_dbg")
tinsert(package.config["Testing"].links, "enet_dbg")
tinsert(package.config["Release"].links, "enet")
else
-- We should be using pkgconfig, but (at least on ubuntu) that adds /usr/include/enet which contains a time.h that gets used before the system header...
tinsert(package.links, "enet")
end
end,
win_names = { "enet" },
unix_names = { "enet" },
},
fcollada = {
add_func = function()

View File

@ -6,7 +6,8 @@ addoption("icc", "Use Intel C++ Compiler (Linux only; should use either \"--cc i
addoption("outpath", "Location for generated project files")
addoption("without-tests", "Disable generation of test projects")
addoption("without-pch", "Disable generation and usage of precompiled headers")
addoption("with-system-nvtt", "Search standard paths for nvidia-texture-tools library, instead of using bundled copy")
addoption("with-system-nvtt", "Search standard paths for the nvidia-texture-tools library, instead of using bundled copy")
addoption("with-system-enet", "Search standard paths for libenet, instead of using bundled copy")
addoption("bindir", "Directory for executables (typically '/usr/games'); default is to be relocatable")
addoption("datadir", "Directory for data files (typically '/usr/share/games/0ad'); default is ../data/ relative to executable")
addoption("libdir", "Directory for libraries (typically '/usr/lib/games/0ad'); default is ./ relative to executable")

View File

@ -8,11 +8,14 @@ die()
JOBS=${JOBS:="-j2"}
# Parse command-line options
with_system_nvtt=false
with_system_enet=false
for i in "$@"
do
case $i in
--with-system-nvtt ) with_system_nvtt=true ;;
--with-system-enet ) with_system_enet=true ;;
-j* ) JOBS=$i ;;
esac
done
@ -32,6 +35,10 @@ if [ "$with_system_nvtt" = "false" ]; then
(cd ../../libraries/nvtt && JOBS=${JOBS} ./build.sh) || die "NVTT build failed"
fi
echo
if [ "$with_system_enet" = "false" ]; then
(cd ../../libraries/enet && JOBS=${JOBS} ./build.sh) || die "ENet build failed"
fi
echo
# Make sure workspaces/gcc exists.
mkdir -p gcc

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010 Wildfire Games
/* Copyright (c) 2011 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -27,11 +27,27 @@
#ifndef INCLUDED_ENET
#define INCLUDED_ENET
#if OS_WIN
// enet/win32.h wants to include winsock2.h which causes conflicts.
// provide some required definitions from winsock.h, then pretend
// we already included winsock.h
typedef uintptr_t SOCKET;
#define INVALID_SOCKET (SOCKET)(~0)
struct fd_set;
#define _WINSOCK2API_ // winsock2.h include guard
#define WIN32
#endif // OS_WIN
#include <enet/enet.h>
#if defined(ENET_VERSION_MAJOR) && (ENET_VERSION_MAJOR > 1 || ENET_VERSION_MINOR > 2)
#error The game currently requires ENet 1.2.x. You are using a newer version, which\
has an incompatible API and network protocol. Please switch to an older version.
#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 a newer older, which\
has an incompatible API and network protocol. Please switch to a newer version.
#endif
#endif // #ifndef INCLUDED_ENET

View File

@ -34,6 +34,8 @@
#define DEFAULT_WELCOME_MESSAGE L"Welcome"
#define MAX_CLIENTS 8
static const int CHANNEL_COUNT = 1;
/**
* enet_host_service timeout (msecs).
* Smaller numbers may hurt performance; larger numbers will
@ -114,7 +116,7 @@ bool CNetServerWorker::SetupConnection()
addr.port = PS_DEFAULT_PORT;
// Create ENet server
m_Host = enet_host_create(&addr, MAX_CLIENTS, 0, 0);
m_Host = enet_host_create(&addr, MAX_CLIENTS, CHANNEL_COUNT, 0, 0);
if (!m_Host)
{
LOGERROR(L"Net server: enet_host_create failed");

View File

@ -53,7 +53,7 @@ bool CNetClientSession::Connect(u16 port, const CStr& server)
ENSURE(!m_Server);
// Create ENet host
ENetHost* host = enet_host_create(NULL, 1, 0, 0);
ENetHost* host = enet_host_create(NULL, 1, CHANNEL_COUNT, 0, 0);
if (!host)
return false;
@ -64,7 +64,7 @@ bool CNetClientSession::Connect(u16 port, const CStr& server)
return false;
// Initiate connection to server
ENetPeer* peer = enet_host_connect(host, &addr, CHANNEL_COUNT);
ENetPeer* peer = enet_host_connect(host, &addr, CHANNEL_COUNT, 0);
if (!peer)
return false;