forked from cafeberry/cafeberry
added 360 support and fixed vita again again
This commit is contained in:
@@ -379,6 +379,17 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame,
|
||||
if (!NetworkSocketLayer::IsActive())
|
||||
NetworkSocketLayer::HostGame(port);
|
||||
|
||||
//Fall back to the local name.
|
||||
if (IQNet::m_player[0].m_gamertag[0] == 0)
|
||||
{
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft != NULL && pMinecraft->user != NULL)
|
||||
{
|
||||
wcsncpy(IQNet::m_player[0].m_gamertag, pMinecraft->user->name.c_str(), 31);
|
||||
IQNet::m_player[0].m_gamertag[31] = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
const wchar_t *hostName = IQNet::m_player[0].m_gamertag;
|
||||
unsigned int settings = app.GetGameHostOption(eGameHostOption_All);
|
||||
NetworkSocketLayer::StartAdvertising(port, hostName, settings, 0, 0, MINECRAFT_NET_VERSION);
|
||||
@@ -731,19 +742,47 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||
delete friendsSessions[0][i];
|
||||
friendsSessions[0].clear();
|
||||
std::vector<FriendSessionInfo *> updatedSessions;
|
||||
|
||||
for (size_t i = 0; i < lanSessions.size(); i++)
|
||||
{
|
||||
FriendSessionInfo *info = new FriendSessionInfo();
|
||||
size_t nameLen = wcslen(lanSessions[i].hostName);
|
||||
info->displayLabel = new wchar_t[nameLen + 1];
|
||||
wcsncpy(info->displayLabel, lanSessions[i].hostName, nameLen);
|
||||
info->displayLabel[nameLen] = L'\0';
|
||||
info->displayLabelLength = (unsigned char)nameLen;
|
||||
info->displayLabelViewableStartIndex = 0;
|
||||
#if defined(__ORBIS__) || defined(__PSVITA__)
|
||||
SceNetInAddr ip_addr = {};
|
||||
sceNetInetPton(SCE_NET_AF_INET, lanSessions[i].hostIP, &ip_addr);
|
||||
SessionID sessionId = (ULONGLONG)((uint64_t)ip_addr.s_addr | ((uint64_t)lanSessions[i].hostPort << 32));
|
||||
#else
|
||||
SessionID sessionId = (ULONGLONG)((unsigned __int64)inet_addr(lanSessions[i].hostIP) | ((unsigned __int64)lanSessions[i].hostPort << 32));
|
||||
#endif
|
||||
|
||||
FriendSessionInfo *info = NULL;
|
||||
for (size_t j = 0; j < friendsSessions[0].size(); j++)
|
||||
{
|
||||
if (friendsSessions[0][j] != NULL && friendsSessions[0][j]->sessionId == sessionId)
|
||||
{
|
||||
info = friendsSessions[0][j];
|
||||
friendsSessions[0][j] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (info == NULL)
|
||||
info = new FriendSessionInfo();
|
||||
|
||||
info->sessionId = sessionId;
|
||||
|
||||
// Only reallocate the label when the name actually changed, so it stays put as well
|
||||
if (info->displayLabel == NULL || wcscmp(info->displayLabel, lanSessions[i].hostName) != 0)
|
||||
{
|
||||
size_t nameLen = wcslen(lanSessions[i].hostName);
|
||||
wchar_t *newLabel = new wchar_t[nameLen + 1];
|
||||
wcsncpy(newLabel, lanSessions[i].hostName, nameLen);
|
||||
newLabel[nameLen] = L'\0';
|
||||
|
||||
delete [] info->displayLabel;
|
||||
info->displayLabel = newLabel;
|
||||
info->displayLabelLength = (unsigned char)nameLen;
|
||||
info->displayLabelViewableStartIndex = 0;
|
||||
}
|
||||
|
||||
info->data.netVersion = lanSessions[i].netVersion;
|
||||
info->data.m_uiGameHostSettings = lanSessions[i].gameHostSettings;
|
||||
@@ -770,16 +809,14 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__ORBIS__) || defined(__PSVITA__)
|
||||
SceNetInAddr ip_addr = {};
|
||||
sceNetInetPton(SCE_NET_AF_INET, lanSessions[i].hostIP, &ip_addr);
|
||||
info->sessionId = (ULONGLONG)((uint64_t)ip_addr.s_addr | ((uint64_t)lanSessions[i].hostPort << 32));
|
||||
#else
|
||||
info->sessionId = (ULONGLONG)((unsigned __int64)inet_addr(lanSessions[i].hostIP) | ((unsigned __int64)lanSessions[i].hostPort << 32));
|
||||
#endif
|
||||
friendsSessions[0].push_back(info);
|
||||
updatedSessions.push_back(info);
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < friendsSessions[0].size(); j++)
|
||||
delete friendsSessions[0][j];
|
||||
|
||||
friendsSessions[0] = updatedSessions;
|
||||
|
||||
m_searchResultsCount[0] = (int)friendsSessions[0].size();
|
||||
|
||||
if (m_SessionsUpdatedCallback != NULL)
|
||||
@@ -820,6 +857,7 @@ bool CPlatformNetworkManagerStub::GetGameSessionInfo(int iPad, SessionID session
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam )
|
||||
|
||||
Reference in New Issue
Block a user