Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ res/keeperfx_icon.ico
.header_checksum
/deps/enet
/deps/enet6
/deps/libcurl
/deps/zlib
/deps/spng
/deps/astronomy
Expand Down
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ obj/bflib_datetm.o \
obj/bflib_dernc.o \
obj/bflib_enet.o \
obj/net_portforward.o \
obj/net_holepunch.o \
obj/bflib_fileio.o \
obj/bflib_filelst.o \
obj/bflib_fmvids.o \
Expand Down Expand Up @@ -287,6 +288,7 @@ obj/net_input_lag.o \
obj/net_received_packets.o \
obj/net_redundant_packets.o \
obj/net_checksums.o \
obj/net_matchmaking.o \
obj/packets.o \
obj/packets_cheats.o \
obj/packets_input.o \
Expand Down Expand Up @@ -377,6 +379,7 @@ LINKLIB = -mwindows \
-L"deps/enet6/lib" -lenet6 \
-L"deps/miniupnpc" -lminiupnpc \
-L"deps/libnatpmp" -lnatpmp -liphlpapi \
-L"deps/libcurl/lib" -lcurl -lwldap32 -lcrypt32 -lsecur32 -liphlpapi \
-L"deps/spng" -lspng \
-L"deps/centijson" -ljson \
-L"deps/zlib" -lminizip -lz \
Expand All @@ -395,7 +398,8 @@ INCS = \
-I"deps/openal/include" \
-I"deps/luajit/include" \
-I"deps/miniupnpc/include" \
-I"deps/libnatpmp/include"
-I"deps/libnatpmp/include" \
-I"deps/libcurl/include"
CXXINCS = $(INCS)

STDOBJS = $(subst obj/,obj/std/,$(OBJS))
Expand Down Expand Up @@ -435,7 +439,7 @@ HVLOGFLAGS = -DBFDEBUG_LEVEL=10
WARNFLAGS = -Wall -W -Wshadow -Wno-sign-compare -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-sign-compare -Wno-strict-aliasing -Wno-unknown-pragmas -Werror
# disabled warnings: -Wextra -Wtype-limits
CXXFLAGS = $(CXXINCS) -c -std=gnu++1y -fmessage-length=0 $(WARNFLAGS) $(DEPFLAGS) $(OPTFLAGS) $(DBGFLAGS) $(FTEST_DBGFLAGS) $(INCFLAGS)
CFLAGS = $(INCS) -c -std=gnu11 -fmessage-length=0 $(WARNFLAGS) -Werror=implicit $(DEPFLAGS) $(FTEST_DBGFLAGS) $(OPTFLAGS) $(DBGFLAGS) $(INCFLAGS)
CFLAGS = $(INCS) -c -std=gnu11 -fmessage-length=0 $(WARNFLAGS) -Werror=implicit $(DEPFLAGS) $(FTEST_DBGFLAGS) $(OPTFLAGS) $(DBGFLAGS) $(INCFLAGS) -DCURL_STATICLIB
LDFLAGS = $(LINKLIB) $(OPTFLAGS) $(DBGFLAGS) $(FTEST_DBGFLAGS) $(LINKFLAGS) -Wl,-Map,"$(@:%.exe=%.map)"

ifeq ($(USE_PRE_FILE), 1)
Expand Down Expand Up @@ -651,10 +655,11 @@ libexterns: libexterns.mk

clean-libexterns: libexterns.mk
-$(MAKE) -f libexterns.mk clean-libexterns
-$(RM) -rf deps/enet6 deps/zlib deps/spng deps/astronomy deps/centijson deps/luajit deps/miniupnpc deps/libnatpmp
-$(RM) -rf deps/enet6 deps/zlib deps/spng deps/astronomy deps/centijson deps/luajit deps/miniupnpc deps/libnatpmp deps/libcurl
-$(RM) deps/libcurl-mingw32.tar.gz
-$(RM) libexterns

