Skip to content
Merged
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 CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if(EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".js")
add_link_options("$<$<CONFIG:DEBUG>:-gsource-map>")
add_link_options(-Wno-pthreads-mem-growth -sALLOW_MEMORY_GROWTH=1)
add_compile_definitions(MC_NO_NETWORKING)
endif()

# Detect Windows
Expand Down
5 changes: 5 additions & 0 deletions GameMods.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -53,4 +54,8 @@
// Toggle Demo Mode
//#define DEMO

#if defined(MC_NO_NETWORKING) && defined(FEATURE_NETWORKING)
#undef FEATURE_NETWORKING
#endif

#endif
11 changes: 6 additions & 5 deletions source/client/app/Minecraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/client/gui/components/AvailableGamesList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion source/client/gui/screens/OptionsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void OptionsScreen::init()

updateTexts();

#ifdef __EMSCRIPTEN__
#ifndef FEATURE_NETWORKING
m_srvVisButton.m_bEnabled = false;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion source/client/gui/screens/PauseScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions source/client/gui/screens/StartMenuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/raknet/SocketLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down