mirror of
https://github.com/Minecraft-Community-Edition/client.git
synced 2026-05-23 01:24:32 +00:00
keyboard warrior
This commit is contained in:
@@ -57,6 +57,11 @@
|
||||
#include "..\Minecraft.World\GenericStats.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include "Xbox\Network\NetworkPlayerXbox.h"
|
||||
#include "Common\Network\PlatformNetworkManagerStub.h"
|
||||
#endif
|
||||
|
||||
ClientConnection::ClientConnection(Minecraft *minecraft, const wstring& ip, int port)
|
||||
{
|
||||
// 4J Stu - No longer used as we use the socket version below.
|
||||
@@ -758,6 +763,27 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet)
|
||||
player->displayName = player->name;
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
{
|
||||
PlayerUID pktXuid = player->getXuid();
|
||||
const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e;
|
||||
if (pktXuid >= WIN64_XUID_BASE && pktXuid < WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS)
|
||||
{
|
||||
BYTE smallId = (BYTE)(pktXuid - WIN64_XUID_BASE);
|
||||
INetworkPlayer *np = g_NetworkManager.GetPlayerBySmallId(smallId);
|
||||
if (np != NULL)
|
||||
{
|
||||
NetworkPlayerXbox *npx = (NetworkPlayerXbox *)np;
|
||||
IQNetPlayer *qp = npx->GetQNetPlayer();
|
||||
if (qp != NULL && qp->m_gamertag[0] == 0)
|
||||
{
|
||||
wcsncpy_s(qp->m_gamertag, 32, packet->name.c_str(), _TRUNCATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// printf("\t\t\t\t%d: Add player\n",packet->id,packet->yRot);
|
||||
|
||||
int item = packet->carriedItem;
|
||||
@@ -893,6 +919,39 @@ void ClientConnection::handleMoveEntitySmall(shared_ptr<MoveEntityPacketSmall> p
|
||||
|
||||
void ClientConnection::handleRemoveEntity(shared_ptr<RemoveEntitiesPacket> packet)
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
if (!g_NetworkManager.IsHost())
|
||||
{
|
||||
for (int i = 0; i < packet->ids.length; i++)
|
||||
{
|
||||
shared_ptr<Entity> entity = getEntity(packet->ids[i]);
|
||||
if (entity != NULL && entity->GetType() == eTYPE_PLAYER)
|
||||
{
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(entity);
|
||||
if (player != NULL)
|
||||
{
|
||||
PlayerUID xuid = player->getXuid();
|
||||
INetworkPlayer *np = g_NetworkManager.GetPlayerByXuid(xuid);
|
||||
if (np != NULL)
|
||||
{
|
||||
NetworkPlayerXbox *npx = (NetworkPlayerXbox *)np;
|
||||
IQNetPlayer *qp = npx->GetQNetPlayer();
|
||||
if (qp != NULL)
|
||||
{
|
||||
extern CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
||||
g_pPlatformNetworkManager->NotifyPlayerLeaving(qp);
|
||||
qp->m_smallId = 0;
|
||||
qp->m_isRemote = false;
|
||||
qp->m_isHostPlayer = false;
|
||||
qp->m_gamertag[0] = 0;
|
||||
qp->SetCustomDataValue(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (int i = 0; i < packet->ids.length; i++)
|
||||
{
|
||||
level->removeEntity(packet->ids[i]);
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "..\..\..\Minecraft.World\Socket.h"
|
||||
#include "..\..\..\Minecraft.World\StringHelpers.h"
|
||||
#include "PlatformNetworkManagerStub.h"
|
||||
#include "..\..\Xbox\Network\NetworkPlayerXbox.h" // TODO - stub version of this?
|
||||
#ifdef _WINDOWS64
|
||||
#include "..\..\Windows64\Network\WinsockNetLayer.h"
|
||||
#include "..\..\Minecraft.h"
|
||||
#include "..\..\User.h"
|
||||
#endif
|
||||
|
||||
CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
||||
|
||||
@@ -72,7 +77,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer )
|
||||
}
|
||||
}
|
||||
g_NetworkManager.PlayerJoining( networkPlayer );
|
||||
|
||||
|
||||
if( createFakeSocket == true && !m_bHostChanged )
|
||||
{
|
||||
g_NetworkManager.CreateSocket( networkPlayer, localPlayer );
|
||||
@@ -92,7 +97,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer )
|
||||
// g_NetworkManager.UpdateAndSetGameSessionData();
|
||||
SystemFlagAddPlayer( networkPlayer );
|
||||
}
|
||||
|
||||
|
||||
for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
|
||||
{
|
||||
if(playerChangedCallback[idx] != NULL)
|
||||
@@ -114,10 +119,42 @@ 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)
|
||||
{
|
||||
m_pGameNetworkManager = pGameNetworkManager;
|
||||
m_flagIndexSize = flagIndexSize;
|
||||
m_pIQNet = new IQNet();
|
||||
g_pPlatformNetworkManager = this;
|
||||
for( int i = 0; i < XUSER_MAX_COUNT; i++ )
|
||||
{
|
||||
@@ -148,19 +185,12 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa
|
||||
m_currentSearchResultsCount[i] = 0;
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
m_lanSessionManager.Initialize();
|
||||
#endif
|
||||
|
||||
// Success!
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::Terminate()
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
m_lanSessionManager.Shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
int CPlatformNetworkManagerStub::GetJoiningReadyPercentage()
|
||||
@@ -182,8 +212,57 @@ bool CPlatformNetworkManagerStub::isSystemPrimaryPlayer(IQNetPlayer *pQNetPlayer
|
||||
void CPlatformNetworkManagerStub::DoWork()
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
m_lanSessionManager.Tick();
|
||||
TickSearch();
|
||||
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--;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
IQNetPlayer *qp = &IQNet::m_player[i];
|
||||
if (qp->GetCustomDataValue() == 0)
|
||||
continue;
|
||||
INetworkPlayer *np = (INetworkPlayer *)qp->GetCustomDataValue();
|
||||
Socket *sock = np->GetSocket();
|
||||
if (sock != NULL && sock->isClosing())
|
||||
{
|
||||
WinsockNetLayer::CloseConnectionBySmallId((BYTE)i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_iQNetStubState == QNET_STATE_GAME_PLAY && !m_pIQNet->IsHost())
|
||||
{
|
||||
if (!WinsockNetLayer::IsConnected() && !g_NetworkManager.IsLeavingGame())
|
||||
{
|
||||
if (app.GetDisconnectReason() == DisconnectPacket::eDisconnect_None)
|
||||
app.SetDisconnectReason(DisconnectPacket::eDisconnect_Quitting);
|
||||
app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_ExitWorld, (void *)TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -244,16 +323,31 @@ bool CPlatformNetworkManagerStub::LeaveGame(bool bMigrateHost)
|
||||
m_bLeavingGame = true;
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
m_lanSessionManager.StopBroadcasting();
|
||||
WinsockNetLayer::StopAdvertising();
|
||||
#endif
|
||||
|
||||
// If we are the host wait for the game server to end
|
||||
if(m_pIQNet->IsHost() && g_NetworkManager.ServerStoppedValid())
|
||||
{
|
||||
m_pIQNet->EndGame();
|
||||
g_NetworkManager.ServerStoppedWait();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -264,31 +358,38 @@ bool CPlatformNetworkManagerStub::_LeaveGame(bool bMigrateHost, bool bLeaveRoom)
|
||||
|
||||
void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, unsigned char publicSlots /*= MINECRAFT_NET_MAX_PLAYERS*/, unsigned char privateSlots /*= 0*/)
|
||||
{
|
||||
// #ifdef _XBOX
|
||||
// 4J Stu - We probably did this earlier as well, but just to be sure!
|
||||
SetLocalGame( !bOnlineGame );
|
||||
SetPrivateGame( bIsPrivate );
|
||||
SystemFlagReset();
|
||||
|
||||
// Make sure that the Primary Pad is in by default
|
||||
localUsersMask |= GetLocalPlayerMask( g_NetworkManager.GetPrimaryPad() );
|
||||
|
||||
m_bLeavingGame = false;
|
||||
|
||||
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 );
|
||||
//#endif
|
||||
|
||||
#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
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::_HostGame(int usersMask, unsigned char publicSlots /*= MINECRAFT_NET_MAX_PLAYERS*/, unsigned char privateSlots /*= 0*/)
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
// Start LAN broadcasting so other instances can discover this game
|
||||
char* gamertag = ProfileManager.GetGamertag(0);
|
||||
m_lanSessionManager.StartBroadcasting(m_hostGameSessionData, gamertag, "Minecraft World");
|
||||
app.DebugPrintf("LAN: Host game started, broadcasting session\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CPlatformNetworkManagerStub::_StartGame()
|
||||
@@ -298,7 +399,52 @@ bool CPlatformNetworkManagerStub::_StartGame()
|
||||
|
||||
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;
|
||||
#else
|
||||
return CGameNetworkManager::JOINGAME_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CPlatformNetworkManagerStub::SetLocalGame(bool isLocal)
|
||||
@@ -331,54 +477,32 @@ void CPlatformNetworkManagerStub::UnRegisterPlayerChangedCallback(int iPad, void
|
||||
|
||||
void CPlatformNetworkManagerStub::HandleSignInChange()
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/)
|
||||
{
|
||||
// DWORD playerCount = m_pIQNet->GetPlayerCount();
|
||||
//
|
||||
// if( this->m_bLeavingGame )
|
||||
// return;
|
||||
//
|
||||
// if( GetHostPlayer() == NULL )
|
||||
// return;
|
||||
//
|
||||
// for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i)
|
||||
// {
|
||||
// if( i < playerCount )
|
||||
// {
|
||||
// INetworkPlayer *pNetworkPlayer = GetPlayerByIndex(i);
|
||||
//
|
||||
// // We can call this from NotifyPlayerLeaving but at that point the player is still considered in the session
|
||||
// if( pNetworkPlayer != pNetworkPlayerLeaving )
|
||||
// {
|
||||
// m_hostGameSessionData.players[i] = ((NetworkPlayerXbox *)pNetworkPlayer)->GetUID();
|
||||
//
|
||||
// char *temp;
|
||||
// temp = (char *)wstringtofilename( pNetworkPlayer->GetOnlineName() );
|
||||
// memcpy(m_hostGameSessionData.szPlayers[i],temp,XUSER_NAME_SIZE);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_hostGameSessionData.players[i] = NULL;
|
||||
// memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_hostGameSessionData.players[i] = NULL;
|
||||
// memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// m_hostGameSessionData.hostPlayerUID = ((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetXuid();
|
||||
// m_hostGameSessionData.m_uiGameHostSettings = app.GetGameHostOption(eGameHostOption_All);
|
||||
}
|
||||
|
||||
int CPlatformNetworkManagerStub::RemovePlayerOnSocketClosedThreadProc( void* lpParam )
|
||||
@@ -525,28 +649,59 @@ wstring CPlatformNetworkManagerStub::GatherRTTStats()
|
||||
void CPlatformNetworkManagerStub::TickSearch()
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
// Start listening if we're not already and not hosting
|
||||
if (!m_lanSessionManager.IsListening() && !m_lanSessionManager.IsBroadcasting())
|
||||
{
|
||||
m_lanSessionManager.StartListening();
|
||||
}
|
||||
if (m_SessionsUpdatedCallback == NULL)
|
||||
return;
|
||||
|
||||
// If new sessions were discovered, notify the UI
|
||||
if (m_lanSessionManager.HasNewSessions())
|
||||
{
|
||||
m_lanSessionManager.ClearNewSessionsFlag();
|
||||
m_bSearchResultsReady = true;
|
||||
static DWORD lastSearchTime = 0;
|
||||
DWORD now = GetTickCount();
|
||||
if (now - lastSearchTime < 2000)
|
||||
return;
|
||||
lastSearchTime = now;
|
||||
|
||||
if (m_SessionsUpdatedCallback != NULL)
|
||||
{
|
||||
m_SessionsUpdatedCallback(m_pSearchParam);
|
||||
}
|
||||
}
|
||||
SearchForGames();
|
||||
#endif
|
||||
}
|
||||
|
||||
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 )
|
||||
@@ -562,12 +717,10 @@ void CPlatformNetworkManagerStub::SetSearchResultsReady(int resultCount)
|
||||
|
||||
vector<FriendSessionInfo *> *CPlatformNetworkManagerStub::GetSessionList(int iPad, int localPlayers, bool partyOnly)
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
return m_lanSessionManager.GetSessionList();
|
||||
#else
|
||||
vector<FriendSessionInfo *> *filteredList = new vector<FriendSessionInfo *>();
|
||||
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||
filteredList->push_back(friendsSessions[0][i]);
|
||||
return filteredList;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CPlatformNetworkManagerStub::GetGameSessionInfo(int iPad, SessionID sessionId, FriendSessionInfo *foundSessionInfo)
|
||||
@@ -596,15 +749,6 @@ void CPlatformNetworkManagerStub::ForceFriendsSessionRefresh()
|
||||
delete m_pSearchResults[i];
|
||||
m_pSearchResults[i] = NULL;
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
// Restart LAN listening to force a fresh discovery
|
||||
if (m_lanSessionManager.IsListening())
|
||||
{
|
||||
m_lanSessionManager.StopListening();
|
||||
m_lanSessionManager.StartListening();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
INetworkPlayer *CPlatformNetworkManagerStub::addNetworkPlayer(IQNetPlayer *pQNetPlayer)
|
||||
@@ -636,7 +780,7 @@ INetworkPlayer *CPlatformNetworkManagerStub::getNetworkPlayer(IQNetPlayer *pQNet
|
||||
|
||||
INetworkPlayer *CPlatformNetworkManagerStub::GetLocalPlayerByUserIndex(int userIndex )
|
||||
{
|
||||
return getNetworkPlayer(m_pIQNet->GetLocalPlayerByUserIndex(userIndex));
|
||||
return getNetworkPlayer(m_pIQNet->GetLocalPlayerByUserIndex(userIndex));
|
||||
}
|
||||
|
||||
INetworkPlayer *CPlatformNetworkManagerStub::GetPlayerByIndex(int playerIndex)
|
||||
@@ -651,7 +795,21 @@ INetworkPlayer * CPlatformNetworkManagerStub::GetPlayerByXuid(PlayerUID xuid)
|
||||
|
||||
INetworkPlayer * CPlatformNetworkManagerStub::GetPlayerBySmallId(unsigned char smallId)
|
||||
{
|
||||
return getNetworkPlayer(m_pIQNet->GetPlayerBySmallId(smallId));
|
||||
IQNetPlayer *qnetPlayer = m_pIQNet->GetPlayerBySmallId(smallId);
|
||||
if (qnetPlayer == NULL)
|
||||
return NULL;
|
||||
|
||||
INetworkPlayer *networkPlayer = getNetworkPlayer(qnetPlayer);
|
||||
#ifdef _WINDOWS64
|
||||
if (networkPlayer == NULL && smallId != 0 && !m_pIQNet->IsHost())
|
||||
{
|
||||
qnetPlayer->m_isRemote = true;
|
||||
qnetPlayer->m_isHostPlayer = false;
|
||||
NotifyPlayerJoined(qnetPlayer);
|
||||
networkPlayer = getNetworkPlayer(qnetPlayer);
|
||||
}
|
||||
#endif
|
||||
return networkPlayer;
|
||||
}
|
||||
|
||||
INetworkPlayer *CPlatformNetworkManagerStub::GetHostPlayer()
|
||||
|
||||
@@ -6,10 +6,6 @@ using namespace std;
|
||||
#include "PlatformNetworkManagerInterface.h"
|
||||
#include "SessionInfo.h"
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include "LANSessionManager.h"
|
||||
#endif
|
||||
|
||||
class CPlatformNetworkManagerStub : public CPlatformNetworkManager
|
||||
{
|
||||
friend class CGameNetworkManager;
|
||||
@@ -165,16 +161,11 @@ public:
|
||||
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
||||
virtual void ForceFriendsSessionRefresh();
|
||||
|
||||
private:
|
||||
public:
|
||||
void NotifyPlayerJoined( IQNetPlayer *pQNetPlayer );
|
||||
void NotifyPlayerLeaving( IQNetPlayer *pQNetPlayer );
|
||||
|
||||
#ifndef _XBOX
|
||||
void FakeLocalPlayerJoined() { NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0)); }
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
CLANSessionManager* GetLANSessionManager() { return &m_lanSessionManager; }
|
||||
private:
|
||||
CLANSessionManager m_lanSessionManager;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -63,12 +63,19 @@ typedef struct _GameSessionData
|
||||
#else
|
||||
typedef struct _GameSessionData
|
||||
{
|
||||
unsigned short netVersion; // 2 bytes
|
||||
unsigned int m_uiGameHostSettings; // 4 bytes
|
||||
unsigned int texturePackParentId; // 4 bytes
|
||||
unsigned char subTexturePackId; // 1 byte
|
||||
unsigned short netVersion;
|
||||
unsigned int m_uiGameHostSettings;
|
||||
unsigned int texturePackParentId;
|
||||
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()
|
||||
{
|
||||
@@ -76,6 +83,13 @@ typedef struct _GameSessionData
|
||||
m_uiGameHostSettings = 0;
|
||||
texturePackParentId = 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;
|
||||
#endif
|
||||
|
||||
@@ -1018,7 +1018,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
|
||||
released = InputManager.ButtonReleased(iPad,key); // Toggle
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0)
|
||||
if (iPad == 0 && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
int vk = 0;
|
||||
switch (key)
|
||||
@@ -1029,10 +1029,10 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
|
||||
case ACTION_MENU_DOWN: vk = VK_DOWN; break;
|
||||
case ACTION_MENU_LEFT: vk = VK_LEFT; break;
|
||||
case ACTION_MENU_RIGHT: vk = VK_RIGHT; break;
|
||||
case ACTION_MENU_X: vk = 'E'; break;
|
||||
case ACTION_MENU_X: vk = 'R'; break;
|
||||
case ACTION_MENU_Y: vk = VK_TAB; break;
|
||||
case ACTION_MENU_LEFT_SCROLL: vk = 'Q'; break;
|
||||
case ACTION_MENU_RIGHT_SCROLL: vk = 'R'; break;
|
||||
case ACTION_MENU_RIGHT_SCROLL: vk = 'E'; break;
|
||||
case ACTION_MENU_PAGEUP: vk = VK_PRIOR; break;
|
||||
case ACTION_MENU_PAGEDOWN: vk = VK_NEXT; break;
|
||||
}
|
||||
@@ -1043,6 +1043,19 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
|
||||
if (!pressed && !released && g_KBMInput.IsKeyDown(vk)) { down = true; }
|
||||
}
|
||||
|
||||
if ((key == ACTION_MENU_UP || key == ACTION_MENU_DOWN) && !pressed && !released && !down)
|
||||
{
|
||||
bool inCrafting = (m_groups[(EUIGroup)(iPad+1)]->FindScene(eUIScene_Crafting2x2Menu) != NULL)
|
||||
|| (m_groups[(EUIGroup)(iPad+1)]->FindScene(eUIScene_Crafting3x3Menu) != NULL);
|
||||
if (inCrafting)
|
||||
{
|
||||
int wsKey = (key == ACTION_MENU_UP) ? 'W' : 'S';
|
||||
if (g_KBMInput.IsKeyPressed(wsKey)) { pressed = true; down = true; }
|
||||
if (g_KBMInput.IsKeyReleased(wsKey)) { released = true; down = false; }
|
||||
if (!pressed && !released && g_KBMInput.IsKeyDown(wsKey)) { down = true; }
|
||||
}
|
||||
}
|
||||
|
||||
if ((key == ACTION_MENU_OK || key == ACTION_MENU_A) && !g_KBMInput.IsMouseGrabbed())
|
||||
{
|
||||
if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)) { pressed = true; down = true; }
|
||||
|
||||
@@ -454,6 +454,11 @@ SCreditTextItemDef UIScene_Credits::gs_aCreditDefs[MAX_CREDIT_STRINGS] =
|
||||
{ L"Victoria Bruder (CompuCom Systems Inc)", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,eSmallText },
|
||||
|
||||
#elif defined(_WIN64)
|
||||
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,eSmallText }, // extra blank line
|
||||
{ L"Code Used", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,eExtraLargeText },
|
||||
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,eSmallText }, // extra blank line
|
||||
{ L"LCEMP Multiplayer", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,eLargeText },
|
||||
{ L"notpies", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,eSmallText },
|
||||
#elif defined(__PSVITA__)
|
||||
// font credits
|
||||
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,eSmallText }, // extra blank line
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define PSVITA_CREDITS_COUNT 77
|
||||
#define PS4_CREDITS_COUNT 75
|
||||
#define XBOXONE_CREDITS_COUNT (75+318)
|
||||
#define WIN64_EXTRA_CREDITS_COUNT 5
|
||||
#define MILES_AND_IGGY_CREDITS_COUNT 8
|
||||
#define DYNAMODE_FONT_CREDITS_COUNT 2
|
||||
#define PS3_DOLBY_CREDIT 4
|
||||
@@ -15,8 +16,10 @@
|
||||
#define MAX_CREDIT_STRINGS (PS3_CREDITS_COUNT + MILES_AND_IGGY_CREDITS_COUNT + DYNAMODE_FONT_CREDITS_COUNT + PS3_DOLBY_CREDIT)
|
||||
#elif defined(__ORBIS__)
|
||||
#define MAX_CREDIT_STRINGS (PS4_CREDITS_COUNT + MILES_AND_IGGY_CREDITS_COUNT + DYNAMODE_FONT_CREDITS_COUNT)
|
||||
#elif defined(_DURANGO) || defined _WIN64
|
||||
#elif defined(_DURANGO)
|
||||
#define MAX_CREDIT_STRINGS (XBOXONE_CREDITS_COUNT + MILES_AND_IGGY_CREDITS_COUNT)
|
||||
#elif defined _WIN64
|
||||
#define MAX_CREDIT_STRINGS (XBOXONE_CREDITS_COUNT + WIN64_EXTRA_CREDITS_COUNT + MILES_AND_IGGY_CREDITS_COUNT)
|
||||
#elif defined(__PSVITA__)
|
||||
#define MAX_CREDIT_STRINGS (PSVITA_CREDITS_COUNT + MILES_AND_IGGY_CREDITS_COUNT + DYNAMODE_FONT_CREDITS_COUNT)
|
||||
#endif
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#ifdef _WINDOWS64
|
||||
#include "discord_game_sdk.h"
|
||||
#pragma comment(lib, "discord_game_sdk.dll.lib")
|
||||
#include "Windows64\Network\WinsockNetLayer.h"
|
||||
#endif
|
||||
|
||||
#ifndef E_FAIL
|
||||
@@ -256,7 +257,7 @@ void PIXSetMarkerDeprecated(int a, char *b, ...) {}
|
||||
|
||||
bool IsEqualXUID(PlayerUID a, PlayerUID b)
|
||||
{
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) || defined(_DURANGO)
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) || defined(_DURANGO) || defined(_WINDOWS64)
|
||||
return (a == b);
|
||||
#else
|
||||
return false;
|
||||
@@ -280,33 +281,6 @@ namespace
|
||||
char s_stubGamertagA[XUSER_MAX_COUNT][32];
|
||||
wchar_t s_stubGamertagW[XUSER_MAX_COUNT][32];
|
||||
|
||||
DWORD StubSupportedLocalUserMask()
|
||||
{
|
||||
DWORD mask = 0;
|
||||
for(unsigned int i = 0; i < XUSER_MAX_COUNT && i < 32; ++i)
|
||||
{
|
||||
mask |= (1u << i);
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
bool StubSupportsLocalUser(DWORD userIndex)
|
||||
{
|
||||
return userIndex < XUSER_MAX_COUNT;
|
||||
}
|
||||
|
||||
DWORD StubClampLocalUserMask(DWORD usersMask)
|
||||
{
|
||||
DWORD clampedMask = usersMask & StubSupportedLocalUserMask();
|
||||
if(clampedMask == 0)
|
||||
{
|
||||
clampedMask = (1u << 0);
|
||||
}
|
||||
return clampedMask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EnsureStubIdentity()
|
||||
{
|
||||
if(s_stubIdentityInitialised)
|
||||
@@ -347,11 +321,7 @@ namespace
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
sprintf_s(s_stubGamertagA[i], sizeof(s_stubGamertagA[i]), "Player%u-%u", pid % 10000, i);
|
||||
#else
|
||||
snprintf(s_stubGamertagA[i], sizeof(s_stubGamertagA[i]), "Player%u-%u", pid % 10000, i);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,70 +335,36 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
extern bool _bQNetStubIsHost;
|
||||
BYTE IQNetPlayer::GetSmallId()
|
||||
{
|
||||
int idx = (int)(this - &IQNet::m_player[0]);
|
||||
if(idx < 0 || idx >= (int)XUSER_MAX_COUNT)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(!_bQNetStubIsHost)
|
||||
{
|
||||
// When acting as a client, reserve small id 0 for the remote host.
|
||||
return (BYTE)(idx + 1);
|
||||
}
|
||||
return (BYTE)idx;
|
||||
}
|
||||
QNET_STATE _iQNetStubState = QNET_STATE_IDLE;
|
||||
|
||||
BYTE IQNetPlayer::GetSmallId() { return m_smallId; }
|
||||
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);
|
||||
}
|
||||
bool IQNetPlayer::IsSameSystem(IQNetPlayer *player)
|
||||
{
|
||||
if(player == NULL)
|
||||
if (WinsockNetLayer::IsActive())
|
||||
{
|
||||
return false;
|
||||
WinsockNetLayer::SendToSmallId(player->m_smallId, pvData, dwDataSize);
|
||||
}
|
||||
|
||||
ULONG_PTR ptr = (ULONG_PTR)player;
|
||||
ULONG_PTR begin = (ULONG_PTR)&IQNet::m_player[0];
|
||||
ULONG_PTR end = (ULONG_PTR)&IQNet::m_player[XUSER_MAX_COUNT];
|
||||
return (ptr >= begin && ptr < end);
|
||||
}
|
||||
bool IQNetPlayer::IsSameSystem(IQNetPlayer *player) { return (this == player) || (!m_isRemote && !player->m_isRemote); }
|
||||
DWORD IQNetPlayer::GetSendQueueSize( IQNetPlayer *player, DWORD dwFlags ) { return 0; }
|
||||
DWORD IQNetPlayer::GetCurrentRtt() { return 0; }
|
||||
extern bool _bQNetStubIsHost;
|
||||
bool IQNetPlayer::IsHost() { return _bQNetStubIsHost && this == &IQNet::m_player[0]; }
|
||||
bool IQNetPlayer::IsHost() { return m_isHostPlayer; }
|
||||
bool IQNetPlayer::IsGuest() { return false; }
|
||||
bool IQNetPlayer::IsLocal() { return true; }
|
||||
bool IQNetPlayer::IsLocal() { return !m_isRemote; }
|
||||
PlayerUID IQNetPlayer::GetXuid()
|
||||
{
|
||||
EnsureStubIdentity();
|
||||
int idx = (int)(this - &IQNet::m_player[0]);
|
||||
if(idx < 0 || idx >= (int)XUSER_MAX_COUNT)
|
||||
// For the local player (smallId 0 on host, or the assigned smallId on client),
|
||||
// try Discord XUID first for richer identity
|
||||
if (!m_isRemote)
|
||||
{
|
||||
idx = 0;
|
||||
EnsureStubIdentity();
|
||||
if (s_discordXuid != 0)
|
||||
return s_discordXuid | 0x100000000ULL;
|
||||
}
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
PlayerUID uid;
|
||||
uid.setUserID(0x70000000u | (unsigned int)(idx & 0xFF));
|
||||
return uid;
|
||||
#else
|
||||
return (s_stubXuidBase + (ULONGLONG)(idx & 0x0F)) | 0x100000000ULL;
|
||||
#endif
|
||||
return (PlayerUID)(0xe000d45248242f2e + m_smallId);
|
||||
}
|
||||
LPCWSTR IQNetPlayer::GetGamertag()
|
||||
{
|
||||
EnsureStubIdentity();
|
||||
int idx = (int)(this - &IQNet::m_player[0]);
|
||||
if(idx < 0 || idx >= (int)XUSER_MAX_COUNT)
|
||||
{
|
||||
idx = 0;
|
||||
}
|
||||
return s_stubGamertagW[idx];
|
||||
}
|
||||
int IQNetPlayer::GetSessionIndex() { return GetSmallId(); }
|
||||
LPCWSTR IQNetPlayer::GetGamertag() { return m_gamertag; }
|
||||
int IQNetPlayer::GetSessionIndex() { return m_smallId; }
|
||||
bool IQNetPlayer::IsTalking() { return false; }
|
||||
bool IQNetPlayer::IsMutedByLocalUser(DWORD dwUserIndex) { return false; }
|
||||
bool IQNetPlayer::HasVoice() { return false; }
|
||||
@@ -441,156 +377,118 @@ ULONG_PTR IQNetPlayer::GetCustomDataValue() {
|
||||
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;
|
||||
bool _bQNetStubIsHost = true;
|
||||
DWORD _dwQNetStubLocalUsersMask = (1u << 0);
|
||||
|
||||
HRESULT IQNet::AddLocalPlayerByUserIndex(DWORD dwUserIndex)
|
||||
void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal)
|
||||
{
|
||||
if(!StubSupportsLocalUser(dwUserIndex))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_dwQNetStubLocalUsersMask |= (1u << dwUserIndex);
|
||||
return S_OK;
|
||||
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;
|
||||
}
|
||||
|
||||
static bool Win64_IsActivePlayer(IQNetPlayer *p, DWORD index)
|
||||
{
|
||||
if (index == 0) return true;
|
||||
return (p->GetCustomDataValue() != 0);
|
||||
}
|
||||
|
||||
HRESULT IQNet::AddLocalPlayerByUserIndex(DWORD dwUserIndex){ return S_OK; }
|
||||
IQNetPlayer *IQNet::GetHostPlayer() { return &m_player[0]; }
|
||||
IQNetPlayer *IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex)
|
||||
{
|
||||
if(!StubSupportsLocalUser(dwUserIndex))
|
||||
if (s_isHosting)
|
||||
{
|
||||
if (dwUserIndex < MINECRAFT_NET_MAX_PLAYERS &&
|
||||
!m_player[dwUserIndex].m_isRemote &&
|
||||
Win64_IsActivePlayer(&m_player[dwUserIndex], dwUserIndex))
|
||||
return &m_player[dwUserIndex];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (_dwQNetStubLocalUsersMask & (1u << dwUserIndex)) ? &m_player[dwUserIndex] : NULL;
|
||||
if (dwUserIndex != 0)
|
||||
return NULL;
|
||||
for (DWORD i = 0; i < s_playerCount; i++)
|
||||
{
|
||||
if (!m_player[i].m_isRemote && Win64_IsActivePlayer(&m_player[i], i))
|
||||
return &m_player[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
IQNetPlayer *IQNet::GetPlayerByIndex(DWORD dwPlayerIndex)
|
||||
{
|
||||
if(!_bQNetStubGameRunning)
|
||||
DWORD found = 0;
|
||||
for (DWORD i = 0; i < s_playerCount; i++)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD currentIndex = 0;
|
||||
for(DWORD localUser = 0; localUser < XUSER_MAX_COUNT; ++localUser)
|
||||
{
|
||||
if((_dwQNetStubLocalUsersMask & (1u << localUser)) == 0)
|
||||
if (Win64_IsActivePlayer(&m_player[i], i))
|
||||
{
|
||||
continue;
|
||||
if (found == dwPlayerIndex) return &m_player[i];
|
||||
found++;
|
||||
}
|
||||
|
||||
if(currentIndex == dwPlayerIndex)
|
||||
{
|
||||
return &m_player[localUser];
|
||||
}
|
||||
|
||||
++currentIndex;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return &m_player[0];
|
||||
}
|
||||
IQNetPlayer *IQNet::GetPlayerBySmallId(BYTE SmallId)
|
||||
{
|
||||
if(!_bQNetStubGameRunning)
|
||||
{
|
||||
if (SmallId >= MINECRAFT_NET_MAX_PLAYERS)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(DWORD localUser = 0; localUser < XUSER_MAX_COUNT; ++localUser)
|
||||
{
|
||||
if((_dwQNetStubLocalUsersMask & (1u << localUser)) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(m_player[localUser].GetSmallId() == SmallId)
|
||||
{
|
||||
return &m_player[localUser];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
m_player[SmallId].m_smallId = SmallId;
|
||||
if (SmallId >= s_playerCount)
|
||||
s_playerCount = SmallId + 1;
|
||||
return &m_player[SmallId];
|
||||
}
|
||||
IQNetPlayer *IQNet::GetPlayerByXuid(PlayerUID xuid)
|
||||
{
|
||||
if(!_bQNetStubGameRunning)
|
||||
for (DWORD i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
return NULL;
|
||||
if (Win64_IsActivePlayer(&m_player[i], i) && m_player[i].GetXuid() == xuid) return &m_player[i];
|
||||
}
|
||||
|
||||
for(DWORD localUser = 0; localUser < XUSER_MAX_COUNT; ++localUser)
|
||||
{
|
||||
if((_dwQNetStubLocalUsersMask & (1u << localUser)) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IQNetPlayer *localPlayer = &m_player[localUser];
|
||||
PlayerUID localXuidOnline = localPlayer->GetXuid();
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) || defined(_DURANGO)
|
||||
if(xuid == localXuidOnline)
|
||||
{
|
||||
return localPlayer;
|
||||
}
|
||||
#else
|
||||
PlayerUID localXuidOffline = localXuidOnline & ~0x100000000ULL;
|
||||
if(xuid == localXuidOnline || xuid == localXuidOffline)
|
||||
{
|
||||
return localPlayer;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
DWORD IQNet::GetPlayerCount()
|
||||
{
|
||||
if(!_bQNetStubGameRunning)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD count = 0;
|
||||
for(DWORD localUser = 0; localUser < XUSER_MAX_COUNT; ++localUser)
|
||||
for (DWORD i = 0; i < s_playerCount; i++)
|
||||
{
|
||||
if(_dwQNetStubLocalUsersMask & (1u << localUser))
|
||||
{
|
||||
++count;
|
||||
}
|
||||
if (Win64_IsActivePlayer(&m_player[i], i)) count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
QNET_STATE IQNet::GetState() { return _bQNetStubGameRunning ? QNET_STATE_GAME_PLAY : QNET_STATE_IDLE; }
|
||||
bool IQNet::IsHost() { return _bQNetStubIsHost; }
|
||||
HRESULT IQNet::JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo)
|
||||
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; }
|
||||
void IQNet::HostGame() { _iQNetStubState = QNET_STATE_SESSION_STARTING; s_isHosting = true; }
|
||||
void IQNet::ClientJoinGame()
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwUserIndex);
|
||||
UNREFERENCED_PARAMETER(pInviteInfo);
|
||||
_bQNetStubIsHost = false;
|
||||
_bQNetStubGameRunning = true;
|
||||
_dwQNetStubLocalUsersMask = StubClampLocalUserMask(dwUserMask);
|
||||
if(StubSupportsLocalUser(dwUserIndex))
|
||||
_iQNetStubState = QNET_STATE_SESSION_STARTING;
|
||||
s_isHosting = false;
|
||||
|
||||
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
_dwQNetStubLocalUsersMask |= (1u << dwUserIndex);
|
||||
m_player[i].m_smallId = (BYTE)i;
|
||||
m_player[i].m_isRemote = true;
|
||||
m_player[i].m_isHostPlayer = false;
|
||||
m_player[i].m_gamertag[0] = 0;
|
||||
m_player[i].SetCustomDataValue(0);
|
||||
}
|
||||
_dwQNetStubLocalUsersMask = StubClampLocalUserMask(_dwQNetStubLocalUsersMask);
|
||||
return S_OK;
|
||||
}
|
||||
void IQNet::HostGame()
|
||||
{
|
||||
_bQNetStubIsHost = true;
|
||||
_bQNetStubGameRunning = true;
|
||||
_dwQNetStubLocalUsersMask = (1u << 0);
|
||||
}
|
||||
void IQNet::EndGame()
|
||||
{
|
||||
_bQNetStubGameRunning = false;
|
||||
_bQNetStubIsHost = true;
|
||||
_dwQNetStubLocalUsersMask = (1u << 0);
|
||||
_iQNetStubState = QNET_STATE_IDLE;
|
||||
s_isHosting = false;
|
||||
s_playerCount = 1;
|
||||
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
m_player[i].m_smallId = (BYTE)i;
|
||||
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; }
|
||||
@@ -766,7 +664,6 @@ DWORD XEnableGuestSignin(BOOL fEnable) { return 0; }
|
||||
#ifdef _WINDOWS64
|
||||
static void *profileData[4];
|
||||
static bool s_bProfileIsFullVersion;
|
||||
static int s_iPrimaryPad = 0;
|
||||
void C_4JProfile::Initialise( DWORD dwTitleID,
|
||||
DWORD dwOfferID,
|
||||
unsigned short usProfileVersion,
|
||||
@@ -836,21 +733,8 @@ void C_4JProfile::SetTrialTextStringTable(CXuiStringTable *pStringTable,int i
|
||||
void C_4JProfile::SetTrialAwardText(eAwardType AwardType,int iTitle,int iText) {}
|
||||
int C_4JProfile::GetLockedProfile() { return 0; }
|
||||
void C_4JProfile::SetLockedProfile(int iProf) {}
|
||||
bool C_4JProfile::IsSignedIn(int iQuadrant)
|
||||
{
|
||||
if(iQuadrant < 0 || iQuadrant >= (int)XUSER_MAX_COUNT)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(iQuadrant == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return InputManager.IsPadConnected(iQuadrant);
|
||||
}
|
||||
bool C_4JProfile::IsSignedInLive(int iProf) { return IsSignedIn(iProf); }
|
||||
bool C_4JProfile::IsSignedIn(int iQuadrant) { return ( iQuadrant == 0); }
|
||||
bool C_4JProfile::IsSignedInLive(int iProf) { return true; }
|
||||
bool C_4JProfile::IsGuest(int iQuadrant) { return false; }
|
||||
UINT C_4JProfile::RequestSignInUI(bool bFromInvite,bool bLocalGame,bool bNoGuestsAllowed,bool bMultiplayerSignIn,bool bAddUser, int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant) { return 0; }
|
||||
UINT C_4JProfile::DisplayOfflineProfile(int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant) { return 0; }
|
||||
@@ -859,18 +743,23 @@ void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {}
|
||||
bool C_4JProfile::QuerySigninStatus(void) { return true; }
|
||||
void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid)
|
||||
{
|
||||
EnsureStubIdentity();
|
||||
if(pXuid == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ULONGLONG value = s_stubXuidBase + (ULONGLONG)(iPad & 0x0F);
|
||||
if(bOnlineXuid)
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad != 0)
|
||||
{
|
||||
value |= 0x100000000ULL;
|
||||
*pXuid = INVALID_XUID;
|
||||
return;
|
||||
}
|
||||
*pXuid = value;
|
||||
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; }
|
||||
@@ -891,45 +780,17 @@ void C_4JProfile::AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly
|
||||
BOOL C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, DWORD dwXuidCount ) { return true; }
|
||||
bool C_4JProfile::GetProfileAvatar(int iPad,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam) { return false; }
|
||||
void C_4JProfile::CancelProfileAvatarRequest() {}
|
||||
int C_4JProfile::GetPrimaryPad() { return s_iPrimaryPad; }
|
||||
void C_4JProfile::SetPrimaryPad(int iPad)
|
||||
{
|
||||
if(iPad >= 0 && iPad < (int)XUSER_MAX_COUNT && IsSignedIn(iPad))
|
||||
{
|
||||
s_iPrimaryPad = iPad;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_iPrimaryPad = 0;
|
||||
}
|
||||
}
|
||||
int C_4JProfile::GetPrimaryPad() { return 0; }
|
||||
void C_4JProfile::SetPrimaryPad(int iPad) {}
|
||||
#ifdef _DURANGO
|
||||
char fakeGamerTag[32] = "PlayerName";
|
||||
void SetFakeGamertag(char *name){ strcpy_s(fakeGamerTag, name); }
|
||||
char* C_4JProfile::GetGamertag(int iPad){ return fakeGamerTag; }
|
||||
#else
|
||||
char* C_4JProfile::GetGamertag(int iPad)
|
||||
{
|
||||
EnsureStubIdentity();
|
||||
if(iPad < 0 || iPad >= (int)XUSER_MAX_COUNT)
|
||||
{
|
||||
iPad = 0;
|
||||
}
|
||||
return s_stubGamertagA[iPad];
|
||||
}
|
||||
wstring C_4JProfile::GetDisplayName(int iPad)
|
||||
{
|
||||
EnsureStubIdentity();
|
||||
if(iPad < 0 || iPad >= (int)XUSER_MAX_COUNT)
|
||||
{
|
||||
iPad = 0;
|
||||
}
|
||||
wchar_t displayName[32];
|
||||
swprintf(displayName, 32, L"%S", s_stubGamertagA[iPad]);
|
||||
return displayName;
|
||||
}
|
||||
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; }
|
||||
#endif
|
||||
bool C_4JProfile::IsFullVersion() { return true; }
|
||||
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
|
||||
void C_4JProfile::SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam) {}
|
||||
void C_4JProfile::SetNotificationsCallback(void ( *Func)(LPVOID, DWORD, unsigned int),LPVOID lpParam) {}
|
||||
bool C_4JProfile::RegionIsNorthAmerica(void) { return false; }
|
||||
@@ -950,10 +811,6 @@ int C_4JProfile::SetOldProfileVersionCallback(int( *Func)(LPVOID,unsigned ch
|
||||
// To store the dashboard preferences for controller flipped, etc.
|
||||
C_4JProfile::PROFILESETTINGS ProfileSettingsA[XUSER_MAX_COUNT];
|
||||
|
||||
#define MAX_AWARDS 32
|
||||
|
||||
static bool s_awardsUnlocked[XUSER_MAX_COUNT][MAX_AWARDS] = {};
|
||||
|
||||
C_4JProfile::PROFILESETTINGS * C_4JProfile::GetDashboardProfileSettings(int iPad) { return &ProfileSettingsA[iPad]; }
|
||||
void C_4JProfile::WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged, bool bOverride5MinuteLimitOnProfileWrites) {}
|
||||
void C_4JProfile::ForceQueuedProfileWrites(int iPad) {}
|
||||
@@ -979,24 +836,9 @@ void C_4JProfile::RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardTy
|
||||
CXuiStringTable*pStringTable, int iTitleStr, int iTextStr, int iAcceptStr, char *pszThemeName, unsigned int ulThemeSize) {}
|
||||
int C_4JProfile::GetAwardId(int iAwardNumber) { return 0; }
|
||||
eAwardType C_4JProfile::GetAwardType(int iAwardNumber) { return eAwardType_Achievement; }
|
||||
bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber)
|
||||
{
|
||||
if (iQuadrant < 0 || iQuadrant >= XUSER_MAX_COUNT) return false;
|
||||
if (iAwardNumber < 0 || iAwardNumber >= MAX_AWARDS) return false;
|
||||
return !s_awardsUnlocked[iQuadrant][iAwardNumber];
|
||||
}
|
||||
void C_4JProfile::Award(int iQuadrant, int iAwardNumber, bool bForce)
|
||||
{
|
||||
if (iQuadrant < 0 || iQuadrant >= XUSER_MAX_COUNT) return;
|
||||
if (iAwardNumber < 0 || iAwardNumber >= MAX_AWARDS) return;
|
||||
s_awardsUnlocked[iQuadrant][iAwardNumber] = true;
|
||||
}
|
||||
bool C_4JProfile::IsAwardsFlagSet(int iQuadrant, int iAward)
|
||||
{
|
||||
if (iQuadrant < 0 || iQuadrant >= XUSER_MAX_COUNT) return false;
|
||||
if (iAward < 0 || iAward >= MAX_AWARDS) return false;
|
||||
return s_awardsUnlocked[iQuadrant][iAward];
|
||||
}
|
||||
bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) { return false; }
|
||||
void C_4JProfile::Award(int iQuadrant, int iAwardNumber, bool bForce) {}
|
||||
bool C_4JProfile::IsAwardsFlagSet(int iQuadrant, int iAward) { return false; }
|
||||
void C_4JProfile::RichPresenceInit(int iPresenceCount, int iContextCount) {}
|
||||
void C_4JProfile::RegisterRichPresenceContext(int iGameConfigContextID) {}
|
||||
void C_4JProfile::SetRichPresenceContextValue(int iPad,int iContextID, int iVal) {}
|
||||
|
||||
@@ -46,7 +46,7 @@ void Input::tick(LocalPlayer *player)
|
||||
float kbXA = 0.0f;
|
||||
float kbYA = 0.0f;
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed())
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_RIGHT) )
|
||||
kbXA = g_KBMInput.GetMoveX();
|
||||
@@ -94,7 +94,7 @@ void Input::tick(LocalPlayer *player)
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed())
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
// Left Shift = sneak (hold to crouch)
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SNEAK_TOGGLE))
|
||||
@@ -166,7 +166,7 @@ void Input::tick(LocalPlayer *player)
|
||||
float turnY = ty * abs(ty) * turnSpeed;
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed())
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
float mouseSensitivity = ((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame)) / 100.0f;
|
||||
float mouseLookScale = 5.0f;
|
||||
@@ -190,7 +190,7 @@ void Input::tick(LocalPlayer *player)
|
||||
unsigned int jump = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP);
|
||||
bool kbJump = false;
|
||||
#ifdef _WINDOWS64
|
||||
kbJump = (iPad == 0) && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_JUMP);
|
||||
kbJump = (iPad == 0) && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive() && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_JUMP);
|
||||
#endif
|
||||
if( (jump > 0 || kbJump) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP) )
|
||||
jumping = true;
|
||||
|
||||
@@ -35,6 +35,8 @@ void KeyboardMouseInput::Init()
|
||||
m_mouseGrabbed = false;
|
||||
m_cursorHiddenForUI = false;
|
||||
m_windowFocused = true;
|
||||
m_kbmActive = true;
|
||||
m_screenWantsCursorHidden = false;
|
||||
m_hasInput = false;
|
||||
|
||||
RAWINPUTDEVICE rid;
|
||||
|
||||
@@ -64,6 +64,12 @@ public:
|
||||
void SetWindowFocused(bool focused);
|
||||
bool IsWindowFocused() const { return m_windowFocused; }
|
||||
|
||||
void SetKBMActive(bool active) { m_kbmActive = active; }
|
||||
bool IsKBMActive() const { return m_kbmActive; }
|
||||
|
||||
void SetScreenCursorHidden(bool hidden) { m_screenWantsCursorHidden = hidden; }
|
||||
bool IsScreenCursorHidden() const { return m_screenWantsCursorHidden; }
|
||||
|
||||
bool HasAnyInput() const { return m_hasInput; }
|
||||
|
||||
float GetMoveX() const;
|
||||
@@ -106,6 +112,9 @@ private:
|
||||
|
||||
bool m_windowFocused;
|
||||
|
||||
bool m_kbmActive;
|
||||
bool m_screenWantsCursorHidden;
|
||||
|
||||
bool m_hasInput;
|
||||
};
|
||||
|
||||
|
||||
@@ -328,6 +328,12 @@ void LocalPlayer::aiStep()
|
||||
}
|
||||
}
|
||||
if (isSneaking()) sprintTriggerTime = 0;
|
||||
|
||||
if (input->sprinting && !isSprinting() && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness) && input->ya >= runTreshold)
|
||||
{
|
||||
setSprinting(true);
|
||||
}
|
||||
|
||||
// 4J-PB - try not stopping sprint on collision
|
||||
//if (isSprinting() && (input->ya < runTreshold || horizontalCollision || !enoughFoodToSprint))
|
||||
if (isSprinting() && (input->ya < runTreshold || !enoughFoodToSprint))
|
||||
|
||||
@@ -4364,6 +4364,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
|
||||
<ClInclude Include="KeyboardMouseInput.h" />
|
||||
<ClInclude Include="Windows64\Network\NetworkPlayerInterface.h" />
|
||||
<ClInclude Include="Windows64\Network\P2PConnectionManagerWin.h" />
|
||||
<ClInclude Include="Windows64\Network\WinsockNetLayer.h" />
|
||||
<ClInclude Include="Common\Network\NetworkPlayerInterface.h" />
|
||||
<ClInclude Include="Common\Network\PlatformNetworkManagerInterface.h" />
|
||||
<ClInclude Include="Common\Network\PlatformNetworkManagerStub.h">
|
||||
@@ -21566,6 +21567,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
|
||||
<ClCompile Include="ConnectScreen.cpp" />
|
||||
<ClCompile Include="KeyboardMouseInput.cpp" />
|
||||
<ClCompile Include="Windows64\Network\P2PConnectionManagerWin.cpp" />
|
||||
<ClCompile Include="Windows64\Network\WinsockNetLayer.cpp" />
|
||||
<ClCompile Include="Common\Network\PlatformNetworkManagerStub.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Xbox 360'">true</ExcludedFromBuild>
|
||||
|
||||
@@ -2971,6 +2971,9 @@
|
||||
<ClInclude Include="Windows64\Network\P2PConnectionManagerWin.h">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Windows64\Network\WinsockNetLayer.h">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PS3\PS3Extras\EdgeZLib.h">
|
||||
<Filter>PS3\PS3Extras</Filter>
|
||||
</ClInclude>
|
||||
@@ -5097,6 +5100,9 @@
|
||||
<ClCompile Include="Windows64\Network\P2PConnectionManagerWin.cpp">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Windows64\Network\WinsockNetLayer.cpp">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PS3\PS3Extras\EdgeZLib.cpp">
|
||||
<Filter>PS3\PS3Extras</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -1470,7 +1470,7 @@ void Minecraft::run_middle()
|
||||
{
|
||||
if(InputManager.ButtonDown(i, MINECRAFT_ACTION_SNEAK_TOGGLE)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
|
||||
#ifdef _WINDOWS64
|
||||
if(i == 0 && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_SNEAK)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
|
||||
if(i == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_SNEAK)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -1481,7 +1481,7 @@ void Minecraft::run_middle()
|
||||
if(InputManager.ButtonPressed(i, MINECRAFT_ACTION_GAME_INFO)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_GAME_INFO;
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (i == 0)
|
||||
if (i == 0 && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_ACTION;
|
||||
@@ -1518,12 +1518,6 @@ void Minecraft::run_middle()
|
||||
showFpsCounter = !showFpsCounter;
|
||||
}
|
||||
|
||||
int wheel = g_KBMInput.GetMouseWheel();
|
||||
if (wheel > 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_RIGHT_SCROLL;
|
||||
else if (wheel < 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_LEFT_SCROLL;
|
||||
|
||||
for (int slot = 0; slot < 9; slot++)
|
||||
{
|
||||
if (g_KBMInput.IsKeyPressed('1' + slot))
|
||||
@@ -2339,7 +2333,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
||||
if (screen == NULL && !ui.GetMenuDisplayed(iPad) )
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsWindowFocused())
|
||||
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsWindowFocused() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
g_KBMInput.SetMouseGrabbed(true);
|
||||
}
|
||||
@@ -3285,7 +3279,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
||||
wheel = -1;
|
||||
}
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && wheel == 0)
|
||||
if (iPad == 0 && wheel == 0 && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
int mw = g_KBMInput.GetMouseWheel();
|
||||
if (mw > 0) wheel = -1;
|
||||
@@ -3325,7 +3319,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION) || (iPad == 0 && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT));
|
||||
bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION) || (iPad == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT));
|
||||
#else
|
||||
bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION);
|
||||
#endif
|
||||
@@ -3356,7 +3350,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
||||
}
|
||||
*/
|
||||
#ifdef _WINDOWS64
|
||||
bool useHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_USE) || (iPad == 0 && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_RIGHT));
|
||||
bool useHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_USE) || (iPad == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_RIGHT));
|
||||
#else
|
||||
bool useHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_USE);
|
||||
#endif
|
||||
|
||||
BIN
Minecraft.Client/Windows64/GameHDD/20260303223738/saveData.ms
Normal file
BIN
Minecraft.Client/Windows64/GameHDD/20260303223738/saveData.ms
Normal file
Binary file not shown.
BIN
Minecraft.Client/Windows64/GameHDD/20260303224052/saveData.ms
Normal file
BIN
Minecraft.Client/Windows64/GameHDD/20260303224052/saveData.ms
Normal file
Binary file not shown.
BIN
Minecraft.Client/Windows64/GameHDD/20260303225915/saveData.ms
Normal file
BIN
Minecraft.Client/Windows64/GameHDD/20260303225915/saveData.ms
Normal file
Binary file not shown.
BIN
Minecraft.Client/Windows64/GameHDD/20260303230038/saveData.ms
Normal file
BIN
Minecraft.Client/Windows64/GameHDD/20260303230038/saveData.ms
Normal file
Binary file not shown.
BIN
Minecraft.Client/Windows64/GameHDD/20260303231510/saveData.ms
Normal file
BIN
Minecraft.Client/Windows64/GameHDD/20260303231510/saveData.ms
Normal file
Binary file not shown.
910
Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp
Normal file
910
Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp
Normal file
@@ -0,0 +1,910 @@
|
||||
// Code implemented by LCEMP, credit if used on other repos
|
||||
|
||||
#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;
|
||||
s_connected = false;
|
||||
s_active = false;
|
||||
|
||||
if (s_hostConnectionSocket != INVALID_SOCKET)
|
||||
{
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool connected = false;
|
||||
BYTE assignedSmallId = 0;
|
||||
const int maxAttempts = 12;
|
||||
|
||||
for (int attempt = 0; attempt < maxAttempts; ++attempt)
|
||||
{
|
||||
s_hostConnectionSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
|
||||
if (s_hostConnectionSocket == INVALID_SOCKET)
|
||||
{
|
||||
app.DebugPrintf("socket() failed: %d\n", WSAGetLastError());
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
if (iResult == SOCKET_ERROR)
|
||||
{
|
||||
int err = WSAGetLastError();
|
||||
app.DebugPrintf("connect() to %s:%d failed (attempt %d/%d): %d\n", ip, port, attempt + 1, maxAttempts, err);
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
Sleep(200);
|
||||
continue;
|
||||
}
|
||||
|
||||
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 (attempt %d/%d)\n", attempt + 1, maxAttempts);
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
Sleep(200);
|
||||
continue;
|
||||
}
|
||||
|
||||
assignedSmallId = assignBuf[0];
|
||||
connected = true;
|
||||
break;
|
||||
}
|
||||
freeaddrinfo(result);
|
||||
|
||||
if (!connected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
s_localSmallId = assignedSmallId;
|
||||
|
||||
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);
|
||||
|
||||
std::vector<BYTE> recvBuf;
|
||||
recvBuf.resize(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 =
|
||||
((uint32_t)header[0] << 24) |
|
||||
((uint32_t)header[1] << 16) |
|
||||
((uint32_t)header[2] << 8) |
|
||||
((uint32_t)header[3]);
|
||||
|
||||
if (packetSize <= 0 || packetSize > WIN64_NET_MAX_PACKET_SIZE)
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Invalid packet size %d from client smallId=%d (max=%d)\n",
|
||||
packetSize,
|
||||
clientSmallId,
|
||||
(int)WIN64_NET_MAX_PACKET_SIZE);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((int)recvBuf.size() < packetSize)
|
||||
{
|
||||
recvBuf.resize(packetSize);
|
||||
app.DebugPrintf("Win64 LAN: Resized host recv buffer to %d bytes for client smallId=%d\n", packetSize, clientSmallId);
|
||||
}
|
||||
|
||||
if (!RecvExact(sock, &recvBuf[0], packetSize))
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Client smallId=%d disconnected (body)\n", clientSmallId);
|
||||
break;
|
||||
}
|
||||
|
||||
HandleDataReceived(clientSmallId, s_hostSmallId, &recvBuf[0], packetSize);
|
||||
}
|
||||
|
||||
EnterCriticalSection(&s_connectionsLock);
|
||||
for (size_t i = 0; i < s_connections.size(); i++)
|
||||
{
|
||||
if (s_connections[i].smallId == clientSmallId)
|
||||
{
|
||||
s_connections[i].active = false;
|
||||
if (s_connections[i].tcpSocket != INVALID_SOCKET)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void WinsockNetLayer::CloseConnectionBySmallId(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 && s_connections[i].tcpSocket != INVALID_SOCKET)
|
||||
{
|
||||
closesocket(s_connections[i].tcpSocket);
|
||||
s_connections[i].tcpSocket = INVALID_SOCKET;
|
||||
app.DebugPrintf("Win64 LAN: Force-closed TCP connection for smallId=%d\n", smallId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&s_connectionsLock);
|
||||
}
|
||||
|
||||
DWORD WINAPI WinsockNetLayer::ClientRecvThreadProc(LPVOID param)
|
||||
{
|
||||
std::vector<BYTE> recvBuf;
|
||||
recvBuf.resize(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_MAX_PACKET_SIZE)
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Invalid packet size %d from host (max=%d)\n",
|
||||
packetSize,
|
||||
(int)WIN64_NET_MAX_PACKET_SIZE);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((int)recvBuf.size() < packetSize)
|
||||
{
|
||||
recvBuf.resize(packetSize);
|
||||
app.DebugPrintf("Win64 LAN: Resized client recv buffer to %d bytes\n", packetSize);
|
||||
}
|
||||
|
||||
if (!RecvExact(s_hostConnectionSocket, &recvBuf[0], packetSize))
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Disconnected from host (body)\n");
|
||||
break;
|
||||
}
|
||||
|
||||
HandleDataReceived(s_hostSmallId, s_localSmallId, &recvBuf[0], packetSize);
|
||||
}
|
||||
|
||||
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
|
||||
149
Minecraft.Client/Windows64/Network/WinsockNetLayer.h
Normal file
149
Minecraft.Client/Windows64/Network/WinsockNetLayer.h
Normal file
@@ -0,0 +1,149 @@
|
||||
#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_NET_MAX_PACKET_SIZE (4 * 1024 * 1024)
|
||||
#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 void CloseConnectionBySmallId(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
|
||||
@@ -26,6 +26,8 @@ void CConsoleMinecraftApp::StoreLaunchData()
|
||||
}
|
||||
void CConsoleMinecraftApp::ExitGame()
|
||||
{
|
||||
extern HWND g_hWnd;
|
||||
PostMessage(g_hWnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
void CConsoleMinecraftApp::FatalLoadError()
|
||||
{
|
||||
@@ -55,7 +57,8 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||
app.ReleaseSaveThumbnail();
|
||||
ProfileManager.SetLockedProfile(0);
|
||||
pMinecraft->user->name = L"Windows";
|
||||
extern wchar_t g_Win64UsernameW[17];
|
||||
pMinecraft->user->name = g_Win64UsernameW;
|
||||
app.ApplyGameSettingsChanged(0);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "Resource.h"
|
||||
#include "..\..\Minecraft.World\compression.h"
|
||||
#include "..\..\Minecraft.World\OldChunkStorage.h"
|
||||
#include "Network\WinsockNetLayer.h"
|
||||
|
||||
#include "Xbox/resource.h"
|
||||
|
||||
@@ -82,6 +83,9 @@ BOOL g_bWidescreen = TRUE;
|
||||
int g_iScreenWidth = 1920;
|
||||
int g_iScreenHeight = 1080;
|
||||
|
||||
char g_Win64Username[17] = {0};
|
||||
wchar_t g_Win64UsernameW[17] = {0};
|
||||
|
||||
void DefineActions(void)
|
||||
{
|
||||
// The app needs to define the actions required, and the possible mappings for these
|
||||
@@ -342,6 +346,52 @@ D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0;
|
||||
ID3D11Device* g_pd3dDevice = NULL;
|
||||
ID3D11DeviceContext* g_pImmediateContext = NULL;
|
||||
IDXGISwapChain* g_pSwapChain = NULL;
|
||||
|
||||
static WORD g_originalGammaRamp[3][256];
|
||||
static bool g_gammaRampSaved = false;
|
||||
|
||||
void Windows64_UpdateGamma(unsigned short usGamma)
|
||||
{
|
||||
if (!g_hWnd) return;
|
||||
|
||||
HDC hdc = GetDC(g_hWnd);
|
||||
if (!hdc) return;
|
||||
|
||||
if (!g_gammaRampSaved)
|
||||
{
|
||||
GetDeviceGammaRamp(hdc, g_originalGammaRamp);
|
||||
g_gammaRampSaved = true;
|
||||
}
|
||||
|
||||
float gamma = (float)usGamma / 32768.0f;
|
||||
if (gamma < 0.01f) gamma = 0.01f;
|
||||
if (gamma > 1.0f) gamma = 1.0f;
|
||||
|
||||
float invGamma = 1.0f / (0.5f + gamma * 0.5f);
|
||||
|
||||
WORD ramp[3][256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
float normalized = (float)i / 255.0f;
|
||||
float corrected = powf(normalized, invGamma);
|
||||
WORD val = (WORD)(corrected * 65535.0f + 0.5f);
|
||||
ramp[0][i] = val;
|
||||
ramp[1][i] = val;
|
||||
ramp[2][i] = val;
|
||||
}
|
||||
|
||||
SetDeviceGammaRamp(hdc, ramp);
|
||||
ReleaseDC(g_hWnd, hdc);
|
||||
}
|
||||
|
||||
void Windows64_RestoreGamma()
|
||||
{
|
||||
if (!g_gammaRampSaved || !g_hWnd) return;
|
||||
HDC hdc = GetDC(g_hWnd);
|
||||
if (!hdc) return;
|
||||
SetDeviceGammaRamp(hdc, g_originalGammaRamp);
|
||||
ReleaseDC(g_hWnd, hdc);
|
||||
}
|
||||
ID3D11RenderTargetView* g_pRenderTargetView = NULL;
|
||||
ID3D11DepthStencilView* g_pDepthStencilView = NULL;
|
||||
ID3D11Texture2D* g_pDepthStencilBuffer = NULL;
|
||||
@@ -829,6 +879,9 @@ void Render()
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CleanupDevice()
|
||||
{
|
||||
extern void Windows64_RestoreGamma();
|
||||
Windows64_RestoreGamma();
|
||||
|
||||
if( g_pImmediateContext ) g_pImmediateContext->ClearState();
|
||||
|
||||
if( g_pRenderTargetView ) g_pRenderTargetView->Release();
|
||||
@@ -877,8 +930,32 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
//g_iScreenWidth = 960;
|
||||
//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;
|
||||
if (!GetUserNameA(g_Win64Username, &sz))
|
||||
strncpy_s(g_Win64Username, 17, "Player", _TRUNCATE);
|
||||
g_Win64Username[16] = 0;
|
||||
}
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, g_Win64Username, -1, g_Win64UsernameW, 17);
|
||||
|
||||
// Initialize global strings
|
||||
MyRegisterClass(hInstance);
|
||||
@@ -1028,6 +1105,22 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app);
|
||||
|
||||
#endif
|
||||
|
||||
// Ensure the GameHDD save directory exists at runtime (the 4J_Storage lib expects it)
|
||||
{
|
||||
wchar_t exePath[MAX_PATH];
|
||||
if (GetModuleFileNameW(NULL, exePath, MAX_PATH))
|
||||
{
|
||||
wstring exeDir(exePath);
|
||||
size_t lastSlash = exeDir.find_last_of(L"\\/");
|
||||
if (lastSlash != wstring::npos)
|
||||
exeDir = exeDir.substr(0, lastSlash);
|
||||
wstring gameHDDPath = exeDir + L"\\Windows64\\GameHDD";
|
||||
CreateDirectoryW((exeDir + L"\\Windows64").c_str(), NULL);
|
||||
CreateDirectoryW(gameHDDPath.c_str(), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// Set a callback for the default player options to be set - when there is no profile data for the player
|
||||
ProfileManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app);
|
||||
#if 0
|
||||
@@ -1043,7 +1136,17 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
// ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet.
|
||||
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
|
||||
//app.InitGameSettings();
|
||||
@@ -1163,14 +1266,28 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
MSG msg = {0};
|
||||
while( WM_QUIT != msg.message )
|
||||
{
|
||||
g_KBMInput.Tick();
|
||||
|
||||
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
|
||||
{
|
||||
if( msg.message == WM_QUIT ) break;
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
continue;
|
||||
}
|
||||
if( msg.message == WM_QUIT ) break;
|
||||
|
||||
g_KBMInput.Tick();
|
||||
|
||||
#ifdef _DEBUG
|
||||
for( int vk = 0; vk < 256; vk++ )
|
||||
{
|
||||
if( g_KBMInput.IsKeyPressed(vk) )
|
||||
{
|
||||
char dbgBuf[64];
|
||||
sprintf_s(dbgBuf, "INPUT: Key pressed vk=0x%02X\n", vk);
|
||||
OutputDebugStringA(dbgBuf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
RenderManager.StartFrame();
|
||||
#if 0
|
||||
if(pMinecraft->soundEngine->isStreamingWavebankReady() &&
|
||||
@@ -1193,6 +1310,26 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
PIXBeginNamedEvent(0,"Input manager tick");
|
||||
InputManager.Tick();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
if (InputManager.IsPadConnected(0))
|
||||
{
|
||||
bool controllerActive = InputManager.ButtonPressed(0) ||
|
||||
InputManager.GetJoypadStick_LX(0,false) != 0.0f || InputManager.GetJoypadStick_LY(0,false) != 0.0f ||
|
||||
InputManager.GetJoypadStick_RX(0,false) != 0.0f || InputManager.GetJoypadStick_RY(0,false) != 0.0f ||
|
||||
InputManager.GetJoypadLTrigger(0,false) != 0 || InputManager.GetJoypadRTrigger(0,false) != 0;
|
||||
|
||||
if (controllerActive && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
g_KBMInput.SetKBMActive(false);
|
||||
g_KBMInput.SetMouseGrabbed(false);
|
||||
g_KBMInput.SetCursorHiddenForUI(true);
|
||||
}
|
||||
else if (!g_KBMInput.IsKBMActive() && g_KBMInput.HasAnyInput())
|
||||
{
|
||||
g_KBMInput.SetCursorHiddenForUI(false);
|
||||
g_KBMInput.SetKBMActive(true);
|
||||
}
|
||||
}
|
||||
PIXBeginNamedEvent(0,"Profile manager tick");
|
||||
// ProfileManager.Tick();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
#include "I18n.h"
|
||||
|
||||
Language *I18n::lang = Language::getInstance();
|
||||
wstring I18n::get(const wstring& id, ...)
|
||||
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"";
|
||||
#else
|
||||
//#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"";
|
||||
//#else
|
||||
va_list va;
|
||||
va_start(va, id);
|
||||
return I18n::get(id, va);
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
wstring I18n::get(const wstring& id, va_list args)
|
||||
|
||||
@@ -10,6 +10,6 @@ private:
|
||||
static Language *lang;
|
||||
|
||||
public:
|
||||
static wstring get(const wstring& id, ...);
|
||||
static wstring get(const wstring id, ...);
|
||||
static wstring get(const wstring& id, va_list args);
|
||||
};
|
||||
@@ -20,15 +20,15 @@ wstring Language::getElement(const wstring& elementId)
|
||||
return elementId;
|
||||
} */
|
||||
|
||||
wstring Language::getElement(const wstring& 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"";
|
||||
#else
|
||||
//#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"";
|
||||
//#else
|
||||
va_list args;
|
||||
va_start(args, elementId);
|
||||
return getElement(elementId, args);
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
wstring Language::getElement(const wstring& elementId, va_list args)
|
||||
|
||||
@@ -7,7 +7,7 @@ private:
|
||||
public:
|
||||
Language();
|
||||
static Language *getInstance();
|
||||
wstring getElement(const wstring& elementId, ...);
|
||||
wstring getElement(const wstring elementId, ...);
|
||||
wstring getElement(const wstring& elementId, va_list args);
|
||||
wstring getElementName(const wstring& elementId);
|
||||
wstring getElementDescription(const wstring& elementId);
|
||||
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
bool IsHost();
|
||||
bool IsGuest();
|
||||
bool IsLocal();
|
||||
PlayerUID GetXuid();
|
||||
PlayerUID GetXuid();
|
||||
LPCWSTR GetGamertag();
|
||||
int GetSessionIndex();
|
||||
bool IsTalking();
|
||||
@@ -215,10 +215,17 @@ public:
|
||||
int GetUserIndex();
|
||||
void SetCustomDataValue(ULONG_PTR ulpCustomDataValue);
|
||||
ULONG_PTR GetCustomDataValue();
|
||||
|
||||
BYTE m_smallId;
|
||||
bool m_isRemote;
|
||||
bool m_isHostPlayer;
|
||||
wchar_t m_gamertag[32];
|
||||
private:
|
||||
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_MESSAGES = 0;
|
||||
const int QNET_GETSENDQUEUESIZE_BYTES = 0;
|
||||
@@ -309,9 +316,12 @@ public:
|
||||
bool IsHost();
|
||||
HRESULT JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo);
|
||||
void HostGame();
|
||||
void ClientJoinGame();
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user