deps/enet6 deps/zlib deps/spng deps/astronomy deps/centijson deps/ffmpeg deps/openal deps/luajit deps/miniupnpc deps/libnatpmp:
deps/enet6 deps/zlib deps/spng deps/astronomy deps/centijson deps/ffmpeg deps/openal deps/luajit deps/miniupnpc deps/libnatpmp deps/libcurl:
$(MKDIR) $@

src/api.c: deps/centijson/include/json.h
Expand All @@ -668,6 +673,7 @@ src/bflib_sndlib.cpp: deps/openal/include/AL/al.h
src/net_resync.cpp: deps/zlib/include/zlib.h
src/console_cmd.c: deps/luajit/include/lua.h
src/net_portforward.cpp: deps/miniupnpc/include/miniupnpc/miniupnpc.h deps/libnatpmp/include/natpmp/natpmp.h
src/net_matchmaking.c: deps/libcurl/include/curl/curl.h

deps/enet6-mingw32.tar.gz:
curl -Lso $@ "https://github.com/dkfans/kfx-deps/releases/download/20260212/enet6-mingw32.tar.gz"
Expand Down Expand Up @@ -731,6 +737,12 @@ deps/libnatpmp-mingw32.tar.gz:
deps/libnatpmp/include/natpmp/natpmp.h: deps/libnatpmp-mingw32.tar.gz | deps/libnatpmp
tar xzmf $< -C deps/libnatpmp

deps/libcurl-mingw32.tar.gz:
curl -Lso $@ "https://github.com/dkfans/kfx-deps/releases/download/20260310/libcurl-mingw32.tar.gz"

deps/libcurl/include/curl/curl.h: deps/libcurl-mingw32.tar.gz | deps/libcurl
tar xzmf $< -C deps/libcurl

cppcheck: | src/ver_defs.h
cppcheck: | deps/zlib/include/zlib.h
cppcheck: | deps/spng/include/spng.h
Expand Down
15 changes: 11 additions & 4 deletions docs/multiplayer_readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ you are over a couple hundred kilometer away from each other.
Multiplayer over ENET/UDP
------------------------------

KeeperFX includes an online matchmaking server. Hosted games are listed there
automatically, allowing others to browse and join without exchanging IP addresses.

To host a ENET/UDP game:
Make sure the port 5556 is open for traffic and is forwarded to port 5556 on
your computer. When you have started the game, click Multiplayer -> ENET/UDP ->
Create Game.
Create Game. Your game will appear in the matchmaking list for others to join.

To join a ENET/UDP game:
Specify a command line option -sessions [ip_address]:5556 when starting game.
For instance, if the host's IP address is 55.83.54.187, the appropriate command
line option is -sessions 55.83.54.187:5556
Click Multiplayer -> ENET/UDP to browse available games from the matchmaking
server, then select one and click Join Game.

Alternatively, join directly by specifying a command line option
-sessions [ip_address]:5556 when starting game. For instance, if the host's IP
address is 55.83.54.187, the appropriate command line option is
-sessions 55.83.54.187:5556
The launcher can be used to set this.

Several sessions can be added to command line by prepending a semicolon before
Expand Down
21 changes: 18 additions & 3 deletions linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ src/map_utils.c \
src/moonphase.c \
src/net_checksums.c \
src/net_game.c \
src/net_holepunch.c \
src/net_matchmaking.c \
src/net_input_lag.c \
src/net_received_packets.c \
src/net_redundant_packets.c \
Expand Down Expand Up @@ -282,6 +284,7 @@ KFX_INCLUDES = \
-Ideps/centitoml \
-Ideps/astronomy/include \
-Ideps/enet6/include \
-Ideps/libcurl/include \
$(shell pkg-config --cflags-only-I luajit)

