diff --git a/CMakeLists.txt b/CMakeLists.txt index eb5fe579b..74e95fdae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ if(EMSCRIPTEN) set(CMAKE_EXECUTABLE_SUFFIX ".js") add_link_options("$<$:-gsource-map>") add_link_options(-Wno-pthreads-mem-growth -sALLOW_MEMORY_GROWTH=1) + add_compile_definitions(MC_NO_NETWORKING) endif() # Detect Windows diff --git a/GameMods.hpp b/GameMods.hpp index be951179e..a5e30f031 100644 --- a/GameMods.hpp +++ b/GameMods.hpp @@ -22,6 +22,7 @@ // Features (major changes) //#define FEATURE_PLANT_VEGGIES // Generates tall grass, and dead bushes around the world. //#define FEATURE_GFX_SHADERS // Loads and uses Shaders from the assets folder for rendering. +#define FEATURE_NETWORKING // Enables multi-player through RakNet // Enhancements (minor changes) //#define ENH_ENTITY_SHADING // Allows shading of entities -- Currently we are abandoning this. Want to add normal support @@ -53,4 +54,8 @@ // Toggle Demo Mode //#define DEMO +#if defined(MC_NO_NETWORKING) && defined(FEATURE_NETWORKING) +#undef FEATURE_NETWORKING +#endif + #endif diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index cca979877..28bbdbbe5 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -6,7 +6,8 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "client/app/Minecraft.hpp" +#include "Minecraft.hpp" +#include "GameMods.hpp" #include "client/gui/screens/PauseScreen.hpp" #include "client/gui/screens/StartMenuScreen.hpp" #include "client/gui/screens/RenameMPLevelScreen.hpp" @@ -1217,7 +1218,7 @@ void Minecraft::hostMultiplayer() if (!m_pRakNetInstance) return; -#ifndef __EMSCRIPTEN__ +#ifdef FEATURE_NETWORKING m_pRakNetInstance->host(m_pUser->field_0, C_DEFAULT_PORT, C_MAX_CONNECTIONS); m_pNetEventCallback = new ServerSideNetworkHandler(this, m_pRakNetInstance); #endif @@ -1228,7 +1229,7 @@ void Minecraft::joinMultiplayer(const PingedCompatibleServer& serverInfo) if (!m_pRakNetInstance) return; -#ifndef __EMSCRIPTEN__ +#ifdef FEATURE_NETWORKING if (field_18 && m_pNetEventCallback) { field_18 = false; @@ -1242,7 +1243,7 @@ void Minecraft::cancelLocateMultiplayer() if (!m_pRakNetInstance) return; -#ifndef __EMSCRIPTEN__ +#ifdef FEATURE_NETWORKING field_18 = false; m_pRakNetInstance->stopPingForHosts(); delete m_pNetEventCallback; @@ -1255,7 +1256,7 @@ void Minecraft::locateMultiplayer() if (!m_pRakNetInstance) return; -#ifndef __EMSCRIPTEN__ +#ifdef FEATURE_NETWORKING field_18 = true; m_pRakNetInstance->pingForHosts(C_DEFAULT_PORT); m_pNetEventCallback = new ClientSideNetworkHandler(this, m_pRakNetInstance); diff --git a/source/client/gui/components/AvailableGamesList.cpp b/source/client/gui/components/AvailableGamesList.cpp index 3dc2339c0..14b602eb4 100644 --- a/source/client/gui/components/AvailableGamesList.cpp +++ b/source/client/gui/components/AvailableGamesList.cpp @@ -29,8 +29,8 @@ void AvailableGamesList::renderBackground(float f) void AvailableGamesList::renderItem(int idx, int x, int y, int width, Tesselator& t) { - drawString(*m_pMinecraft->m_pFont, std::string(m_games[idx].m_name.C_String()), x, y + 2, 0xFFFFA0); - drawString(*m_pMinecraft->m_pFont, std::string(m_games[idx].m_address.ToString()), x, y + 16, 0xFFFFA0); + drawString(*m_pMinecraft->m_pFont, std::string(m_games[idx].m_name.C_String()), x, y + 2, 0xA0FFFF); + drawString(*m_pMinecraft->m_pFont, std::string(m_games[idx].m_address.ToString()), x, y + 16, 0xA0FFFF); } void AvailableGamesList::selectItem(int index, bool b) diff --git a/source/client/gui/screens/OptionsScreen.cpp b/source/client/gui/screens/OptionsScreen.cpp index 7313bf215..faec71133 100644 --- a/source/client/gui/screens/OptionsScreen.cpp +++ b/source/client/gui/screens/OptionsScreen.cpp @@ -349,7 +349,7 @@ void OptionsScreen::init() updateTexts(); -#ifdef __EMSCRIPTEN__ +#ifndef FEATURE_NETWORKING m_srvVisButton.m_bEnabled = false; #endif } diff --git a/source/client/gui/screens/PauseScreen.cpp b/source/client/gui/screens/PauseScreen.cpp index 7854597ac..2040d7a8f 100644 --- a/source/client/gui/screens/PauseScreen.cpp +++ b/source/client/gui/screens/PauseScreen.cpp @@ -93,7 +93,7 @@ void PauseScreen::init() for (int i = 0; i < int(m_buttons.size()); i++) m_buttonTabList.push_back(m_buttons[i]); -#ifdef __EMSCRIPTEN__ +#ifndef FEATURE_NETWORKING m_btnVisible.m_bEnabled = false; #endif } diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index 3ec8205ba..9f17a3e04 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -420,10 +420,10 @@ void StartMenuScreen::_updateLicense() { m_optionsButton.m_bEnabled = true; m_startButton.m_bEnabled = true; -#ifdef __EMSCRIPTEN__ - m_joinButton.m_bEnabled = false; -#else +#ifdef FEATURE_NETWORKING m_joinButton.m_bEnabled = true; +#else + m_joinButton.m_bEnabled = false; #endif } else diff --git a/thirdparty/raknet/SocketLayer.cpp b/thirdparty/raknet/SocketLayer.cpp index fb15a5949..a771075bf 100644 --- a/thirdparty/raknet/SocketLayer.cpp +++ b/thirdparty/raknet/SocketLayer.cpp @@ -119,7 +119,7 @@ void PrepareAddrInfoHints(addrinfo *hints) void SocketLayer::SetSocketOptions( __UDPSOCKET__ listenSocket, bool blockingSocket, bool setBroadcast) { -#if (!defined(__DREAMCAST__) && !defined(_NO_NETWORKING_)) +#if (!defined(__DREAMCAST__) && !defined(MC_NO_NETWORKING)) #ifdef __native_client__ (void) listenSocket; #else @@ -189,7 +189,7 @@ void SocketLayer::SetSocketOptions( __UDPSOCKET__ listenSocket, bool blockingSoc RakNet::RakString SocketLayer::GetSubNetForSocketAndIp(__UDPSOCKET__ inSock, RakNet::RakString inIpString) { - #if (!defined(__DREAMCAST__) && !defined(_NO_NETWORKING_)) + #if (!defined(__DREAMCAST__) && !defined(MC_NO_NETWORKING)) RakNet::RakString netMaskString; RakNet::RakString ipString;