List of commits:
Subject Hash Author Date (UTC)
Disable networking and remove dead code aaa8bd8300f89099bace4ee1de374d05dff2c089 mse 2021-11-15 05:17:06
Update gamecontrollerdb 828ce88dd2107d69b6332b9768f7c556473b8a24 mse 2021-11-14 00:29:26
Bump version to 0.6.2 baa2215230b5deed37b69f4075bd3b3385dbb913 mse 2021-11-14 00:08:13
Fix controller menu selection 3a1567ae279289d72058d6aa23d0c4eb147db2a8 mse 2021-11-13 23:00:12
Chinese translations for confec-select and name-your-confec 6c5c9d0fadb17066af82d459d1d46868af0e9faa mse 2021-11-13 20:58:26
Parse newlines in CSL notifications fc21ba1563a1c36ff20711c84b0dc3f3d7588646 mse 2021-11-13 05:12:11
Scriptable special items: GIVESPECIAL <id> <name> 256a2581e75dc3762b098f8cae3259899f8c4a94 mse 2021-11-13 03:24:02
Improved particles, darker nights, work on GIVESPECIAL e8e352e03fdffb8a8e57f94f99028bc1c6c03376 mse 2021-11-12 08:51:36
Fix caption padding bug a49cd2397d2e1b98679828303116db858d146a93 mse 2021-11-08 23:35:07
Disable is_regular_file for Boost support ebee78afad8b29f0332a4cf719c7c4d70e8c9ff8 mse 2021-11-08 22:41:42
Bump version to 0.6.1 9bdeecf9d39b75d12e44cb65bbb97a2e8277fcd4 mse 2021-11-08 21:34:25
Improve caption printing and start work on GIVESPECIAL ec51488e4fd5552ae6d22db1b6eedfef7c2541b7 mse 2021-11-08 20:29:59
Load current screen's images for CSL support 43ef06272048c164fc754a547a57859bdfb909db mse 2021-11-06 03:23:56
Fix Mac builds and bump version to v0.6.0 efcc6a0b4858af2abd027c8379d41ee1fe073620 mse 2021-11-04 23:40:55
Remove structured initializer for older compiler support 772a6b05b40cd5f7412a7736fe574319fe67289a mse 2021-11-04 17:54:41
Make C++ standard version configurable b100287447ddf4aa503ebac88710b0b92e25aa7f mse 2021-11-04 15:56:47
Fix zoom for particles 5c80a4a30c13672f00df8f3d74297908c132f45d mse 2021-11-04 14:54:34
Use 2 different speed curves for smart zoom 56f9cd38408e4cd3ed08b75b00b131a0bc236b56 mse 2021-10-22 01:51:47
Improve smart zoom math 87da264dca8c443c24a6340002a8cd8169a1446b mse 2021-10-17 10:11:14
Add smart zoom cc57dc0952db6c59d06ef7a9b5c5526f7801945f mse 2021-10-16 09:13:49
Commit aaa8bd8300f89099bace4ee1de374d05dff2c089 - Disable networking and remove dead code
Author: mse
Author date (UTC): 2021-11-15 05:17
Committer name: mse
Committer date (UTC): 2021-11-15 05:17
Parent(s): 828ce88dd2107d69b6332b9768f7c556473b8a24
Signing key:
Tree: 5225b33682868a932e0c67449f53e7776432a240
File Lines added Lines deleted
Makefile 46 22
confec.cpp 57 236
File Makefile changed (mode: 100644) (index cbf1cb9..2698129)
... ... OPENSSL_TAR=$(OPENSSL_DIR).tar.gz
41 41
42 42 LINCC := gcc -march=x86-64 -include $(shell readlink -f include/force_link_glibc_2.25.h) LINCC := gcc -march=x86-64 -include $(shell readlink -f include/force_link_glibc_2.25.h)
43 43 LINCXX := $(CXX) -march=x86-64 -include $(shell readlink -f include/force_link_glibc_2.25.h) LINCXX := $(CXX) -march=x86-64 -include $(shell readlink -f include/force_link_glibc_2.25.h)
44 CXXDYNAMIC=$(LINCXX) $(CXXFLAGS) -O3 -D__LIGHT__ -o $(PROGRAM)-dynamic $(PROGRAM).cpp libs.o libboost_system.a -Wl,-rpath,. -L. -l:libSDL2.so -lssl -lcrypto -pthread
44 #CXXDYNAMIC=$(LINCXX) $(CXXFLAGS) -O3 -D__LIGHT__ -D__BEAST__ -o $(PROGRAM)-dynamic $(PROGRAM).cpp libs.o libboost_system.a -Wl,-rpath,. -L. -l:libSDL2.so -lssl -lcrypto -pthread
45 CXXDYNAMIC=$(LINCXX) $(CXXFLAGS) -O3 -D__LIGHT__ -o $(PROGRAM)-dynamic $(PROGRAM).cpp libs.o -Wl,-rpath,. -L. -l:libSDL2.so -pthread
45 46 MACCXX=clang++ -march=x86-64 MACCXX=clang++ -march=x86-64
46 47 WINCXX=i686-w64-mingw32-g++-posix -march=pentium4 -static-libgcc -static-libstdc++ WINCXX=i686-w64-mingw32-g++-posix -march=pentium4 -static-libgcc -static-libstdc++
47 CXXFLAGS=-Iinclude -I$(OPENSSL_DIR)/include -I$(BOOST_DIR) -I$(POCO_DIR)/Foundation/include -I$(POCO_DIR)/Net/include -I$(POCO_DIR)/NetSSL_OpenSSL/include -I$(POCO_DIR)/Crypto/include -std=$(CXXSTD) -Wall -Wextra -Wfatal-errors
48 #CXXFLAGS=-Iinclude -I$(OPENSSL_DIR)/include -I$(BOOST_DIR) -I$(POCO_DIR)/Foundation/include -I$(POCO_DIR)/Net/include -I$(POCO_DIR)/NetSSL_OpenSSL/include -I$(POCO_DIR)/Crypto/include -std=$(CXXSTD) -Wall -Wextra -Wfatal-errors
49 CXXFLAGS=-Iinclude -I$(BOOST_DIR) -std=$(CXXSTD) -Wall -Wextra -Wfatal-errors
48 50 WIN_CMAKE_FLAGS=-DCMAKE_C_COMPILER=i686-w64-mingw32-gcc-win32 -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++-win32 -DCMAKE_C_COMPILER_WORKS=1 -DCMAKE_CXX_COMPILER_WORKS=1 WIN_CMAKE_FLAGS=-DCMAKE_C_COMPILER=i686-w64-mingw32-gcc-win32 -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++-win32 -DCMAKE_C_COMPILER_WORKS=1 -DCMAKE_CXX_COMPILER_WORKS=1
49 51 MAC_OPENSSL_SSL=libssl-mac.a MAC_OPENSSL_SSL=libssl-mac.a
50 52 MAC_OPENSSL_CRYPTO=libcrypto-mac.a MAC_OPENSSL_CRYPTO=libcrypto-mac.a
 
