From 510ce208a83791aca610ab38198a9ebbb2ad2bfe Mon Sep 17 00:00:00 2001 From: fgsfds Date: Mon, 5 Feb 2018 20:06:32 +0300 Subject: [PATCH] port forwarding and miniupnpc are now completely optional --- README | 9 ++++++--- src/game/Doom2DF.lpr | 2 ++ src/game/g_net.pas | 15 ++++++++++++++- src/lib/miniupnpc/miniupnpc.pas | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README b/README index 744360a..d9d63a8 100644 --- a/README +++ b/README @@ -19,11 +19,13 @@ cd src/game fpc -O3 -Fi../lib/vampimg -Fi../lib/vampimg/JpegLib -Fi../lib/vampimg/ZLib -Fu../lib/vampimg -Fu../lib/vampimg/JpegLib -Fu../lib/vampimg/ZLib -FE../../bin -FU../../tmp Doom2DF.lpr If you want SDL_mixer instead of FMOD, add -dUSE_MIXER. +If you want the server to be able to forward ports via UPNP, add -dUSE_MINIUPNPC. To build a headless (no video/audio, for dedicated servers) executable, add -dHEADLESS. Replace -O3 with -g -gl to enable debugging features. Run the game with --gdb when using a debugger to prevent it from eating exceptions. -Windows binaries will require the appropriate DLLs (SDL2.dll, SDL2_mixer.dll or FMODEx.dll, ENet.dll). +Windows binaries will require the appropriate DLLs (SDL2.dll, SDL2_mixer.dll or FMODEx.dll, ENet.dll, miniupnpc.dll), +unless you choose to static link them (see below). Static Linking @@ -35,8 +37,9 @@ It is now possible to link windoze LibJIT and ENet as static libs. First, you need to clone ( http://repo.or.cz/d2df-binlib.git ) (repo with prebuilt windoze libs). Then, you can use: - -dLIBJIT_WINDOZE_STATIC -- static LibJIT - -dLIBENET_WINDOZE_STATIC -- static ENet + -dLIBJIT_WINDOZE_STATIC -- static LibJIT + -dLIBENET_WINDOZE_STATIC -- static ENet + -dLIBMINIUPNPC_WINDOZE_STATIC -- static MiniUPNPC Don't forget to specify lib*.a location with -Fi<...> diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 429c5f0..5f707e0 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -38,7 +38,9 @@ uses math, GL, GLExt, +{$IFDEF USE_MINIUPNPC} miniupnpc in '../lib/miniupnpc/miniupnpc.pas', +{$ENDIF} SDL2 in '../lib/sdl2/sdl2.pas', {$IFDEF USE_SDLMIXER} SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas', diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 93525c9..4e2ed9a 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -19,7 +19,7 @@ unit g_net; interface uses - e_log, e_msg, ENet, miniupnpc, Classes, MAPDEF; + e_log, e_msg, ENet, Classes, MAPDEF{$IFDEF USE_MINIUPNPC}, miniupnpc;{$ELSE};{$ENDIF} const NET_PROTOCOL_VER = 173; @@ -141,10 +141,12 @@ var NetGotEverything: Boolean = False; NetGotKeys: Boolean = False; +{$IFDEF USE_MINIUPNPC} NetPortForwarded: Word = 0; NetPongForwarded: Boolean = False; NetIGDControl: AnsiString; NetIGDService: TURLStr; +{$ENDIF} NetDumpFile: TStream; @@ -1111,6 +1113,7 @@ begin end; function g_Net_ForwardPorts(ForwardPongPort: Boolean = True): Boolean; +{$IFDEF USE_MINIUPNPC} var DevList: PUPNPDev; Urls: TUPNPUrls; @@ -1203,8 +1206,14 @@ begin FreeUPNPUrls(@Urls); Result := True; end; +{$ELSE} +begin + Result := False; +end; +{$ENDIF} procedure g_Net_UnforwardPorts(); +{$IFDEF USE_MINIUPNPC} var I: Integer; StrPort: AnsiString; @@ -1233,6 +1242,10 @@ begin NetPortForwarded := 0; end; +{$ELSE} +begin +end; +{$ENDIF} initialization diff --git a/src/lib/miniupnpc/miniupnpc.pas b/src/lib/miniupnpc/miniupnpc.pas index 3e453b1..37ced0c 100644 --- a/src/lib/miniupnpc/miniupnpc.pas +++ b/src/lib/miniupnpc/miniupnpc.pas @@ -1,4 +1,4 @@ -{$DEFINE LIBMINIUPNPC_WINDOZE_STATIC} +{.$DEFINE LIBMINIUPNPC_WINDOZE_STATIC} {$MODE OBJFPC} {$PACKRECORDS C} -- 2.29.2