KFX_CFLAGS += -g -DDEBUG -DBFDEBUG_LEVEL=0 -O3 -march=x86-64 $(KFX_INCLUDES) -Wall -Wextra -Werror -Wno-unused-parameter -Wno-absolute-value -Wno-unknown-pragmas -Wno-format-truncation -Wno-sign-compare
Expand Down Expand Up @@ -309,6 +312,7 @@ KFX_LDFLAGS += \
$(shell pkg-config --libs-only-l zlib) \
-lminiupnpc \
-lnatpmp \
-Ldeps/libcurl/lib -lcurl -lssl -lcrypto -lzstd \
-ldl

TOML_SOURCES = \
Expand All @@ -331,11 +335,12 @@ endif
all: bin/keeperfx

clean:
rm -rf obj bin src/ver_defs.h deps/astronomy deps/centijson deps/enet6
rm -rf obj bin src/ver_defs.h deps/astronomy deps/centijson deps/enet6 deps/libcurl
rm -f deps/libcurl-lin64.tar.gz

.PHONY: all clean

bin/keeperfx: $(KFX_OBJECTS) $(TOML_OBJECTS) | bin
bin/keeperfx: $(KFX_OBJECTS) $(TOML_OBJECTS) deps/libcurl/lib/libcurl.a | bin
$(CXX) -o $@ $(KFX_OBJECTS) $(TOML_OBJECTS) $(KFX_LDFLAGS)

$(KFX_C_OBJECTS): obj/%.o: src/%.c src/ver_defs.h | obj
Expand All @@ -349,13 +354,15 @@ $(KFX_CXX_OBJECTS): obj/%.o: src/%.cpp src/ver_defs.h | obj
$(TOML_OBJECTS): obj/centitoml/%.o: deps/centitoml/%.c | obj/centitoml
$(CC) $(TOML_CFLAGS) -c $< -o $@

bin obj deps/astronomy deps/centijson deps/enet6 obj/centitoml:
bin obj deps/astronomy deps/centijson deps/enet6 deps/libcurl obj/centitoml:
$(MKDIR) $@

src/actionpt.c: deps/centijson/include/json.h
src/api.c: deps/centijson/include/json.h
src/bflib_enet.cpp: deps/enet6/include/enet6/enet.h
src/moonphase.c: deps/astronomy/include/astronomy.h
src/net_holepunch.c: deps/enet6/include/enet6/enet.h
src/net_matchmaking.c: deps/libcurl/include/curl/curl.h
deps/centitoml/toml_api.c: deps/centijson/include/json.h
deps/centitoml/toml_conv.c: deps/centijson/include/json.h

Expand All @@ -377,6 +384,14 @@ deps/enet6-lin64.tar.gz:
deps/enet6/include/enet6/enet.h: deps/enet6-lin64.tar.gz | deps/enet6
tar xzmf $< -C deps/enet6

deps/libcurl-lin64.tar.gz:
curl -Lso $@ "https://github.com/dkfans/kfx-deps/releases/download/20260310/libcurl-lin64.tar.gz"

deps/libcurl/lib/libcurl.a: deps/libcurl-lin64.tar.gz | deps/libcurl
tar xzmf $< -C deps/libcurl

deps/libcurl/include/curl/curl.h: deps/libcurl/lib/libcurl.a

src/ver_defs.h: version.mk
$(ECHO) "#define VER_MAJOR $(VER_MAJOR)" > $@.swp
$(ECHO) "#define VER_MINOR $(VER_MINOR)" >> $@.swp
Expand Down
9 changes: 2 additions & 7 deletions src/bflib_datetm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
#include "bflib_basics.h"
#include "game_legacy.h"

#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include <SDL2/SDL.h>
#include "post_inc.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -307,9 +304,7 @@ TbResult LbDateTimeDecode(const time_t *datetime,struct TbDate *curr_date,struct

inline void LbDoMultitasking(void)
{
#if defined(_WIN32)
Sleep(LARGE_DELAY_TIME>>1); // This switches to other tasks
#endif
SDL_Delay(LARGE_DELAY_TIME>>1);
}

TbBool LbSleepFor(TbClockMSec delay)
Expand Down
Loading
Loading