... ... drmfree-gnu: $(PROGRAM_DRMFREE)
63 65 steam-gnu: $(PROGRAM)-static steam-gnu: $(PROGRAM)-static
64 66
65 67 $(PROGRAM)-static: libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp $(INCLUDES) $(PROGRAM)-static: libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp $(INCLUDES)
66 # Building Steam version for GNU/Linux.
67 $(LINCXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -O3 -D__LIGHT__ -D__STEAM__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a \
68 # Building Steam version with Boost::Beast for GNU/Linux.
69 $(LINCXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -O3 -D__LIGHT__ -D__BEAST__ -D__STEAM__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a \
68 70 -Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread -lsteam_api -Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread -lsteam_api
69 71
70 $(PROGRAM_DRMFREE): libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp $(INCLUDES)
72 #$(PROGRAM_DRMFREE): libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp $(INCLUDES)
73 # Building DRM-free version with Boost::Beast for GNU/Linux.
74 #$(LINCXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -O3 -D__LIGHT__ -D__BEAST__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a \
75 #-Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread
76
77 $(PROGRAM_DRMFREE): libs.o libSDL2.a $(PROGRAM).cpp $(INCLUDES)
71 78 # Building DRM-free version for GNU/Linux. # Building DRM-free version for GNU/Linux.
72 $(LINCXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -O3 -D__LIGHT__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a \
73 -Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread
79 $(LINCXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -O3 -D__LIGHT__ -o $@ $(PROGRAM).cpp libs.o libSDL2.a -Wl,-rpath,. -L. -ldl -pthread
74 80
75 $(PROGRAM)-dynamic: libs.o libboost_system.a $(PROGRAM).cpp $(INCLUDES)
81 #$(PROGRAM)-dynamic: libs.o libboost_system.a $(PROGRAM).cpp $(INCLUDES)
82 $(PROGRAM)-dynamic: libs.o $(PROGRAM).cpp $(INCLUDES)
76 83 $(CXXDYNAMIC) $(CXXDYNAMIC)
77 84
78 85 # VR support, lol. Not currently implemented. # VR support, lol. Not currently implemented.
79 86 ccvr: libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp $(INCLUDES) ccvr: libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp $(INCLUDES)
80 $(LINCXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -O3 -D__LIGHT__ -D__STEAM__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a \
87 $(LINCXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -O3 -D__LIGHT__ -D__BEAST__ -D__STEAM__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a \
81 88 -Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread -lopenxr_loader -lsteam_api -Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread -lopenxr_loader -lsteam_api
82 89
90 # debug build settings may be outdated and broken
83 91 debug: clean libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp debug: clean libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp
84 92 $(LINCXX) -Iinclude -I$(BOOST_DIR) -std=$(CXXSTD) -Wall -Wextra -Wfatal-errors -g -D__STEAM__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a -Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread -lsteam_api $(POCO_LINKS) $(LINCXX) -Iinclude -I$(BOOST_DIR) -std=$(CXXSTD) -Wall -Wextra -Wfatal-errors -g -D__STEAM__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a -Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread -lsteam_api $(POCO_LINKS)
85 93
 
... ... drmfree: $(PROGRAM_DRMFREE) $(PROGRAM_DRMFREE).exe
90 98
91 99 demo: $(PROGRAM)-demo-static $(PROGRAM)-demo.exe demo: $(PROGRAM)-demo-static $(PROGRAM)-demo.exe
92 100
101 # demo build settings may be outdated and broken
93 102 $(PROGRAM)-demo-static: libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp $(INCLUDES) $(PROGRAM)-demo-static: libs.o libboost_system.a libSDL2.a $(PROGRAM).cpp $(INCLUDES)
94 103 $(LINCXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -O3 -D__LIGHT__ -D__STEAM__ -D__DEMO__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a \ $(LINCXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -O3 -D__LIGHT__ -D__STEAM__ -D__DEMO__ -o $@ $(PROGRAM).cpp libs.o libboost_system.a libSDL2.a \
95 104 -Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread -lsteam_api -Wl,-rpath,. -L. -ldl -lssl -lcrypto -pthread -lsteam_api
 
... ... $(PROGRAM)-demo.exe: libs-win.o libboost_system-win.a $(WIN_OPENSSL_SSL) $(WIN_O
102 111 ccserver: ccserver.cpp $(INCLUDES) ccserver: ccserver.cpp $(INCLUDES)
103 112 $(LINCXX) $(CXXFLAGS) -O3 -o $@ ccserver.cpp -Wl,-rpath,. -L. -pthread -l:$(POCO_FOUNDATION) -l:$(POCO_NET) $(LINCXX) $(CXXFLAGS) -O3 -o $@ ccserver.cpp -Wl,-rpath,. -L. -pthread -l:$(POCO_FOUNDATION) -l:$(POCO_NET)
104 113
105 libs.o: libs.cpp micropather.cpp include/tm_json.h $(BOOST_DIR)
114 # Uncomment the line with the $(BOOST_DIR) dependency when building with Boost::Beast.
115 #libs.o: libs.cpp micropather.cpp include/tm_json.h $(BOOST_DIR)
116 libs.o: libs.cpp micropather.cpp include/tm_json.h
106 117 $(LINCXX) $(CXXFLAGS) -O3 -o $@ libs.cpp -c $(LINCXX) $(CXXFLAGS) -O3 -o $@ libs.cpp -c
107 118
108 119 # Build SDL2 for Linux as compatibly as possible. # Build SDL2 for Linux as compatibly as possible.
 
... ... libSDL2.a: $(SDL2_DIR)
120 131
121 132 # Mac builds currently link boost::filesystem regardless of C++ standard version. The assumption on Mac is c++1z # Mac builds currently link boost::filesystem regardless of C++ standard version. The assumption on Mac is c++1z
122 133 $(PROGRAM)-mac: libs-mac.o SDL2.framework libboost_filesystem.a $(MAC_OPENSSL_SSL) $(MAC_OPENSSL_CRYPTO) $(PROGRAM).cpp $(INCLUDES) $(PROGRAM)-mac: libs-mac.o SDL2.framework libboost_filesystem.a $(MAC_OPENSSL_SSL) $(MAC_OPENSSL_CRYPTO) $(PROGRAM).cpp $(INCLUDES)
123 # Building Steam version for Mac.
124 $(MACCXX) $(CXXFLAGS) -O3 -D__LIGHT__ -D__STEAM__ -o $@ $(PROGRAM).cpp libs-mac.o $(MAC_OPENSSL_SSL) $(MAC_OPENSSL_CRYPTO) \
134 # Building Steam version with Boost::Beast for Mac.
135 $(MACCXX) $(CXXFLAGS) -O3 -D__LIGHT__ -D__BEAST__ -D__STEAM__ -o $@ $(PROGRAM).cpp libs-mac.o $(MAC_OPENSSL_SSL) $(MAC_OPENSSL_CRYPTO) \
125 136 -F. -L. -Wl,-rpath,"." -framework SDL2 -ldl -pthread -lboost_filesystem -lsteam_api -F. -L. -Wl,-rpath,"." -framework SDL2 -ldl -pthread -lboost_filesystem -lsteam_api
126 137
127 $(PROGRAM_DRMFREE)-mac: libs-mac.o SDL2.framework libboost_filesystem.a $(MAC_OPENSSL_SSL) $(MAC_OPENSSL_CRYPTO) $(PROGRAM).cpp $(INCLUDES)
138 #$(PROGRAM_DRMFREE)-mac: libs-mac.o SDL2.framework libboost_filesystem.a $(MAC_OPENSSL_SSL) $(MAC_OPENSSL_CRYPTO) $(PROGRAM).cpp $(INCLUDES)
139 # Building DRM-free version with Boost::Beast for Mac.
140 #$(MACCXX) $(CXXFLAGS) -O3 -D__LIGHT__ -D__BEAST__ -o $@ $(PROGRAM).cpp libs-mac.o $(MAC_OPENSSL_SSL) $(MAC_OPENSSL_CRYPTO) \
141 #-F. -L. -Wl,-rpath,"." -framework SDL2 -ldl -pthread -lboost_filesystem
142
143 $(PROGRAM_DRMFREE)-mac: libs-mac.o SDL2.framework libboost_filesystem.a $(PROGRAM).cpp $(INCLUDES)
128 144 # Building DRM-free version for Mac. # Building DRM-free version for Mac.
129 $(MACCXX) $(CXXFLAGS) -O3 -D__LIGHT__ -o $@ $(PROGRAM).cpp libs-mac.o $(MAC_OPENSSL_SSL) $(MAC_OPENSSL_CRYPTO) \
130 -F. -L. -Wl,-rpath,"." -framework SDL2 -ldl -pthread -lboost_filesystem
145 $(MACCXX) $(CXXFLAGS) -O3 -D__LIGHT__ -o $@ $(PROGRAM).cpp libs-mac.o -F. -L. -Wl,-rpath,"." -framework SDL2 -ldl -pthread -lboost_filesystem
131 146
132 147 libs-mac.o: libs.cpp micropather.cpp include/tm_json.h $(BOOST_DIR) libs-mac.o: libs.cpp micropather.cpp include/tm_json.h $(BOOST_DIR)
133 148 $(MACCXX) $(CXXFLAGS) -O3 -o $@ libs.cpp -c $(MACCXX) $(CXXFLAGS) -O3 -o $@ libs.cpp -c
134 149
135 150 $(PROGRAM).exe: libs-win.o libboost_system-win.a $(WIN_OPENSSL_SSL) $(WIN_OPENSSL_CRYPTO) $(PROGRAM).cpp $(INCLUDES) $(PROGRAM).exe: libs-win.o libboost_system-win.a $(WIN_OPENSSL_SSL) $(WIN_OPENSSL_CRYPTO) $(PROGRAM).cpp $(INCLUDES)
136 $(WINCXX) $(CXXFLAGS) -I$(OPENSSL_DIR)/include -O3 -D__LIGHT__ -D__STEAM__ -o $@ $(PROGRAM).cpp libs-win.o libboost_system-win.a \
151 # Building Steam version with Boost::Beast for Windows.
152 $(WINCXX) $(CXXFLAGS) -I$(OPENSSL_DIR)/include -O3 -D__LIGHT__ -D__BEAST__ -D__STEAM__ -o $@ $(PROGRAM).cpp libs-win.o libboost_system-win.a \
137 153 -L. -l:$(WIN_OPENSSL_SSL) -l:$(WIN_OPENSSL_CRYPTO) -lwsock32 -lws2_32 -lmingw32 -l:SDL2.dll -l:libSDL2main.a -l:steam_api.dll \ -L. -l:$(WIN_OPENSSL_SSL) -l:$(WIN_OPENSSL_CRYPTO) -lwsock32 -lws2_32 -lmingw32 -l:SDL2.dll -l:libSDL2main.a -l:steam_api.dll \
138 154 -static -lpthread -static -lpthread
139 155
140 $(PROGRAM_DRMFREE).exe: libs-win.o libboost_system-win.a $(WIN_OPENSSL_SSL) $(WIN_OPENSSL_CRYPTO) $(PROGRAM).cpp $(INCLUDES)
156 #$(PROGRAM_DRMFREE).exe: libs-win.o libboost_system-win.a $(WIN_OPENSSL_SSL) $(WIN_OPENSSL_CRYPTO) $(PROGRAM).cpp $(INCLUDES)
157 # Building DRM-free version with Boost::Beast for Windows.
158 #$(WINCXX) $(CXXFLAGS) -I$(OPENSSL_DIR)/include -O3 -D__LIGHT__ -D__BEAST__ -o $@ $(PROGRAM).cpp libs-win.o libboost_system-win.a \
159 #-L. -l:$(WIN_OPENSSL_SSL) -l:$(WIN_OPENSSL_CRYPTO) -lwsock32 -lws2_32 -lmingw32 -l:SDL2.dll -l:libSDL2main.a \
160 #-static -lpthread
161
162 $(PROGRAM_DRMFREE).exe: libs-win.o $(PROGRAM).cpp $(INCLUDES)
141 163 # Building DRM-free version for Windows. # Building DRM-free version for Windows.
142 $(WINCXX) $(CXXFLAGS) -I$(OPENSSL_DIR)/include -O3 -D__LIGHT__ -o $@ $(PROGRAM).cpp libs-win.o libboost_system-win.a \
143 -L. -l:$(WIN_OPENSSL_SSL) -l:$(WIN_OPENSSL_CRYPTO) -lwsock32 -lws2_32 -lmingw32 -l:SDL2.dll -l:libSDL2main.a \
144 -static -lpthread
164 $(WINCXX) $(CXXFLAGS) -O3 -D__LIGHT__ -o $@ $(PROGRAM).cpp libs-win.o -L. -lmingw32 -l:SDL2.dll -l:libSDL2main.a -static -lpthread
165
166 # You get the picture.
167 #libs-win.o: include/SDL2 libSDL2main.a SDL2.dll libs.cpp micropather.cpp include/tm_json.h $(BOOST_DIR) $(OPENSSL_DIR)
168 #$(WINCXX) $(CXXFLAGS) -I$(OPENSSL_DIR)/include -O3 -o $@ libs.cpp -c
145 169
146 libs-win.o: include/SDL2 libSDL2main.a SDL2.dll libs.cpp micropather.cpp include/tm_json.h $(BOOST_DIR) $(OPENSSL_DIR)
147 $(WINCXX) $(CXXFLAGS) -I$(OPENSSL_DIR)/include -O3 -o $@ libs.cpp -c
170 libs-win.o: include/SDL2 libSDL2main.a SDL2.dll libs.cpp micropather.cpp include/tm_json.h
171 $(WINCXX) $(CXXFLAGS) -O3 -o $@ libs.cpp -c
148 172
149 173 include/SDL2: $(SDL2_WIN_TAR) include/SDL2: $(SDL2_WIN_TAR)
150 174 $(RM) -r $@ $(RM) -r $@
File confec.cpp changed (mode: 100644) (index c615b94..78729cf)
... ... FILE *FileOpen( const char* filename, const char* modes );
26 26 #ifdef __STEAM__ #ifdef __STEAM__
27 27 #include <steam/steam_api.h> #include <steam/steam_api.h>
28 28 #endif #endif
29 /*
30 #include <Poco/Exception.h>
31 #include <Poco/Timespan.h>
32 #include <Poco/Net/HTTPRequest.h>
33 #include <Poco/Net/HTTPResponse.h>
34 #include <Poco/Net/HTTPClientSession.h>
35 #include <Poco/Net/HTTPSClientSession.h>
36 #include <Poco/Net/WebSocket.h>
37 */
38 // Asio and Beast stuff takes a long time to compile.
39 #define BOOST_ASIO_SEPARATE_COMPILATION
40 #define BOOST_BEAST_SEPARATE_COMPILATION
41 #include <boost/beast/core.hpp>
42 #include <boost/beast/ssl.hpp>
43 #include <boost/beast/websocket.hpp>
44 #include <boost/beast/websocket/ssl.hpp>
45 #include <boost/asio/connect.hpp>
46 #include <boost/asio/ip/tcp.hpp>
47 #include <boost/asio/ssl/stream.hpp>
48 #include <boost/asio/ssl/rfc2818_verification.hpp>
49 #include <mutex>
50 #include <thread>
51 #include <regex>
29 #ifdef __BEAST__
30 // Asio and Beast stuff takes a long time to compile.
31 #define BOOST_ASIO_SEPARATE_COMPILATION
32 #define BOOST_BEAST_SEPARATE_COMPILATION
33 #include <boost/beast/core.hpp>
34 #include <boost/beast/ssl.hpp>
35 #include <boost/beast/websocket.hpp>
36 #include <boost/beast/websocket/ssl.hpp>
37 #include <boost/asio/connect.hpp>
38 #include <boost/asio/ip/tcp.hpp>
39 #include <boost/asio/ssl/stream.hpp>
40 #include <boost/asio/ssl/rfc2818_verification.hpp>
41 #include <mutex>
42 #include <thread>
43 #include <regex>
44 #endif
52 45 #endif #endif
53 46
54 47 // OpenGL wrapper. // OpenGL wrapper.
 
... ... struct PeerState {
688 681
689 682 std::map<unsigned long long,PeerState> ws_peer_states; std::map<unsigned long long,PeerState> ws_peer_states;
690 683
691 #ifdef __EMSCRIPTEN__
684 #if defined(__EMSCRIPTEN__)
692 685 EMSCRIPTEN_WEBSOCKET_T ws_socket = 0; EMSCRIPTEN_WEBSOCKET_T ws_socket = 0;
693 686 EM_BOOL wsOnClose( int eventType, const EmscriptenWebSocketCloseEvent *e, void *userData ); EM_BOOL wsOnClose( int eventType, const EmscriptenWebSocketCloseEvent *e, void *userData );
694 687 EM_BOOL wsOnError( int eventType, const EmscriptenWebSocketErrorEvent *e, void *userData ); EM_BOOL wsOnError( int eventType, const EmscriptenWebSocketErrorEvent *e, void *userData );
695 688 EM_BOOL wsOnMessage( int eventType, const EmscriptenWebSocketMessageEvent *e, void *userData ); EM_BOOL wsOnMessage( int eventType, const EmscriptenWebSocketMessageEvent *e, void *userData );
696 #else
697 /*
698 // Client session may be HTTP or the HTTPS derived class.
699 Poco::Net::HTTPClientSession *ws_client_session = nullptr;
700 Poco::Net::WebSocket *ws_socket = nullptr;
701 bool ws_socket_active = false;
702 const int ws_buffer_size = 65536;
703 char ws_buffer[ws_buffer_size];
704 void wsHandleException( Poco::Exception &e );
705 */
689 #elif defined(__BEAST__)
706 690 namespace ws_net = boost::asio; namespace ws_net = boost::asio;
707 691 namespace ws_websocket = boost::beast::websocket; namespace ws_websocket = boost::beast::websocket;
708 692 // The io_context is required for all network I/O // The io_context is required for all network I/O
 
... ... FILE *FileOpen( const char* filename, const char* modes ){
1511 1495 return fopen( filename, modes ); return fopen( filename, modes );
1512 1496 } }
1513 1497
1514 #ifdef __EMSCRIPTEN__
1498 #if defined(__EMSCRIPTEN__)
1515 1499
1516 1500 void wsConnect( const std::string &uri, void (*f)(std::string) ){ void wsConnect( const std::string &uri, void (*f)(std::string) ){
1517 1501 if( !emscripten_websocket_is_supported() ){ if( !emscripten_websocket_is_supported() ){
 
... ... bool wsSendString( const std::string &str ){
1612 1596 return success; return success;
1613 1597 } }
1614 1598
1615 #else
1616
1617 /*
1618
1619 void wsConnect( const std::string &uri, void (*f)(std::string) ){
1620 // Parse the URI.
1621 auto uri_parts = wsParseAddress( uri );
1622 if( uri_parts.size() < 6 ){
1623 Notify( &tex_notification_net, "Network Error", "Invalid URI" );
1624 // Return to the main menu.
1625 settings_display = false;
1626 inputTarget = nullptr;
1627 convo.go( "init.json" );
1628 }
1629 // Label the URI components.
1630 std::string
1631 scheme = uri_parts[2],
1632 authority = uri_parts[4],
1633 path = uri_parts[5];
1634 bool wss = scheme == "wss";
1635 if( path.empty() ) path = "/";
1636 // Query string.
1637 if( uri_parts.size() > 6 ) path += uri_parts[6];
1638 // Host and port.
1639 std::string host = authority;
1640 Poco::UInt16 port = wss ? 443 : 80;
1641 size_t colon_at = authority.find( ':' );
1642 if( colon_at != std::string::npos ){
1643 host = authority.substr( 0, colon_at );
1644 port = std::stoi( authority.substr( colon_at + 1 ) );
1645 }
1646 // Create a client session without connecting, per Poco's design.
1647 ws_client_session = wss
1648 ? new Poco::Net::HTTPSClientSession()
1649 : new Poco::Net::HTTPClientSession();
1650 ws_client_session->setHost( host );
1651 ws_client_session->setPort( port );
1652 // HTTP proxy settings. TODO: Use wsParseAddress for this too.
1653 Poco::Net::HTTPClientSession::ProxyConfig pc;
1654 std::string p = settings.sections.get( "Misc" ).get( "http_proxy" );
1655 size_t first = p.length() < 3 ? std::string::npos : p.find( "://" );
1656 size_t last = p.empty() ? std::string::npos : p.find_last_of( ':' );
1657 std::string
1658 p0 = first == std::string::npos ? "" : p.substr( 0, first ),
1659 p1 = last == std::string::npos ? "" : p.substr( 0, last ),
1660 p2 = last == std::string::npos ? "0" : p.substr( last + 1 );
1661 pc.host = first == std::string::npos ? "" : p1.substr( first + 3 );
1662 pc.port = std::stoi( p2 );
1663 // TODO: Username and password detection.
1664 pc.username = "";
1665 pc.password = "";
1666 pc.authMethod = pc.username.empty()
1667 ? ws_client_session->ProxyAuthentication::PROXY_AUTH_NONE
1668 : ws_client_session->ProxyAuthentication::PROXY_AUTH_HTTP_BASIC;
1669 // Check the settings.
1670 if( p0 == "http" && host != "localhost" && host != "127.0.0.1" ){
1671 ws_client_session->setProxyConfig( pc );
1672 }
1673 // Connect to the server.
1674 try{
1675 // Prepare a generic request to initialize the connection.
1676 Poco::Net::HTTPRequest
1677 request( Poco::Net::HTTPRequest::HTTP_GET, path, "HTTP/1.1" );
1678 // Prepare a hole for the response.
1679 Poco::Net::HTTPResponse response;
1680 // Connect to the WebSocket server.
1681 ws_socket = new Poco::Net::WebSocket(
1682 *ws_client_session,
1683 request,
1684 response
1685 );
1686 ws_socket->setMaxPayloadSize( ws_buffer_size );
1687 // 0.1 seconds.
1688 ws_socket->setReceiveTimeout( Poco::Timespan( 0, 100 * 1000 ) );
1689 }catch( Poco::Exception &e ){
1690 wsHandleException( e );
1691 return;
1692 }
1693 ws_socket_active = true;
1694 // TODO: Notify( &tex_notification_net, "Connected to", uri );
1695 ws_callback = f;
1696 // Spawn the WebSocket thread if it does not already exist.
1697 if( ws_thread.get_id() != std::thread::id() ) return;
1698 ws_thread = std::thread( [](){
1699 while( ws_socket ){
1700 int flags = 0, bytes_received = 0;
1701 // Receive bytes from the server.
1702 try{
1703 bytes_received = ws_socket->receiveFrame(
1704 (void*)ws_buffer,
1705 ws_buffer_size,
1706 flags
1707 );
1708 }catch( Poco::Exception &e ){
1709 // Continue on.
1710 }
1711 std::string to_send = "";
1712 // Critical section.
1713 ws_mutex.lock();
1714 if( !ws_socket_active ){
1715 // Orderly shutdown.
1716 ws_socket->shutdown();
1717 // Clean up the object.
1718 delete ws_socket;
1719 ws_socket = nullptr;
1720 // Clean up the client session.
1721 delete ws_client_session;
1722 // Return control to other threads.
1723 ws_mutex.unlock();
1724 // Exit the thread.
1725 return;
1726 }
1727 if( bytes_received > 0 )
1728 ws_callback( std::string( ws_buffer, bytes_received ) );
1729 if( ws_out.size() > 0 ){
1730 to_send = ws_out;
1731 ws_out = "";
1732 }
1733 ws_mutex.unlock();
1734 if( to_send.size() > 0 ){
1735 try{
1736 // Defaults to text mode.
1737 // In case of binary:
1738 //ws_socket.SendFlags::FRAME_BINARY
1739 int bytes_sent = ws_socket
1740 ->sendFrame( to_send.data(), to_send.size() );
1741 if( bytes_sent < 0 ){
1742 // TODO: Condition reached, treat as error.
1743 }
1744 }catch( Poco::Exception &e ){
1745 wsHandleException( e );
1746 return;
1747 }
1748 }
1749 }
1750 } );
1751 ws_thread.detach();
1752 }
1753
1754 std::smatch wsParseAddress( const std::string &uri ){
1755 // https://stackoverflow.com/questions/5620235/cpp-regular-expression-to-validate-url/31613265#31613265
1756 // https://tools.ietf.org/html/rfc3986#page-50
1757 std::regex uri_regex(
1758 R"(^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)",
1759 std::regex::extended
1760 );
1761 std::smatch matches;
1762 std::regex_match( uri, matches, uri_regex );
1763 return matches;
1764 }
1765
1766 // Poco WebSocket exception handler.
1767 void wsHandleException( Poco::Exception &e ){
1768 Notify(
1769 &tex_notification_net,
1770 "Network Error",
1771 e.displayText()
1772 );
1773 // Clean up the object.
1774 delete ws_socket;
1775 ws_socket = nullptr;
1776 // Clean up the client session.
1777 delete ws_client_session;
1778 // Return to the main menu.
1779 settings_display = false;
1780 inputTarget = nullptr;
1781 convo.go( "init.json" );
1782 }
1783
1784 // Disconnect from the server.
1785 void wsDisconnect(){
1786 // Critical section.
1787 ws_mutex.lock();
1788 ws_socket_active = false;
1789 ws_mutex.unlock();
1790 }
1791
1792 // Send a string to the server.
1793 bool wsSendString( const std::string &str ){
1794 bool success = false;
1795 // Critical section.
1796 ws_mutex.lock();
1797 if( ws_socket ){
1798 ws_out = str;
1799 success = true;
1800 }
1801 ws_mutex.unlock();
1802 return success;
1803 }
1804
1805 */
1599 #elif defined(__BEAST__)
1806 1600
1807 1601 std::smatch wsParseAddress( const std::string &uri ){ std::smatch wsParseAddress( const std::string &uri ){
1808 1602 // https://stackoverflow.com/questions/5620235#31613265 // https://stackoverflow.com/questions/5620235#31613265
 
... ... bool wsSendString( const std::string &str ){
2091 1885 return success; return success;
2092 1886 } }
2093 1887
1888 #else
1889
1890 // These "null device" functions always act like a connection is broken.
1891
1892 void wsConnect( const std::string &uri, void (*f)(std::string) ){
1893 (void)uri;
1894 (void)f;
1895 Notify(
1896 &tex_notification_net,
1897 "Network Error",
1898 "Network support not compiled"
1899 );
1900 // Return to the main menu.
1901 settings_display = false;
1902 inputTarget = nullptr;
1903 convo.go( "init.json" );
1904 }
1905
1906 void wsDisconnect(){
1907 multiplayer = 0;
1908 }
1909
1910 bool wsSendString( const std::string &str ){
1911 (void)str;
1912 return false;
1913 }
1914
2094 1915 #endif #endif
2095 1916
2096 1917 // Uploads world data to convo and resets necessary variables. // Uploads world data to convo and resets necessary variables.
 
... ... void DrawPopups( double d ){
5488 5309 float popup_y = popup_margin * popup_scale; float popup_y = popup_margin * popup_scale;
5489 5310
5490 5311 // Critical section. // Critical section.
5491 #ifndef __EMSCRIPTEN__
5312 #ifdef __BEAST__
5492 5313 ws_mutex.lock(); ws_mutex.lock();
5493 5314 #endif #endif
5494 5315
 
... ... void DrawPopups( double d ){
5539 5360 popups.end() popups.end()
5540 5361 ); );
5541 5362
5542 #ifndef __EMSCRIPTEN__
5363 #ifdef __BEAST__
5543 5364 ws_mutex.unlock(); ws_mutex.unlock();
5544 5365 #endif #endif
5545 5366 } }
 
... ... void GameLoop( double d ){
5955 5776 && !fgl::textInputEnabled ){ && !fgl::textInputEnabled ){
5956 5777 // Trigger command input. // Trigger command input.
5957 5778 // Critical section. // Critical section.
5958 #ifndef __EMSCRIPTEN__
5779 #ifdef __BEAST__
5959 5780 ws_mutex.lock(); ws_mutex.lock();
5960 5781 #endif #endif
5961 5782 // Set the string to display and the destination address. // Set the string to display and the destination address.
 
... ... void GameLoop( double d ){
5963 5784 TextInputPrompt( &ws_chat_message, "Enter message" ); TextInputPrompt( &ws_chat_message, "Enter message" );
5964 5785 // Clear the string to avoid sending prematurely. // Clear the string to avoid sending prematurely.
5965 5786 ws_chat_message = ""; ws_chat_message = "";
5966 #ifndef __EMSCRIPTEN__
5787 #ifdef __BEAST__
5967 5788 ws_mutex.unlock(); ws_mutex.unlock();
5968 5789 #endif #endif
5969 5790 }else if( sleepButtonDown && !sleep_mode }else if( sleepButtonDown && !sleep_mode
 
... ... void GameLoop( double d ){
5971 5792 // Trigger sleep mode or text input, depending on // Trigger sleep mode or text input, depending on
5972 5793 // context. // context.
5973 5794 // Critical section. // Critical section.
5974 #ifndef __EMSCRIPTEN__
5795 #ifdef __BEAST__
5975 5796 ws_mutex.lock(); ws_mutex.lock();
5976 5797 #endif #endif
5977 5798 if( multiplayer ){ if( multiplayer ){
 
... ... void GameLoop( double d ){
5982 5803 player.task = fworld::TASK_SLEEP; player.task = fworld::TASK_SLEEP;
5983 5804 player.stun = sleep_duration; player.stun = sleep_duration;
5984 5805 } }
5985 #ifndef __EMSCRIPTEN__
5806 #ifdef __BEAST__
5986 5807 ws_mutex.unlock(); ws_mutex.unlock();
5987 5808 #endif #endif
5988 5809 } }
 
... ... void GameLoop( double d ){
6057 5878 } }
6058 5879
6059 5880 // Critical section. // Critical section.
6060 #ifndef __EMSCRIPTEN__
5881 #ifdef __BEAST__
6061 5882 ws_mutex.lock(); ws_mutex.lock();
6062 5883 #endif #endif
6063 5884 // Interpolate and animate ws_entities. // Interpolate and animate ws_entities.
 
... ... void GameLoop( double d ){
6101 5922 else else
6102 5923 world.drawEntities(); world.drawEntities();
6103 5924 DrawParticles(); DrawParticles();
6104 #ifndef __EMSCRIPTEN__
5925 #ifdef __BEAST__
6105 5926 ws_mutex.unlock(); ws_mutex.unlock();
6106 5927 #endif #endif
6107 5928
 
... ... void GameLoop( double d ){
6658 6479 // Draw the chat buffer. // Draw the chat buffer.
6659 6480 std::string chat_text = ""; std::string chat_text = "";
6660 6481 // Critical section. // Critical section.
6661 #ifndef __EMSCRIPTEN__
6482 #ifdef __BEAST__
6662 6483 ws_mutex.lock(); ws_mutex.lock();
6663 6484 #endif #endif
6664 6485 for( auto &m : chat_buffer ){ for( auto &m : chat_buffer ){
6665 6486 chat_text += m + "\n"; chat_text += m + "\n";
6666 6487 } }
6667 #ifndef __EMSCRIPTEN__
6488 #ifdef __BEAST__
6668 6489 ws_mutex.unlock(); ws_mutex.unlock();
6669 6490 #endif #endif
6670 6491 // Black shadow. // Black shadow.
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using git:
git clone git://git.rocketgit.com/user/mse/ConfectionerEngine

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main