update lcemp networking
This commit is contained in:
51 files changed
+629
-183
No files matched your search
@@ -402,6 +402,7 @@ void Chunk::rebuild()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tile *tile = Tile::tiles[tileId];
|
Tile *tile = Tile::tiles[tileId];
|
||||||
|
if (!tile) continue;
|
||||||
if (currentLayer == 0 && tile->isEntityTile())
|
if (currentLayer == 0 && tile->isEntityTile())
|
||||||
{
|
{
|
||||||
shared_ptr<TileEntity> et = region->getTileEntity(x, y, z);
|
shared_ptr<TileEntity> et = region->getTileEntity(x, y, z);
|
||||||
@@ -739,9 +740,9 @@ void Chunk::rebuild_SPU()
|
|||||||
{
|
{
|
||||||
// 4J - get tile from those copied into our local array in earlier optimisation
|
// 4J - get tile from those copied into our local array in earlier optimisation
|
||||||
unsigned char tileId = pOutData->getTile(x,y,z);
|
unsigned char tileId = pOutData->getTile(x,y,z);
|
||||||
if (tileId > 0)
|
if (tileId > 0 && tileId != 0xff)
|
||||||
{
|
{
|
||||||
if (currentLayer == 0 && Tile::tiles[tileId]->isEntityTile())
|
if (currentLayer == 0 && Tile::tiles[tileId] && Tile::tiles[tileId]->isEntityTile())
|
||||||
{
|
{
|
||||||
shared_ptr<TileEntity> et = region.getTileEntity(x, y, z);
|
shared_ptr<TileEntity> et = region.getTileEntity(x, y, z);
|
||||||
if (TileEntityRenderDispatcher::instance->hasRenderer(et))
|
if (TileEntityRenderDispatcher::instance->hasRenderer(et))
|
||||||
@@ -754,6 +755,7 @@ void Chunk::rebuild_SPU()
|
|||||||
{
|
{
|
||||||
|
|
||||||
Tile *tile = Tile::tiles[tileId];
|
Tile *tile = Tile::tiles[tileId];
|
||||||
|
if (!tile) continue;
|
||||||
int renderLayer = tile->getRenderLayer();
|
int renderLayer = tile->getRenderLayer();
|
||||||
|
|
||||||
if (renderLayer != currentLayer)
|
if (renderLayer != currentLayer)
|
||||||
|
|||||||
@@ -776,6 +776,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet)
|
|||||||
player->yRotp = packet->yRot;
|
player->yRotp = packet->yRot;
|
||||||
player->yHeadRot = packet->yHeadRot * 360 / 256.0f;
|
player->yHeadRot = packet->yHeadRot * 360 / 256.0f;
|
||||||
player->setXuid(packet->xuid);
|
player->setXuid(packet->xuid);
|
||||||
|
player->setOnlineXuid(packet->OnlineXuid);
|
||||||
|
|
||||||
#ifdef _DURANGO
|
#ifdef _DURANGO
|
||||||
// On Durango request player display name from network manager
|
// On Durango request player display name from network manager
|
||||||
@@ -788,11 +789,11 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet)
|
|||||||
|
|
||||||
#if defined _WINDOWS64 || defined DISABLE_PSN || defined _DISABLE_XBLIVE
|
#if defined _WINDOWS64 || defined DISABLE_PSN || defined _DISABLE_XBLIVE
|
||||||
{
|
{
|
||||||
PlayerUID pktXuid = player->getXuid();
|
PlayerUID netXuid = packet->OnlineXuid;
|
||||||
const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e;
|
const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e;
|
||||||
if (pktXuid >= WIN64_XUID_BASE && pktXuid < WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS)
|
if (netXuid >= WIN64_XUID_BASE && netXuid < WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS)
|
||||||
{
|
{
|
||||||
BYTE smallId = (BYTE)(pktXuid - WIN64_XUID_BASE);
|
BYTE smallId = (BYTE)(netXuid - WIN64_XUID_BASE);
|
||||||
INetworkPlayer *np = g_NetworkManager.GetPlayerBySmallId(smallId);
|
INetworkPlayer *np = g_NetworkManager.GetPlayerBySmallId(smallId);
|
||||||
if (np != NULL)
|
if (np != NULL)
|
||||||
{
|
{
|
||||||
@@ -954,39 +955,6 @@ void ClientConnection::handleMoveEntitySmall(shared_ptr<MoveEntityPacketSmall> p
|
|||||||
|
|
||||||
void ClientConnection::handleRemoveEntity(shared_ptr<RemoveEntitiesPacket> packet)
|
void ClientConnection::handleRemoveEntity(shared_ptr<RemoveEntitiesPacket> packet)
|
||||||
{
|
{
|
||||||
#if defined _WINDOWS64 || defined DISABLE_PSN || defined _DISABLE_XBLIVE
|
|
||||||
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++)
|
for (int i = 0; i < packet->ids.length; i++)
|
||||||
{
|
{
|
||||||
level->removeEntity(packet->ids[i]);
|
level->removeEntity(packet->ids[i]);
|
||||||
@@ -1068,6 +1036,7 @@ void ClientConnection::handleChunkVisibility(shared_ptr<ChunkVisibilityPacket> p
|
|||||||
void ClientConnection::handleChunkTilesUpdate(shared_ptr<ChunkTilesUpdatePacket> packet)
|
void ClientConnection::handleChunkTilesUpdate(shared_ptr<ChunkTilesUpdatePacket> packet)
|
||||||
{
|
{
|
||||||
// 4J - changed to encode level in packet
|
// 4J - changed to encode level in packet
|
||||||
|
if (packet->levelIdx >= minecraft->levels.length) return;
|
||||||
MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->levels[packet->levelIdx];
|
MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->levels[packet->levelIdx];
|
||||||
if( dimensionLevel )
|
if( dimensionLevel )
|
||||||
{
|
{
|
||||||
@@ -1137,6 +1106,7 @@ void ClientConnection::handleChunkTilesUpdate(shared_ptr<ChunkTilesUpdatePacket>
|
|||||||
void ClientConnection::handleBlockRegionUpdate(shared_ptr<BlockRegionUpdatePacket> packet)
|
void ClientConnection::handleBlockRegionUpdate(shared_ptr<BlockRegionUpdatePacket> packet)
|
||||||
{
|
{
|
||||||
// 4J - changed to encode level in packet
|
// 4J - changed to encode level in packet
|
||||||
|
if (packet->levelIdx >= minecraft->levels.length) return;
|
||||||
MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->levels[packet->levelIdx];
|
MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->levels[packet->levelIdx];
|
||||||
if( dimensionLevel )
|
if( dimensionLevel )
|
||||||
{
|
{
|
||||||
@@ -1194,6 +1164,8 @@ void ClientConnection::handleTileUpdate(shared_ptr<TileUpdatePacket> packet)
|
|||||||
destroyTilePacket = true;
|
destroyTilePacket = true;
|
||||||
}
|
}
|
||||||
// 4J - changed to encode level in packet
|
// 4J - changed to encode level in packet
|
||||||
|
if (packet->levelIdx >= minecraft->levels.length) return;
|
||||||
|
|
||||||
MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->levels[packet->levelIdx];
|
MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->levels[packet->levelIdx];
|
||||||
if( dimensionLevel )
|
if( dimensionLevel )
|
||||||
{
|
{
|
||||||
@@ -2350,6 +2322,7 @@ void ClientConnection::handleAddMob(shared_ptr<AddMobPacket> packet)
|
|||||||
float xRot = packet->xRot * 360 / 256.0f;
|
float xRot = packet->xRot * 360 / 256.0f;
|
||||||
|
|
||||||
shared_ptr<LivingEntity> mob = dynamic_pointer_cast<LivingEntity>(EntityIO::newById(packet->type, level));
|
shared_ptr<LivingEntity> mob = dynamic_pointer_cast<LivingEntity>(EntityIO::newById(packet->type, level));
|
||||||
|
if (mob == NULL) return;
|
||||||
mob->xp = packet->x;
|
mob->xp = packet->x;
|
||||||
mob->yp = packet->y;
|
mob->yp = packet->y;
|
||||||
mob->zp = packet->z;
|
mob->zp = packet->z;
|
||||||
@@ -3593,10 +3566,12 @@ void ClientConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UIScene *scene = ui.GetTopScene(m_userIndex, eUILayer_Scene);
|
UIScene *scene = ui.GetTopScene(m_userIndex, eUILayer_Scene);
|
||||||
UIScene_TradingMenu *screen = (UIScene_TradingMenu *)scene;
|
UIScene_TradingMenu *screen = dynamic_cast<UIScene_TradingMenu *>(scene);
|
||||||
trader = screen->getMerchant();
|
if (screen != NULL)
|
||||||
|
trader = screen->getMerchant();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (trader == NULL) return;
|
||||||
MerchantRecipeList *recipeList = MerchantRecipeList::createFromStream(&input);
|
MerchantRecipeList *recipeList = MerchantRecipeList::createFromStream(&input);
|
||||||
trader->overrideOffers(recipeList);
|
trader->overrideOffers(recipeList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ BYTE NetworkSocketLayer::s_nextSmallId = 1;
|
|||||||
CRITICAL_SECTION NetworkSocketLayer::s_sendLock;
|
CRITICAL_SECTION NetworkSocketLayer::s_sendLock;
|
||||||
CRITICAL_SECTION NetworkSocketLayer::s_connectionsLock;
|
CRITICAL_SECTION NetworkSocketLayer::s_connectionsLock;
|
||||||
|
|
||||||
std::vector<RemoteConnection> NetworkSocketLayer::s_connections;
|
RemoteConnection NetworkSocketLayer::s_connections[NETWORK_LAN_MAX_CLIENTS + 1];
|
||||||
|
|
||||||
C4JThread* NetworkSocketLayer::s_advertiseThread = NULL;
|
C4JThread* NetworkSocketLayer::s_advertiseThread = NULL;
|
||||||
volatile bool NetworkSocketLayer::s_advertising = false;
|
volatile bool NetworkSocketLayer::s_advertising = false;
|
||||||
@@ -55,6 +55,9 @@ std::vector<LANSession> NetworkSocketLayer::s_discoveredSessions;
|
|||||||
CRITICAL_SECTION NetworkSocketLayer::s_disconnectLock;
|
CRITICAL_SECTION NetworkSocketLayer::s_disconnectLock;
|
||||||
std::vector<BYTE> NetworkSocketLayer::s_disconnectedSmallIds;
|
std::vector<BYTE> NetworkSocketLayer::s_disconnectedSmallIds;
|
||||||
|
|
||||||
|
CRITICAL_SECTION NetworkSocketLayer::s_pendingJoinLock;
|
||||||
|
std::vector<BYTE> NetworkSocketLayer::s_pendingJoinSmallIds;
|
||||||
|
|
||||||
CRITICAL_SECTION NetworkSocketLayer::s_freeSmallIdLock;
|
CRITICAL_SECTION NetworkSocketLayer::s_freeSmallIdLock;
|
||||||
std::vector<BYTE> NetworkSocketLayer::s_freeSmallIds;
|
std::vector<BYTE> NetworkSocketLayer::s_freeSmallIds;
|
||||||
|
|
||||||
@@ -83,7 +86,17 @@ bool NetworkSocketLayer::Initialize()
|
|||||||
InitializeCriticalSection(&s_advertiseLock);
|
InitializeCriticalSection(&s_advertiseLock);
|
||||||
InitializeCriticalSection(&s_discoveryLock);
|
InitializeCriticalSection(&s_discoveryLock);
|
||||||
InitializeCriticalSection(&s_disconnectLock);
|
InitializeCriticalSection(&s_disconnectLock);
|
||||||
|
InitializeCriticalSection(&s_pendingJoinLock);
|
||||||
InitializeCriticalSection(&s_freeSmallIdLock);
|
InitializeCriticalSection(&s_freeSmallIdLock);
|
||||||
|
|
||||||
|
for (int i = 0; i < NETWORK_LAN_MAX_CLIENTS + 1; i++)
|
||||||
|
{
|
||||||
|
s_connections[i].tcpSocket = INVALID_SOCKET;
|
||||||
|
s_connections[i].smallId = 0;
|
||||||
|
s_connections[i].recvThread = NULL;
|
||||||
|
s_connections[i].active = false;
|
||||||
|
InitializeCriticalSection(&s_connections[i].sendLock);
|
||||||
|
}
|
||||||
s_locksCreated = true;
|
s_locksCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +180,7 @@ void NetworkSocketLayer::Shutdown()
|
|||||||
|
|
||||||
EnterCriticalSection(&s_connectionsLock);
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
for (size_t i = 0; i < s_connections.size(); i++)
|
for (int i = 0; i < NETWORK_LAN_MAX_CLIENTS + 1; i++)
|
||||||
{
|
{
|
||||||
s_connections[i].active = false;
|
s_connections[i].active = false;
|
||||||
#if defined _WINDOWS64 || defined _XBOX
|
#if defined _WINDOWS64 || defined _XBOX
|
||||||
@@ -177,9 +190,16 @@ void NetworkSocketLayer::Shutdown()
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
closesocket(s_connections[i].tcpSocket);
|
closesocket(s_connections[i].tcpSocket);
|
||||||
|
s_connections[i].tcpSocket = INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
if (s_connections[i].recvThread != NULL)
|
||||||
|
{
|
||||||
|
s_connections[i].recvThread->WaitForCompletion(2000);
|
||||||
|
delete s_connections[i].recvThread;
|
||||||
|
s_connections[i].recvThread = NULL;
|
||||||
|
}
|
||||||
|
DeleteCriticalSection(&s_connections[i].sendLock);
|
||||||
}
|
}
|
||||||
s_connections.clear();
|
|
||||||
LeaveCriticalSection(&s_connectionsLock);
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
if (s_acceptThread != NULL)
|
if (s_acceptThread != NULL)
|
||||||
@@ -204,6 +224,8 @@ void NetworkSocketLayer::Shutdown()
|
|||||||
DeleteCriticalSection(&s_discoveryLock);
|
DeleteCriticalSection(&s_discoveryLock);
|
||||||
DeleteCriticalSection(&s_disconnectLock);
|
DeleteCriticalSection(&s_disconnectLock);
|
||||||
s_disconnectedSmallIds.clear();
|
s_disconnectedSmallIds.clear();
|
||||||
|
DeleteCriticalSection(&s_pendingJoinLock);
|
||||||
|
s_pendingJoinSmallIds.clear();
|
||||||
DeleteCriticalSection(&s_freeSmallIdLock);
|
DeleteCriticalSection(&s_freeSmallIdLock);
|
||||||
s_freeSmallIds.clear();
|
s_freeSmallIds.clear();
|
||||||
s_locksCreated = false;
|
s_locksCreated = false;
|
||||||
@@ -219,6 +241,14 @@ bool NetworkSocketLayer::HostGame(int port)
|
|||||||
s_isHost = true;
|
s_isHost = true;
|
||||||
s_localSmallId = 0;
|
s_localSmallId = 0;
|
||||||
s_hostSmallId = 0;
|
s_hostSmallId = 0;
|
||||||
|
s_connected = false;
|
||||||
|
s_active = false;
|
||||||
|
|
||||||
|
if (s_hostConnectionSocket != INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(s_hostConnectionSocket);
|
||||||
|
s_hostConnectionSocket = INVALID_SOCKET;
|
||||||
|
}
|
||||||
s_nextSmallId = 1;
|
s_nextSmallId = 1;
|
||||||
s_hostGamePort = port;
|
s_hostGamePort = port;
|
||||||
|
|
||||||
@@ -786,9 +816,9 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
|
|||||||
bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSize)
|
bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSize)
|
||||||
{
|
{
|
||||||
#if defined _WINDOWS64 || defined _XBOX
|
#if defined _WINDOWS64 || defined _XBOX
|
||||||
if (sock == INVALID_SOCKET || dataSize <= 0) return false;
|
if (sock == INVALID_SOCKET || dataSize <= 0 || dataSize > NETWORK_LAN_MAX_PACKET_SIZE) return false;
|
||||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||||
if (sock < 0 || dataSize <= 0) return false;
|
if (sock < 0 || dataSize <= 0 || dataSize > NETWORK_LAN_MAX_PACKET_SIZE) return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EnterCriticalSection(&s_sendLock);
|
EnterCriticalSection(&s_sendLock);
|
||||||
@@ -809,10 +839,7 @@ bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSiz
|
|||||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||||
if (sent < 0 || sent == 0)
|
if (sent < 0 || sent == 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
LeaveCriticalSection(&s_sendLock);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
totalSent += sent;
|
totalSent += sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -826,14 +853,10 @@ bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSiz
|
|||||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||||
if (sent < 0 || sent == 0)
|
if (sent < 0 || sent == 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
LeaveCriticalSection(&s_sendLock);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
totalSent += sent;
|
totalSent += sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
LeaveCriticalSection(&s_sendLock);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -843,31 +866,38 @@ bool NetworkSocketLayer::SendToSmallId(BYTE targetSmallId, const void *data, int
|
|||||||
|
|
||||||
if (s_isHost)
|
if (s_isHost)
|
||||||
{
|
{
|
||||||
SOCKET sock = GetSocketForSmallId(targetSmallId);
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
#if defined _WINDOWS64 || defined _XBOX
|
if (targetSmallId >= NETWORK_LAN_MAX_CLIENTS + 1 || !s_connections[targetSmallId].active)
|
||||||
if (sock == INVALID_SOCKET) return false;
|
{
|
||||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
if (sock < 0) return false;
|
return false;
|
||||||
#endif
|
}
|
||||||
return SendOnSocket(sock, data, dataSize);
|
SOCKET sock = s_connections[targetSmallId].tcpSocket;
|
||||||
|
CRITICAL_SECTION *pLock = &s_connections[targetSmallId].sendLock;
|
||||||
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
|
EnterCriticalSection(pLock);
|
||||||
|
bool result = SendOnSocket(sock, data, dataSize);
|
||||||
|
LeaveCriticalSection(pLock);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return SendOnSocket(s_hostConnectionSocket, data, dataSize);
|
EnterCriticalSection(&s_sendLock);
|
||||||
|
bool result = SendOnSocket(s_hostConnectionSocket, data, dataSize);
|
||||||
|
LeaveCriticalSection(&s_sendLock);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKET NetworkSocketLayer::GetSocketForSmallId(BYTE smallId)
|
SOCKET NetworkSocketLayer::GetSocketForSmallId(BYTE smallId)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&s_connectionsLock);
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
for (size_t i = 0; i < s_connections.size(); i++)
|
if (smallId < NETWORK_LAN_MAX_CLIENTS + 1 && s_connections[smallId].active)
|
||||||
{
|
{
|
||||||
if (s_connections[i].smallId == smallId && s_connections[i].active)
|
SOCKET sock = s_connections[smallId].tcpSocket;
|
||||||
{
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
SOCKET sock = s_connections[i].tcpSocket;
|
return sock;
|
||||||
LeaveCriticalSection(&s_connectionsLock);
|
|
||||||
return sock;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&s_connectionsLock);
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
#if defined _WINDOWS64 || defined _XBOX
|
#if defined _WINDOWS64 || defined _XBOX
|
||||||
@@ -981,15 +1011,19 @@ int NetworkSocketLayer::AcceptThreadProc(LPVOID param)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteConnection conn;
|
RemoteConnection &conn = s_connections[assignedSmallId];
|
||||||
|
|
||||||
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
|
if (conn.recvThread != NULL)
|
||||||
|
{
|
||||||
|
conn.recvThread->WaitForCompletion(2000);
|
||||||
|
delete conn.recvThread;
|
||||||
|
conn.recvThread = NULL;
|
||||||
|
}
|
||||||
conn.tcpSocket = clientSocket;
|
conn.tcpSocket = clientSocket;
|
||||||
conn.smallId = assignedSmallId;
|
conn.smallId = assignedSmallId;
|
||||||
conn.active = true;
|
conn.active = true;
|
||||||
conn.recvThread = NULL;
|
|
||||||
|
|
||||||
EnterCriticalSection(&s_connectionsLock);
|
|
||||||
s_connections.push_back(conn);
|
|
||||||
int connIdx = (int)s_connections.size() - 1;
|
|
||||||
LeaveCriticalSection(&s_connectionsLock);
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
app.DebugPrintf("Win64 LAN: Client connected, assigned smallId=%d\n", assignedSmallId);
|
app.DebugPrintf("Win64 LAN: Client connected, assigned smallId=%d\n", assignedSmallId);
|
||||||
@@ -999,17 +1033,17 @@ int NetworkSocketLayer::AcceptThreadProc(LPVOID param)
|
|||||||
extern void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal);
|
extern void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal);
|
||||||
Win64_SetupRemoteQNetPlayer(qnetPlayer, assignedSmallId, false, false);
|
Win64_SetupRemoteQNetPlayer(qnetPlayer, assignedSmallId, false, false);
|
||||||
|
|
||||||
extern CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
EnterCriticalSection(&s_pendingJoinLock);
|
||||||
g_pPlatformNetworkManager->NotifyPlayerJoined(qnetPlayer);
|
s_pendingJoinSmallIds.push_back(assignedSmallId);
|
||||||
|
LeaveCriticalSection(&s_pendingJoinLock);
|
||||||
|
|
||||||
DWORD *threadParam = new DWORD;
|
DWORD *threadParam = new DWORD;
|
||||||
*threadParam = connIdx;
|
*threadParam = assignedSmallId;
|
||||||
C4JThread* hThread = new C4JThread(RecvThreadProc, threadParam, "RecvThreadProc");
|
C4JThread* hThread = new C4JThread(RecvThreadProc, threadParam, "RecvThreadProc");
|
||||||
hThread->Run();
|
hThread->Run();
|
||||||
|
|
||||||
EnterCriticalSection(&s_connectionsLock);
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
if (connIdx < (int)s_connections.size())
|
s_connections[assignedSmallId].recvThread = hThread;
|
||||||
s_connections[connIdx].recvThread = hThread;
|
|
||||||
LeaveCriticalSection(&s_connectionsLock);
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1017,17 +1051,16 @@ int NetworkSocketLayer::AcceptThreadProc(LPVOID param)
|
|||||||
|
|
||||||
int NetworkSocketLayer::RecvThreadProc(LPVOID param)
|
int NetworkSocketLayer::RecvThreadProc(LPVOID param)
|
||||||
{
|
{
|
||||||
DWORD connIdx = *(DWORD *)param;
|
BYTE clientSmallId = (BYTE)*(DWORD *)param;
|
||||||
delete (DWORD *)param;
|
delete (DWORD *)param;
|
||||||
|
|
||||||
EnterCriticalSection(&s_connectionsLock);
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
if (connIdx >= (DWORD)s_connections.size())
|
if (clientSmallId >= NETWORK_LAN_MAX_CLIENTS + 1 || !s_connections[clientSmallId].active)
|
||||||
{
|
{
|
||||||
LeaveCriticalSection(&s_connectionsLock);
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SOCKET sock = s_connections[connIdx].tcpSocket;
|
SOCKET sock = s_connections[clientSmallId].tcpSocket;
|
||||||
BYTE clientSmallId = s_connections[connIdx].smallId;
|
|
||||||
LeaveCriticalSection(&s_connectionsLock);
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
std::vector<BYTE> recvBuf;
|
std::vector<BYTE> recvBuf;
|
||||||
@@ -1048,7 +1081,7 @@ int NetworkSocketLayer::RecvThreadProc(LPVOID param)
|
|||||||
((uint32_t)header[2] << 8) |
|
((uint32_t)header[2] << 8) |
|
||||||
((uint32_t)header[3]);
|
((uint32_t)header[3]);
|
||||||
|
|
||||||
if (packetSize <= 0 || packetSize > NETWORK_LAN_MAX_PACKET_SIZE)
|
if (packetSize <= 0 || (unsigned int)packetSize > NETWORK_LAN_MAX_PACKET_SIZE)
|
||||||
{
|
{
|
||||||
app.DebugPrintf("LAN: Invalid packet size %d from client smallId=%d (max=%d)\n",
|
app.DebugPrintf("LAN: Invalid packet size %d from client smallId=%d (max=%d)\n",
|
||||||
packetSize,
|
packetSize,
|
||||||
@@ -1073,18 +1106,11 @@ int NetworkSocketLayer::RecvThreadProc(LPVOID param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&s_connectionsLock);
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
for (size_t i = 0; i < s_connections.size(); i++)
|
s_connections[clientSmallId].active = false;
|
||||||
|
if (s_connections[clientSmallId].tcpSocket != INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
if (s_connections[i].smallId == clientSmallId)
|
closesocket(s_connections[clientSmallId].tcpSocket);
|
||||||
{
|
s_connections[clientSmallId].tcpSocket = INVALID_SOCKET;
|
||||||
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);
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
|
|
||||||
@@ -1116,18 +1142,34 @@ void NetworkSocketLayer::PushFreeSmallId(BYTE smallId)
|
|||||||
LeaveCriticalSection(&s_freeSmallIdLock);
|
LeaveCriticalSection(&s_freeSmallIdLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NetworkSocketLayer::PopPendingJoinSmallId(BYTE *outSmallId)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
EnterCriticalSection(&s_pendingJoinLock);
|
||||||
|
if (!s_pendingJoinSmallIds.empty())
|
||||||
|
{
|
||||||
|
*outSmallId = s_pendingJoinSmallIds.back();
|
||||||
|
s_pendingJoinSmallIds.pop_back();
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&s_pendingJoinLock);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkSocketLayer::IsSmallIdConnected(BYTE smallId)
|
||||||
|
{
|
||||||
|
if (smallId >= NETWORK_LAN_MAX_CLIENTS + 1) return false;
|
||||||
|
return s_connections[smallId].active;
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkSocketLayer::CloseConnectionBySmallId(BYTE smallId)
|
void NetworkSocketLayer::CloseConnectionBySmallId(BYTE smallId)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&s_connectionsLock);
|
EnterCriticalSection(&s_connectionsLock);
|
||||||
for (size_t i = 0; i < s_connections.size(); i++)
|
if (smallId < NETWORK_LAN_MAX_CLIENTS + 1 && s_connections[smallId].active && s_connections[smallId].tcpSocket != INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
if (s_connections[i].smallId == smallId && s_connections[i].active && s_connections[i].tcpSocket != INVALID_SOCKET)
|
closesocket(s_connections[smallId].tcpSocket);
|
||||||
{
|
s_connections[smallId].tcpSocket = INVALID_SOCKET;
|
||||||
closesocket(s_connections[i].tcpSocket);
|
app.DebugPrintf("Win64 LAN: Force-closed TCP connection for smallId=%d\n", smallId);
|
||||||
s_connections[i].tcpSocket = INVALID_SOCKET;
|
|
||||||
app.DebugPrintf("Win64 LAN: Force-closed TCP connection for smallId=%d\n", smallId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&s_connectionsLock);
|
LeaveCriticalSection(&s_connectionsLock);
|
||||||
}
|
}
|
||||||
@@ -1150,9 +1192,9 @@ int NetworkSocketLayer::ClientRecvThreadProc(LPVOID param)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int packetSize = (header[0] << 24) | (header[1] << 16) | (header[2] << 8) | header[3];
|
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 > NETWORK_LAN_MAX_PACKET_SIZE)
|
if (packetSize <= 0 || (unsigned int)packetSize > NETWORK_LAN_MAX_PACKET_SIZE)
|
||||||
{
|
{
|
||||||
app.DebugPrintf("LAN: Invalid packet size %d from host\n", packetSize);
|
app.DebugPrintf("LAN: Invalid packet size %d from host\n", packetSize);
|
||||||
break;
|
break;
|
||||||
@@ -1161,7 +1203,6 @@ int NetworkSocketLayer::ClientRecvThreadProc(LPVOID param)
|
|||||||
if ((int)recvBuf.size() < packetSize)
|
if ((int)recvBuf.size() < packetSize)
|
||||||
{
|
{
|
||||||
recvBuf.resize(packetSize);
|
recvBuf.resize(packetSize);
|
||||||
app.DebugPrintf("LAN: Resized client recv buffer to %d bytes\n", packetSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RecvExact(s_hostConnectionSocket, &recvBuf[0], packetSize))
|
if (!RecvExact(s_hostConnectionSocket, &recvBuf[0], packetSize))
|
||||||
@@ -1494,8 +1535,8 @@ std::vector<LANSession> NetworkSocketLayer::GetDiscoveredSessions()
|
|||||||
|
|
||||||
int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param)
|
int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param)
|
||||||
{
|
{
|
||||||
app.DebugPrintf("Discovery thread started\n");
|
|
||||||
char recvBuf[1024];
|
char recvBuf[1024];
|
||||||
|
const size_t MAX_DISCOVERED_SESSIONS = 64;
|
||||||
|
|
||||||
while (s_discovering)
|
while (s_discovering)
|
||||||
{
|
{
|
||||||
@@ -1544,6 +1585,11 @@ int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param)
|
|||||||
if (broadcast->magic != NETWORK_LAN_BROADCAST_MAGIC)
|
if (broadcast->magic != NETWORK_LAN_BROADCAST_MAGIC)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
broadcast->hostName[31] = L'\0';
|
||||||
|
|
||||||
|
for (int pn = 0; pn < 8; pn++)
|
||||||
|
broadcast->playerNames[pn][XUSER_NAME_SIZE - 1] = '\0';
|
||||||
|
|
||||||
char senderIP[64];
|
char senderIP[64];
|
||||||
#if defined _XBOX
|
#if defined _XBOX
|
||||||
unsigned char *ipBytes = (unsigned char *)&senderAddr.sin_addr;
|
unsigned char *ipBytes = (unsigned char *)&senderAddr.sin_addr;
|
||||||
@@ -1586,6 +1632,12 @@ int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param)
|
|||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
|
if (s_discoveredSessions.size() >= MAX_DISCOVERED_SESSIONS)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&s_discoveryLock);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
LANSession session;
|
LANSession session;
|
||||||
memset(&session, 0, sizeof(session));
|
memset(&session, 0, sizeof(session));
|
||||||
strncpy(session.hostIP, senderIP, sizeof(session.hostIP) - 1);
|
strncpy(session.hostIP, senderIP, sizeof(session.hostIP) - 1);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#define NETWORK_LAN_DEFAULT_PORT 25565
|
#define NETWORK_LAN_DEFAULT_PORT 25565
|
||||||
#define NETWORK_LAN_MAX_CLIENTS 7
|
#define NETWORK_LAN_MAX_CLIENTS 7
|
||||||
#define NETWORK_LAN_RECV_BUFFER_SIZE 65536
|
#define NETWORK_LAN_RECV_BUFFER_SIZE 65536
|
||||||
#define NETWORK_LAN_MAX_PACKET_SIZE (4 * 1024 * 1024)
|
#define NETWORK_LAN_MAX_PACKET_SIZE (3 * 1024 * 1024)
|
||||||
#define NETWORK_LAN_DISCOVERY_PORT 25566
|
#define NETWORK_LAN_DISCOVERY_PORT 25566
|
||||||
#define NETWORK_LAN_BROADCAST_MAGIC 0x4D434C4E
|
#define NETWORK_LAN_BROADCAST_MAGIC 0x4D434C4E
|
||||||
|
|
||||||
@@ -141,6 +141,7 @@ struct RemoteConnection
|
|||||||
BYTE smallId;
|
BYTE smallId;
|
||||||
C4JThread* recvThread;
|
C4JThread* recvThread;
|
||||||
volatile bool active;
|
volatile bool active;
|
||||||
|
CRITICAL_SECTION sendLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NetworkSocketLayer
|
class NetworkSocketLayer
|
||||||
@@ -170,6 +171,10 @@ public:
|
|||||||
static void PushFreeSmallId(BYTE smallId);
|
static void PushFreeSmallId(BYTE smallId);
|
||||||
static void CloseConnectionBySmallId(BYTE smallId);
|
static void CloseConnectionBySmallId(BYTE smallId);
|
||||||
|
|
||||||
|
static bool PopPendingJoinSmallId(BYTE *outSmallId);
|
||||||
|
|
||||||
|
static bool IsSmallIdConnected(BYTE smallId);
|
||||||
|
|
||||||
static bool StartAdvertising(int gamePort, const wchar_t *hostName, unsigned int gameSettings, unsigned int texPackId, unsigned char subTexId, unsigned short netVer);
|
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 StopAdvertising();
|
||||||
static void UpdateAdvertisePlayerCount(BYTE count);
|
static void UpdateAdvertisePlayerCount(BYTE count);
|
||||||
@@ -206,7 +211,7 @@ private:
|
|||||||
static CRITICAL_SECTION s_sendLock;
|
static CRITICAL_SECTION s_sendLock;
|
||||||
static CRITICAL_SECTION s_connectionsLock;
|
static CRITICAL_SECTION s_connectionsLock;
|
||||||
|
|
||||||
static std::vector<RemoteConnection> s_connections;
|
static RemoteConnection s_connections[NETWORK_LAN_MAX_CLIENTS + 1];
|
||||||
|
|
||||||
static SOCKET s_advertiseSock;
|
static SOCKET s_advertiseSock;
|
||||||
static C4JThread* s_advertiseThread;
|
static C4JThread* s_advertiseThread;
|
||||||
@@ -224,6 +229,9 @@ private:
|
|||||||
static CRITICAL_SECTION s_disconnectLock;
|
static CRITICAL_SECTION s_disconnectLock;
|
||||||
static std::vector<BYTE> s_disconnectedSmallIds;
|
static std::vector<BYTE> s_disconnectedSmallIds;
|
||||||
|
|
||||||
|
static CRITICAL_SECTION s_pendingJoinLock;
|
||||||
|
static std::vector<BYTE> s_pendingJoinSmallIds;
|
||||||
|
|
||||||
static CRITICAL_SECTION s_freeSmallIdLock;
|
static CRITICAL_SECTION s_freeSmallIdLock;
|
||||||
static std::vector<BYTE> s_freeSmallIds;
|
static std::vector<BYTE> s_freeSmallIds;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -233,6 +233,8 @@ void CPlatformNetworkManagerStub::DoWork()
|
|||||||
BYTE disconnectedSmallId;
|
BYTE disconnectedSmallId;
|
||||||
while (NetworkSocketLayer::PopDisconnectedSmallId(&disconnectedSmallId))
|
while (NetworkSocketLayer::PopDisconnectedSmallId(&disconnectedSmallId))
|
||||||
{
|
{
|
||||||
|
if (disconnectedSmallId == 0) continue;
|
||||||
|
if (NetworkSocketLayer::IsSmallIdConnected(disconnectedSmallId)) continue;
|
||||||
IQNetPlayer *qnetPlayer = m_pIQNet->GetPlayerBySmallId(disconnectedSmallId);
|
IQNetPlayer *qnetPlayer = m_pIQNet->GetPlayerBySmallId(disconnectedSmallId);
|
||||||
if (qnetPlayer != NULL && qnetPlayer->m_smallId == disconnectedSmallId)
|
if (qnetPlayer != NULL && qnetPlayer->m_smallId == disconnectedSmallId)
|
||||||
{
|
{
|
||||||
@@ -248,6 +250,16 @@ void CPlatformNetworkManagerStub::DoWork()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BYTE joinedSmallId;
|
||||||
|
while (NetworkSocketLayer::PopPendingJoinSmallId(&joinedSmallId))
|
||||||
|
{
|
||||||
|
IQNetPlayer *qnetPlayer = m_pIQNet->GetPlayerBySmallId(joinedSmallId);
|
||||||
|
if (qnetPlayer != NULL && qnetPlayer->m_smallId == joinedSmallId)
|
||||||
|
{
|
||||||
|
NotifyPlayerJoined(qnetPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 1; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
for (int i = 1; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
IQNetPlayer *qp = &IQNet::m_player[i];
|
IQNetPlayer *qp = &IQNet::m_player[i];
|
||||||
@@ -294,12 +306,27 @@ int CPlatformNetworkManagerStub::GetLocalPlayerMask(int playerIndex)
|
|||||||
|
|
||||||
bool CPlatformNetworkManagerStub::AddLocalPlayerByUserIndex( int userIndex )
|
bool CPlatformNetworkManagerStub::AddLocalPlayerByUserIndex( int userIndex )
|
||||||
{
|
{
|
||||||
|
if (m_pIQNet->AddLocalPlayerByUserIndex(userIndex) != S_OK) return false;
|
||||||
NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(userIndex));
|
NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(userIndex));
|
||||||
return ( m_pIQNet->AddLocalPlayerByUserIndex(userIndex) == S_OK );
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPlatformNetworkManagerStub::RemoveLocalPlayerByUserIndex( int userIndex )
|
bool CPlatformNetworkManagerStub::RemoveLocalPlayerByUserIndex( int userIndex )
|
||||||
{
|
{
|
||||||
|
if (userIndex > 0 && userIndex < XUSER_MAX_COUNT)
|
||||||
|
{
|
||||||
|
IQNetPlayer *qnetPlayer = m_pIQNet->GetLocalPlayerByUserIndex(userIndex);
|
||||||
|
if (qnetPlayer != NULL)
|
||||||
|
{
|
||||||
|
NotifyPlayerLeaving(qnetPlayer);
|
||||||
|
qnetPlayer->m_isRemote = true;
|
||||||
|
qnetPlayer->m_isHostPlayer = false;
|
||||||
|
qnetPlayer->m_gamertag[0] = 0;
|
||||||
|
qnetPlayer->SetCustomDataValue(0);
|
||||||
|
if (IQNet::s_playerCount > 1)
|
||||||
|
IQNet::s_playerCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +403,11 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame,
|
|||||||
IQNet::m_player[0].m_smallId = 0;
|
IQNet::m_player[0].m_smallId = 0;
|
||||||
IQNet::m_player[0].m_isRemote = false;
|
IQNet::m_player[0].m_isRemote = false;
|
||||||
IQNet::m_player[0].m_isHostPlayer = true;
|
IQNet::m_player[0].m_isHostPlayer = true;
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
extern wchar_t g_Win64UsernameW[17];
|
||||||
|
wcscpy_s(IQNet::m_player[0].m_gamertag, 32, g_Win64UsernameW);
|
||||||
IQNet::s_playerCount = 1;
|
IQNet::s_playerCount = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (getNetworkPlayer(&IQNet::m_player[0]) == NULL)
|
if (getNetworkPlayer(&IQNet::m_player[0]) == NULL)
|
||||||
NotifyPlayerJoined(&IQNet::m_player[0]);
|
NotifyPlayerJoined(&IQNet::m_player[0]);
|
||||||
@@ -854,6 +885,7 @@ bool CPlatformNetworkManagerStub::GetGameSessionInfo(int iPad, SessionID session
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlatformNetworkManagerStub::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam )
|
void CPlatformNetworkManagerStub::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam )
|
||||||
|
|||||||
@@ -959,11 +959,19 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//ProfileManager.RequestSignInUI(false, false, false, true, false,&CScene_MultiGameCreate::StartGame_SignInReturned, this,ProfileManager.GetPrimaryPad());
|
//ProfileManager.RequestSignInUI(false, false, false, true, false,&CScene_MultiGameCreate::StartGame_SignInReturned, this,ProfileManager.GetPrimaryPad());
|
||||||
|
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||||
|
SignInInfo info;
|
||||||
|
info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned;
|
||||||
|
info.lpParam = this;
|
||||||
|
info.requireOnline = m_MoreOptionsParams.bOnlineGame;
|
||||||
|
UIScene_CreateWorldMenu::StartGame_SignInReturned(this, true, ProfileManager.GetPrimaryPad());
|
||||||
|
#else
|
||||||
SignInInfo info;
|
SignInInfo info;
|
||||||
info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned;
|
info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned;
|
||||||
info.lpParam = this;
|
info.lpParam = this;
|
||||||
info.requireOnline = m_MoreOptionsParams.bOnlineGame;
|
info.requireOnline = m_MoreOptionsParams.bOnlineGame;
|
||||||
ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info);
|
ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1342,12 +1350,16 @@ int UIScene_CreateWorldMenu::ConfirmCreateReturned(void *pParam,int iPad,C4JStor
|
|||||||
|
|
||||||
if(isClientSide && app.IsLocalMultiplayerAvailable())
|
if(isClientSide && app.IsLocalMultiplayerAvailable())
|
||||||
{
|
{
|
||||||
|
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||||
|
UIScene_CreateWorldMenu::StartGame_SignInReturned(pClass, true, ProfileManager.GetPrimaryPad());
|
||||||
|
#else
|
||||||
//ProfileManager.RequestSignInUI(false, false, false, true, false,&UIScene_CreateWorldMenu::StartGame_SignInReturned, pClass,ProfileManager.GetPrimaryPad());
|
//ProfileManager.RequestSignInUI(false, false, false, true, false,&UIScene_CreateWorldMenu::StartGame_SignInReturned, pClass,ProfileManager.GetPrimaryPad());
|
||||||
SignInInfo info;
|
SignInInfo info;
|
||||||
info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned;
|
info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned;
|
||||||
info.lpParam = pClass;
|
info.lpParam = pClass;
|
||||||
info.requireOnline = pClass->m_MoreOptionsParams.bOnlineGame;
|
info.requireOnline = pClass->m_MoreOptionsParams.bOnlineGame;
|
||||||
ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info);
|
ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "..\..\MinecraftServer.h"
|
#include "..\..\MinecraftServer.h"
|
||||||
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
|
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
|
||||||
#include "..\..\..\Minecraft.World\net.minecraft.world.h"
|
#include "..\..\..\Minecraft.World\net.minecraft.world.h"
|
||||||
#include "..\..\Common\Network\NetworkSocketLayer.h"
|
#include "..\..\Common\Network\NetworkSocketLayer.h"
|
||||||
|
|
||||||
#define UPDATE_PLAYERS_TIMER_ID 0
|
#define UPDATE_PLAYERS_TIMER_ID 0
|
||||||
#define UPDATE_PLAYERS_TIMER_TIME 30000
|
#define UPDATE_PLAYERS_TIMER_TIME 30000
|
||||||
@@ -368,7 +368,7 @@ void UIScene_JoinMenu::checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege,
|
|||||||
|
|
||||||
void UIScene_JoinMenu::StartSharedLaunchFlow()
|
void UIScene_JoinMenu::StartSharedLaunchFlow()
|
||||||
{
|
{
|
||||||
const bool bManualJoin = (g_MultiplayerJoin == true);
|
const bool bManualJoin = (g_MultiplayerJoin == true);
|
||||||
if (bManualJoin)
|
if (bManualJoin)
|
||||||
{
|
{
|
||||||
JoinGame(this);
|
JoinGame(this);
|
||||||
@@ -431,7 +431,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const bool bManualJoin = (g_MultiplayerJoin == true);
|
const bool bManualJoin = (g_MultiplayerJoin == true);
|
||||||
|
|
||||||
DWORD dwSignedInUsers = 0;
|
DWORD dwSignedInUsers = 0;
|
||||||
bool noPrivileges = false;
|
bool noPrivileges = false;
|
||||||
|
|||||||
@@ -1446,7 +1446,12 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam)
|
|||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||||
|
DWORD dwLocalUsersMask = CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
|
||||||
|
StartGameFromSave(pClass, dwLocalUsersMask);
|
||||||
|
#else
|
||||||
pClass->m_bRequestQuadrantSignin = true;
|
pClass->m_bRequestQuadrantSignin = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "UIScene_MainMenu.h"
|
#include "UIScene_MainMenu.h"
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
#include <error_dialog.h>
|
#include <error_dialog.h>
|
||||||
#include "..\..\Common\Network\NetworkSocketLayer.h"
|
#include "..\..\Common\Network\NetworkSocketLayer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Random *UIScene_MainMenu::random = new Random();
|
Random *UIScene_MainMenu::random = new Random();
|
||||||
@@ -319,7 +319,7 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId)
|
|||||||
//CD - Added for audio
|
//CD - Added for audio
|
||||||
ui.PlayUISFX(eSFX_Press);
|
ui.PlayUISFX(eSFX_Press);
|
||||||
|
|
||||||
if(g_MultiplayerJoin)
|
if(g_MultiplayerJoin)
|
||||||
{
|
{
|
||||||
// request only completes after the platform network timeout.
|
// request only completes after the platform network timeout.
|
||||||
// this needs to be done before hand or else the PS4 crashes ill need to look more into this
|
// this needs to be done before hand or else the PS4 crashes ill need to look more into this
|
||||||
@@ -386,6 +386,10 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId)
|
|||||||
ui.NavigateToScene(primaryPad,eUIScene_TrialExitUpsell);
|
ui.NavigateToScene(primaryPad,eUIScene_TrialExitUpsell);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#elif defined _WINDOWS64
|
||||||
|
case eControl_Exit:
|
||||||
|
app.ExitGame();
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _DURANGO
|
#ifdef _DURANGO
|
||||||
@@ -1108,7 +1112,7 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_PlayGame(void *
|
|||||||
int primaryPad = ProfileManager.GetPrimaryPad();
|
int primaryPad = ProfileManager.GetPrimaryPad();
|
||||||
|
|
||||||
UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam;
|
UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam;
|
||||||
const bool bManualJoin = (g_MultiplayerJoin == true);
|
const bool bManualJoin = (g_MultiplayerJoin == true);
|
||||||
if (bManualJoin)
|
if (bManualJoin)
|
||||||
{
|
{
|
||||||
CreateLoad_SignInReturned(pClass, true, primaryPad);
|
CreateLoad_SignInReturned(pClass, true, primaryPad);
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ DWORD XEnableGuestSignin(BOOL fEnable) { return 0; }
|
|||||||
/////////////////////////////////////////////// Profile library
|
/////////////////////////////////////////////// Profile library
|
||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
static void *profileData[4];
|
static void *profileData[4];
|
||||||
static bool s_bProfileIsFullVersion;
|
static bool s_bProfileIsFullVersion = true;
|
||||||
void C_4JProfile::Initialise( DWORD dwTitleID,
|
void C_4JProfile::Initialise( DWORD dwTitleID,
|
||||||
DWORD dwOfferID,
|
DWORD dwOfferID,
|
||||||
unsigned short usProfileVersion,
|
unsigned short usProfileVersion,
|
||||||
@@ -374,6 +374,7 @@ void C_4JProfile::Initialise( DWORD dwTitleID,
|
|||||||
GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)profileData[i];
|
GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)profileData[i];
|
||||||
pGameSettings->ucMenuSensitivity=100; //eGameSetting_Sensitivity_InMenu
|
pGameSettings->ucMenuSensitivity=100; //eGameSetting_Sensitivity_InMenu
|
||||||
pGameSettings->ucInterfaceOpacity=80; //eGameSetting_Sensitivity_InMenu
|
pGameSettings->ucInterfaceOpacity=80; //eGameSetting_Sensitivity_InMenu
|
||||||
|
pGameSettings->ucGamma=100; //eGameSetting_Gamma
|
||||||
pGameSettings->usBitmaskValues|=0x0200; //eGameSetting_DisplaySplitscreenGamertags - on
|
pGameSettings->usBitmaskValues|=0x0200; //eGameSetting_DisplaySplitscreenGamertags - on
|
||||||
pGameSettings->usBitmaskValues|=0x0400; //eGameSetting_Hints - on
|
pGameSettings->usBitmaskValues|=0x0400; //eGameSetting_Hints - on
|
||||||
pGameSettings->usBitmaskValues|=0x1000; //eGameSetting_Autosave - 2
|
pGameSettings->usBitmaskValues|=0x1000; //eGameSetting_Autosave - 2
|
||||||
@@ -437,7 +438,95 @@ DWORD IQNetPlayer::GetCurrentRtt() { return 0; }
|
|||||||
bool IQNetPlayer::IsHost() { return m_isHostPlayer; }
|
bool IQNetPlayer::IsHost() { return m_isHostPlayer; }
|
||||||
bool IQNetPlayer::IsGuest() { return false; }
|
bool IQNetPlayer::IsGuest() { return false; }
|
||||||
bool IQNetPlayer::IsLocal() { return !m_isRemote; }
|
bool IQNetPlayer::IsLocal() { return !m_isRemote; }
|
||||||
PlayerUID IQNetPlayer::GetXuid() { return (PlayerUID)(0xe000d45248242f2e + m_smallId); }
|
static void Win64_BuildSplitName(int iPad, char *outName, int outSize);
|
||||||
|
|
||||||
|
PlayerUID IQNetPlayer::GetXuid()
|
||||||
|
{
|
||||||
|
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||||
|
if (!m_isRemote)
|
||||||
|
{
|
||||||
|
int idx = (int)(this - &IQNet::m_player[0]);
|
||||||
|
if (idx == 0)
|
||||||
|
{
|
||||||
|
extern char g_Win64Username[17];
|
||||||
|
return Win64_UsernameToXuid(g_Win64Username);
|
||||||
|
}
|
||||||
|
if (idx > 0 && idx < XUSER_MAX_COUNT)
|
||||||
|
{
|
||||||
|
char splitName[32];
|
||||||
|
Win64_BuildSplitName(idx, splitName, sizeof(splitName));
|
||||||
|
return Win64_UsernameToXuid(splitName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return (PlayerUID)(0xe000d45248242f2e + m_smallId);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerUID Win64_UsernameToXuid(const char* username)
|
||||||
|
{
|
||||||
|
uint64_t hash = 14695981039346656037ULL;
|
||||||
|
for (const char* p = username; *p; ++p)
|
||||||
|
{
|
||||||
|
hash ^= (uint64_t)(unsigned char)(*p);
|
||||||
|
hash *= 1099511628211ULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint64_t WIN64_XUID_BASE = 0xe000d45248242f2e;
|
||||||
|
if (hash >= WIN64_XUID_BASE && hash <= WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS)
|
||||||
|
hash = WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS + 1;
|
||||||
|
if (hash == 0)
|
||||||
|
hash = 1;
|
||||||
|
return (PlayerUID)hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerUID Win64_UsernameToXuid(const wchar_t* username)
|
||||||
|
{
|
||||||
|
char narrow[64];
|
||||||
|
int i = 0;
|
||||||
|
for (; username[i] && i < 63; ++i)
|
||||||
|
narrow[i] = (char)(unsigned char)(username[i] & 0xFF);
|
||||||
|
narrow[i] = 0;
|
||||||
|
return Win64_UsernameToXuid(narrow);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Win64_BuildSplitName(int iPad, char *outName, int outSize)
|
||||||
|
{
|
||||||
|
extern char g_Win64Username[17];
|
||||||
|
char candidate[32];
|
||||||
|
sprintf(candidate, "%s_%d", g_Win64Username, iPad);
|
||||||
|
for (DWORD i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||||
|
{
|
||||||
|
if (!IQNet::m_player[i].m_isRemote) continue;
|
||||||
|
if (IQNet::m_player[i].m_gamertag[0] == 0) continue;
|
||||||
|
char remoteName[64];
|
||||||
|
int j = 0;
|
||||||
|
for (; IQNet::m_player[i].m_gamertag[j] && j < 63; ++j)
|
||||||
|
remoteName[j] = (char)(unsigned char)(IQNet::m_player[i].m_gamertag[j] & 0xFF);
|
||||||
|
remoteName[j] = 0;
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
if (_stricmp(candidate, remoteName) == 0)
|
||||||
|
#else
|
||||||
|
if (strcasecmp(candidate, remoteName) == 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
sprintf(candidate, "%s_%d_L", g_Win64Username, iPad);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strncpy(outName, candidate, outSize - 1);
|
||||||
|
outName[outSize - 1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Win64_BuildSplitNameW(int iPad, wchar_t *outName, int outSize)
|
||||||
|
{
|
||||||
|
char narrow[32];
|
||||||
|
Win64_BuildSplitName(iPad, narrow, sizeof(narrow));
|
||||||
|
for (int i = 0; i < outSize - 1 && narrow[i]; ++i)
|
||||||
|
{
|
||||||
|
outName[i] = (wchar_t)(unsigned char)narrow[i];
|
||||||
|
outName[i + 1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
LPCWSTR IQNetPlayer::GetGamertag() { return m_gamertag; }
|
LPCWSTR IQNetPlayer::GetGamertag() { return m_gamertag; }
|
||||||
int IQNetPlayer::GetSessionIndex() { return m_smallId; }
|
int IQNetPlayer::GetSessionIndex() { return m_smallId; }
|
||||||
bool IQNetPlayer::IsTalking() { return false; }
|
bool IQNetPlayer::IsTalking() { return false; }
|
||||||
@@ -470,15 +559,30 @@ void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost,
|
|||||||
|
|
||||||
static bool Win64_IsActivePlayer(IQNetPlayer *p, DWORD index);
|
static bool Win64_IsActivePlayer(IQNetPlayer *p, DWORD index);
|
||||||
|
|
||||||
HRESULT IQNet::AddLocalPlayerByUserIndex(DWORD dwUserIndex){ return S_OK; }
|
HRESULT IQNet::AddLocalPlayerByUserIndex(DWORD dwUserIndex)
|
||||||
|
{
|
||||||
|
// no E_FAIL on PS3.
|
||||||
|
if (dwUserIndex >= MINECRAFT_NET_MAX_PLAYERS) return (HRESULT)0x80004005L;
|
||||||
|
m_player[dwUserIndex].m_isRemote = false;
|
||||||
|
m_player[dwUserIndex].m_smallId = (BYTE)dwUserIndex;
|
||||||
|
if (dwUserIndex > 0)
|
||||||
|
{
|
||||||
|
wchar_t splitNameW[32];
|
||||||
|
Win64_BuildSplitNameW((int)dwUserIndex, splitNameW, 32);
|
||||||
|
wcsncpy(m_player[dwUserIndex].m_gamertag, splitNameW, 32 - 1);
|
||||||
|
m_player[dwUserIndex].m_gamertag[32 - 1] = 0;
|
||||||
|
}
|
||||||
|
if (dwUserIndex >= (DWORD)s_playerCount)
|
||||||
|
s_playerCount = dwUserIndex + 1;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
IQNetPlayer *IQNet::GetHostPlayer() { return &m_player[0]; }
|
IQNetPlayer *IQNet::GetHostPlayer() { return &m_player[0]; }
|
||||||
IQNetPlayer *IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex)
|
IQNetPlayer *IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex)
|
||||||
{
|
{
|
||||||
if (s_isHosting)
|
if (s_isHosting)
|
||||||
{
|
{
|
||||||
if (dwUserIndex < MINECRAFT_NET_MAX_PLAYERS &&
|
if (dwUserIndex < MINECRAFT_NET_MAX_PLAYERS &&
|
||||||
!m_player[dwUserIndex].m_isRemote &&
|
!m_player[dwUserIndex].m_isRemote)
|
||||||
Win64_IsActivePlayer(&m_player[dwUserIndex], dwUserIndex))
|
|
||||||
return &m_player[dwUserIndex];
|
return &m_player[dwUserIndex];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -575,7 +679,7 @@ void C_4JProfile::SetTrialTextStringTable(CXuiStringTable *pStringTable,int i
|
|||||||
void C_4JProfile::SetTrialAwardText(eAwardType AwardType,int iTitle,int iText) {}
|
void C_4JProfile::SetTrialAwardText(eAwardType AwardType,int iTitle,int iText) {}
|
||||||
int C_4JProfile::GetLockedProfile() { return 0; }
|
int C_4JProfile::GetLockedProfile() { return 0; }
|
||||||
void C_4JProfile::SetLockedProfile(int iProf) {}
|
void C_4JProfile::SetLockedProfile(int iProf) {}
|
||||||
bool C_4JProfile::IsSignedIn(int iQuadrant) { return ( iQuadrant == 0); }
|
bool C_4JProfile::IsSignedIn(int iQuadrant) { return (iQuadrant >= 0 && iQuadrant < XUSER_MAX_COUNT); }
|
||||||
bool C_4JProfile::IsSignedInLive(int iProf) { return true; }
|
bool C_4JProfile::IsSignedInLive(int iProf) { return true; }
|
||||||
bool C_4JProfile::IsGuest(int iQuadrant) { return false; }
|
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::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; }
|
||||||
@@ -585,16 +689,21 @@ void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {}
|
|||||||
bool C_4JProfile::QuerySigninStatus(void) { return true; }
|
bool C_4JProfile::QuerySigninStatus(void) { return true; }
|
||||||
void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid)
|
void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid)
|
||||||
{
|
{
|
||||||
if (iPad != 0)
|
if (iPad == 0)
|
||||||
{
|
{
|
||||||
// previously INVALID_XUID
|
extern char g_Win64Username[17];
|
||||||
*pXuid = 0;
|
*pXuid = Win64_UsernameToXuid(g_Win64Username);
|
||||||
return;
|
}
|
||||||
|
else if (iPad > 0 && iPad < XUSER_MAX_COUNT)
|
||||||
|
{
|
||||||
|
char splitName[32];
|
||||||
|
Win64_BuildSplitName(iPad, splitName, sizeof(splitName));
|
||||||
|
*pXuid = Win64_UsernameToXuid(splitName);
|
||||||
}
|
}
|
||||||
if (IQNet::s_isHosting)
|
|
||||||
*pXuid = 0xe000d45248242f2e;
|
|
||||||
else
|
else
|
||||||
*pXuid = 0xe000d45248242f2e + NetworkSocketLayer::GetLocalSmallId();
|
{
|
||||||
|
*pXuid = INVALID_XUID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BOOL C_4JProfile::AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2) { return xuid1 == xuid2; }
|
BOOL C_4JProfile::AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2) { return xuid1 == xuid2; }
|
||||||
BOOL C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; }
|
BOOL C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; }
|
||||||
@@ -623,8 +732,30 @@ char fakeGamerTag[32] = "PlayerName";
|
|||||||
void SetFakeGamertag(char *name){ strcpy_s(fakeGamerTag, name); }
|
void SetFakeGamertag(char *name){ strcpy_s(fakeGamerTag, name); }
|
||||||
char* C_4JProfile::GetGamertag(int iPad){ return fakeGamerTag; }
|
char* C_4JProfile::GetGamertag(int iPad){ return fakeGamerTag; }
|
||||||
#else
|
#else
|
||||||
char* C_4JProfile::GetGamertag(int iPad){ extern char g_Win64Username[17]; return g_Win64Username; }
|
static char s_win64SplitNames[4][32];
|
||||||
wstring C_4JProfile::GetDisplayName(int iPad){ extern wchar_t g_Win64UsernameW[17]; return g_Win64UsernameW; }
|
char* C_4JProfile::GetGamertag(int iPad)
|
||||||
|
{
|
||||||
|
extern char g_Win64Username[17];
|
||||||
|
if (iPad == 0) return g_Win64Username;
|
||||||
|
if (iPad > 0 && iPad < XUSER_MAX_COUNT)
|
||||||
|
{
|
||||||
|
Win64_BuildSplitName(iPad, s_win64SplitNames[iPad], sizeof(s_win64SplitNames[iPad]));
|
||||||
|
return s_win64SplitNames[iPad];
|
||||||
|
}
|
||||||
|
return g_Win64Username;
|
||||||
|
}
|
||||||
|
wstring C_4JProfile::GetDisplayName(int iPad)
|
||||||
|
{
|
||||||
|
extern wchar_t g_Win64UsernameW[17];
|
||||||
|
if (iPad == 0) return g_Win64UsernameW;
|
||||||
|
if (iPad > 0 && iPad < XUSER_MAX_COUNT)
|
||||||
|
{
|
||||||
|
wchar_t buf[32];
|
||||||
|
Win64_BuildSplitNameW(iPad, buf, 32);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
return g_Win64UsernameW;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
|
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
|
||||||
void C_4JProfile::SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam) {}
|
void C_4JProfile::SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam) {}
|
||||||
|
|||||||
@@ -1964,7 +1964,11 @@ bool LevelRenderer::updateDirtyChunks()
|
|||||||
{
|
{
|
||||||
if( (!onlyRebuild) ||
|
if( (!onlyRebuild) ||
|
||||||
globalChunkFlags[ pClipChunk->globalIdx ] & CHUNK_FLAG_COMPILED ||
|
globalChunkFlags[ pClipChunk->globalIdx ] & CHUNK_FLAG_COMPILED ||
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
( distSq < 96 * 96 ) ) // Always rebuild really near things or else building (say) at tower up into empty blocks when we are low on memory will not create render data
|
||||||
|
#else
|
||||||
( distSq < 20 * 20 ) ) // Always rebuild really near things or else building (say) at tower up into empty blocks when we are low on memory will not create render data
|
( distSq < 20 * 20 ) ) // Always rebuild really near things or else building (say) at tower up into empty blocks when we are low on memory will not create render data
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
considered++;
|
considered++;
|
||||||
// Is this chunk nearer than our nearest?
|
// Is this chunk nearer than our nearest?
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ public:
|
|||||||
static const int CHUNK_SIZE = 16;
|
static const int CHUNK_SIZE = 16;
|
||||||
#endif
|
#endif
|
||||||
static const int CHUNK_Y_COUNT = Level::maxBuildHeight / CHUNK_SIZE;
|
static const int CHUNK_Y_COUNT = Level::maxBuildHeight / CHUNK_SIZE;
|
||||||
#if ( defined _XBOX_ONE || defined _WINDOWS64 )
|
#if defined _WINDOWS64
|
||||||
|
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 2047 * 1024 * 1024; // whisper - added (wow)
|
||||||
|
#elif ( defined _XBOX_ONE )
|
||||||
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 512 * 1024 * 1024; // 4J - added
|
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 512 * 1024 * 1024; // 4J - added
|
||||||
#elif defined __ORBIS__
|
#elif defined __ORBIS__
|
||||||
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 448 * 1024 * 1024; // 4J - added - hard limit is 512 so giving a lot of headroom here for fragmentation (have seen 16MB lost to fragmentation in multiplayer crash dump before)
|
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 448 * 1024 * 1024; // 4J - added - hard limit is 512 so giving a lot of headroom here for fragmentation (have seen 16MB lost to fragmentation in multiplayer crash dump before)
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public:
|
|||||||
static void SetTime(__int64 time) { setTimeAtEndOfTick = true; setTime = time; }
|
static void SetTime(__int64 time) { setTimeAtEndOfTick = true; setTime = time; }
|
||||||
|
|
||||||
C4JThread::Event* m_serverPausedEvent;
|
C4JThread::Event* m_serverPausedEvent;
|
||||||
private:
|
public:
|
||||||
// 4J Added
|
// 4J Added
|
||||||
bool m_isServerPaused;
|
bool m_isServerPaused;
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,20 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face)
|
|||||||
|
|
||||||
if (oldTile == NULL) return false;
|
if (oldTile == NULL) return false;
|
||||||
|
|
||||||
|
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||||
|
if (g_NetworkManager.IsHost())
|
||||||
|
{
|
||||||
|
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||||
|
int data = level->getData(x, y, z);
|
||||||
|
bool changed = level->removeTile(x, y, z);
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
oldTile->destroy(level, x, y, z, data);
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||||
|
|
||||||
int data = level->getData(x, y, z);
|
int data = level->getData(x, y, z);
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
|||||||
uint8_t * AddRichPresenceString(int iID);
|
uint8_t * AddRichPresenceString(int iID);
|
||||||
void FreeRichPresenceStrings();
|
void FreeRichPresenceStrings();
|
||||||
|
|
||||||
|
char g_Win64Username[17] = {0};
|
||||||
|
|
||||||
BOOL g_bWidescreen = TRUE;
|
BOOL g_bWidescreen = TRUE;
|
||||||
|
|
||||||
|
|
||||||
@@ -984,6 +986,9 @@ int main(int argc, const char *argv[] )
|
|||||||
app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
|
app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
|
||||||
&app.uiGameDefinedDataChangedBitmask);
|
&app.uiGameDefinedDataChangedBitmask);
|
||||||
|
|
||||||
|
strncpy(g_Win64Username, ProfileManager.GetGamertag(0), 17);
|
||||||
|
g_Win64Username[16] = 0;
|
||||||
|
|
||||||
// register the awards
|
// register the awards
|
||||||
RegisterAwardsWithProfileManager();
|
RegisterAwardsWithProfileManager();
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,8 @@ extern "C" void* __wrap__malloc_init(size_t a_Boundary, size_t a_Size)
|
|||||||
// for a long time.
|
// for a long time.
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
char g_Win64Username[17] = {0};
|
||||||
|
|
||||||
BOOL g_bWidescreen = TRUE;
|
BOOL g_bWidescreen = TRUE;
|
||||||
//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware
|
//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware
|
||||||
|
|
||||||
@@ -910,6 +912,9 @@ int main()
|
|||||||
app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
|
app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
|
||||||
&app.uiGameDefinedDataChangedBitmask);
|
&app.uiGameDefinedDataChangedBitmask);
|
||||||
|
|
||||||
|
strncpy(g_Win64Username, ProfileManager.GetGamertag(0), 17);
|
||||||
|
g_Win64Username[16] = 0;
|
||||||
|
|
||||||
app.DebugPrintf("+++Main - after ProfileManager.Initialise\n");
|
app.DebugPrintf("+++Main - after ProfileManager.Initialise\n");
|
||||||
|
|
||||||
// register the awards
|
// register the awards
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ extern "C" void* __wrap__malloc_init(size_t a_Boundary, size_t a_Size)
|
|||||||
// for a long time.
|
// for a long time.
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
char g_Win64Username[17] = {0};
|
||||||
|
|
||||||
BOOL g_bWidescreen = TRUE;
|
BOOL g_bWidescreen = TRUE;
|
||||||
//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware
|
//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware
|
||||||
|
|
||||||
@@ -601,6 +603,8 @@ int main()
|
|||||||
app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
|
app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
|
||||||
&app.uiGameDefinedDataChangedBitmask);
|
&app.uiGameDefinedDataChangedBitmask);
|
||||||
|
|
||||||
|
strncpy(g_Win64Username, ProfileManager.GetGamertag(0), 17);
|
||||||
|
g_Win64Username[16] = 0;
|
||||||
|
|
||||||
// register the awards
|
// register the awards
|
||||||
RegisterAwardsWithProfileManager();
|
RegisterAwardsWithProfileManager();
|
||||||
|
|||||||
@@ -539,7 +539,12 @@ void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, shared_ptr<ServerPlay
|
|||||||
// 4J - added - actually create & add player to a playerchunk, if there is one queued for this player.
|
// 4J - added - actually create & add player to a playerchunk, if there is one queued for this player.
|
||||||
void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
if( addRequests.size() )
|
#ifdef _WINDOWS64
|
||||||
|
const int maxPerTick = 10;
|
||||||
|
#else
|
||||||
|
const int maxPerTick = 1;
|
||||||
|
#endif
|
||||||
|
for (int _processed = 0; _processed < maxPerTick && addRequests.size(); _processed++)
|
||||||
{
|
{
|
||||||
// Find the nearest chunk request to the player
|
// Find the nearest chunk request to the player
|
||||||
int px = (int)player->x;
|
int px = (int)player->x;
|
||||||
@@ -569,6 +574,10 @@ void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
|
|||||||
getChunk(itNearest->x, itNearest->z, true)->add(itNearest->player);
|
getChunk(itNearest->x, itNearest->z, true)->add(itNearest->player);
|
||||||
addRequests.erase(itNearest);
|
addRequests.erase(itNearest);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1577,7 +1577,10 @@ bool PlayerConnection::isDisconnected()
|
|||||||
void PlayerConnection::handleDebugOptions(shared_ptr<DebugOptionsPacket> packet)
|
void PlayerConnection::handleDebugOptions(shared_ptr<DebugOptionsPacket> packet)
|
||||||
{
|
{
|
||||||
//Player player = dynamic_pointer_cast<Player>( player->shared_from_this() );
|
//Player player = dynamic_pointer_cast<Player>( player->shared_from_this() );
|
||||||
player->SetDebugOptions(packet->m_uiVal);
|
if(app.DebugSettingsOn())
|
||||||
|
{
|
||||||
|
player->SetDebugOptions(packet->m_uiVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
||||||
@@ -1587,6 +1590,10 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
|||||||
if(iRecipe == -1)
|
if(iRecipe == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int recipeCount = (int)Recipes::getInstance()->getRecipies()->size();
|
||||||
|
if(iRecipe < 0 || iRecipe >= recipeCount)
|
||||||
|
return;
|
||||||
|
|
||||||
Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
|
Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
|
||||||
shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
|
shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -1086,7 +1086,9 @@ void ServerLevel::entityRemoved(shared_ptr<Entity> e)
|
|||||||
|
|
||||||
shared_ptr<Entity> ServerLevel::getEntity(int id)
|
shared_ptr<Entity> ServerLevel::getEntity(int id)
|
||||||
{
|
{
|
||||||
return entitiesById[id];
|
AUTO_VAR(it, entitiesById.find(id));
|
||||||
|
if(it != entitiesById.end()) return it->second;
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerLevel::addGlobalEntity(shared_ptr<Entity> e)
|
bool ServerLevel::addGlobalEntity(shared_ptr<Entity> e)
|
||||||
|
|||||||
@@ -329,6 +329,10 @@ void ServerPlayer::doTickA()
|
|||||||
// 4J - split off the chunk sending bit of the tick here from ::doTick so we can do this exactly once per player per server tick
|
// 4J - split off the chunk sending bit of the tick here from ::doTick so we can do this exactly once per player per server tick
|
||||||
void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
|
void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
|
||||||
{
|
{
|
||||||
|
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||||
|
for (int _w64cs = 0; _w64cs < 4; _w64cs++)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
// printf("[%d] %s: sendChunks: %d, empty: %d\n",tickCount, connection->getNetworkPlayer()->GetUID().getOnlineID(),sendChunks,chunksToSend.empty());
|
// printf("[%d] %s: sendChunks: %d, empty: %d\n",tickCount, connection->getNetworkPlayer()->GetUID().getOnlineID(),sendChunks,chunksToSend.empty());
|
||||||
if (!chunksToSend.empty())
|
if (!chunksToSend.empty())
|
||||||
{
|
{
|
||||||
@@ -367,6 +371,17 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if defined(_WINDOWS64)
|
||||||
|
if( dontDelayChunks ||
|
||||||
|
((connection->countDelayedPackets() < 16 )&&
|
||||||
|
(g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages( NULL, true ) < 16 )&&
|
||||||
|
!connection->done) )
|
||||||
|
{
|
||||||
|
lastBrupSendTickCount = tickCount;
|
||||||
|
okToSend = true;
|
||||||
|
MinecraftServer::s_slowQueuePacketSent = true;
|
||||||
|
}
|
||||||
|
#else
|
||||||
bool canSendToPlayer = MinecraftServer::chunkPacketManagement_CanSendTo(connection->getNetworkPlayer());
|
bool canSendToPlayer = MinecraftServer::chunkPacketManagement_CanSendTo(connection->getNetworkPlayer());
|
||||||
|
|
||||||
// app.DebugPrintf(">>> %d\n", canSendToPlayer);
|
// app.DebugPrintf(">>> %d\n", canSendToPlayer);
|
||||||
@@ -408,6 +423,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
|
|||||||
{
|
{
|
||||||
// app.DebugPrintf(" - <NOT OK>\n");
|
// app.DebugPrintf(" - <NOT OK>\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (okToSend)
|
if (okToSend)
|
||||||
@@ -485,6 +501,9 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerPlayer::doTickB()
|
void ServerPlayer::doTickB()
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ D3DSAMPLERSTATETYPE SamplerStateModes[]=
|
|||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
char g_Win64Username[17] = {0};
|
||||||
|
|
||||||
BOOL g_bWidescreen = TRUE;
|
BOOL g_bWidescreen = TRUE;
|
||||||
|
|
||||||
|
|
||||||
@@ -433,6 +435,9 @@ int __cdecl main()
|
|||||||
&app.uiGameDefinedDataChangedBitmask
|
&app.uiGameDefinedDataChangedBitmask
|
||||||
);
|
);
|
||||||
|
|
||||||
|
strncpy(g_Win64Username, ProfileManager.GetGamertag(0), 17);
|
||||||
|
g_Win64Username[16] = 0;
|
||||||
|
|
||||||
// register the awards
|
// register the awards
|
||||||
ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement);
|
ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement);
|
||||||
ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, eAwardType_Achievement);
|
ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, eAwardType_Achievement);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void AwardStatPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
|
|
||||||
// Read parameter blob.
|
// Read parameter blob.
|
||||||
int length = dis->readInt();
|
int length = dis->readInt();
|
||||||
if(length > 0)
|
if(length > 0 && length <= 65536)
|
||||||
{
|
{
|
||||||
m_paramData = byteArray(length);
|
m_paramData = byteArray(length);
|
||||||
dis->readFully(m_paramData);
|
dis->readFully(m_paramData);
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ void BlockRegionUpdatePacket::read(DataInputStream *dis) //throws IOException
|
|||||||
levelIdx = ( size >> 30 ) & 3;
|
levelIdx = ( size >> 30 ) & 3;
|
||||||
size &= 0x3fffffff;
|
size &= 0x3fffffff;
|
||||||
|
|
||||||
|
const int MAX_COMPRESSED_CHUNK_SIZE = 5 * 1024 * 1024;
|
||||||
|
if(size < 0 || size > MAX_COMPRESSED_CHUNK_SIZE)
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(size == 0)
|
if(size == 0)
|
||||||
{
|
{
|
||||||
buffer = byteArray();
|
buffer = byteArray();
|
||||||
@@ -131,7 +137,10 @@ void BlockRegionUpdatePacket::read(DataInputStream *dis) //throws IOException
|
|||||||
|
|
||||||
|
|
||||||
delete [] compressedBuffer.data;
|
delete [] compressedBuffer.data;
|
||||||
assert(buffer.length == outputSize);
|
if(buffer.length != outputSize)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("BlockRegionUpdatePacket: decompressed size mismatch (expected %d, got %d)\n", buffer.length, outputSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,14 @@
|
|||||||
//offset - the offset in the buffer of the first byte to read.
|
//offset - the offset in the buffer of the first byte to read.
|
||||||
//length - the maximum number of bytes to read from the buffer.
|
//length - the maximum number of bytes to read from the buffer.
|
||||||
ByteArrayInputStream::ByteArrayInputStream(byteArray buf, unsigned int offset, unsigned int length)
|
ByteArrayInputStream::ByteArrayInputStream(byteArray buf, unsigned int offset, unsigned int length)
|
||||||
: pos( offset ), count( min( offset+length, buf.length ) ), mark( offset )
|
: pos( offset ), mark( offset )
|
||||||
{
|
{
|
||||||
|
if( offset > buf.length )
|
||||||
|
count = buf.length;
|
||||||
|
else if( length > buf.length - offset )
|
||||||
|
count = buf.length;
|
||||||
|
else
|
||||||
|
count = offset + length;
|
||||||
this->buf = buf;
|
this->buf = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,12 @@ void ByteArrayOutputStream::write(unsigned int b)
|
|||||||
{
|
{
|
||||||
// If we will fill the buffer we need to make it bigger
|
// If we will fill the buffer we need to make it bigger
|
||||||
if( count + 1 >= buf.length )
|
if( count + 1 >= buf.length )
|
||||||
buf.resize( buf.length * 2 );
|
{
|
||||||
|
unsigned int newSize = buf.length * 2;
|
||||||
|
if( newSize <= buf.length )
|
||||||
|
return;
|
||||||
|
buf.resize( newSize );
|
||||||
|
}
|
||||||
|
|
||||||
buf[count] = (byte) b;
|
buf[count] = (byte) b;
|
||||||
count++;
|
count++;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public:
|
|||||||
void load(DataInput *dis, int tagDepth)
|
void load(DataInput *dis, int tagDepth)
|
||||||
{
|
{
|
||||||
int length = dis->readInt();
|
int length = dis->readInt();
|
||||||
|
|
||||||
|
if (length < 0 || length > 2 * 1024 * 1024) length = 0;
|
||||||
|
|
||||||
if ( data.data ) delete[] data.data;
|
if ( data.data ) delete[] data.data;
|
||||||
data = byteArray(length);
|
data = byteArray(length);
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ void ComplexItemDataPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
itemType = dis->readShort();
|
itemType = dis->readShort();
|
||||||
itemId = dis->readShort();
|
itemId = dis->readShort();
|
||||||
|
|
||||||
data = charArray(dis->readUnsignedShort() & 0xffff);
|
int dataLength = dis->readUnsignedShort() & 0xffff;
|
||||||
|
if(dataLength > 32767) dataLength = 0;
|
||||||
|
data = charArray(dataLength);
|
||||||
dis->readFully(data);
|
dis->readFully(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,12 @@ public:
|
|||||||
}
|
}
|
||||||
tags.clear();
|
tags.clear();
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
|
int tagCount = 0;
|
||||||
|
const int MAX_COMPOUND_TAGS = 10000;
|
||||||
while ((tag = Tag::readNamedTag(dis))->getId() != Tag::TAG_End)
|
while ((tag = Tag::readNamedTag(dis))->getId() != Tag::TAG_End)
|
||||||
{
|
{
|
||||||
tags[tag->getName()] = tag;
|
tags[tag->getName()] = tag;
|
||||||
|
if(++tagCount >= MAX_COMPOUND_TAGS) break;
|
||||||
}
|
}
|
||||||
delete tag;
|
delete tag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ Connection::Connection(Socket *socket, const wstring& id, PacketListener *packet
|
|||||||
const char *szId = wstringtofilename(id);
|
const char *szId = wstringtofilename(id);
|
||||||
char readThreadName[256];
|
char readThreadName[256];
|
||||||
char writeThreadName[256];
|
char writeThreadName[256];
|
||||||
sprintf(readThreadName,"%s read\n",szId);
|
sprintf(readThreadName, "%.240s read\n", szId);
|
||||||
sprintf(writeThreadName,"%s write\n",szId);
|
sprintf(writeThreadName, "%.240s write\n", szId);
|
||||||
|
|
||||||
readThread = new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE);
|
readThread = new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE);
|
||||||
writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE);
|
writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE);
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ void ContainerSetContentPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
{
|
{
|
||||||
containerId = dis->readByte();
|
containerId = dis->readByte();
|
||||||
int count = dis->readShort();
|
int count = dis->readShort();
|
||||||
|
|
||||||
|
if(count < 0 || count > 256) count = 0;
|
||||||
|
|
||||||
items = ItemInstanceArray(count);
|
items = ItemInstanceArray(count);
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void ContainerSetSlotPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
// 4J Stu - TU-1 hotfix
|
// 4J Stu - TU-1 hotfix
|
||||||
// Fix for #13142 - Holding down the A button on the furnace ingredient slot causes the UI to display incorrect item counts
|
// Fix for #13142 - Holding down the A button on the furnace ingredient slot causes the UI to display incorrect item counts
|
||||||
BYTE byteId = dis->readByte();
|
BYTE byteId = dis->readByte();
|
||||||
containerId = *(char *)&byteId;
|
containerId = (char)(signed char)byteId;
|
||||||
slot = dis->readShort();
|
slot = dis->readShort();
|
||||||
item = readItem(dis);
|
item = readItem(dis);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void CustomPayloadPacket::read(DataInputStream *dis)
|
|||||||
identifier = readUtf(dis, 20);
|
identifier = readUtf(dis, 20);
|
||||||
length = dis->readShort();
|
length = dis->readShort();
|
||||||
|
|
||||||
if (length > 0 && length < Short::MAX_VALUE)
|
if (length > 0 && length <= Short::MAX_VALUE)
|
||||||
{
|
{
|
||||||
if(data.data != NULL)
|
if(data.data != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -303,6 +303,10 @@ wstring DataInputStream::readUTF()
|
|||||||
int b = stream->read();
|
int b = stream->read();
|
||||||
unsigned short UTFLength = (unsigned short) (((a & 0xff) << 8) | (b & 0xff));
|
unsigned short UTFLength = (unsigned short) (((a & 0xff) << 8) | (b & 0xff));
|
||||||
|
|
||||||
|
const unsigned short MAX_UTF_LENGTH = 32767;
|
||||||
|
if( UTFLength > MAX_UTF_LENGTH )
|
||||||
|
return outputString;
|
||||||
|
|
||||||
//// 4J Stu - I decided while writing DataOutputStream that we didn't need to bother using the UTF8 format
|
//// 4J Stu - I decided while writing DataOutputStream that we didn't need to bother using the UTF8 format
|
||||||
//// used in the java libs, and just write in/out as wchar_t all the time
|
//// used in the java libs, and just write in/out as wchar_t all the time
|
||||||
|
|
||||||
|
|||||||
@@ -432,6 +432,28 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
|
|||||||
CompoundTag *DirectoryLevelStorage::load(shared_ptr<Player> player)
|
CompoundTag *DirectoryLevelStorage::load(shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
CompoundTag *tag = loadPlayerDataTag( player->getXuid() );
|
CompoundTag *tag = loadPlayerDataTag( player->getXuid() );
|
||||||
|
|
||||||
|
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||||
|
if (tag == NULL)
|
||||||
|
{
|
||||||
|
const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e;
|
||||||
|
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||||
|
{
|
||||||
|
PlayerUID oldXuid = WIN64_XUID_BASE + i;
|
||||||
|
tag = loadPlayerDataTag(oldXuid);
|
||||||
|
if (tag != NULL)
|
||||||
|
{
|
||||||
|
ConsoleSavePath oldFile = ConsoleSavePath(playerDir.getName() + _toString(oldXuid) + L".dat");
|
||||||
|
if (m_saveFile->doesFileExist(oldFile))
|
||||||
|
{
|
||||||
|
m_saveFile->deleteFile(m_saveFile->createFile(oldFile));
|
||||||
|
}
|
||||||
|
app.DebugPrintf("Migrated player data from old XUID %llu to new XUID %llu\n", oldXuid, player->getXuid());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (tag != NULL)
|
if (tag != NULL)
|
||||||
{
|
{
|
||||||
player->load(tag);
|
player->load(tag);
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ void ExplodePacket::read(DataInputStream *dis) //throws IOException
|
|||||||
r = dis->readFloat();
|
r = dis->readFloat();
|
||||||
int count = dis->readInt();
|
int count = dis->readInt();
|
||||||
|
|
||||||
|
if(count < 0 || count > 32768) count = 0;
|
||||||
|
|
||||||
int xp = (int)x;
|
int xp = (int)x;
|
||||||
int yp = (int)y;
|
int yp = (int)y;
|
||||||
int zp = (int)z;
|
int zp = (int)z;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void GameCommandPacket::read(DataInputStream *dis)
|
|||||||
command = (EGameCommand)dis->readInt();
|
command = (EGameCommand)dis->readInt();
|
||||||
length = dis->readShort();
|
length = dis->readShort();
|
||||||
|
|
||||||
if (length > 0 && length < Short::MAX_VALUE)
|
if (length > 0 && length <= Short::MAX_VALUE)
|
||||||
{
|
{
|
||||||
if(data.data != NULL)
|
if(data.data != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public:
|
|||||||
void load(DataInput *dis, int tagDepth)
|
void load(DataInput *dis, int tagDepth)
|
||||||
{
|
{
|
||||||
int length = dis->readInt();
|
int length = dis->readInt();
|
||||||
|
if (length < 0 || length > 65536) length = 0;
|
||||||
|
|
||||||
if ( data.data ) delete[] data.data;
|
if ( data.data ) delete[] data.data;
|
||||||
data = intArray(length);
|
data = intArray(length);
|
||||||
|
|||||||
@@ -1197,7 +1197,6 @@ void LevelChunk::addEntity(shared_ptr<Entity> e)
|
|||||||
int zc = Mth::floor(e->z / 16);
|
int zc = Mth::floor(e->z / 16);
|
||||||
if (xc != this->x || zc != this->z)
|
if (xc != this->x || zc != this->z)
|
||||||
{
|
{
|
||||||
app.DebugPrintf("Wrong location!");
|
|
||||||
// System.out.println("Wrong location! " + e);
|
// System.out.println("Wrong location! " + e);
|
||||||
// Thread.dumpStack();
|
// Thread.dumpStack();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,13 @@ public:
|
|||||||
}
|
}
|
||||||
type = dis->readByte();
|
type = dis->readByte();
|
||||||
int size = dis->readInt();
|
int size = dis->readInt();
|
||||||
|
if (size < 0 || size > 10000) size = 0;
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
Tag *tag = Tag::newTag(type, L"");
|
Tag *tag = Tag::newTag(type, L"");
|
||||||
|
if (tag == NULL) break;
|
||||||
tag->load(dis, tagDepth);
|
tag->load(dis, tagDepth);
|
||||||
list.push_back(tag);
|
list.push_back(tag);
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-17
@@ -268,7 +268,13 @@ void Packet::updatePacketStatsPIX()
|
|||||||
shared_ptr<Packet> Packet::getPacket(int id)
|
shared_ptr<Packet> Packet::getPacket(int id)
|
||||||
{
|
{
|
||||||
// 4J: Removed try/catch
|
// 4J: Removed try/catch
|
||||||
return idToCreateMap[id]();
|
#ifdef __PS3__
|
||||||
|
boost::unordered_map<int, packetCreateFn>::iterator it = idToCreateMap.find(id);
|
||||||
|
#else
|
||||||
|
auto it = idToCreateMap.find(id);
|
||||||
|
#endif
|
||||||
|
if (it == idToCreateMap.end()) return shared_ptr<Packet>();
|
||||||
|
return it->second();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Packet::writeBytes(DataOutputStream *dataoutputstream, byteArray bytes)
|
void Packet::writeBytes(DataOutputStream *dataoutputstream, byteArray bytes)
|
||||||
@@ -330,13 +336,12 @@ shared_ptr<Packet> Packet::readPacket(DataInputStream *dis, bool isServer) // th
|
|||||||
if ((isServer && serverReceivedPackets.find(id) == serverReceivedPackets.end()) || (!isServer && clientReceivedPackets.find(id) == clientReceivedPackets.end()))
|
if ((isServer && serverReceivedPackets.find(id) == serverReceivedPackets.end()) || (!isServer && clientReceivedPackets.find(id) == clientReceivedPackets.end()))
|
||||||
{
|
{
|
||||||
//app.DebugPrintf("Bad packet id %d\n", id);
|
//app.DebugPrintf("Bad packet id %d\n", id);
|
||||||
__debugbreak();
|
return nullptr;
|
||||||
assert(false);
|
|
||||||
// throw new IOException(wstring(L"Bad packet id ") + _toString<int>(id));
|
// throw new IOException(wstring(L"Bad packet id ") + _toString<int>(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
packet = getPacket(id);
|
packet = getPacket(id);
|
||||||
if (packet == NULL) assert(false);//throw new IOException(wstring(L"Bad packet id ") + _toString<int>(id));
|
if (packet == NULL) return nullptr;//throw new IOException(wstring(L"Bad packet id ") + _toString<int>(id));
|
||||||
|
|
||||||
//app.DebugPrintf("%s reading packet %d\n", isServer ? "Server" : "Client", packet->getId());
|
//app.DebugPrintf("%s reading packet %d\n", isServer ? "Server" : "Client", packet->getId());
|
||||||
packet->read(dis);
|
packet->read(dis);
|
||||||
@@ -394,17 +399,9 @@ wstring Packet::readUtf(DataInputStream *dis, int maxLength) // throws IOExcepti
|
|||||||
{
|
{
|
||||||
|
|
||||||
short stringLength = dis->readShort();
|
short stringLength = dis->readShort();
|
||||||
if (stringLength > maxLength)
|
if (stringLength > maxLength || stringLength < 0)
|
||||||
{
|
{
|
||||||
wstringstream stream;
|
return L"";
|
||||||
stream << L"Received string length longer than maximum allowed (" << stringLength << " > " << maxLength << ")";
|
|
||||||
assert(false);
|
|
||||||
// throw new IOException( stream.str() );
|
|
||||||
}
|
|
||||||
if (stringLength < 0)
|
|
||||||
{
|
|
||||||
assert(false);
|
|
||||||
// throw new IOException(L"Received string length is less than zero! Weird string!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring builder = L"";
|
wstring builder = L"";
|
||||||
@@ -507,7 +504,7 @@ shared_ptr<ItemInstance> Packet::readItem(DataInputStream *dis)
|
|||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> item = nullptr;
|
shared_ptr<ItemInstance> item = nullptr;
|
||||||
int id = dis->readShort();
|
int id = dis->readShort();
|
||||||
if (id >= 0)
|
if (id >= 0 && id < 32000) // validate against Item::ITEM_NUM_COUNT
|
||||||
{
|
{
|
||||||
int count = dis->readByte();
|
int count = dis->readByte();
|
||||||
int damage = dis->readShort();
|
int damage = dis->readShort();
|
||||||
@@ -545,9 +542,16 @@ void Packet::writeItem(shared_ptr<ItemInstance> item, DataOutputStream *dos)
|
|||||||
CompoundTag *Packet::readNbt(DataInputStream *dis)
|
CompoundTag *Packet::readNbt(DataInputStream *dis)
|
||||||
{
|
{
|
||||||
int size = dis->readShort();
|
int size = dis->readShort();
|
||||||
if (size < 0) return NULL;
|
if (size <= 0) return NULL;
|
||||||
|
|
||||||
|
const int MAX_NBT_SIZE = 32767;
|
||||||
|
if (size > MAX_NBT_SIZE) return NULL;
|
||||||
byteArray buff(size);
|
byteArray buff(size);
|
||||||
dis->readFully(buff);
|
if (!dis->readFully(buff))
|
||||||
|
{
|
||||||
|
delete [] buff.data;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
CompoundTag *result = (CompoundTag *) NbtIo::decompress(buff);
|
CompoundTag *result = (CompoundTag *) NbtIo::decompress(buff);
|
||||||
delete [] buff.data;
|
delete [] buff.data;
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ void PreLoginPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
m_friendsOnlyBits = dis->readByte();
|
m_friendsOnlyBits = dis->readByte();
|
||||||
m_ugcPlayersVersion = dis->readInt();
|
m_ugcPlayersVersion = dis->readInt();
|
||||||
m_dwPlayerCount = dis->readByte();
|
m_dwPlayerCount = dis->readByte();
|
||||||
|
if( m_dwPlayerCount > MINECRAFT_NET_MAX_PLAYERS ) m_dwPlayerCount = MINECRAFT_NET_MAX_PLAYERS;
|
||||||
if( m_dwPlayerCount > 0 )
|
if( m_dwPlayerCount > 0 )
|
||||||
{
|
{
|
||||||
m_playerXuids = new PlayerUID[m_dwPlayerCount];
|
m_playerXuids = new PlayerUID[m_dwPlayerCount];
|
||||||
@@ -74,6 +75,7 @@ void PreLoginPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
{
|
{
|
||||||
m_szUniqueSaveName[i]=dis->readByte();
|
m_szUniqueSaveName[i]=dis->readByte();
|
||||||
}
|
}
|
||||||
|
m_szUniqueSaveName[m_iSaveNameLen - 1] = 0;
|
||||||
m_serverSettings = dis->readInt();
|
m_serverSettings = dis->readInt();
|
||||||
m_hostIndex = dis->readByte();
|
m_hostIndex = dis->readByte();
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ RemoveEntitiesPacket::~RemoveEntitiesPacket()
|
|||||||
|
|
||||||
void RemoveEntitiesPacket::read(DataInputStream *dis) //throws IOException
|
void RemoveEntitiesPacket::read(DataInputStream *dis) //throws IOException
|
||||||
{
|
{
|
||||||
ids = intArray(dis->readByte());
|
int count = dis->readByte();
|
||||||
|
if(count < 0) count = 0;
|
||||||
|
ids = intArray(count);
|
||||||
for(unsigned int i = 0; i < ids.length; ++i)
|
for(unsigned int i = 0; i < ids.length; ++i)
|
||||||
{
|
{
|
||||||
ids[i] = dis->readInt();
|
ids[i] = dis->readInt();
|
||||||
|
|||||||
@@ -138,6 +138,11 @@ void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHos
|
|||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&m_queueLockNetwork[queueIdx]);
|
EnterCriticalSection(&m_queueLockNetwork[queueIdx]);
|
||||||
|
if(m_queueNetwork[queueIdx].size() + dwDataSize > 2 * 1024 * 1024)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&m_queueLockNetwork[queueIdx]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
for( unsigned int i = 0; i < dwDataSize; i++ )
|
for( unsigned int i = 0; i < dwDataSize; i++ )
|
||||||
{
|
{
|
||||||
m_queueNetwork[queueIdx].push(*pbData++);
|
m_queueNetwork[queueIdx].push(*pbData++);
|
||||||
|
|||||||
@@ -343,8 +343,10 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
|
|||||||
vector<shared_ptr<DataItem> > *result = NULL;
|
vector<shared_ptr<DataItem> > *result = NULL;
|
||||||
|
|
||||||
int currentHeader = input->readByte();
|
int currentHeader = input->readByte();
|
||||||
|
int itemCount = 0;
|
||||||
|
const int MAX_ENTITY_DATA_ITEMS = 256;
|
||||||
|
|
||||||
while (currentHeader != EOF_MARKER)
|
while (currentHeader != EOF_MARKER && itemCount < MAX_ENTITY_DATA_ITEMS)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
@@ -399,6 +401,7 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result->push_back(item);
|
result->push_back(item);
|
||||||
|
itemCount++;
|
||||||
|
|
||||||
currentHeader = input->readByte();
|
currentHeader = input->readByte();
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-5
@@ -84,27 +84,48 @@ Tag *Tag::readNamedTag(DataInput *dis)
|
|||||||
|
|
||||||
Tag *Tag::readNamedTag(DataInput *dis, int tagDepth)
|
Tag *Tag::readNamedTag(DataInput *dis, int tagDepth)
|
||||||
{
|
{
|
||||||
|
static __declspec(thread) int depth = 0;
|
||||||
|
static __declspec(thread) int totalTagCount = 0;
|
||||||
|
|
||||||
|
if (depth == 0)
|
||||||
|
totalTagCount = 0;
|
||||||
|
|
||||||
|
depth++;
|
||||||
|
|
||||||
|
if (depth > 256)
|
||||||
|
{
|
||||||
|
depth--;
|
||||||
|
return new EndTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
totalTagCount++;
|
||||||
|
const int MAX_TOTAL_TAGS = 32768;
|
||||||
|
if (totalTagCount > MAX_TOTAL_TAGS)
|
||||||
|
{
|
||||||
|
depth--;
|
||||||
|
return new EndTag();
|
||||||
|
}
|
||||||
|
|
||||||
byte type = dis->readByte();
|
byte type = dis->readByte();
|
||||||
if (type == 0) return new EndTag();
|
if (type == 0) { depth--; return new EndTag(); }
|
||||||
|
|
||||||
// 4J Stu - readByte can return -1, so if it's that then also mark as the end tag
|
// 4J Stu - readByte can return -1, so if it's that then also mark as the end tag
|
||||||
if(type == 255)
|
if(type == 255)
|
||||||
{
|
{
|
||||||
app.DebugPrintf("readNamedTag read a type of 255\n");
|
depth--;
|
||||||
#ifndef _CONTENT_PACKAGE
|
|
||||||
__debugbreak();
|
|
||||||
#endif
|
|
||||||
return new EndTag();
|
return new EndTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring name = dis->readUTF();//new String(bytes, "UTF-8");
|
wstring name = dis->readUTF();//new String(bytes, "UTF-8");
|
||||||
|
|
||||||
Tag *tag = newTag(type, name);
|
Tag *tag = newTag(type, name);
|
||||||
|
if (tag == NULL) { depth--; return new EndTag(); }
|
||||||
// short length = dis.readShort();
|
// short length = dis.readShort();
|
||||||
// byte[] bytes = new byte[length];
|
// byte[] bytes = new byte[length];
|
||||||
// dis.readFully(bytes);
|
// dis.readFully(bytes);
|
||||||
|
|
||||||
tag->load(dis, tagDepth);
|
tag->load(dis, tagDepth);
|
||||||
|
depth--;
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,16 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
{
|
{
|
||||||
textureName = dis->readUTF();
|
textureName = dis->readUTF();
|
||||||
dwSkinID = (DWORD)dis->readInt();
|
dwSkinID = (DWORD)dis->readInt();
|
||||||
dwTextureBytes = (DWORD)dis->readShort();
|
short rawTextureBytes = dis->readShort();
|
||||||
|
if(rawTextureBytes <= 0)
|
||||||
|
{
|
||||||
|
dwTextureBytes = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dwTextureBytes = (DWORD)(unsigned short)rawTextureBytes;
|
||||||
|
if(dwTextureBytes > 65536) dwTextureBytes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(dwTextureBytes>0)
|
if(dwTextureBytes>0)
|
||||||
{
|
{
|
||||||
@@ -136,7 +145,16 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
}
|
}
|
||||||
uiAnimOverrideBitmask = dis->readInt();
|
uiAnimOverrideBitmask = dis->readInt();
|
||||||
|
|
||||||
dwBoxC = (DWORD)dis->readShort();
|
short rawBoxC = dis->readShort();
|
||||||
|
if(rawBoxC <= 0)
|
||||||
|
{
|
||||||
|
dwBoxC = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dwBoxC = (DWORD)(unsigned short)rawBoxC;
|
||||||
|
if(dwBoxC > 256) dwBoxC = 0; // sane limit for skin boxes
|
||||||
|
}
|
||||||
|
|
||||||
if(dwBoxC>0)
|
if(dwBoxC>0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,16 +37,24 @@ void TexturePacket::handle(PacketListener *listener)
|
|||||||
void TexturePacket::read(DataInputStream *dis) //throws IOException
|
void TexturePacket::read(DataInputStream *dis) //throws IOException
|
||||||
{
|
{
|
||||||
textureName = dis->readUTF();
|
textureName = dis->readUTF();
|
||||||
dwBytes = (DWORD)dis->readShort();
|
short rawBytes = dis->readShort();
|
||||||
|
if(rawBytes <= 0)
|
||||||
if(dwBytes>0)
|
|
||||||
{
|
{
|
||||||
this->pbData= new BYTE [dwBytes];
|
dwBytes = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dwBytes = (DWORD)(unsigned short)rawBytes;
|
||||||
|
if(dwBytes > 65536)
|
||||||
|
{
|
||||||
|
dwBytes = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for(DWORD i=0;i<dwBytes;i++)
|
this->pbData= new BYTE [dwBytes];
|
||||||
{
|
|
||||||
this->pbData[i] = dis->readByte();
|
for(DWORD i=0;i<dwBytes;i++)
|
||||||
}
|
{
|
||||||
|
this->pbData[i] = dis->readByte();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void UpdateGameRuleProgressPacket::read(DataInputStream *dis) //throws IOExcepti
|
|||||||
m_dataTag = dis->readInt();
|
m_dataTag = dis->readInt();
|
||||||
int dataLength = dis->readInt();
|
int dataLength = dis->readInt();
|
||||||
|
|
||||||
if(dataLength > 0)
|
if(dataLength > 0 && dataLength <= 65536)
|
||||||
{
|
{
|
||||||
m_data = byteArray(dataLength);
|
m_data = byteArray(dataLength);
|
||||||
dis->readFully(m_data);
|
dis->readFully(m_data);
|
||||||
|
|||||||
@@ -196,9 +196,20 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
|
|||||||
unsigned int rleSize = staticRleSize;
|
unsigned int rleSize = staticRleSize;
|
||||||
unsigned char *dynamicRleBuf = NULL;
|
unsigned char *dynamicRleBuf = NULL;
|
||||||
|
|
||||||
if(*pDestSize > rleSize)
|
unsigned int safeRleSize = max(rleSize, *pDestSize);
|
||||||
|
|
||||||
|
const unsigned int MAX_RLE_ALLOC = 16 * 1024 * 1024; // 16 MB
|
||||||
|
if(safeRleSize > MAX_RLE_ALLOC)
|
||||||
{
|
{
|
||||||
rleSize = *pDestSize;
|
LeaveCriticalSection(&rleDecompressLock);
|
||||||
|
*pDestSize = 0;
|
||||||
|
// E_FAIL doesnt exist on PS3
|
||||||
|
return (HRESULT)0x80004005L;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(safeRleSize > staticRleSize)
|
||||||
|
{
|
||||||
|
rleSize = safeRleSize;
|
||||||
dynamicRleBuf = new unsigned char[rleSize];
|
dynamicRleBuf = new unsigned char[rleSize];
|
||||||
Decompress(dynamicRleBuf, &rleSize, pSource, SrcSize);
|
Decompress(dynamicRleBuf, &rleSize, pSource, SrcSize);
|
||||||
pucIn = (unsigned char *)dynamicRleBuf;
|
pucIn = (unsigned char *)dynamicRleBuf;
|
||||||
@@ -212,16 +223,19 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
|
|||||||
//unsigned char *pucIn = (unsigned char *)rleDecompressBuf;
|
//unsigned char *pucIn = (unsigned char *)rleDecompressBuf;
|
||||||
unsigned char *pucEnd = pucIn + rleSize;
|
unsigned char *pucEnd = pucIn + rleSize;
|
||||||
unsigned char *pucOut = (unsigned char *)pDestination;
|
unsigned char *pucOut = (unsigned char *)pDestination;
|
||||||
|
unsigned char *pucOutEnd = pucOut + *pDestSize;
|
||||||
|
|
||||||
while( pucIn != pucEnd )
|
while( pucIn != pucEnd )
|
||||||
{
|
{
|
||||||
unsigned char thisOne = *pucIn++;
|
unsigned char thisOne = *pucIn++;
|
||||||
if( thisOne == 255 )
|
if( thisOne == 255 )
|
||||||
{
|
{
|
||||||
|
if( pucIn >= pucEnd ) break;
|
||||||
unsigned int count = *pucIn++;
|
unsigned int count = *pucIn++;
|
||||||
if( count < 3 )
|
if( count < 3 )
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; }
|
||||||
for( unsigned int i = 0; i < count; i++ )
|
for( unsigned int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
*pucOut++ = 255;
|
*pucOut++ = 255;
|
||||||
@@ -230,7 +244,9 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
if( pucIn >= pucEnd ) break;
|
||||||
unsigned char data = *pucIn++;
|
unsigned char data = *pucIn++;
|
||||||
|
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; }
|
||||||
for( unsigned int i = 0; i < count; i++ )
|
for( unsigned int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
*pucOut++ = data;
|
*pucOut++ = data;
|
||||||
@@ -239,6 +255,7 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if( pucOut >= pucOutEnd ) break;
|
||||||
*pucOut++ = thisOne;
|
*pucOut++ = thisOne;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,16 +277,19 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
|
|||||||
unsigned char *pucIn = (unsigned char *)pSource;
|
unsigned char *pucIn = (unsigned char *)pSource;
|
||||||
unsigned char *pucEnd = pucIn + SrcSize;
|
unsigned char *pucEnd = pucIn + SrcSize;
|
||||||
unsigned char *pucOut = (unsigned char *)pDestination;
|
unsigned char *pucOut = (unsigned char *)pDestination;
|
||||||
|
unsigned char *pucOutEnd = pucOut + *pDestSize;
|
||||||
|
|
||||||
while( pucIn != pucEnd )
|
while( pucIn != pucEnd )
|
||||||
{
|
{
|
||||||
unsigned char thisOne = *pucIn++;
|
unsigned char thisOne = *pucIn++;
|
||||||
if( thisOne == 255 )
|
if( thisOne == 255 )
|
||||||
{
|
{
|
||||||
|
if( pucIn >= pucEnd ) break;
|
||||||
unsigned int count = *pucIn++;
|
unsigned int count = *pucIn++;
|
||||||
if( count < 3 )
|
if( count < 3 )
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; }
|
||||||
for( unsigned int i = 0; i < count; i++ )
|
for( unsigned int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
*pucOut++ = 255;
|
*pucOut++ = 255;
|
||||||
@@ -278,7 +298,9 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
if( pucIn >= pucEnd ) break;
|
||||||
unsigned char data = *pucIn++;
|
unsigned char data = *pucIn++;
|
||||||
|
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; }
|
||||||
for( unsigned int i = 0; i < count; i++ )
|
for( unsigned int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
*pucOut++ = data;
|
*pucOut++ = data;
|
||||||
@@ -287,6 +309,7 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if( pucOut >= pucOutEnd ) break;
|
||||||
*pucOut++ = thisOne;
|
*pucOut++ = thisOne;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,6 +249,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal);
|
void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal);
|
||||||
|
char GetUsername();
|
||||||
|
PlayerUID Win64_UsernameToXuid(const char* username);
|
||||||
|
PlayerUID Win64_UsernameToXuid(const wchar_t* username);
|
||||||
|
|
||||||
const int QNET_GETSENDQUEUESIZE_SECONDARY_TYPE = 0;
|
const int QNET_GETSENDQUEUESIZE_SECONDARY_TYPE = 0;
|
||||||
const int QNET_GETSENDQUEUESIZE_MESSAGES = 0;
|
const int QNET_GETSENDQUEUESIZE_MESSAGES = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user