forked from cafeberry/cafeberry
Xbox 360 fixes (again...) (#29)
Merging main repo undid a lot of my changes so this PR reimplements them. Fixes build and playthrough. Has been tested.Reviewed-on: pieeebot/cafeberry#29 Co-authored-by: qloak <realminecart@gmail.com>
This commit is contained in:
1 parent
ebbd54288b
commit
125819419f
6 files changed
+368
-135
No files matched your search
@@ -486,31 +486,41 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
XNDNS *pDns = NULL;
|
||||
int iResult = XNetDnsLookup(ip, NULL, &pDns);
|
||||
if (iResult != 0 || pDns == NULL)
|
||||
{
|
||||
app.DebugPrintf("XNetDnsLookup failed for %s - %d\n", ip, iResult);
|
||||
return false;
|
||||
}
|
||||
|
||||
while (pDns->iStatus == WSAEINPROGRESS)
|
||||
{
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
if (pDns->iStatus != 0 || pDns->cina == 0)
|
||||
{
|
||||
app.DebugPrintf("pDns->iStatus failed for %s - %d\n", ip, iResult);
|
||||
XNetDnsRelease(pDns);
|
||||
return false;
|
||||
}
|
||||
|
||||
int iResult = 0;
|
||||
struct sockaddr_in addr = {};
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons((WORD)port);
|
||||
addr.sin_addr = pDns->aina[0];
|
||||
XNetDnsRelease(pDns);
|
||||
|
||||
unsigned long ipAddr = inet_addr(ip);
|
||||
if (ipAddr != INADDR_NONE)
|
||||
{
|
||||
addr.sin_addr.s_addr = ipAddr;
|
||||
}
|
||||
else
|
||||
{
|
||||
XNDNS *pDns = NULL;
|
||||
iResult = XNetDnsLookup(ip, NULL, &pDns);
|
||||
if (iResult != 0 || pDns == NULL)
|
||||
{
|
||||
app.DebugPrintf("XNetDnsLookup failed for %s - %d\n", ip, iResult);
|
||||
return false;
|
||||
}
|
||||
|
||||
while (pDns->iStatus == WSAEINPROGRESS)
|
||||
{
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
if (pDns->iStatus != 0 || pDns->cina == 0)
|
||||
{
|
||||
app.DebugPrintf("pDns->iStatus failed for %s - %d\n", ip, iResult);
|
||||
XNetDnsRelease(pDns);
|
||||
return false;
|
||||
}
|
||||
|
||||
addr.sin_addr = pDns->aina[0];
|
||||
XNetDnsRelease(pDns);
|
||||
}
|
||||
|
||||
bool connected = false;
|
||||
BYTE assignedSmallId = 0;
|
||||
@@ -935,7 +945,7 @@ int NetworkSocketLayer::AcceptThreadProc(LPVOID param)
|
||||
setsockopt(clientSocket, IPPROTO_TCP, TCP_NODELAY, (const char *)&noDelay, sizeof(noDelay));
|
||||
|
||||
extern QNET_STATE _iQNetStubState;
|
||||
if (_iQNetStubState != QNET_STATE_GAME_PLAY)
|
||||
if (_iQNetStubState != QNET_STATE_GAME_PLAY && _iQNetStubState != QNET_STATE_SESSION_STARTING)
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Rejecting connection, game not ready\n");
|
||||
closesocket(clientSocket);
|
||||
@@ -1260,7 +1270,8 @@ void NetworkSocketLayer::UpdateAdvertisePlayerNames(BYTE count, const char playe
|
||||
s_advertiseData.playerCount = count;
|
||||
for (int i = 0; i < count && i < 8; i++)
|
||||
{
|
||||
memcpy(s_advertiseData.playerNames[i], playerNames[i], XUSER_NAME_SIZE);
|
||||
memcpy(s_advertiseData.playerNames[i], playerNames[i],
|
||||
NETWORK_LAN_PLAYER_NAME_SIZE < (int)XUSER_NAME_SIZE ? NETWORK_LAN_PLAYER_NAME_SIZE : (int)XUSER_NAME_SIZE);
|
||||
}
|
||||
LeaveCriticalSection(&s_advertiseLock);
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ typedef SceNetSocklen_t socklen_t;
|
||||
|
||||
class Socket;
|
||||
|
||||
#define NETWORK_LAN_PLAYER_NAME_SIZE 32
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct LANBroadcast
|
||||
{
|
||||
@@ -113,7 +115,7 @@ struct LANBroadcast
|
||||
DWORD texturePackParentId;
|
||||
BYTE subTexturePackId;
|
||||
BYTE isJoinable;
|
||||
char playerNames[8][XUSER_NAME_SIZE];
|
||||
char playerNames[8][NETWORK_LAN_PLAYER_NAME_SIZE];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
@@ -130,7 +132,7 @@ struct LANSession
|
||||
unsigned char subTexturePackId;
|
||||
bool isJoinable;
|
||||
DWORD lastSeenTick;
|
||||
char playerNames[8][XUSER_NAME_SIZE];
|
||||
char playerNames[8][NETWORK_LAN_PLAYER_NAME_SIZE];
|
||||
};
|
||||
|
||||
struct RemoteConnection
|
||||
|
||||
@@ -12,6 +12,9 @@ CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
||||
|
||||
void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer )
|
||||
{
|
||||
if (getNetworkPlayer(pQNetPlayer) != NULL)
|
||||
return;
|
||||
|
||||
const char * pszDescription;
|
||||
|
||||
// 4J Stu - We create a fake socket for every where that we need an INBOUND queue of game data. Outbound
|
||||
@@ -164,6 +167,8 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa
|
||||
playerChangedCallback[ i ] = NULL;
|
||||
}
|
||||
|
||||
NetworkSocketLayer::Initialize();
|
||||
|
||||
m_bLeavingGame = false;
|
||||
m_bLeaveGameOnTick = false;
|
||||
m_bHostChanged = false;
|
||||
@@ -373,6 +378,9 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame,
|
||||
IQNet::m_player[0].m_isHostPlayer = true;
|
||||
IQNet::s_playerCount = 1;
|
||||
|
||||
if (getNetworkPlayer(&IQNet::m_player[0]) == NULL)
|
||||
NotifyPlayerJoined(&IQNet::m_player[0]);
|
||||
|
||||
_HostGame( localUsersMask, publicSlots, privateSlots );
|
||||
|
||||
int port = NETWORK_LAN_DEFAULT_PORT;
|
||||
@@ -413,6 +421,7 @@ int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo *searchResult, int l
|
||||
IQNet::m_player[0].m_isRemote = true;
|
||||
IQNet::m_player[0].m_isHostPlayer = true;
|
||||
wcsncpy(IQNet::m_player[0].m_gamertag, searchResult->data.hostName, 31);
|
||||
IQNet::m_player[0].m_gamertag[31] = L'\0';
|
||||
|
||||
NetworkSocketLayer::StopDiscovery();
|
||||
|
||||
@@ -435,8 +444,6 @@ int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo *searchResult, int l
|
||||
NotifyPlayerJoined(&IQNet::m_player[0]);
|
||||
NotifyPlayerJoined(&IQNet::m_player[localSmallId]);
|
||||
|
||||
m_pGameNetworkManager->StateChange_AnyToStarting();
|
||||
|
||||
return CGameNetworkManager::JOINGAME_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -495,6 +502,18 @@ bool CPlatformNetworkManagerStub::_RunNetworkGame()
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::SetGamePlayState()
|
||||
{
|
||||
extern QNET_STATE _iQNetStubState;
|
||||
|
||||
_iQNetStubState = QNET_STATE_GAME_PLAY;
|
||||
|
||||
if (m_pIQNet->IsHost())
|
||||
{
|
||||
NetworkSocketLayer::UpdateAdvertiseJoinable(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/)
|
||||
{
|
||||
if (this->m_bLeavingGame)
|
||||
@@ -801,7 +820,22 @@ vector<FriendSessionInfo *> *CPlatformNetworkManagerStub::GetSessionList(int iPa
|
||||
{
|
||||
vector<FriendSessionInfo *> *filteredList = new vector<FriendSessionInfo *>();
|
||||
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||
filteredList->push_back(friendsSessions[0][i]);
|
||||
{
|
||||
FriendSessionInfo *src = friendsSessions[0][i];
|
||||
FriendSessionInfo *copy = new FriendSessionInfo();
|
||||
*copy = *src;
|
||||
if (src->displayLabel != NULL)
|
||||
{
|
||||
copy->displayLabel = new wchar_t[(size_t)src->displayLabelLength + 1];
|
||||
wcsncpy(copy->displayLabel, src->displayLabel, src->displayLabelLength);
|
||||
copy->displayLabel[src->displayLabelLength] = L'\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
copy->displayLabel = NULL;
|
||||
}
|
||||
filteredList->push_back(copy);
|
||||
}
|
||||
return filteredList;
|
||||
}
|
||||
|
||||
@@ -861,9 +895,11 @@ void CPlatformNetworkManagerStub::removeNetworkPlayer(IQNetPlayer *pQNetPlayer)
|
||||
if( *it == pNetworkPlayer )
|
||||
{
|
||||
currentNetworkPlayers.erase(it);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pQNetPlayer->SetCustomDataValue(0);
|
||||
}
|
||||
|
||||
INetworkPlayer *CPlatformNetworkManagerStub::getNetworkPlayer(IQNetPlayer *pQNetPlayer)
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
|
||||
virtual void HandleSignInChange();
|
||||
|
||||
virtual void SetGamePlayState();
|
||||
virtual bool _RunNetworkGame();
|
||||
|
||||
private:
|
||||
|
||||
Reference in new issue
Block a user