mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
9ab2fc21a6
|
Before Width: | Height: | Size: 952 KiB After Width: | Height: | Size: 952 KiB |
3
.github/workflows/nightly.yml
vendored
3
.github/workflows/nightly.yml
vendored
|
|
@ -5,6 +5,9 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
|
paths-ignore:
|
||||||
|
- '.gitignore'
|
||||||
|
- '*.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -430,3 +430,6 @@ build/*
|
||||||
!x64/**/iggy_w64.dll
|
!x64/**/iggy_w64.dll
|
||||||
!x64/**/mss64.dll
|
!x64/**/mss64.dll
|
||||||
!x64/**/redist64/
|
!x64/**/redist64/
|
||||||
|
|
||||||
|
# Local saves
|
||||||
|
Minecraft.Client/Saves/
|
||||||
|
|
|
||||||
|
|
@ -757,7 +757,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef _WINDOWS64
|
/*#ifdef _WINDOWS64
|
||||||
// On Windows64 all XUIDs are INVALID_XUID so the XUID check above never fires.
|
// On Windows64 all XUIDs are INVALID_XUID so the XUID check above never fires.
|
||||||
// packet->m_playerIndex is the server-assigned sequential index (set via LoginPacket),
|
// packet->m_playerIndex is the server-assigned sequential index (set via LoginPacket),
|
||||||
// NOT the controller slot — so we must scan all local player slots and match by
|
// NOT the controller slot — so we must scan all local player slots and match by
|
||||||
|
|
@ -771,7 +771,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif*/
|
||||||
|
|
||||||
double x = packet->x / 32.0;
|
double x = packet->x / 32.0;
|
||||||
double y = packet->y / 32.0;
|
double y = packet->y / 32.0;
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ void SoundEngine::playMusicTick() {};
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
char SoundEngine::m_szSoundPath[]={"Windows64\\Sound\\"};
|
char SoundEngine::m_szSoundPath[]={"Windows64Media\\Sound\\"};
|
||||||
char SoundEngine::m_szMusicPath[]={"music\\"};
|
char SoundEngine::m_szMusicPath[]={"music\\"};
|
||||||
char SoundEngine::m_szRedistName[]={"redist64"};
|
char SoundEngine::m_szRedistName[]={"redist64"};
|
||||||
#elif defined _DURANGO
|
#elif defined _DURANGO
|
||||||
|
|
|
||||||
|
|
@ -760,6 +760,43 @@ bool CMinecraftApp::LoadBeaconMenu(int iPad ,shared_ptr<Inventory> inventory, sh
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
// GAME SETTINGS
|
// GAME SETTINGS
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
static void Win64_GetSettingsPath(char *outPath, DWORD size)
|
||||||
|
{
|
||||||
|
GetModuleFileNameA(NULL, outPath, size);
|
||||||
|
char *lastSlash = strrchr(outPath, '\\');
|
||||||
|
if (lastSlash) *(lastSlash + 1) = '\0';
|
||||||
|
strncat_s(outPath, size, "settings.dat", _TRUNCATE);
|
||||||
|
}
|
||||||
|
static void Win64_SaveSettings(GAME_SETTINGS *gs)
|
||||||
|
{
|
||||||
|
if (!gs) return;
|
||||||
|
char filePath[MAX_PATH] = {};
|
||||||
|
Win64_GetSettingsPath(filePath, MAX_PATH);
|
||||||
|
FILE *f = NULL;
|
||||||
|
if (fopen_s(&f, filePath, "wb") == 0 && f)
|
||||||
|
{
|
||||||
|
fwrite(gs, sizeof(GAME_SETTINGS), 1, f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void Win64_LoadSettings(GAME_SETTINGS *gs)
|
||||||
|
{
|
||||||
|
if (!gs) return;
|
||||||
|
char filePath[MAX_PATH] = {};
|
||||||
|
Win64_GetSettingsPath(filePath, MAX_PATH);
|
||||||
|
FILE *f = NULL;
|
||||||
|
if (fopen_s(&f, filePath, "rb") == 0 && f)
|
||||||
|
{
|
||||||
|
GAME_SETTINGS temp = {};
|
||||||
|
if (fread(&temp, sizeof(GAME_SETTINGS), 1, f) == 1)
|
||||||
|
memcpy(gs, &temp, sizeof(GAME_SETTINGS));
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void CMinecraftApp::InitGameSettings()
|
void CMinecraftApp::InitGameSettings()
|
||||||
{
|
{
|
||||||
for(int i=0;i<XUSER_MAX_COUNT;i++)
|
for(int i=0;i<XUSER_MAX_COUNT;i++)
|
||||||
|
|
@ -780,6 +817,8 @@ void CMinecraftApp::InitGameSettings()
|
||||||
// clear this for now - it will come from reading the system values
|
// clear this for now - it will come from reading the system values
|
||||||
memset(pProfileSettings,0,sizeof(C_4JProfile::PROFILESETTINGS));
|
memset(pProfileSettings,0,sizeof(C_4JProfile::PROFILESETTINGS));
|
||||||
SetDefaultOptions(pProfileSettings,i);
|
SetDefaultOptions(pProfileSettings,i);
|
||||||
|
Win64_LoadSettings(GameSettingsA[i]);
|
||||||
|
ApplyGameSettingsChanged(i);
|
||||||
#elif defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__
|
#elif defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__
|
||||||
C4JStorage::PROFILESETTINGS *pProfileSettings=StorageManager.GetDashboardProfileSettings(i);
|
C4JStorage::PROFILESETTINGS *pProfileSettings=StorageManager.GetDashboardProfileSettings(i);
|
||||||
// 4J-PB - don't cause an options write to happen here
|
// 4J-PB - don't cause an options write to happen here
|
||||||
|
|
@ -1342,9 +1381,13 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal)
|
||||||
case eGameSetting_Gamma:
|
case eGameSetting_Gamma:
|
||||||
if(iPad==ProfileManager.GetPrimaryPad())
|
if(iPad==ProfileManager.GetPrimaryPad())
|
||||||
{
|
{
|
||||||
|
#if defined(_WIN64) || defined(_WINDOWS64)
|
||||||
|
pMinecraft->options->set(Options::Option::GAMMA, ((float)GameSettingsA[iPad]->ucGamma) / 100.0f);
|
||||||
|
#else
|
||||||
// ucGamma range is 0-100, UpdateGamma is 0 - 32768
|
// ucGamma range is 0-100, UpdateGamma is 0 - 32768
|
||||||
float fVal=((float)GameSettingsA[iPad]->ucGamma)*327.68f;
|
float fVal=((float)GameSettingsA[iPad]->ucGamma)*327.68f;
|
||||||
RenderManager.UpdateGamma((unsigned short)fVal);
|
RenderManager.UpdateGamma((unsigned short)fVal);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -2368,6 +2411,9 @@ void CMinecraftApp::CheckGameSettingsChanged(bool bOverride5MinuteTimer, int iPa
|
||||||
StorageManager.WriteToProfile(i,true, bOverride5MinuteTimer);
|
StorageManager.WriteToProfile(i,true, bOverride5MinuteTimer);
|
||||||
#else
|
#else
|
||||||
ProfileManager.WriteToProfile(i,true, bOverride5MinuteTimer);
|
ProfileManager.WriteToProfile(i,true, bOverride5MinuteTimer);
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
Win64_SaveSettings(GameSettingsA[i]);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
GameSettingsA[i]->bSettingsChanged=false;
|
GameSettingsA[i]->bSettingsChanged=false;
|
||||||
}
|
}
|
||||||
|
|
@ -2381,6 +2427,9 @@ void CMinecraftApp::CheckGameSettingsChanged(bool bOverride5MinuteTimer, int iPa
|
||||||
StorageManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
|
StorageManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
|
||||||
#else
|
#else
|
||||||
ProfileManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
|
ProfileManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
Win64_SaveSettings(GameSettingsA[iPad]);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
GameSettingsA[iPad]->bSettingsChanged=false;
|
GameSettingsA[iPad]->bSettingsChanged=false;
|
||||||
}
|
}
|
||||||
|
|
@ -3398,7 +3447,7 @@ void CMinecraftApp::HandleXuiActions(void)
|
||||||
bool gameStarted = false;
|
bool gameStarted = false;
|
||||||
for(int j = 0; j < pMinecraft->levels.length; j++)
|
for(int j = 0; j < pMinecraft->levels.length; j++)
|
||||||
{
|
{
|
||||||
if (pMinecraft->levels.data[i] != NULL)
|
if (pMinecraft->levels.data[i] != nullptr)
|
||||||
{
|
{
|
||||||
gameStarted = true;
|
gameStarted = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -167,6 +167,11 @@ bool CGameNetworkManager::_RunNetworkGame(LPVOID lpParameter)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Client needs QNET_STATE_GAME_PLAY so that IsInGameplay() returns true
|
||||||
|
s_pPlatformNetworkManager->SetGamePlayState();
|
||||||
|
}
|
||||||
|
|
||||||
if( g_NetworkManager.IsLeavingGame() ) return false;
|
if( g_NetworkManager.IsLeavingGame() ) return false;
|
||||||
|
|
||||||
|
|
@ -1479,7 +1484,10 @@ void CGameNetworkManager::CreateSocket( INetworkPlayer *pNetworkPlayer, bool loc
|
||||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||||
|
|
||||||
Socket *socket = NULL;
|
Socket *socket = NULL;
|
||||||
shared_ptr<MultiplayerLocalPlayer> mpPlayer = pMinecraft->localplayers[pNetworkPlayer->GetUserIndex()];
|
shared_ptr<MultiplayerLocalPlayer> mpPlayer = nullptr;
|
||||||
|
int userIdx = pNetworkPlayer->GetUserIndex();
|
||||||
|
if (userIdx >= 0 && userIdx < XUSER_MAX_COUNT)
|
||||||
|
mpPlayer = pMinecraft->localplayers[userIdx];
|
||||||
if( localPlayer && mpPlayer != NULL && mpPlayer->connection != NULL)
|
if( localPlayer && mpPlayer != NULL && mpPlayer->connection != NULL)
|
||||||
{
|
{
|
||||||
// If we already have a MultiplayerLocalPlayer here then we are doing a session type change
|
// If we already have a MultiplayerLocalPlayer here then we are doing a session type change
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ public:
|
||||||
virtual void HandleSignInChange() = 0;
|
virtual void HandleSignInChange() = 0;
|
||||||
|
|
||||||
virtual bool _RunNetworkGame() = 0;
|
virtual bool _RunNetworkGame() = 0;
|
||||||
|
virtual void SetGamePlayState() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom) = 0;
|
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom) = 0;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,12 @@
|
||||||
#include "..\..\..\Minecraft.World\Socket.h"
|
#include "..\..\..\Minecraft.World\Socket.h"
|
||||||
#include "..\..\..\Minecraft.World\StringHelpers.h"
|
#include "..\..\..\Minecraft.World\StringHelpers.h"
|
||||||
#include "PlatformNetworkManagerStub.h"
|
#include "PlatformNetworkManagerStub.h"
|
||||||
#include "..\..\Xbox\Network\NetworkPlayerXbox.h" // TODO - stub version of this?
|
#include "..\..\Xbox\Network\NetworkPlayerXbox.h"
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
#include "..\..\Windows64\Network\WinsockNetLayer.h"
|
||||||
|
#include "..\..\Minecraft.h"
|
||||||
|
#include "..\..\User.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
||||||
|
|
||||||
|
|
@ -114,10 +119,43 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPlatformNetworkManagerStub::NotifyPlayerLeaving(IQNetPlayer* pQNetPlayer)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Player 0x%p \"%ls\" leaving.\n", pQNetPlayer, pQNetPlayer->GetGamertag());
|
||||||
|
|
||||||
|
INetworkPlayer* networkPlayer = getNetworkPlayer(pQNetPlayer);
|
||||||
|
if (networkPlayer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Socket* socket = networkPlayer->GetSocket();
|
||||||
|
if (socket != NULL)
|
||||||
|
{
|
||||||
|
if (m_pIQNet->IsHost())
|
||||||
|
g_NetworkManager.CloseConnection(networkPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pIQNet->IsHost())
|
||||||
|
{
|
||||||
|
SystemFlagRemovePlayer(networkPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_NetworkManager.PlayerLeaving(networkPlayer);
|
||||||
|
|
||||||
|
for (int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
|
||||||
|
{
|
||||||
|
if (playerChangedCallback[idx] != NULL)
|
||||||
|
playerChangedCallback[idx](playerChangedCallbackParam[idx], networkPlayer, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeNetworkPlayer(pQNetPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize)
|
bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize)
|
||||||
{
|
{
|
||||||
m_pGameNetworkManager = pGameNetworkManager;
|
m_pGameNetworkManager = pGameNetworkManager;
|
||||||
m_flagIndexSize = flagIndexSize;
|
m_flagIndexSize = flagIndexSize;
|
||||||
|
m_pIQNet = new IQNet();
|
||||||
g_pPlatformNetworkManager = this;
|
g_pPlatformNetworkManager = this;
|
||||||
for( int i = 0; i < XUSER_MAX_COUNT; i++ )
|
for( int i = 0; i < XUSER_MAX_COUNT; i++ )
|
||||||
{
|
{
|
||||||
|
|
@ -174,6 +212,37 @@ bool CPlatformNetworkManagerStub::isSystemPrimaryPlayer(IQNetPlayer *pQNetPlayer
|
||||||
// We call this twice a frame, either side of the render call so is a good place to "tick" things
|
// We call this twice a frame, either side of the render call so is a good place to "tick" things
|
||||||
void CPlatformNetworkManagerStub::DoWork()
|
void CPlatformNetworkManagerStub::DoWork()
|
||||||
{
|
{
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
extern QNET_STATE _iQNetStubState;
|
||||||
|
if (_iQNetStubState == QNET_STATE_SESSION_STARTING && app.GetGameStarted())
|
||||||
|
{
|
||||||
|
_iQNetStubState = QNET_STATE_GAME_PLAY;
|
||||||
|
if (m_pIQNet->IsHost())
|
||||||
|
WinsockNetLayer::UpdateAdvertiseJoinable(true);
|
||||||
|
}
|
||||||
|
if (_iQNetStubState == QNET_STATE_IDLE)
|
||||||
|
TickSearch();
|
||||||
|
if (_iQNetStubState == QNET_STATE_GAME_PLAY && m_pIQNet->IsHost())
|
||||||
|
{
|
||||||
|
BYTE disconnectedSmallId;
|
||||||
|
while (WinsockNetLayer::PopDisconnectedSmallId(&disconnectedSmallId))
|
||||||
|
{
|
||||||
|
IQNetPlayer* qnetPlayer = m_pIQNet->GetPlayerBySmallId(disconnectedSmallId);
|
||||||
|
if (qnetPlayer != NULL && qnetPlayer->m_smallId == disconnectedSmallId)
|
||||||
|
{
|
||||||
|
NotifyPlayerLeaving(qnetPlayer);
|
||||||
|
qnetPlayer->m_smallId = 0;
|
||||||
|
qnetPlayer->m_isRemote = false;
|
||||||
|
qnetPlayer->m_isHostPlayer = false;
|
||||||
|
qnetPlayer->m_gamertag[0] = 0;
|
||||||
|
qnetPlayer->SetCustomDataValue(0);
|
||||||
|
WinsockNetLayer::PushFreeSmallId(disconnectedSmallId);
|
||||||
|
if (IQNet::s_playerCount > 1)
|
||||||
|
IQNet::s_playerCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int CPlatformNetworkManagerStub::GetPlayerCount()
|
int CPlatformNetworkManagerStub::GetPlayerCount()
|
||||||
|
|
@ -232,6 +301,10 @@ bool CPlatformNetworkManagerStub::LeaveGame(bool bMigrateHost)
|
||||||
|
|
||||||
m_bLeavingGame = true;
|
m_bLeavingGame = true;
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
WinsockNetLayer::StopAdvertising();
|
||||||
|
#endif
|
||||||
|
|
||||||
// If we are the host wait for the game server to end
|
// If we are the host wait for the game server to end
|
||||||
if(m_pIQNet->IsHost() && g_NetworkManager.ServerStoppedValid())
|
if(m_pIQNet->IsHost() && g_NetworkManager.ServerStoppedValid())
|
||||||
{
|
{
|
||||||
|
|
@ -239,6 +312,22 @@ bool CPlatformNetworkManagerStub::LeaveGame(bool bMigrateHost)
|
||||||
g_NetworkManager.ServerStoppedWait();
|
g_NetworkManager.ServerStoppedWait();
|
||||||
g_NetworkManager.ServerStoppedDestroy();
|
g_NetworkManager.ServerStoppedDestroy();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pIQNet->EndGame();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AUTO_VAR(it, currentNetworkPlayers.begin()); it != currentNetworkPlayers.end(); it++)
|
||||||
|
delete* it;
|
||||||
|
currentNetworkPlayers.clear();
|
||||||
|
m_machineQNetPrimaryPlayers.clear();
|
||||||
|
SystemFlagReset();
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
WinsockNetLayer::Shutdown();
|
||||||
|
WinsockNetLayer::Initialize();
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,7 +351,24 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame,
|
||||||
|
|
||||||
m_pIQNet->HostGame();
|
m_pIQNet->HostGame();
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
IQNet::m_player[0].m_smallId = 0;
|
||||||
|
IQNet::m_player[0].m_isRemote = false;
|
||||||
|
IQNet::m_player[0].m_isHostPlayer = true;
|
||||||
|
IQNet::s_playerCount = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
_HostGame( localUsersMask, publicSlots, privateSlots );
|
_HostGame( localUsersMask, publicSlots, privateSlots );
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
int port = WIN64_NET_DEFAULT_PORT;
|
||||||
|
if (!WinsockNetLayer::IsActive())
|
||||||
|
WinsockNetLayer::HostGame(port);
|
||||||
|
|
||||||
|
const wchar_t* hostName = IQNet::m_player[0].m_gamertag;
|
||||||
|
unsigned int settings = app.GetGameHostOption(eGameHostOption_All);
|
||||||
|
WinsockNetLayer::StartAdvertising(port, hostName, settings, 0, 0, MINECRAFT_NET_VERSION);
|
||||||
|
#endif
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,7 +383,52 @@ bool CPlatformNetworkManagerStub::_StartGame()
|
||||||
|
|
||||||
int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo* searchResult, int localUsersMask, int primaryUserIndex)
|
int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo* searchResult, int localUsersMask, int primaryUserIndex)
|
||||||
{
|
{
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
if (searchResult == NULL)
|
||||||
|
return CGameNetworkManager::JOINGAME_FAIL_GENERAL;
|
||||||
|
|
||||||
|
const char* hostIP = searchResult->data.hostIP;
|
||||||
|
int hostPort = searchResult->data.hostPort;
|
||||||
|
|
||||||
|
if (hostPort <= 0 || hostIP[0] == 0)
|
||||||
|
return CGameNetworkManager::JOINGAME_FAIL_GENERAL;
|
||||||
|
|
||||||
|
m_bLeavingGame = false;
|
||||||
|
IQNet::s_isHosting = false;
|
||||||
|
m_pIQNet->ClientJoinGame();
|
||||||
|
|
||||||
|
IQNet::m_player[0].m_smallId = 0;
|
||||||
|
IQNet::m_player[0].m_isRemote = true;
|
||||||
|
IQNet::m_player[0].m_isHostPlayer = true;
|
||||||
|
wcsncpy_s(IQNet::m_player[0].m_gamertag, 32, searchResult->data.hostName, _TRUNCATE);
|
||||||
|
|
||||||
|
WinsockNetLayer::StopDiscovery();
|
||||||
|
|
||||||
|
if (!WinsockNetLayer::JoinGame(hostIP, hostPort))
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Failed to connect to %s:%d\n", hostIP, hostPort);
|
||||||
|
return CGameNetworkManager::JOINGAME_FAIL_GENERAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE localSmallId = WinsockNetLayer::GetLocalSmallId();
|
||||||
|
|
||||||
|
IQNet::m_player[localSmallId].m_smallId = localSmallId;
|
||||||
|
IQNet::m_player[localSmallId].m_isRemote = false;
|
||||||
|
IQNet::m_player[localSmallId].m_isHostPlayer = false;
|
||||||
|
|
||||||
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
|
wcscpy_s(IQNet::m_player[localSmallId].m_gamertag, 32, pMinecraft->user->name.c_str());
|
||||||
|
IQNet::s_playerCount = localSmallId + 1;
|
||||||
|
|
||||||
|
NotifyPlayerJoined(&IQNet::m_player[0]);
|
||||||
|
NotifyPlayerJoined(&IQNet::m_player[localSmallId]);
|
||||||
|
|
||||||
|
m_pGameNetworkManager->StateChange_AnyToStarting();
|
||||||
|
|
||||||
return CGameNetworkManager::JOINGAME_SUCCESS;
|
return CGameNetworkManager::JOINGAME_SUCCESS;
|
||||||
|
#else
|
||||||
|
return CGameNetworkManager::JOINGAME_SUCCESS;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPlatformNetworkManagerStub::SetLocalGame(bool isLocal)
|
bool CPlatformNetworkManagerStub::SetLocalGame(bool isLocal)
|
||||||
|
|
@ -315,6 +466,22 @@ void CPlatformNetworkManagerStub::HandleSignInChange()
|
||||||
|
|
||||||
bool CPlatformNetworkManagerStub::_RunNetworkGame()
|
bool CPlatformNetworkManagerStub::_RunNetworkGame()
|
||||||
{
|
{
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
extern QNET_STATE _iQNetStubState;
|
||||||
|
_iQNetStubState = QNET_STATE_GAME_PLAY;
|
||||||
|
|
||||||
|
for (DWORD i = 0; i < IQNet::s_playerCount; i++)
|
||||||
|
{
|
||||||
|
if (IQNet::m_player[i].m_isRemote)
|
||||||
|
{
|
||||||
|
INetworkPlayer* pNetworkPlayer = getNetworkPlayer(&IQNet::m_player[i]);
|
||||||
|
if (pNetworkPlayer != NULL && pNetworkPlayer->GetSocket() != NULL)
|
||||||
|
{
|
||||||
|
Socket::addIncomingSocket(pNetworkPlayer->GetSocket());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -503,10 +670,60 @@ wstring CPlatformNetworkManagerStub::GatherRTTStats()
|
||||||
|
|
||||||
void CPlatformNetworkManagerStub::TickSearch()
|
void CPlatformNetworkManagerStub::TickSearch()
|
||||||
{
|
{
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
if (m_SessionsUpdatedCallback == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
static DWORD lastSearchTime = 0;
|
||||||
|
DWORD now = GetTickCount();
|
||||||
|
if (now - lastSearchTime < 2000)
|
||||||
|
return;
|
||||||
|
lastSearchTime = now;
|
||||||
|
|
||||||
|
SearchForGames();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlatformNetworkManagerStub::SearchForGames()
|
void CPlatformNetworkManagerStub::SearchForGames()
|
||||||
{
|
{
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
std::vector<Win64LANSession> lanSessions = WinsockNetLayer::GetDiscoveredSessions();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||||
|
delete friendsSessions[0][i];
|
||||||
|
friendsSessions[0].clear();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < lanSessions.size(); i++)
|
||||||
|
{
|
||||||
|
FriendSessionInfo* info = new FriendSessionInfo();
|
||||||
|
size_t nameLen = wcslen(lanSessions[i].hostName);
|
||||||
|
info->displayLabel = new wchar_t[nameLen + 1];
|
||||||
|
wcscpy_s(info->displayLabel, nameLen + 1, lanSessions[i].hostName);
|
||||||
|
info->displayLabelLength = (unsigned char)nameLen;
|
||||||
|
info->displayLabelViewableStartIndex = 0;
|
||||||
|
|
||||||
|
info->data.netVersion = lanSessions[i].netVersion;
|
||||||
|
info->data.m_uiGameHostSettings = lanSessions[i].gameHostSettings;
|
||||||
|
info->data.texturePackParentId = lanSessions[i].texturePackParentId;
|
||||||
|
info->data.subTexturePackId = lanSessions[i].subTexturePackId;
|
||||||
|
info->data.isReadyToJoin = lanSessions[i].isJoinable;
|
||||||
|
info->data.isJoinable = lanSessions[i].isJoinable;
|
||||||
|
strncpy_s(info->data.hostIP, sizeof(info->data.hostIP), lanSessions[i].hostIP, _TRUNCATE);
|
||||||
|
info->data.hostPort = lanSessions[i].hostPort;
|
||||||
|
wcsncpy_s(info->data.hostName, XUSER_NAME_SIZE, lanSessions[i].hostName, _TRUNCATE);
|
||||||
|
info->data.playerCount = lanSessions[i].playerCount;
|
||||||
|
info->data.maxPlayers = lanSessions[i].maxPlayers;
|
||||||
|
|
||||||
|
info->sessionId = (SessionID)((unsigned __int64)inet_addr(lanSessions[i].hostIP) | ((unsigned __int64)lanSessions[i].hostPort << 32));
|
||||||
|
|
||||||
|
friendsSessions[0].push_back(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_searchResultsCount[0] = (int)friendsSessions[0].size();
|
||||||
|
|
||||||
|
if (m_SessionsUpdatedCallback != NULL)
|
||||||
|
m_SessionsUpdatedCallback(m_pSearchParam);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int CPlatformNetworkManagerStub::SearchForGamesThreadProc( void* lpParameter )
|
int CPlatformNetworkManagerStub::SearchForGamesThreadProc( void* lpParameter )
|
||||||
|
|
@ -522,7 +739,9 @@ void CPlatformNetworkManagerStub::SetSearchResultsReady(int resultCount)
|
||||||
|
|
||||||
vector<FriendSessionInfo *> *CPlatformNetworkManagerStub::GetSessionList(int iPad, int localPlayers, bool partyOnly)
|
vector<FriendSessionInfo *> *CPlatformNetworkManagerStub::GetSessionList(int iPad, int localPlayers, bool partyOnly)
|
||||||
{
|
{
|
||||||
vector<FriendSessionInfo *> *filteredList = new vector<FriendSessionInfo *>();;
|
vector<FriendSessionInfo*>* filteredList = new vector<FriendSessionInfo*>();
|
||||||
|
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||||
|
filteredList->push_back(friendsSessions[0][i]);
|
||||||
return filteredList;
|
return filteredList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,9 @@ public:
|
||||||
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
||||||
virtual void ForceFriendsSessionRefresh();
|
virtual void ForceFriendsSessionRefresh();
|
||||||
|
|
||||||
private:
|
public:
|
||||||
void NotifyPlayerJoined( IQNetPlayer *pQNetPlayer );
|
void NotifyPlayerJoined( IQNetPlayer *pQNetPlayer );
|
||||||
|
void NotifyPlayerLeaving(IQNetPlayer* pQNetPlayer);
|
||||||
|
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
void FakeLocalPlayerJoined() { NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0)); }
|
void FakeLocalPlayerJoined() { NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0)); }
|
||||||
|
|
|
||||||
|
|
@ -63,12 +63,19 @@ typedef struct _GameSessionData
|
||||||
#else
|
#else
|
||||||
typedef struct _GameSessionData
|
typedef struct _GameSessionData
|
||||||
{
|
{
|
||||||
unsigned short netVersion; // 2 bytes
|
unsigned short netVersion;
|
||||||
unsigned int m_uiGameHostSettings; // 4 bytes
|
unsigned int m_uiGameHostSettings;
|
||||||
unsigned int texturePackParentId; // 4 bytes
|
unsigned int texturePackParentId;
|
||||||
unsigned char subTexturePackId; // 1 byte
|
unsigned char subTexturePackId;
|
||||||
|
|
||||||
bool isReadyToJoin; // 1 byte
|
bool isReadyToJoin;
|
||||||
|
bool isJoinable;
|
||||||
|
|
||||||
|
char hostIP[64];
|
||||||
|
int hostPort;
|
||||||
|
wchar_t hostName[XUSER_NAME_SIZE];
|
||||||
|
unsigned char playerCount;
|
||||||
|
unsigned char maxPlayers;
|
||||||
|
|
||||||
_GameSessionData()
|
_GameSessionData()
|
||||||
{
|
{
|
||||||
|
|
@ -76,6 +83,13 @@ typedef struct _GameSessionData
|
||||||
m_uiGameHostSettings = 0;
|
m_uiGameHostSettings = 0;
|
||||||
texturePackParentId = 0;
|
texturePackParentId = 0;
|
||||||
subTexturePackId = 0;
|
subTexturePackId = 0;
|
||||||
|
isReadyToJoin = false;
|
||||||
|
isJoinable = true;
|
||||||
|
memset(hostIP, 0, sizeof(hostIP));
|
||||||
|
hostPort = 0;
|
||||||
|
memset(hostName, 0, sizeof(hostName));
|
||||||
|
playerCount = 0;
|
||||||
|
maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||||
}
|
}
|
||||||
} GameSessionData;
|
} GameSessionData;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -284,13 +284,8 @@ UIScene_LoadOrJoinMenu::~UIScene_LoadOrJoinMenu()
|
||||||
g_NetworkManager.SetSessionsUpdatedCallback( NULL, NULL );
|
g_NetworkManager.SetSessionsUpdatedCallback( NULL, NULL );
|
||||||
app.SetLiveLinkRequired( false );
|
app.SetLiveLinkRequired( false );
|
||||||
|
|
||||||
if(m_currentSessions)
|
delete m_currentSessions;
|
||||||
{
|
m_currentSessions = NULL;
|
||||||
for(AUTO_VAR(it, m_currentSessions->begin()); it < m_currentSessions->end(); ++it)
|
|
||||||
{
|
|
||||||
delete (*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TO_BE_IMPLEMENTED
|
#if TO_BE_IMPLEMENTED
|
||||||
// Reset the background downloading, in case we changed it by attempting to download a texture pack
|
// Reset the background downloading, in case we changed it by attempting to download a texture pack
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "UI.h"
|
#include "UI.h"
|
||||||
#include "UIScene_SettingsGraphicsMenu.h"
|
#include "UIScene_SettingsGraphicsMenu.h"
|
||||||
|
#include "..\..\Minecraft.h"
|
||||||
|
#include "..\..\GameRenderer.h"
|
||||||
|
|
||||||
UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
||||||
{
|
{
|
||||||
// Setup all the Iggy references we need for this scene
|
// Setup all the Iggy references we need for this scene
|
||||||
initialiseMovie();
|
initialiseMovie();
|
||||||
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
|
|
||||||
m_bNotInGame=(Minecraft::GetInstance()->level==NULL);
|
m_bNotInGame=(Minecraft::GetInstance()->level==NULL);
|
||||||
|
|
||||||
|
|
@ -19,6 +22,9 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD
|
||||||
swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),app.GetGameSettings(m_iPad,eGameSetting_Gamma));
|
swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),app.GetGameSettings(m_iPad,eGameSetting_Gamma));
|
||||||
m_sliderGamma.init(TempString,eControl_Gamma,0,100,app.GetGameSettings(m_iPad,eGameSetting_Gamma));
|
m_sliderGamma.init(TempString,eControl_Gamma,0,100,app.GetGameSettings(m_iPad,eGameSetting_Gamma));
|
||||||
|
|
||||||
|
swprintf((WCHAR*)TempString, 256, L"FOV: %d%%", (int)pMinecraft->gameRenderer->GetFovVal());
|
||||||
|
m_sliderFOV.init(TempString, eControl_FOV, 70, 110, (int)pMinecraft->gameRenderer->GetFovVal());
|
||||||
|
|
||||||
swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity));
|
swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity));
|
||||||
m_sliderInterfaceOpacity.init(TempString,eControl_InterfaceOpacity,0,100,app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity));
|
m_sliderInterfaceOpacity.init(TempString,eControl_InterfaceOpacity,0,100,app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity));
|
||||||
|
|
||||||
|
|
@ -141,6 +147,17 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal
|
||||||
m_sliderGamma.setLabel(TempString);
|
m_sliderGamma.setLabel(TempString);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case eControl_FOV:
|
||||||
|
{
|
||||||
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
|
pMinecraft->gameRenderer->SetFovVal((float)currentValue);
|
||||||
|
WCHAR TempString[256];
|
||||||
|
swprintf((WCHAR*)TempString, 256, L"FOV: %d%%", (int)currentValue);
|
||||||
|
m_sliderFOV.setLabel(TempString);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case eControl_InterfaceOpacity:
|
case eControl_InterfaceOpacity:
|
||||||
m_sliderInterfaceOpacity.handleSliderMove(value);
|
m_sliderInterfaceOpacity.handleSliderMove(value);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,18 @@ private:
|
||||||
eControl_BedrockFog,
|
eControl_BedrockFog,
|
||||||
eControl_CustomSkinAnim,
|
eControl_CustomSkinAnim,
|
||||||
eControl_Gamma,
|
eControl_Gamma,
|
||||||
|
eControl_FOV,
|
||||||
eControl_InterfaceOpacity
|
eControl_InterfaceOpacity
|
||||||
};
|
};
|
||||||
|
|
||||||
UIControl_CheckBox m_checkboxClouds, m_checkboxBedrockFog, m_checkboxCustomSkinAnim; // Checkboxes
|
UIControl_CheckBox m_checkboxClouds, m_checkboxBedrockFog, m_checkboxCustomSkinAnim; // Checkboxes
|
||||||
UIControl_Slider m_sliderGamma, m_sliderInterfaceOpacity; // Sliders
|
UIControl_Slider m_sliderGamma, m_sliderFOV, m_sliderInterfaceOpacity; // Sliders
|
||||||
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
|
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
|
||||||
UI_MAP_ELEMENT( m_checkboxClouds, "Clouds")
|
UI_MAP_ELEMENT( m_checkboxClouds, "Clouds")
|
||||||
UI_MAP_ELEMENT( m_checkboxBedrockFog, "BedrockFog")
|
UI_MAP_ELEMENT( m_checkboxBedrockFog, "BedrockFog")
|
||||||
UI_MAP_ELEMENT( m_checkboxCustomSkinAnim, "CustomSkinAnim")
|
UI_MAP_ELEMENT( m_checkboxCustomSkinAnim, "CustomSkinAnim")
|
||||||
UI_MAP_ELEMENT( m_sliderGamma, "Gamma")
|
UI_MAP_ELEMENT( m_sliderGamma, "Gamma")
|
||||||
|
UI_MAP_ELEMENT(m_sliderFOV, "FOV")
|
||||||
UI_MAP_ELEMENT( m_sliderInterfaceOpacity, "InterfaceOpacity")
|
UI_MAP_ELEMENT( m_sliderInterfaceOpacity, "InterfaceOpacity")
|
||||||
UI_END_MAP_ELEMENTS_AND_NAMES()
|
UI_END_MAP_ELEMENTS_AND_NAMES()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include "StatsCounter.h"
|
#include "StatsCounter.h"
|
||||||
#include "Windows64\Social\SocialManager.h"
|
#include "Windows64\Social\SocialManager.h"
|
||||||
#include "Windows64\Sentient\DynamicConfigurations.h"
|
#include "Windows64\Sentient\DynamicConfigurations.h"
|
||||||
|
#include "Windows64\Network\WinsockNetLayer.h"
|
||||||
#elif defined __PSVITA__
|
#elif defined __PSVITA__
|
||||||
#include "PSVita\Sentient\SentientManager.h"
|
#include "PSVita\Sentient\SentientManager.h"
|
||||||
#include "StatsCounter.h"
|
#include "StatsCounter.h"
|
||||||
|
|
@ -185,27 +186,23 @@ D3DXVECTOR3::D3DXVECTOR3() {}
|
||||||
D3DXVECTOR3::D3DXVECTOR3(float x, float y, float z) : x(x), y(y), z(z) {}
|
D3DXVECTOR3::D3DXVECTOR3(float x, float y, float z) : x(x), y(y), z(z) {}
|
||||||
D3DXVECTOR3& D3DXVECTOR3::operator += (CONST D3DXVECTOR3 & add) { x += add.x; y += add.y; z += add.z; return *this; }
|
D3DXVECTOR3& D3DXVECTOR3::operator += (CONST D3DXVECTOR3 & add) { x += add.x; y += add.y; z += add.z; return *this; }
|
||||||
|
|
||||||
BYTE IQNetPlayer::GetSmallId() { return 0; }
|
BYTE IQNetPlayer::GetSmallId() { return m_smallId; }
|
||||||
void IQNetPlayer::SendData(IQNetPlayer * player, const void* pvData, DWORD dwDataSize, DWORD dwFlags)
|
void IQNetPlayer::SendData(IQNetPlayer * player, const void* pvData, DWORD dwDataSize, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
app.DebugPrintf("Sending from 0x%x to 0x%x %d bytes\n",this,player,dwDataSize);
|
if (WinsockNetLayer::IsActive())
|
||||||
|
{
|
||||||
|
WinsockNetLayer::SendToSmallId(player->m_smallId, pvData, dwDataSize);
|
||||||
}
|
}
|
||||||
bool IQNetPlayer::IsSameSystem(IQNetPlayer *player) { return true; }
|
}
|
||||||
|
bool IQNetPlayer::IsSameSystem(IQNetPlayer * player) { return (this == player) || (!m_isRemote && !player->m_isRemote); }
|
||||||
DWORD IQNetPlayer::GetSendQueueSize(IQNetPlayer * player, DWORD dwFlags) { return 0; }
|
DWORD IQNetPlayer::GetSendQueueSize(IQNetPlayer * player, DWORD dwFlags) { return 0; }
|
||||||
DWORD IQNetPlayer::GetCurrentRtt() { return 0; }
|
DWORD IQNetPlayer::GetCurrentRtt() { return 0; }
|
||||||
bool IQNetPlayer::IsHost() { return this == &IQNet::m_player[0]; }
|
bool IQNetPlayer::IsHost() { return m_isHostPlayer; }
|
||||||
bool IQNetPlayer::IsGuest() { return false; }
|
bool IQNetPlayer::IsGuest() { return false; }
|
||||||
bool IQNetPlayer::IsLocal() { return true; }
|
bool IQNetPlayer::IsLocal() { return true; }
|
||||||
PlayerUID IQNetPlayer::GetXuid() { return INVALID_XUID; }
|
PlayerUID IQNetPlayer::GetXuid() { return INVALID_XUID; }
|
||||||
LPCWSTR IQNetPlayer::GetGamertag()
|
extern wstring g_playerName;
|
||||||
{
|
LPCWSTR IQNetPlayer::GetGamertag() { return g_playerName.empty() ? L"Windows" : g_playerName.c_str(); }
|
||||||
static wchar_t tags[4][16];
|
|
||||||
int idx = GetUserIndex();
|
|
||||||
if(idx < 0 || idx >= 4) idx = 0;
|
|
||||||
mbstowcs(tags[idx], ProfileManager.GetGamertag(idx), 15);
|
|
||||||
tags[idx][15] = L'\0';
|
|
||||||
return tags[idx];
|
|
||||||
}
|
|
||||||
int IQNetPlayer::GetSessionIndex() { return 0; }
|
int IQNetPlayer::GetSessionIndex() { return 0; }
|
||||||
bool IQNetPlayer::IsTalking() { return false; }
|
bool IQNetPlayer::IsTalking() { return false; }
|
||||||
bool IQNetPlayer::IsMutedByLocalUser(DWORD dwUserIndex) { return false; }
|
bool IQNetPlayer::IsMutedByLocalUser(DWORD dwUserIndex) { return false; }
|
||||||
|
|
@ -219,22 +216,104 @@ ULONG_PTR IQNetPlayer::GetCustomDataValue() {
|
||||||
return m_customData;
|
return m_customData;
|
||||||
}
|
}
|
||||||
|
|
||||||
IQNetPlayer IQNet::m_player[4];
|
IQNetPlayer IQNet::m_player[MINECRAFT_NET_MAX_PLAYERS];
|
||||||
|
DWORD IQNet::s_playerCount = 1;
|
||||||
|
bool IQNet::s_isHosting = true;
|
||||||
|
|
||||||
bool _bQNetStubGameRunning = false;
|
QNET_STATE _iQNetStubState = QNET_STATE_IDLE;
|
||||||
|
|
||||||
|
void Win64_SetupRemoteQNetPlayer(IQNetPlayer * player, BYTE smallId, bool isHost, bool isLocal)
|
||||||
|
{
|
||||||
|
player->m_smallId = smallId;
|
||||||
|
player->m_isRemote = !isLocal;
|
||||||
|
player->m_isHostPlayer = isHost;
|
||||||
|
swprintf_s(player->m_gamertag, 32, L"Player%d", smallId);
|
||||||
|
if (smallId >= IQNet::s_playerCount)
|
||||||
|
IQNet::s_playerCount = smallId + 1;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT IQNet::AddLocalPlayerByUserIndex(DWORD dwUserIndex) { return S_OK; }
|
HRESULT IQNet::AddLocalPlayerByUserIndex(DWORD dwUserIndex) { return S_OK; }
|
||||||
IQNetPlayer* IQNet::GetHostPlayer() { return &m_player[0]; }
|
IQNetPlayer* IQNet::GetHostPlayer() { return &m_player[0]; }
|
||||||
IQNetPlayer *IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex) { return &m_player[dwUserIndex]; }
|
IQNetPlayer* IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex)
|
||||||
IQNetPlayer *IQNet::GetPlayerByIndex(DWORD dwPlayerIndex) { return &m_player[0]; }
|
{
|
||||||
IQNetPlayer *IQNet::GetPlayerBySmallId(BYTE SmallId){ return &m_player[0]; }
|
if (s_isHosting)
|
||||||
IQNetPlayer *IQNet::GetPlayerByXuid(PlayerUID xuid){ return &m_player[0]; }
|
{
|
||||||
DWORD IQNet::GetPlayerCount() { return 1; }
|
if (dwUserIndex < MINECRAFT_NET_MAX_PLAYERS && !m_player[dwUserIndex].m_isRemote)
|
||||||
QNET_STATE IQNet::GetState() { return _bQNetStubGameRunning ? QNET_STATE_GAME_PLAY : QNET_STATE_IDLE; }
|
return &m_player[dwUserIndex];
|
||||||
bool IQNet::IsHost() { return true; }
|
return NULL;
|
||||||
|
}
|
||||||
|
if (dwUserIndex != 0)
|
||||||
|
return NULL;
|
||||||
|
for (DWORD i = 0; i < s_playerCount; i++)
|
||||||
|
{
|
||||||
|
if (!m_player[i].m_isRemote)
|
||||||
|
return &m_player[i];
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
static bool Win64_IsActivePlayer(IQNetPlayer * p, DWORD index)
|
||||||
|
{
|
||||||
|
if (index == 0) return true;
|
||||||
|
return (p->GetCustomDataValue() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
IQNetPlayer* IQNet::GetPlayerByIndex(DWORD dwPlayerIndex)
|
||||||
|
{
|
||||||
|
DWORD found = 0;
|
||||||
|
for (DWORD i = 0; i < s_playerCount; i++)
|
||||||
|
{
|
||||||
|
if (Win64_IsActivePlayer(&m_player[i], i))
|
||||||
|
{
|
||||||
|
if (found == dwPlayerIndex) return &m_player[i];
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &m_player[0];
|
||||||
|
}
|
||||||
|
IQNetPlayer* IQNet::GetPlayerBySmallId(BYTE SmallId)
|
||||||
|
{
|
||||||
|
for (DWORD i = 0; i < s_playerCount; i++)
|
||||||
|
{
|
||||||
|
if (m_player[i].m_smallId == SmallId && Win64_IsActivePlayer(&m_player[i], i)) return &m_player[i];
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
IQNetPlayer* IQNet::GetPlayerByXuid(PlayerUID xuid)
|
||||||
|
{
|
||||||
|
for (DWORD i = 0; i < s_playerCount; i++)
|
||||||
|
{
|
||||||
|
if (Win64_IsActivePlayer(&m_player[i], i) && m_player[i].GetXuid() == xuid) return &m_player[i];
|
||||||
|
}
|
||||||
|
return &m_player[0];
|
||||||
|
}
|
||||||
|
DWORD IQNet::GetPlayerCount()
|
||||||
|
{
|
||||||
|
DWORD count = 0;
|
||||||
|
for (DWORD i = 0; i < s_playerCount; i++)
|
||||||
|
{
|
||||||
|
if (Win64_IsActivePlayer(&m_player[i], i)) count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
QNET_STATE IQNet::GetState() { return _iQNetStubState; }
|
||||||
|
bool IQNet::IsHost() { return s_isHosting; }
|
||||||
HRESULT IQNet::JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO * pInviteInfo) { return S_OK; }
|
HRESULT IQNet::JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO * pInviteInfo) { return S_OK; }
|
||||||
void IQNet::HostGame() { _bQNetStubGameRunning = true; }
|
void IQNet::HostGame() { _iQNetStubState = QNET_STATE_SESSION_STARTING; s_isHosting = true; }
|
||||||
void IQNet::EndGame() { _bQNetStubGameRunning = false; }
|
void IQNet::ClientJoinGame() { _iQNetStubState = QNET_STATE_SESSION_STARTING; s_isHosting = false; }
|
||||||
|
void IQNet::EndGame()
|
||||||
|
{
|
||||||
|
_iQNetStubState = QNET_STATE_IDLE;
|
||||||
|
s_isHosting = false;
|
||||||
|
s_playerCount = 1;
|
||||||
|
for (int i = 1; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||||
|
{
|
||||||
|
m_player[i].m_smallId = 0;
|
||||||
|
m_player[i].m_isRemote = false;
|
||||||
|
m_player[i].m_isHostPlayer = false;
|
||||||
|
m_player[i].m_gamertag[0] = 0;
|
||||||
|
m_player[i].SetCustomDataValue(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DWORD MinecraftDynamicConfigurations::GetTrialTime() { return DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; }
|
DWORD MinecraftDynamicConfigurations::GetTrialTime() { return DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; }
|
||||||
|
|
||||||
|
|
@ -468,8 +547,23 @@ UINT C_4JProfile::DisplayOfflineProfile(int( *Func)(LPVOID,const bool, const
|
||||||
UINT C_4JProfile::RequestConvertOfflineToGuestUI(int(*Func)(LPVOID, const bool, const int iPad), LPVOID lpParam, int iQuadrant) { return 0; }
|
UINT C_4JProfile::RequestConvertOfflineToGuestUI(int(*Func)(LPVOID, const bool, const int iPad), LPVOID lpParam, int iQuadrant) { return 0; }
|
||||||
void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {}
|
void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {}
|
||||||
bool C_4JProfile::QuerySigninStatus(void) { return true; }
|
bool C_4JProfile::QuerySigninStatus(void) { return true; }
|
||||||
void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid) {*pXuid = 0xe000d45248242f2e; }
|
void C_4JProfile::GetXUID(int iPad, PlayerUID * pXuid, bool bOnlineXuid)
|
||||||
BOOL C_4JProfile::AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2) { return false; }
|
{
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
if (iPad != 0)
|
||||||
|
{
|
||||||
|
*pXuid = INVALID_XUID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (IQNet::s_isHosting)
|
||||||
|
*pXuid = 0xe000d45248242f2e;
|
||||||
|
else
|
||||||
|
*pXuid = 0xe000d45248242f2e + WinsockNetLayer::GetLocalSmallId();
|
||||||
|
#else
|
||||||
|
* pXuid = 0xe000d45248242f2e + iPad;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
BOOL C_4JProfile::AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) { return xuid1 == xuid2; }
|
||||||
BOOL C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; }
|
BOOL C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; }
|
||||||
bool C_4JProfile::AllowedToPlayMultiplayer(int iProf) { return true; }
|
bool C_4JProfile::AllowedToPlayMultiplayer(int iProf) { return true; }
|
||||||
|
|
||||||
|
|
@ -495,22 +589,8 @@ char fakeGamerTag[32] = "PlayerName";
|
||||||
void SetFakeGamertag(char* name) { strcpy_s(fakeGamerTag, name); }
|
void SetFakeGamertag(char* name) { strcpy_s(fakeGamerTag, name); }
|
||||||
char* C_4JProfile::GetGamertag(int iPad) { return fakeGamerTag; }
|
char* C_4JProfile::GetGamertag(int iPad) { return fakeGamerTag; }
|
||||||
#else
|
#else
|
||||||
char* C_4JProfile::GetGamertag(int iPad)
|
char* C_4JProfile::GetGamertag(int iPad) { extern char g_Win64Username[17]; return g_Win64Username; }
|
||||||
{
|
wstring C_4JProfile::GetDisplayName(int iPad) { extern wchar_t g_Win64UsernameW[17]; return g_Win64UsernameW; }
|
||||||
static char tags[4][16] = { "Player 1", "Player 2", "Player 3", "Player 4" };
|
|
||||||
if(iPad >= 0 && iPad < 4) return tags[iPad];
|
|
||||||
return tags[0];
|
|
||||||
}
|
|
||||||
wstring C_4JProfile::GetDisplayName(int iPad)
|
|
||||||
{
|
|
||||||
switch(iPad)
|
|
||||||
{
|
|
||||||
case 1: return L"Player 2";
|
|
||||||
case 2: return L"Player 3";
|
|
||||||
case 3: return L"Player 4";
|
|
||||||
default: return L"Player 1";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
|
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
|
||||||
void C_4JProfile::SetSignInChangeCallback(void (*Func)(LPVOID, bool, unsigned int), LPVOID lpParam) {}
|
void C_4JProfile::SetSignInChangeCallback(void (*Func)(LPVOID, bool, unsigned int), LPVOID lpParam) {}
|
||||||
|
|
@ -547,7 +627,8 @@ void *C_4JProfile::GetGameDefinedProfileData(int iQuadrant)
|
||||||
void C_4JProfile::ResetProfileProcessState() {}
|
void C_4JProfile::ResetProfileProcessState() {}
|
||||||
void C_4JProfile::Tick(void) {}
|
void C_4JProfile::Tick(void) {}
|
||||||
void C_4JProfile::RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected,
|
void C_4JProfile::RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected,
|
||||||
CXuiStringTable*pStringTable, int iTitleStr, int iTextStr, int iAcceptStr, char *pszThemeName, unsigned int ulThemeSize) {}
|
CXuiStringTable * pStringTable, int iTitleStr, int iTextStr, int iAcceptStr, char* pszThemeName, unsigned int ulThemeSize) {
|
||||||
|
}
|
||||||
int C_4JProfile::GetAwardId(int iAwardNumber) { return 0; }
|
int C_4JProfile::GetAwardId(int iAwardNumber) { return 0; }
|
||||||
eAwardType C_4JProfile::GetAwardType(int iAwardNumber) { return eAwardType_Achievement; }
|
eAwardType C_4JProfile::GetAwardType(int iAwardNumber) { return eAwardType_Achievement; }
|
||||||
bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) { return false; }
|
bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) { return false; }
|
||||||
|
|
|
||||||
|
|
@ -903,7 +903,7 @@ void GameRenderer::updateLightTexture(float a)
|
||||||
if (_g > 1) _g = 1;
|
if (_g > 1) _g = 1;
|
||||||
if (_b > 1) _b = 1;
|
if (_b > 1) _b = 1;
|
||||||
|
|
||||||
float brightness = 0.0f; // 4J - TODO - was mc->options->gamma;
|
float brightness = mc->options->gamma;
|
||||||
|
|
||||||
float ir = 1 - _r;
|
float ir = 1 - _r;
|
||||||
float ig = 1 - _g;
|
float ig = 1 - _g;
|
||||||
|
|
|
||||||
|
|
@ -310,6 +310,7 @@
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64EC'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64EC'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
|
@ -774,7 +775,7 @@
|
||||||
</CustomBuildBeforeTargets>
|
</CustomBuildBeforeTargets>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<ImageXexOutput>$(OutDir)$(ProjectName)_D.xex</ImageXexOutput>
|
<ImageXexOutput>$(OutDir)$(ProjectName)_D.xex</ImageXexOutput>
|
||||||
<IncludePath>$(ProjectDir)\..\Minecraft.World\x64headers;$(ProjectDir)\Xbox\Sentient\Include;$(IncludePath)</IncludePath>
|
<IncludePath>$(ProjectDir)\..\Minecraft.World\x64headers;$(ProjectDir)\Xbox\Sentient\Include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
@ -1754,7 +1755,7 @@ xcopy /q /y /i /s /e $(ProjectDir)DurangoMedia\CU $(LayoutDir)Image\Loose\CU</C
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
<ExceptionHandling>Sync</ExceptionHandling>
|
||||||
|
|
@ -1776,6 +1777,7 @@ xcopy /q /y /i /s /e $(ProjectDir)DurangoMedia\CU $(LayoutDir)Image\Loose\CU</C
|
||||||
<AdditionalDependencies>legacy_stdio_definitions.lib;d3d11.lib;..\Minecraft.World\x64_Release\Minecraft.World.lib;XInput9_1_0.lib;Windows64\Iggy\lib\iggy_w64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>legacy_stdio_definitions.lib;d3d11.lib;..\Minecraft.World\x64_Release\Minecraft.World.lib;XInput9_1_0.lib;Windows64\Iggy\lib\iggy_w64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<ShowProgress>NotSet</ShowProgress>
|
<ShowProgress>NotSet</ShowProgress>
|
||||||
<SuppressStartupBanner>false</SuppressStartupBanner>
|
<SuppressStartupBanner>false</SuppressStartupBanner>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>Run postbuild script</Message>
|
<Message>Run postbuild script</Message>
|
||||||
|
|
@ -21547,6 +21549,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ORBIS'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ORBIS'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|ORBIS'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|ORBIS'">true</ExcludedFromBuild>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Windows64\Network\WinsockNetLayer.h" />
|
||||||
<ClInclude Include="Windows64\Resource.h">
|
<ClInclude Include="Windows64\Resource.h">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Durango'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Durango'">true</ExcludedFromBuild>
|
||||||
|
|
@ -38310,6 +38313,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Durango'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Durango'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Durango'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Durango'">true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Windows64\Network\WinsockNetLayer.cpp" />
|
||||||
<ClCompile Include="Windows64\Windows64_App.cpp">
|
<ClCompile Include="Windows64\Windows64_App.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Durango'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Durango'">true</ExcludedFromBuild>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -6,6 +6,7 @@
|
||||||
#include "Minecraft.h"
|
#include "Minecraft.h"
|
||||||
#include "ClientConnection.h"
|
#include "ClientConnection.h"
|
||||||
#include "LevelRenderer.h"
|
#include "LevelRenderer.h"
|
||||||
|
#include "Common\Network\GameNetworkManager.h"
|
||||||
#include "..\Minecraft.World\net.minecraft.world.level.h"
|
#include "..\Minecraft.World\net.minecraft.world.level.h"
|
||||||
#include "..\Minecraft.World\net.minecraft.world.item.h"
|
#include "..\Minecraft.World\net.minecraft.world.item.h"
|
||||||
#include "..\Minecraft.World\net.minecraft.world.entity.player.h"
|
#include "..\Minecraft.World\net.minecraft.world.entity.player.h"
|
||||||
|
|
@ -85,6 +86,14 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face)
|
||||||
|
|
||||||
if (oldTile == NULL) return false;
|
if (oldTile == NULL) return false;
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
if (g_NetworkManager.IsHost())
|
||||||
|
{
|
||||||
|
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||||
|
|
||||||
int data = level->getData(x, y, z);
|
int data = level->getData(x, y, z);
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@
|
||||||
|
|
||||||
Random *PendingConnection::random = new Random();
|
Random *PendingConnection::random = new Random();
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
bool g_bRejectDuplicateNames = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, const wstring& id)
|
PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, const wstring& id)
|
||||||
{
|
{
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
|
|
@ -166,6 +170,30 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||||
{
|
{
|
||||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||||
}
|
}
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
else if (g_bRejectDuplicateNames)
|
||||||
|
{
|
||||||
|
bool nameTaken = false;
|
||||||
|
vector<shared_ptr<ServerPlayer> >& pl = server->getPlayers()->players;
|
||||||
|
for (unsigned int i = 0; i < pl.size(); i++)
|
||||||
|
{
|
||||||
|
if (pl[i] != NULL && pl[i]->name == name)
|
||||||
|
{
|
||||||
|
nameTaken = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nameTaken)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Rejecting duplicate name: %ls\n", name.c_str());
|
||||||
|
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handleAcceptedLogin(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
handleAcceptedLogin(packet);
|
handleAcceptedLogin(packet);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include "..\Minecraft.World\net.minecraft.world.level.saveddata.h"
|
#include "..\Minecraft.World\net.minecraft.world.level.saveddata.h"
|
||||||
#include "..\Minecraft.World\JavaMath.h"
|
#include "..\Minecraft.World\JavaMath.h"
|
||||||
#include "..\Minecraft.World\EntityIO.h"
|
#include "..\Minecraft.World\EntityIO.h"
|
||||||
#ifdef _XBOX
|
#if defined(_XBOX) || defined(_WINDOWS64)
|
||||||
#include "Xbox\Network\NetworkPlayerXbox.h"
|
#include "Xbox\Network\NetworkPlayerXbox.h"
|
||||||
#elif defined(__PS3__) || defined(__ORBIS__)
|
#elif defined(__PS3__) || defined(__ORBIS__)
|
||||||
#include "Common\Network\Sony\NetworkPlayerSony.h"
|
#include "Common\Network\Sony\NetworkPlayerSony.h"
|
||||||
|
|
@ -56,6 +56,11 @@ PlayerList::PlayerList(MinecraftServer *server)
|
||||||
maxPlayers = server->settings->getInt(L"max-players", 20);
|
maxPlayers = server->settings->getInt(L"max-players", 20);
|
||||||
doWhiteList = false;
|
doWhiteList = false;
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||||
|
#else
|
||||||
|
maxPlayers = server->settings->getInt(L"max-players", 20);
|
||||||
|
#endif
|
||||||
InitializeCriticalSection(&m_kickPlayersCS);
|
InitializeCriticalSection(&m_kickPlayersCS);
|
||||||
InitializeCriticalSection(&m_closePlayersCS);
|
InitializeCriticalSection(&m_closePlayersCS);
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +105,14 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
if (networkPlayer != NULL && !networkPlayer->IsLocal())
|
||||||
|
{
|
||||||
|
NetworkPlayerXbox* nxp = (NetworkPlayerXbox*)networkPlayer;
|
||||||
|
IQNetPlayer* qnp = nxp->GetQNetPlayer();
|
||||||
|
wcsncpy_s(qnp->m_gamertag, 32, player->name.c_str(), _TRUNCATE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// 4J Stu - TU-1 hotfix
|
// 4J Stu - TU-1 hotfix
|
||||||
// Fix for #13150 - When a player loads/joins a game after saving/leaving in the nether, sometimes they are spawned on top of the nether and cannot mine down
|
// Fix for #13150 - When a player loads/joins a game after saving/leaving in the nether, sometimes they are spawned on top of the nether and cannot mine down
|
||||||
validatePlayerSpawnPosition(player);
|
validatePlayerSpawnPosition(player);
|
||||||
|
|
@ -227,7 +239,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
||||||
sendLevelInfo(player, level);
|
sendLevelInfo(player, level);
|
||||||
|
|
||||||
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
||||||
//server->players->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(L"§e" + playerEntity->name + L" joined the game.") ) );
|
//server->players->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(L"<EFBFBD>e" + playerEntity->name + L" joined the game.") ) );
|
||||||
broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) );
|
broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) );
|
||||||
|
|
||||||
MemSect(14);
|
MemSect(14);
|
||||||
|
|
@ -428,7 +440,7 @@ void PlayerList::add(shared_ptr<ServerPlayer> player)
|
||||||
// Some code from here has been moved to the above validatePlayerSpawnPosition function
|
// Some code from here has been moved to the above validatePlayerSpawnPosition function
|
||||||
|
|
||||||
// 4J Stu - Swapped these lines about so that we get the chunk visiblity packet way ahead of all the add tracked entity packets
|
// 4J Stu - Swapped these lines about so that we get the chunk visiblity packet way ahead of all the add tracked entity packets
|
||||||
// Fix for #9169 - ART : Sign text is replaced with the words “Awaiting approval”.
|
// Fix for #9169 - ART : Sign text is replaced with the words <EFBFBD>Awaiting approval<61>.
|
||||||
changeDimension(player, NULL);
|
changeDimension(player, NULL);
|
||||||
level->addEntity(player);
|
level->addEntity(player);
|
||||||
|
|
||||||
|
|
@ -471,12 +483,10 @@ void PlayerList::remove(shared_ptr<ServerPlayer> player)
|
||||||
ServerLevel *level = player->getLevel();
|
ServerLevel *level = player->getLevel();
|
||||||
if (player->riding != NULL)
|
if (player->riding != NULL)
|
||||||
{
|
{
|
||||||
// remove mount first because the player unmounts when being
|
|
||||||
// removed, also remove mount because it's saved in the player's
|
|
||||||
// save tag
|
|
||||||
level->removeEntityImmediately(player->riding);
|
level->removeEntityImmediately(player->riding);
|
||||||
app.DebugPrintf("removing player mount");
|
app.DebugPrintf("removing player mount");
|
||||||
}
|
}
|
||||||
|
level->getTracker()->removeEntity(player);
|
||||||
level->removeEntity(player);
|
level->removeEntity(player);
|
||||||
level->getChunkMap()->remove(player);
|
level->getChunkMap()->remove(player);
|
||||||
AUTO_VAR(it, find(players.begin(),players.end(),player));
|
AUTO_VAR(it, find(players.begin(),players.end(),player));
|
||||||
|
|
@ -497,17 +507,30 @@ void PlayerList::remove(shared_ptr<ServerPlayer> player)
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid)
|
shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid)
|
||||||
{
|
{
|
||||||
if (players.size() >= maxPlayers)
|
#ifdef _WINDOWS64
|
||||||
|
if (players.size() >= (unsigned int)MINECRAFT_NET_MAX_PLAYERS)
|
||||||
|
#else
|
||||||
|
if (players.size() >= (unsigned int)maxPlayers)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull);
|
pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull);
|
||||||
return shared_ptr<ServerPlayer>();
|
return shared_ptr<ServerPlayer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> player = shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) ));
|
shared_ptr<ServerPlayer> player = shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) ));
|
||||||
player->gameMode->player = player; // 4J added as had to remove this assignment from ServerPlayer ctor
|
player->gameMode->player = player; // 4J added as had to remove this assignment from ServerPlayer ctor
|
||||||
player->setXuid( xuid ); // 4J Added
|
player->setXuid( xuid ); // 4J Added
|
||||||
player->setOnlineXuid( onlineXuid ); // 4J Added
|
player->setOnlineXuid( onlineXuid ); // 4J Added
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
{
|
||||||
|
INetworkPlayer* np = pendingConnection->connection->getSocket()->getPlayer();
|
||||||
|
if (np != NULL)
|
||||||
|
{
|
||||||
|
PlayerUID realXuid = np->GetUID();
|
||||||
|
player->setXuid(realXuid);
|
||||||
|
player->setOnlineXuid(realXuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// Work out the base server player settings
|
// Work out the base server player settings
|
||||||
INetworkPlayer *networkPlayer = pendingConnection->connection->getSocket()->getPlayer();
|
INetworkPlayer *networkPlayer = pendingConnection->connection->getSocket()->getPlayer();
|
||||||
if(networkPlayer != NULL && !networkPlayer->IsHost())
|
if(networkPlayer != NULL && !networkPlayer->IsHost())
|
||||||
|
|
|
||||||
844
Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp
Normal file
844
Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp
Normal file
|
|
@ -0,0 +1,844 @@
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
|
||||||
|
#include "WinsockNetLayer.h"
|
||||||
|
#include "..\..\Common\Network\PlatformNetworkManagerStub.h"
|
||||||
|
#include "..\..\..\Minecraft.World\Socket.h"
|
||||||
|
|
||||||
|
SOCKET WinsockNetLayer::s_listenSocket = INVALID_SOCKET;
|
||||||
|
SOCKET WinsockNetLayer::s_hostConnectionSocket = INVALID_SOCKET;
|
||||||
|
HANDLE WinsockNetLayer::s_acceptThread = NULL;
|
||||||
|
HANDLE WinsockNetLayer::s_clientRecvThread = NULL;
|
||||||
|
|
||||||
|
bool WinsockNetLayer::s_isHost = false;
|
||||||
|
bool WinsockNetLayer::s_connected = false;
|
||||||
|
bool WinsockNetLayer::s_active = false;
|
||||||
|
bool WinsockNetLayer::s_initialized = false;
|
||||||
|
|
||||||
|
BYTE WinsockNetLayer::s_localSmallId = 0;
|
||||||
|
BYTE WinsockNetLayer::s_hostSmallId = 0;
|
||||||
|
BYTE WinsockNetLayer::s_nextSmallId = 1;
|
||||||
|
|
||||||
|
CRITICAL_SECTION WinsockNetLayer::s_sendLock;
|
||||||
|
CRITICAL_SECTION WinsockNetLayer::s_connectionsLock;
|
||||||
|
|
||||||
|
std::vector<Win64RemoteConnection> WinsockNetLayer::s_connections;
|
||||||
|
|
||||||
|
SOCKET WinsockNetLayer::s_advertiseSock = INVALID_SOCKET;
|
||||||
|
HANDLE WinsockNetLayer::s_advertiseThread = NULL;
|
||||||
|
volatile bool WinsockNetLayer::s_advertising = false;
|
||||||
|
Win64LANBroadcast WinsockNetLayer::s_advertiseData = {};
|
||||||
|
CRITICAL_SECTION WinsockNetLayer::s_advertiseLock;
|
||||||
|
int WinsockNetLayer::s_hostGamePort = WIN64_NET_DEFAULT_PORT;
|
||||||
|
|
||||||
|
SOCKET WinsockNetLayer::s_discoverySock = INVALID_SOCKET;
|
||||||
|
HANDLE WinsockNetLayer::s_discoveryThread = NULL;
|
||||||
|
volatile bool WinsockNetLayer::s_discovering = false;
|
||||||
|
CRITICAL_SECTION WinsockNetLayer::s_discoveryLock;
|
||||||
|
std::vector<Win64LANSession> WinsockNetLayer::s_discoveredSessions;
|
||||||
|
|
||||||
|
CRITICAL_SECTION WinsockNetLayer::s_disconnectLock;
|
||||||
|
std::vector<BYTE> WinsockNetLayer::s_disconnectedSmallIds;
|
||||||
|
|
||||||
|
CRITICAL_SECTION WinsockNetLayer::s_freeSmallIdLock;
|
||||||
|
std::vector<BYTE> WinsockNetLayer::s_freeSmallIds;
|
||||||
|
|
||||||
|
bool g_Win64MultiplayerHost = false;
|
||||||
|
bool g_Win64MultiplayerJoin = false;
|
||||||
|
int g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT;
|
||||||
|
char g_Win64MultiplayerIP[256] = "127.0.0.1";
|
||||||
|
|
||||||
|
bool WinsockNetLayer::Initialize()
|
||||||
|
{
|
||||||
|
if (s_initialized) return true;
|
||||||
|
|
||||||
|
WSADATA wsaData;
|
||||||
|
int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("WSAStartup failed: %d\n", result);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeCriticalSection(&s_sendLock);
|
||||||
|
InitializeCriticalSection(&s_connectionsLock);
|
||||||
|
InitializeCriticalSection(&s_advertiseLock);
|
||||||
|
InitializeCriticalSection(&s_discoveryLock);
|
||||||
|
InitializeCriticalSection(&s_disconnectLock);
|
||||||
|
InitializeCriticalSection(&s_freeSmallIdLock);
|
||||||
|
|
||||||
|
s_initialized = true;
|
||||||
|
|
||||||
|
StartDiscovery();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinsockNetLayer::Shutdown()
|
||||||
|
{
|
||||||
|
StopAdvertising();
|
||||||
|
StopDiscovery();
|
||||||
|
|
||||||
|
s_active = false;
|
||||||
|
s_connected = false;
|
||||||
|
|
||||||
|
if (s_listenSocket != INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(s_listenSocket);
|
||||||
|
s_listenSocket = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_hostConnectionSocket != INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(s_hostConnectionSocket);
|
||||||
|
s_hostConnectionSocket = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
|
for (size_t i = 0; i < s_connections.size(); i++)
|
||||||
|
{
|
||||||
|
s_connections[i].active = false;
|
||||||
|
if (s_connections[i].tcpSocket != INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(s_connections[i].tcpSocket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s_connections.clear();
|
||||||
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
|
if (s_acceptThread != NULL)
|
||||||
|
{
|
||||||
|
WaitForSingleObject(s_acceptThread, 2000);
|
||||||
|
CloseHandle(s_acceptThread);
|
||||||
|
s_acceptThread = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_clientRecvThread != NULL)
|
||||||
|
{
|
||||||
|
WaitForSingleObject(s_clientRecvThread, 2000);
|
||||||
|
CloseHandle(s_clientRecvThread);
|
||||||
|
s_clientRecvThread = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_initialized)
|
||||||
|
{
|
||||||
|
DeleteCriticalSection(&s_sendLock);
|
||||||
|
DeleteCriticalSection(&s_connectionsLock);
|
||||||
|
DeleteCriticalSection(&s_advertiseLock);
|
||||||
|
DeleteCriticalSection(&s_discoveryLock);
|
||||||
|
DeleteCriticalSection(&s_disconnectLock);
|
||||||
|
s_disconnectedSmallIds.clear();
|
||||||
|
DeleteCriticalSection(&s_freeSmallIdLock);
|
||||||
|
s_freeSmallIds.clear();
|
||||||
|
WSACleanup();
|
||||||
|
s_initialized = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WinsockNetLayer::HostGame(int port)
|
||||||
|
{
|
||||||
|
if (!s_initialized && !Initialize()) return false;
|
||||||
|
|
||||||
|
s_isHost = true;
|
||||||
|
s_localSmallId = 0;
|
||||||
|
s_hostSmallId = 0;
|
||||||
|
s_nextSmallId = 1;
|
||||||
|
s_hostGamePort = port;
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_freeSmallIdLock);
|
||||||
|
s_freeSmallIds.clear();
|
||||||
|
LeaveCriticalSection(&s_freeSmallIdLock);
|
||||||
|
|
||||||
|
struct addrinfo hints = {};
|
||||||
|
struct addrinfo *result = NULL;
|
||||||
|
|
||||||
|
hints.ai_family = AF_INET;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_protocol = IPPROTO_TCP;
|
||||||
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
|
char portStr[16];
|
||||||
|
sprintf_s(portStr, "%d", port);
|
||||||
|
|
||||||
|
int iResult = getaddrinfo(NULL, portStr, &hints, &result);
|
||||||
|
if (iResult != 0)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("getaddrinfo failed: %d\n", iResult);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_listenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
|
||||||
|
if (s_listenSocket == INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("socket() failed: %d\n", WSAGetLastError());
|
||||||
|
freeaddrinfo(result);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt = 1;
|
||||||
|
setsockopt(s_listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));
|
||||||
|
|
||||||
|
iResult = ::bind(s_listenSocket, result->ai_addr, (int)result->ai_addrlen);
|
||||||
|
freeaddrinfo(result);
|
||||||
|
if (iResult == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("bind() failed: %d\n", WSAGetLastError());
|
||||||
|
closesocket(s_listenSocket);
|
||||||
|
s_listenSocket = INVALID_SOCKET;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
iResult = listen(s_listenSocket, SOMAXCONN);
|
||||||
|
if (iResult == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("listen() failed: %d\n", WSAGetLastError());
|
||||||
|
closesocket(s_listenSocket);
|
||||||
|
s_listenSocket = INVALID_SOCKET;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_active = true;
|
||||||
|
s_connected = true;
|
||||||
|
|
||||||
|
s_acceptThread = CreateThread(NULL, 0, AcceptThreadProc, NULL, 0, NULL);
|
||||||
|
|
||||||
|
app.DebugPrintf("Win64 LAN: Hosting on port %d\n", port);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WinsockNetLayer::JoinGame(const char *ip, int port)
|
||||||
|
{
|
||||||
|
if (!s_initialized && !Initialize()) return false;
|
||||||
|
|
||||||
|
s_isHost = false;
|
||||||
|
s_hostSmallId = 0;
|
||||||
|
|
||||||
|
struct addrinfo hints = {};
|
||||||
|
struct addrinfo *result = NULL;
|
||||||
|
|
||||||
|
hints.ai_family = AF_INET;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_protocol = IPPROTO_TCP;
|
||||||
|
|
||||||
|
char portStr[16];
|
||||||
|
sprintf_s(portStr, "%d", port);
|
||||||
|
|
||||||
|
int iResult = getaddrinfo(ip, portStr, &hints, &result);
|
||||||
|
if (iResult != 0)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("getaddrinfo failed for %s:%d - %d\n", ip, port, iResult);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_hostConnectionSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
|
||||||
|
if (s_hostConnectionSocket == INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("socket() failed: %d\n", WSAGetLastError());
|
||||||
|
freeaddrinfo(result);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int noDelay = 1;
|
||||||
|
setsockopt(s_hostConnectionSocket, IPPROTO_TCP, TCP_NODELAY, (const char *)&noDelay, sizeof(noDelay));
|
||||||
|
|
||||||
|
iResult = connect(s_hostConnectionSocket, result->ai_addr, (int)result->ai_addrlen);
|
||||||
|
freeaddrinfo(result);
|
||||||
|
if (iResult == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("connect() to %s:%d failed: %d\n", ip, port, WSAGetLastError());
|
||||||
|
closesocket(s_hostConnectionSocket);
|
||||||
|
s_hostConnectionSocket = INVALID_SOCKET;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE assignBuf[1];
|
||||||
|
int bytesRecv = recv(s_hostConnectionSocket, (char *)assignBuf, 1, 0);
|
||||||
|
if (bytesRecv != 1)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Failed to receive small ID assignment from host\n");
|
||||||
|
closesocket(s_hostConnectionSocket);
|
||||||
|
s_hostConnectionSocket = INVALID_SOCKET;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s_localSmallId = assignBuf[0];
|
||||||
|
|
||||||
|
app.DebugPrintf("Win64 LAN: Connected to %s:%d, assigned smallId=%d\n", ip, port, s_localSmallId);
|
||||||
|
|
||||||
|
s_active = true;
|
||||||
|
s_connected = true;
|
||||||
|
|
||||||
|
s_clientRecvThread = CreateThread(NULL, 0, ClientRecvThreadProc, NULL, 0, NULL);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WinsockNetLayer::SendOnSocket(SOCKET sock, const void *data, int dataSize)
|
||||||
|
{
|
||||||
|
if (sock == INVALID_SOCKET || dataSize <= 0) return false;
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_sendLock);
|
||||||
|
|
||||||
|
BYTE header[4];
|
||||||
|
header[0] = (BYTE)((dataSize >> 24) & 0xFF);
|
||||||
|
header[1] = (BYTE)((dataSize >> 16) & 0xFF);
|
||||||
|
header[2] = (BYTE)((dataSize >> 8) & 0xFF);
|
||||||
|
header[3] = (BYTE)(dataSize & 0xFF);
|
||||||
|
|
||||||
|
int totalSent = 0;
|
||||||
|
int toSend = 4;
|
||||||
|
while (totalSent < toSend)
|
||||||
|
{
|
||||||
|
int sent = send(sock, (const char *)header + totalSent, toSend - totalSent, 0);
|
||||||
|
if (sent == SOCKET_ERROR || sent == 0)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&s_sendLock);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
totalSent += sent;
|
||||||
|
}
|
||||||
|
|
||||||
|
totalSent = 0;
|
||||||
|
while (totalSent < dataSize)
|
||||||
|
{
|
||||||
|
int sent = send(sock, (const char *)data + totalSent, dataSize - totalSent, 0);
|
||||||
|
if (sent == SOCKET_ERROR || sent == 0)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&s_sendLock);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
totalSent += sent;
|
||||||
|
}
|
||||||
|
|
||||||
|
LeaveCriticalSection(&s_sendLock);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WinsockNetLayer::SendToSmallId(BYTE targetSmallId, const void *data, int dataSize)
|
||||||
|
{
|
||||||
|
if (!s_active) return false;
|
||||||
|
|
||||||
|
if (s_isHost)
|
||||||
|
{
|
||||||
|
SOCKET sock = GetSocketForSmallId(targetSmallId);
|
||||||
|
if (sock == INVALID_SOCKET) return false;
|
||||||
|
return SendOnSocket(sock, data, dataSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return SendOnSocket(s_hostConnectionSocket, data, dataSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SOCKET WinsockNetLayer::GetSocketForSmallId(BYTE smallId)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
|
for (size_t i = 0; i < s_connections.size(); i++)
|
||||||
|
{
|
||||||
|
if (s_connections[i].smallId == smallId && s_connections[i].active)
|
||||||
|
{
|
||||||
|
SOCKET sock = s_connections[i].tcpSocket;
|
||||||
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
return sock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
return INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool RecvExact(SOCKET sock, BYTE *buf, int len)
|
||||||
|
{
|
||||||
|
int totalRecv = 0;
|
||||||
|
while (totalRecv < len)
|
||||||
|
{
|
||||||
|
int r = recv(sock, (char *)buf + totalRecv, len - totalRecv, 0);
|
||||||
|
if (r <= 0) return false;
|
||||||
|
totalRecv += r;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinsockNetLayer::HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, unsigned char *data, unsigned int dataSize)
|
||||||
|
{
|
||||||
|
INetworkPlayer *pPlayerFrom = g_NetworkManager.GetPlayerBySmallId(fromSmallId);
|
||||||
|
INetworkPlayer *pPlayerTo = g_NetworkManager.GetPlayerBySmallId(toSmallId);
|
||||||
|
|
||||||
|
if (pPlayerFrom == NULL || pPlayerTo == NULL) return;
|
||||||
|
|
||||||
|
if (s_isHost)
|
||||||
|
{
|
||||||
|
::Socket *pSocket = pPlayerFrom->GetSocket();
|
||||||
|
if (pSocket != NULL)
|
||||||
|
pSocket->pushDataToQueue(data, dataSize, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
::Socket *pSocket = pPlayerTo->GetSocket();
|
||||||
|
if (pSocket != NULL)
|
||||||
|
pSocket->pushDataToQueue(data, dataSize, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI WinsockNetLayer::AcceptThreadProc(LPVOID param)
|
||||||
|
{
|
||||||
|
while (s_active)
|
||||||
|
{
|
||||||
|
SOCKET clientSocket = accept(s_listenSocket, NULL, NULL);
|
||||||
|
if (clientSocket == INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
if (s_active)
|
||||||
|
app.DebugPrintf("accept() failed: %d\n", WSAGetLastError());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int noDelay = 1;
|
||||||
|
setsockopt(clientSocket, IPPROTO_TCP, TCP_NODELAY, (const char *)&noDelay, sizeof(noDelay));
|
||||||
|
|
||||||
|
extern QNET_STATE _iQNetStubState;
|
||||||
|
if (_iQNetStubState != QNET_STATE_GAME_PLAY)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Rejecting connection, game not ready\n");
|
||||||
|
closesocket(clientSocket);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE assignedSmallId;
|
||||||
|
EnterCriticalSection(&s_freeSmallIdLock);
|
||||||
|
if (!s_freeSmallIds.empty())
|
||||||
|
{
|
||||||
|
assignedSmallId = s_freeSmallIds.back();
|
||||||
|
s_freeSmallIds.pop_back();
|
||||||
|
}
|
||||||
|
else if (s_nextSmallId < MINECRAFT_NET_MAX_PLAYERS)
|
||||||
|
{
|
||||||
|
assignedSmallId = s_nextSmallId++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&s_freeSmallIdLock);
|
||||||
|
app.DebugPrintf("Win64 LAN: Server full, rejecting connection\n");
|
||||||
|
closesocket(clientSocket);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&s_freeSmallIdLock);
|
||||||
|
|
||||||
|
BYTE assignBuf[1] = { assignedSmallId };
|
||||||
|
int sent = send(clientSocket, (const char *)assignBuf, 1, 0);
|
||||||
|
if (sent != 1)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Failed to send small ID to client\n");
|
||||||
|
closesocket(clientSocket);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Win64RemoteConnection conn;
|
||||||
|
conn.tcpSocket = clientSocket;
|
||||||
|
conn.smallId = assignedSmallId;
|
||||||
|
conn.active = true;
|
||||||
|
conn.recvThread = NULL;
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
|
s_connections.push_back(conn);
|
||||||
|
int connIdx = (int)s_connections.size() - 1;
|
||||||
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
|
app.DebugPrintf("Win64 LAN: Client connected, assigned smallId=%d\n", assignedSmallId);
|
||||||
|
|
||||||
|
IQNetPlayer *qnetPlayer = &IQNet::m_player[assignedSmallId];
|
||||||
|
|
||||||
|
extern void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal);
|
||||||
|
Win64_SetupRemoteQNetPlayer(qnetPlayer, assignedSmallId, false, false);
|
||||||
|
|
||||||
|
extern CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
||||||
|
g_pPlatformNetworkManager->NotifyPlayerJoined(qnetPlayer);
|
||||||
|
|
||||||
|
DWORD *threadParam = new DWORD;
|
||||||
|
*threadParam = connIdx;
|
||||||
|
HANDLE hThread = CreateThread(NULL, 0, RecvThreadProc, threadParam, 0, NULL);
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
|
if (connIdx < (int)s_connections.size())
|
||||||
|
s_connections[connIdx].recvThread = hThread;
|
||||||
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI WinsockNetLayer::RecvThreadProc(LPVOID param)
|
||||||
|
{
|
||||||
|
DWORD connIdx = *(DWORD *)param;
|
||||||
|
delete (DWORD *)param;
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
|
if (connIdx >= (DWORD)s_connections.size())
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
SOCKET sock = s_connections[connIdx].tcpSocket;
|
||||||
|
BYTE clientSmallId = s_connections[connIdx].smallId;
|
||||||
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
|
BYTE *recvBuf = new BYTE[WIN64_NET_RECV_BUFFER_SIZE];
|
||||||
|
|
||||||
|
while (s_active)
|
||||||
|
{
|
||||||
|
BYTE header[4];
|
||||||
|
if (!RecvExact(sock, header, 4))
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Client smallId=%d disconnected (header)\n", clientSmallId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int packetSize = (header[0] << 24) | (header[1] << 16) | (header[2] << 8) | header[3];
|
||||||
|
|
||||||
|
if (packetSize <= 0 || packetSize > WIN64_NET_RECV_BUFFER_SIZE)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Invalid packet size %d from client smallId=%d\n", packetSize, clientSmallId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RecvExact(sock, recvBuf, packetSize))
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Client smallId=%d disconnected (body)\n", clientSmallId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HandleDataReceived(clientSmallId, s_hostSmallId, recvBuf, packetSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] recvBuf;
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
|
for (size_t i = 0; i < s_connections.size(); i++)
|
||||||
|
{
|
||||||
|
if (s_connections[i].smallId == clientSmallId)
|
||||||
|
{
|
||||||
|
s_connections[i].active = false;
|
||||||
|
closesocket(s_connections[i].tcpSocket);
|
||||||
|
s_connections[i].tcpSocket = INVALID_SOCKET;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_disconnectLock);
|
||||||
|
s_disconnectedSmallIds.push_back(clientSmallId);
|
||||||
|
LeaveCriticalSection(&s_disconnectLock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WinsockNetLayer::PopDisconnectedSmallId(BYTE *outSmallId)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
EnterCriticalSection(&s_disconnectLock);
|
||||||
|
if (!s_disconnectedSmallIds.empty())
|
||||||
|
{
|
||||||
|
*outSmallId = s_disconnectedSmallIds.back();
|
||||||
|
s_disconnectedSmallIds.pop_back();
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&s_disconnectLock);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinsockNetLayer::PushFreeSmallId(BYTE smallId)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&s_freeSmallIdLock);
|
||||||
|
s_freeSmallIds.push_back(smallId);
|
||||||
|
LeaveCriticalSection(&s_freeSmallIdLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI WinsockNetLayer::ClientRecvThreadProc(LPVOID param)
|
||||||
|
{
|
||||||
|
BYTE *recvBuf = new BYTE[WIN64_NET_RECV_BUFFER_SIZE];
|
||||||
|
|
||||||
|
while (s_active && s_hostConnectionSocket != INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
BYTE header[4];
|
||||||
|
if (!RecvExact(s_hostConnectionSocket, header, 4))
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Disconnected from host (header)\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int packetSize = (header[0] << 24) | (header[1] << 16) | (header[2] << 8) | header[3];
|
||||||
|
|
||||||
|
if (packetSize <= 0 || packetSize > WIN64_NET_RECV_BUFFER_SIZE)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Invalid packet size %d from host\n", packetSize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RecvExact(s_hostConnectionSocket, recvBuf, packetSize))
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Disconnected from host (body)\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HandleDataReceived(s_hostSmallId, s_localSmallId, recvBuf, packetSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] recvBuf;
|
||||||
|
|
||||||
|
s_connected = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WinsockNetLayer::StartAdvertising(int gamePort, const wchar_t *hostName, unsigned int gameSettings, unsigned int texPackId, unsigned char subTexId, unsigned short netVer)
|
||||||
|
{
|
||||||
|
if (s_advertising) return true;
|
||||||
|
if (!s_initialized) return false;
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_advertiseLock);
|
||||||
|
memset(&s_advertiseData, 0, sizeof(s_advertiseData));
|
||||||
|
s_advertiseData.magic = WIN64_LAN_BROADCAST_MAGIC;
|
||||||
|
s_advertiseData.netVersion = netVer;
|
||||||
|
s_advertiseData.gamePort = (WORD)gamePort;
|
||||||
|
wcsncpy_s(s_advertiseData.hostName, 32, hostName, _TRUNCATE);
|
||||||
|
s_advertiseData.playerCount = 1;
|
||||||
|
s_advertiseData.maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||||
|
s_advertiseData.gameHostSettings = gameSettings;
|
||||||
|
s_advertiseData.texturePackParentId = texPackId;
|
||||||
|
s_advertiseData.subTexturePackId = subTexId;
|
||||||
|
s_advertiseData.isJoinable = 0;
|
||||||
|
s_hostGamePort = gamePort;
|
||||||
|
LeaveCriticalSection(&s_advertiseLock);
|
||||||
|
|
||||||
|
s_advertiseSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
|
if (s_advertiseSock == INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Failed to create advertise socket: %d\n", WSAGetLastError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL broadcast = TRUE;
|
||||||
|
setsockopt(s_advertiseSock, SOL_SOCKET, SO_BROADCAST, (const char *)&broadcast, sizeof(broadcast));
|
||||||
|
|
||||||
|
s_advertising = true;
|
||||||
|
s_advertiseThread = CreateThread(NULL, 0, AdvertiseThreadProc, NULL, 0, NULL);
|
||||||
|
|
||||||
|
app.DebugPrintf("Win64 LAN: Started advertising on UDP port %d\n", WIN64_LAN_DISCOVERY_PORT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinsockNetLayer::StopAdvertising()
|
||||||
|
{
|
||||||
|
s_advertising = false;
|
||||||
|
|
||||||
|
if (s_advertiseSock != INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(s_advertiseSock);
|
||||||
|
s_advertiseSock = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_advertiseThread != NULL)
|
||||||
|
{
|
||||||
|
WaitForSingleObject(s_advertiseThread, 2000);
|
||||||
|
CloseHandle(s_advertiseThread);
|
||||||
|
s_advertiseThread = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinsockNetLayer::UpdateAdvertisePlayerCount(BYTE count)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&s_advertiseLock);
|
||||||
|
s_advertiseData.playerCount = count;
|
||||||
|
LeaveCriticalSection(&s_advertiseLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinsockNetLayer::UpdateAdvertiseJoinable(bool joinable)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&s_advertiseLock);
|
||||||
|
s_advertiseData.isJoinable = joinable ? 1 : 0;
|
||||||
|
LeaveCriticalSection(&s_advertiseLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI WinsockNetLayer::AdvertiseThreadProc(LPVOID param)
|
||||||
|
{
|
||||||
|
struct sockaddr_in broadcastAddr;
|
||||||
|
memset(&broadcastAddr, 0, sizeof(broadcastAddr));
|
||||||
|
broadcastAddr.sin_family = AF_INET;
|
||||||
|
broadcastAddr.sin_port = htons(WIN64_LAN_DISCOVERY_PORT);
|
||||||
|
broadcastAddr.sin_addr.s_addr = INADDR_BROADCAST;
|
||||||
|
|
||||||
|
while (s_advertising)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&s_advertiseLock);
|
||||||
|
Win64LANBroadcast data = s_advertiseData;
|
||||||
|
LeaveCriticalSection(&s_advertiseLock);
|
||||||
|
|
||||||
|
int sent = sendto(s_advertiseSock, (const char *)&data, sizeof(data), 0,
|
||||||
|
(struct sockaddr *)&broadcastAddr, sizeof(broadcastAddr));
|
||||||
|
|
||||||
|
if (sent == SOCKET_ERROR && s_advertising)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Broadcast sendto failed: %d\n", WSAGetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WinsockNetLayer::StartDiscovery()
|
||||||
|
{
|
||||||
|
if (s_discovering) return true;
|
||||||
|
if (!s_initialized) return false;
|
||||||
|
|
||||||
|
s_discoverySock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
|
if (s_discoverySock == INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Failed to create discovery socket: %d\n", WSAGetLastError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL reuseAddr = TRUE;
|
||||||
|
setsockopt(s_discoverySock, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuseAddr, sizeof(reuseAddr));
|
||||||
|
|
||||||
|
struct sockaddr_in bindAddr;
|
||||||
|
memset(&bindAddr, 0, sizeof(bindAddr));
|
||||||
|
bindAddr.sin_family = AF_INET;
|
||||||
|
bindAddr.sin_port = htons(WIN64_LAN_DISCOVERY_PORT);
|
||||||
|
bindAddr.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
||||||
|
if (::bind(s_discoverySock, (struct sockaddr *)&bindAddr, sizeof(bindAddr)) == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Discovery bind failed: %d\n", WSAGetLastError());
|
||||||
|
closesocket(s_discoverySock);
|
||||||
|
s_discoverySock = INVALID_SOCKET;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD timeout = 500;
|
||||||
|
setsockopt(s_discoverySock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout));
|
||||||
|
|
||||||
|
s_discovering = true;
|
||||||
|
s_discoveryThread = CreateThread(NULL, 0, DiscoveryThreadProc, NULL, 0, NULL);
|
||||||
|
|
||||||
|
app.DebugPrintf("Win64 LAN: Listening for LAN games on UDP port %d\n", WIN64_LAN_DISCOVERY_PORT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinsockNetLayer::StopDiscovery()
|
||||||
|
{
|
||||||
|
s_discovering = false;
|
||||||
|
|
||||||
|
if (s_discoverySock != INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(s_discoverySock);
|
||||||
|
s_discoverySock = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_discoveryThread != NULL)
|
||||||
|
{
|
||||||
|
WaitForSingleObject(s_discoveryThread, 2000);
|
||||||
|
CloseHandle(s_discoveryThread);
|
||||||
|
s_discoveryThread = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_discoveryLock);
|
||||||
|
s_discoveredSessions.clear();
|
||||||
|
LeaveCriticalSection(&s_discoveryLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Win64LANSession> WinsockNetLayer::GetDiscoveredSessions()
|
||||||
|
{
|
||||||
|
std::vector<Win64LANSession> result;
|
||||||
|
EnterCriticalSection(&s_discoveryLock);
|
||||||
|
result = s_discoveredSessions;
|
||||||
|
LeaveCriticalSection(&s_discoveryLock);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI WinsockNetLayer::DiscoveryThreadProc(LPVOID param)
|
||||||
|
{
|
||||||
|
char recvBuf[512];
|
||||||
|
|
||||||
|
while (s_discovering)
|
||||||
|
{
|
||||||
|
struct sockaddr_in senderAddr;
|
||||||
|
int senderLen = sizeof(senderAddr);
|
||||||
|
|
||||||
|
int recvLen = recvfrom(s_discoverySock, recvBuf, sizeof(recvBuf), 0,
|
||||||
|
(struct sockaddr *)&senderAddr, &senderLen);
|
||||||
|
|
||||||
|
if (recvLen == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recvLen < (int)sizeof(Win64LANBroadcast))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Win64LANBroadcast *broadcast = (Win64LANBroadcast *)recvBuf;
|
||||||
|
if (broadcast->magic != WIN64_LAN_BROADCAST_MAGIC)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
char senderIP[64];
|
||||||
|
inet_ntop(AF_INET, &senderAddr.sin_addr, senderIP, sizeof(senderIP));
|
||||||
|
|
||||||
|
DWORD now = GetTickCount();
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_discoveryLock);
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
for (size_t i = 0; i < s_discoveredSessions.size(); i++)
|
||||||
|
{
|
||||||
|
if (strcmp(s_discoveredSessions[i].hostIP, senderIP) == 0 &&
|
||||||
|
s_discoveredSessions[i].hostPort == (int)broadcast->gamePort)
|
||||||
|
{
|
||||||
|
s_discoveredSessions[i].netVersion = broadcast->netVersion;
|
||||||
|
wcsncpy_s(s_discoveredSessions[i].hostName, 32, broadcast->hostName, _TRUNCATE);
|
||||||
|
s_discoveredSessions[i].playerCount = broadcast->playerCount;
|
||||||
|
s_discoveredSessions[i].maxPlayers = broadcast->maxPlayers;
|
||||||
|
s_discoveredSessions[i].gameHostSettings = broadcast->gameHostSettings;
|
||||||
|
s_discoveredSessions[i].texturePackParentId = broadcast->texturePackParentId;
|
||||||
|
s_discoveredSessions[i].subTexturePackId = broadcast->subTexturePackId;
|
||||||
|
s_discoveredSessions[i].isJoinable = (broadcast->isJoinable != 0);
|
||||||
|
s_discoveredSessions[i].lastSeenTick = now;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
Win64LANSession session;
|
||||||
|
memset(&session, 0, sizeof(session));
|
||||||
|
strncpy_s(session.hostIP, sizeof(session.hostIP), senderIP, _TRUNCATE);
|
||||||
|
session.hostPort = (int)broadcast->gamePort;
|
||||||
|
session.netVersion = broadcast->netVersion;
|
||||||
|
wcsncpy_s(session.hostName, 32, broadcast->hostName, _TRUNCATE);
|
||||||
|
session.playerCount = broadcast->playerCount;
|
||||||
|
session.maxPlayers = broadcast->maxPlayers;
|
||||||
|
session.gameHostSettings = broadcast->gameHostSettings;
|
||||||
|
session.texturePackParentId = broadcast->texturePackParentId;
|
||||||
|
session.subTexturePackId = broadcast->subTexturePackId;
|
||||||
|
session.isJoinable = (broadcast->isJoinable != 0);
|
||||||
|
session.lastSeenTick = now;
|
||||||
|
s_discoveredSessions.push_back(session);
|
||||||
|
|
||||||
|
app.DebugPrintf("Win64 LAN: Discovered game \"%ls\" at %s:%d\n",
|
||||||
|
session.hostName, session.hostIP, session.hostPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = s_discoveredSessions.size(); i > 0; i--)
|
||||||
|
{
|
||||||
|
if (now - s_discoveredSessions[i - 1].lastSeenTick > 5000)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Win64 LAN: Session \"%ls\" at %s timed out\n",
|
||||||
|
s_discoveredSessions[i - 1].hostName, s_discoveredSessions[i - 1].hostIP);
|
||||||
|
s_discoveredSessions.erase(s_discoveredSessions.begin() + (i - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LeaveCriticalSection(&s_discoveryLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
147
Minecraft.Client/Windows64/Network/WinsockNetLayer.h
Normal file
147
Minecraft.Client/Windows64/Network/WinsockNetLayer.h
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
|
||||||
|
#include <WinSock2.h>
|
||||||
|
#include <WS2tcpip.h>
|
||||||
|
#include <vector>
|
||||||
|
#include "..\..\Common\Network\NetworkPlayerInterface.h"
|
||||||
|
|
||||||
|
#pragma comment(lib, "Ws2_32.lib")
|
||||||
|
|
||||||
|
#define WIN64_NET_DEFAULT_PORT 25565
|
||||||
|
#define WIN64_NET_MAX_CLIENTS 7
|
||||||
|
#define WIN64_NET_RECV_BUFFER_SIZE 65536
|
||||||
|
#define WIN64_LAN_DISCOVERY_PORT 25566
|
||||||
|
#define WIN64_LAN_BROADCAST_MAGIC 0x4D434C4E
|
||||||
|
|
||||||
|
class Socket;
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct Win64LANBroadcast
|
||||||
|
{
|
||||||
|
DWORD magic;
|
||||||
|
WORD netVersion;
|
||||||
|
WORD gamePort;
|
||||||
|
wchar_t hostName[32];
|
||||||
|
BYTE playerCount;
|
||||||
|
BYTE maxPlayers;
|
||||||
|
DWORD gameHostSettings;
|
||||||
|
DWORD texturePackParentId;
|
||||||
|
BYTE subTexturePackId;
|
||||||
|
BYTE isJoinable;
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
struct Win64LANSession
|
||||||
|
{
|
||||||
|
char hostIP[64];
|
||||||
|
int hostPort;
|
||||||
|
wchar_t hostName[32];
|
||||||
|
unsigned short netVersion;
|
||||||
|
unsigned char playerCount;
|
||||||
|
unsigned char maxPlayers;
|
||||||
|
unsigned int gameHostSettings;
|
||||||
|
unsigned int texturePackParentId;
|
||||||
|
unsigned char subTexturePackId;
|
||||||
|
bool isJoinable;
|
||||||
|
DWORD lastSeenTick;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Win64RemoteConnection
|
||||||
|
{
|
||||||
|
SOCKET tcpSocket;
|
||||||
|
BYTE smallId;
|
||||||
|
HANDLE recvThread;
|
||||||
|
volatile bool active;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WinsockNetLayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool Initialize();
|
||||||
|
static void Shutdown();
|
||||||
|
|
||||||
|
static bool HostGame(int port);
|
||||||
|
static bool JoinGame(const char *ip, int port);
|
||||||
|
|
||||||
|
static bool SendToSmallId(BYTE targetSmallId, const void *data, int dataSize);
|
||||||
|
static bool SendOnSocket(SOCKET sock, const void *data, int dataSize);
|
||||||
|
|
||||||
|
static bool IsHosting() { return s_isHost; }
|
||||||
|
static bool IsConnected() { return s_connected; }
|
||||||
|
static bool IsActive() { return s_active; }
|
||||||
|
|
||||||
|
static BYTE GetLocalSmallId() { return s_localSmallId; }
|
||||||
|
static BYTE GetHostSmallId() { return s_hostSmallId; }
|
||||||
|
|
||||||
|
static SOCKET GetSocketForSmallId(BYTE smallId);
|
||||||
|
|
||||||
|
static void HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, unsigned char *data, unsigned int dataSize);
|
||||||
|
|
||||||
|
static bool PopDisconnectedSmallId(BYTE *outSmallId);
|
||||||
|
static void PushFreeSmallId(BYTE smallId);
|
||||||
|
|
||||||
|
static bool StartAdvertising(int gamePort, const wchar_t *hostName, unsigned int gameSettings, unsigned int texPackId, unsigned char subTexId, unsigned short netVer);
|
||||||
|
static void StopAdvertising();
|
||||||
|
static void UpdateAdvertisePlayerCount(BYTE count);
|
||||||
|
static void UpdateAdvertiseJoinable(bool joinable);
|
||||||
|
|
||||||
|
static bool StartDiscovery();
|
||||||
|
static void StopDiscovery();
|
||||||
|
static std::vector<Win64LANSession> GetDiscoveredSessions();
|
||||||
|
|
||||||
|
static int GetHostPort() { return s_hostGamePort; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
static DWORD WINAPI AcceptThreadProc(LPVOID param);
|
||||||
|
static DWORD WINAPI RecvThreadProc(LPVOID param);
|
||||||
|
static DWORD WINAPI ClientRecvThreadProc(LPVOID param);
|
||||||
|
static DWORD WINAPI AdvertiseThreadProc(LPVOID param);
|
||||||
|
static DWORD WINAPI DiscoveryThreadProc(LPVOID param);
|
||||||
|
|
||||||
|
static SOCKET s_listenSocket;
|
||||||
|
static SOCKET s_hostConnectionSocket;
|
||||||
|
static HANDLE s_acceptThread;
|
||||||
|
static HANDLE s_clientRecvThread;
|
||||||
|
|
||||||
|
static bool s_isHost;
|
||||||
|
static bool s_connected;
|
||||||
|
static bool s_active;
|
||||||
|
static bool s_initialized;
|
||||||
|
|
||||||
|
static BYTE s_localSmallId;
|
||||||
|
static BYTE s_hostSmallId;
|
||||||
|
static BYTE s_nextSmallId;
|
||||||
|
|
||||||
|
static CRITICAL_SECTION s_sendLock;
|
||||||
|
static CRITICAL_SECTION s_connectionsLock;
|
||||||
|
|
||||||
|
static std::vector<Win64RemoteConnection> s_connections;
|
||||||
|
|
||||||
|
static SOCKET s_advertiseSock;
|
||||||
|
static HANDLE s_advertiseThread;
|
||||||
|
static volatile bool s_advertising;
|
||||||
|
static Win64LANBroadcast s_advertiseData;
|
||||||
|
static CRITICAL_SECTION s_advertiseLock;
|
||||||
|
static int s_hostGamePort;
|
||||||
|
|
||||||
|
static SOCKET s_discoverySock;
|
||||||
|
static HANDLE s_discoveryThread;
|
||||||
|
static volatile bool s_discovering;
|
||||||
|
static CRITICAL_SECTION s_discoveryLock;
|
||||||
|
static std::vector<Win64LANSession> s_discoveredSessions;
|
||||||
|
|
||||||
|
static CRITICAL_SECTION s_disconnectLock;
|
||||||
|
static std::vector<BYTE> s_disconnectedSmallIds;
|
||||||
|
|
||||||
|
static CRITICAL_SECTION s_freeSmallIdLock;
|
||||||
|
static std::vector<BYTE> s_freeSmallIds;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern bool g_Win64MultiplayerHost;
|
||||||
|
extern bool g_Win64MultiplayerJoin;
|
||||||
|
extern int g_Win64MultiplayerPort;
|
||||||
|
extern char g_Win64MultiplayerIP[256];
|
||||||
|
|
||||||
|
#endif
|
||||||
Binary file not shown.
|
|
@ -10,11 +10,46 @@
|
||||||
#include "..\..\Minecraft.World\BiomeSource.h"
|
#include "..\..\Minecraft.World\BiomeSource.h"
|
||||||
#include "..\..\Minecraft.World\LevelType.h"
|
#include "..\..\Minecraft.World\LevelType.h"
|
||||||
|
|
||||||
|
wstring g_playerName;
|
||||||
|
|
||||||
CConsoleMinecraftApp app;
|
CConsoleMinecraftApp app;
|
||||||
|
|
||||||
|
static void LoadPlayerName()
|
||||||
|
{
|
||||||
|
if (!g_playerName.empty()) return;
|
||||||
|
g_playerName = L"Windows";
|
||||||
|
|
||||||
|
char exePath[MAX_PATH] = {};
|
||||||
|
GetModuleFileNameA(NULL, exePath, MAX_PATH);
|
||||||
|
char *lastSlash = strrchr(exePath, '\\');
|
||||||
|
if (lastSlash) *(lastSlash + 1) = '\0';
|
||||||
|
char filePath[MAX_PATH] = {};
|
||||||
|
_snprintf_s(filePath, sizeof(filePath), _TRUNCATE, "%susername.txt", exePath);
|
||||||
|
|
||||||
|
FILE *f = NULL;
|
||||||
|
if (fopen_s(&f, filePath, "r") == 0 && f)
|
||||||
|
{
|
||||||
|
char buf[128] = {};
|
||||||
|
if (fgets(buf, sizeof(buf), f))
|
||||||
|
{
|
||||||
|
int len = (int)strlen(buf);
|
||||||
|
while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r' || buf[len-1] == ' '))
|
||||||
|
buf[--len] = '\0';
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
|
wchar_t wbuf[128] = {};
|
||||||
|
mbstowcs(wbuf, buf, 127);
|
||||||
|
g_playerName = wbuf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp()
|
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp()
|
||||||
{
|
{
|
||||||
m_bShutdown = false;
|
m_bShutdown = false;
|
||||||
|
LoadPlayerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId)
|
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId)
|
||||||
|
|
@ -35,9 +70,27 @@ void CConsoleMinecraftApp::FatalLoadError()
|
||||||
|
|
||||||
void CConsoleMinecraftApp::CaptureSaveThumbnail()
|
void CConsoleMinecraftApp::CaptureSaveThumbnail()
|
||||||
{
|
{
|
||||||
|
RenderManager.CaptureThumbnail(&m_ThumbnailBuffer);
|
||||||
}
|
}
|
||||||
void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize)
|
void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize)
|
||||||
{
|
{
|
||||||
|
// On a save caused by a create world, the thumbnail capture won't have happened
|
||||||
|
if (m_ThumbnailBuffer.Allocated())
|
||||||
|
{
|
||||||
|
if (pbData)
|
||||||
|
{
|
||||||
|
*pbData = new BYTE[m_ThumbnailBuffer.GetBufferSize()];
|
||||||
|
*pdwSize = m_ThumbnailBuffer.GetBufferSize();
|
||||||
|
memcpy(*pbData, m_ThumbnailBuffer.GetBufferPointer(), *pdwSize);
|
||||||
|
}
|
||||||
|
m_ThumbnailBuffer.Release();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No capture happened (e.g. first save on world creation) leave thumbnail as NULL
|
||||||
|
if (pbData) *pbData = NULL;
|
||||||
|
if (pdwSize) *pdwSize = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void CConsoleMinecraftApp::ReleaseSaveThumbnail()
|
void CConsoleMinecraftApp::ReleaseSaveThumbnail()
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +110,8 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
||||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||||
app.ReleaseSaveThumbnail();
|
app.ReleaseSaveThumbnail();
|
||||||
ProfileManager.SetLockedProfile(0);
|
ProfileManager.SetLockedProfile(0);
|
||||||
pMinecraft->user->name = L"Windows";
|
LoadPlayerName();
|
||||||
|
pMinecraft->user->name = g_playerName;
|
||||||
app.ApplyGameSettingsChanged(0);
|
app.ApplyGameSettingsChanged(0);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit
|
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "4JLibs\inc\4J_Render.h"
|
||||||
|
|
||||||
class CConsoleMinecraftApp : public CMinecraftApp
|
class CConsoleMinecraftApp : public CMinecraftApp
|
||||||
{
|
{
|
||||||
|
ImageFileBuffer m_ThumbnailBuffer;
|
||||||
public:
|
public:
|
||||||
CConsoleMinecraftApp();
|
CConsoleMinecraftApp();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "..\..\Minecraft.World\compression.h"
|
#include "..\..\Minecraft.World\compression.h"
|
||||||
#include "..\..\Minecraft.World\OldChunkStorage.h"
|
#include "..\..\Minecraft.World\OldChunkStorage.h"
|
||||||
|
#include "Network\WinsockNetLayer.h"
|
||||||
|
|
||||||
#include "Xbox/resource.h"
|
#include "Xbox/resource.h"
|
||||||
|
|
||||||
|
|
@ -84,6 +85,11 @@ BOOL g_bWidescreen = TRUE;
|
||||||
int g_iScreenWidth = 1920;
|
int g_iScreenWidth = 1920;
|
||||||
int g_iScreenHeight = 1080;
|
int g_iScreenHeight = 1080;
|
||||||
|
|
||||||
|
char g_Win64Username[17] = { 0 };
|
||||||
|
wchar_t g_Win64UsernameW[17] = { 0 };
|
||||||
|
UINT g_ScreenWidth = 1920;
|
||||||
|
UINT g_ScreenHeight = 1080;
|
||||||
|
|
||||||
// Fullscreen toggle state
|
// Fullscreen toggle state
|
||||||
static bool g_isFullscreen = false;
|
static bool g_isFullscreen = false;
|
||||||
static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
|
static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
|
||||||
|
|
@ -723,20 +729,6 @@ void CleanupDevice()
|
||||||
if( g_pd3dDevice ) g_pd3dDevice->Release();
|
if( g_pd3dDevice ) g_pd3dDevice->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef HRESULT(__stdcall* SetProcessDpiAwareness_f)(PROCESS_DPI_AWARENESS);
|
|
||||||
static HRESULT dyn_SetProcessDpiAwareness(PROCESS_DPI_AWARENESS value)
|
|
||||||
{
|
|
||||||
static const auto ptr = reinterpret_cast<SetProcessDpiAwareness_f>(
|
|
||||||
reinterpret_cast<void*>(::GetProcAddress(static_cast<HMODULE>(LoadLibraryExW(L"Shcore.dll", nullptr, 0)), "SetProcessDpiAwareness")));
|
|
||||||
if (ptr == nullptr)
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ptr(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
_In_opt_ HINSTANCE hPrevInstance,
|
_In_opt_ HINSTANCE hPrevInstance,
|
||||||
_In_ LPTSTR lpCmdLine,
|
_In_ LPTSTR lpCmdLine,
|
||||||
|
|
@ -745,7 +737,16 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
|
|
||||||
dyn_SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
|
// 4J-Win64: set CWD to exe dir so asset paths resolve correctly
|
||||||
|
{
|
||||||
|
char szExeDir[MAX_PATH] = {};
|
||||||
|
GetModuleFileNameA(NULL, szExeDir, MAX_PATH);
|
||||||
|
char *pSlash = strrchr(szExeDir, '\\');
|
||||||
|
if (pSlash) { *(pSlash + 1) = '\0'; SetCurrentDirectoryA(szExeDir); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Declare DPI awareness so GetSystemMetrics returns physical pixels
|
||||||
|
SetProcessDPIAware();
|
||||||
g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
|
g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||||
g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN);
|
g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
|
||||||
|
|
@ -771,8 +772,41 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
//g_iScreenWidth = 960;
|
//g_iScreenWidth = 960;
|
||||||
//g_iScreenHeight = 544;
|
//g_iScreenHeight = 544;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char cmdLineA[1024];
|
||||||
|
strncpy_s(cmdLineA, sizeof(cmdLineA), lpCmdLine, _TRUNCATE);
|
||||||
|
|
||||||
|
char* nameArg = strstr(cmdLineA, "-name ");
|
||||||
|
if (nameArg)
|
||||||
|
{
|
||||||
|
nameArg += 6;
|
||||||
|
while (*nameArg == ' ') nameArg++;
|
||||||
|
char nameBuf[17];
|
||||||
|
int n = 0;
|
||||||
|
while (nameArg[n] && nameArg[n] != ' ' && n < 16) { nameBuf[n] = nameArg[n]; n++; }
|
||||||
|
nameBuf[n] = 0;
|
||||||
|
strncpy_s(g_Win64Username, 17, nameBuf, _TRUNCATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_Win64Username[0] == 0)
|
||||||
|
{
|
||||||
|
DWORD sz = 17;
|
||||||
|
static bool seeded = false;
|
||||||
|
if (!seeded)
|
||||||
|
{
|
||||||
|
seeded = true;
|
||||||
|
srand((unsigned int)time(NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
int r = rand() % 10000; // 0<>9999
|
||||||
|
|
||||||
|
snprintf(g_Win64Username, 17, "Player%04d", r);
|
||||||
|
|
||||||
|
g_Win64Username[16] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, g_Win64Username, -1, g_Win64UsernameW, 17);
|
||||||
|
|
||||||
// Initialize global strings
|
// Initialize global strings
|
||||||
MyRegisterClass(hInstance);
|
MyRegisterClass(hInstance);
|
||||||
|
|
@ -938,7 +972,17 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
// ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet.
|
// ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet.
|
||||||
g_NetworkManager.Initialise();
|
g_NetworkManager.Initialise();
|
||||||
|
|
||||||
|
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||||
|
{
|
||||||
|
IQNet::m_player[i].m_smallId = (BYTE)i;
|
||||||
|
IQNet::m_player[i].m_isRemote = false;
|
||||||
|
IQNet::m_player[i].m_isHostPlayer = (i == 0);
|
||||||
|
swprintf_s(IQNet::m_player[i].m_gamertag, 32, L"Player%d", i);
|
||||||
|
}
|
||||||
|
extern wchar_t g_Win64UsernameW[17];
|
||||||
|
wcscpy_s(IQNet::m_player[0].m_gamertag, 32, g_Win64UsernameW);
|
||||||
|
|
||||||
|
WinsockNetLayer::Initialize();
|
||||||
|
|
||||||
// 4J-PB moved further down
|
// 4J-PB moved further down
|
||||||
//app.InitGameSettings();
|
//app.InitGameSettings();
|
||||||
|
|
@ -1110,7 +1154,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|
||||||
PIXBeginNamedEvent(0,"Network manager do work #1");
|
PIXBeginNamedEvent(0,"Network manager do work #1");
|
||||||
// g_NetworkManager.DoWork();
|
g_NetworkManager.DoWork();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|
||||||
// LeaderboardManager::Instance()->Tick();
|
// LeaderboardManager::Instance()->Tick();
|
||||||
|
|
@ -1236,19 +1280,34 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// F11 toggles fullscreen
|
// F3 toggles the debug console overlay, F11 toggles fullscreen
|
||||||
|
if (KMInput.IsKeyPressed(VK_F3))
|
||||||
|
{
|
||||||
|
static bool s_debugConsole = false;
|
||||||
|
s_debugConsole = !s_debugConsole;
|
||||||
|
ui.ShowUIDebugConsole(s_debugConsole);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _DEBUG_MENUS_ENABLED
|
||||||
|
if (KMInput.IsKeyPressed(VK_F4))
|
||||||
|
{
|
||||||
|
ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_DebugOverlay, NULL, eUILayer_Debug);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (KMInput.IsKeyPressed(VK_F11))
|
if (KMInput.IsKeyPressed(VK_F11))
|
||||||
{
|
{
|
||||||
ToggleFullscreen();
|
ToggleFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TAB opens host options menu. - Vvis :3
|
// TAB opens game info menu. - Vvis :3 - Updated by detectiveren
|
||||||
if (KMInput.IsKeyPressed(VK_TAB) && !ui.GetMenuDisplayed(0))
|
if (KMInput.IsKeyPressed(VK_TAB) && !ui.GetMenuDisplayed(0))
|
||||||
{
|
{
|
||||||
if (Minecraft* pMinecraft = Minecraft::GetInstance())
|
if (Minecraft* pMinecraft = Minecraft::GetInstance())
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
ui.NavigateToScene(0, eUIScene_InGameHostOptionsMenu);
|
ui.NavigateToScene(0, eUIScene_InGameInfoMenu);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ ArmorSlot::ArmorSlot(int slotNum, shared_ptr<Container> container, int id, int x
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int ArmorSlot::getMaxStackSize()
|
int ArmorSlot::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public:
|
||||||
ArmorSlot(int slotNum, shared_ptr<Container> container, int id, int x, int y);
|
ArmorSlot(int slotNum, shared_ptr<Container> container, int id, int x, int y);
|
||||||
virtual ~ArmorSlot() {}
|
virtual ~ArmorSlot() {}
|
||||||
|
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual bool mayPlace(shared_ptr<ItemInstance> item);
|
virtual bool mayPlace(shared_ptr<ItemInstance> item);
|
||||||
Icon *getNoItemIcon();
|
Icon *getNoItemIcon();
|
||||||
//virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
|
//virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ bool BeaconMenu::PaymentSlot::mayPlace(shared_ptr<ItemInstance> item)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BeaconMenu::PaymentSlot::getMaxStackSize()
|
int BeaconMenu::PaymentSlot::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ private:
|
||||||
PaymentSlot(shared_ptr<Container> container, int slot, int x, int y);
|
PaymentSlot(shared_ptr<Container> container, int slot, int x, int y);
|
||||||
|
|
||||||
bool mayPlace(shared_ptr<ItemInstance> item);
|
bool mayPlace(shared_ptr<ItemInstance> item);
|
||||||
int getMaxStackSize();
|
int getMaxStackSize() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,7 @@ void BeaconTileEntity::setCustomName(const wstring &name)
|
||||||
this->name = name;
|
this->name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BeaconTileEntity::getMaxStackSize()
|
int BeaconTileEntity::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ public:
|
||||||
wstring getCustomName();
|
wstring getCustomName();
|
||||||
bool hasCustomName();
|
bool hasCustomName();
|
||||||
void setCustomName(const wstring &name);
|
void setCustomName(const wstring &name);
|
||||||
int getMaxStackSize();
|
int getMaxStackSize() const;
|
||||||
bool stillValid(shared_ptr<Player> player);
|
bool stillValid(shared_ptr<Player> player);
|
||||||
void startOpen();
|
void startOpen();
|
||||||
void stopOpen();
|
void stopOpen();
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ bool BrewingStandMenu::PotionSlot::mayPlace(shared_ptr<ItemInstance> item)
|
||||||
return mayPlaceItem(item);
|
return mayPlaceItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BrewingStandMenu::PotionSlot::getMaxStackSize()
|
int BrewingStandMenu::PotionSlot::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +231,7 @@ bool BrewingStandMenu::IngredientsSlot::mayCombine(shared_ptr<ItemInstance> seco
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BrewingStandMenu::IngredientsSlot::getMaxStackSize()
|
int BrewingStandMenu::IngredientsSlot::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ private:
|
||||||
PotionSlot(shared_ptr<Player> player, shared_ptr<Container> container, int slot, int x, int y);
|
PotionSlot(shared_ptr<Player> player, shared_ptr<Container> container, int slot, int x, int y);
|
||||||
|
|
||||||
virtual bool mayPlace(shared_ptr<ItemInstance> item);
|
virtual bool mayPlace(shared_ptr<ItemInstance> item);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual void onTake(shared_ptr<Player> player, shared_ptr<ItemInstance> carried);
|
virtual void onTake(shared_ptr<Player> player, shared_ptr<ItemInstance> carried);
|
||||||
static bool mayPlaceItem(shared_ptr<ItemInstance> item);
|
static bool mayPlaceItem(shared_ptr<ItemInstance> item);
|
||||||
virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
|
virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
|
||||||
|
|
@ -59,7 +59,7 @@ private:
|
||||||
IngredientsSlot(shared_ptr<Container> container, int slot, int x, int y);
|
IngredientsSlot(shared_ptr<Container> container, int slot, int x, int y);
|
||||||
|
|
||||||
virtual bool mayPlace(shared_ptr<ItemInstance> item);
|
virtual bool mayPlace(shared_ptr<ItemInstance> item);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
|
virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -397,7 +397,7 @@ void BrewingStandTileEntity::setItem(unsigned int slot, shared_ptr<ItemInstance>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int BrewingStandTileEntity::getMaxStackSize()
|
int BrewingStandTileEntity::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
// this value is not used for the potion slots
|
// this value is not used for the potion slots
|
||||||
return 64;
|
return 64;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public:
|
||||||
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i);
|
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i);
|
||||||
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
||||||
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual bool stillValid(shared_ptr<Player> player);
|
virtual bool stillValid(shared_ptr<Player> player);
|
||||||
virtual void startOpen();
|
virtual void startOpen();
|
||||||
virtual void stopOpen();
|
virtual void stopOpen();
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ void ChestTileEntity::save(CompoundTag *base)
|
||||||
base->putBoolean(L"bonus", isBonusChest);
|
base->putBoolean(L"bonus", isBonusChest);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ChestTileEntity::getMaxStackSize()
|
int ChestTileEntity::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return Container::LARGE_MAX_STACK_SIZE;
|
return Container::LARGE_MAX_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public:
|
||||||
virtual void setCustomName(const wstring &name);
|
virtual void setCustomName(const wstring &name);
|
||||||
virtual void load(CompoundTag *base);
|
virtual void load(CompoundTag *base);
|
||||||
virtual void save(CompoundTag *base);
|
virtual void save(CompoundTag *base);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual bool stillValid(shared_ptr<Player> player);
|
virtual bool stillValid(shared_ptr<Player> player);
|
||||||
virtual void setChanged();
|
virtual void setChanged();
|
||||||
virtual void clearCache();
|
virtual void clearCache();
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ void CompoundContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item
|
||||||
else c1->setItem(slot, item);
|
else c1->setItem(slot, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CompoundContainer::getMaxStackSize()
|
int CompoundContainer::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return c1->getMaxStackSize();
|
return c1->getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public:
|
||||||
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i);
|
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i);
|
||||||
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
||||||
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual void setChanged();
|
virtual void setChanged();
|
||||||
virtual bool stillValid(shared_ptr<Player> player);
|
virtual bool stillValid(shared_ptr<Player> player);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public:
|
||||||
virtual wstring getName() = 0;
|
virtual wstring getName() = 0;
|
||||||
virtual wstring getCustomName() = 0; // 4J Stu added for sending over the network
|
virtual wstring getCustomName() = 0; // 4J Stu added for sending over the network
|
||||||
virtual bool hasCustomName() = 0;
|
virtual bool hasCustomName() = 0;
|
||||||
virtual int getMaxStackSize() = 0;
|
virtual int getMaxStackSize() const = 0;
|
||||||
virtual void setChanged() = 0;
|
virtual void setChanged() = 0;
|
||||||
virtual bool stillValid(shared_ptr<Player> player) = 0;
|
virtual bool stillValid(shared_ptr<Player> player) = 0;
|
||||||
virtual void startOpen() = 0;
|
virtual void startOpen() = 0;
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ void CraftingContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item
|
||||||
if(menu) menu->slotsChanged();
|
if(menu) menu->slotsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CraftingContainer::getMaxStackSize()
|
int CraftingContainer::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return Container::LARGE_MAX_STACK_SIZE;
|
return Container::LARGE_MAX_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public:
|
||||||
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
||||||
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
|
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
|
||||||
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual void setChanged();
|
virtual void setChanged();
|
||||||
bool stillValid(shared_ptr<Player> player);
|
bool stillValid(shared_ptr<Player> player);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ void DispenserTileEntity::save(CompoundTag *base)
|
||||||
if (hasCustomName()) base->putString(L"CustomName", name);
|
if (hasCustomName()) base->putString(L"CustomName", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DispenserTileEntity::getMaxStackSize()
|
int DispenserTileEntity::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return Container::LARGE_MAX_STACK_SIZE;
|
return Container::LARGE_MAX_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public:
|
||||||
virtual bool hasCustomName();
|
virtual bool hasCustomName();
|
||||||
virtual void load(CompoundTag *base);
|
virtual void load(CompoundTag *base);
|
||||||
virtual void save(CompoundTag *base);
|
virtual void save(CompoundTag *base);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual bool stillValid(shared_ptr<Player> player);
|
virtual bool stillValid(shared_ptr<Player> player);
|
||||||
virtual void setChanged();
|
virtual void setChanged();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ EnchantmentContainer::EnchantmentContainer(EnchantmentMenu *menu) : SimpleContai
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int EnchantmentContainer::getMaxStackSize()
|
int EnchantmentContainer::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ private:
|
||||||
EnchantmentMenu *m_menu;
|
EnchantmentMenu *m_menu;
|
||||||
public:
|
public:
|
||||||
EnchantmentContainer(EnchantmentMenu *menu);
|
EnchantmentContainer(EnchantmentMenu *menu);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual void setChanged();
|
virtual void setChanged();
|
||||||
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
|
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
|
||||||
};
|
};
|
||||||
|
|
@ -1468,25 +1468,17 @@ void Entity::onLoadedFromSave()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag<DoubleTag> *Entity::newDoubleList(unsigned int number, double firstValue, ...)
|
template<typename ...Args>
|
||||||
|
ListTag<DoubleTag> *Entity::newDoubleList(unsigned int, double firstValue, Args... args)
|
||||||
{
|
{
|
||||||
ListTag<DoubleTag> *res = new ListTag<DoubleTag>();
|
ListTag<DoubleTag> *res = new ListTag<DoubleTag>();
|
||||||
|
|
||||||
// Add the first parameter to the ListTag
|
// Add the first parameter to the ListTag
|
||||||
res->add( new DoubleTag(L"", firstValue ) );
|
res->add( new DoubleTag(L"", firstValue ) );
|
||||||
|
|
||||||
va_list vl;
|
// use pre-C++17 fold trick (TODO: once we drop C++14 support, use C++14 fold expression)
|
||||||
va_start(vl,firstValue);
|
using expander = int[];
|
||||||
|
(void)expander{0, (res->add(new DoubleTag(L"", static_cast<double>(args))), 0)...};
|
||||||
double val;
|
|
||||||
|
|
||||||
for (unsigned int i=1;i<number;i++)
|
|
||||||
{
|
|
||||||
val=va_arg(vl,double);
|
|
||||||
res->add(new DoubleTag(L"", val));
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(vl);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,8 @@ public:
|
||||||
virtual void onLoadedFromSave();
|
virtual void onLoadedFromSave();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ListTag<DoubleTag> *newDoubleList(unsigned int number, double firstValue, ...);
|
template<typename ...Args>
|
||||||
|
ListTag<DoubleTag> *newDoubleList(unsigned int, double firstValue, Args... args);
|
||||||
ListTag<FloatTag> *newFloatList(unsigned int number, float firstValue, float secondValue);
|
ListTag<FloatTag> *newFloatList(unsigned int number, float firstValue, float secondValue);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ void FurnaceTileEntity::save(CompoundTag *base)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int FurnaceTileEntity::getMaxStackSize()
|
int FurnaceTileEntity::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return Container::LARGE_MAX_STACK_SIZE;
|
return Container::LARGE_MAX_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
@ -250,7 +250,7 @@ void FurnaceTileEntity::tick()
|
||||||
bool FurnaceTileEntity::canBurn()
|
bool FurnaceTileEntity::canBurn()
|
||||||
{
|
{
|
||||||
if (items[SLOT_INPUT] == NULL) return false;
|
if (items[SLOT_INPUT] == NULL) return false;
|
||||||
ItemInstance *burnResult = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
|
const ItemInstance *burnResult = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
|
||||||
if (burnResult == NULL) return false;
|
if (burnResult == NULL) return false;
|
||||||
if (items[SLOT_RESULT] == NULL) return true;
|
if (items[SLOT_RESULT] == NULL) return true;
|
||||||
if (!items[SLOT_RESULT]->sameItem_not_shared(burnResult)) return false;
|
if (!items[SLOT_RESULT]->sameItem_not_shared(burnResult)) return false;
|
||||||
|
|
@ -264,7 +264,7 @@ void FurnaceTileEntity::burn()
|
||||||
{
|
{
|
||||||
if (!canBurn()) return;
|
if (!canBurn()) return;
|
||||||
|
|
||||||
ItemInstance *result = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
|
const ItemInstance *result = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
|
||||||
if (items[SLOT_RESULT] == NULL) items[SLOT_RESULT] = result->copy();
|
if (items[SLOT_RESULT] == NULL) items[SLOT_RESULT] = result->copy();
|
||||||
else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++;
|
else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public:
|
||||||
virtual void setCustomName(const wstring &name);
|
virtual void setCustomName(const wstring &name);
|
||||||
virtual void load(CompoundTag *base);
|
virtual void load(CompoundTag *base);
|
||||||
virtual void save(CompoundTag *base);
|
virtual void save(CompoundTag *base);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
int getBurnProgress(int max);
|
int getBurnProgress(int max);
|
||||||
int getLitProgress(int max);
|
int getLitProgress(int max);
|
||||||
bool isLit();
|
bool isLit();
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ void HopperTileEntity::setCustomName(const wstring &name)
|
||||||
this->name = name;
|
this->name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int HopperTileEntity::getMaxStackSize()
|
int HopperTileEntity::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return Container::LARGE_MAX_STACK_SIZE;
|
return Container::LARGE_MAX_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public:
|
||||||
virtual wstring getCustomName();
|
virtual wstring getCustomName();
|
||||||
virtual bool hasCustomName();
|
virtual bool hasCustomName();
|
||||||
virtual void setCustomName(const wstring &name);
|
virtual void setCustomName(const wstring &name);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual bool stillValid(shared_ptr<Player> player);
|
virtual bool stillValid(shared_ptr<Player> player);
|
||||||
virtual void startOpen();
|
virtual void startOpen();
|
||||||
virtual void stopOpen();
|
virtual void stopOpen();
|
||||||
|
|
|
||||||
|
|
@ -3,20 +3,3 @@
|
||||||
#include "I18n.h"
|
#include "I18n.h"
|
||||||
|
|
||||||
Language *I18n::lang = Language::getInstance();
|
Language *I18n::lang = Language::getInstance();
|
||||||
wstring I18n::get(const wstring& id, ...)
|
|
||||||
{
|
|
||||||
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
|
|
||||||
return L"";
|
|
||||||
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
|
|
||||||
return id;
|
|
||||||
#else
|
|
||||||
va_list va;
|
|
||||||
va_start(va, id);
|
|
||||||
return I18n::get(id, va);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
wstring I18n::get(const wstring& id, va_list args)
|
|
||||||
{
|
|
||||||
return lang->getElement(id, args);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ private:
|
||||||
static Language *lang;
|
static Language *lang;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static wstring get(const wstring& id, ...);
|
template<typename ...Args>
|
||||||
static wstring get(const wstring& id, va_list args);
|
static wstring get(Args... args)
|
||||||
|
{
|
||||||
|
return lang->getElement(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -592,7 +592,7 @@ bool Inventory::hasCustomName()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Inventory::getMaxStackSize()
|
int Inventory::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return MAX_INVENTORY_STACK_SIZE;
|
return MAX_INVENTORY_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ public:
|
||||||
wstring getName();
|
wstring getName();
|
||||||
wstring getCustomName();
|
wstring getCustomName();
|
||||||
bool hasCustomName();
|
bool hasCustomName();
|
||||||
int getMaxStackSize();
|
int getMaxStackSize() const;
|
||||||
bool canDestroy(Tile *tile);
|
bool canDestroy(Tile *tile);
|
||||||
shared_ptr<ItemInstance> getArmor(int layer);
|
shared_ptr<ItemInstance> getArmor(int layer);
|
||||||
int getArmorValue();
|
int getArmorValue();
|
||||||
|
|
|
||||||
|
|
@ -668,7 +668,7 @@ shared_ptr<ItemInstance> Item::useTimeDepleted(shared_ptr<ItemInstance> itemInst
|
||||||
return itemInstance;
|
return itemInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Item::getMaxStackSize()
|
int Item::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return maxStackSize;
|
return maxStackSize;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -668,7 +668,7 @@ public:
|
||||||
virtual bool TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
|
virtual bool TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
|
||||||
virtual shared_ptr<ItemInstance> use(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
|
virtual shared_ptr<ItemInstance> use(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
|
||||||
virtual shared_ptr<ItemInstance> useTimeDepleted(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
|
virtual shared_ptr<ItemInstance> useTimeDepleted(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual int getLevelDataForAuxValue(int auxValue);
|
virtual int getLevelDataForAuxValue(int auxValue);
|
||||||
bool isStackedByData();
|
bool isStackedByData();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ void ItemInstance::load(CompoundTag *compoundTag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ItemInstance::getMaxStackSize()
|
int ItemInstance::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return getItem()->getMaxStackSize();
|
return getItem()->getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
@ -393,7 +393,7 @@ bool ItemInstance::sameItemWithTags(shared_ptr<ItemInstance> b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Stu - Added this for the one time when we compare with a non-shared pointer
|
// 4J Stu - Added this for the one time when we compare with a non-shared pointer
|
||||||
bool ItemInstance::sameItem_not_shared(ItemInstance *b)
|
bool ItemInstance::sameItem_not_shared(const ItemInstance *b)
|
||||||
{
|
{
|
||||||
return id == b->id && auxValue == b->auxValue;
|
return id == b->id && auxValue == b->auxValue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ public:
|
||||||
shared_ptr<ItemInstance> useTimeDepleted(Level *level, shared_ptr<Player> player);
|
shared_ptr<ItemInstance> useTimeDepleted(Level *level, shared_ptr<Player> player);
|
||||||
CompoundTag *save(CompoundTag *compoundTag);
|
CompoundTag *save(CompoundTag *compoundTag);
|
||||||
void load(CompoundTag *compoundTag);
|
void load(CompoundTag *compoundTag);
|
||||||
int getMaxStackSize();
|
int getMaxStackSize() const;
|
||||||
bool isStackable();
|
bool isStackable();
|
||||||
bool isDamageableItem();
|
bool isDamageableItem();
|
||||||
bool isStackedByData();
|
bool isStackedByData();
|
||||||
|
|
@ -113,7 +113,7 @@ private:
|
||||||
public:
|
public:
|
||||||
bool sameItem(shared_ptr<ItemInstance> b);
|
bool sameItem(shared_ptr<ItemInstance> b);
|
||||||
bool sameItemWithTags(shared_ptr<ItemInstance> b); //4J Added
|
bool sameItemWithTags(shared_ptr<ItemInstance> b); //4J Added
|
||||||
bool sameItem_not_shared(ItemInstance *b); // 4J Stu - Added this for the one time I need it
|
bool sameItem_not_shared(const ItemInstance *b); // 4J Stu - Added this for the one time I need it
|
||||||
virtual unsigned int getUseDescriptionId(); // 4J Added
|
virtual unsigned int getUseDescriptionId(); // 4J Added
|
||||||
virtual unsigned int getDescriptionId(int iData = -1);
|
virtual unsigned int getDescriptionId(int iData = -1);
|
||||||
virtual ItemInstance *setDescriptionId(unsigned int id);
|
virtual ItemInstance *setDescriptionId(unsigned int id);
|
||||||
|
|
|
||||||
|
|
@ -14,37 +14,12 @@ Language *Language::getInstance()
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4J Jev, creates 2 identical functions.
|
std::wstring Language::getElementName(const std::wstring& elementId)
|
||||||
wstring Language::getElement(const wstring& elementId)
|
|
||||||
{
|
|
||||||
return elementId;
|
|
||||||
} */
|
|
||||||
|
|
||||||
wstring Language::getElement(const wstring& elementId, ...)
|
|
||||||
{
|
|
||||||
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
|
|
||||||
return L"";
|
|
||||||
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
|
|
||||||
return elementId;
|
|
||||||
#else
|
|
||||||
va_list args;
|
|
||||||
va_start(args, elementId);
|
|
||||||
return getElement(elementId, args);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
wstring Language::getElement(const wstring& elementId, va_list args)
|
|
||||||
{
|
|
||||||
// 4J TODO
|
|
||||||
return elementId;
|
|
||||||
}
|
|
||||||
|
|
||||||
wstring Language::getElementName(const wstring& elementId)
|
|
||||||
{
|
{
|
||||||
return elementId;
|
return elementId;
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Language::getElementDescription(const wstring& elementId)
|
std::wstring Language::getElementDescription(const std::wstring& elementId)
|
||||||
{
|
{
|
||||||
return elementId;
|
return elementId;
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class Language
|
class Language
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
@ -7,8 +9,11 @@ private:
|
||||||
public:
|
public:
|
||||||
Language();
|
Language();
|
||||||
static Language *getInstance();
|
static Language *getInstance();
|
||||||
wstring getElement(const wstring& elementId, ...);
|
template<typename...Args>
|
||||||
wstring getElement(const wstring& elementId, va_list args);
|
inline std::wstring getElement(const std::wstring& elementId, Args...)
|
||||||
wstring getElementName(const wstring& elementId);
|
{
|
||||||
wstring getElementDescription(const wstring& elementId);
|
return elementId;
|
||||||
|
}
|
||||||
|
std::wstring getElementName(const std::wstring& elementId);
|
||||||
|
std::wstring getElementDescription(const std::wstring& elementId);
|
||||||
};
|
};
|
||||||
|
|
@ -105,7 +105,7 @@ bool MerchantContainer::hasCustomName()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MerchantContainer::getMaxStackSize()
|
int MerchantContainer::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return Container::LARGE_MAX_STACK_SIZE;
|
return Container::LARGE_MAX_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public:
|
||||||
wstring getName();
|
wstring getName();
|
||||||
wstring getCustomName();
|
wstring getCustomName();
|
||||||
bool hasCustomName();
|
bool hasCustomName();
|
||||||
int getMaxStackSize();
|
int getMaxStackSize() const;
|
||||||
bool stillValid(shared_ptr<Player> player);
|
bool stillValid(shared_ptr<Player> player);
|
||||||
void startOpen();
|
void startOpen();
|
||||||
void stopOpen();
|
void stopOpen();
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ wstring MinecartContainer::getName()
|
||||||
return hasCustomName() ? getCustomName() : app.GetString(IDS_CONTAINER_MINECART);
|
return hasCustomName() ? getCustomName() : app.GetString(IDS_CONTAINER_MINECART);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MinecartContainer::getMaxStackSize()
|
int MinecartContainer::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return Container::LARGE_MAX_STACK_SIZE;
|
return Container::LARGE_MAX_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
virtual void stopOpen();
|
virtual void stopOpen();
|
||||||
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
|
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
|
||||||
virtual wstring getName();
|
virtual wstring getName();
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual void changeDimension(int i);
|
virtual void changeDimension(int i);
|
||||||
virtual void remove();
|
virtual void remove();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public:
|
||||||
virtual wstring getName() { return MinecartContainer::getName(); }
|
virtual wstring getName() { return MinecartContainer::getName(); }
|
||||||
virtual wstring getCustomName() { return MinecartContainer::getCustomName(); }
|
virtual wstring getCustomName() { return MinecartContainer::getCustomName(); }
|
||||||
virtual bool hasCustomName() { return MinecartContainer::hasCustomName(); }
|
virtual bool hasCustomName() { return MinecartContainer::hasCustomName(); }
|
||||||
virtual int getMaxStackSize() { return MinecartContainer::getMaxStackSize(); }
|
virtual int getMaxStackSize() const { return MinecartContainer::getMaxStackSize(); }
|
||||||
|
|
||||||
virtual void setChanged() { MinecartContainer::setChanged(); }
|
virtual void setChanged() { MinecartContainer::setChanged(); }
|
||||||
virtual bool stillValid(shared_ptr<Player> player) { return MinecartContainer::stillValid(player); }
|
virtual bool stillValid(shared_ptr<Player> player) { return MinecartContainer::stillValid(player); }
|
||||||
|
|
|
||||||
|
|
@ -307,6 +307,7 @@
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64EC'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64EC'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
|
@ -1336,7 +1337,7 @@
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
<ExceptionHandling>Sync</ExceptionHandling>
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ void ResultContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
|
||||||
items[0] = item;
|
items[0] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ResultContainer::getMaxStackSize()
|
int ResultContainer::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return Container::LARGE_MAX_STACK_SIZE;
|
return Container::LARGE_MAX_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public:
|
||||||
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
|
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
|
||||||
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
||||||
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual void setChanged();
|
virtual void setChanged();
|
||||||
virtual bool stillValid(shared_ptr<Player> player);
|
virtual bool stillValid(shared_ptr<Player> player);
|
||||||
virtual void startOpen() { } // TODO Auto-generated method stub
|
virtual void startOpen() { } // TODO Auto-generated method stub
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ void SimpleContainer::setCustomName(const wstring &name)
|
||||||
this->stringName = name;
|
this->stringName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SimpleContainer::getMaxStackSize()
|
int SimpleContainer::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return Container::LARGE_MAX_STACK_SIZE;
|
return Container::LARGE_MAX_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public:
|
||||||
virtual wstring getCustomName();
|
virtual wstring getCustomName();
|
||||||
virtual bool hasCustomName();
|
virtual bool hasCustomName();
|
||||||
virtual void setCustomName(const wstring &name);
|
virtual void setCustomName(const wstring &name);
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual void setChanged();
|
virtual void setChanged();
|
||||||
virtual bool stillValid(shared_ptr<Player> player);
|
virtual bool stillValid(shared_ptr<Player> player);
|
||||||
virtual void startOpen() { } // TODO Auto-generated method stub
|
virtual void startOpen() { } // TODO Auto-generated method stub
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ void Slot::setChanged()
|
||||||
container->setChanged();
|
container->setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Slot::getMaxStackSize()
|
int Slot::getMaxStackSize() const
|
||||||
{
|
{
|
||||||
return container->getMaxStackSize();
|
return container->getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public:
|
||||||
virtual bool hasItem();
|
virtual bool hasItem();
|
||||||
virtual void set(shared_ptr<ItemInstance> item);
|
virtual void set(shared_ptr<ItemInstance> item);
|
||||||
virtual void setChanged();
|
virtual void setChanged();
|
||||||
virtual int getMaxStackSize();
|
virtual int getMaxStackSize() const;
|
||||||
virtual Icon *getNoItemIcon();
|
virtual Icon *getNoItemIcon();
|
||||||
virtual shared_ptr<ItemInstance> remove(int c);
|
virtual shared_ptr<ItemInstance> remove(int c);
|
||||||
virtual bool isAt(shared_ptr<Container> c, int s);
|
virtual bool isAt(shared_ptr<Container> c, int s);
|
||||||
|
|
|
||||||
|
|
@ -215,10 +215,17 @@ public:
|
||||||
int GetUserIndex();
|
int GetUserIndex();
|
||||||
void SetCustomDataValue(ULONG_PTR ulpCustomDataValue);
|
void SetCustomDataValue(ULONG_PTR ulpCustomDataValue);
|
||||||
ULONG_PTR GetCustomDataValue();
|
ULONG_PTR GetCustomDataValue();
|
||||||
|
|
||||||
|
BYTE m_smallId;
|
||||||
|
bool m_isRemote;
|
||||||
|
bool m_isHostPlayer;
|
||||||
|
wchar_t m_gamertag[32];
|
||||||
private:
|
private:
|
||||||
ULONG_PTR m_customData;
|
ULONG_PTR m_customData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void Win64_SetupRemoteQNetPlayer(IQNetPlayer* player, BYTE smallId, bool isHost, bool isLocal);
|
||||||
|
|
||||||
const int QNET_GETSENDQUEUESIZE_SECONDARY_TYPE = 0;
|
const int QNET_GETSENDQUEUESIZE_SECONDARY_TYPE = 0;
|
||||||
const int QNET_GETSENDQUEUESIZE_MESSAGES = 0;
|
const int QNET_GETSENDQUEUESIZE_MESSAGES = 0;
|
||||||
const int QNET_GETSENDQUEUESIZE_BYTES = 0;
|
const int QNET_GETSENDQUEUESIZE_BYTES = 0;
|
||||||
|
|
@ -309,9 +316,12 @@ public:
|
||||||
bool IsHost();
|
bool IsHost();
|
||||||
HRESULT JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo);
|
HRESULT JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo);
|
||||||
void HostGame();
|
void HostGame();
|
||||||
|
void ClientJoinGame();
|
||||||
void EndGame();
|
void EndGame();
|
||||||
|
|
||||||
static IQNetPlayer m_player[4];
|
static IQNetPlayer m_player[MINECRAFT_NET_MAX_PLAYERS];
|
||||||
|
static DWORD s_playerCount;
|
||||||
|
static bool s_isHosting;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _DURANGO
|
#ifdef _DURANGO
|
||||||
|
|
|
||||||
23
README.md
23
README.md
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[](https://discord.gg/5CSzhc9t)
|
[](https://discord.gg/5CSzhc9t)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
|
|
@ -23,6 +23,25 @@ This project contains the source code of Minecraft Legacy Console Edition v1.6.0
|
||||||
- Disabled V-Sync for better performance
|
- Disabled V-Sync for better performance
|
||||||
- Added a high-resolution timer path on Windows for smoother high-FPS gameplay timing
|
- Added a high-resolution timer path on Windows for smoother high-FPS gameplay timing
|
||||||
- Device's screen resolution will be used as the game resolution instead of using a fixed resolution (1920x1080)
|
- Device's screen resolution will be used as the game resolution instead of using a fixed resolution (1920x1080)
|
||||||
|
- LAN Multiplayer & Discovery
|
||||||
|
|
||||||
|
## Multiplayer
|
||||||
|
|
||||||
|
Basic LAN multiplayer is available on the Windows build
|
||||||
|
|
||||||
|
- Hosting a multiplayer world automatically advertises it on the local network
|
||||||
|
- Other players on the same LAN can discover the session from the in-game Join Game menu
|
||||||
|
- Game connections use TCP port `25565` by default
|
||||||
|
- LAN discovery uses UDP port `25566`
|
||||||
|
- You can override your in-game username at launch with `-name`
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Minecraft.Client.exe -name Steve
|
||||||
|
```
|
||||||
|
|
||||||
|
This feature is based on [LCEMP](https://github.com/LCEMP/LCEMP/)
|
||||||
|
|
||||||
## Controls (Keyboard & Mouse)
|
## Controls (Keyboard & Mouse)
|
||||||
|
|
||||||
|
|
@ -41,7 +60,7 @@ This project contains the source code of Minecraft Legacy Console Edition v1.6.0
|
||||||
- **Use / Place**: `Right Click`
|
- **Use / Place**: `Right Click`
|
||||||
- **Select Item**: `Mouse Wheel` or keys `1` to `9`
|
- **Select Item**: `Mouse Wheel` or keys `1` to `9`
|
||||||
- **Accept or Decline Tutorial hints**: `Enter` to accept and `B` to decline
|
- **Accept or Decline Tutorial hints**: `Enter` to accept and `B` to decline
|
||||||
- **Host Options**: `TAB`
|
- **Game Info (Player list and Host Options)**: `TAB`
|
||||||
- **Toggle Debug Info**: `F3`
|
- **Toggle Debug Info**: `F3`
|
||||||
- **Open Debug Overlay**: `F4`
|
- **Open Debug Overlay**: `F4`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -476,6 +476,7 @@ set(MINECRAFT_CLIENT_SOURCES
|
||||||
"Windows64/Windows64_App.cpp"
|
"Windows64/Windows64_App.cpp"
|
||||||
"Windows64/Windows64_Minecraft.cpp"
|
"Windows64/Windows64_Minecraft.cpp"
|
||||||
"Windows64/Windows64_UIController.cpp"
|
"Windows64/Windows64_UIController.cpp"
|
||||||
|
"Windows64/Network/WinsockNetLayer.cpp"
|
||||||
"WitchModel.cpp"
|
"WitchModel.cpp"
|
||||||
"WitchRenderer.cpp"
|
"WitchRenderer.cpp"
|
||||||
"WitherBossModel.cpp"
|
"WitherBossModel.cpp"
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,28 @@ set(_project_dir "${PROJECT_SOURCE_DIR}/Minecraft.Client")
|
||||||
function(copy_tree_if_exists src_rel dst_rel)
|
function(copy_tree_if_exists src_rel dst_rel)
|
||||||
set(_src "${_project_dir}/${src_rel}")
|
set(_src "${_project_dir}/${src_rel}")
|
||||||
set(_dst "${OUTPUT_DIR}/${dst_rel}")
|
set(_dst "${OUTPUT_DIR}/${dst_rel}")
|
||||||
|
|
||||||
if(EXISTS "${_src}")
|
if(EXISTS "${_src}")
|
||||||
file(MAKE_DIRECTORY "${_dst}")
|
file(MAKE_DIRECTORY "${_dst}")
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${_src}" "${_dst}")
|
file(GLOB_RECURSE _files RELATIVE "${_src}" "${_src}/*")
|
||||||
|
|
||||||
|
foreach(_file IN LISTS _files) # if not a source file
|
||||||
|
if(NOT _file MATCHES "\\.(cpp|c|h|hpp|xml|lang)$")
|
||||||
|
set(_full_src "${_src}/${_file}")
|
||||||
|
set(_full_dst "${_dst}/${_file}")
|
||||||
|
|
||||||
|
if(IS_DIRECTORY "${_full_src}")
|
||||||
|
file(MAKE_DIRECTORY "${_full_dst}")
|
||||||
|
else()
|
||||||
|
get_filename_component(_dst_dir "${_full_dst}" DIRECTORY)
|
||||||
|
file(MAKE_DIRECTORY "${_dst_dir}")
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
|
||||||
|
"${_full_src}" "${_full_dst}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
@ -25,10 +44,15 @@ endfunction()
|
||||||
function(copy_file_if_exists src_rel dst_rel)
|
function(copy_file_if_exists src_rel dst_rel)
|
||||||
set(_src "${PROJECT_SOURCE_DIR}/${src_rel}")
|
set(_src "${PROJECT_SOURCE_DIR}/${src_rel}")
|
||||||
set(_dst "${OUTPUT_DIR}/${dst_rel}")
|
set(_dst "${OUTPUT_DIR}/${dst_rel}")
|
||||||
if(EXISTS "${_src}")
|
|
||||||
get_filename_component(_dst_dir "${_dst}" DIRECTORY)
|
get_filename_component(_dst_dir "${_dst}" DIRECTORY)
|
||||||
file(MAKE_DIRECTORY "${_dst_dir}")
|
file(MAKE_DIRECTORY "${_dst_dir}")
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_src}" "${_dst}")
|
|
||||||
|
if(EXISTS "${_src}")
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
|
||||||
|
"${_src}" "${_dst}"
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
@ -46,24 +70,24 @@ function(copy_first_existing dst_rel)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if(CONFIGURATION STREQUAL "Debug")
|
function(remove_directory_if_exists rel_path)
|
||||||
copy_tree_if_exists("Durango/Sound" "Durango/Sound")
|
set(_dir "${OUTPUT_DIR}/${rel_path}")
|
||||||
|
if(EXISTS "${_dir}")
|
||||||
|
file(REMOVE_RECURSE "${_dir}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
copy_tree_if_exists("Durango/Sound" "Windows64/Sound")
|
||||||
copy_tree_if_exists("music" "music")
|
copy_tree_if_exists("music" "music")
|
||||||
copy_tree_if_exists("Windows64/GameHDD" "Windows64/GameHDD")
|
copy_tree_if_exists("Windows64/GameHDD" "Windows64/GameHDD")
|
||||||
copy_tree_if_exists("Common/Media" "Common/Media")
|
copy_file_if_exists("Minecraft.Client/Common/Media/MediaWindows64.arc" "Common/Media/MediaWindows64.arc")
|
||||||
copy_tree_if_exists("Common/res" "Common/res")
|
|
||||||
copy_tree_if_exists("Common/Trial" "Common/Trial")
|
|
||||||
copy_tree_if_exists("Common/Tutorial" "Common/Tutorial")
|
|
||||||
else()
|
|
||||||
copy_tree_if_exists("music" "music")
|
|
||||||
copy_tree_if_exists("Windows64/GameHDD" "Windows64/GameHDD")
|
|
||||||
copy_tree_if_exists("Common/Media" "Common/Media")
|
|
||||||
copy_tree_if_exists("Common/res" "Common/res")
|
copy_tree_if_exists("Common/res" "Common/res")
|
||||||
copy_tree_if_exists("Common/Trial" "Common/Trial")
|
copy_tree_if_exists("Common/Trial" "Common/Trial")
|
||||||
copy_tree_if_exists("Common/Tutorial" "Common/Tutorial")
|
copy_tree_if_exists("Common/Tutorial" "Common/Tutorial")
|
||||||
copy_tree_if_exists("DurangoMedia" "Windows64Media")
|
copy_tree_if_exists("DurangoMedia" "Windows64Media")
|
||||||
copy_tree_if_exists("Windows64Media" "Windows64Media")
|
copy_tree_if_exists("Windows64Media" "Windows64Media")
|
||||||
endif()
|
|
||||||
|
remove_directory_if_exists("Windows64Media/Layout")
|
||||||
|
|
||||||
# Some runtime code asserts if this directory tree is missing.
|
# Some runtime code asserts if this directory tree is missing.
|
||||||
ensure_dir("Windows64/GameHDD")
|
ensure_dir("Windows64/GameHDD")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue